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.cpp 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * \file dnn/test/cuda/utils.cpp
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. */
  11. #include "./utils.h"
  12. namespace megdnn {
  13. namespace test {
  14. bool check_compute_capability(int major, int minor) {
  15. int dev;
  16. cuda_check(cudaGetDevice(&dev));
  17. cudaDeviceProp prop;
  18. cuda_check(cudaGetDeviceProperties(&prop, dev));
  19. //! we just skip sm_62 here, which means jetson tx2
  20. //! unless require sm_62 explicitly
  21. if (prop.major == 6 && prop.minor == 2) {
  22. return prop.major == major && prop.minor == minor;
  23. }
  24. return prop.major > major || (prop.major == major && prop.minor >= minor);
  25. }
  26. bool check_compute_capability_eq(int major, int minor) {
  27. int dev;
  28. cuda_check(cudaGetDevice(&dev));
  29. cudaDeviceProp prop;
  30. cuda_check(cudaGetDeviceProperties(&prop, dev));
  31. return (prop.major == major && prop.minor == minor);
  32. }
  33. const cudaDeviceProp current_cuda_device_prop() {
  34. int dev;
  35. cuda_check(cudaGetDevice(&dev));
  36. cudaDeviceProp prop;
  37. cuda_check(cudaGetDeviceProperties(&prop, dev));
  38. return prop;
  39. }
  40. } // namespace test
  41. } // namespace megdnn
  42. // vim: syntax=cpp.doxygen