PDA

View Full Version : cl.h (OpenCL 1.1) and cl.hpp (OpenCL1.1/1.0 version) - incompatible?



Raistmer
11-04-2013, 06:03 AM
I updated CUDA SDK to v 5.5 and got:

cl.hpp(2996) : error C2664: 'clEnqueueNativeKernel' : cannot convert parameter 2 from 'void (__cdecl *)(void *)' to 'void (__stdcall *)(void *)'
1> This conversion requires a reinterpret_cast, a C-style cast or function-style cast

switched back to CUDA SDK 3.2 - all builds OK.

Then I compared cl.hpp I use with provided on khronos site for OpenCL 1.1/1.0 - they are the same.
So I decided that cl.h from CUDA 5.5 SDK is "wrong" one.
But it has no differencies with cl.h for OpenCL 1.1 from Kronos site (!). So, cl.h and cl.hpp, both taken for OpenCL 1.1 are incompatible with each other?
Anyone tried this?

aschmied
02-06-2014, 12:05 PM
I guess you've probably found a workaround by now, but I'll reply in case someone else finds this thread.

__cdecl and __sdtcall refer to the function calling convention used by the compiler. The convention used by callbacks in OpenCL is defined in the header cl_platform.h:



#if defined(_WIN32)
#define CL_API_ENTRY
#define CL_API_CALL __stdcall
#define CL_CALLBACK __stdcall
#else
#define CL_API_ENTRY
#define CL_API_CALL
#define CL_CALLBACK
#endif


I had the same build issue as you and was able to build by modifying enqueueNativeKernel in cl.hpp at line 2971 from



cl_int enqueueNativeKernel(
void (*userFptr)(void *),
std::pair<void*, ::size_t> args,
const VECTOR_CLASS<Memory>* mem_objects = NULL,
const VECTOR_CLASS<const void*>* mem_locs = NULL,
const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const


to



cl_int enqueueNativeKernel(
void (CL_CALLBACK * userFptr)(void *),
std::pair<void*, ::size_t> args,
const VECTOR_CLASS<Memory>* mem_objects = NULL,
const VECTOR_CLASS<const void*>* mem_locs = NULL,
const VECTOR_CLASS<Event>* events = NULL,
Event* event = NULL) const


I'm not sure if something in our build changes the calling convention for user functions or if the absence of CL_CALLBACK here is an error.