From 06073dcba3805f53dcb7abc464cbcc566549f2d4 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Wed, 6 Apr 2016 19:21:45 -0500 Subject: [PATCH] Fixing some opencl issues. --- CMakeLists.txt | 2 ++ rai/plat/posix/openclapi.cpp | 2 +- rai/plat/windows/openclapi.cpp | 11 +++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c489a0e3..b56c8197 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,8 @@ include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets find_package (cppnetlib) include_directories (${CPPNETLIB_INCLUDE_DIRS}) +include_directories (${OPENCL_INCLUDE_DIRS}) + add_library (ed25519 ed25519-donna/ed25519-donna-portable.h ed25519-donna/ed25519-hash-custom.h diff --git a/rai/plat/posix/openclapi.cpp b/rai/plat/posix/openclapi.cpp index 0960c5ec..d0cb3151 100644 --- a/rai/plat/posix/openclapi.cpp +++ b/rai/plat/posix/openclapi.cpp @@ -20,7 +20,7 @@ public: clCreateCommandQueue = reinterpret_cast (dlsym(opencl_library, "clCreateCommandQueue")); clCreateBuffer = reinterpret_cast (dlsym(opencl_library, "clCreateBuffer")); clCreateProgramWithSource = reinterpret_cast (dlsym(opencl_library, "clCreateProgramWithSource")); - clCreateBuildProgram = reinterpret_cast (dlsym(opencl_library, "clCreateBuildProgram")); + clBuildProgram = reinterpret_cast (dlsym(opencl_library, "clBuildProgram")); clCreateKernel = reinterpret_cast (dlsym(opencl_library, "clCreateKernel")); clSetKernelArg = reinterpret_cast (dlsym(opencl_library, "clSetKernelArg")); clReleaseKernel = reinterpret_cast (dlsym(opencl_library, "clReleaseKernel")); diff --git a/rai/plat/windows/openclapi.cpp b/rai/plat/windows/openclapi.cpp index 3507f827..8a685f9a 100644 --- a/rai/plat/windows/openclapi.cpp +++ b/rai/plat/windows/openclapi.cpp @@ -19,8 +19,8 @@ namespace clCreateContext = reinterpret_cast (GetProcAddress(opencl_library, "clCreateContext")); clCreateCommandQueue = reinterpret_cast (GetProcAddress(opencl_library, "clCreateCommandQueue")); clCreateBuffer = reinterpret_cast (GetProcAddress(opencl_library, "clCreateBuffer")); - clCreateProgramWithSource = reinterpret_cast (dlsym(opencl_library, "clCreateProgramWithSource")); - clCreateBuildProgram = reinterpret_cast (GetProcAddress(opencl_library, "clCreateBuildProgram")); + clCreateProgramWithSource = reinterpret_cast (GetProcAddress(opencl_library, "clCreateProgramWithSource")); + clBuildProgram = reinterpret_cast (GetProcAddress(opencl_library, "clBuildProgram")); clCreateKernel = reinterpret_cast (GetProcAddress(opencl_library, "clCreateKernel")); clSetKernelArg = reinterpret_cast (GetProcAddress(opencl_library, "clSetKernelArg")); clReleaseKernel = reinterpret_cast (GetProcAddress(opencl_library, "clReleaseKernel")); @@ -34,7 +34,7 @@ namespace } ~opencl_initializer() { - dlclose(opencl_library); + FreeLibrary(opencl_library); } HMODULE opencl_library; cl_int(*clGetPlatformIDs) (cl_uint, cl_platform_id *, cl_uint *); @@ -71,7 +71,10 @@ cl_int clGetPlatformIDs(cl_uint num_entries, cl_platform_id * platforms, cl_uint else { result = CL_SUCCESS; - *num_platforms = 0; + if (num_platforms != nullptr) + { + *num_platforms = 0; + } } return result; }