Selecting OpenCL CPU platform in Compute.scala

394 views Asked by At

I installed 3 different OpenCL runtimes on my laptop:

  • NVIDIA CUDA OpenCL on GPU
  • Intel OpenCL SDK on CPU
  • POCL (also on CPU)

As a result, here is a part of the result of clinfo:

$ clinfo
Number of platforms                               3
Platform Name                                   Portable Computing Language
Platform Vendor                                 The pocl project
Platform Version                                OpenCL 1.2 pocl 1.1 None+Asserts, LLVM 6.0.0, SPIR, SLEEF, DISTRO, POCL_DEBUG
...
Platform Name                                   Intel(R) OpenCL
Platform Vendor                                 Intel(R) Corporation
Platform Version                                OpenCL 1.2 LINUX
...
Platform Name                                   NVIDIA CUDA
Platform Vendor                                 NVIDIA Corporation
Platform Version                                OpenCL 1.2 CUDA 9.0.282

Now I want to use the Compute.scala Scala library to perform NDArray computations on GPU and CPU (based on the LWJGL library.

The device type is selected using the following import line at the beginning of the program:

import com.thoughtworks.compute.gpu._ // for GPU
// OR
import com.thoughtworks.compute.cpu._ // for CPU

After a quick test, my code runs fine with both device types. However, how am I supposed to know WHICH platform is running when choosing CPU? Is it the Intel OpenCL platform, or POCL?

By looking at the code of the library, I suspect it just picks the first CPU platform in the platform list.

So my questions are:

  • How do I know which CPU platform is being used?
  • How can I select the platform I want to use in Compute.scala?
  • Maybe it is necessary to "disable" one of the platforms. If it's the case, how can I do that?

Thank you.

1

There are 1 answers

0
Florent F On

I found a quick-and-dirty way to switch between platforms: I simply rename the ICD file in /etc/OpenCL/vendors/ to "disable" it, so that only the platform I want is detected (can be checked with clinfo).

For example $ sudo mv /etc/OpenCL/vendors/pocl.icd /etc/OpenCL/vendors/pocl.icd_ to use intel64 (the other available CPU platform) instead of pocl, and vice-versa for using pocl instead of intel64.

If someone has a more clean and programmatic way to solve this, their are welcome!