Skip to content

Update sycl interface library to use SYCL 2020 exceptions #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oleksandr-pavlyk opened this issue Oct 13, 2021 · 2 comments
Closed

Update sycl interface library to use SYCL 2020 exceptions #628

oleksandr-pavlyk opened this issue Oct 13, 2021 · 2 comments
Assignees

Comments

@oleksandr-pavlyk
Copy link
Contributor

oleksandr-pavlyk commented Oct 13, 2021

// 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;
}
@oleksandr-pavlyk
Copy link
Contributor Author

This is consistent with example code snippet from SYCL-2020 spec repo, https://github.com/KhronosGroup/SYCL-Docs/blob/SYCL-2020/master/adoc/code/handlingException.cpp

@oleksandr-pavlyk
Copy link
Contributor Author

This is done via #683

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants