-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from jdinan/pr/atomicity-clarification
Update atomic memory model text
- Loading branch information
Showing
6 changed files
with
104 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <shmem.h> | ||
|
||
int main(void) { | ||
static uint64_t x = 0; | ||
|
||
shmem_init(); | ||
/* Undefined behavior: The following AMOs access the same location concurrently using | ||
* different types. */ | ||
if (shmem_my_pe() > 0) | ||
shmem_uint32_atomic_or((uint32_t*)&x, shmem_my_pe()+1, 0); | ||
else | ||
shmem_uint64_atomic_or(&x, shmem_my_pe()+1, 0); | ||
|
||
shmem_finalize(); | ||
return 0; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <shmem.h> | ||
|
||
int main(void) { | ||
static long psync[SHMEM_REDUCE_SYNC_SIZE]; | ||
static int pwrk[SHMEM_REDUCE_MIN_WRKDATA_SIZE]; | ||
static int x = 0, y = 0; | ||
|
||
for (int i = 0; i < SHMEM_REDUCE_SYNC_SIZE; i++) | ||
psync[i] = SHMEM_SYNC_VALUE; | ||
|
||
shmem_init(); | ||
shmem_int_atomic_inc(&x, (shmem_my_pe()+1) % shmem_n_pes()); | ||
/* Undefined behavior: The following reduction operation performs accesses to symmetric | ||
* variable 'x' that are concurrent with previously issued atomic increment operations | ||
* on the same variable. */ | ||
shmem_int_sum_to_all(&y, &x, 1, 0, 0, shmem_n_pes(), pwrk, psync); | ||
|
||
shmem_finalize(); | ||
return 0; | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <shmem.h> | ||
|
||
int main(void) { | ||
static int x = 0; | ||
|
||
shmem_init(); | ||
/* Undefined behavior: OpenSHMEM atomic increment operations are concurrent with the local | ||
* increment of symmetric variable 'x'. */ | ||
if (shmem_my_pe() > 0) | ||
shmem_int_atomic_inc(&x, 0); | ||
else | ||
x++; | ||
|
||
shmem_finalize(); | ||
return 0; | ||
} |
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