forked from kscience/kmath
testing native exceptions
This commit is contained in:
parent
8e4f7ffce6
commit
cd362c749e
@ -42,8 +42,10 @@ val generateJNIHeader by tasks.registering {
|
||||
doLast {
|
||||
exec {
|
||||
workingDir(projectDir.resolve("src/main/java/space/kscience/kmath/noa"))
|
||||
commandLine("$javaHome/bin/javac", "-h",
|
||||
projectDir.resolve("src/main/resources") , "JNoa.java")
|
||||
commandLine(
|
||||
"$javaHome/bin/javac", "-h",
|
||||
projectDir.resolve("src/main/resources"), "JNoa.java"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -78,12 +80,17 @@ val downloadTorch by tasks.registering(Download::class) {
|
||||
overwrite(false)
|
||||
}
|
||||
|
||||
val downloadJNoa by tasks.registering(Download::class) {
|
||||
fun downloadJNoaHelper(update: Boolean) = tasks.registering(Download::class) {
|
||||
src("https://github.com/grinisrit/noa/archive/refs/heads/kmath.zip")
|
||||
dest(File("$thirdPartyDir/jnoa", "kmath.zip"))
|
||||
overwrite(false)
|
||||
overwrite(update)
|
||||
}
|
||||
|
||||
val downloadJNoa by downloadJNoaHelper(false)
|
||||
|
||||
val reDownloadJNoa by downloadJNoaHelper(true)
|
||||
|
||||
|
||||
val extractCMake by tasks.registering(Copy::class) {
|
||||
dependsOn(downloadCMake)
|
||||
from(tarTree(resources.gzip(downloadCMake.get().dest)))
|
||||
@ -144,7 +151,7 @@ val configureCpp by tasks.registering {
|
||||
"-DJAVA_HOME=$javaHome",
|
||||
"-DBUILD_NOA_KMATH=ON",
|
||||
"-DCMAKE_BUILD_TYPE=Release",
|
||||
"-DBUILD_NOA_CUDA=${if(!cudaFound) "ON" else "OFF"}",
|
||||
"-DBUILD_NOA_CUDA=${if (!cudaFound) "ON" else "OFF"}",
|
||||
"-DBUILD_NOA_TESTS=OFF",
|
||||
"-DBUILD_NOA_BENCHMARKS=OFF",
|
||||
"-DINSTALL_NOA=OFF"
|
||||
|
@ -20,5 +20,6 @@ public class JNoa {
|
||||
}
|
||||
}
|
||||
|
||||
public static native void testException();
|
||||
public static native boolean cudaIsAvailable();
|
||||
}
|
||||
|
@ -7,6 +7,14 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: space_kscience_kmath_noa_JNoa
|
||||
* Method: testException
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_space_kscience_kmath_noa_JNoa_testException
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: space_kscience_kmath_noa_JNoa
|
||||
* Method: cudaIsAvailable
|
||||
|
@ -10,12 +10,16 @@ import kotlin.test.Test
|
||||
class TestUtils {
|
||||
|
||||
@Test
|
||||
fun testExceptions() {
|
||||
fun throwingExceptions() {
|
||||
try {
|
||||
println(cudaAvailable())
|
||||
JNoa.testException()
|
||||
} catch(e:NoaException) {
|
||||
println(e)
|
||||
println("ALL GOOD")
|
||||
println("Caught NoaException in JVM\n:$e")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cudaSupport() {
|
||||
println("CUDA support available: ${cudaAvailable()}")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user