Welcome to the official home of AMD's Aparapi
Please see http://developer.amd.com/tools-and-sdks/open-source for additional AMD open-source contributions.
Refer to the current documentation or the older docs on google code Aparapi Google Code for documentation.
Binary downloads at Maven Central coming soon!
Watch this space!
What is Aparapi?
Aparapi allows Java developers to take advantage of the compute power of GPU and APU devices by executing data parallel code fragments on the GPU rather than being confined to the local CPU. It does this by converting Java bytecode to OpenCL at runtime and executing on the GPU, if for any reason Aparapi can't execute on the GPU it will execute in a Java thread pool.
We like to think that for the appropriate workload this extends Java's 'Write Once Run Anywhere' to include GPU devices.
With Aparapi we can take a sequential loop such as this (which adds each element from inA and inB arrays and puts the result in result).
final float inA[] = .... // get a float array of data from somewhere
final float inB[] = .... // get a float array of data from somewhere (inA.length==inB.length)
final float result = new float[inA.length];
for (int i=0; i<array.length; i++){
result[i]=intA[i]+inB[i];
}
And refactor the sequential loop to the following form:
Kernel kernel = new Kernel(){
@Override public void run(){
int i= getGlobalId();
result[i]=intA[i]+inB[i];
}
};
Range range = Range.create(result.length);
kernel.execute(range);
In the above code we extend com.amd.aparapi.Kernel base class and override the Kernel.run() method to express our data parallel algorithm. We initiate the execution of the Kernel(over a specific range 0..results.length) using Kernel.execute(range).
For folks following the new Java 8 lambda extensions. Here is how we expect the above Aparapi code to look when Java 8 arrives.
Device.getBest().forEach(result.length, id -> result[id] = intA[id]+inB[id]);
Because we are also targeting the new "HSA Intermediate Language" https://hsafoundation.app.box.com/s/m6mrsjv8b7r50kqeyyal in the 'lambda' branch, Aparapi users will now be able to access Strings (and other objects) from the Java heap. So given an array of Strings and ints we can extract the lengths in parallel.
Device.hsa().forEach(strings.length, id -> lengths[id] = strings[id].length());
Note that because the example ''only'' works with HSA we need to select a HSA device.
If you would like to download and try Aparapi follow the 'Downloads' link above and read the UsersGuide, alternatively if you would like to contribute or access the code you can check out the code from the SVN repository above and jump right in by reading the DevelopersGuide pages.
Aparapi in the news + upcoming presentations
- "GPU Acceleration of Interactive Large Scale Data Analytics Utilizing The Aparapi Framework" - Ryan LaMothe - AFDS
- "Aparapi: OpenCL GPU and Multi-Core CPU Heterogeneous Computing for Java" - Ryan LaMothe and Gary Frost - AFDS
- "Performance Evaluation of AMD-APARAPI Using Real World Applications" - Prakash Raghavendra - AFDS
- "Aparapi: An Open Source tool for extending the Java promise of ‘Write Once Run Anywhere’ to include the GPU" - Gary Frost - OSCON 7/18/2012
- Aparapi talk at DOSUG (Denver Open Source User Group) Sept 4th 2012
- Meetup meeting in Paris Sept 25th 2012
Useful links
- Quick Reference Guide
- 2010 InfoQ Interview
- JavaOne 2010 Aparapi presentation
- AMD Fusion Developer Summit presentation
- AMD Fusion Developer Summit video
- Open Source Announcement at developer.amd.com
- Aparapi Mandlebrot demo on YouTube
- Witold Bolt's "The smell of fresh coffee: Aparapi - Java on the GPU!"
- Some interesting feedback on Aparapi from this blogger 'a hackers craic'
- A nice blog showing how to implement an option volatility surface using Aparapi
- Here is Eduardo Dudu's Game of Life extensions including links to the code Really nice graphics!
- Here also is a Spanish Blog
- Some really good performance analysis of algorithms implemented using Aparapi
- Nice YouTube demo (Aparapi + JMonkeyEngine
- Another YouTube demo using Aparapi
- A nice blog describing one developers take on Aparapi
- Aparapi running on Nexus 4 Phone
- An attempt to use Aparapi for Neural Network applications
- A nice writeup of Aparapi from Tomas Zrybak
Similar Work
- Peter Calvert's java-GPU has similar goals and offers a mechanism for converting Java code for use on the GPU
- Check out Peter's dissertation "Parallelisation of Java for Graphics Processors" which can be found here
- Marco Hutter's Java bindings for CUDA
- Marco Hutter's Java bindings for OpenCL
- Ian Wetherbee's Java acceleration project - creates accelerated code from Java (currently C code and native Android - but CUDA creation planned)
- "Rootbeer: Seamlessly using GPUs from Java" by Philip C. Pratt-Szeliga
Wiki Pages
- User’s Guide UsersGuide
- Developer’s Guide DevelopersGuide, for developers who want to build Aparapi or contribute to the project
- Frequently Asked Questions FrequentlyAskedQuestions
About the name
Aparapi is just a contraction of "A PARallel API"
However... "Apa rapi" in Indonesian (the language spoken on the island of Java) translates to "What a neat...". So "Apa rapi Java Project" translates to "What a neat Java Project" How cool is that?