VS 11 Developer Preview gotchas with C++ AMP

Now that the VS 11 Developer Preview is available for download, if you want to work with C++ AMP there are some things you should know and to save yourself some pain and frustration trying to figure them out, I have listed them below.

VS 11 Express

If you want to build non-Metro-style apps, i.e. you want to build desktop or server apps that run on Windows 7 and on Windows 8, then the Express edition is NOT the one you want. Please download the Ultimate edition instead (which also allows the building of Metro-style apps, but in addition lets you build desktop and server apps too).

If you do want to build in the Express edition Metro-style apps that use C++ AMP, you can! The one gotcha is that you cannot use our two enum classes (accelerator_restriction and queuing_mode), as you'll get a linker error. This will be fixed for Beta.

The GPU debugger also doesn't work in Express, but there is a workaround: To enable the GPU debugger, please run this script.

VS 11 Ultimate on Windows 8

If you install Ultimate on Windows 8, you have full debugging support without having to run any scripts.

The gotcha for Metro-style apps described above still applies.

However, when you try to run your C++ AMP apps on your DirectX11 hardware, you will require a Windows 8 driver for that hardware (debugging uses an emulator, so it has no such requirements). The availability of a Windows 8 driver for a specific card depends on your hardware vendor, so please check with them about availability. Some cards work fine, and others don't yet.

VS 11 Ultimate on Windows 7

If you install Ultimate on Windows 7, your hardware will no doubt have a driver, so you are good to go for running your C++ AMP apps on your DirectX 11 cards.

However, GPU debugging is not supported on Windows 7 (and there is no workaround, other than installing on Windows 8).

Furthermore, on Windows 7 you should not even build your project in debug mode, if it uses C++ AMP and also you are using const array (or array_view<const T,N>). In that specific scenario, building in debug mode and then running your app will result in a (fairly cryptic) runtime exception.

D3D11: ERROR: ID3D11DeviceContext::Dispatch: The Shader Resource View in slot 0 of the Compute Shader unit is a Structured Buffer while the shader expects a typed Buffer. This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #2097394: DEVICE_SHADERRESOURCEVIEW_BUFFER_TYPE_MISMATCH ]

So always build in release mode on Windows 7 with the Developer Preview (this will be fixed for Beta). If you must build in debug mode, e.g. because you want to debug the CPU portion of your code, you have three options

  • separate the C++ AMP portion into its own project so you can build that in release configuration and the rest in debug.
  • Or, do not use const array or array_view<const… though this will have negative impact on performance
  • Or, the actual fix
    • find the one or two occurrences of D3D11SDKLayers.dll on your installation and rename them to D3D11SDKLayers.dll.bad or some other such name. The dll is under %windir%\System32 and on a 64 bit system also under %windir%\SysWOW64\D3D11SDKLayers.dll.
    • install the DirectX SDK from June 2010 (the only file you need is the version of the D3D11SDKLayers.dll file that it has, which is older than the one VS 11 Developer Preview installs, and does not have the bug that the newer version has). To save you disc space and time, note that you only need the first option checked ("Install DirectX Runtime") so you can ignore the other 6 "DirectX…" options.

 

Feedback and questions

Once you are using C++ AMP, please post your feedback and questions at our MSDN forum: https://social.msdn.microsoft.com/Forums/en/parallelcppnative/threads