Created
September 18, 2012 09:34
-
-
Save submachine/3742251 to your computer and use it in GitHub Desktop.
An atomic 'fetch and add' using OpenMP directives
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
/* Compiling with `gcc -fopenmp -m32 -O2 -S' produces: | |
movl $1, %eax | |
lock xaddl %eax, j | |
movl %eax, i | |
ret | |
*/ | |
int i, j; | |
void foo (void) | |
{ | |
#pragma omp atomic capture | |
i = j++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment