Changes

Jump to: navigation, search

GPU621/Debugging OpenMP

2,575 bytes added, 22:21, 29 November 2022
Walkthrough
=== Configuration ===
* Enable OpenMP for the current project file
'''Project''' - '''Property''' - '''C/C++''' - '''Language [Intel C++]''' - '''OpenMP Support''' - '''Generate Parallel Code (/Qiopenmp)'''
* The output of the sample program
 
[[File: walkthrouth_output.png]]
== Case A: Using the Thread Window ==
// TODO: walkthrough on using thread window to debug (medium)
// https=== Serial Region === [[File://learnwalkthrouth_serial.microsoftpng]]  * When one of the breakpoints is reached and the debugger stops at the serial region, only the main thread exists  [[File: walkthrough_serial2.png]]  === Parallel Region === [[File: walkthrough_parallel.com/en-us/visualstudio/png]]  * When one of the breakpoints is reached and the debugger/walkthrough-debugging-stops at a-parallel-application?viewregion, all threads are listed in the Thread window. (including main & worker threads)  [[File: walkthrough_parallel2.png]]  === Freeze Feature === * All threads can be frozen (including the main thread) so that the programmer can check the status of one specific thread* Frozen thread can also be thawed at any time to make it back into service [[File: freeze.png]]  === Flag Feature === * All threads can be flagged in order to filter the list in the Threads window* It is quite useful when there are too many threads* By clicking `Show Flagged Threads Only`, only threads that are marked will be displayed [[File: flag.png]]  ==vs-2022= Search &tabsSort =cpp== *A specific thread can be searched using the Search bar located at the upper left corner  [[File: search.png]]  *By clicking the title of each column, existing threads can be sorted based on the selected column  [[File: sort.png]] 
== Case B: Using the Parallel Stacks Window ==
// TODO: walkthrough on using parallel stacks window to debug (long)
=== Start Execution Until the 1st Breakpoint === When the program stops at the first break point, only the main thread exists in Parallel Stacks Window [[File: 1stExe.png]]  === Resume Execution Until the 2nd Breakpoint === * The Parallel Stacks Window reveals the current status of all threads in the program* There are 2 Threads that come from `ntdll.dll`, which is a runtime library that we don't really care here* There are 2 threads that are ahead of other worker threads** They have reached the barrier (`__kmp_linear_barrier_release_template` & `__kmp_yield`)* There are 8 threads that are ready to move on [[File: 2nd.png]]  === Resume Execution Until the 3rd Breakpoint === * When reaches the 3rd break point, Thanks to `#pragma omp critical`, all threads are waiting, trying to pass their result to main* As shown in the picture, there are 11 threads are ready to pass their values** They are either in the current thread or in the waiting list (`__kmp_wait_4` // https`__kmp_yield`)* According to the code, we know that there will be 11 threads passing their calculated results to the main thread* At this point, the value of `total_Sum` is 0 [[File://learn3rd.microsoftpng]]  === Resume Execution Until the 4th Breakpoint === * When the program reaches this step, all calculations have been completed* As can be seen in the figure, all worker threads have reached `__kmp_linear_barrier_release_template`* This means that their work is done* And we can see that the result of the program is correct [[File: 4th.com/en-us/visualstudio/debugger/using-png]]  === Resume Execution Until the-parallel-stacks-window?viewLast Breakpoint ===vs-2022 When the program ends, all threads are terminated and the program returns to only one main thread
https[[File://en5th.wikipedia.org/wiki/Help:Cheatsheetpng]]
24
edits

Navigation menu