5 Replies Latest reply on Oct 26, 2009 6:10 AM by Sternenprinz

    OpenCL.dll dynamic loading issues

    fiery

      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

        • OpenCL.dll dynamic loading issues
          nou

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

            • OpenCL.dll dynamic loading issues
              fiery

               

              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...

                • OpenCL.dll dynamic loading issues
                  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).

                    • OpenCL.dll dynamic loading issues
                      fiery

                       

                      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.

                        • OpenCL.dll dynamic loading issues
                          Sternenprinz

                          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. :-/