ompi/group: add helper function for creating plist groups
This commit adds a helper function for creating groups from proc lists. The function is used by ompi_comm_fill_rest to create the local and remote groups. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Этот коммит содержится в:
родитель
5334d22a37
Коммит
406b9ff1e6
@ -1980,19 +1980,16 @@ static int ompi_comm_fill_rest(ompi_communicator_t *comm,
|
||||
count on the proc pointers
|
||||
This is just a quick fix, and will be looking for a
|
||||
better solution */
|
||||
OBJ_RELEASE( comm->c_local_group );
|
||||
/* silence clang warning about a NULL pointer dereference */
|
||||
assert (NULL != comm->c_local_group);
|
||||
OBJ_RELEASE( comm->c_local_group );
|
||||
if (comm->c_local_group) {
|
||||
OBJ_RELEASE( comm->c_local_group );
|
||||
}
|
||||
|
||||
if (comm->c_remote_group) {
|
||||
OBJ_RELEASE( comm->c_remote_group );
|
||||
}
|
||||
|
||||
/* allocate a group structure for the new communicator */
|
||||
comm->c_local_group = ompi_group_allocate(num_procs);
|
||||
|
||||
/* free the malloced proc pointers */
|
||||
free(comm->c_local_group->grp_proc_pointers);
|
||||
|
||||
/* set the group information */
|
||||
comm->c_local_group->grp_proc_pointers = proc_pointers;
|
||||
comm->c_local_group = ompi_group_allocate_plist_w_procs (proc_pointers, num_procs);
|
||||
|
||||
/* set the remote group to be the same as local group */
|
||||
comm->c_remote_group = comm->c_local_group;
|
||||
|
@ -153,6 +153,7 @@ OMPI_DECLSPEC extern struct ompi_predefined_group_t *ompi_mpi_group_null_addr;
|
||||
* @return Pointer to new group structure
|
||||
*/
|
||||
OMPI_DECLSPEC ompi_group_t *ompi_group_allocate(int group_size);
|
||||
ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_proc_t **procs, int group_size);
|
||||
ompi_group_t *ompi_group_allocate_sporadic(int group_size);
|
||||
ompi_group_t *ompi_group_allocate_strided(void);
|
||||
ompi_group_t *ompi_group_allocate_bmap(int orig_group_size, int group_size);
|
||||
|
@ -55,6 +55,24 @@ ompi_predefined_group_t *ompi_mpi_group_null_addr = &ompi_mpi_group_null;
|
||||
* Allocate a new group structure
|
||||
*/
|
||||
ompi_group_t *ompi_group_allocate(int group_size)
|
||||
{
|
||||
/* local variables */
|
||||
ompi_proc_t **procs = calloc (group_size, sizeof (ompi_proc_t *));
|
||||
ompi_group_t *new_group;
|
||||
|
||||
if (NULL == procs) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_group = ompi_group_allocate_plist_w_procs (procs, group_size);
|
||||
if (NULL == new_group) {
|
||||
free (procs);
|
||||
}
|
||||
|
||||
return new_group;
|
||||
}
|
||||
|
||||
ompi_group_t *ompi_group_allocate_plist_w_procs (ompi_proc_t **procs, int group_size)
|
||||
{
|
||||
/* local variables */
|
||||
ompi_group_t * new_group = NULL;
|
||||
@ -65,28 +83,19 @@ ompi_group_t *ompi_group_allocate(int group_size)
|
||||
new_group = OBJ_NEW(ompi_group_t);
|
||||
|
||||
if (NULL == new_group) {
|
||||
goto error_exit;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (0 > new_group->grp_f_to_c_index) {
|
||||
OBJ_RELEASE (new_group);
|
||||
new_group = NULL;
|
||||
goto error_exit;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate array of (ompi_proc_t *)'s, one for each
|
||||
* process in the group.
|
||||
*/
|
||||
new_group->grp_proc_pointers = (struct ompi_proc_t **)
|
||||
malloc(sizeof(struct ompi_proc_t *) * group_size);
|
||||
|
||||
if (NULL == new_group->grp_proc_pointers) {
|
||||
/* grp_proc_pointers allocation failed */
|
||||
OBJ_RELEASE (new_group);
|
||||
new_group = NULL;
|
||||
goto error_exit;
|
||||
}
|
||||
new_group->grp_proc_pointers = procs;
|
||||
|
||||
/* set the group size */
|
||||
new_group->grp_proc_count = group_size;
|
||||
@ -95,8 +104,8 @@ ompi_group_t *ompi_group_allocate(int group_size)
|
||||
new_group->grp_my_rank = MPI_UNDEFINED;
|
||||
OMPI_GROUP_SET_DENSE(new_group);
|
||||
|
||||
error_exit:
|
||||
/* return */
|
||||
ompi_group_increment_proc_count (new_group);
|
||||
|
||||
return new_group;
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user