2
0
mirror of https://github.com/boostorg/compute.git synced 2026-01-26 18:32:48 +00:00
Files
compute/example/list_devices.cpp
Kyle Lutz 518d39fc2b Use bitwise-and to check device::type()
This changes the checks for the device type to use the bitwise-and
operator instead of the equaility operator. The returned type is a
bitset and this would cause errors when multiple bits were set.

This fixes a bug on POCL which returns the device type as a
combination of CL_DEVICE_TYPE_DEFAULT and CL_DEVICE_TYPE_CPU. Now
the correct device type (device::cpu) is detected for POCL.
2013-09-07 14:16:20 -04:00

45 lines
1.4 KiB
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.
//---------------------------------------------------------------------------//
#include <iostream>
#include <boost/compute.hpp>
namespace compute = boost::compute;
int main()
{
std::vector<compute::platform> platforms = compute::system::platforms();
for(size_t i = 0; i < platforms.size(); i++){
const compute::platform &platform = platforms[i];
std::cout << "Platform '" << platform.name() << "'" << std::endl;
std::vector<compute::device> devices = platform.devices();
for(size_t j = 0; j < devices.size(); j++){
const compute::device &device = devices[j];
std::string type;
if(device.type() & compute::device::gpu)
type = "GPU Device";
else if(device.type() & compute::device::cpu)
type = "CPU Device";
else if(device.type() & compute::device::accelerator)
type = "Accelerator Device";
else
type = "Unknown Device";
std::cout << " " << type << ": " << device.name() << std::endl;
}
}
return 0;
}