Open main menu

CDOT Wiki β

Changes

OpenMP Debugging in Visual Studio / Team Debug

929 bytes added, 18:48, 5 December 2017
Case B - Using the Parallel Stacks Window
==Case B - Using the Parallel Stacks Window==
We will use the following program , which uses cilk API for parallelization, to experiment with the Parallel Stacks Window:
In the above code, the main program calls functions that may themselves call other functions. At each cilk_spawn keyword, we can expect a new child thread to call the function. However, if the function have very short operations each, then the different spawns may not even be distributed to different child threads, since each function call may take very fast. That was originally the case, where all of the function calls were done by one thread. Therefore, the functions were adjusted to sleep for 1 second within the function itself. This way, the functions took long enough so that the program did spawn into multiple child threads.  Here is the output of the program, with the cilk_for loop commented out:[[File:CilkOutput.PNG|500px|center|Step 1 - threads]] From the output we can see that 4 different workers (child threads) occupied the 6 function calls. In order of the function calls in the code, Worker 0 took foo(), worker 3 took coo(), worker 2 took boo(), worker 1 took doo(), worker 0 took zoo(), and finally worker 3 took the remaining foo() function. The Parallel Stacks window allows us to see the call stack information for all active threads at any point in our program.
Setup:
And if we double click on it, the focus will shift to its call stack in the Parallel Stacks window:
[[File:Stacks-step1b-worker3.PNG|500px|center|Step 1b - Worker 3]]
 
To clear out the other threads from the program which have nothing to do with our cilk spawned threads, we can flag the threads we want in the Threads window, and then click on the flags icon at the top of the Parallel Stacks window, which will just show the call stacks of the flagged threads:
[[File:Stacks-step1b-threads-flagged.PNG|500px|center|Step 1b - Flagged Threads]]
[[File:Stacks-step1b-flagged.PNG|500px|center|Step 1b - Flagged Threads]]
==Case C==
92
edits