MCPcopy Create free account
hub / github.com/boostorg/compute / system

Class system

include/boost/compute/system.hpp:55–441  ·  view source on GitHub ↗

\class system \brief Provides access to platforms and devices on the system. The system class contains a set of static functions which provide access to the OpenCL platforms and compute devices on the host system. The default_device() convenience method automatically selects and returns the "best" compute device for the system following a set of heuristics and environment variables. This simplif

Source from the content-addressed store, hash-verified

53///
54/// \see platform, device, context
55class system
56{
57public:
58 /// Returns the default compute device for the system.
59 ///
60 /// The default device is selected based on a set of heuristics and can be
61 /// influenced using one of the following environment variables:
62 ///
63 /// \li \c BOOST_COMPUTE_DEFAULT_DEVICE -
64 /// name of the compute device (e.g. "GTX TITAN")
65 /// \li \c BOOST_COMPUTE_DEFAULT_DEVICE_TYPE
66 /// type of the compute device (e.g. "GPU" or "CPU")
67 /// \li \c BOOST_COMPUTE_DEFAULT_PLATFORM -
68 /// name of the platform (e.g. "NVIDIA CUDA")
69 /// \li \c BOOST_COMPUTE_DEFAULT_VENDOR -
70 /// name of the device vendor (e.g. "NVIDIA")
71 /// \li \c BOOST_COMPUTE_DEFAULT_ENFORCE -
72 /// If this is set to "1", then throw a no_device_found() exception
73 /// if any of the above environment variables is set, but a matching
74 /// device was not found.
75 ///
76 /// The default device is determined once on the first time this function
77 /// is called. Calling this function multiple times will always result in
78 /// the same device being returned.
79 ///
80 /// If no OpenCL device is found on the system, a no_device_found exception
81 /// is thrown.
82 ///
83 /// For example, to print the name of the default compute device on the
84 /// system:
85 /// \code
86 /// // get the default compute device
87 /// boost::compute::device device = boost::compute::system::default_device();
88 ///
89 /// // print the name of the device
90 /// std::cout << "default device: " << device.name() << std::endl;
91 /// \endcode
92 static device default_device()
93 {
94 return init_default_device();
95 }
96
97 /// Returns the device with \p name.
98 ///
99 /// \throws no_device_found if no device with \p name is found.
100 static device find_device(const std::string &name)
101 {
102 const std::vector<device> devices = system::devices();
103 for(size_t i = 0; i < devices.size(); i++){
104 const device& device = devices[i];
105
106 if(device.name() == name){
107 return device;
108 }
109 }
110
111 BOOST_THROW_EXCEPTION(no_device_found());
112 }

Callers

nothing calls this directly

Calls 2

command_queueClass · 0.70
getMethod · 0.45

Tested by

no test coverage detected