Changes

Jump to: navigation, search

GPU621/OpenMP Debugging

880 bytes added, 19:55, 8 December 2021
Case A - Using the Thread window
==Case A - Using the Thread window==
The following example of how to use Visual Studio's thread window was performed on Microsoft Visual Studio 2019 with Intel OneAPI Libraries and Intel Visual C++ Compiler.
 
<syntaxhighlight lang="cpp">
#include <iostream>
#include <omp.h>
 
using namespace std;
 
int main()
{
printf("num of default usable thread is %d \n\n", omp_get_max_threads());
 
// serial ver
printf("num of thread currently using is %d \n", omp_get_num_threads());
 
printf("working thread num is %d \n", omp_get_thread_num());
 
printf("\n");
 
#pragma omp parallel
{
#pragma omp single // set openMP ver
{
printf("num of thread currently using is %d \n", omp_get_num_threads());
}
printf("working thread num is %d \n", omp_get_thread_num());
}
printf("\n");
 
#pragma omp parallel num_threads(8)
{
#pragma omp single // set openMP with num of threads ver
{
printf("num of thread currently using is %d \n", omp_get_num_threads());
}
printf("working thread num is %d \n", omp_get_thread_num());
}
printf("\n");
 
return 0;
}
</syntaxhighlight>
49
edits

Navigation menu