]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/compute/detail/nvidia_compute_capability.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / compute / detail / nvidia_compute_capability.hpp
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
11 #ifndef BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP
12 #define BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP
13
14 #include <boost/compute/device.hpp>
15
16 #ifdef BOOST_COMPUTE_HAVE_HDR_CL_EXT
17 #include <boost/compute/detail/cl_versions.hpp>
18 #include <CL/cl_ext.h>
19 #endif
20
21 namespace boost {
22 namespace compute {
23 namespace detail {
24
25 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
26 #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
27 #else
28 #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
29 #endif
30
31 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
32 #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
33 #else
34 #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
35 #endif
36
37 inline void get_nvidia_compute_capability(const device &device, int &major, int &minor)
38 {
39 if(!device.supports_extension("cl_nv_device_attribute_query")){
40 major = minor = 0;
41 return;
42 }
43
44 major = device.get_info<uint_>(BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV);
45 minor = device.get_info<uint_>(BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV);
46 }
47
48 inline bool check_nvidia_compute_capability(const device &device, int major, int minor)
49 {
50 int actual_major, actual_minor;
51 get_nvidia_compute_capability(device, actual_major, actual_minor);
52
53 return actual_major > major ||
54 (actual_major == major && actual_minor >= minor);
55 }
56
57 } // end detail namespace
58 } // end compute namespace
59 } // end boost namespace
60
61 #endif // BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP