Skip to content

Update sycl interface library to use SYCL 2020 exceptions #628

Closed
@oleksandr-pavlyk

Description

@oleksandr-pavlyk
// a.cpp
#include <CL/sycl.hpp>
#include <iostream>

int main(void) {
  sycl::device d;

  try {
     sycl::device pd = d.get_info<sycl::info::device::parent_device>();
  } catch (const sycl::runtime_error &re) {
     std::cerr << "No parent" << std::endl;
  }
  return 0;
}

Compiling this with clang++ -fsycl a.cpp generates lots of SYCL_2020 deprecation warnings.

A way to change this code to conform to SYCL 2020 spec is as follows:

// a_sycl2020_conformant.cpp
#include <CL/sycl.hpp>
#include <iostream>

int main(void) {
  sycl::device d;

  try {
     sycl::device pd = d.get_info<sycl::info::device::parent_device>();
  } catch (const sycl::exception &e) {
     if (e.category() == sycl::sycl_category() && e.code() == sycl::errc::runtime) {
        std::cerr << "No parent" << std::endl;
     } else {
        std::cerr << "Unknown exception occurred: " << ex.what() << std::endl;
        std::terminate();
     }
  }
  return 0;
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions