From 62a025439b7775c327c3efef57d1b2df32a35885 Mon Sep 17 00:00:00 2001 From: raver119 Date: Wed, 7 Aug 2019 21:36:27 +0300 Subject: [PATCH] java cuda compilation fix Signed-off-by: raver119 --- libnd4j/blas/CMakeLists.txt | 2 +- .../linalg/jcublas/JCublasNDArrayFactory.java | 20 +++++++++---------- .../java/org/nd4j/nativeblas/Nd4jCuda.java | 11 ++++++++-- .../java/org/nd4j/nativeblas/Nd4jCpu.java | 11 ++++++++-- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/libnd4j/blas/CMakeLists.txt b/libnd4j/blas/CMakeLists.txt index dfa136ed7..2e3c51091 100755 --- a/libnd4j/blas/CMakeLists.txt +++ b/libnd4j/blas/CMakeLists.txt @@ -168,7 +168,7 @@ if(CUDA_BLAS) list(APPEND CUDA_NVCC_FLAGS -DCUDA_10 ${EXPM} -w --cudart=static -O3 --expt-extended-lambda -gencode arch=compute_35,code=sm_35 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_70,code=sm_70) endif() else() - list(APPEND CUDA_NVCC_FLAGS -DCUDA_10 ${EXPM} -w --cudart=static --expt-extended-lambda -O3 -arch=compute_${COMPUTE} -code=sm_${COMPUTE}) + list(APPEND CUDA_NVCC_FLAGS -DCUDA_10 ${EXPM} -w --cudart=static --expt-extended-lambda -O3 -Xfatbin -compress-all -arch=compute_${COMPUTE} -code=sm_${COMPUTE}) endif() elseif(CUDA_VERSION VERSION_GREATER "8.0") # cuda 9 if ("${COMPUTE}" STREQUAL "all") diff --git a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/JCublasNDArrayFactory.java b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/JCublasNDArrayFactory.java index 45ca51a39..b0db6ec50 100644 --- a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/JCublasNDArrayFactory.java +++ b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/linalg/jcublas/JCublasNDArrayFactory.java @@ -280,27 +280,27 @@ public class JCublasNDArrayFactory extends BaseNativeNDArrayFactory { @Override public INDArray create(long[] data, long[] shape, long[] stride, char order, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, order, dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, order, dataType); } @Override public INDArray create(int[] data, long[] shape, long[] stride, char order, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, order, dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, order, dataType); } @Override public INDArray create(short[] data, long[] shape, long[] stride, char order, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, order, dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, order, dataType); } @Override public INDArray create(byte[] data, long[] shape, long[] stride, char order, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, order, dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, order, dataType); } @Override public INDArray create(boolean[] data, long[] shape, long[] stride, char order, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, order, dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, order, dataType); } @Override @@ -1593,27 +1593,27 @@ public class JCublasNDArrayFactory extends BaseNativeNDArrayFactory { @Override public INDArray create(long[] data, long[] shape, long[] stride, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, Nd4j.order(), dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, Nd4j.order(), dataType); } @Override public INDArray create(int[] data, long[] shape, long[] stride, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, Nd4j.order(), dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, Nd4j.order(), dataType); } @Override public INDArray create(short[] data, long[] shape, long[] stride, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, Nd4j.order(), dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, Nd4j.order(), dataType); } @Override public INDArray create(byte[] data, long[] shape, long[] stride, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, Nd4j.order(), dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, Nd4j.order(), dataType); } @Override public INDArray create(boolean[] data, long[] shape, long[] stride, DataType dataType, MemoryWorkspace workspace) { - return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType, workspace), shape, stride, Nd4j.order(), dataType); + return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride, Nd4j.order(), dataType); } @Override diff --git a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/nativeblas/Nd4jCuda.java b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/nativeblas/Nd4jCuda.java index b9fd2a4c6..bc33b9e55 100644 --- a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/nativeblas/Nd4jCuda.java +++ b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/nativeblas/Nd4jCuda.java @@ -3814,9 +3814,12 @@ public native @Cast("char*") String runFullBenchmarkSuit(@Cast("bool") boolean p public native void syncToDevice(); public native void syncShape(); -// #ifndef __JAVACPP_HACK__ + /** + * This method can be used on architectures that use special buffers + * @param writeList + * @param readList + */ -// #endif /** * This method returns buffer pointer offset by given number of elements, wrt own data type @@ -5107,12 +5110,16 @@ NDArray& NDArray::operator()(const Nd4jLong* idx) { //////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// + + // #ifndef __JAVACPP_HACK__ // #endif diff --git a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/nativeblas/Nd4jCpu.java b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/nativeblas/Nd4jCpu.java index 9d6292106..5e2a4e296 100644 --- a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/nativeblas/Nd4jCpu.java +++ b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/nativeblas/Nd4jCpu.java @@ -3814,9 +3814,12 @@ public native @Cast("char*") String runFullBenchmarkSuit(@Cast("bool") boolean p public native void syncToDevice(); public native void syncShape(); -// #ifndef __JAVACPP_HACK__ + /** + * This method can be used on architectures that use special buffers + * @param writeList + * @param readList + */ -// #endif /** * This method returns buffer pointer offset by given number of elements, wrt own data type @@ -5107,12 +5110,16 @@ NDArray& NDArray::operator()(const Nd4jLong* idx) { //////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// + + // #ifndef __JAVACPP_HACK__ // #endif