2
0
mirror of https://github.com/boostorg/compute.git synced 2026-02-01 20:32:19 +00:00

update amd_kernel test program to use platform info structure instead of using device info structure

This commit is contained in:
Chester Kuo
2014-10-08 15:55:26 +08:00
parent 86fb40da9f
commit 7d772f35d7

View File

@@ -23,20 +23,31 @@ namespace compute = boost::compute;
// this example shows how to use the static c++ kernel language
// extension (currently only supported by AMD) to compile and
// execute a templated c++ kernel.
// Using platform vendor info to decide if this is AMD platform
int main()
{
// get default device and setup context
bool amd_device = false;
compute::device device = compute::system::default_device();
compute::context context(device);
compute::command_queue queue(context, device);
std::cout << "device: " << device.name() << std::endl;
std::vector<compute::platform> platforms = compute::system::platforms();
// ensure we have an amd device
if(device.vendor() != "Advanced Micro Devices, Inc."){
for(size_t i = 0; i < platforms.size(); i++){
const compute::platform &platform = platforms[i];
std::cout << "Platform Name '" << platform.name() << "'" << std::endl;
std::cout << "Platform vendor '" << platform.vendor() << "'" << std::endl;
if ( platform.vendor() == "Advanced Micro Devices, Inc.") {
amd_device = true;
break;
}
}
if ( !amd_device ) {
std::cerr << "error: static C++ kernel language is only "
<< "supported on AMD devices."
<< std::endl;
return 0;
<< "supported on AMD devices."
<< std::endl;
return 0;
}
// create input int values and copy them to the device