SarcasticJoe
SarcasticJoe

Reputation: 11

Compile errors using Nvidia GPU Computing toolkit and Cygwin with Eclipse

I am using Nvidia GPU Computing toolkit on Windows 7 x64 with the 64 bit Cygwin package and Eclipse. (I use the internal build tools because GNU make doesn't lik colons in Windows paths.) My code:

Here's the fairly basic piece of code: #include #include using namespace std;

int main() {
    cl_int error = 42;
    cl_platform_id platform;

    error = clGetPlatformIDs(1, &platform, NULL);

    return 0;
}

C++ code both compiles and runs fine, and I can use OpenCL headers and cl_int and cl_device_id, but with clGetPlatformID I get the following compile error:

relocation truncated to fit: R_X86_64_32 against symbol 
'__imp_clGetPlatformIDs' defined in .idata$5 section in 
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\lib
\x64/OpenCL.lib(OpenCL.dll.b)

I have tried the following:

My guess is that the internal builder is to blame, but using it was the solution to another problem that caused the build to fail.

Upvotes: 0

Views: 596

Answers (2)

Yuri Pechatnov
Yuri Pechatnov

Reputation: 11

I had the same error, finally I have solved this problem and the latest what I have done is:

1) In cygwin install all packages containing opencl in name.

2) Next, in ...\cygwin\etc\OpenCL\vendors\ (I have found pocl.icd there) create nvidia.icd and place there one string "/cygdrive/c/Windows/System32/nvopencl.dll". The similar actions can be done for Intel OpenCL driver.

3) Finally do not make mistakes (as I did) in CMake file. Example of working code:

cmake_minimum_required(VERSION 3.6)

set(MODULE_NAME opencl-test)

project(${MODULE_NAME})

set(CMAKE_CXX_STANDARD 14)

find_package(OpenCL)

# set include directories
include_directories(${OpenCL_INCLUDE_DIRS})

# set source files
set(SOURCE_FILES main.cpp)
add_executable(${MODULE_NAME} ${SOURCE_FILES})

# linking
target_link_libraries(${MODULE_NAME} ${OpenCL_LIBRARY})

Upvotes: 1

SarcasticJoe
SarcasticJoe

Reputation: 11

I've got a bit of an update on this:

Wiped and re-installed pretty much everything (CUDA toolkit, Cygwin, Eclipse) and it still gives me the same error even with the appropriate flags (which I used before Captain Obvious linked to a post suggesting it).

The progress I've made is that I've probably zeroed in on where the problem actually lies. Using relative paths solved the issues with GNU make not being able to deal with colons in paths. This basically clears the Eclipse internal builder. However I've got almost the exact same setup working on another machine, the differences being that this setup has an AMD card and thus uses the AMD App SDK rather than Nvidia's OpenCL toolkit.

My suspicion is that this might be a bug brought on by the recent released version 6.0 of the CUDA toolkit as it introduces some pretty major upgrades like unified memory and they might not have tested it so well without the NSight Visual Studio-plugin. After all they do recommend that you develop using Visual Studio with that plugin and I don't have (legal) access to Visual Studio right now.

Edit: I've pretty now much confirmed it... Installed the AMD App SDK on the Nvidia GPU machine and it runs flawlessly, so seems like Nvidia has actually fucked up OpenCL in version 6 of the CUDA Toolkit. Thou knowing that they're in competition with OpenCL trough CUDA i hardly find this surprising.

Upvotes: 1

Related Questions