Reference Document: A 3.pdf
Q1
workers = omp_get_max_threads(); //can use num_procs
printf ("%d maximum allowed threads\n", workers);
printf ("Total number of allocated cores are:%d\n", omp_get_num_procs());
omp_set_dynamic(1); // dynamic adjustment enabled
omp_set_num_threads(8);
printf ("Total number of requested when dynamic is true are:%d\n", 8);
#pragma omp parallel {
#pragma omp single nowait
printf("Total threads in parallel region1=%d:\n", omp_get_num_threads());
#pragma omp for
for (i = 0; i < mult; i++)
{a = complex_func();}
}
omp_set_dynamic(0); // dynamic adjustment disabled
omp_set_num_threads(6);
printf("Total number of requested when dynamic is false are:%d\n", 6);
#pragma omp parallel {
#pragma omp single nowait
printf("Total threads in parallel region2=%d:\n", omp_get_num_threads());
#pragma omp for
for (i = 0; i < mult; i++)
{a = complex_func();}
}
Output
4 maximum allowed threads
Total number of allocated cores are 4
Total number of requested when dynamic is true are: 8
Total threads in parallel region1= 4
Total number of requested when dynamic is false are: 6
Total threads in parallel region2= 6
Q2
Final State
Q3
Q4
(i)
All to All Personalised AKA Total Exchange
(ii)
(iii)