-
Notifications
You must be signed in to change notification settings - Fork 12
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 #27 from davidozog/pr/SOS_v1.5.2_sync
Sync with SOS v1.5.2
- Loading branch information
Showing
14 changed files
with
618 additions
and
17 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,16 @@ | ||
Makefile.in | ||
aclocal.m4 | ||
autom4te.cache | ||
configure | ||
|
||
config/compile | ||
config/config.guess | ||
config/config.sub | ||
config/depcomp | ||
config/install-sh | ||
config/libtool.m4 | ||
config/ltmain.sh | ||
config/lt*.m4 | ||
config/missing | ||
|
||
config/test-driver |
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright (c) 2022 Intel Corporation. All rights reserved. | ||
* This software is available to you under the BSD license below: | ||
* | ||
* Redistribution and use in source and binary forms, with or | ||
* without modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <shmem.h> | ||
#include <shmemx.h> | ||
|
||
#define N 128 | ||
#define SHMEM_MALLOC_INVALID_HINT ~(SHMEM_MALLOC_ATOMICS_REMOTE) | ||
|
||
int main(int argc, char **argv) { | ||
int npes, mype; | ||
int errors = 0; | ||
|
||
shmem_init(); | ||
|
||
npes = shmem_n_pes(); | ||
mype = shmem_my_pe(); | ||
|
||
int *src[N]; | ||
|
||
/* Allocate an array of N buffers on the symmeytric heap */ | ||
for (int i = 0; i < N; i++) | ||
src[i] = (int *)shmem_malloc_with_hints(N * sizeof(int), SHMEMX_MALLOC_NO_BARRIER); | ||
|
||
shmem_barrier_all(); /* Synchronization is required after using the SHMEMX_MALLOC_NO_BARRIER hint */ | ||
int *dst = (int *)malloc(N * sizeof(int)); | ||
|
||
for (int i = 0; i < N; i++) { | ||
for (int j = 0; j < N; j++) { | ||
src[i][j] = -1; | ||
} | ||
} | ||
|
||
/* src is initialized to become a diagonal matrix */ | ||
for (int i = 0; i < N; i++) { | ||
src[i][i] = i; | ||
dst[i] = -1; | ||
} | ||
|
||
shmem_sync_all(); /* sync sender and receiver */ | ||
|
||
if (mype == 0) { | ||
for (int i = 0; i < N; i++) { | ||
/* get elements from src's diagonal on each PE and copy into dst on PE 0 */ | ||
shmem_int_get(&dst[i], &src[i][i], 1, i % npes); | ||
} | ||
} | ||
|
||
shmem_barrier_all(); /* sync sender and receiver */ | ||
|
||
if (mype == 0) { | ||
for (int i = 0 ; i < N ; ++i) { | ||
if (src[i][i] != dst[i]) { | ||
printf("%d,%d ", src[i][i], dst[i]); | ||
++errors; | ||
} | ||
} | ||
if(errors) { | ||
printf("\nFailed with %d errors\n", errors); | ||
shmem_global_exit(errors); | ||
} | ||
} | ||
|
||
for (int i = 0; i < N; i++) | ||
shmem_free(src[i]); | ||
free(dst); | ||
|
||
if (mype == 0) | ||
printf("Passed with 0 errors\n"); | ||
|
||
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
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,63 @@ | ||
/* | ||
* Copyright (c) 2022 Intel Corporation. All rights reserved. | ||
* This software is available to you under the BSD license below: | ||
* | ||
* Redistribution and use in source and binary forms, with or | ||
* without modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <shmem.h> | ||
|
||
#define NELEM 10 | ||
|
||
long src[NELEM]; | ||
|
||
int main(void) | ||
{ | ||
int me; | ||
int errors = 0; | ||
|
||
shmem_init(); | ||
|
||
me = shmem_my_pe(); | ||
|
||
for (int i = 0; i < NELEM; i++) | ||
src[i] = me + i; | ||
|
||
shmem_barrier_all(); | ||
|
||
shmem_long_broadcast(SHMEM_TEAM_WORLD, src, src, NELEM, 0); | ||
|
||
/* Validate broadcast data */ | ||
for (int j = 0; j < NELEM; j++) { | ||
long expected = j; | ||
if (src[j] != expected) { | ||
printf("%d: Expected src[%d] = %ld, got src[%d] = %ld\n", me, j, expected, j, src[j]); | ||
errors++; | ||
} | ||
} | ||
|
||
shmem_finalize(); | ||
|
||
return errors != 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
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,80 @@ | ||
/* | ||
* Copyright (c) 2022 Intel Corporation. All rights reserved. | ||
* This software is available to you under the BSD license below: | ||
* | ||
* Redistribution and use in source and binary forms, with or | ||
* without modification, are permitted provided that the following | ||
* conditions are met: | ||
* | ||
* - Redistributions of source code must retain the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* - Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <shmem.h> | ||
|
||
int main(void) { | ||
int ret; | ||
shmem_team_t retrieved_team; | ||
|
||
shmem_init(); | ||
|
||
if (shmem_n_pes() < 2) { | ||
fprintf(stderr, "ERR - Requires at least 2 PEs\n"); | ||
shmem_finalize(); | ||
return 0; | ||
} | ||
|
||
/* test for invalid context */ | ||
ret = shmem_ctx_get_team(SHMEM_CTX_INVALID, &retrieved_team); | ||
if (ret == 0 || retrieved_team != SHMEM_TEAM_INVALID) { | ||
fprintf(stderr, "Error in return values for SHMEM_CTX_INVALID\n"); | ||
shmem_global_exit(1); | ||
} | ||
|
||
/* test for default context */ | ||
ret = shmem_ctx_get_team(SHMEM_CTX_DEFAULT, &retrieved_team); | ||
if (ret != 0 || retrieved_team != SHMEM_TEAM_WORLD) { | ||
fprintf(stderr, "Error in return values for SHMEM_CTX_DEFAULT\n"); | ||
shmem_global_exit(2); | ||
} | ||
|
||
/* test for a created context on a user defined team*/ | ||
shmem_team_t new_team; | ||
shmem_team_config_t *config; | ||
|
||
config = NULL; | ||
int npes = shmem_n_pes(); | ||
|
||
ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, (npes + 1) / 2, | ||
config, 0, &new_team); | ||
if (new_team != SHMEM_TEAM_INVALID) { | ||
shmem_ctx_t team_ctx; | ||
if (!shmem_team_create_ctx(new_team, 0L, &team_ctx)) { | ||
ret = shmem_ctx_get_team(team_ctx, &retrieved_team); | ||
if (ret != 0 || retrieved_team != new_team) { | ||
fprintf(stderr, "Error in return values for a team context\n"); | ||
shmem_global_exit(3); | ||
} | ||
} | ||
} | ||
|
||
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
Oops, something went wrong.