GL-CL interoperability in OSX

classic Classic list List threaded Threaded
14 messages Options
ac
Reply | Threaded
Open this post in threaded view
|

GL-CL interoperability in OSX

ac
Hello

I'm trying to create a CLGL context to share data between OpenCL and OpenGL.

I tested the CLGLInteroperabilityDemo, but I get this error:

Exception in thread "AWT-EventQueue-0" com.jogamp.opencl.CLException$CLInvalidValueException: can not create CL context [error: CL_INVALID_VALUE]
        at com.jogamp.opencl.CLException.checkForError(CLException.java:67)
        at com.jogamp.opencl.CLContext.createContext(CLContext.java:228)
        at com.jogamp.opencl.gl.CLGLContext.create(CLGLContext.java:124)
        at test.GLCLInteroperabilityDemo.init(GLCLInteroperabilityDemo.java:132)
        ...

I'm on OSX 10.6.7, with a NVidia geforce 320M card. I can create pure CL contexts and everything works fine in that case, the problem happens when I attempt CL-GL. Can be this related to the GL context being 2 instead of 3?

Thanks,
Andres
ac
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

ac
It seems that I cannot create a GL3/GL4 context. If I do:

profile = GLProfile.getDefault();
...
GLDrawableFactory factory = GLDrawableFactory.getFactory(profile);
drawable = factory.createGLDrawable(win);
context = drawable.createContext(null);  

my profile is created as [GL2/GL2]. If I try profile = GLProfile.get(GLProfile.GL4bc), or any other profile after GL3, I get a "java.lang.RuntimeException: Cannot get a valid OpenGL profile".

However, if I keep using the default profile, then the GL object associated to the context seems to be of type jogamp.opengl.gl4.GL4bcImpl. But if I try context.getGL().getGL4bc(), then I get "GLException: Not a GL4bc implementation"

BTW, I'm using jocl-0.9-b330-20110411-macosx-universal. My application works inside an AWT window, just in case this information is useful.

So my questions here are:
* How to explicitly create a GL3/GL4 context? Is there something in the initialization I'm missing? Is this a current limitation in OSX? I'm running 10.6.7, everything up-to-date as far as I know.
* Is this issue related to the problem I mentioned in the first post, where I cannot create a CLGLContext?

Any insights will be greatly appreciated,
Andres
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

Sven Gothel
Administrator
On Wednesday, April 20, 2011 03:24:25 am ac [via jogamp] wrote:

>
> It seems that I cannot create a GL3/GL4 context. If I do:
>
> profile = GLProfile.getDefault();
> ...
> GLDrawableFactory factory = GLDrawableFactory.getFactory(profile);
> drawable = factory.createGLDrawable(win);
> context = drawable.createContext(null);  
>
> my profile is created as [GL2/GL2]. If I try profile =
> GLProfile.get(GLProfile.GL4bc), or any other profile after GL3, I get a
> "java.lang.RuntimeException: Cannot get a valid OpenGL profile".

Sure ..

And since JOGL tries to get the highest fixed function profile,
I guess you are out of luck. Run test.sh as recommended in our FAQ/bug-reports.
We also have this getAvailableProfiles .. check the jogl core junit tests.

profile = GLProfile.get(GLProfile.GL4bc);
profile = GLProfile.getMaximum();

OSX ? Thought they just offered GL3 support ?
However, we haven't touched this yet, ie our current OSX GLContext selection
code may not recognize a GL3* profile.

Does your OSX machine have OpenGL 3* support ?

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

Wade Walker
Administrator
In reply to this post by ac
ac wrote
* How to explicitly create a GL3/GL4 context? Is there something in the initialization I'm missing? Is this a current limitation in OSX? I'm running 10.6.7, everything up-to-date as far as I know.
Hi Andres,

Unfortunately, Mac OS X 10.6.7 still only supports OpenGL 2.1. See http://developer.apple.com/graphicsimaging/opengl/capabilities/ for more details. There have been rumors of upcoming OpenGL 3 support, but nothing official yet.

ac
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

ac
Ok I see. So, this means we have to wait for Apple to release updated OpenGL drivers at some point.

Thanks a lot for the clarifications guys!
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

Michael Bien
In reply to this post by ac
  a GL 2.x context is sufficient for GL-CL interoperability.

could you run

  java -jar jocl.jar:gluegen-rt.jar -Djava.library.path="path/to/jocl/libs:path/to/gluegen-rt/libs" com.jogamp.opencl.util.CLInfo


and post/attach the results?

best regards,
michael


On 04/19/2011 05:56 AM, ac [via jogamp] wrote:

