Use the CUDA Warp Watch
Use the CUDA Warp Watch
VS2010的局部变量和全局变量工具窗口只支持在一个thread中查看变量一次,Nsight Debuger使用current focus thread and stack frame来计算这些表达式。
Nsight提出cuda Warp Watch的工具窗口,可以展示一个单独的focused Warp中的表达式的值的信息。
To use the CUDA Debugger Warp Watch feature:
- 首先在VS中进入调试状态
- 从Nsight菜单中,选择Windows > CUDA Warp Watch.
- 选择合适的Warp Watch窗口。
- 选择后,你可以在Warp Watch窗口中添加自己的表达式来观察,当Debugger遇到断点或异常而停止时,将会计算表达式的值
- 右击工具窗口,表达式可以从Warp Watch菜单中编辑
The features shown here include the following:- Add Watch - Adds a new expression to the Watch window. (You can use F2 to edit the expression in the current column.)
- Copy column - This will copy elements to the clipboard so they may be pasted into another document (e.g., a spreadsheet).
- Delete Watch / Clear All - Deletes the current expression, or deletes all expressions that have been entered.
- Hexadecimal Display - This menu item controls the Visual Studio global hexadecimal display setting. It is the same setting used in the Visual Studio watch, locals, and autos windows.
- CUDA focus可以通过以下四个工具窗口来改变
- CUDA Focus Picker
- CUDA Info Pages
- The Next / Previous warp commands
- A suspend event
The view updates when the current CUDA focus changes, and always shows the warp that contains the current focus thread.
Example Scenarios
Example: Diverged Warp Watch
In this scenario, the lane is at a different PC than the focus lane. Lanes diverged from focus have a gray background.
Note this is NOT the same as inactive lanes. You can change to an inactive lane, and the other lanes will show diverged. |
Example 1. An example of a successful evaluation, diverged at lane 16. In this figure, the focus is lane 16.
Example 2. Changing to a different focus shows the other lanes as diverged from focus. (This is represented by reversing the white and gray backgrounds.) In this instance, the lane was changed to 0, so lanes 16-31 are now gray; the PC is at
line 54.
Example 3. Here, you can see that it is possible to have a variable that is valid in some lanes, but not in others.
Example: Error Types
Errors can occur for various reasons within the warp watch. For example:
- A lane may be at a different PC; hence the evaluation scope of a given expression could be different.
- A shadow variable could be a different type than the focus lane.
Example 4. This illustrates a shadow variable error. Here, the focus variable's type isfloat
, but it is shadowing anint
.
Another common cause for error is when the lane has diverged from the focus lane and is in a different stack frame. The CUDA Warp Watch feature does not evaluate in other stack frames.
Example 5. This illustrates a stack frame error. Here, the frame "SubFrame" does not exist in the even lanes, hence it cannot evaluate.
Warp Exceptions
The CUDA Memory Checker shows results in the Warps Page of the CUDA Info window. Select theWarp Exceptions bookmark, and it will filter to show any warp that is currently at an exception. These exceptions will match the output in the Output window.
When an exception is detected, the CUDA Debugger will stop in the first CUDA thread that triggered the exception. Use theSet Focus command in the Lanes and Warps pages, to switch to other threads.
Figure 1. A misaligned load in Global memory. The exception is being hit on the first 16 lanes in 5 warps.
Figure 2. The focus lane shows that 16 of the lanes have hit the exception.