device_function.hip 346 B

1234567891011121314151617
  1. #include <system_error>
  2. #include <hip/hip_runtime_api.h>
  3. static __global__ void fake_hip_kernel()
  4. {
  5. }
  6. int __host__ try_compile_hip_func(int x)
  7. {
  8. fake_hip_kernel<<<1, 1>>>();
  9. bool valid = (hipSuccess == hipGetLastError());
  10. if (!valid) {
  11. throw std::system_error(ENODEV, std::generic_category(), "no hip device");
  12. }
  13. return x * x;
  14. }