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 Sumatra supports a few calls in the Streams API. Only streams with a single operation consisting of either Stream.forEach or Stream.reduce are supported. The Stream must always be marked as .parallel(). In addition there are the following restrictions:
Stream.forEach
- The Stream source 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 Stream source 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.
- Compressed References are not supported for Stream.reduce offloads
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 and support for the usual java control flow mechanisms, the following features are supported:
- The lambda itself can either be static or an instance method of the enclosing class. You can call class methods in the enclosing class. Lambda captures are fully supported.
- You can access both static and instance fields in the enclosing class. If you are writing to fields that are shared by many workitems, 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.
- 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.
- java.util.concurrent.atomic operations are supported, for example AtomicInteger. Generally an atomic will be an object shared between workitems. Make sure the logic is truly parallel.
- Runtime exceptions are supported (for example, ArrayIndexOutOfBoundsException, ClassCastException NullPointerException).
- Both compressed and uncompressed heap references are supported. There is no additional restriction on the heap size.
Overview
Content Tools
ThemeBuilder