|
Usage
How to use / install JavaCL
Featured PrequisitesOpenCL implementationThere are now quite a few OpenCL implementations out there (and they're all working fine with JavaCL) :
Note that ATI Stream's CPU implementation only supports images in version 2.4 (before, it will just crash your app !) Also note that you don't need to install Catalyst drivers or build anything from the APPSDK package : simply untar the package, set up your LD_LIBRARY_PATH and sudo-untar the ICD registration package.
Optional : OpenGL bindingsIf you want to share data between OpenCL and OpenGL, you'll need an OpenGL library such as JOGL or LWJGL. Lightweight Java Game Library (LWJGL)The excellent Lightweight Java Game Library (LWJGL) is a premier choice for OpenGL and OpenAL cross-platform programming in Java, providing a fast close-to-metal API. It can be installed in many various ways, including Maven. Jogamp JOGLAfter a long radio silence, fresh forces are injected again into JOGL (now hosted at jogamp.org), with even alternative OpenCL bindings. As the jogamp OpenGL bindings are still a bit uneasy to install, here's a simplified install procedure to get the latest version of JOGL :
/usr/lib/jvm/java-6-sun/jre/lib/ext/ /usr/lib/jvm/java-6-openjdk/jre/lib/ext/ So you might install JOGL like this (download included, shown here for i586 architecture) :cd /usr/lib/jvm/java-6-openjdk/jre/lib/ext/ sudo wget http://nativelibs4java.sourceforge.net/thirdparty/jogl/jogl-linux-i586-latest.zip sudo unzip jogl-linux*.zip sudo rm jogl-linux*.zip C:\Program Files\Java\jre-1.6.0\lib\ext ~/Library/Java/Extensions (the ~ is your user home directory ; you can create these directories if they don't exist, but make sure to do it in a Terminal, as there might be translations in the Finder, for instance ~/Library being visible as Bibliothèque in French) Use JavaCL in a projectWith MavenJavaCL and its plugin can be used with Maven, simply edit your pom.xml as follows : <project>
<dependencies>
<dependency>
<groupId>com.nativelibs4java</groupId>
<artifactId>javacl</artifactId>
<version>1.0.0-RC2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.nativelibs4java</groupId>
<artifactId>maven-javacl-plugin</artifactId>
<version>1.0.0-RC1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>If you wish to use a previous release (1.0.0-RC1, for instance) or a snapshot (1.0-SNAPSHOT), you'll need the following repositories : <project>
<repositories>
<repository>
<id>sonatype</id>
<name>Sonatype OSS Snapshots Repository</name>
<url>http://oss.sonatype.org/content/groups/public</url>
</repository>
<repository>
<id>nativelibs4java</id>
<name>nativelibs4java Maven2 Repository</name>
<url>http://nativelibs4java.sourceforge.net/maven</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>sonatype</id>
<name>Sonatype OSS Snapshots Repository</name>
<url>http://oss.sonatype.org/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
</project>Please read this wiki page for more information about JavaCL Generator. With sbt (simple-build-tool)Add these two lines to your project file : import sbt._
class MyProject(info: ProjectInfo) extends DefaultProject(info)
{
// Repository for snapshots :
// val sonatypeOSSRepo = "Sonatype OSS Repository" at "http://oss.sonatype.org/content/groups/public"
val javacl = "com.nativelibs4java" % "javacl" % "1.0.0-RC2"
}Raw downloadIf you're not using Maven, Gradle, sbt or any other build manager, you can proceed to the downloads section and add javacl-x.x.x-shaded.jar to your classpath manually : Compile some code : javac -cp javacl-x.x.x-shaded.jar MyTest.java Run the code (replace the semi-colon ';' by ':' on Unix systems) : java -cp javacl-x.x.x-shaded.jar;. MyTest Install / Build from sourcesPlease read the Build page. | |