Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:44:34

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP
0012 #define BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP
0013 
0014 #include <boost/compute/device.hpp>
0015 
0016 #ifdef BOOST_COMPUTE_HAVE_HDR_CL_EXT    
0017   #include <boost/compute/detail/cl_versions.hpp>
0018   #include <CL/cl_ext.h>
0019 #endif
0020 
0021 namespace boost {
0022 namespace compute {
0023 namespace detail {
0024 
0025 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
0026     #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV
0027 #else
0028     #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
0029 #endif
0030 
0031 #ifdef CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
0032     #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV
0033 #else
0034     #define BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
0035 #endif
0036 
0037 inline void get_nvidia_compute_capability(const device &device, int &major, int &minor)
0038 {
0039     if(!device.supports_extension("cl_nv_device_attribute_query")){
0040         major = minor = 0;
0041         return;
0042     }
0043 
0044     major = device.get_info<uint_>(BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV);
0045     minor = device.get_info<uint_>(BOOST_COMPUTE_CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV);
0046 }
0047 
0048 inline bool check_nvidia_compute_capability(const device &device, int major, int minor)
0049 {
0050     int actual_major, actual_minor;
0051     get_nvidia_compute_capability(device, actual_major, actual_minor);
0052 
0053     return actual_major > major ||
0054            (actual_major == major && actual_minor >= minor);
0055 }
0056 
0057 } // end detail namespace
0058 } // end compute namespace
0059 } // end boost namespace
0060 
0061 #endif // BOOST_COMPUTE_DETAIL_NVIDIA_COMPUTE_CAPABILITY_HPP