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 <boost/compute/detail/cl_versions.hpp>
  15. #include <CL/cl_ext.h>
  16. #endif
  17. namespace boost {
  18. namespace compute {
  19. namespace detail {
  20. #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
  21. #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
  22. #else
  23. #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
  24. #endif
  25. #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
  26. #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
  27. #else
  28. #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
  29. #endif
  30. inline void get_nvidia_compute_capability(const device &device, int &major, int &minor)
  31. {
  32. if(!device.supports_extension("cl_nv_device_attribute_query")){
  33. major = minor = 0;
  34. return;
  35. }
  36. major = device.get_info<uint_>(BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV);
  37. minor = device.get_info<uint_>(BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV);
  38. }
  39. inline bool check_nvidia_compute_capability(const device &device, int major, int minor)
  40. {
  41. int actual_major, actual_minor;
  42. get_nvidia_compute_capability(device, actual_major, actual_minor);
  43. return actual_major > major ||
  44. (actual_major == major && actual_minor >= minor);
  45. }
  46. } // end detail namespace
  47. } // end compute namespace
  48. } // end boost namespace
  49. #endif // BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP