Skip to content

Explicit Device Selection

Hüseyin Tuğrul BÜYÜKIŞIK edited this page May 29, 2017 · 9 revisions

Although the v1.0.x versions use automatic selection of all XYZ types like

     ClNumberCruncher cruncher = new ClNumberCruncher(AcceleratorType.GPU|AcceleratorType.CPU, kernelString);

now with v1.1.x+, it can be chosen using Hardware namespace like in these examples:

     Hardware.ClPlatforms platforms = Hardware.ClPlatforms.all();
     ClNumberCruncher cruncher = new ClNumberCruncher(platforms.cpus(), kernelString);
     // or with these:
     platforms.devicesIntel()
     platforms.devicesWithDedicatedMemory()
     platforms.platformsAmd().gpus()

     // to select single amd gpu from amd platform (since some other platforms can see same device and duplicate)
     platforms.platformsAmd().gpus().devicesWithMostComputeUnits()[0] 
     // selects fury-x over fury if both are in system


     // to select gpu and cpu both with most numerous compute units compared to other
     // devices with their respective types all 
     var devices = platforms.platformsIntel().gpus().devicesWithMostComputeUnits()[0];
     var devices2 = platforms.platformsIntel().cpus().devicesWithMostComputeUnits()[0];
     var devices3= devices+devices2; // any number of devices can be added like this, not just one

For CPU devices, less number of cores can be chosen by device partition:

   platforms.platformsAmd().cpus(true); // N-1 cores
   platforms.platformsAmd().cpus(true,streamOnOff,5); // min(5,N-1) cores

v1.1.7+ features nbody performance related device reordering:

Cekirdekler.Hardware.ClPlatforms platforms = Cekirdekler.Hardware.ClPlatforms.all();
var selectedDevices = platforms.platformsAmd().devicesAmd().devicesWithHighestDirectNbodyPerformance();

here first device is the best nbody performer.

selectedDevices[0]