> Hello
>
> I'm trying to create a CLGL context to share data between OpenCL and OpenGL.
>
> I tested the CLGLInteroperabilityDemo, but I get this error:
>
> Exception in thread "AWT-EventQueue-0"
> com.jogamp.opencl.CLException$CLInvalidValueException: can not create CL
> context [error: CL_INVALID_VALUE]
> at com.jogamp.opencl.CLException.checkForError(CLException.java:67)
> at com.jogamp.opencl.CLContext.createContext(CLContext.java:228)
> at com.jogamp.opencl.gl.CLGLContext.create(CLGLContext.java:124)
> at test.GLCLInteroperabilityDemo.init(GLCLInteroperabilityDemo.java:132)
>          ...
>
> I'm on OSX 10.6.7, with a NVidia geforce 320M card. I can create pure CL
> contexts and everything works fine in that case, the problem happens when I
> attempt CL-GL. Can be this related to the GL context being 2 instead of 3?
>
> Thanks,
> Andres

ac
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

ac
I get the following:

HOST_JRE: 1.6.0_22-b04-307-10M3326
HOST_JVM: Java HotSpot(TM) 64-Bit Server VM
HOST_ARCH: x86_64
HOST_NUM_CORES: 2
HOST_OS: Mac OS X
HOST_LITTLE_ENDIAN: true
CL_BINDING_UNAVAILABLE_FUNCTIONS: [clCreateEventFromGLsyncKHR, clCreateSubBuffer, clCreateSubDevicesEXT, clCreateUserEvent, clEnqueueCopyBufferRect, clEnqueueReadBufferRect, clEnqueueWriteBufferRect, clGetGLContextInfoKHR, clIcdGetPlatformIDsKHR, clReleaseDeviceEXT, clRetainDeviceEXT, clSetEventCallback, clSetMemObjectDestructorCallback, clSetUserEventStatus]

