Skip to content

Commit 4a45a11

Browse files
authored
Merge pull request MicrosoftDocs#3432 from corob-msft/docs/corob/cpp-docs-3018
Update for cpp-docs 3018
2 parents c5e1faa + 861292a commit 4a45a11

1 file changed

Lines changed: 38 additions & 39 deletions

File tree

‎docs/parallel/amp/walkthrough-debugging-a-cpp-amp-application.md‎

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
2-
description: "Learn more about: Walkthrough: Debugging a C++ AMP Application"
3-
title: "Walkthrough: Debugging a C++ AMP Application"
4-
ms.date: "04/23/2019"
2+
description: "Learn more about: Walkthrough: Debugging a C++ AMP application"
3+
title: "Walkthrough: Debugging a C++ AMP application"
4+
ms.date: 03/07/2021
55
helpviewer_keywords: ["debugging, C++ Accelerated Massive Parallelism", "C++ AMP, debugging", "C++ Accelerated Massive Parallelism, debugging", "debugging, C++ AMP"]
6-
ms.assetid: 40e92ecc-f6ba-411c-960c-b3047b854fb5
76
---
8-
# Walkthrough: Debugging a C++ AMP Application
7+
# Walkthrough: Debugging a C++ AMP application
98

10-
This topic demonstrates how to debug an application that uses C++ Accelerated Massive Parallelism (C++ AMP) to take advantage of the graphics processing unit (GPU). It uses a parallel-reduction program that sums up a large array of integers. This walkthrough illustrates the following tasks:
9+
This article demonstrates how to debug an application that uses C++ Accelerated Massive Parallelism (C++ AMP) to take advantage of the graphics processing unit (GPU). It uses a parallel-reduction program that sums up a large array of integers. This walkthrough illustrates the following tasks:
1110

1211
- Launching the GPU debugger.
1312

@@ -27,15 +26,15 @@ Before you start this walkthrough:
2726

2827
- Read [C++ AMP Overview](../../parallel/amp/cpp-amp-overview.md).
2928

30-
- Make sure that line numbers are displayed in the text editor. For more information, see [How to: Display Line Numbers in the Editor](/visualstudio/ide/reference/how-to-display-line-numbers-in-the-editor).
29+
- Make sure that line numbers are displayed in the text editor. For more information, see [How to: Display line numbers in the editor](/visualstudio/ide/reference/how-to-display-line-numbers-in-the-editor).
3130

32-
- Make sure you are running at least Windows 8 or Windows Server 2012 to support debugging on the software emulator.
31+
- Make sure you're running at least Windows 8 or Windows Server 2012 to support debugging on the software emulator.
3332

3433
[!INCLUDE[note_settings_general](../../mfc/includes/note_settings_general_md.md)]
3534

3635
### To create the sample project
3736

38-
The instructions for creating a project vary depending on which version of Visual Studio you are using. Make sure you have the correct version selected in the upper left of this page.
37+
The instructions for creating a project vary depending on which version of Visual Studio you're using. Make sure you have the correct documentation version selected above the table of contents on this page.
3938

4039
::: moniker range="msvc-160"
4140

@@ -45,7 +44,7 @@ The instructions for creating a project vary depending on which version of Visua
4544

4645
1. At the top of the dialog, set **Language** to **C++**, set **Platform** to **Windows**, and set **Project type** to **Console**.
4746

48-
1. From the filtered list of project types, choose **Console App** then choose **Next**. In the next page, enter `AMPMapReduce` in the **Name** box to specify a name for the project, and specify the project location if desired.
47+
1. From the filtered list of project types, choose **Console App** then choose **Next**. In the next page, enter `AMPMapReduce` in the **Name** box to specify a name for the project, and specify the project location if you want a different one.
4948

5049
![Name the project](../../build/media/mathclient-project-name-2019.png "Name the project")
5150

@@ -186,7 +185,7 @@ Next:
186185
if (!passed) {
187186
printf("Actual (GPU): %d, Expected (CPU): %d", actual, expected);
188187
}
189-
printf("sum: %s\n", passed "Passed!" : "Failed!");
188+
printf("sum: %s\n", passed ? "Passed!" : "Failed!");
190189

191190
getchar();
192191

@@ -206,7 +205,7 @@ Next:
206205
207206
## Debugging the CPU Code
208207
209-
In this procedure, you will use the Local Windows Debugger to make sure that the CPU code in this application is correct. The segment of the CPU code in this application that is especially interesting is the **`for`** loop in the `reduction_sum_gpu_kernel` function. It controls the tree-based parallel reduction that is run on the GPU.
208+
In this procedure, you'll use the Local Windows Debugger to make sure that the CPU code in this application is correct. The segment of the CPU code in this application that is especially interesting is the **`for`** loop in the `reduction_sum_gpu_kernel` function. It controls the tree-based parallel reduction that is run on the GPU.
210209
211210
### To debug the CPU code
212211
@@ -218,7 +217,7 @@ In this procedure, you will use the Local Windows Debugger to make sure that the
218217
219218
4. Set breakpoints on the lines of code shown in the following illustration (approximately lines 67 line 70).
220219
221-
![CPU breakpoints](../../parallel/amp/media/campcpubreakpoints.png "CPU breakpoints") <br/>
220+
![CPU breakpoints marked next to lines of code in the editor.](../../parallel/amp/media/campcpubreakpoints.png "CPU breakpoints") <br/>
222221
CPU breakpoints
223222
224223
5. On the menu bar, choose **Debug** > **Start Debugging**.
@@ -241,16 +240,16 @@ This section shows how to debug the GPU code, which is the code contained in the
241240
242241
4. In the **Debugger Type** list, verify that **Auto** is selected.
243242
244-
**Auto** is the default value. Prior to Windows 10, **GPU Only** is the required value instead of **Auto**.
243+
**Auto** is the default value. In versions before Windows 10, **GPU Only** is the required value instead of **Auto**.
245244
246245
5. Choose the **OK** button.
247246
248247
6. Set a breakpoint at line 30, as shown in the following illustration.
249248
250-
![GPU breakpoints](../../parallel/amp/media/campgpubreakpoints.png "GPU breakpoints") <br/>
249+
![GPU breakpoints marked next to a line of code in the editor.](../../parallel/amp/media/campgpubreakpoints.png "GPU breakpoints") <br/>
251250
GPU breakpoint
252251
253-
7. On the menu bar, choose **Debug** > **Start Debugging**. The breakpoints in the CPU code at lines 67 and 70 are not executed during GPU debugging because those lines of code are executed on the CPU.
252+
7. On the menu bar, choose **Debug** > **Start Debugging**. The breakpoints in the CPU code at lines 67 and 70 don't get executed during GPU debugging because those lines of code run on the CPU.
254253
255254
### To use the GPU Threads window
256255
@@ -260,14 +259,14 @@ This section shows how to debug the GPU code, which is the code contained in the
260259
261260
2. Dock the **GPU Threads** window at the bottom of Visual Studio. Choose the **Expand Thread Switch** button to display the tile and thread text boxes. The **GPU Threads** window shows the total number of active and blocked GPU threads, as shown in the following illustration.
262261
263-
![GPU Threads window with 4 active threads](../../parallel/amp/media/campc.png "GPU Threads window with 4 active threads") <br/>
262+
![GPU Threads window with 4 active threads.](../../parallel/amp/media/campc.png "GPU Threads window with 4 active threads") <br/>
264263
GPU Threads window
265264
266-
There are 313 tiles allocated for this computation. Each tile contains 32 threads. Because local GPU debugging occurs on a software emulator, there are four active GPU threads. The four threads execute the instructions simultaneously and then move on together to the next instruction.
265+
313 tiles get allocated for this computation. Each tile contains 32 threads. Because local GPU debugging occurs on a software emulator, there are four active GPU threads. The four threads execute the instructions simultaneously and then move on together to the next instruction.
267266
268267
In the **GPU Threads** window, there are four GPU threads active and 28 GPU threads blocked at the [tile_barrier::wait](reference/tile-barrier-class.md#wait) statement defined at about line 21 (`t_idx.barrier.wait();`). All 32 GPU threads belong to the first tile, `tile[0]`. An arrow points to the row that includes the current thread. To switch to a different thread, use one of the following methods:
269268
270-
- In the row for the thread to switch to in the **GPU Threads** window, open the shortcut menu and choose **Switch To Thread**. If the row represents more than one thread, you will switch to the first thread according to the thread coordinates.
269+
- In the row for the thread to switch to in the **GPU Threads** window, open the shortcut menu and choose **Switch To Thread**. If the row represents more than one thread, you'll switch to the first thread according to the thread coordinates.
271270
272271
- Enter the tile and thread values of the thread in the corresponding text boxes and then choose the **Switch Thread** button.
273272
@@ -283,14 +282,14 @@ This section shows how to debug the GPU code, which is the code contained in the
283282
284283
3. Make sure that **Threads** is selected in the list in the upper-left corner. In the following illustration, the **Parallel Stacks** window shows a call-stack focused view of the GPU threads that you saw in the **GPU Threads** window.
285284
286-
![Parallel Stacks window with 4 active threads](../../parallel/amp/media/campd.png "Parallel Stacks window with 4 active threads") <br/>
285+
![Parallel Stacks window with 4 active threads.](../../parallel/amp/media/campd.png "Parallel Stacks window with 4 active threads") <br/>
287286
Parallel Stacks window
288287
289-
32 threads went from `_kernel_stub` to the lambda statement in the `parallel_for_each` function call and then to the `sum_kernel_tiled` function, where the parallel reduction occurs. 28 out of the 32 threads have progressed to the [tile_barrier::wait](reference/tile-barrier-class.md#wait) statement and remain blocked at line 22, whereas the other 4 threads remain active in the `sum_kernel_tiled` function at line 30.
288+
32 threads went from `_kernel_stub` to the lambda statement in the `parallel_for_each` function call and then to the `sum_kernel_tiled` function, where the parallel reduction occurs. 28 out of the 32 threads have progressed to the [`tile_barrier::wait`](reference/tile-barrier-class.md#wait) statement and remain blocked at line 22, while the other four threads remain active in the `sum_kernel_tiled` function at line 30.
290289
291-
You can inspect the properties of a GPU thread that are available in the **GPU Threads** window in the rich DataTip of the **Parallel Stacks** window. To do this, rest the mouse pointer on the stack frame of **sum_kernel_tiled**. The following illustration shows the DataTip.
290+
You can inspect the properties of a GPU thread. They're available in the **GPU Threads** window in the rich DataTip of the **Parallel Stacks** window. To see them, hover the pointer on the stack frame of `sum_kernel_tiled`. The following illustration shows the DataTip.
292291
293-
![DataTip for Parallel Stacks window](../../parallel/amp/media/campe.png "DataTip for Parallel Stacks window") <br/>
292+
![DataTip for Parallel Stacks window.](../../parallel/amp/media/campe.png "DataTip for Parallel Stacks window") <br/>
294293
GPU thread DataTip
295294
296295
For more information about the **Parallel Stacks** window, see [Using the Parallel Stacks Window](/visualstudio/debugger/using-the-parallel-stacks-window).
@@ -313,18 +312,18 @@ This section shows how to debug the GPU code, which is the code contained in the
313312
314313
Select the **localA[localIdx[0]]** column header to sort the column. The following illustration shows the results of sorting by **localA[localIdx[0]]**.
315314
316-
![Parallel Watch window with sorted results](../../parallel/amp/media/campf.png "Parallel Watch window with sorted results") <br/>
315+
![Parallel Watch window with sorted results.](../../parallel/amp/media/campf.png "Parallel Watch window with sorted results") <br/>
317316
Results of sort
318317
319-
You can export the content in the **Parallel Watch** window to Excel by choosing the **Excel** button and then choosing **Open in Excel**. If you have Excel installed on your development computer, this opens an Excel worksheet that contains the content.
318+
You can export the content in the **Parallel Watch** window to Excel by choosing the **Excel** button and then choosing **Open in Excel**. If you have Excel installed on your development computer, the button opens an Excel worksheet that contains the content.
320319
321320
6. In the upper-right corner of the **Parallel Watch** window, there's a filter control that you can use to filter the content by using Boolean expressions. Enter `localA[localIdx[0]] > 20000` in the filter control text box and then choose the **Enter** key.
322321
323-
The window now contains only threads on which the `localA[localIdx[0]]` value is greater than 20000. The content is still sorted by the `localA[localIdx[0]]` column, which is the sorting action you performed earlier.
322+
The window now contains only threads on which the `localA[localIdx[0]]` value is greater than 20000. The content is still sorted by the `localA[localIdx[0]]` column, which is the sorting action you chose earlier.
324323
325324
## Flagging GPU Threads
326325
327-
You can mark specific GPU threads by flagging them in the **GPU Threads** window, the **Parallel Watch** window, or the DataTip in the **Parallel Stacks** window. If a row in the GPU Threads window contains more than one thread, flagging that row flags all threads that are contained in the row.
326+
You can mark specific GPU threads by flagging them in the **GPU Threads** window, the **Parallel Watch** window, or the DataTip in the **Parallel Stacks** window. If a row in the GPU Threads window contains more than one thread, flagging that row flags all threads contained in the row.
328327
329328
### To flag GPU threads
330329
@@ -336,16 +335,16 @@ You can mark specific GPU threads by flagging them in the **GPU Threads** window
336335
337336
The following illustration shows the four active flagged threads in the **GPU Threads** window.
338337
339-
![GPU Threads window with flagged threads](../../parallel/amp/media/campg.png "GPU Threads window with flagged threads") <br/>
338+
![GPU Threads window with flagged threads.](../../parallel/amp/media/campg.png "GPU Threads window with flagged threads") <br/>
340339
Active threads in the GPU Threads window
341340
342341
The **Parallel Watch** window and the DataTip of the **Parallel Stacks** window both indicate the flagged threads.
343342
344-
4. If you want to focus on the four threads that you flagged, you can choose to show, in the **GPU Threads**, **Parallel Watch**, and **Parallel Stacks** windows, only the flagged threads.
343+
4. If you want to focus on the four threads that you flagged, you can choose to show only the flagged threads. It limits what you see in the **GPU Threads**, **Parallel Watch**, and **Parallel Stacks** windows.
345344
346345
Choose the **Show Flagged Only** button on any of the windows or on the **Debug Location** toolbar. The following illustration shows the **Show Flagged Only** button on the **Debug Location** toolbar.
347346
348-
![Debug Location toolbar with Show Only Flagged icon](../../parallel/amp/media/camph.png "Debug Location toolbar with Show Only Flagged icon") <br/>
347+
![Debug Location toolbar with Show Only Flagged icon.](../../parallel/amp/media/camph.png "Debug Location toolbar with Show Only Flagged icon") <br/>
349348
**Show Flagged Only** button
350349
351350
Now the **GPU Threads**, **Parallel Watch**, and **Parallel Stacks** windows display only the flagged threads.
@@ -364,7 +363,7 @@ You can freeze (suspend) and thaw (resume) GPU threads from either the **GPU Thr
364363
365364
The following illustration of the **GPU Threads** window shows that all four threads are frozen.
366365
367-
![GPU Threads windows showing frozen threads](../../parallel/amp/media/campk.png "GPU Threads windows showing frozen threads") <br/>
366+
![GPU Threads windows showing frozen threads.](../../parallel/amp/media/campk.png "GPU Threads windows showing frozen threads") <br/>
368367
Frozen threads in the **GPU Threads** window
369368
370369
Similarly, the **Parallel Watch** window shows that all four threads are frozen.
@@ -381,10 +380,10 @@ You can freeze (suspend) and thaw (resume) GPU threads from either the **GPU Thr
381380
382381
The threads in the **GPU Threads** window are grouped by address. The address corresponds to the instruction in disassembly where each group of threads is located. 24 threads are at line 22 where the [tile_barrier::wait Method](reference/tile-barrier-class.md#wait) is executed. 12 threads are at the instruction for the barrier at line 32. Four of these threads are flagged. Eight threads are at the breakpoint at line 30. Four of these threads are frozen. The following illustration shows the grouped threads in the **GPU Threads** window.
383382
384-
![GPU Threads window with threads grouped by Address](../../parallel/amp/media/campl.png "GPU Threads window with threads grouped by Address") <br/>
383+
![GPU Threads window with threads grouped by Address.](../../parallel/amp/media/campl.png "GPU Threads window with threads grouped by Address") <br/>
385384
Grouped threads in the **GPU Threads** window
386385
387-
2. You can also perform the **Group By** operation by opening the shortcut menu for the data grid of the **Parallel Watch** window, choosing **Group By**, and then choosing the menu item that corresponds to how you want to group the threads.
386+
2. You can also do the **Group By** operation by opening the shortcut menu for the **Parallel Watch** window's data grid. Select **Group By**, and then choose the menu item that corresponds to how you want to group the threads.
388387
389388
## Running All Threads to a Specific Location in Code
390389
@@ -398,12 +397,12 @@ You run all the threads in a given tile to the line that contains the cursor by
398397
399398
3. On the shortcut menu for the **Code Editor**, choose **Run Current Tile To Cursor**.
400399
401-
The 24 threads that were previously blocked at the barrier at line 21 have progressed to line 32. This is shown in the **GPU Threads** window.
400+
The 24 threads that were previously blocked at the barrier at line 21 have progressed to line 32. It's shown in the **GPU Threads** window.
402401
403402
## See also
404403
405-
[C++ AMP Overview](../../parallel/amp/cpp-amp-overview.md)<br/>
406-
[Debugging GPU Code](/visualstudio/debugger/debugging-gpu-code)<br/>
407-
[How to: Use the GPU Threads Window](/visualstudio/debugger/how-to-use-the-gpu-threads-window)<br/>
408-
[How to: Use the Parallel Watch Window](/visualstudio/debugger/how-to-use-the-parallel-watch-window)<br/>
409-
[Analyzing C++ AMP Code with the Concurrency Visualizer](/archive/blogs/nativeconcurrency/analyzing-c-amp-code-with-the-concurrency-visualizer)
404+
[C++ AMP overview](../../parallel/amp/cpp-amp-overview.md)\
405+
[Debugging GPU code](/visualstudio/debugger/debugging-gpu-code)\
406+
[How to: Use the GPU Threads window](/visualstudio/debugger/how-to-use-the-gpu-threads-window)\
407+
[How to: Use the Parallel Watch window](/visualstudio/debugger/how-to-use-the-parallel-watch-window)\
408+
[Analyzing C++ AMP code with the Concurrency Visualizer](/archive/blogs/nativeconcurrency/analyzing-c-amp-code-with-the-concurrency-visualizer)

0 commit comments

Comments
 (0)