0

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:

  • Uninstall/reinstall Cygwin tools
  • Uninstall/reinstall both 32 and 64 bit libraries in the Nvidia GPU Computing toolkit
  • Uninstall/reinstall Eclipse and checked most settings
  • Avoiding 32 bit memory restrictions by adding "-mcmodel=medium" or "-mcmodel=large". (According to searches, at some point 32 and 64 bit binaries are being mixed.)
  • Confirmed that I am only using 64 bit Nvidia libraries and Cygwin tools.

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.

Veedrac
  • 58,273
  • 15
  • 112
  • 169
  • Searching for _"relocation truncated to fit"_ would have directed you to http://stackoverflow.com/questions/10486116/what-does-this-gcc-error-relocation-truncated-to-fit-mean among other links. – Captain Obvlious Jun 12 '14 at 16:30
  • Welcome to SO and a quick note: to increase the chance that your question is answered, you need to make it succinct so that it is read quickly. I have edited your question to reflect this. Please review and make sure it contains the essentials of your problem. – Sabuncu Jun 12 '14 at 17:30
  • @Sabuncu I've pretty much applied your suggested edit for you. People didn't seem to get quite how amazing an edit it was. Probably because they are too lazy to read it ;). – Veedrac Jun 12 '14 at 17:39
  • @Veedrac Thank you so much. But separately I have flagged the question and have requested moderator attention. I am disappointed at how quickly other reviewers judge an edit simply based on the amount of "red" (deleted) content. Thanks again. – Sabuncu Jun 12 '14 at 17:54
  • I suppose I could have used fewer words in describing my problems, but the fairly significant trimming down that you did was in my opinion excessive as it gives the picture that I didn't do my research. The link posted by captain obvious was one of the first things I read up on and it didn't help at all, it just confirmed my suspicions. – SarcasticJoe Jun 13 '14 at 07:02
  • @Sabuncu See my previous comment (noticed I forgot the "@"-part only after the 5 minute edit window had passed) – SarcasticJoe Jun 13 '14 at 12:06
  • I understand, I may have been too aggressive w/ the editing, I understand. – Sabuncu Jun 13 '14 at 13:03

2 Answers2

1

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.

1

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})