2
我想用C++ AMP在GPU上执行长时间运行的内核。这需要使用DirectX创建一个不会超时的设备。我正在设置标志,但它仍然触发超时检测恢复。我的盒子里没有插入显示器,我有一个专用的Radeon HD 7970。还有什么我需要做的,以防止Windows 8在完成之前取消我的内核?DirectX 11.1试图创建设备不触发超时检测恢复
#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
});
Simon,作为对第2点的回应,如果我使用较小的实例大小,它不会导致TDR。只有当我扩展它并增加导致TDR的运行长度时。感谢您的帮助。 –
当我回来的时候,我会提供更多的代码来显示Accelerator_View的创建以及parallel_for_each的调用,以确保我正确地做到了这一点。 –
好的,我很期待。 @MatthewCrews –