Skip to content

Detect SYCL GPU backend availability #64

@SylvainJoube

Description

@SylvainJoube

It would be nice to have a function to test GPU availability when using SYCL.

A runtime implementation could be like:

// Checks whether GPU offloading is available in this system
// Don't forget the compilation flag "-fsycl -fsycl-targets=nvptx64-nvidia-cuda,x86_64"
// With x86_64 or spir64 for parallel CPU execution, to target both Nvidia GPUs and native CPUs.
static bool has_gpu()
{
  auto devices = ::sycl::device::get_devices();
  for (const auto& dev : devices)
  {
    if (dev.is_gpu())
    {
      return true;
    }
  }
  return false;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions