JOCL NVIDIA ArrayIndexOutOfBoundsException

Hi,
I’m trying my program now on NVIDIA GPU on windows after development on linux using ATI’s CPU implementation.
Right at the very beginning I do:
cl_platform_id platforms[] = new cl_platform_id[1];
clGetPlatformIDs(1, platforms, null);

and get:
java.lang.ArrayIndexOutOfBoundsException: 1
at org.jocl.CL.clGetPlatformIDsNative(Native Method)
at org.jocl.CL.clGetPlatformIDs(CL.java:1484)
at fang.Context.context(Runtime.java:17)

Any ideas where the problem is? I tried increasing the size of the array, but still always get out of bounds exception.
This is frustrating, as it comes from native OpenCL method and I can’t even look at its source. Is it a nvidia implementation bug?
I run newest NVIDIA drivers for Vista32bit notebook and newest JOCL windows 32bit binaries.

Thanks,
Marcin

Hello,

This is a bug that already has been resolved internally. The updated version including some other minor bugfixes will be uploaded soon - possibly already today, but probably not later than tomorrow. Sorry for inconveniences.

bye
Marco

Thanks a lot, I’m looking forward to the update.

Marcin

You mentioned that increasing the array size did not help - in this case, the error might actually not have been related to the bug that has just been fixed, but might instead have been a compatibility issue: I received a similar error report via mail, and in this case, updating to the latest version of the NVIDIA Toolkit solved the problem. If you already have the latest version of the NVIDIA Toolkit, the new version of JOCL should work with this as well - it has been compiled with the latest version (3.0) of the Toolkit, which has been published a few days ago.

In any case, the latest version is now available at http://jocl.org/downloads/downloads.html - you may want to give it a try.

I’ve got the same error with the new version (JOCL 0.1.6)

I try to launch JOCLSimpleLWJGL.java

A window appears but this error message turn in while…

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1
    at org.jocl.samples.JOCLSimpleLWJGL.initCL(JOCLSimpleLWJGL.java:453)
    at org.jocl.samples.JOCLSimpleLWJGL.init(JOCLSimpleLWJGL.java:425)
    at org.jocl.samples.JOCLSimpleLWJGL$3.paintGL(JOCLSimpleLWJGL.java:344)
    at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:314)
    at org.lwjgl.opengl.AWTGLCanvas.update(AWTGLCanvas.java:343)
    at sun.awt.RepaintArea.updateComponent(Unknown Source)
    at sun.awt.RepaintArea.paint(Unknown Source)
    at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

OS: Windows 7 pro 64bit
GPU: Nvidia Quadro FX 580
EPI: Eclipse
JRE: 1.6
JOCL: 0.1.6
LWJGL: 2.7.1

bye,
muggiwara

Sorry, this ist not really a “bug” in JOCL, but just a typo in the sample: The line should be
clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, 0, null, numDevicesArray);
(instead of “platforms[1]”).

I’ll fix this sample as soon as possible. I’ve recently been switching between the two platforms I have (NVIDIA and AMD), this line must have slipped into the sample accidentally. I’ll have to think about a more general initialization stub anyhow, because the order of the platforms depends on the order of the OpenCL installations.

I have updated most of the samples so that they use a common initialization stub that basically starts with


        final int platformIndex = 0;
        final long deviceType = CL_DEVICE_TYPE_ALL;
        final int deviceIndex = 0;

where the platform and device can easily be specified (using the first platform and the first device by default). Hope this is OK. However, the initialization in general is usually just ~40 lines of boilerplate code… maybe I should increase the efforts for the attempts to wrap the OO-Jogamp-JOCL around JOCL…