nvidia_compute_capability.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #ifndef BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP
  11. #define BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP
  12. #include <boost/compute/device.hpp>
  13. #ifdef BOOST_COMPUTE_HAVE_HDR_CL_EXT
  14. #include <CL/cl_ext.h>
  15. #endif
  16. namespace boost {
  17. namespace compute {
  18. namespace detail {
  19. #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
  20. #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
  21. #else
  22. #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
  23. #endif
  24. #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
  25. #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
  26. #else
  27. #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
  28. #endif
  29. inline void get_nvidia_compute_capability(const device &device, int &major, int &minor)
  30. {
  31. if(!device.supports_extension("cl_nv_device_attribute_query")){
  32. major = minor = 0;
  33. return;
  34. }
  35. major = device.get_info<uint_>(BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV);
  36. minor = device.get_info<uint_>(BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV);
  37. }
  38. inline bool check_nvidia_compute_capability(const device &device, int major, int minor)
  39. {
  40. int actual_major, actual_minor;
  41. get_nvidia_compute_capability(device, actual_major, actual_minor);
  42. return actual_major > major ||
  43. (actual_major == major && actual_minor >= minor);
  44. }
  45. } // end detail namespace
  46. } // end compute namespace
  47. } // end boost namespace
  48. #endif // BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP