cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

fiery
Journeyman III

OpenCL.dll dynamic loading issues

I'm trying to dynamically load OpenCL.dll and import procedures from it.  It works once, but doesn't work twice.  What I do basically is:

  opencldll:=LoadLibrary(opencldll_filename);
  @clgetplatformids:=GetProcAddress(opencldll,'clGetPlatformIDs');
  @clgetdeviceids  :=GetProcAddress(opencldll,'clGetDeviceIDs');
  clGetPlatformIDs...
  clGetDeviceIDs...
  FreeLibrary(opencldll);

At first I get 1 platform (ID = 0) and 2 devices (one for the GPU, other for the CPU), which is fine and correct.  At subsequent calls however, clGetDeviceIDs only returns 1 device, the CPU.  What's even more weird is that after calling that function once, the "classic" Stream layer also stops working (calInit fails).  Maybe at unloading OpenCL.dll via FreeLibrary the cleanup process is not done properly in OpenCL.dll?

I'm using Stream 2.0 Beta4 with a Radeon HD 3450 card.


Thanks,
Fiery

0 Likes
5 Replies
nou
Exemplar

no getting two devices isnt correct becasue radeon 3450 isnt supported with OpenCL

0 Likes
fiery
Journeyman III

Originally posted by: nou no getting two devices isnt correct becasue radeon 3450 isnt supported with OpenCL

Thanks, but I've just checked it with a Radeon HD 5770, and the very same issue presents there as well...

0 Likes

This works here. Even having an application relying on OpenCL running and having a CAL app running in parallel (e.g. own OCL app + the pciespeedtest demo from AMD).

0 Likes

Originally posted by: Sternenprinz This works here. Even having an application relying on OpenCL running and having a CAL app running in parallel (e.g. own OCL app + the pciespeedtest demo from AMD).

Are you sure your app loads OpenCL.dll dynamically, using LoadLibrary?  With static linking it works fine of course.  When I don't unload the DLL using FreeLibrary and just do the whole thing all over again (LoadLibrary ... GetProcAddress ... clGetPlatformIDs ... clGetDeviceIDs ... LoadLibrary ... GetProcAddress ... clGetPlatformIDs ... clGetDeviceIDs ... etc), it works as expected.

But in our application we don't use static linking, because then our app (which is a generic diagnostic tool, and not just a GPGPU solution) wouldn't start without the presence of OpenCL.dll.

0 Likes

Yes, absolutely sure! I did some rather stupid modifications (loading lib before every single group of clXXX calls and unloading afterwards) to confirm this. Tools like the Debugger from MSVC or the Dependeny Walker confirm that the DLL gets loaded/unloaded every time. The reason for dynamic linking is the same here.

On the other hand, i cant build any kernel for GPU targets. 😕

0 Likes