1 Reply Latest reply on Nov 2, 2009 12:08 AM by Sternenprinz

    Visual Studio 2010 and OpenCL SDK: provide SDKUtil


      Please provide (as Nvidia in OpenCL SDK provides utils lib source) sources of SDKUtil so we can build samples on Visual Studio 2010..

        • Visual Studio 2010 and OpenCL SDK: provide SDKUtil

          You can bind the OpenCL.dll/.so as any other lib. All you have to do is to modify the cl.h header. I will give you one example.

          Change all function declaration to a typedef, e.g.:

          typedef  cl_int
          (CL_API_CALL *fn_clGetPlatformIDs)(cl_uint /* num_entries */,
                           cl_platform_id * /* platforms */,
                           cl_uint *        /* num_platforms */) CL_API_SUFFIX__VERSION_1_0;

          // Note the little 'fn_' in front of clGetPlatformIDs

          // Essentially this is a simple search & replace task

          Then declare a function variable for each API-Function, e.g.

          fn_clGetPlatformIDs clGetPlatformIDs;

          Finally bind all functions dynamically somewhere in your code, e.g. for Win32-API.

          clGetPlatformIDs = GetProcAddress(<HWND>,"clGetPlatformIDs");

          // dont forget to do some error checking!

          This way all other code should not need any change.

          NOTE: Due to abscence of an ICD this doesnt help you with different OpenCL implementations. Currently this have to be done for each different kind of calling convention/name mangling/and so on (worst case for each vendor).

          On the other hand: The changes for binding to e.g. the NVidia Implementation are minor (including those needed for a final ICD), this mod enables the use of virtually any C/C++ Compiler and finally gets you rid of the static OpenCL dependency that prevents execution of your program if no OpenCL is found.