This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
You can debug C++ code that is running on the graphics processing unit (GPU). GPU debugging support in Visual Studio includes race detection, launching processes and attaching to them, and integration into the debugging windows.
Debugging is supported on Windows 7, Windows 8, Windows 10, Windows 11, Windows Server 2008 R2, Windows Server 2012 and Windows Server 2016. For debugging on the software emulator, Windows 8, Windows 10, Windows 11, or Windows Server 2012, Windows Server 2016 is required. For debugging on the hardware, you must install the drivers for your graphics card. Not all hardware vendors implement all debugger features. See the vendor documentation for limitations.
Note
Independent hardware vendors who want to support GPU debugging in Visual Studio must create a DLL that implements the VSD3DDebug interface and targets their own drivers.
The debugger can't break on both CPU code and GPU code in the same app execution. By default, the debugger breaks on CPU code. To debug GPU code, use one of these two steps:
In theDebug Type list on theStandard toolbar, chooseGPU Only.
InSolution Explorer, on the shortcut menu for the project, chooseProperties. In theProperty Pages dialog box, selectDebugging, and then selectGPU Only in theDebugger Type list.
You can use the Visual Studio debugging commands to start and stop GPU debugging. For more information, seeNavigating through Code with the Debugger. You can also attach the GPU debugger to a running process, but only if that process executes GPU code. For more information, seeAttach to Running Processes.
When you're debugging on the GPU, you have two options for running to the cursor location. The commands for both options are available on the shortcut menu of the code editor.
TheRun to Cursor command runs your app until it reaches the cursor location and then breaks. This doesn't imply that the current thread runs to the cursor; rather, it means that the first thread that reaches the cursor point triggers the break. SeeNavigating through Code with the Debugger
TheRun Current Tile to Cursor command runs your app until all of the threads in the current tile reach the cursor and then breaks.
By using certain debugging windows, you can examine, flag, and freeze GPU threads. For more information, see:
The debugger can identify several data synchronization conditions during execution. When a condition is detected, the debugger enters the break state. You have two options—Break orContinue. By using theExceptions dialog box, you can configure whether the debugger detects these conditions and also which conditions it will break for. For more information, seeManaging Exceptions with the Debugger. You can also use theOptions dialog box to specify that the debugger should ignore exceptions if the data that's written doesn't change the value of the data. For more information, seeGeneral, Debugging, Options Dialog Box.
Breakpoints in GPU code are only hit if the code is running on theaccelerator::direct3d_ref (REF) accelerator. If you don't specify an accelerator in your code, the REF accelerator is automatically selected as theDebugging Accelerator Type in the project properties. If your code explicitly selects an accelerator, then the REF accelerator won't be used during debugging and the breakpoints won't be hit unless your GPU hardware has debugging support. You can remedy this by writing your code so that it uses the REF accelerator during debugging. For more information, see project properties andUsing accelerator and accelerator_view Objects andProject Settings for a C++ Debug Configuration.
Conditional breakpoints in GPU code are supported, but not every expression can be evaluated on the device. When an expression can't be evaluated on the device, it's evaluated on the debugger. The debugger is likely to run more slowly than the device.
This error happens when there's an inconsistency between the project settings and the configuration of the PC that you're debugging on. For more information, seeProject Settings for a C++ Debug Configuration.
This error happens if you're debugging on a remote PC. The debugger can't determine until run time whether the drivers are installed on the remote PC. The drivers are available from the manufacturer of the graphics card.
It's possible for C++ AMP computations to exceed the default time interval that's set by the Windows timeout detection and recovery process (TDR). When that happens, the computation is canceled and the data is lost. For more information, seeHandling TDRs in C++ AMP.
Was this page helpful?
Was this page helpful?