LCOV - code coverage report
Current view: top level - sc/source/core/opencl/clcc - clew.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 6 89 6.7 %
Date: 2014-11-03 Functions: 1 3 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //  Copyright (c) 2009-2011 Organic Vectory B.V.
       2             : //  Written by George van Venrooij
       3             : //
       4             : //  Distributed under the Boost Software License, Version 1.0.
       5             : //  (See accompanying file license.txt)
       6             : 
       7             : #include "clcc/clew.h"
       8             : 
       9             : //! \file clew.c
      10             : //! \brief OpenCL run-time loader source
      11             : 
      12             : #ifndef CLCC_GENERATE_DOCUMENTATION
      13             :     #ifdef _WIN32
      14             :         #define WIN32_LEAN_AND_MEAN
      15             :         #define VC_EXTRALEAN
      16             :         #include <prewin.h>
      17             :         #include <postwin.h>
      18             : 
      19             :         typedef HMODULE             CLCC_DYNLIB_HANDLE;
      20             : 
      21             :         #define CLCC_DYNLIB_OPEN    LoadLibrary
      22             :         #define CLCC_DYNLIB_CLOSE   FreeLibrary
      23             :         #define CLCC_DYNLIB_IMPORT  GetProcAddress
      24             :     #else
      25             :         #include <dlfcn.h>
      26             : 
      27             :         typedef void*                   CLCC_DYNLIB_HANDLE;
      28             : 
      29             :         #define CLCC_DYNLIB_OPEN(path)  dlopen(path, RTLD_NOW | RTLD_GLOBAL)
      30             :         #define CLCC_DYNLIB_CLOSE       dlclose
      31             :         #define CLCC_DYNLIB_IMPORT      dlsym
      32             :     #endif
      33             : #else
      34             :     //typedef implementation_defined  CLCC_DYNLIB_HANDLE;
      35             :     //#define CLCC_DYNLIB_OPEN(path)  implementation_defined
      36             :     //#define CLCC_DYNLIB_CLOSE       implementation_defined
      37             :     //#define CLCC_DYNLIB_IMPORT      implementation_defined
      38             : #endif
      39             : 
      40             : #include <stdlib.h>
      41             : 
      42             : //! \brief module handle
      43             : static CLCC_DYNLIB_HANDLE module = NULL;
      44             : 
      45             : //  Variables holding function entry points
      46             : #ifndef CLCC_GENERATE_DOCUMENTATION
      47             : PFNCLGETPLATFORMIDS                 __clewGetPlatformIDs                = NULL;
      48             : PFNCLGETPLATFORMINFO                __clewGetPlatformInfo               = NULL;
      49             : PFNCLGETDEVICEIDS                   __clewGetDeviceIDs                  = NULL;
      50             : PFNCLGETDEVICEINFO                  __clewGetDeviceInfo                 = NULL;
      51             : PFNCLCREATECONTEXT                  __clewCreateContext                 = NULL;
      52             : PFNCLCREATECONTEXTFROMTYPE          __clewCreateContextFromType         = NULL;
      53             : PFNCLRETAINCONTEXT                  __clewRetainContext                 = NULL;
      54             : PFNCLRELEASECONTEXT                 __clewReleaseContext                = NULL;
      55             : PFNCLGETCONTEXTINFO                 __clewGetContextInfo                = NULL;
      56             : PFNCLCREATECOMMANDQUEUE             __clewCreateCommandQueue            = NULL;
      57             : PFNCLRETAINCOMMANDQUEUE             __clewRetainCommandQueue            = NULL;
      58             : PFNCLRELEASECOMMANDQUEUE            __clewReleaseCommandQueue           = NULL;
      59             : PFNCLGETCOMMANDQUEUEINFO            __clewGetCommandQueueInfo           = NULL;
      60             : PFNCLSETCOMMANDQUEUEPROPERTY        __clewSetCommandQueueProperty       = NULL;
      61             : PFNCLCREATEBUFFER                   __clewCreateBuffer                  = NULL;
      62             : PFNCLCREATEIMAGE2D                  __clewCreateImage2D                 = NULL;
      63             : PFNCLCREATEIMAGE3D                  __clewCreateImage3D                 = NULL;
      64             : PFNCLRETAINMEMOBJECT                __clewRetainMemObject               = NULL;
      65             : PFNCLRELEASEMEMOBJECT               __clewReleaseMemObject              = NULL;
      66             : PFNCLGETSUPPORTEDIMAGEFORMATS       __clewGetSupportedImageFormats      = NULL;
      67             : PFNCLGETMEMOBJECTINFO               __clewGetMemObjectInfo              = NULL;
      68             : PFNCLGETIMAGEINFO                   __clewGetImageInfo                  = NULL;
      69             : PFNCLCREATESAMPLER                  __clewCreateSampler                 = NULL;
      70             : PFNCLRETAINSAMPLER                  __clewRetainSampler                 = NULL;
      71             : PFNCLRELEASESAMPLER                 __clewReleaseSampler                = NULL;
      72             : PFNCLGETSAMPLERINFO                 __clewGetSamplerInfo                = NULL;
      73             : PFNCLCREATEPROGRAMWITHSOURCE        __clewCreateProgramWithSource       = NULL;
      74             : PFNCLCREATEPROGRAMWITHBINARY        __clewCreateProgramWithBinary       = NULL;
      75             : PFNCLRETAINPROGRAM                  __clewRetainProgram                 = NULL;
      76             : PFNCLRELEASEPROGRAM                 __clewReleaseProgram                = NULL;
      77             : PFNCLBUILDPROGRAM                   __clewBuildProgram                  = NULL;
      78             : PFNCLUNLOADCOMPILER                 __clewUnloadCompiler                = NULL;
      79             : PFNCLGETPROGRAMINFO                 __clewGetProgramInfo                = NULL;
      80             : PFNCLGETPROGRAMBUILDINFO            __clewGetProgramBuildInfo           = NULL;
      81             : PFNCLCREATEKERNEL                   __clewCreateKernel                  = NULL;
      82             : PFNCLCREATEKERNELSINPROGRAM         __clewCreateKernelsInProgram        = NULL;
      83             : PFNCLRETAINKERNEL                   __clewRetainKernel                  = NULL;
      84             : PFNCLRELEASEKERNEL                  __clewReleaseKernel                 = NULL;
      85             : PFNCLSETKERNELARG                   __clewSetKernelArg                  = NULL;
      86             : PFNCLGETKERNELINFO                  __clewGetKernelInfo                 = NULL;
      87             : PFNCLGETKERNELWORKGROUPINFO         __clewGetKernelWorkGroupInfo        = NULL;
      88             : PFNCLWAITFOREVENTS                  __clewWaitForEvents                 = NULL;
      89             : PFNCLGETEVENTINFO                   __clewGetEventInfo                  = NULL;
      90             : PFNCLRETAINEVENT                    __clewRetainEvent                   = NULL;
      91             : PFNCLRELEASEEVENT                   __clewReleaseEvent                  = NULL;
      92             : PFNCLGETEVENTPROFILINGINFO          __clewGetEventProfilingInfo         = NULL;
      93             : PFNCLFLUSH                          __clewFlush                         = NULL;
      94             : PFNCLFINISH                         __clewFinish                        = NULL;
      95             : PFNCLENQUEUEREADBUFFER              __clewEnqueueReadBuffer             = NULL;
      96             : PFNCLENQUEUEWRITEBUFFER             __clewEnqueueWriteBuffer            = NULL;
      97             : PFNCLENQUEUECOPYBUFFER              __clewEnqueueCopyBuffer             = NULL;
      98             : PFNCLENQUEUEREADIMAGE               __clewEnqueueReadImage              = NULL;
      99             : PFNCLENQUEUEWRITEIMAGE              __clewEnqueueWriteImage             = NULL;
     100             : PFNCLENQUEUECOPYIMAGE               __clewEnqueueCopyImage              = NULL;
     101             : PFNCLENQUEUECOPYIMAGETOBUFFER       __clewEnqueueCopyImageToBuffer      = NULL;
     102             : PFNCLENQUEUECOPYBUFFERTOIMAGE       __clewEnqueueCopyBufferToImage      = NULL;
     103             : PFNCLENQUEUEMAPBUFFER               __clewEnqueueMapBuffer              = NULL;
     104             : PFNCLENQUEUEMAPIMAGE                __clewEnqueueMapImage               = NULL;
     105             : PFNCLENQUEUEUNMAPMEMOBJECT          __clewEnqueueUnmapMemObject         = NULL;
     106             : PFNCLENQUEUENDRANGEKERNEL           __clewEnqueueNDRangeKernel          = NULL;
     107             : PFNCLENQUEUETASK                    __clewEnqueueTask                   = NULL;
     108             : PFNCLENQUEUENATIVEKERNEL            __clewEnqueueNativeKernel           = NULL;
     109             : PFNCLENQUEUEMARKER                  __clewEnqueueMarker                 = NULL;
     110             : PFNCLENQUEUEWAITFOREVENTS           __clewEnqueueWaitForEvents          = NULL;
     111             : PFNCLENQUEUEBARRIER                 __clewEnqueueBarrier                = NULL;
     112             : PFNCLGETEXTENSIONFUNCTIONADDRESS    __clewGetExtensionFunctionAddress   = NULL;
     113             : #endif  //  CLCC_GENERATE_DOCUMENTATION
     114             : 
     115             : //! \brief Unloads OpenCL dynamic library, should not be called directly
     116           0 : static void clewExit(void)
     117             : {
     118           0 :     if (module != NULL)
     119             :     {
     120             :         //  Ignore errors
     121           0 :         CLCC_DYNLIB_CLOSE(module);
     122           0 :         module = NULL;
     123             :     }
     124           0 : }
     125             : 
     126             : #define CLEW_CHECK_FUNCTION(f)              \
     127             :     if ((f) == NULL)                        \
     128             :     {                                       \
     129             :         CLCC_DYNLIB_CLOSE(module);          \
     130             :         module = NULL;                      \
     131             :         return CLEW_ERROR_IMPORT_FAILED;    \
     132             :     }                                       \
     133             : 
     134             : //! \param path path to dynamic library to load
     135             : //! \return CLEW_ERROR_OPEN_FAILED if the library could not be opened
     136             : //! CLEW_ERROR_ATEXIT_FAILED if atexit(clewExit) failed
     137             : //! CLEW_SUCCESS when the library was successfully loaded
     138         446 : int clewInit(const char* path)
     139             : {
     140         446 :     int error = 0;
     141             : 
     142             :     //  Check if already initialized
     143         446 :     if (module != NULL)
     144             :     {
     145           0 :         return CLEW_SUCCESS;
     146             :     }
     147             : 
     148             :     //  Load library
     149         446 :     module = CLCC_DYNLIB_OPEN(path);
     150             : 
     151             :     //  Check for errors
     152         446 :     if (module == NULL)
     153             :     {
     154         446 :         return CLEW_ERROR_OPEN_FAILED;
     155             :     }
     156             : 
     157             :     //  Set unloading
     158           0 :     error = atexit(clewExit);
     159             : 
     160           0 :     if (error)
     161             :     {
     162             :         //  Failure queing atexit, shutdown with error
     163           0 :         CLCC_DYNLIB_CLOSE(module);
     164           0 :         module = NULL;
     165             : 
     166           0 :         return CLEW_ERROR_ATEXIT_FAILED;
     167             :     }
     168             : 
     169             :     //  Determine function entry-points
     170           0 :     CLEW_CHECK_FUNCTION(__clewGetPlatformIDs                = (PFNCLGETPLATFORMIDS              )CLCC_DYNLIB_IMPORT(module, "clGetPlatformIDs"));
     171           0 :     CLEW_CHECK_FUNCTION(__clewGetPlatformInfo               = (PFNCLGETPLATFORMINFO             )CLCC_DYNLIB_IMPORT(module, "clGetPlatformInfo"));
     172           0 :     CLEW_CHECK_FUNCTION(__clewGetDeviceIDs                  = (PFNCLGETDEVICEIDS                )CLCC_DYNLIB_IMPORT(module, "clGetDeviceIDs"));
     173           0 :     CLEW_CHECK_FUNCTION(__clewGetDeviceInfo                 = (PFNCLGETDEVICEINFO               )CLCC_DYNLIB_IMPORT(module, "clGetDeviceInfo"));
     174           0 :     CLEW_CHECK_FUNCTION(__clewCreateContext                 = (PFNCLCREATECONTEXT               )CLCC_DYNLIB_IMPORT(module, "clCreateContext"));
     175           0 :     CLEW_CHECK_FUNCTION(__clewCreateContextFromType         = (PFNCLCREATECONTEXTFROMTYPE       )CLCC_DYNLIB_IMPORT(module, "clCreateContextFromType"));
     176           0 :     CLEW_CHECK_FUNCTION(__clewRetainContext                 = (PFNCLRETAINCONTEXT               )CLCC_DYNLIB_IMPORT(module, "clRetainContext"));
     177           0 :     CLEW_CHECK_FUNCTION(__clewReleaseContext                = (PFNCLRELEASECONTEXT              )CLCC_DYNLIB_IMPORT(module, "clReleaseContext"));
     178           0 :     CLEW_CHECK_FUNCTION(__clewGetContextInfo                = (PFNCLGETCONTEXTINFO              )CLCC_DYNLIB_IMPORT(module, "clGetContextInfo"));
     179           0 :     CLEW_CHECK_FUNCTION(__clewCreateCommandQueue            = (PFNCLCREATECOMMANDQUEUE          )CLCC_DYNLIB_IMPORT(module, "clCreateCommandQueue"));
     180           0 :     CLEW_CHECK_FUNCTION(__clewRetainCommandQueue            = (PFNCLRETAINCOMMANDQUEUE          )CLCC_DYNLIB_IMPORT(module, "clRetainCommandQueue"));
     181           0 :     CLEW_CHECK_FUNCTION(__clewReleaseCommandQueue           = (PFNCLRELEASECOMMANDQUEUE         )CLCC_DYNLIB_IMPORT(module, "clReleaseCommandQueue"));
     182           0 :     CLEW_CHECK_FUNCTION(__clewGetCommandQueueInfo           = (PFNCLGETCOMMANDQUEUEINFO         )CLCC_DYNLIB_IMPORT(module, "clGetCommandQueueInfo"));
     183           0 :     CLEW_CHECK_FUNCTION(__clewSetCommandQueueProperty       = (PFNCLSETCOMMANDQUEUEPROPERTY     )CLCC_DYNLIB_IMPORT(module, "clSetCommandQueueProperty"));
     184           0 :     CLEW_CHECK_FUNCTION(__clewCreateBuffer                  = (PFNCLCREATEBUFFER                )CLCC_DYNLIB_IMPORT(module, "clCreateBuffer"));
     185           0 :     CLEW_CHECK_FUNCTION(__clewCreateImage2D                 = (PFNCLCREATEIMAGE2D               )CLCC_DYNLIB_IMPORT(module, "clCreateImage2D"));
     186           0 :     CLEW_CHECK_FUNCTION(__clewCreateImage3D                 = (PFNCLCREATEIMAGE3D               )CLCC_DYNLIB_IMPORT(module, "clCreateImage3D"));
     187           0 :     CLEW_CHECK_FUNCTION(__clewRetainMemObject               = (PFNCLRETAINMEMOBJECT             )CLCC_DYNLIB_IMPORT(module, "clRetainMemObject"));
     188           0 :     CLEW_CHECK_FUNCTION(__clewReleaseMemObject              = (PFNCLRELEASEMEMOBJECT            )CLCC_DYNLIB_IMPORT(module, "clReleaseMemObject"));
     189           0 :     CLEW_CHECK_FUNCTION(__clewGetSupportedImageFormats      = (PFNCLGETSUPPORTEDIMAGEFORMATS    )CLCC_DYNLIB_IMPORT(module, "clGetSupportedImageFormats"));
     190           0 :     CLEW_CHECK_FUNCTION(__clewGetMemObjectInfo              = (PFNCLGETMEMOBJECTINFO            )CLCC_DYNLIB_IMPORT(module, "clGetMemObjectInfo"));
     191           0 :     CLEW_CHECK_FUNCTION(__clewGetImageInfo                  = (PFNCLGETIMAGEINFO                )CLCC_DYNLIB_IMPORT(module, "clGetImageInfo"));
     192           0 :     CLEW_CHECK_FUNCTION(__clewCreateSampler                 = (PFNCLCREATESAMPLER               )CLCC_DYNLIB_IMPORT(module, "clCreateSampler"));
     193           0 :     CLEW_CHECK_FUNCTION(__clewRetainSampler                 = (PFNCLRETAINSAMPLER               )CLCC_DYNLIB_IMPORT(module, "clRetainSampler"));
     194           0 :     CLEW_CHECK_FUNCTION(__clewReleaseSampler                = (PFNCLRELEASESAMPLER              )CLCC_DYNLIB_IMPORT(module, "clReleaseSampler"));
     195           0 :     CLEW_CHECK_FUNCTION(__clewGetSamplerInfo                = (PFNCLGETSAMPLERINFO              )CLCC_DYNLIB_IMPORT(module, "clGetSamplerInfo"));
     196           0 :     CLEW_CHECK_FUNCTION(__clewCreateProgramWithSource       = (PFNCLCREATEPROGRAMWITHSOURCE     )CLCC_DYNLIB_IMPORT(module, "clCreateProgramWithSource"));
     197           0 :     CLEW_CHECK_FUNCTION(__clewCreateProgramWithBinary       = (PFNCLCREATEPROGRAMWITHBINARY     )CLCC_DYNLIB_IMPORT(module, "clCreateProgramWithBinary"));
     198           0 :     CLEW_CHECK_FUNCTION(__clewRetainProgram                 = (PFNCLRETAINPROGRAM               )CLCC_DYNLIB_IMPORT(module, "clRetainProgram"));
     199           0 :     CLEW_CHECK_FUNCTION(__clewReleaseProgram                = (PFNCLRELEASEPROGRAM              )CLCC_DYNLIB_IMPORT(module, "clReleaseProgram"));
     200           0 :     CLEW_CHECK_FUNCTION(__clewBuildProgram                  = (PFNCLBUILDPROGRAM                )CLCC_DYNLIB_IMPORT(module, "clBuildProgram"));
     201           0 :     CLEW_CHECK_FUNCTION(__clewUnloadCompiler                = (PFNCLUNLOADCOMPILER              )CLCC_DYNLIB_IMPORT(module, "clUnloadCompiler"));
     202           0 :     CLEW_CHECK_FUNCTION(__clewGetProgramInfo                = (PFNCLGETPROGRAMINFO              )CLCC_DYNLIB_IMPORT(module, "clGetProgramInfo"));
     203           0 :     CLEW_CHECK_FUNCTION(__clewGetProgramBuildInfo           = (PFNCLGETPROGRAMBUILDINFO         )CLCC_DYNLIB_IMPORT(module, "clGetProgramBuildInfo"));
     204           0 :     CLEW_CHECK_FUNCTION(__clewCreateKernel                  = (PFNCLCREATEKERNEL                )CLCC_DYNLIB_IMPORT(module, "clCreateKernel"));
     205           0 :     CLEW_CHECK_FUNCTION(__clewCreateKernelsInProgram        = (PFNCLCREATEKERNELSINPROGRAM      )CLCC_DYNLIB_IMPORT(module, "clCreateKernelsInProgram"));
     206           0 :     CLEW_CHECK_FUNCTION(__clewRetainKernel                  = (PFNCLRETAINKERNEL                )CLCC_DYNLIB_IMPORT(module, "clRetainKernel"));
     207           0 :     CLEW_CHECK_FUNCTION(__clewReleaseKernel                 = (PFNCLRELEASEKERNEL               )CLCC_DYNLIB_IMPORT(module, "clReleaseKernel"));
     208           0 :     CLEW_CHECK_FUNCTION(__clewSetKernelArg                  = (PFNCLSETKERNELARG                )CLCC_DYNLIB_IMPORT(module, "clSetKernelArg"));
     209           0 :     CLEW_CHECK_FUNCTION(__clewGetKernelInfo                 = (PFNCLGETKERNELINFO               )CLCC_DYNLIB_IMPORT(module, "clGetKernelInfo"));
     210           0 :     CLEW_CHECK_FUNCTION(__clewGetKernelWorkGroupInfo        = (PFNCLGETKERNELWORKGROUPINFO      )CLCC_DYNLIB_IMPORT(module, "clGetKernelWorkGroupInfo"));
     211           0 :     CLEW_CHECK_FUNCTION(__clewWaitForEvents                 = (PFNCLWAITFOREVENTS               )CLCC_DYNLIB_IMPORT(module, "clWaitForEvents"));
     212           0 :     CLEW_CHECK_FUNCTION(__clewGetEventInfo                  = (PFNCLGETEVENTINFO                )CLCC_DYNLIB_IMPORT(module, "clGetEventInfo"));
     213           0 :     CLEW_CHECK_FUNCTION(__clewRetainEvent                   = (PFNCLRETAINEVENT                 )CLCC_DYNLIB_IMPORT(module, "clRetainEvent"));
     214           0 :     CLEW_CHECK_FUNCTION(__clewReleaseEvent                  = (PFNCLRELEASEEVENT                )CLCC_DYNLIB_IMPORT(module, "clReleaseEvent"));
     215           0 :     CLEW_CHECK_FUNCTION(__clewGetEventProfilingInfo         = (PFNCLGETEVENTPROFILINGINFO       )CLCC_DYNLIB_IMPORT(module, "clGetEventProfilingInfo"));
     216           0 :     CLEW_CHECK_FUNCTION(__clewFlush                         = (PFNCLFLUSH                       )CLCC_DYNLIB_IMPORT(module, "clFlush"));
     217           0 :     CLEW_CHECK_FUNCTION(__clewFinish                        = (PFNCLFINISH                      )CLCC_DYNLIB_IMPORT(module, "clFinish"));
     218           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueReadBuffer             = (PFNCLENQUEUEREADBUFFER           )CLCC_DYNLIB_IMPORT(module, "clEnqueueReadBuffer"));
     219           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueWriteBuffer            = (PFNCLENQUEUEWRITEBUFFER          )CLCC_DYNLIB_IMPORT(module, "clEnqueueWriteBuffer"));
     220           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueCopyBuffer             = (PFNCLENQUEUECOPYBUFFER           )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyBuffer"));
     221           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueReadImage              = (PFNCLENQUEUEREADIMAGE            )CLCC_DYNLIB_IMPORT(module, "clEnqueueReadImage"));
     222           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueWriteImage             = (PFNCLENQUEUEWRITEIMAGE           )CLCC_DYNLIB_IMPORT(module, "clEnqueueWriteImage"));
     223           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueCopyImage              = (PFNCLENQUEUECOPYIMAGE            )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyImage"));
     224           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueCopyImageToBuffer      = (PFNCLENQUEUECOPYIMAGETOBUFFER    )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyImageToBuffer"));
     225           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueCopyBufferToImage      = (PFNCLENQUEUECOPYBUFFERTOIMAGE    )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyBufferToImage"));
     226           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueMapBuffer              = (PFNCLENQUEUEMAPBUFFER            )CLCC_DYNLIB_IMPORT(module, "clEnqueueMapBuffer"));
     227           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueMapImage               = (PFNCLENQUEUEMAPIMAGE             )CLCC_DYNLIB_IMPORT(module, "clEnqueueMapImage"));
     228           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueUnmapMemObject         = (PFNCLENQUEUEUNMAPMEMOBJECT       )CLCC_DYNLIB_IMPORT(module, "clEnqueueUnmapMemObject"));
     229           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueNDRangeKernel          = (PFNCLENQUEUENDRANGEKERNEL        )CLCC_DYNLIB_IMPORT(module, "clEnqueueNDRangeKernel"));
     230           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueTask                   = (PFNCLENQUEUETASK                 )CLCC_DYNLIB_IMPORT(module, "clEnqueueTask"));
     231           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueNativeKernel           = (PFNCLENQUEUENATIVEKERNEL         )CLCC_DYNLIB_IMPORT(module, "clEnqueueNativeKernel"));
     232           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueMarker                 = (PFNCLENQUEUEMARKER               )CLCC_DYNLIB_IMPORT(module, "clEnqueueMarker"));
     233           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueWaitForEvents          = (PFNCLENQUEUEWAITFOREVENTS        )CLCC_DYNLIB_IMPORT(module, "clEnqueueWaitForEvents"));
     234           0 :     CLEW_CHECK_FUNCTION(__clewEnqueueBarrier                = (PFNCLENQUEUEBARRIER              )CLCC_DYNLIB_IMPORT(module, "clEnqueueBarrier"));
     235           0 :     CLEW_CHECK_FUNCTION(__clewGetExtensionFunctionAddress   = (PFNCLGETEXTENSIONFUNCTIONADDRESS )CLCC_DYNLIB_IMPORT(module, "clGetExtensionFunctionAddress"));
     236             : 
     237           0 :     return CLEW_SUCCESS;
     238             : }
     239             : 
     240             : //! \param error CL error code
     241             : //! \return a string representation of the error code
     242           0 : const char* clewErrorString(cl_int error)
     243             : {
     244             :     static const char* strings[] =
     245             :     {
     246             :         // Error Codes
     247             :           "CL_SUCCESS"                                  //   0
     248             :         , "CL_DEVICE_NOT_FOUND"                         //  -1
     249             :         , "CL_DEVICE_NOT_AVAILABLE"                     //  -2
     250             :         , "CL_COMPILER_NOT_AVAILABLE"                   //  -3
     251             :         , "CL_MEM_OBJECT_ALLOCATION_FAILURE"            //  -4
     252             :         , "CL_OUT_OF_RESOURCES"                         //  -5
     253             :         , "CL_OUT_OF_HOST_MEMORY"                       //  -6
     254             :         , "CL_PROFILING_INFO_NOT_AVAILABLE"             //  -7
     255             :         , "CL_MEM_COPY_OVERLAP"                         //  -8
     256             :         , "CL_IMAGE_FORMAT_MISMATCH"                    //  -9
     257             :         , "CL_IMAGE_FORMAT_NOT_SUPPORTED"               //  -10
     258             :         , "CL_BUILD_PROGRAM_FAILURE"                    //  -11
     259             :         , "CL_MAP_FAILURE"                              //  -12
     260             : 
     261             :         , ""    //  -13
     262             :         , ""    //  -14
     263             :         , ""    //  -15
     264             :         , ""    //  -16
     265             :         , ""    //  -17
     266             :         , ""    //  -18
     267             :         , ""    //  -19
     268             : 
     269             :         , ""    //  -20
     270             :         , ""    //  -21
     271             :         , ""    //  -22
     272             :         , ""    //  -23
     273             :         , ""    //  -24
     274             :         , ""    //  -25
     275             :         , ""    //  -26
     276             :         , ""    //  -27
     277             :         , ""    //  -28
     278             :         , ""    //  -29
     279             : 
     280             :         , "CL_INVALID_VALUE"                            //  -30
     281             :         , "CL_INVALID_DEVICE_TYPE"                      //  -31
     282             :         , "CL_INVALID_PLATFORM"                         //  -32
     283             :         , "CL_INVALID_DEVICE"                           //  -33
     284             :         , "CL_INVALID_CONTEXT"                          //  -34
     285             :         , "CL_INVALID_QUEUE_PROPERTIES"                 //  -35
     286             :         , "CL_INVALID_COMMAND_QUEUE"                    //  -36
     287             :         , "CL_INVALID_HOST_PTR"                         //  -37
     288             :         , "CL_INVALID_MEM_OBJECT"                       //  -38
     289             :         , "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR"          //  -39
     290             :         , "CL_INVALID_IMAGE_SIZE"                       //  -40
     291             :         , "CL_INVALID_SAMPLER"                          //  -41
     292             :         , "CL_INVALID_BINARY"                           //  -42
     293             :         , "CL_INVALID_BUILD_OPTIONS"                    //  -43
     294             :         , "CL_INVALID_PROGRAM"                          //  -44
     295             :         , "CL_INVALID_PROGRAM_EXECUTABLE"               //  -45
     296             :         , "CL_INVALID_KERNEL_NAME"                      //  -46
     297             :         , "CL_INVALID_KERNEL_DEFINITION"                //  -47
     298             :         , "CL_INVALID_KERNEL"                           //  -48
     299             :         , "CL_INVALID_ARG_INDEX"                        //  -49
     300             :         , "CL_INVALID_ARG_VALUE"                        //  -50
     301             :         , "CL_INVALID_ARG_SIZE"                         //  -51
     302             :         , "CL_INVALID_KERNEL_ARGS"                      //  -52
     303             :         , "CL_INVALID_WORK_DIMENSION"                   //  -53
     304             :         , "CL_INVALID_WORK_GROUP_SIZE"                  //  -54
     305             :         , "CL_INVALID_WORK_ITEM_SIZE"                   //  -55
     306             :         , "CL_INVALID_GLOBAL_OFFSET"                    //  -56
     307             :         , "CL_INVALID_EVENT_WAIT_LIST"                  //  -57
     308             :         , "CL_INVALID_EVENT"                            //  -58
     309             :         , "CL_INVALID_OPERATION"                        //  -59
     310             :         , "CL_INVALID_GL_OBJECT"                        //  -60
     311             :         , "CL_INVALID_BUFFER_SIZE"                      //  -61
     312             :         , "CL_INVALID_MIP_LEVEL"                        //  -62
     313             :         , "CL_INVALID_GLOBAL_WORK_SIZE"                 //  -63
     314             :     };
     315             : 
     316           0 :     if  (   (error > 0)
     317           0 :         ||  (error < -63)
     318             :         )
     319             :     {
     320           0 :         return "unknown error code (no OpenCL driver?)";
     321             :     }
     322             : 
     323           0 :     return strings[-error];
     324             : }

Generated by: LCOV version 1.10