Skip to content

Commit

Permalink
* Add presets for OpenCL 3.0 and enable OpenCL acceleration for DNNL…
Browse files Browse the repository at this point in the history
… (issue bytedeco#938)
  • Loading branch information
saudet authored and junlarsen committed Dec 23, 2020
1 parent 32f3fd0 commit 13a8e35
Show file tree
Hide file tree
Showing 186 changed files with 6,851 additions and 20 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/opencl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: opencl
on:
push:
paths:
- opencl/**
pull_request:
paths:
- opencl/**
workflow_dispatch:
env:
CI_DEPLOY_MODULE: ${{ github.workflow }}
CI_DEPLOY_PLATFORM: ${{ github.job }}
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
jobs:
linux-x86_64:
runs-on: ubuntu-16.04
container: centos:6
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions
macosx-x86_64:
runs-on: macos-10.15
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions
windows-x86_64:
runs-on: windows-2019
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions
redeploy:
needs: [linux-x86_64, macosx-x86_64, windows-x86_64]
runs-on: ubuntu-16.04
steps:
- uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

* Enable OpenCL acceleration for DNNL ([issue #938](https://github.com/bytedeco/javacpp-presets/issues/938))
* Introduce monkey patching when loading presets for CPython to relocate home more reliably
* Add display sample for librealsense2 ([pull #978](https://github.com/bytedeco/javacpp-presets/pull/978))
* Fix builds for libpostal on Mac and Windows ([issue #903](https://github.com/bytedeco/javacpp-presets/issues/903))
* Fix builds for NumPy and SciPy on Linux when using a cross compiler or not
* Update presets for Visual Studio 2019 on Windows
* Add presets for TVM 0.7.0 and bundle its official Java API (TVM4J) via the `jnitvm_runtime` library
* Add presets for OpenCL 3.0, TVM 0.7.0 and bundle its official Java API (TVM4J) via the `jnitvm_runtime` library
* Include `free()` in presets for FTTW as required by `fftw_export_wisdom_to_string()` ([issue bytedeco/javacpp#429](https://github.com/bytedeco/javacpp/issues/429))
* Include all missing header files from the `opencv_ximgproc` module ([issue #958](https://github.com/bytedeco/javacpp-presets/issues/958))
* Disable assembly optimizations for libx264 with FFmpeg on Mac to work around crashes ([issue bytedeco/javacv#1519](https://github.com/bytedeco/javacv/issues/1519))
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ JavaCPP Presets
 [![caffe](https://github.com/bytedeco/javacpp-presets/workflows/caffe/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Acaffe)
 [![openpose](https://github.com/bytedeco/javacpp-presets/workflows/openpose/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Aopenpose)
 [![cuda](https://github.com/bytedeco/javacpp-presets/workflows/cuda/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Acuda)
 [![opencl](https://github.com/bytedeco/javacpp-presets/workflows/opencl/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Aopencl)
 [![mxnet](https://github.com/bytedeco/javacpp-presets/workflows/mxnet/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Amxnet)
 [![tensorflow](https://github.com/bytedeco/javacpp-presets/workflows/tensorflow/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Atensorflow)
 [![tensorrt](https://github.com/bytedeco/javacpp-presets/workflows/tensorrt/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Atensorrt)
Expand Down Expand Up @@ -192,6 +193,7 @@ Each child module in turn relies by default on the included [`cppbuild.sh` scrip
* CUDA 11.1.x https://developer.nvidia.com/cuda-downloads
* cuDNN 8.0.x https://developer.nvidia.com/cudnn
* NCCL 2.7.x https://developer.nvidia.com/nccl
* OpenCL 3.0 https://github.com/KhronosGroup/OpenCL-ICD-Loader
* MXNet 1.7.0 https://github.com/apache/incubator-mxnet
* TensorFlow 1.15.x https://github.com/tensorflow/tensorflow
* TensorRT 7.x https://developer.nvidia.com/tensorrt
Expand Down
2 changes: 1 addition & 1 deletion cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function sedinplace {
}

if [[ -z ${PROJECTS:-} ]]; then
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 hyperscan mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe openpose cuda mxnet tensorflow tensorrt ale onnx ngraph onnxruntime tvm liquidfun qt skia cpu_features systems)
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 hyperscan mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe openpose cuda opencl mxnet tensorflow tensorrt ale onnx ngraph onnxruntime tvm liquidfun qt skia cpu_features systems)
fi

for PROJECT in ${PROJECTS[@]}; do
Expand Down
2 changes: 1 addition & 1 deletion dnnl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Sample Usage
------------
Here is a simple example of DNNL ported to Java from this C++ source file:

* https://github.com/intel/mkl-dnn/blob/master/examples/cpu_cnn_inference_int8.cpp
* https://github.com/intel/mkl-dnn/blob/master/examples/cpu_cnn_inference_int8.cpp

We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `CpuCnnInferenceInt8.java` source files below, simply execute on the command line:
```bash
Expand Down
23 changes: 22 additions & 1 deletion dnnl/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ mkdir -p $PLATFORM
cd $PLATFORM
mkdir -p include lib bin
INSTALL_PATH=`pwd`

OPENCL_PATH="$INSTALL_PATH/../../../opencl/cppbuild/$PLATFORM/"

if [[ -n "${BUILD_PATH:-}" ]]; then
PREVIFS="$IFS"
IFS="$BUILD_PATH_SEPARATOR"
for P in $BUILD_PATH; do
if [[ -f "$P/include/CL/cl.h" ]]; then
OPENCL_PATH="$P"
fi
done
IFS="$PREVIFS"
fi

OPENCL_PATH="${OPENCL_PATH//\\//}"

echo "Decompressing archives..."
tar --totals -xf ../oneTBB-$TBB_VERSION.tar.bz2
tar --totals -xf ../oneDNN-$MKLDNN_VERSION.tar.bz2
Expand All @@ -27,6 +43,11 @@ patch -Np1 < ../../../mkl-dnn.patch

sedinplace 's/-fvisibility=internal//g' cmake/platform.cmake
sedinplace 's/-fvisibility-inlines-hidden//g' cmake/platform.cmake
sedinplace 's:Headers/cl.h:CL/cl.h:g' cmake/FindOpenCL.cmake

if [[ -d "$OPENCL_PATH" ]]; then
export OPENCLROOT="$OPENCL_PATH"
fi

case $PLATFORM in
linux-x86_64)
Expand Down Expand Up @@ -83,7 +104,7 @@ case $PLATFORM in
cp -a build/*debug/tbb_debug.lib ../lib/intel64/vc14/
cd ../oneDNN-$MKLDNN_VERSION
fi
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" -DARCH_OPT_FLAGS='' -DMKLDNN_BUILD_EXAMPLES=OFF -DMKLDNN_BUILD_TESTS=OFF -DDNNL_CPU_RUNTIME=$DNNL_CPU_RUNTIME -DTBBROOT=$INSTALL_PATH .
"$CMAKE" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" -DARCH_OPT_FLAGS='' -DMKLDNN_BUILD_EXAMPLES=OFF -DMKLDNN_BUILD_TESTS=OFF -DDNNL_CPU_RUNTIME=$DNNL_CPU_RUNTIME -DTBBROOT=$INSTALL_PATH -DDNNL_GPU_RUNTIME=$DNNL_GPU_RUNTIME .
ninja -j $MAKEJ
ninja install
;;
Expand Down
5 changes: 5 additions & 0 deletions dnnl/platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
</properties>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencl-platform</artifactId>
<version>3.0-${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-platform</artifactId>
Expand Down
54 changes: 54 additions & 0 deletions dnnl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@
<version>1.7-${project.parent.version}</version>
<name>JavaCPP Presets for DNNL</name>

<properties>
<javacpp.nativeRequires>
requires org.bytedeco.opencl.${javacpp.platform.module};
</javacpp.nativeRequires>
</properties>

<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencl</artifactId>
<version>3.0-${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
Expand All @@ -32,6 +43,49 @@
<plugin>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>opencl-platform</artifactId>
<version>3.0-${project.parent.version}</version>
</dependency>
</dependencies>
<configuration>
<classPaths>
<classPath>${basedir}/../opencl/target/classes/</classPath>
<classPath>${project.build.outputDirectory}</classPath>
</classPaths>
<includePaths>
<includePath>${basedir}/../opencl/target/classes/org/bytedeco/opencl/include/</includePath>
<includePath>${basedir}/../opencl/src/main/resources/org/bytedeco/opencl/include/</includePath>
<includePath>${basedir}/../opencl/cppbuild/${javacpp.platform}/include/</includePath>
<includePath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/include/</includePath>
<includePath>${basedir}/target/classes/org/bytedeco/${javacpp.packageName}/include/</includePath>
</includePaths>
<linkPaths>
<linkPath>${basedir}/../opencl/cppbuild/${javacpp.platform}/lib/</linkPath>
<linkPath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/lib/</linkPath>
</linkPaths>
<preloadPaths>
<preloadPath>${basedir}/../opencl/cppbuild/${javacpp.platform}/bin/</preloadPath>
<preloadPath>${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/bin/</preloadPath>
</preloadPaths>
<buildResources>
<buildResource>/${javacpp.platform.library.path}/</buildResource>
<buildResource>/org/bytedeco/opencl/${javacpp.platform}/</buildResource>
</buildResources>
<includeResources>
<includeResource>/${javacpp.platform.library.path}/include/</includeResource>
<includeResource>/org/bytedeco/opencl/include/</includeResource>
<includeResource>/org/bytedeco/opencl/${javacpp.platform}/include/</includeResource>
</includeResources>
<linkResources>
<linkResource>/${javacpp.platform.library.path}/</linkResource>
<linkResource>/${javacpp.platform.library.path}/lib/</linkResource>
<linkResource>/org/bytedeco/opencl/${javacpp.platform}/</linkResource>
<linkResource>/org/bytedeco/opencl/${javacpp.platform}/lib/</linkResource>
</linkResources>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/IntMemoryMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/binary.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/concat.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/const_dnnl_op_desc_t.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/convolution_forward.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/dnnl_binary_desc_t.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/dnnl_blocking_desc_t.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/dnnl_eltwise_desc_t.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/dnnl_engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/dnnl_engine_handle.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
2 changes: 2 additions & 0 deletions dnnl/src/gen/java/org/bytedeco/dnnl/dnnl_exec_arg_t.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.bytedeco.javacpp.annotation.*;

import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.opencl.*;
import static org.bytedeco.opencl.global.OpenCL.*;

import static org.bytedeco.dnnl.global.dnnl.*;

Expand Down
Loading

0 comments on commit 13a8e35

Please sign in to comment.