How do you enumerate all accelerators in C++ AMP?
In C++ AMP, how does one detect and enumerate all C++ AMP accelerators?
Don McCrady distributed an app here that enumerates non-emulated accelerators. Though I had a DX11 card (GTX 260), I didn't see any available accelerat开发者_Go百科ors. Daniel Moth shows here how to query an individual accelerator, but I couldn't find how do enumerate all (emulated and non) accelerators using a C++ AMP call.
Looks like it's pretty simple: 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.
Here's my code:
#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;
});
}
Update 1:
As of VS 11 Beta, this is now accelerator::get_all();
Thanks for reposting the answer from my blog here :-)
You made a side comment in your question:
"Though I had a DX11 card (GTX 260), I didn't see any available accelerators"
If Don's utility didn't find your card, then it is not a DX11 card, or there is a bug in his utility and we'd appreciate you reporting the repro to him. However, I verified on the vendor's site that GTX 260 is a DX10 card. So that would not be a good target for C++ AMP code, unfortunately...
Cheers
Daniel
精彩评论