-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signal set add APIs #1109
Closed
Closed
Signal set add APIs #1109
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d9c686a
Signal set add APIs
wrrobin be43e0b
Unit tests for signal set add
wrrobin a149fe0
Moved unit tests to shmemx
wrrobin f024b91
C11 for set add
wrrobin a3e44ae
Update of the unit tests based on the issues reported by Rithwik
wrrobin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -245,6 +245,14 @@ SHMEM_PROF_DEF_CTX_PUT_N_SIGNAL_NBI(`mem') | |
#define shmemx_ct_wait pshmemx_ct_wait | ||
#pragma weak shmem_signal_fetch = pshmem_signal_fetch | ||
#define shmem_signal_fetch pshmem_signal_fetch | ||
#pragma weak shmemx_signal_add = pshmemx_signal_add | ||
#define shmemx_signal_add pshmemx_signal_add | ||
#pragma weak shmemx_signal_set = pshmemx_signal_set | ||
#define shmemx_signal_set pshmemx_signal_set | ||
#pragma weak shmemx_ctx_signal_add = pshmemx_ctx_signal_add | ||
#define shmemx_ctx_signal_add pshmemx_ctx_signal_add | ||
#pragma weak shmemx_ctx_signal_set = pshmemx_ctx_signal_set | ||
#define shmemx_ctx_signal_set pshmemx_ctx_signal_set | ||
|
||
#endif /* ENABLE_PROFILING */ | ||
|
||
|
@@ -700,6 +708,52 @@ shmem_signal_fetch(const uint64_t* sig_addr) | |
return val; | ||
} | ||
|
||
void SHMEM_FUNCTION_ATTRIBUTES | ||
shmemx_signal_add(uint64_t *sig_addr, uint64_t signal, int pe) | ||
{ | ||
SHMEM_ERR_CHECK_INITIALIZED(); | ||
SHMEM_ERR_CHECK_PE(pe); | ||
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t)); | ||
|
||
shmem_internal_atomic(SHMEM_CTX_DEFAULT, sig_addr, &signal, sizeof(uint64_t), | ||
pe, SHM_INTERNAL_SUM, SHM_INTERNAL_UINT64); | ||
} | ||
|
||
void SHMEM_FUNCTION_ATTRIBUTES | ||
shmemx_ctx_signal_add(shmem_ctx_t ctx, uint64_t *sig_addr, uint64_t signal, int pe) | ||
{ | ||
SHMEM_ERR_CHECK_INITIALIZED(); | ||
SHMEM_ERR_CHECK_PE(pe); | ||
SHMEM_ERR_CHECK_CTX(ctx); | ||
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t)); | ||
|
||
shmem_internal_atomic(ctx, sig_addr, &signal, sizeof(uint64_t), | ||
pe, SHM_INTERNAL_SUM, SHM_INTERNAL_UINT64); | ||
} | ||
|
||
void SHMEM_FUNCTION_ATTRIBUTES | ||
shmemx_signal_set(uint64_t *sig_addr, uint64_t signal, int pe) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question about const-ness of sig_addr |
||
{ | ||
SHMEM_ERR_CHECK_INITIALIZED(); | ||
SHMEM_ERR_CHECK_PE(pe); | ||
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t)); | ||
|
||
shmem_internal_atomic_set(SHMEM_CTX_DEFAULT, (void *) sig_addr, &signal, | ||
sizeof(uint64_t), pe, SHM_INTERNAL_UINT64); | ||
} | ||
|
||
void SHMEM_FUNCTION_ATTRIBUTES | ||
shmemx_ctx_signal_set(shmem_ctx_t ctx, uint64_t *sig_addr, uint64_t signal, int pe) | ||
{ | ||
SHMEM_ERR_CHECK_INITIALIZED(); | ||
SHMEM_ERR_CHECK_PE(pe); | ||
SHMEM_ERR_CHECK_CTX(ctx); | ||
SHMEM_ERR_CHECK_SYMMETRIC(sig_addr, sizeof(uint64_t)); | ||
|
||
shmem_internal_atomic_set(ctx, (void *) sig_addr, &signal, | ||
sizeof(uint64_t), pe, SHM_INTERNAL_UINT64); | ||
} | ||
|
||
void SHMEM_FUNCTION_ATTRIBUTES | ||
shmemx_getmem_ct(shmemx_ct_t ct, void *target, const void *source, size_t nelems, int pe) | ||
{ | ||
|
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,83 @@ | ||
/* | ||
* Copyright (c) 2024 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. | ||
*/ | ||
|
||
/* | ||
* Validate signal_add operation | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <shmem.h> | ||
#include <shmemx.h> | ||
#include <string.h> | ||
|
||
#define MSG_SZ 10 | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
long source[MSG_SZ]; | ||
long *target; | ||
int me, npes, i; | ||
int errors = 0; | ||
|
||
static uint64_t sig_addr = 0; | ||
|
||
shmem_init(); | ||
|
||
me = shmem_my_pe(); | ||
npes = shmem_n_pes(); | ||
|
||
for (i = 0; i < MSG_SZ; i++) | ||
source[i] = i; | ||
|
||
target = (long *) shmem_calloc(MSG_SZ, sizeof(long)); | ||
if (!target) { | ||
fprintf(stderr, "Failed to allocate target pointer\n"); | ||
shmem_global_exit(1); | ||
} | ||
|
||
shmem_barrier_all(); | ||
for (i = 0; i < npes; i++) { | ||
shmem_long_put(target, source, MSG_SZ, i); | ||
shmem_fence(); | ||
shmemx_signal_add(&sig_addr, me, i); | ||
} | ||
|
||
shmem_signal_wait_until(&sig_addr, SHMEM_CMP_EQ, (uint64_t) ((npes * (npes - 1)) / 2)); | ||
|
||
for (i = 0; i < MSG_SZ; i++) { | ||
if (target[i] != source[i]) { | ||
fprintf(stderr, "%10d: target[%d] = %ld not matching %ld with SHMEM_SIGNAL_ADD\n", | ||
me, i, target[i], source[i]); | ||
errors++; | ||
} | ||
} | ||
|
||
shmem_free(target); | ||
shmem_finalize(); | ||
|
||
return errors; | ||
} |
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,87 @@ | ||
/* | ||
* Copyright (c) 2024 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. | ||
*/ | ||
|
||
/* | ||
* Validate signal_set operation | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <shmem.h> | ||
#include <shmemx.h> | ||
#include <string.h> | ||
|
||
#define MSG_SZ 10 | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
long source[MSG_SZ]; | ||
long *target; | ||
int me, npes, i, dest_pe; | ||
int errors = 0; | ||
|
||
static uint64_t sig_addr = 0; | ||
|
||
shmem_init(); | ||
|
||
me = shmem_my_pe(); | ||
npes = shmem_n_pes(); | ||
dest_pe = (me + 1) % npes; | ||
|
||
for (i = 0; i < MSG_SZ; i++) | ||
source[i] = me + i; | ||
|
||
target = (long *) shmem_calloc(MSG_SZ, sizeof(long)); | ||
if (!target) { | ||
fprintf(stderr, "Failed to allocate target pointer\n"); | ||
shmem_global_exit(1); | ||
} | ||
|
||
shmem_barrier_all(); | ||
if (me == 0) { | ||
shmem_long_put_nbi(target, source, MSG_SZ, dest_pe); | ||
shmemx_signal_set(SHMEM_CTX_DEFAULT, &sig_addr, me + 1, dest_pe); | ||
shmem_signal_wait_until(&sig_addr, SHMEM_CMP_EQ, npes); | ||
} else { | ||
shmem_signal_wait_until(&sig_addr, SHMEM_CMP_EQ, me); | ||
shmem_long_put_nbi(target, source, MSG_SZ, dest_pe); | ||
shmemx_signal_set(SHMEM_CTX_DEFAULT, &sig_addr, me + 1, dest_pe); | ||
} | ||
shmem_barrier_all(); | ||
|
||
for (i = 0; i < MSG_SZ; i++) { | ||
if (target[i] != (long)(((me + npes - 1) % npes) + i)) { | ||
fprintf(stderr, "%10d: target[%d] = %ld not matching %ld with SHMEM_SIGNAL_SET\n", | ||
me, i, target[i], (long)(((me + npes - 1) % npes) + i)); | ||
errors++; | ||
} | ||
} | ||
|
||
shmem_free(target); | ||
shmem_finalize(); | ||
|
||
return errors; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should sig_addr be const? I know in the PR where this was added in the spec the change was suggested to remove the const modifier from sig_addr, but it looks like in the main branch of the OpenSHMEM spec repo it is still a const parameter