Florent F
Florent F

Reputation: 611

Selecting OpenCL CPU platform in Compute.scala

I installed 3 different OpenCL runtimes on my laptop:

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:

Thank you.

Upvotes: 0

Views: 410

Answers (1)

Florent F
Florent F

Reputation: 611

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!

Upvotes: 0

Related Questions