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

CleanShot 2024-04-02 at 00.12.19@2x

CleanShot 2024-04-02 at 00.12.37@2x

Final State

CleanShot 2024-06-22 at 4 .05.14@2x

Q3

CleanShot 2024-04-02 at 00.10.00@2x

CleanShot 2024-04-02 at 00.10.27@2x

Q4

(i)

All to All Personalised AKA Total Exchange

(ii)

CleanShot 2024-06-22 at 4 .04.55@2x

(iii)

CleanShot 2024-06-22 at 4 .04.29@2x