Skip to content

Commit

Permalink
teams: preallocate num_contexts if config_mask set
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ozog committed Apr 30, 2024
1 parent aa1e722 commit 625a986
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/shmem_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,21 +336,27 @@ int shmem_internal_team_split_strided(shmem_internal_team_t *parent_team, int PE
myteam->size = PE_size;

if (config_mask == 0) {
shmem_team_config_t default_config;
default_config.num_contexts = 0;
myteam->config_mask = 0;
memcpy(&myteam->config, &default_config, sizeof(shmem_team_config_t));
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 {
myteam->config = *config;
myteam->config_mask = config_mask;
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

0 comments on commit 625a986

Please sign in to comment.