mirror of
https://github.com/boostorg/compute.git
synced 2026-01-27 06:42:19 +00:00
boost::compute::system::default_device() supports the following environment variables: BOOST_COMPUTE_DEFAULT_DEVICE for device name BOOST_COMPUTE_DEFAULT_PLATFORM for OpenCL platform name BOOST_COMPUTE_DEFAULT_VENDOR for device vendor name If one or more of these variables is set, then device that satisfies all conditions gets selected. If such a device is unavailable, then the first available GPU is selected. If there are no GPUs in the system, then the first available CPU is selected. Otherwise, default_device() returns null device. The hello_world example is modified to use default_device() instead of default_gpu_device().
28 lines
758 B
C++
28 lines
758 B
C++
//---------------------------------------------------------------------------//
|
|
// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0
|
|
// See accompanying file LICENSE_1_0.txt or copy at
|
|
// http://www.boost.org/LICENSE_1_0.txt
|
|
//
|
|
// See http://kylelutz.github.com/compute for more information.
|
|
//---------------------------------------------------------------------------//
|
|
|
|
//[hello_world_example
|
|
|
|
#include <iostream>
|
|
#include <boost/compute.hpp>
|
|
|
|
int main()
|
|
{
|
|
// get the default device
|
|
boost::compute::device device =
|
|
boost::compute::system::default_device();
|
|
|
|
// print the device's name
|
|
std::cout << "hello from " << device.name() << std::endl;
|
|
|
|
return 0;
|
|
}
|
|
//]
|