forked from openshmem-org/specification
-
Notifications
You must be signed in to change notification settings - Fork 0
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 openshmem-org#237 from nspark/improve-examples
Improve example code
- Loading branch information
Showing
67 changed files
with
1,004 additions
and
1,143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
BasedOnStyle: LLVM | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
BeforeElse: true | ||
ColumnLimit: 93 |
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
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 |
---|---|---|
|
@@ -86,4 +86,3 @@ | |
load/store operations from the origin \ac{PE} or vice versa. | ||
} | ||
\end{apidefinition} | ||
\newpage |
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 @@ | ||
*.[cf]x |
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
#include <shmem.h> | ||
|
||
int main(void) { | ||
static uint64_t x = 0; | ||
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_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; | ||
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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
#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; | ||
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; | ||
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_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; | ||
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
#include <shmem.h> | ||
|
||
int main(void) { | ||
static int x = 0; | ||
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_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; | ||
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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
#include <stdio.h> | ||
#include <shmem.h> /* The OpenSHMEM header file */ | ||
#include <stdio.h> | ||
|
||
int main (void) | ||
{ | ||
shmem_init(); | ||
int me = shmem_my_pe(); | ||
int npes = shmem_n_pes(); | ||
printf("Hello from %d of %d\n", me, npes); | ||
shmem_finalize(); | ||
return 0; | ||
int main(void) { | ||
shmem_init(); | ||
int mype = shmem_my_pe(); | ||
int npes = shmem_n_pes(); | ||
printf("Hello from %d of %d\n", mype, npes); | ||
shmem_finalize(); | ||
return 0; | ||
} |
Oops, something went wrong.