Difference between revisions of "GPU621/Group 2"

From CDOT Wiki
Jump to: navigation, search
m (Debugging single-threaded V.S. multithreaded programs)
(OpenMP Debugging in Visual Studio)
Line 17: Line 17:
  
 
= OpenMP Debugging in Visual Studio =
 
= OpenMP Debugging in Visual Studio =
 +
Debugging in Visual Studio will be demonstrated using this code:
 +
<syntaxhighlight>
 +
#include <stdio.h>
 +
#include <omp.h>
 +
 +
int main() {
 +
int numThreads = omp_get_max_threads();
 +
printf("Number of threads: %d\n", numThreads);
 +
#pragma omp parallel
 +
{
 +
int threadNum = omp_get_thread_num() + 1;
 +
printf("Hello thread #%d\n", threadNum);
 +
}
 +
printf("End of program");
 +
}
 +
</syntaxhighlight>
 +
 
== Threads Window ==
 
== Threads Window ==
 +
[[File:ThreadsWindow.png]]
 +
 +
The threads window displays all the threads in your application
 +
 
=== Switching Threads ===
 
=== Switching Threads ===
 +
[[File:ThreadsWindowSwitch.png]]
 +
 +
[[File:ThreadsWindowSwitch2.png]]
 +
 +
== Freezing/Thawing Threads ==
 +
[[File:ThreadsWindowFreeze1.png]]
 +
 +
[[File:ThreadsWindowFreeze2.png]]
 +
 +
[[File:ThreadsWindowFreeze3.png]]
 +
 +
[[File:ThreadsWindowFreeze4.png|850px|right]]
 +
 +
[[File:ThreadsWindowFreeze5.png|850px|right]]
 +
 +
[[File:ThreadsWindowFreeze6.png|850px|right]]
 +
 +
[[File:ThreadsWindowFreeze7.png|850px|right]]
 +
 +
[[File:ThreadsWindowFreeze8.png|850px|right]]
 +
 +
[[File:ThreadsWindowFreeze9.png|850px|right]]
 +
 +
[[File:ThreadsWindowFreeze10.png|850px|right]]
 +
 +
[[File:ThreadsWindowFreeze11.png|850px|right]]
 +
 
=== Flagging Threads ===
 
=== Flagging Threads ===
 +
[[File:ThreadsWindowFlag.png]]
 +
 +
== Grouping Threads ==
 +
[[File:ThreadsWindowGroup1.png]]
 +
 +
[[File:ThreadsWindowGroup2.png]]
 +
 +
== Searching Threads ==
 +
[[File:ThreadsWindowSearch1.png]]
  
== Walkthrough ==
+
[[File:ThreadsWindowSearch2.png]]
  
 
= Sources =
 
= Sources =
 
https://learn.microsoft.com/en-ca/previous-versions/visualstudio/visual-studio-2015/debugger/debug-multithreaded-applications-in-visual-studio?view=vs-2015
 
https://learn.microsoft.com/en-ca/previous-versions/visualstudio/visual-studio-2015/debugger/debug-multithreaded-applications-in-visual-studio?view=vs-2015

Revision as of 17:09, 2 March 2023


GPU621/DPS921 | Participants | Groups and Projects | Resources | Glossary

Group Members

  1. Darius Seifert Booth
  2. Rudy Chung

Definitions

Processes

Every process is a separate instance of a particular program that is being run on a computer.

Threads

Threads are sets of instructions that get executed by the processes that contain them. The existence of multiple threads enables a process to separate work to be performed in parallel.

Debugging Single-threaded V.S. Multi-threaded Programs

Debugging usually occurs on a single threaded program by pausing the execution at a specific line of code. While the execution is paused, the values of all the variables can be inspected. This can be helpful to closely view what is occurring between each line of code.

Debugging a multithreaded program is different from debugging a single threaded program because each thread has its own sequence of execution, meaning that the point that the execution is paused at can vary for each thread.

OpenMP Debugging in Visual Studio

Debugging in Visual Studio will be demonstrated using this code:

#include <stdio.h>
#include <omp.h>

int main() {
	int numThreads = omp_get_max_threads();
	printf("Number of threads: %d\n", numThreads);
	#pragma omp parallel
	{
		int threadNum = omp_get_thread_num() + 1;
		printf("Hello thread #%d\n", threadNum);
	}
	printf("End of program");
}

Threads Window

ThreadsWindow.png

The threads window displays all the threads in your application

Switching Threads

ThreadsWindowSwitch.png

ThreadsWindowSwitch2.png

Freezing/Thawing Threads

ThreadsWindowFreeze1.png

ThreadsWindowFreeze2.png

ThreadsWindowFreeze3.png

ThreadsWindowFreeze4.png
ThreadsWindowFreeze5.png
ThreadsWindowFreeze6.png
ThreadsWindowFreeze7.png
ThreadsWindowFreeze8.png
ThreadsWindowFreeze9.png
ThreadsWindowFreeze10.png
ThreadsWindowFreeze11.png

Flagging Threads

ThreadsWindowFlag.png

Grouping Threads

ThreadsWindowGroup1.png

ThreadsWindowGroup2.png

Searching Threads

ThreadsWindowSearch1.png

ThreadsWindowSearch2.png

Sources

https://learn.microsoft.com/en-ca/previous-versions/visualstudio/visual-studio-2015/debugger/debug-multithreaded-applications-in-visual-studio?view=vs-2015