You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.h 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <cuda.h>
  3. #include <cuda_runtime.h>
  4. #include <cstdio>
  5. #define cuda_check(expr) \
  6. do { \
  7. auto ret = (expr); \
  8. if (ret != cudaSuccess) { \
  9. fprintf(stderr, "cuda call %s failed", #expr); \
  10. __builtin_trap(); \
  11. } \
  12. } while (0)
  13. namespace megdnn {
  14. namespace test {
  15. bool check_compute_capability(int major, int minor);
  16. bool check_compute_capability_eq(int major, int minor);
  17. const cudaDeviceProp current_cuda_device_prop();
  18. } // namespace test
  19. } // namespace megdnn
  20. #define require_compute_capability(x, y) \
  21. do { \
  22. if (!megdnn::test::check_compute_capability((x), (y))) { \
  23. printf("skip testcase due to cuda compute capability not " \
  24. "require.(expected:%d.%d)\n", \
  25. (x), (y)); \
  26. return; \
  27. } \
  28. } while (0)
  29. #define require_compute_capability_eq(x, y) \
  30. do { \
  31. if (!megdnn::test::check_compute_capability_eq((x), (y))) { \
  32. printf("skip testcase due to cuda compute capability not " \
  33. "equal to %d.%d\n", \
  34. (x), (y)); \
  35. return; \
  36. } \
  37. } while (0)
  38. // vim: syntax=cpp.doxygen