HPCE / hpce-2014-cw4

3 stars 5 forks source link

Problems setting up OpenCL environment #2

Open bwh10 opened 9 years ago

bwh10 commented 9 years ago

I am having massive problems setting up my OpenCL environment for Windows 7.

  1. For Visual Studio 2013:

I set up the "Additional Include Directories" under C/C++->General to point to the "include" directory in the opencl_sdk which you gave. However, Visual Studio always cannot find certain header files:

1>H:\VS2013\opencl_sdk\include\CL/cl.h(33): fatal error C1083: Cannot open include file: 'CL/cl_platform.h': No such file or directory

I am pretty sure I setup the include dependencies correct on VS:

image

  1. For Mingw:

I used the following Makefile to try and compile the test_opencl program:

all: addition

addition: g++ -std=gnu++0x -c -I "H:\VS2013\opencl_sdk\include" test_opencl.cpp -o test_opencl.o g++ test_opencl.o -o test_opencl.exe -L "H:\VS2013\opencl_sdk\lib\windows\x86" -lOpenCL

However, it throws me the following error:

image

I am at a complete loss of what to do next. Could you perhaps provide steps to show how to correctly setup the OpenCL environment on Windows?

Thanks for your help in advance.

bwh10 commented 9 years ago

I tried compiling test_Opencl.cpp on Cygwin but to no avail as well. The problem is somehow linked to CL\cl.hpp and it gives the following error:

mkdir -p bin g++ -I include -Wall -std=c++11 -O2 -I /cygdrive/c/Users/Bryan/Dropbox/School/EE4_HPC/hpce-2014-cw4/opencl_sdk/include test_opencl.cpp -o bin/test_opencl -L /cygdrive/c/Users/Bryan/Dropbox/School/EE4_HPC/hpce-2014-cw4/opencl_sdk/lib/cygwin/x86_64 -lOpenCL In file included from test_opencl.cpp:19:0: /cygdrive/c/Users/Bryan/Dropbox/School/EE4_HPC/hpce-2014-cw4/opencl_sdk/include/CL/cl.hpp: In member function ‘clint cl::CommandQueue::enqueueNativeKernel(void ()(void), std::pair<void*, unsigned int>, const std::vectorcl::Memory, const std::vector, const std::vectorcl::Event, cl::Event_) const’: /cygdrive/c/Users/Bryan/Dropbox/School/EE4_HPC/hpce-2014-cw4/openclsdk/include/CL/cl.hpp:2996:34: error: invalid conversion from ‘void ()(void)’ to ‘void (attribute((stdcall)) *)(void)’ -fpermissive event), ^ In file included from /cygdrive/c/Users/Bryan/Dropbox/School/EE4_HPC/hpce-2014-cw4/opencl_sdk/include/CL/opencl.h:42:0, from /cygdrive/c/Users/Bryan/Dropbox/School/EE4_HPC/hpce-2014-cw4/opencl_sdk/include/CL/cl.hpp:161, from test_opencl.cpp:19: /cygdrive/c/Users/Bryan/Dropbox/School/EE4_HPC/hpce-2014-cw4/opencl_sdk/include/CL/cl.h:960:1: note: initializing argument 2 of ‘cl_int clEnqueueNativeKernel(cl_commandqueue, void (attribute((stdcall)) )(void), void, size_t, cl_uint, _clmem const_, const void__, cl_uint, _clevent const_, _cl_event__)’ clEnqueueNativeKernel(cl_commandqueue / commandqueue /, ^ makefile:40: recipe for target 'bin/testopencl' failed make: ** [bin/test_opencl] Error 1

Any ideas on how to fix this?

bwh10 commented 9 years ago

After spending 2 days fiddling around with this issue, I finally managed to compile the test_opencl code under Cygwin. The problem was that I was using a 32 bit version rather than the 64 bit version of Cygwin. Apparently, using the 32 bit Cygwin does not work even though I linked it to the 32 bit OpenCL library. This is a very strange problem indeed! However, when I ran test_opencl.exe on my home laptop, it gave:

$ ./test_opencl Segmentation fault (core dumped)

Could it be because I do not have the appropriate OpenCL drivers installed on my home Windows 7 laptop?

m8pple commented 9 years ago

Hrmm, my sympathies - the OpenCL stuff should be somewhat easier to compile than the TBB stuff.

Going through the things you tried:

  1. VS2003: To me it looks like you've set things up correctly in VS 2013. If it can find CL/cl.h, I don't see why it wouldn't be able to find CL/cl_platform.h. The opencl_sdk\include directory looks fine to me.
  2. MinGW: The error message makes no real sense, it is saying that it can't convert from one type to the same type. The only thing I can think is that there is some calling convention problem, .e.g. one is extern "C" and the other is not. But that should not be causing a problem, as this is all using standard OpenCL headers. Sorry, no idea again.
  3. Cyginw: that looks like it is hitting the same error, but now there is more information in the message:
/cygdrive/c/Users/Bryan/Dropbox/School/EE4_HPC/hpce-2014-cw4/opencl_sdk/include/CL/cl.hpp:2996:34: error: invalid conversion from ‘void ()(void)’ to ‘void (attribute((stdcall)) *)(void)’ -fpermissive event),

