Skip to content

Commit 37257e4

Browse files
committed
errors + 0.3 version bump
1 parent a8b209a commit 37257e4

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

build.gradle

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@ plugins {
33
}
44

55
group 'com.github.TannerLow'
6-
version '0.2'
6+
version '0.3'
77
description 'Matrix Library with GPU compatibility.'
88

99
repositories {
1010
mavenCentral()
1111
maven { url "https://jitpack.io" }
1212
}
1313

14-
//java {
15-
// sourceCompatibility = JavaVersion.VERSION_16
16-
// targetCompatibility = JavaVersion.VERSION_16
17-
//}
18-
19-
2014
dependencies {
2115
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
2216
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'

src/main/java/com/github/TannerLow/JavaMatrixMath/GPU.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ public void initialize(boolean automaticSelection) {
145145
isInitialized = true;
146146
}
147147

148-
public int loadProgram(String programCode) {
148+
public int loadProgram(String programCode) throws IllegalStateException {
149+
if(!isInitialized) {
150+
throw new IllegalStateException("GPU not yet initialized.");
151+
}
152+
149153
// Create the program from the source code
150154
cl_program program = clCreateProgramWithSource(context,
151155
1, new String[]{ programCode }, null, null);
@@ -208,8 +212,13 @@ public void close() {
208212
clReleaseProgram(program);
209213
}
210214

211-
clReleaseCommandQueue(commandQueue);
212-
clReleaseContext(context);
215+
if(commandQueue != null) {
216+
clReleaseCommandQueue(commandQueue);
217+
}
218+
219+
if(context != null) {
220+
clReleaseContext(context);
221+
}
213222
}
214223

215224
private static String getStringInfo(cl_platform_id platform, int paramName) {

0 commit comments

Comments
 (0)