Skip to content

Instantly share code, notes, and snippets.

@PChild
Last active October 18, 2017 17:38
Show Gist options
  • Save PChild/a99d24f5babf05f93a38dff21daaa03e to your computer and use it in GitHub Desktop.
Save PChild/a99d24f5babf05f93a38dff21daaa03e to your computer and use it in GitHub Desktop.
Testing what happens with function-scoped static variables interacting with OpenMP
#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