OpenCL4Java v1.0-beta-2 is available !

Download / Browse JavaDoc / Discuss

Here are the main changes since beta 1 :

  • JAR is now self-sufficient (includes JNA + JNAerator’s runtime classes)
  • CLMem is now an abstract base class

    • CLBuffer subclass has type-safe subclasses (CLByteBuffer, CLIntBuffer..)
    • To create a CLBuffer : context.createIntBuffer(Input, size)…
    • Added CLBuffer.copyTo (-> clEnqueueCopyBuffer)
    • Each typed CLBuffer subclass has map, mapLater, read methods that return typed NIO buffers
  • Added support for barriers and markers in CLQueue
  • Rationalized naming of all enums : CL_ENTITY_ATTRIBUTE_SOME_VALUE = CLEntity.Attribute.SomeValue (enum item SomeValue in enum Attribute in class CLEntity)
  • Added full typing of OpenCL Exceptions (now possible to selectively catch a CLException.OutOfHostMemory, for instance)
  • Added experimental support of images (under-tested) :

    • CLContext.getSupportedImageFormats + CLImageFormat and associated enums
    • CLImage2D, CLImage3D and corresponding creation methods in CLContext + all image info getters
  • Added CLDevice.getMaxWorkItemSizes()
  • Moved method createContext from CLContext to CLPlatform
  • Added CLKernel.setLocalArg(argIndex, localArgByteLength)
  • Allow localWorkSizes to be null in enqueueNDRange
  • Fixed issue #2 : enqueueNDRange does not work for nDim > 1
  • Added all the CL_DEVICE_PREFERRED_VECTOR_WIDTH_XXX infos to CLDevice as getPreferredVectorWithXXX()
  • Changed return type of getExtensions() method of both CLPlatform and CLDevice from String to String[]
  • Added com.nativelibs4java.opencl.HardwareReport (with main method) : outputs html report with devices stats
  • Added hashCode and equals method to most classes
  • Added ability to create out of order queues and change queue properties after creation

Migration tips :

If you wrote code with the recent beta 1, you’ll have to do the following changes to compile :

  • Change all occurrences of CLMem to CLByteBuffer
  • Change CLContext.createContext into platform.createContext (and get the platform from OpenCL4Java.listPlatforms()).

Then to remove deprecation warnings (and have chances to compile when version 1.0 final comes out, stripped off all deprecated methods) :

  • Change createInput to a safer createIntBuffer, createFloatBuffer… method (will return a properly typed CLBuffer subclass, and let you speak in terms of element count instead of byteCount)
  • Change blockingMapRead(queue) to map(queue, MapFlags.Read) (same for Write, ReadWrite)
  • Change enqueueMapRead(queue) to mapLater(queue, MapFlags.Read) (same for Write, ReadWrite)

I might be forgetting important hints, but if you’re having a harder time than expected while migrating, I’m on the NativeLibs4Java google group to help 🙂