forked from kscience/kmath
threads setting
This commit is contained in:
parent
e17fe32ae2
commit
cadcb9916f
@ -10,17 +10,25 @@ public class JNoa {
|
|||||||
static {
|
static {
|
||||||
String jNoaPath = System.getProperty("user.home") +
|
String jNoaPath = System.getProperty("user.home") +
|
||||||
"/devspace/noa/cmake-build-release/kmath/libjnoa.so";
|
"/devspace/noa/cmake-build-release/kmath/libjnoa.so";
|
||||||
//"/.konan/third-party/kmath-noa-0.3.0-dev-14/cpp-build/kmath/libjnoa.so";
|
//"/.konan/third-party/kmath-noa-0.3.0-dev-14/cpp-build/kmath/libjnoa.so";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
System.load(jNoaPath);
|
System.load(jNoaPath);
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
System.err.println("Failed to load native NOA library from:\n" +
|
System.err.println("Failed to load native NOA library from:\n" +
|
||||||
jNoaPath +"\n" + e);
|
jNoaPath + "\n" + e);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static native int testException(int seed);
|
public static native int testException(int seed);
|
||||||
|
|
||||||
public static native boolean cudaIsAvailable();
|
public static native boolean cudaIsAvailable();
|
||||||
|
|
||||||
|
public static native int getNumThreads();
|
||||||
|
|
||||||
|
public static native void setNumThreads(int numThreads);
|
||||||
|
|
||||||
|
public static native void setSeed(int seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,3 +8,15 @@ package space.kscience.kmath.noa
|
|||||||
public fun cudaAvailable(): Boolean {
|
public fun cudaAvailable(): Boolean {
|
||||||
return JNoa.cudaIsAvailable()
|
return JNoa.cudaIsAvailable()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun getNumThreads(): Int {
|
||||||
|
return JNoa.getNumThreads()
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun setNumThreads(numThreads: Int): Unit {
|
||||||
|
JNoa.setNumThreads(numThreads)
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun setSeed(seed: Int): Unit {
|
||||||
|
JNoa.setSeed(seed)
|
||||||
|
}
|
||||||
|
@ -23,6 +23,30 @@ JNIEXPORT jint JNICALL Java_space_kscience_kmath_noa_JNoa_testException
|
|||||||
JNIEXPORT jboolean JNICALL Java_space_kscience_kmath_noa_JNoa_cudaIsAvailable
|
JNIEXPORT jboolean JNICALL Java_space_kscience_kmath_noa_JNoa_cudaIsAvailable
|
||||||
(JNIEnv *, jclass);
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: space_kscience_kmath_noa_JNoa
|
||||||
|
* Method: getNumThreads
|
||||||
|
* Signature: ()I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_space_kscience_kmath_noa_JNoa_getNumThreads
|
||||||
|
(JNIEnv *, jclass);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: space_kscience_kmath_noa_JNoa
|
||||||
|
* Method: setNumThreads
|
||||||
|
* Signature: (I)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_space_kscience_kmath_noa_JNoa_setNumThreads
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: space_kscience_kmath_noa_JNoa
|
||||||
|
* Method: setSeed
|
||||||
|
* Signature: (I)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_space_kscience_kmath_noa_JNoa_setSeed
|
||||||
|
(JNIEnv *, jclass, jint);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,4 +19,11 @@ class TestUtils {
|
|||||||
}
|
}
|
||||||
assertEquals(i, 10)
|
assertEquals(i, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun settingNumThreads(){
|
||||||
|
val numThreads = 2
|
||||||
|
setNumThreads(numThreads)
|
||||||
|
assertEquals(numThreads, getNumThreads())
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user