so the stdcall part is complaining about the calling convention, saying that the way they pass function arguments is different.

I'm beginning to suspect that there is something wrong with cl.hpp. I updated it to a newer version in commit d95ee76423 in response to issue #1, but I wonder if that is causing problems in other clients. For me it worked ok when I tried the updated version, but what you're seeing suggests it isn't.

Ok, anyway, let's focus on getting things working now it compiles.

Yes, the crash could be caused by the lack of an OpenCL support library, as your program will try to dynamically load OpenCL.dll at run-time. That is only the ICD, a sort of wrapper which dispatches to the hardware drivers, but if the program can't link to it it will crash.

On my (64-bit, Win 7) machine I can see OpenCL.dll in C:\Windows\System32. Is there anything there, or anywhere similar?

Things to try would be:

yuchen-w commented 9 years ago

I've also got a similar error when I initially set up the environment (Cuda Toolkit 6.5, VS2013, Win8.1):

Error 2 error C2664: 'cl_int clEnqueueNativeKernel(cl_command_queue,void (stdcall _)(void ),void ,size_t,cl_uint,const clmem ,const void ,cl_uint,const cl_event ,cl_event )' : cannot convert argument 2 from 'void (cdecl )(void )' to 'void (__stdcall )(void )' F:\Skydrive\Documents\Work\EE4\HPCE\CW4\hpce-2014-cw4\include\CL\cl.hpp 2996 1 CW4

image

That was with 32 bit. I also tried compiling 64 bit by forcing it to compile 64 bit in the Configuration Manager: image

And now I just get a load of symbol errors: image

No mention of the C2664 errors I've seen previously. I suspect this might be because the .lib files included in the project are not 64 bit? Or I've set up the 64 bit environment wrongly somehow?

yuchen-w commented 9 years ago

Thought I would try one last thing before going to bed: image

This fixed it! image

chungcyk commented 9 years ago

Been trying to run the test cpp but it seem to got stuck looking for a PDB file, but the dll files are there. Anyone had the same error?

image

yuchen-w commented 9 years ago

Try installing the Intel OpenCL SDK. It looks like it's running on your CPU and not your nvidia card.

m8pple commented 9 years ago

I agree with @yuchen-w

Additionally, the pdb only contains debugging information, and shouldn't be needed just to run the program. Is it because the programming is crashing and trying to find the debug info, or for something else?

chungcyk commented 9 years ago

It just "break" stating the pdb files are missing. What I've done so far is to change the system variable in the test_opencl.cpp so that it has to use my Nvidia chip and that seemed to be a work around solution (although totally not legit I suppose)

yuchen-w commented 9 years ago

I was not able to run OpenCL code on my CPU until I installed the Intel CPU run-time. Did you install that?

https://software.intel.com/en-us/articles/opencl-drivers

@m8pple has posted about this previously.