Write an OpenMP program that divides the Iterations into chunks containing 2 iterations,
respectively (OMP_SCHEDULE=static,2). Its input should be the number of iterations, and
its output should be which iterations of a parallelized for loop are executed by which thread.
For example, if there are two threads and four iterations, the output might be the following:
a. Thread 0 : Iterations 0 −− 1
b. Thread 1 : Iterations 2 – 3
STEP1
Open Dev C++
STEP2
Click on File----Project----Select Console----OpenMP
Select Project as C++ and press OK
STEP3
After Project is created under project create set.cpp file and type code as in below
#include <stdio.h>
#include <omp.h>
int main() {
int n;
printf("Enter number of iterations: ");
scanf("%d", &n);
// Parallel for loop with static scheduling and chunk size 2
#pragma omp parallel for schedule(static, 2)
for (int i = 0; i < n; i++) {
int tid = omp_get_thread_num();
printf("Thread %d : Iteration %d\n", tid, i);
}
return 0;
}
Final Step Goto Execute Menu and click on Compile and Run You can see the Thread execution based
on number of Iterations