bkloppenborg / liboi

OpenCL Interferometry Library
https://github.com/bkloppenborg/liboi/wiki
GNU Lesser General Public License v3.0
5 stars 6 forks source link

FindOpenCL.cmake fails to detect correct version on NVIDIA hardware #45

Closed bkloppenborg closed 9 years ago

bkloppenborg commented 9 years ago

The present FindOpenCL.cmake script detects OpenCL 1.2 on machines with NVIDIA hardware even though they only support OpenCL 1.1. This is because the find script checks the headers, but not the libraries against which the executable will be linked.

bkloppenborg commented 9 years ago

A valid workaround is to do the following: Edit the simtoi/lib/liboi/src/CMakeLists.txt file. There is a block of text that looks like this:

# Find OpenCL. Set compiler flags if we find an old (1.0, 1.1) version
# to use clCreateFromGLTexture3D on these old devices.
find_package(OpenCL REQUIRED)
include_directories(${OPENCL_INCLUDE_DIRS})
message(STATUS "Found OpenCL Version: ${OpenCL_VERSION_STRING}")
if(${OpenCL_VERSION_STRING} VERSION_EQUAL 1.0)
    add_definitions(-DDETECTED_OPENCL_1_0)
elseif(${OpenCL_VERSION_STRING} VERSION_EQUAL 1.1)
    add_definitions(-DDETECTED_OPENCL_1_1)
elseif(${OpenCL_VERSION_STRING} VERSION_EQUAL 1.2)
    add_definitions(-DDETECTED_OPENCL_1_2)
elseif(${OpenCL_VERSION_STRING} VERSION_EQUAL 2.0)
    add_definitions(-DDETECTED_OPENCL_2_0)
else(${OpenCL_VERSION_STRING} VERSION_EQUAL 2.0)
    add_definitions(-DDETECTED_OPENCL_UNKNOWN_VERSION)
endif(${OpenCL_VERSION_STRING} VERSION_EQUAL 1.0)

Comment out all of the if-statements, but leave add_definitions(-DDETECTED_OPENCL_1_1) uncommented. Remove everything in the build directory, redo cmake, and try compiling again.

bkloppenborg commented 9 years ago

Fixed in commit 56521e0ef67da0ef93c119394743657e2ec96e46