Advertisement

openCl setup

Started by January 07, 2014 02:58 PM
15 comments, last by fir 11 years ago

If GPU-Z is finding an OpenCL platform then it's working. And, no, a .dll is fine for linking. You might need to tell MinGW to search for it though, I'm not sure it searches System32 by default. Try passing -LC:\Windows\System32 or something like that to the linker (or copy the DLL in your project folder). Loading the entry points of every function manually is stupid since the header already does it for you automatically, you just need to set the linker up right.

It would be great : O but this is not working

(i copied the opencl.dll into mingw lib directory)


c:\!CODE>c:\mingw\bin\gcc  -Wall main.c -lglew32 -lopengl32 -lglu32  -lfreeglut -lOpenCl 
main.c:95:1: warning: multi-line comment
main.c:193:1: warning: multi-line comment
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccMDNaaa.o(.text+0x137):main.c: undefined reference to `clGetPlatformIDs@12'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccMDNaaa.o(.text+0x171):main.c: undefined reference to `clGetDeviceIDs@24'
> Execution finished.
he cannot link the functions.. How would it work like automatic generation of import lib for a dll?

Are you sure that OpenCL.dll is not a 64-bit DLL? This kind of error suggests mingw just skipped the DLL as incompatible, and so could not link. Otherwise, I really don't know. I would suggest spending the time to actually download the SDK to have everything you need before proceeding. It should come with proper DLL's that you can most certainly link to (I'm using the AMD APP since I have an AMD graphics card and I can link to my OpenCL.dll with no issues).

EDIT: lib is not usually the right directory for shared libraries (.dll). Try copying it into bin (though I don't think it will make a difference).

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Advertisement

Are you sure that OpenCL.dll is not a 64-bit DLL? This kind of error suggests mingw just skipped the DLL as incompatible, and so could not link. Otherwise, I really don't know. I would suggest spending the time to actually download the SDK to have everything you need before proceeding. It should come with proper DLL's that you can most certainly link to (I'm using the AMD APP since I have an AMD graphics card and I can link to my OpenCL.dll with no issues).

EDIT: lib is not usually the right directory for shared libraries (.dll). Try copying it into bin (though I don't think it will make a difference).

I can link to it with GetprocAddr call and get results

so it seem to be ok.. dont know.. i will try to stay dynamic loading and check which api calls work ok what info they

give back whhich fails etc - it will take me a couple of hours

but maybe some thing will clarify

some 2 example i found in the www (for example this for mac

https://developer.apple.com/library/mac/samplecode/OpenCL_Hello_World_Example/Listings/hello_c.html

are starting the thing with

int gpu = 1;
err = clGetDeviceIDs(NULL, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL);
with platform_id as a NULL
for me this code fails - I need to pass the platform id to pass (and find a fail later) - its sad :C

some 2 example i found in the www (for example this for mac

https://developer.apple.com/library/mac/samplecode/OpenCL_Hello_World_Example/Listings/hello_c.html

are starting the thing with

int gpu = 1;
err = clGetDeviceIDs(NULL, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL);

with platform_id as a NULL

for me this code fails - I need to pass the platform id to pass (and find a fail later) - its sad :C

Yes, passing NULL as the platform ID is technically implementation defined behaviour, on some implementations it assumes the default platform, on others (like yours) it fails. Does clGetPlatformIDs() not find a platform? That's the platform ID you need to obtain. And if it still doesn't work with an invalid context error, maybe your OpenCL runtime is just broken, we can't really debug your issues remotely sad.png

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”


some 2 example i found in the www (for example this for mac

https://developer.apple.com/library/mac/samplecode/OpenCL_Hello_World_Example/Listings/hello_c.html

are starting the thing with

int gpu = 1;
err = clGetDeviceIDs(NULL, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL);

with platform_id as a NULL

for me this code fails - I need to pass the platform id to pass (and find a fail later) - its sad :C

Yes, passing NULL as the platform ID is technically implementation defined behaviour, on some implementations it assumes the default platform, on others (like yours) it fails. Does clGetPlatformIDs() not find a platform? That's the platform ID you need to obtain. And if it still doesn't work with an invalid context error, maybe your OpenCL runtime is just broken, we can't really debug your issues remotely sad.png

i know, tnx for the answers anyway its much helpfull - i will just test different api calls maybe it will go on

as to platform it seem to return one platform id, this seem to be ok - will check further though as i said need a couple of hours

to test and look

I run the other trouble

when running


static  cl_device_id device_id[10] = {0};
 
static cl_uint num_devices__ = 20;
 
  ret = clGetDeviceIDs_( platform_id[0], CL_DEVICE_TYPE_GPU, 10, device_id, &num_devices__ );
 
if(ret == CL_SUCCESS) printf("get device id success , devices %d ", num_devices__) ;

i got succes but device number is 17334360

othervise it seem run 8for example when put CL_DEVICE_TYPE_ACCELERATOR

oit return the error CL_DEVICE_NOT_FOUND etc correct behavior

dont know the hell it is :C

edit

now i managed to run platform then device (got strange device num 17 mln as i said) then context by create context but when running for the queue i got crash :c

seem that i will not avoid this fail - maybe will need the proper import lib to download (if not whole sdk)

Advertisement

finally i manged to fir this //yuppi

I used clew minilibrary (it works nicely this is just

some code needed for runtime dynamic linking )

then i fired apple example (I needed though

ask for clGetPlatformIDs, because sending NULL

to clGetDeviceIDs do not work here) and this is

working

I think my previous error was done by the thing

i do not used api function typedefs, so when i

was calling this thru casting some argument sizes

was corrupting the argument layout on the stack

(not sure but probably - i had no previous experience

with dynamic linking, now i get a little one ;o

This topic is closed to new replies.

Advertisement