Results 1 to 2 of 2

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

  1. #1
    Newbie
    Join Date
    Nov 2013
    Posts
    1

    Question cl.h (OpenCL 1.1) and cl.hpp (OpenCL1.1/1.0 version) - incompatible?

    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?

  2. #2
    Newbie
    Join Date
    Feb 2014
    Posts
    1
    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:

    Code :
    #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

    Code :
        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

    Code :
        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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •