Created
November 2, 2021 11:34
-
-
Save kaityo256/1d78d926fa8f46566ab003e08639ef59 to your computer and use it in GitHub Desktop.
OpenMP Schedule Sample
This file contains 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 <cstdio> | |
#include <omp.h> | |
const int N = 8; | |
int d[N] = {}; | |
int main() { | |
int tid; | |
#pragma omp parallel for schedule(static) | |
for (int i = 0; i < N; i++) { | |
tid = omp_get_thread_num(); | |
for (int j = 0; j < 1000; j++) { | |
d[i] += tid; | |
} | |
} | |
for (int i = 0; i < N; i++) { | |
printf("%d %d\n", i, d[i]); | |
} | |
} |
I forgot private(tid)
.
#pragma omp parallel for schedule(static) private(tid)
This is the reason why the behaviours between g++ and icpc werr different.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the case of Intel Compiler
This is the expected behavior.
For the case of GCC
WHY????