File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed
src/main/java/com/github/TannerLow/JavaMatrixMath Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -3,20 +3,14 @@ plugins {
33}
44
55group ' com.github.TannerLow'
6- version ' 0.2 '
6+ version ' 0.3 '
77description ' Matrix Library with GPU compatibility.'
88
99repositories {
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-
2014dependencies {
2115 testImplementation ' org.junit.jupiter:junit-jupiter-api:5.8.1'
2216 testRuntimeOnly ' org.junit.jupiter:junit-jupiter-engine:5.8.1'
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments