The State of Sumatra
This page will reflect
- what APIs can currently be offloaded
- what java patterns in the offloaded lambda can and cannot be handled
APIs that can be Offloaded
Currenlty we handle only streams with a single operation consisting of either Stream.forEach or Stream.reduce. The Stream must always be marked as .parallel(). In addition there are the following restrictions:
Stream.forEach
- The spliterator must be either
- an IntRange starting at 0 with step 1.
- a spliterator from Arrays.stream or ArrayList.stream. Any primitive or Object is allowed for the type of the array.
Stream.reduce
- The input spliterator must be from Arrays.stream or ArrayList.stream
- The type of the array must be int
- The reduce function itself must be Int:sum, Int:max or Int:min. User written reduce functions are not supported yet.
Java Patterns Not Allowed in Lambdas
- Limited exception handling or try/catch inside a kernel
- No calling methods that would be a JNI or runtime call back to CPU code
- No synchronization in kernels. This is in line with good lambda/parallel programming practice.
- Recursion is not supported.
Java Patterns Allowed in Lambdas
In addition to the normal operations on primitive types, the following features are supported:
- You can access both static and instance fields in the enclosing class. If you are writing such fields make sure the logic is truly parallel.
- Object types are supported. You can access fields in Objects and call methods in objects. Overloaded virtual methods are not supported yet but will be supported in the future (they need profiling information to be gathered before the lambda is compiled for HSAIL).
- Objects and arrays can be allocated on the java heap. The arrays can be of any type.
- java.util.concurrent.atomic operations, for example AtomicInteger. Generally an atomic will be an object shared between workitems. Make sure the logic is truly parallel.
- The java.lang.Math routines are fully supported.
- Calls to many JDK library routines are supported if they do not contain the unsupported patterns listed above. Note that System.arraycopy (although native on many platforms) is fully supported.
- Runtime exceptions are supported (for example, ArrayIndexOutOfBoundsException, ClassCastException NullPointerException).
Overview
Content Tools
ThemeBuilder