Created
April 17, 2018 06:51
-
-
Save auriza/d00a76bd3b1a6e67e92e64f7189bae31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <omp.h> | |
int main() { | |
int i, j; | |
int n = 5; | |
// for --> imbalance | |
// for collapse(2) --> undefined: inner-loop depends on outer-loop (j <= i) | |
// task --> balance | |
#pragma omp parallel | |
{ | |
#pragma omp single private(i,j) | |
for (i = 0; i < n; i++) | |
for (j = 0; j <= i; j++) | |
#pragma omp task | |
{ | |
printf("[%d]: (%d, %d)\n", omp_get_thread_num(), i, j); | |
sleep(1); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment