You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4a45a11
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/parallel/amp/walkthrough-debugging-a-cpp-amp-application.md
+38-39Lines changed: 38 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,12 @@
1
1
---
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
5
5
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
7
6
---
8
-
# Walkthrough: Debugging a C++ AMP Application
7
+
# Walkthrough: Debugging a C++ AMP application
9
8
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:
11
10
12
11
- Launching the GPU debugger.
13
12
@@ -27,15 +26,15 @@ Before you start this walkthrough:
- 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).
31
30
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.
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.
39
38
40
39
::: moniker range="msvc-160"
41
40
@@ -45,7 +44,7 @@ The instructions for creating a project vary depending on which version of Visua
45
44
46
45
1. At the top of the dialog, set **Language** to **C++**, set **Platform** to **Windows**, and set **Project type** to **Console**.
47
46
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.
49
48
50
49

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.
210
209
211
210
### To debug the CPU code
212
211
@@ -218,7 +217,7 @@ In this procedure, you will use the Local Windows Debugger to make sure that the
218
217
219
218
4. Set breakpoints on the lines of code shown in the following illustration (approximately lines 67 line 70).
 <br/>
251
250
GPU breakpoint
252
251
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.
254
253
255
254
### To use the GPU Threads window
256
255
@@ -260,14 +259,14 @@ This section shows how to debug the GPU code, which is the code contained in the
260
259
261
260
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.
262
261
263
-
 <br/>
262
+
 <br/>
264
263
GPU Threads window
265
264
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.
267
266
268
267
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:
269
268
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.
271
270
272
271
- Enter the tile and thread values of the thread in the corresponding text boxes and then choose the **Switch Thread** button.
273
272
@@ -283,14 +282,14 @@ This section shows how to debug the GPU code, which is the code contained in the
283
282
284
283
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.
285
284
286
-
 <br/>
285
+
 <br/>
287
286
Parallel Stacks window
288
287
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.
290
289
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.
292
291
293
-
 <br/>
292
+
 <br/>
294
293
GPU thread DataTip
295
294
296
295
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
313
312
314
313
Select the **localA[localIdx[0]]** column header to sort the column. The following illustration shows the results of sorting by **localA[localIdx[0]]**.
315
314
316
-
 <br/>
315
+
 <br/>
317
316
Results of sort
318
317
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.
320
319
321
320
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.
322
321
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.
324
323
325
324
## Flagging GPU Threads
326
325
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.
328
327
329
328
### To flag GPU threads
330
329
@@ -336,16 +335,16 @@ You can mark specific GPU threads by flagging them in the **GPU Threads** window
336
335
337
336
The following illustration shows the four active flagged threads in the **GPU Threads** window.
338
337
339
-
 <br/>
338
+
 <br/>
340
339
Active threads in the GPU Threads window
341
340
342
341
The **Parallel Watch** window and the DataTip of the **Parallel Stacks** window both indicate the flagged threads.
343
342
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.
345
344
346
345
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.
347
346
348
-
 <br/>
347
+
 <br/>
349
348
**Show Flagged Only** button
350
349
351
350
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
364
363
365
364
The following illustration of the **GPU Threads** window shows that all four threads are frozen.
366
365
367
-
 <br/>
366
+
 <br/>
368
367
Frozen threads in the **GPU Threads** window
369
368
370
369
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
381
380
382
381
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.
383
382
384
-
 <br/>
383
+
 <br/>
385
384
Grouped threads in the **GPU Threads** window
386
385
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.
388
387
389
388
## Running All Threads to a Specific Location in Code
390
389
@@ -398,12 +397,12 @@ You run all the threads in a given tile to the line that contains the cursor by
398
397
399
398
3. On the shortcut menu for the **Code Editor**, choose **Run Current Tile To Cursor**.
400
399
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.
0 commit comments