CL_PLATFORM_NAME: Apple
CL_PLATFORM_VERSION: OpenCL 1.0 (Dec 23 2010 17:30:26)
CL_PLATFORM_PROFILE: FULL_PROFILE
CL_PLATFORM_VENDOR: Apple
CL_PLATFORM_ICD_SUFFIX_KHR: com.jogamp.opencl.CLException$CLInvalidValueException: can not receive info string [error: CL_INVALID_VALUE]
CL_PLATFORM_EXTENSIONS: []

 - CL_DEVICE_NAME: GeForce 320M
 - CL_DEVICE_TYPE: GPU
 - CL_DEVICE_VERSION: OpenCL 1.0
 - CL_DEVICE_AVAILABLE: false
 - CL_DEVICE_ENDIAN_LITTLE: false
 - CL_DEVICE_PROFILE: FULL_PROFILE
 - CL_DEVICE_VENDOR: NVIDIA
 - CL_DEVICE_EXTENSIONS: [cl_APPLE_gl_sharing, cl_khr_byte_addressable_store, cl_APPLE_ContextLoggingFunctions, cl_khr_local_int32_extended_atomics, cl_APPLE_SetMemObjectDestructor, cl_khr_local_int32_base_atomics, cl_khr_global_int32_base_atomics, cl_khr_global_int32_extended_atomics]
 - CL_DEVICE_MAX_COMPUTE_UNITS: 6
 - CL_DEVICE_MAX_CLOCK_FREQUENCY: 950
 - CL_DEVICE_VENDOR_ID: 7088510129523533312
 - CL_DEVICE_OPENCL_C_VERSION: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info string [error: CL_INVALID_OPERATION]
 - CL_DRIVER_VERSION: CLH 1.0
 - CL_DEVICE_ADDRESS_BITS: 32
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT: 1
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR: 1
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: 1
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: 1
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: 1
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: 0
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_INT: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_MAX_WORK_GROUP_SIZE: 512
 - CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3
 - CL_DEVICE_MAX_WORK_ITEM_SIZES: [512, 512, 64]
 - CL_DEVICE_MAX_PARAMETER_SIZE: 4352
 - CL_DEVICE_MAX_MEM_ALLOC_SIZE: 134217728
 - CL_DEVICE_GLOBAL_MEM_SIZE: 268435456
 - CL_DEVICE_LOCAL_MEM_SIZE: 16384
 - CL_DEVICE_HOST_UNIFIED_MEMORY: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 65536
 - CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 0
 - CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 0
 - CL_DEVICE_MAX_CONSTANT_ARGS: 9
 - CL_DEVICE_IMAGE_SUPPORT: true
 - CL_DEVICE_MAX_READ_IMAGE_ARGS: 128
 - CL_DEVICE_MAX_WRITE_IMAGE_ARGS: 8
 - CL_DEVICE_IMAGE2D_MAX_WIDTH: 4096
 - CL_DEVICE_IMAGE2D_MAX_HEIGHT: 4096
 - CL_DEVICE_IMAGE3D_MAX_WIDTH: 2048
 - CL_DEVICE_IMAGE3D_MAX_HEIGHT: 2048
 - CL_DEVICE_IMAGE3D_MAX_DEPTH: 2048
 - CL_DEVICE_MAX_SAMPLERS: 16
 - CL_DEVICE_PROFILING_TIMER_RESOLUTION: 1000
 - CL_DEVICE_EXECUTION_CAPABILITIES: [EXEC_KERNEL]
 - CL_DEVICE_HALF_FP_CONFIG: []
 - CL_DEVICE_SINGLE_FP_CONFIG: [INF_NAN, ROUND_TO_NEAREST]
 - CL_DEVICE_DOUBLE_FP_CONFIG: []
 - CL_DEVICE_LOCAL_MEM_TYPE: LOCAL
 - CL_DEVICE_GLOBAL_MEM_CACHE_TYPE: NONE
 - CL_DEVICE_QUEUE_PROPERTIES: [PROFILING_MODE]
 - CL_DEVICE_COMPILER_AVAILABLE: true
 - CL_DEVICE_ERROR_CORRECTION_SUPPORT: false
 - cl_khr_fp16: false
 - cl_khr_fp64: false
 - cl_khr_gl_sharing | cl_APPLE_gl_sharing: true

 - CL_DEVICE_NAME: Intel(R) Core(TM)2 Duo CPU     P8600  @ 2.40GHz
 - CL_DEVICE_TYPE: CPU
 - CL_DEVICE_VERSION: OpenCL 1.0
 - CL_DEVICE_AVAILABLE: false
 - CL_DEVICE_ENDIAN_LITTLE: false
 - CL_DEVICE_PROFILE: FULL_PROFILE
 - CL_DEVICE_VENDOR: Intel
 - CL_DEVICE_EXTENSIONS: [cl_APPLE_gl_sharing, cl_khr_byte_addressable_store, cl_APPLE_ContextLoggingFunctions, cl_khr_fp64, cl_khr_local_int32_extended_atomics, cl_APPLE_SetMemObjectDestructor, cl_khr_local_int32_base_atomics, cl_khr_global_int32_base_atomics, cl_khr_global_int32_extended_atomics]
 - CL_DEVICE_MAX_COMPUTE_UNITS: 2
 - CL_DEVICE_MAX_CLOCK_FREQUENCY: 2400
 - CL_DEVICE_VENDOR_ID: 7376740505675236352
 - CL_DEVICE_OPENCL_C_VERSION: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info string [error: CL_INVALID_OPERATION]
 - CL_DRIVER_VERSION: 1.0
 - CL_DEVICE_ADDRESS_BITS: 64
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT: 8
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR: 16
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: 4
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: 2
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: 4
 - CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: 2
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_INT: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_MAX_WORK_GROUP_SIZE: 1
 - CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3
 - CL_DEVICE_MAX_WORK_ITEM_SIZES: [1, 1, 1]
 - CL_DEVICE_MAX_PARAMETER_SIZE: 4096
 - CL_DEVICE_MAX_MEM_ALLOC_SIZE: 1073741824
 - CL_DEVICE_GLOBAL_MEM_SIZE: 3221225472
 - CL_DEVICE_LOCAL_MEM_SIZE: 16384
 - CL_DEVICE_HOST_UNIFIED_MEMORY: com.jogamp.opencl.CLException$CLInvalidOperationException: error while asking for info value [error: CL_INVALID_OPERATION]
 - CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 65536
 - CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 64
 - CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 3145728
 - CL_DEVICE_MAX_CONSTANT_ARGS: 8
 - CL_DEVICE_IMAGE_SUPPORT: true
 - CL_DEVICE_MAX_READ_IMAGE_ARGS: 128
 - CL_DEVICE_MAX_WRITE_IMAGE_ARGS: 8
 - CL_DEVICE_IMAGE2D_MAX_WIDTH: 8192
 - CL_DEVICE_IMAGE2D_MAX_HEIGHT: 8192
 - CL_DEVICE_IMAGE3D_MAX_WIDTH: 2048
 - CL_DEVICE_IMAGE3D_MAX_HEIGHT: 2048
 - CL_DEVICE_IMAGE3D_MAX_DEPTH: 2048
 - CL_DEVICE_MAX_SAMPLERS: 16
 - CL_DEVICE_PROFILING_TIMER_RESOLUTION: 1
 - CL_DEVICE_EXECUTION_CAPABILITIES: [EXEC_KERNEL, EXEC_NATIVE_KERNEL]
 - CL_DEVICE_HALF_FP_CONFIG: []
 - CL_DEVICE_SINGLE_FP_CONFIG: [DENORM, INF_NAN, ROUND_TO_NEAREST]
 - CL_DEVICE_DOUBLE_FP_CONFIG: [DENORM, INF_NAN, ROUND_TO_NEAREST, ROUND_TO_INF, ROUND_TO_ZERO, FMA]
 - CL_DEVICE_LOCAL_MEM_TYPE: GLOBAL
 - CL_DEVICE_GLOBAL_MEM_CACHE_TYPE: READ_WRITE
 - CL_DEVICE_QUEUE_PROPERTIES: [PROFILING_MODE]
 - CL_DEVICE_COMPILER_AVAILABLE: true
 - CL_DEVICE_ERROR_CORRECTION_SUPPORT: false
 - cl_khr_fp16: false
 - cl_khr_fp64: true
 - cl_khr_gl_sharing | cl_APPLE_gl_sharing: true




Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

