Question
include #include void function_1() { for (int i = 0; i != 1; i++) { printf (Function 1 done by thread %d , omp_get_thread_num());
include #include void function_1() { for (int i = 0; i != 1; i++) { printf ("Function 1 done by thread %d " , omp_get_thread_num()); } } void function_2() { for (int j = 0; j != 2; j++) { printf ("Function 2 done by thread %d " , omp_get_thread_num()); } } int main() { int n = 2; //number of threads omp_set_num_threads(n); #pragma omp parallel { #pragma omp sections { #pragma omp section { function_1(); } #pragma omp section { function_2(); } } } } /* gcc sections.c -o sections -fopenmp ./sections 1. What is the expected output? 2. What happens if the number of threads and the number of sections is different? 2.1 More threads than sections? 2.2 Less threads than sections? 3. Which thread executes which section?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started