ompi/group: do not allocate ompi_proc_t's on group union/difference
This commit modifies the ompi_group_t union/difference code to compare/copy the raw group values. This will either be a ompi_proc_t or a sentinel value. This commit also adds helper functions to convert between opal process names and sentinel values. Signed-off-by: Nathan Hjelm <hjelmn@me.com>
Этот коммит содержится в:
родитель
2041aac4e4
Коммит
5b7943db78
@ -109,12 +109,13 @@ int ompi_comm_init(void)
|
|||||||
|
|
||||||
for (size_t i = 0 ; i < size ; ++i) {
|
for (size_t i = 0 ; i < size ; ++i) {
|
||||||
opal_process_name_t name = {.vpid = i, .jobid = OMPI_PROC_MY_NAME->jobid};
|
opal_process_name_t name = {.vpid = i, .jobid = OMPI_PROC_MY_NAME->jobid};
|
||||||
|
/* look for existing ompi_proc_t that matches this name */
|
||||||
group->grp_proc_pointers[i] = (ompi_proc_t *) ompi_proc_lookup (name);
|
group->grp_proc_pointers[i] = (ompi_proc_t *) ompi_proc_lookup (name);
|
||||||
if (NULL == group->grp_proc_pointers[i]) {
|
if (NULL == group->grp_proc_pointers[i]) {
|
||||||
/* set sentinel value */
|
/* set sentinel value */
|
||||||
group->grp_proc_pointers[i] = (ompi_proc_t *)(-*((intptr_t *) &name));
|
group->grp_proc_pointers[i] = (ompi_proc_t *) ompi_proc_name_to_sentinel (name);
|
||||||
} else {
|
} else {
|
||||||
OBJ_RETAIN (ompi_proc_local_proc);
|
OBJ_RETAIN (group->grp_proc_pointers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
|
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
|
||||||
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
|
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
|
||||||
* Copyright (c) 2012-2013 Inria. All rights reserved.
|
* Copyright (c) 2012-2013 Inria. All rights reserved.
|
||||||
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
|
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
* Copyright (c) 2015 Research Organization for Information Science
|
* Copyright (c) 2015 Research Organization for Information Science
|
||||||
* and Technology (RIST). All rights reserved.
|
* and Technology (RIST). All rights reserved.
|
||||||
@ -49,16 +49,14 @@ int ompi_group_translate_ranks ( ompi_group_t *group1,
|
|||||||
ompi_group_t *group2,
|
ompi_group_t *group2,
|
||||||
int *ranks2)
|
int *ranks2)
|
||||||
{
|
{
|
||||||
int rank, proc, proc2;
|
|
||||||
struct ompi_proc_t *proc1_pointer, *proc2_pointer;
|
|
||||||
|
|
||||||
if ( MPI_GROUP_EMPTY == group1 || MPI_GROUP_EMPTY == group2 ) {
|
if ( MPI_GROUP_EMPTY == group1 || MPI_GROUP_EMPTY == group2 ) {
|
||||||
for (proc = 0; proc < n_ranks ; proc++) {
|
for (int proc = 0; proc < n_ranks ; ++proc) {
|
||||||
ranks2[proc] = MPI_UNDEFINED;
|
ranks2[proc] = MPI_UNDEFINED;
|
||||||
}
|
}
|
||||||
return MPI_SUCCESS;
|
return MPI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OMPI_GROUP_SPARSE
|
||||||
/*
|
/*
|
||||||
* If we are translating from a parent to a child that uses the sparse format
|
* If we are translating from a parent to a child that uses the sparse format
|
||||||
* or vice versa, we use the translate ranks function corresponding to the
|
* or vice versa, we use the translate ranks function corresponding to the
|
||||||
@ -80,8 +78,11 @@ int ompi_group_translate_ranks ( ompi_group_t *group1,
|
|||||||
(group1,n_ranks,ranks1,group2,ranks2);
|
(group1,n_ranks,ranks1,group2,ranks2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* unknown sparse group type */
|
||||||
|
assert (0);
|
||||||
}
|
}
|
||||||
else if( group2->grp_parent_group_ptr == group1 ) { /* from parent to child*/
|
|
||||||
|
if( group2->grp_parent_group_ptr == group1 ) { /* from parent to child*/
|
||||||
if(OMPI_GROUP_IS_SPORADIC(group2)) {
|
if(OMPI_GROUP_IS_SPORADIC(group2)) {
|
||||||
return ompi_group_translate_ranks_sporadic
|
return ompi_group_translate_ranks_sporadic
|
||||||
(group1,n_ranks,ranks1,group2,ranks2);
|
(group1,n_ranks,ranks1,group2,ranks2);
|
||||||
@ -95,28 +96,32 @@ int ompi_group_translate_ranks ( ompi_group_t *group1,
|
|||||||
(group1,n_ranks,ranks1,group2,ranks2);
|
(group1,n_ranks,ranks1,group2,ranks2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* unknown sparse group type */
|
||||||
|
assert (0);
|
||||||
}
|
}
|
||||||
else {
|
#endif
|
||||||
/* loop over all ranks */
|
|
||||||
for (proc = 0; proc < n_ranks; proc++) {
|
/* loop over all ranks */
|
||||||
rank=ranks1[proc];
|
for (int proc = 0; proc < n_ranks; ++proc) {
|
||||||
if ( MPI_PROC_NULL == rank) {
|
struct ompi_proc_t *proc1_pointer, *proc2_pointer;
|
||||||
ranks2[proc] = MPI_PROC_NULL;
|
int rank = ranks1[proc];
|
||||||
}
|
|
||||||
else {
|
if ( MPI_PROC_NULL == rank) {
|
||||||
proc1_pointer = ompi_group_peer_lookup(group1 ,rank);
|
ranks2[proc] = MPI_PROC_NULL;
|
||||||
/* initialize to no "match" */
|
continue;
|
||||||
ranks2[proc] = MPI_UNDEFINED;
|
|
||||||
for (proc2 = 0; proc2 < group2->grp_proc_count; proc2++) {
|
|
||||||
proc2_pointer= ompi_group_peer_lookup(group2, proc2);
|
|
||||||
if ( proc1_pointer == proc2_pointer) {
|
|
||||||
ranks2[proc] = proc2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} /* end proc2 loop */
|
|
||||||
} /* end proc loop */
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
proc1_pointer = ompi_group_get_proc_ptr_raw (group1, rank);
|
||||||
|
/* initialize to no "match" */
|
||||||
|
ranks2[proc] = MPI_UNDEFINED;
|
||||||
|
for (int proc2 = 0; proc2 < group2->grp_proc_count; ++proc2) {
|
||||||
|
proc2_pointer = ompi_group_get_proc_ptr_raw (group2, proc2);
|
||||||
|
if ( proc1_pointer == proc2_pointer) {
|
||||||
|
ranks2[proc] = proc2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} /* end proc2 loop */
|
||||||
|
} /* end proc loop */
|
||||||
|
|
||||||
return MPI_SUCCESS;
|
return MPI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -168,25 +173,6 @@ int ompi_group_dump (ompi_group_t* group)
|
|||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the function that iterates through the sparse groups to the dense group
|
|
||||||
* to reach the process pointer
|
|
||||||
*/
|
|
||||||
ompi_proc_t* ompi_group_get_proc_ptr (ompi_group_t* group , int rank)
|
|
||||||
{
|
|
||||||
int ranks1,ranks2;
|
|
||||||
do {
|
|
||||||
if(OMPI_GROUP_IS_DENSE(group)) {
|
|
||||||
return group->grp_proc_pointers[rank];
|
|
||||||
}
|
|
||||||
ranks1 = rank;
|
|
||||||
ompi_group_translate_ranks( group, 1, &ranks1,
|
|
||||||
group->grp_parent_group_ptr,&ranks2);
|
|
||||||
rank = ranks2;
|
|
||||||
group = group->grp_parent_group_ptr;
|
|
||||||
} while (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ompi_group_minloc ( int list[] , int length )
|
int ompi_group_minloc ( int list[] , int length )
|
||||||
{
|
{
|
||||||
int i,index,min;
|
int i,index,min;
|
||||||
|
@ -252,8 +252,6 @@ int ompi_group_free (ompi_group_t **group);
|
|||||||
/**
|
/**
|
||||||
* Functions to handle process pointers for sparse group formats
|
* Functions to handle process pointers for sparse group formats
|
||||||
*/
|
*/
|
||||||
OMPI_DECLSPEC ompi_proc_t* ompi_group_get_proc_ptr (ompi_group_t* group , int rank);
|
|
||||||
|
|
||||||
int ompi_group_translate_ranks_sporadic ( ompi_group_t *group1,
|
int ompi_group_translate_ranks_sporadic ( ompi_group_t *group1,
|
||||||
int n_ranks, const int *ranks1,
|
int n_ranks, const int *ranks1,
|
||||||
ompi_group_t *group2,
|
ompi_group_t *group2,
|
||||||
@ -324,49 +322,89 @@ int ompi_group_calc_bmap ( int n, int orig_size , const int *ranks );
|
|||||||
*/
|
*/
|
||||||
int ompi_group_minloc (int list[], int length);
|
int ompi_group_minloc (int list[], int length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Helper function for retreiving the proc of a group member in a dense group
|
||||||
|
*
|
||||||
|
* This function exists to handle the translation of sentinel group members to real
|
||||||
|
* ompi_proc_t's. If a sentinel value is found and allocate is true then this function
|
||||||
|
* looks for an existing ompi_proc_t using ompi_proc_for_name which will allocate a
|
||||||
|
* ompi_proc_t if one does not exist. If allocate is false then sentinel values translate
|
||||||
|
* to NULL.
|
||||||
|
*/
|
||||||
|
static inline struct ompi_proc_t *ompi_group_dense_lookup (ompi_group_t *group, const int peer_id, const bool allocate)
|
||||||
|
{
|
||||||
|
#if OPAL_ENABLE_DEBUG
|
||||||
|
if (peer_id >= group->grp_proc_count) {
|
||||||
|
opal_output(0, "ompi_group_dense_lookup: invalid peer index (%d)", peer_id);
|
||||||
|
return (struct ompi_proc_t *) NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (OPAL_UNLIKELY((intptr_t) group->grp_proc_pointers[peer_id] < 0)) {
|
||||||
|
if (!allocate) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* replace sentinel value with an actual ompi_proc_t */
|
||||||
|
group->grp_proc_pointers[peer_id] =
|
||||||
|
(ompi_proc_t *) ompi_proc_for_name (ompi_proc_sentinel_to_name ((intptr_t) group->grp_proc_pointers[peer_id]));
|
||||||
|
OBJ_RETAIN(group->grp_proc_pointers[peer_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return group->grp_proc_pointers[peer_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the function that iterates through the sparse groups to the dense group
|
||||||
|
* to reach the process pointer
|
||||||
|
*/
|
||||||
|
static inline ompi_proc_t *ompi_group_get_proc_ptr (ompi_group_t *group, int rank, const bool allocate)
|
||||||
|
{
|
||||||
|
#if OMPI_GROUP_SPARSE
|
||||||
|
do {
|
||||||
|
if (OMPI_GROUP_IS_DENSE(group)) {
|
||||||
|
return ompi_group_dense_lookup (group, peer_id, allocate);
|
||||||
|
}
|
||||||
|
int ranks1 = rank;
|
||||||
|
ompi_group_translate_ranks (group, 1, &ranks1, group->grp_parent_group_ptr, &rank);
|
||||||
|
group = group->grp_parent_group_ptr;
|
||||||
|
} while (1);
|
||||||
|
#else
|
||||||
|
return ompi_group_dense_lookup (group, rank, allocate);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the raw proc pointer from the group
|
||||||
|
*
|
||||||
|
* This function will either return a ompi_proc_t if one exists (either stored in the group
|
||||||
|
* or cached in the proc hash table) or a sentinel value representing the proc. This
|
||||||
|
* differs from ompi_group_get_proc_ptr() which returns the ompi_proc_t or NULL.
|
||||||
|
*/
|
||||||
|
ompi_proc_t *ompi_group_get_proc_ptr_raw (ompi_group_t *group, int rank);
|
||||||
|
|
||||||
|
static inline opal_process_name_t ompi_group_get_proc_name (ompi_group_t *group, int rank)
|
||||||
|
{
|
||||||
|
ompi_proc_t *proc = ompi_group_get_proc_ptr_raw (group, rank);
|
||||||
|
if ((intptr_t) proc < 0) {
|
||||||
|
return ompi_proc_sentinel_to_name ((intptr_t) proc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return proc->super.proc_name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inline function to check if sparse groups are enabled and return the direct access
|
* Inline function to check if sparse groups are enabled and return the direct access
|
||||||
* to the proc pointer, otherwise the lookup function
|
* to the proc pointer, otherwise the lookup function
|
||||||
*/
|
*/
|
||||||
static inline struct ompi_proc_t* ompi_group_peer_lookup(ompi_group_t *group, int peer_id)
|
static inline struct ompi_proc_t* ompi_group_peer_lookup(ompi_group_t *group, int peer_id)
|
||||||
{
|
{
|
||||||
#if OPAL_ENABLE_DEBUG
|
return ompi_group_get_proc_ptr (group, peer_id, true);
|
||||||
if (peer_id >= group->grp_proc_count) {
|
|
||||||
opal_output(0, "ompi_group_lookup_peer: invalid peer index (%d)", peer_id);
|
|
||||||
return (struct ompi_proc_t *) NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if OMPI_GROUP_SPARSE
|
|
||||||
return ompi_group_get_proc_ptr (group, peer_id);
|
|
||||||
#else
|
|
||||||
if (OPAL_UNLIKELY((intptr_t) group->grp_proc_pointers[peer_id] < 0)) {
|
|
||||||
intptr_t sentinel = -(intptr_t) group->grp_proc_pointers[peer_id];
|
|
||||||
/* replace sentinel value with an actual ompi_proc_t */
|
|
||||||
group->grp_proc_pointers[peer_id] =
|
|
||||||
(ompi_proc_t *) ompi_proc_for_name (*((opal_process_name_t *) &sentinel));
|
|
||||||
OBJ_RETAIN(group->grp_proc_pointers[peer_id]);
|
|
||||||
}
|
|
||||||
return group->grp_proc_pointers[peer_id];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct ompi_proc_t *ompi_group_peer_lookup_existing (ompi_group_t *group, int peer_id)
|
static inline struct ompi_proc_t *ompi_group_peer_lookup_existing (ompi_group_t *group, int peer_id)
|
||||||
{
|
{
|
||||||
#if OPAL_ENABLE_DEBUG
|
return ompi_group_get_proc_ptr (group, peer_id, false);
|
||||||
if (peer_id >= group->grp_proc_count) {
|
|
||||||
opal_output(0, "ompi_group_peer_lookup_existing: invalid peer index (%d)", peer_id);
|
|
||||||
return (struct ompi_proc_t *) NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if OMPI_GROUP_SPARSE
|
|
||||||
return ompi_group_get_proc_ptr (group, peer_id);
|
|
||||||
#else
|
|
||||||
if (OPAL_UNLIKELY((intptr_t) group->grp_proc_pointers[peer_id] < 0)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return group->grp_proc_pointers[peer_id];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ompi_group_have_remote_peers (ompi_group_t *group);
|
bool ompi_group_have_remote_peers (ompi_group_t *group);
|
||||||
|
@ -253,9 +253,6 @@ static void ompi_group_construct(ompi_group_t *new_group)
|
|||||||
|
|
||||||
/* default the sparse values for groups */
|
/* default the sparse values for groups */
|
||||||
new_group->grp_parent_group_ptr = NULL;
|
new_group->grp_parent_group_ptr = NULL;
|
||||||
|
|
||||||
/* return */
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -298,9 +295,6 @@ static void ompi_group_destruct(ompi_group_t *group)
|
|||||||
opal_pointer_array_set_item(&ompi_group_f_to_c_table,
|
opal_pointer_array_set_item(&ompi_group_f_to_c_table,
|
||||||
group->grp_f_to_c_index, NULL);
|
group->grp_f_to_c_index, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return */
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Copyright (c) 2006-2007 University of Houston. All rights reserved.
|
* Copyright (c) 2006-2007 University of Houston. All rights reserved.
|
||||||
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
|
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
|
||||||
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
|
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
@ -29,6 +29,38 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
static struct ompi_proc_t *ompi_group_dense_lookup_raw (ompi_group_t *group, const int peer_id)
|
||||||
|
{
|
||||||
|
if (OPAL_UNLIKELY((intptr_t) group->grp_proc_pointers[peer_id] < 0)) {
|
||||||
|
ompi_proc_t *proc =
|
||||||
|
(ompi_proc_t *) ompi_proc_lookup (ompi_proc_sentinel_to_name ((intptr_t) group->grp_proc_pointers[peer_id]));
|
||||||
|
if (NULL != proc) {
|
||||||
|
/* replace sentinel value with an actual ompi_proc_t */
|
||||||
|
group->grp_proc_pointers[peer_id] = proc;
|
||||||
|
/* retain the proc */
|
||||||
|
OBJ_RETAIN(group->grp_proc_pointers[peer_id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return group->grp_proc_pointers[peer_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
ompi_proc_t *ompi_group_get_proc_ptr_raw (ompi_group_t *group, int rank)
|
||||||
|
{
|
||||||
|
#if OMPI_GROUP_SPARSE
|
||||||
|
do {
|
||||||
|
if (OMPI_GROUP_IS_DENSE(group)) {
|
||||||
|
return ompi_group_dense_lookup_raw (group, peer_id);
|
||||||
|
}
|
||||||
|
int ranks1 = rank;
|
||||||
|
ompi_group_translate_ranks (group, 1, &ranks1, group->grp_parent_group_ptr, &rank);
|
||||||
|
group = group->grp_parent_group_ptr;
|
||||||
|
} while (1);
|
||||||
|
#else
|
||||||
|
return ompi_group_dense_lookup_raw (group, rank);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int ompi_group_calc_plist ( int n , const int *ranks ) {
|
int ompi_group_calc_plist ( int n , const int *ranks ) {
|
||||||
return sizeof(char *) * n ;
|
return sizeof(char *) * n ;
|
||||||
}
|
}
|
||||||
@ -37,7 +69,7 @@ int ompi_group_incl_plist(ompi_group_t* group, int n, const int *ranks,
|
|||||||
ompi_group_t **new_group)
|
ompi_group_t **new_group)
|
||||||
{
|
{
|
||||||
/* local variables */
|
/* local variables */
|
||||||
int proc,my_group_rank;
|
int my_group_rank;
|
||||||
ompi_group_t *group_pointer, *new_group_pointer;
|
ompi_group_t *group_pointer, *new_group_pointer;
|
||||||
ompi_proc_t *my_proc_pointer;
|
ompi_proc_t *my_proc_pointer;
|
||||||
|
|
||||||
@ -56,9 +88,9 @@ int ompi_group_incl_plist(ompi_group_t* group, int n, const int *ranks,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* put group elements in the list */
|
/* put group elements in the list */
|
||||||
for (proc = 0; proc < n; proc++) {
|
for (int proc = 0; proc < n; proc++) {
|
||||||
new_group_pointer->grp_proc_pointers[proc] =
|
new_group_pointer->grp_proc_pointers[proc] =
|
||||||
ompi_group_peer_lookup(group_pointer,ranks[proc]);
|
ompi_group_get_proc_ptr_raw (group_pointer, ranks[proc]);
|
||||||
} /* end proc loop */
|
} /* end proc loop */
|
||||||
|
|
||||||
/* increment proc reference counters */
|
/* increment proc reference counters */
|
||||||
@ -87,33 +119,30 @@ int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
|
|||||||
ompi_group_t **new_group)
|
ompi_group_t **new_group)
|
||||||
{
|
{
|
||||||
/* local variables */
|
/* local variables */
|
||||||
int new_group_size, proc1, proc2, found_in_group;
|
int new_group_size, my_group_rank, cnt;
|
||||||
int my_group_rank, cnt;
|
ompi_group_t *new_group_pointer;
|
||||||
ompi_group_t *group1_pointer, *group2_pointer, *new_group_pointer;
|
|
||||||
ompi_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer = NULL;
|
ompi_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer = NULL;
|
||||||
|
|
||||||
group1_pointer = (ompi_group_t *) group1;
|
|
||||||
group2_pointer = (ompi_group_t *) group2;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* form union
|
* form union
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* get new group size */
|
/* get new group size */
|
||||||
new_group_size = group1_pointer->grp_proc_count;
|
new_group_size = group1->grp_proc_count;
|
||||||
|
|
||||||
/* check group2 elements to see if they need to be included in the list */
|
/* check group2 elements to see if they need to be included in the list */
|
||||||
for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) {
|
for (int proc2 = 0; proc2 < group2->grp_proc_count; ++proc2) {
|
||||||
proc2_pointer = ompi_group_peer_lookup(group2_pointer,proc2);
|
bool found_in_group = false;
|
||||||
|
|
||||||
|
proc2_pointer = ompi_group_get_proc_ptr_raw (group2, proc2);
|
||||||
|
|
||||||
/* check to see if this proc2 is alread in the group */
|
/* check to see if this proc2 is alread in the group */
|
||||||
found_in_group = 0;
|
for (int proc1 = 0; proc1 < group1->grp_proc_count; ++proc1) {
|
||||||
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
|
proc1_pointer = ompi_group_get_proc_ptr_raw (group1, proc1);
|
||||||
proc1_pointer = ompi_group_peer_lookup(group1_pointer,proc1);
|
|
||||||
|
|
||||||
if (proc1_pointer == proc2_pointer) {
|
if (proc1_pointer == proc2_pointer) {
|
||||||
/* proc2 is in group1 - don't double count */
|
/* proc2 is in group1 - don't double count */
|
||||||
found_in_group = 1;
|
found_in_group = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} /* end proc1 loop */
|
} /* end proc1 loop */
|
||||||
@ -140,24 +169,25 @@ int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
|
|||||||
/* fill in the new group list */
|
/* fill in the new group list */
|
||||||
|
|
||||||
/* put group1 elements in the list */
|
/* put group1 elements in the list */
|
||||||
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
|
for (int proc1 = 0; proc1 < group1->grp_proc_count; ++proc1) {
|
||||||
new_group_pointer->grp_proc_pointers[proc1] =
|
new_group_pointer->grp_proc_pointers[proc1] =
|
||||||
ompi_group_peer_lookup(group1_pointer,proc1);
|
ompi_group_get_proc_ptr_raw (group1, proc1);
|
||||||
}
|
}
|
||||||
cnt = group1_pointer->grp_proc_count;
|
cnt = group1->grp_proc_count;
|
||||||
|
|
||||||
/* check group2 elements to see if they need to be included in the list */
|
/* check group2 elements to see if they need to be included in the list */
|
||||||
for (proc2 = 0; proc2 < group2_pointer->grp_proc_count; proc2++) {
|
for (int proc2 = 0; proc2 < group2->grp_proc_count; ++proc2) {
|
||||||
proc2_pointer = ompi_group_peer_lookup(group2_pointer,proc2);
|
bool found_in_group = false;
|
||||||
|
|
||||||
|
proc2_pointer = ompi_group_get_proc_ptr_raw (group2, proc2);
|
||||||
|
|
||||||
/* check to see if this proc2 is alread in the group */
|
/* check to see if this proc2 is alread in the group */
|
||||||
found_in_group = 0;
|
for (int proc1 = 0; proc1 < group1->grp_proc_count; ++proc1) {
|
||||||
for (proc1 = 0; proc1 < group1_pointer->grp_proc_count; proc1++) {
|
proc1_pointer = ompi_group_get_proc_ptr_raw (group1, proc1);
|
||||||
proc1_pointer = ompi_group_peer_lookup(group1_pointer,proc1);
|
|
||||||
|
|
||||||
if (proc1_pointer == proc2_pointer) {
|
if (proc1_pointer == proc2_pointer) {
|
||||||
/* proc2 is in group1 - don't double count */
|
/* proc2 is in group1 - don't double count */
|
||||||
found_in_group = 1;
|
found_in_group = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} /* end proc1 loop */
|
} /* end proc1 loop */
|
||||||
@ -166,23 +196,21 @@ int ompi_group_union (ompi_group_t* group1, ompi_group_t* group2,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_group_pointer->grp_proc_pointers[cnt] =
|
new_group_pointer->grp_proc_pointers[cnt++] = proc2_pointer;
|
||||||
ompi_group_peer_lookup(group2_pointer,proc2);
|
|
||||||
cnt++;
|
|
||||||
} /* end proc loop */
|
} /* end proc loop */
|
||||||
|
|
||||||
/* increment proc reference counters */
|
/* increment proc reference counters */
|
||||||
ompi_group_increment_proc_count(new_group_pointer);
|
ompi_group_increment_proc_count(new_group_pointer);
|
||||||
|
|
||||||
/* find my rank */
|
/* find my rank */
|
||||||
my_group_rank = group1_pointer->grp_my_rank;
|
my_group_rank = group1->grp_my_rank;
|
||||||
if (MPI_UNDEFINED == my_group_rank) {
|
if (MPI_UNDEFINED == my_group_rank) {
|
||||||
my_group_rank = group2_pointer->grp_my_rank;
|
my_group_rank = group2->grp_my_rank;
|
||||||
if ( MPI_UNDEFINED != my_group_rank) {
|
if ( MPI_UNDEFINED != my_group_rank) {
|
||||||
my_proc_pointer = ompi_group_peer_lookup(group2_pointer,my_group_rank);
|
my_proc_pointer = ompi_group_peer_lookup(group2,my_group_rank);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
my_proc_pointer = ompi_group_peer_lookup(group1_pointer,my_group_rank);
|
my_proc_pointer = ompi_group_peer_lookup(group1,my_group_rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( MPI_UNDEFINED == my_group_rank ) {
|
if ( MPI_UNDEFINED == my_group_rank ) {
|
||||||
@ -206,38 +234,29 @@ int ompi_group_difference(ompi_group_t* group1, ompi_group_t* group2,
|
|||||||
ompi_group_t **new_group) {
|
ompi_group_t **new_group) {
|
||||||
|
|
||||||
/* local varibles */
|
/* local varibles */
|
||||||
int new_group_size, proc1, proc2, found_in_group2, cnt;
|
int new_group_size, my_group_rank;
|
||||||
int my_group_rank;
|
ompi_group_t *new_group_pointer;
|
||||||
ompi_group_t *group1_pointer, *group2_pointer, *new_group_pointer;
|
|
||||||
ompi_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer = NULL;
|
ompi_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer = NULL;
|
||||||
|
|
||||||
|
|
||||||
group1_pointer=(ompi_group_t *)group1;
|
|
||||||
group2_pointer=(ompi_group_t *)group2;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* form union
|
* form union
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* get new group size */
|
/* get new group size */
|
||||||
new_group_size=0;
|
new_group_size = group1->grp_proc_count;
|
||||||
|
|
||||||
/* loop over group1 members */
|
/* loop over group1 members */
|
||||||
for( proc1=0; proc1 < group1_pointer->grp_proc_count; proc1++ ) {
|
for (int proc1 = 0 ; proc1 < group1->grp_proc_count ; ++proc1) {
|
||||||
proc1_pointer = ompi_group_peer_lookup(group1_pointer,proc1);
|
proc1_pointer = ompi_group_get_proc_ptr_raw (group1, proc1);
|
||||||
|
|
||||||
/* check to see if this proc is in group2 */
|
/* check to see if this proc is in group2 */
|
||||||
found_in_group2=0;
|
for (int proc2 = 0 ; proc2 < group2->grp_proc_count ; ++proc2) {
|
||||||
for( proc2=0 ; proc2 < group2_pointer->grp_proc_count ; proc2++ ) {
|
proc2_pointer = ompi_group_get_proc_ptr_raw (group2, proc2);
|
||||||
proc2_pointer = ompi_group_peer_lookup(group2_pointer,proc2);
|
|
||||||
if( proc1_pointer == proc2_pointer ) {
|
if( proc1_pointer == proc2_pointer ) {
|
||||||
found_in_group2=true;
|
--new_group_size;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} /* end proc1 loop */
|
} /* end proc1 loop */
|
||||||
if(found_in_group2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
new_group_size++;
|
|
||||||
} /* end proc loop */
|
} /* end proc loop */
|
||||||
|
|
||||||
if ( 0 == new_group_size ) {
|
if ( 0 == new_group_size ) {
|
||||||
@ -253,41 +272,39 @@ int ompi_group_difference(ompi_group_t* group1, ompi_group_t* group2,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* fill in group list */
|
/* fill in group list */
|
||||||
cnt=0;
|
|
||||||
/* loop over group1 members */
|
/* loop over group1 members */
|
||||||
for( proc1=0; proc1 < group1_pointer->grp_proc_count; proc1++ ) {
|
for (int proc1 = 0, cnt = 0 ; proc1 < group1->grp_proc_count ; ++proc1) {
|
||||||
proc1_pointer = ompi_group_peer_lookup(group1_pointer,proc1);
|
bool found_in_group2 = false;
|
||||||
|
|
||||||
|
proc1_pointer = ompi_group_get_proc_ptr_raw (group1, proc1);
|
||||||
/* check to see if this proc is in group2 */
|
/* check to see if this proc is in group2 */
|
||||||
found_in_group2=0;
|
for (int proc2 = 0 ; proc2 < group2->grp_proc_count ; ++proc2) {
|
||||||
for( proc2=0 ; proc2 < group2_pointer->grp_proc_count ; proc2++ ) {
|
proc2_pointer = ompi_group_get_proc_ptr_raw (group2, proc2);
|
||||||
proc2_pointer = ompi_group_peer_lookup(group2_pointer,proc2);
|
|
||||||
if( proc1_pointer == proc2_pointer ) {
|
if( proc1_pointer == proc2_pointer ) {
|
||||||
found_in_group2=true;
|
found_in_group2 = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} /* end proc1 loop */
|
} /* end proc1 loop */
|
||||||
if(found_in_group2) {
|
|
||||||
|
if (found_in_group2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_group_pointer->grp_proc_pointers[cnt] =
|
new_group_pointer->grp_proc_pointers[cnt++] = proc1_pointer;
|
||||||
ompi_group_peer_lookup(group1_pointer,proc1);
|
|
||||||
|
|
||||||
cnt++;
|
|
||||||
} /* end proc loop */
|
} /* end proc loop */
|
||||||
|
|
||||||
/* increment proc reference counters */
|
/* increment proc reference counters */
|
||||||
ompi_group_increment_proc_count(new_group_pointer);
|
ompi_group_increment_proc_count(new_group_pointer);
|
||||||
|
|
||||||
/* find my rank */
|
/* find my rank */
|
||||||
my_group_rank=group1_pointer->grp_my_rank;
|
my_group_rank=group1->grp_my_rank;
|
||||||
if ( MPI_UNDEFINED != my_group_rank ) {
|
if ( MPI_UNDEFINED != my_group_rank ) {
|
||||||
my_proc_pointer = ompi_group_peer_lookup(group1_pointer,my_group_rank);
|
my_proc_pointer = ompi_group_peer_lookup(group1,my_group_rank);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my_group_rank=group2_pointer->grp_my_rank;
|
my_group_rank=group2->grp_my_rank;
|
||||||
if ( MPI_UNDEFINED != my_group_rank ) {
|
if ( MPI_UNDEFINED != my_group_rank ) {
|
||||||
my_proc_pointer = ompi_group_peer_lookup(group2_pointer,my_group_rank);
|
my_proc_pointer = ompi_group_peer_lookup(group2,my_group_rank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ ompi_osc_portals4_get_peer(ompi_osc_portals4_module_t *module, int rank)
|
|||||||
static inline ptl_process_t
|
static inline ptl_process_t
|
||||||
ompi_osc_portals4_get_peer_group(struct ompi_group_t *group, int rank)
|
ompi_osc_portals4_get_peer_group(struct ompi_group_t *group, int rank)
|
||||||
{
|
{
|
||||||
ompi_proc_t *proc = ompi_group_get_proc_ptr(group, rank);
|
ompi_proc_t *proc = ompi_group_get_proc_ptr(group, rank, true);
|
||||||
return *((ptl_process_t*) proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_PORTALS4]);
|
return *((ptl_process_t*) proc->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_PORTALS4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +324,16 @@ OMPI_DECLSPEC opal_proc_t *ompi_proc_for_name (const opal_process_name_t proc_na
|
|||||||
|
|
||||||
OMPI_DECLSPEC opal_proc_t *ompi_proc_lookup (const opal_process_name_t proc_name);
|
OMPI_DECLSPEC opal_proc_t *ompi_proc_lookup (const opal_process_name_t proc_name);
|
||||||
|
|
||||||
|
|
||||||
|
static inline intptr_t ompi_proc_name_to_sentinel (opal_process_name_t name) {
|
||||||
|
return -*((intptr_t *) &name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline opal_process_name_t ompi_proc_sentinel_to_name (intptr_t sentinel) {
|
||||||
|
sentinel = -sentinel;
|
||||||
|
return *((opal_process_name_t *) &sentinel);
|
||||||
|
}
|
||||||
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
||||||
#endif /* OMPI_PROC_PROC_H */
|
#endif /* OMPI_PROC_PROC_H */
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||||
* University Research and Technology
|
* University Research and Technology
|
||||||
@ -13,6 +14,8 @@
|
|||||||
* Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved.
|
* Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved.
|
||||||
* Copyright (c) 2014 Research Organization for Information Science
|
* Copyright (c) 2014 Research Organization for Information Science
|
||||||
* and Technology (RIST). All rights reserved.
|
* and Technology (RIST). All rights reserved.
|
||||||
|
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
|
||||||
|
* reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -88,7 +91,7 @@ static void try_kill_peers(ompi_communicator_t *comm,
|
|||||||
} else {
|
} else {
|
||||||
assert(count <= nprocs);
|
assert(count <= nprocs);
|
||||||
procs[count++] =
|
procs[count++] =
|
||||||
*OMPI_CAST_RTE_NAME(&ompi_group_get_proc_ptr(comm->c_remote_group, i)->super.proc_name);
|
*OMPI_CAST_RTE_NAME(&ompi_group_get_proc_ptr(comm->c_remote_group, i, true)->super.proc_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +99,7 @@ static void try_kill_peers(ompi_communicator_t *comm,
|
|||||||
for (i = 0; i < ompi_comm_remote_size(comm); ++i) {
|
for (i = 0; i < ompi_comm_remote_size(comm); ++i) {
|
||||||
assert(count <= nprocs);
|
assert(count <= nprocs);
|
||||||
procs[count++] =
|
procs[count++] =
|
||||||
*OMPI_CAST_RTE_NAME(&ompi_group_get_proc_ptr(comm->c_remote_group, i)->super.proc_name);
|
*OMPI_CAST_RTE_NAME(&ompi_group_get_proc_ptr(comm->c_remote_group, i, true)->super.proc_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nprocs > 0) {
|
if (nprocs > 0) {
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user