cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

nythrix
Journeyman III

Stream 2.2 broke callback into managed code (FIXED)

Hi,

I'm the maintainer of the Cloo project (http://sourceforge.net/projects/cloo/). After upgrading my ATI Stream installation to v2.2 (from v2.01), two things stopped working:

a) clBuildProgram() if a notify function is given (works with null) and

b) clEnqueueNDRangeKernel() if an event list is specified (also works with null).

It might be a bug on my side although I can jump back and forward between the two versions of Stream and reproduce the issues only on one of them.

I should point out that the project is a .NET wrapper, which may or may not be important. Perhaps you've changed something in your callback mechanisms? Because clSetEventCallback fails too (AccessViolationException). However, I'm not 100% that's Stream's fault, so let's focus on a) and b) for now.

I'm conducting the tests on an Intel CPU (SSE3 capable). Catalyst not present.

I could post some code if it helps you. It's not C/C++ though (surprisingly).

0 Likes
4 Replies
Illusio
Journeyman III

b) Is likely some issue with your code. OpenCL.Net runs through all variations of clEnqueueNDRangeKernel with event lists, no event lists and event outputs in its unit tester and has no issues.

SetEventCallback works there as well.

 

0 Likes

Originally posted by: nythrix Hi,

 

I'm the maintainer of the Cloo project (http://sourceforge.net/projects/cloo/). After upgrading my ATI Stream installation to v2.2 (from v2.01), two things stopped working:

 

a) clBuildProgram() if a notify function is given (works with null) and



You need to add "CL_CALLBACK" to the function definition.  For example:

static void CL_CALLBACK notify_callback(...)

If you look in the header files, you will see:

extern CL_API_ENTRY cl_int CL_API_CALL
clBuildProgram(cl_program           /* program */,
               cl_uint              /* num_devices */,
               const cl_device_id * /* device_list */,
               const char *         /* options */,
               void (CL_CALLBACK *  /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
               void *               /* user_data */) CL_API_SUFFIX__VERSION_1_0;

And in cl_platform.h you will find:

#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

Jeff

 

0 Likes

Note that on Windows with ATI, the callbacks are currently cdecl, but will most likely change to stdcall at some point:

http://forums.amd.com/devforum/messageview.cfm?catid=390&threadid=138053&enterthread=y

0 Likes
nythrix
Journeyman III

Indeed, changing from UnmanagedFunctionPointer(CallingConvention.Cdecl) to StdCall does work in both cases (clBuildProgram and clSetEventCallback).

Also clEnqueueNDRange is mysteriously working again. And I never touched it. I must've hit a weak spot in the drivers running the tests one after another. Very odd...

Much appreciated, guys. You've been very helpful indeed!

0 Likes