Skip to content

Commit

Permalink
Merge pull request #1122 from davidozog/pr/num_contexts_patch
Browse files Browse the repository at this point in the history
num_contexts patch
  • Loading branch information
davidozog authored May 1, 2024
2 parents 5b9a7d8 + 6198b74 commit e3ba48e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "modules/tests-sos"]
path = modules/tests-sos
url = ../../openshmem-org/tests-sos.git
branch = main
url = ../../ronawho/tests-sos.git
branch = fix_team_get_config_test
2 changes: 1 addition & 1 deletion modules/tests-sos
30 changes: 26 additions & 4 deletions src/shmem_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,33 @@ int shmem_internal_team_split_strided(shmem_internal_team_t *parent_team, int PE
myteam->start = global_PE_start;
myteam->stride = PE_stride;
myteam->size = PE_size;
if (config) {
myteam->config = *config;
myteam->config_mask = config_mask;

if (config_mask == 0) {
if (config != NULL) {
RAISE_WARN_MSG("%s %s\n", "team_split_strided operation encountered an unexpected",
"non-NULL config structure passed with a config_mask of 0.");
}
shmem_team_config_t defaults;
myteam->config_mask = 0;
myteam->contexts_len = 0;
defaults.num_contexts = 0;
memcpy(&myteam->config, &defaults, sizeof(shmem_team_config_t));
} else {
if (config_mask != SHMEM_TEAM_NUM_CONTEXTS) {
RAISE_WARN_MSG("Invalid team_split_strided config_mask (%ld)\n", config_mask);
return -1;
} else {
shmem_internal_assertp(config->num_contexts >= 0);
myteam->config = *config;
myteam->config_mask = config_mask;
myteam->contexts_len = config->num_contexts;
myteam->contexts = malloc(config->num_contexts * sizeof(shmem_transport_ctx_t*));
for (int i = 0; i < config->num_contexts; i++) {
myteam->contexts[i] = NULL;
}
}
}
myteam->contexts_len = 0;

myteam->psync_idx = -1;

shmem_internal_op_to_all(psync_pool_avail_reduced,
Expand Down
3 changes: 3 additions & 0 deletions src/teams_c.c4
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ shmem_team_get_config(shmem_team_t team, long config_mask, shmem_team_config_t *
return -1;
}
memcpy(config, &myteam->config, sizeof(shmem_team_config_t));
} else if (config != NULL) {
RAISE_WARN_MSG("%s %s\n", "shmem_team_get_config encountered an unexpected",
"non-NULL config structure passed with a config_mask of 0.");
}

return 0;
Expand Down

0 comments on commit e3ba48e

Please sign in to comment.