zeratax / yacx

Yet Another CudaExecutor - wrapper to easily compile and execute cuda kernels
https://zeratax.github.io/yacx
MIT License
8 stars 4 forks source link

compile to .so #36

Closed LukasSiefke closed 4 years ago

LukasSiefke commented 4 years ago

Das geht auch schöner...

g++ -c -I"/usr/lib/jvm/java-1.8.0-openjdk-amd64/include" -I"/usr/lib/jvm/java-1.8.0-openjdk-amd64/include/linux" -I"/tmp/tmp.cTlciDtCIj/include" -fPIC -DNVRTC_GET_TYPE_NAME=1 -std=c++17 -Dcurrent_log_level=loglevel::DEBUG1 -c ../../src/*.cpp
g++ -c -I"/usr/lib/jvm/java-1.8.0-openjdk-amd64/include" -I"/usr/lib/jvm/java-1.8.0-openjdk-amd64/include/linux" -I"/tmp/tmp.cTlciDtCIj/include" -fPIC -DNVRTC_GET_TYPE_NAME=1 -std=c++17 -Dcurrent_log_level=loglevel::DEBUG1 -c ../../src/jni/*.cpp
g++ -I"/usr/lib/jvm/java-1.8.0-openjdk-amd64/include" -I"/usr/lib/jvm/java-1.8.0-openjdk-amd64/include/linux" -I"/tmp/tmp.cTlciDtCIj/include" -shared -o libcudaexecutor-jni.so base/*.o jni/*.o -lcuda -lnvrtc
zeratax commented 4 years ago

irg wie sowas

find_package(JNI REQUIRED)
add_library(jnitests SHARED ${SOURCES})

siehe https://github.com/thefangbear/JNI-By-Examples#finale-build

zeratax commented 4 years ago

man kann jetzt mit cmake das kompilieren, aber beim ausführen passen die pfade aber nicht mehr

$ cmake -H. -Bcmake-build-test -DCMAKE_BUILD_TYPE=Debug
-- JNI enabled
-- Testing enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/tmp.gVdfvJITP6/cmake-build-test
$ make -C cmake-build-test/ JExampleSaxpy
$ cd cmake-build-test/java/bin
$ java -ea -Djava.library.path=../../ ExampleSaxpy
Exception in thread "main" java.nio.file.NoSuchFileException: ../examples/kernels/saxpy.cu
    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
    at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:215)
    at java.base/java.nio.file.Files.newByteChannel(Files.java:370)
    at java.base/java.nio.file.Files.newByteChannel(Files.java:421)
    at java.base/java.nio.file.Files.readAllBytes(Files.java:3205)
    at Utils.loadFile(Utils.java:7)
    at ExampleSaxpy.main(ExampleSaxpy.java:32)

@LukasSiefke @Olliewer

Ich hab utils nach src/java bewegt dann konnte man das einfach kompilieren ohne alles zu kopieren zu müssen

zeratax commented 4 years ago

Hab noch nen script erstellt um es noch einfacher zumachen:

$ ./cudaexecutor.sh

cudaexecutor
Options: ./cudaexecutor.sh
--buildj             Tries CMake build
--execute-java       Tests library with java
--builds             Tries CMake build
--execute-scala      Tests library with scala

beschreibungen nicht so hilfreich, aber einmal baut es halt c + java und einmal c + java + scala hab euer scala zeug noch nicht gemerged ist also ungetestet.

$ ./cudaexecutor.sh --execute-scala ExampleSaxpy