Trouble running platform filter

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Trouble running platform filter

HenryS
Probably some very basic thing but I have trouble running the simple example on https://jogamp.org/deployment/jogamp-next/javadoc/jocl/javadoc/ to filter GPU-only platforms. The line

    CLPlatform platform = CLPlatform.getDefault(type(GPU));

does not compile (GPU does not resolve to a variable). I tried several other variants but I get (other) compiler errors as well. I import the necessary packages (opencl.* and opencl.util.*). Any ideas what I am doing wrong?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trouble running platform filter

Wade Walker
Administrator
If it doesn't even compile, there must be something wrong in your compilation setup. Have you checked the steps at https://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE? It doesn't specifically give a JOCL example, but JOCL works the same way as JOGL.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trouble running platform filter

HenryS
Thanks for your reply. I am running Eclipse and I installed the libraries according the Eclipse IDE User Library instructions. I got the jogamp jocl HelloWorld example which I got up and running. inserted the following statements in the HelloWorls example:

        import com.jogamp.opencl.*;
        import com.jogamp.opencl.util.*;

        CLPlatform platform1 = CLPlatform.getDefault(type (GPU));
        CLPlatform platform2 = CLPlatform.getDefault (CLDeviceFilters.type (CLDevice.Type.GPU));
        CLPlatform platform3 = CLPlatform.getDefault (Filter<CLDevice> GPU);
     
The statement with platform1 complains about GPU cannot be resolved to a variable
The statement with platform2: the method getDefaiut (Filter<CLPlatform> ...) in the type CLPlatform is not applicable for the argument (Filter<CLDevice>)
platform3: Filter, CLDevice and GPU cannot be resolved as a variable

The last 2 examples are suggested reading the javadocs. Are these two imports sufficient?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trouble running platform filter

Wade Walker
Administrator
It looks like the Javadoc is outdated :) If you look in the code for the tests, for example in https://github.com/WadeWalker/jocl/blob/master/test/com/jogamp/opencl/HighLevelBindingTest.java, you can see examples of how to do this.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trouble running platform filter

HenryS
It was a matter of imports indeed. Thanks for your help!

Results are interesting. I use a slightly adapted version of platformTest:
   public void platformTest ()
   {
      final CLPlatform platformGPU = CLPlatform.getDefault(version(CL_1_0), type(GPU));
      final CLPlatform platformCPU = CLPlatform.getDefault(version(CL_1_0), type(CPU));

      if (platformGPU != null && platformGPU.listCLDevices(GPU).length > 0)
      {
         System.out.println (platformGPU.listCLDevices(GPU).length + " OpenCL GPU platform(s) present");
      } // if
     
      if (platformCPU != null && platformCPU.listCLDevices(CPU).length > 0);
      {
         System.out.println (platformCPU.listCLDevices(CPU).length + " OpenCL CPU platform(s) present");
      } // if
   } /*** platformTest ***/  

That reports:
1 OpenCL GPU platform(s) present
1 OpenCL CPU platform(s) present

However, when in the same program 'enumerating'  thru all platforms and for each platform thru all devices I get 2 CPU platforms:

Platform NVIDIA CUDA contains 1 devices
   Device: CLDevice [id: 2716768 name: GeForce GTX 1060 6GB type: GPU profile: FULL_PROFILE]
Platform Intel(R) OpenCL contains 1 devices
   Device: CLDevice [id: 151383568 name: Intel(R) Core(TM) i7 CPU         920  @ 2.67GHz type: CPU profile: FULL_PROFILE]
Platform AMD Accelerated Parallel Processing contains 1 devices
   Device: CLDevice [id: 151784080 name: Intel(R) Core(TM) i7 CPU         920  @ 2.67GHz type: CPU profile: FULL_PROFILE]

I have 2 exactly the same CPU platforms present. CLPlatform.getDefault(version(CL_1_0), type(CPU)) does not see that. The AMD drivers have the tendency to act as drivers for the Intel CPU's as well. And they are not so performant as the Intel drivers. In the benchmark they are about 3.5 as slow for complex tasks compared to the Intel drivers.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trouble running platform filter

Wade Walker
Administrator
Glad it's working now! The behavior you describe is normal -- CLPlatform.getDefault() returns the default platform, not all of them :) Iterating through them will always be more thorough and informative.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trouble running platform filter

HenryS
Ah, thanks for warning me! Saves an unnecessry addition to the bug list ;-)
Loading...