Michael Bien
thanks. fix is in progress. could take a bit longer as usual since it will also touch jogl.
-michael
ac
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

ac
Great. I appreciate your support very much!!
ac
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

ac
The 0.9-b349-20110503 package of jocl seems to incorporate some changes to address the gl-cl interop in osx.

Should I get GL-compatible devices by doing:

CLDevice[] devices = CLPlatform.getDefault(CLPlatformFilters.glSharing()).listCLDevices(CLDeviceFilters.glSharing());

?

Thanks,
Andres
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

Michael Bien
  yes exactly. the first filter gives you a platform supporting at least
one device with GL interoperability or null(!). The second filter
returns all GL capable devices from the selected platform or an empty array.

there is also a platform filter checking vendor compatibility:
https://github.com/mbien/jocl/commit/c00dc66867518f32d6a2615aa8da71a52489d5d8
since its unlikely that for example NV cards will ever talk with AMD
cards and vice versa.

the CLGLContext initialisation issue on mac which was the original topic
of this thread should be fixed with this commit:
https://github.com/mbien/jocl/commit/7d44ee784ffa59146d2d1d124f5ffc482fb0f5f0

however there are no builds available yet containing the above changes,
if you are interested you will have to use my gluegen and jocl
repositories for a build.

best regards,
michael

On 05/09/2011 11:00 AM, ac [via jogamp] wrote:

>
> The 0.9-b349-20110503 package of jocl seems to incorporate some changes to
> address the gl-cl interop in osx.
>
> Should I get GL-compatible devices by doing:
>
> CLDevice[] devices =
> CLPlatform.getDefault(CLPlatformFilters.glSharing()).listCLDevices(CLDeviceFilters.glSharing());
>
> ?
>
> Thanks,
> Andres
ac
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

ac
Great! I'm not in a rush, so I will wait for the new builds including these changes to be available.
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

Jerry Zhu
In reply to this post by Michael Bien
Hi! I have met the same problem when creating cl-glcontext on OSX recently, could you tell me if the new builds are available and where I can get it? Thank you very much!
Reply | Threaded
Open this post in threaded view
|

Re: GL-CL interoperability in OSX

texone
I stumbled across the same Problem this code:

_myPlatForm = CLPlatform.getDefault(CLPlatformFilters.glSharing());
_myDevice = _myPlatForm.getMaxFlopsDevice(CLDeviceFilters.glSharing());
_myGLContext = CLGLContext.create(g.gl.getContext(),_myDevice);

causes this exception:

com.jogamp.opencl.CLException$CLInvalidValueException: can not create CL context [error: CL_INVALID_VALUE]
        at com.jogamp.opencl.CLException.checkForError(CLException.java:67)
        at com.jogamp.opencl.CLContext.createContext(CLContext.java:230)
        at com.jogamp.opencl.gl.CLGLContext.create(CLGLContext.java:126)
        at cc.creativecomputing.opencl.CCOpenCL.<init>(CCOpenCL.java:119)
       
Should this be working right now I have Lion installed with these devices available:

 *** Device Intel(R) Core(TM) i7 CPU       M 620  @ 2.67GHz ******************************************
   id           : 0
   name         : Intel(R) Core(TM) i7 CPU       M 620  @ 2.67GHz
   profile      : FULL_PROFILE
   version      : OpenCL 1.1
   vendor       : Intel
   type         : CPU
   compute units: 4
   gl sharing   : true
 *** Device GeForce GT 330M ******************************************
   id           : 1
   name         : GeForce GT 330M
   profile      : FULL_PROFILE
   version      : OpenCL 1.0
   vendor       : NVIDIA
   type         : GPU
   compute units: 6
   gl sharing   : true

gl sharing should be supported, any advice where to look at or how to fix this?

Best Christian