Device Selector choosing incorrect device


This problem manifests itself in different ways depending on the hardware and drivers used.

  • exception cl::sycl::compile_program_error from create_program_for_kernel_impl()
  • terminate called after throwing an instance of ‘cl::sycl::exception’ what(): Error: [ComputeCpp:RT0106] Device not found

The output of computecpp_info shows a supported devices, but also an unsupported GPU device, for example:

Device 0:

  Device is supported                     : NO - Device does not support SPIR
  CL_DEVICE_NAME                          : Tesla K20m
  CL_DEVICE_VENDOR                        : NVIDIA Corporation
  CL_DRIVER_VERSION                       : 390.30
  CL_DEVICE_TYPE                          : CL_DEVICE_TYPE_GPU
Device 1:
    Device is supported                     : YES - Tested internally by Codeplay Software Ltd.
    CL_DEVICE_NAME                          : Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
    CL_DEVICE_VENDOR                        : Intel(R) Corporation
    CL_DRIVER_VERSION                       :
    CL_DEVICE_TYPE                          : CL_DEVICE_TYPE_CPU

This is caused by the use of the SYCL default selector.

cl::sycl::default_selector selector;

The default selector will try to execute on a GPU by default regardless of the information from computecpp_info.

To solve this use a custom selector, there’s an example of how to do this in the sample code.

Alternatively you can specify the environment variable COMPUTECPP_TARGET=intel:cpu in this case to force selection of an Intel CPU.