我正在尝试使用 C++ AMP 在 GPU 上执行长时间运行的内核。这需要使用 DirectX 创建一个不会超时的设备。我正在设置标志,但它仍在触发超时检测恢复。我的盒子里有一个专用的 Radeon HD 7970,没有插入显示器。我还需要做些什么来防止 Windows 8 在内核完成之前取消它吗?
#include <amp.h>
#include <amp_math.h>
#include <amp_graphics.h>
#include <d3d11.h>
#include <dxgi.h>
#include <vector>
#include <iostream>
#include <iomanip>
#include "amp_tinymt_rng.h"
#include "timer.h"
#include <assert.h>
#pragma comment(lib, "d3d11")
#pragma comment(lib, "dxgi")
//Inside Main()
unsigned int createDeviceFlags = D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT;
ID3D11Device * pDevice = nullptr;
ID3D11DeviceContext * pContext = nullptr;
D3D_FEATURE_LEVEL targetFeatureLevels = D3D_FEATURE_LEVEL_11_1;
D3D_FEATURE_LEVEL featureLevel;
auto hr = D3D11CreateDevice(pAdapter,
D3D_DRIVER_TYPE_UNKNOWN,
nullptr,
createDeviceFlags,
&targetFeatureLevels,
1,
D3D11_SDK_VERSION,
&pDevice,
&featureLevel,
&pContext);
if (FAILED( hr) ||
( featureLevel != D3D_FEATURE_LEVEL_11_1))
{
std:: wcerr << "Failed to create Direct3D 11 device" << std:: endl;
return 10;
}
accelerator_view noTimeoutAcclView = concurrency::direct3d::create_accelerator_view(pDevice);
wcout << noTimeoutAcclView.accelerator.description;
//Setup kernal here
concurrency::parallel_for_each(noTimeoutAcclView, e_size, [=] (index<1> idx) restrict(amp) {
//Execute kernel here
});