Changes

Jump to: navigation, search

GPU621/OpenMP Debugging

693 bytes added, 21:07, 8 December 2021
Case A - Using the Thread window
<syntaxhighlight lang="cpp">
#include <iostream>
#include <omp.h>
 
using namespace std;
 
// Thread Window Example
int max_threads = omp_get_max_threads();
cout << "the maximum amount of threads available is: " << max_threads << endl;
 
{
cout << endl << "~~~~~ Inside Serial Block ~~~~~" << endl;
cout << "the amount of threads available in this block is: " << omp_get_num_threads() << endl;
cout << "current thread is: " << omp_get_thread_num() << endl;
}
 
#pragma omp parallel
{
#pragma omp single
{
cout << endl << "~~~~~~ Inside Parallel Block (num_threads unspecified) ~~~~~~" << endl;
cout << "the amount of threads available in this block is: " << omp_get_num_threads() << endl;
}
cout << "current thread is: " << omp_get_thread_num() << endl;
}
#pragma omp parallel num_threads(max_threads/2)
{
#pragma omp single
{ cout << endl << "~~~~~~ Inside Parallel Block (num_threads specified as " << max_threads / 2 << ") ~~~~~~" << endl; cout << "the amount of threads available in this block is: " << omp_get_num_threads() << endl; } cout << "current thread is: " << omp_get_thread_num() << endl;
}
}
49
edits

Navigation menu