GithubHelp home page GithubHelp logo

adam- / jocl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gpu/jocl

0.0 2.0 0.0 691 KB

Java bindings for OpenCL

Home Page: http://www.jocl.org

License: Other

Java 74.43% C++ 25.36% CMake 0.21%

jocl's Introduction

JOCL

JOCL - Java Bindings for OpenCL - http://jocl.org

Maven Coordinates

JOCL is available in Maven Central under the following coordinates:

<dependency>
    <groupId>org.jocl</groupId>
    <artifactId>jocl</artifactId>
    <version>2.0.3</version>
</dependency>

Build instructions

In order to build JOCL, create a local working directory, e.g. C:\JOCLRoot, and clone the required repositories into this directory:

git clone https://github.com/gpu/JOCL.git
git clone https://github.com/gpu/JOCLCommon.git

Building the native libraries

The native libraries of JOCL can be built with CMake and any compatible target compiler (e.g. Visual Studio or GCC):

  • Start cmake-gui,
  • Set the directory containing the sources of the JOCL project, e.g. C:\JOCLRoot\JOCL
  • Set the directory for the build files: e.g. C:\JOCLRoot\JOCL.build
  • Press "Configure" (and select the appropriate compiler)
  • Press "Generate"

Then, C:\JOCLRoot\JOCL.build will contain the build files, e.g. the GCC makefiles or the Visual Studio project files. Compiling the project with these makefiles will place the binaries into a nativeLibraries subdirectory of the project, e.g. into C:\JOCLRoot\JOCL\nativeLibraries.

Building and packaging the external native library dependencies

JOCL itself does not have external dependencies, except for the run-time dependency to the OpenCL implementation. If you only want to compile JOCL, then you can skip this section.

This section only refers to libraries like JOCLBLAS and JOCLBlast, which require installations of external libraries (clBLAS and CLBlast, respectively). The following JOCLBlast and CLBlast, but the same process applies to all other external dependencies.

Compiling and installing CLBlast (as described in its documentation) will result in directories that contain the header files and the native libraries. In order to build JOCLBlast, the paths to these header directories and library files have to be entered in the CMake GUI, as the values of the CLBLAST_INSTALL_DIR and CLBlast_LIBRARY.

After this information has been entered, the JOCLBlast library may be compiled as described above, under Building the native libraries. The resulting native JOCLBlast library will be placed into the nativeLibraries directory of the project, for example, into C:\JOCLRoot\JOCLBlast\nativeLibraries

This library is dynamically linked against the actual CLBlast library. In order to be able to load this library, the CLBlast library must be in a specific subdirectory of the nativeLibraries folder. The name of this subdirectory is determined by the operating system and architecture that the library is compiled for. The general pattern here is

C:\JOCLRoot\JOCLBlast\nativeLibraries\OS\ARCHITECTURE

The OS here refers to the operating system, and will usually be windows, linux or apple. The ARCHITECTURE refers to the processor architecture of the target system, and will usually be x86 (for 32 bit system) or x86_64 (for 64 bit systems).

For example, on 64 bit Windows, the clblast.dll will have to be placed into the directory

C:\JOCLRoot\JOCLBlast\nativeLibraries\windows\x86_64\

There, it will be picked up by the Maven and integrated into the JAR, as described in the next section.

Building the Java libraries

The actual Java libraries can be built with Apache Maven. After the native libraries have been built as described above, change into the JOCL directory and execute

mvn clean install

This will compile the Java libraries, run the unit tests, assemble the classes (together with the native libraries), sources and JavaDocs into JAR files, and finally place all libraries into the
C:\JOCLRoot\JOCL\target directory.

Building for Android

Compiling native code for Android is a bit of a pain, so we use android-cmake to make our lives a bit easier. We first begin by installing the android-cmake toolchain file into our cmake modules path. On Linux, this is likely /usr/share/cmake-3.2/Modules/.

cd /usr/share/cmake-3.2/Modules
sudo wget https://github.com/taka-no-me/android-cmake/raw/master/android.toolchain.cmake

Next, we want to configure the build for our particular Android target.

cd JOCL
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=android.toolchain \
      -DANDROID_ABI=armeabi-v7a \
      -DANDROID_NATIVE_API_LEVEL=21 \
      -DCMAKE_BUILD_TYPE=Release \
      ..

This should be enough to get you started. For more advanced configuration, refer to the android-cmake documentation.

Finally, when building the final .jar file, we would like to avoid running the local tests, as the Android native libraries won't run on your local machine.

mvn clean install -DskipTests

Building on a virtual machine

Note: This section has to be updated. See issue 23.

JOCL for Linux can be built in a virtual machine using Vagrant. Lewis Cowles and Alex Zhukov have provided a Vagrantfile that contains the complete JOCL build in its provisioning script.

Preparing to build JOCL using Vagrant:

  • Install VirtualBox (tested with version 5.2.10)

  • Install Vagrant (tested with version 2.0.1)

  • Install the vagrant Virtual Box Guest additions plugin with

      vagrant plugin install vagrant-vbguest
    

Building JOCL using Vagrant:

Copy the Vagrantfile into a working directory and execute

vagrant up

The provisioning script will install all required packages, clone the latest state of JOCL from GitHub, build the native library using CMake and gcc, and the JARs using Maven.

The resulting JAR files will be placed in the working directory.

In order to remove the machine that has been created for building JOCL, execute

vagrant destroy 

jocl's People

Contributors

adam- avatar ashishnegi avatar dependabot[bot] avatar gpu avatar haesleinhuepf avatar llemonduck avatar phlip9 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.