Last active
October 18, 2017 17:38
-
-
Save PChild/a99d24f5babf05f93a38dff21daaa03e to your computer and use it in GitHub Desktop.
Testing what happens with function-scoped static variables interacting with OpenMP
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 <stdio.h> | |
#include <stdlib.h> | |
#include <omp.h> | |
void foo(int rank) | |
{ | |
static int x = 5; | |
x++; | |
printf("%d from %d\n", x, rank); | |
} | |
int main(){ | |
omp_set_num_threads(10); | |
#pragma omp parallel | |
{ | |
int rank = omp_get_thread_num(); | |
foo(rank); | |
} | |
exit(0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment