在 C++ AMP 中,如何检测和枚举所有 C++ AMP 加速器?
Don McCrady 分发了一个应用程序 here枚举非模拟加速器。虽然我有一张 DX11 卡 (GTX 260),但我没有看到任何可用的加速器。丹尼尔·莫斯 (Daniel Moth) 展示 here如何查询单个加速器,但我找不到如何使用 C++ AMP 调用枚举所有(模拟和非)加速器。
最佳答案
看起来很简单:concurrency::get_accelerators();
Daniel Moth comments :
in the VS 11 Developer Preview bits, you simply call concurrency::get_accelerators();. We are working to make that more discoverable for the Beta, whenever that is.
这是我的代码:
#include <iostream>
#include "stdafx.h"
#include "amp.h"
using namespace std;
using namespace concurrency;
void inspect_accelerators()
{
auto accelerators = accelerator::get_all();
for_each(begin(accelerators), end(accelerators),[=](accelerator acc){
wcout << "New accelerator: " << acc.description << endl;
wcout << "is_debug = " << acc.is_debug << endl;
wcout << "is_emulated = " << acc.is_emulated <<endl;
wcout << "dedicated_memory = " << acc.dedicated_memory << endl;
wcout << "device_path = " << acc.device_path << endl;
wcout << "has_display = " << acc.has_display << endl;
wcout << "version = " << (acc.version >> 16) << '.' << (acc.version & 0xFFFF) << endl;
});
}
更新 1:
从 VS 11 Beta 开始,这现在是 accelerator::get_all();
关于c++ - 你如何枚举 C++ AMP 中的所有加速器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7533792/