Open main menu

CDOT Wiki β

Changes

GPU621/OpenMP Debugging

396 bytes removed, 20:50, 8 December 2021
Case A - Using the Thread window
using namespace std;
int main(){ printf("num of default usable thread is %d \n\n", omp_get_max_threads());// Thread Window Example
// serial ver #include <iostream> printf("num of thread currently using is %d \n", omp_get_num_threads());#include <omp.h>
printf("working thread num is %d \n", omp_get_thread_num())using namespace std;
void main() { printfint max_threads = omp_get_max_threads(); cout << "\nthe maximum amount of threads available is: ")<< max_threads << endl;
#pragma omp parallel num_threads(max_threads/2) { #pragma omp single // set openMP ver { printf(cout << "num the amount of thread currently using threads available in this block is %d \n: ", << omp_get_num_threads()); } printf("working thread num is %d \n", omp_get_thread_num())<< endl;
}
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