1
1

add error checking. Fix reference counts for procs in new groups.

remove special treatment for creating new empty groups (i.e. they
are no longer mapped to group_empty.  Implement group_free.

This commit was SVN r856.
Этот коммит содержится в:
Rich Graham 2004-03-15 22:14:08 +00:00
родитель abfa077cea
Коммит a7dc6bc338
8 изменённых файлов: 103 добавлений и 39 удалений

Просмотреть файл

@ -50,6 +50,11 @@ extern lam_pointer_array_t *lam_group_f_to_c_table;
*/
lam_group_t *group_allocate(int group_size);
/*
* increment the reference count of the proc structures
*/
void lam_group_increment_proc_count(lam_group_t *group);
/**
* Initialize LAM group infrastructure
*

Просмотреть файл

@ -58,37 +58,58 @@ lam_group_t *group_allocate(int group_size)
/* create new group group element */
new_group=OBJ_NEW(lam_group_t);
if( -1 == new_group->grp_f_to_c_index){
OBJ_RELEASE(new_group);
new_group=NULL;
}
if( new_group ) {
/* allocate array of (lam_proc_t *)'s, one for each
* process in the group */
new_group->grp_proc_pointers=
malloc(sizeof(lam_proc_t *)*group_size);
if( new_group->grp_proc_pointers ) {
/* grp_proc_pointers allocated */
new_group->grp_proc_count=group_size;
/* assign entry in fortran <-> c translation array */
ret_val=lam_pointer_array_add(lam_group_f_to_c_table,new_group);
if( -1 == ret_val ){
OBJ_RELEASE(new_group);
if( 0 < group_size ) {
/* non-empty group */
if( !new_group->grp_proc_pointers ) {
/* grp_proc_pointers allocation failed */
free(new_group);
new_group=NULL;
}
new_group->grp_f_to_c_index=ret_val;
} else {
/* grp_proc_pointers allocation failed */
free(new_group);
new_group=NULL;
}
/* set the group size */
new_group->grp_proc_count=group_size;
}
/* return */
return new_group;
}
/*
* increment the reference count of the proc structures
*/
void lam_group_increment_proc_count(lam_group_t *group) {
/* local variable */
int proc;
for(proc=0 ; proc < group->grp_proc_count ; proc++ ) {
OBJ_RETAIN(group->grp_proc_pointers[proc]);
}
/* return */
return;
}
/**
* group constructor
*/
void lam_group_construct(lam_group_t *new_group){
void lam_group_construct(lam_group_t *new_group)
{
int ret_val;
/* assign entry in fortran <-> c translation array */
ret_val=lam_pointer_array_add(lam_group_f_to_c_table,new_group);
new_group->grp_f_to_c_index=ret_val;
/* return */
return;
@ -97,8 +118,8 @@ void lam_group_construct(lam_group_t *new_group){
/**
* group destructor
*/
void lam_group_destruct(lam_group_t *group){
void lam_group_destruct(lam_group_t *group)
{
/* release thegrp_proc_pointers memory */
if( NULL != group->grp_proc_pointers )
free(group->grp_proc_pointers);
@ -123,6 +144,7 @@ int lam_group_init(void)
{
/* local variables */
int return_value,ret_val;
lam_group_t *new_group_pointer;
return_value=LAM_SUCCESS;
@ -154,8 +176,6 @@ int lam_group_init(void)
};
lam_mpi_group_empty.grp_f_to_c_index=ret_val;
/* contruct group for MPI_COMM_WORLD */
/* return */
return return_value;
}

Просмотреть файл

@ -19,9 +19,17 @@ int MPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result) {
lam_group_t *group1_pointer, *group2_pointer;
lam_proc_t *proc1_pointer, *proc2_pointer;
/* initialization */
return_value=MPI_SUCCESS;
/* check for errors */
if( MPI_PARAM_CHECK ) {
if( ( MPI_GROUP_NULL == group1 ) || ( MPI_GROUP_NULL == group2 ) ){
return MPI_ERR_GROUP;
}
}
/* check for same groups */
if( group1 == group2 ) {
*result=MPI_IDENT;
@ -29,8 +37,7 @@ int MPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result) {
}
/* check to see if either is MPI_GROUP_NULL or MPI_GROUP_EMPTY */
if( ( MPI_GROUP_NULL == group1 ) || ( MPI_GROUP_EMPTY == group1 ) ||
( MPI_GROUP_NULL == group2 ) || ( MPI_GROUP_EMPTY == group2 ) ) {
if( ( MPI_GROUP_EMPTY == group1 ) || ( MPI_GROUP_EMPTY == group2 ) ) {
*result=MPI_UNEQUAL;
return return_value;
}

Просмотреть файл

@ -6,11 +6,32 @@
#include "mpi.h"
#include "mpi/interface/c/bindings.h"
#include "mpi/group/group.h"
#if LAM_HAVE_WEAK_SYMBOLS && LAM_PROFILING_DEFINES
#pragma weak MPI_Group_free = PMPI_Group_free
#endif
int MPI_Group_free(MPI_Group *group) {
int MPI_Group_free(MPI_Group *group)
{
/* local variables */
int proc;
lam_group_t *l_group;
/* check to make sure we don't free GROUP_EMPTY or GROUP_NULL */
if( MPI_PARAM_CHECK ) {
if( (MPI_GROUP_NULL == group) || (MPI_GROUP_EMPTY == group ) ) {
return MPI_ERR_GROUP;
}
}
l_group=(lam_group_t *)group;
/* decrement proc reference count */
for(proc=0 ; proc < l_group->grp_proc_count ; proc++ ) {
OBJ_RELEASE(l_group->grp_proc_pointers[proc]);
}
OBJ_RELEASE(group);
return MPI_SUCCESS;
}

Просмотреть файл

@ -13,6 +13,15 @@
#endif
int MPI_Group_rank(MPI_Group group, int *rank) {
/* error checking */
if( MPI_PARAM_CHECK ) {
if( MPI_GROUP_NULL == group ){
return MPI_ERR_GROUP;
}
}
*rank=lam_group_rank((lam_group_t *)group);
return MPI_SUCCESS;
}

Просмотреть файл

@ -13,6 +13,14 @@
#endif
int MPI_Group_size(MPI_Group group, int *size) {
/* error checking */
if( MPI_PARAM_CHECK ) {
if( MPI_GROUP_NULL == group ) {
return MPI_ERR_GROUP;
}
}
*size=lam_group_size((lam_group_t *)group);
return MPI_SUCCESS;
}

Просмотреть файл

@ -24,10 +24,12 @@ int MPI_Group_translate_ranks(MPI_Group group1, int n_ranks, int *ranks1,
/* check for errors */
if( MPI_PARAM_CHECK ) {
if( (MPI_GROUP_NULL == group1) || (MPI_GROUP_NULL == group2 ) ) {
return MPI_ERR_GROUP;
}
if( n_ranks > group1_pointer->grp_proc_count ){
return MPI_ERR_GROUP;
}
}
/* loop over all ranks */

Просмотреть файл

@ -20,28 +20,17 @@ int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *new_group)
lam_group_t *group1_pointer, *group2_pointer, *new_group_pointer;
lam_proc_t *proc1_pointer, *proc2_pointer, *my_proc_pointer;
/* check for errors */
if( MPI_PARAM_CHECK ) {
if( ( MPI_GROUP_NULL == group1 ) || ( MPI_GROUP_NULL == group2 ) ){
return MPI_ERR_GROUP;
}
}
return_value=MPI_SUCCESS;
group1_pointer= (lam_group_t *) group1;
group2_pointer= (lam_group_t *) group2;
/* check to see if one of the groups is the empty group */
if ((MPI_GROUP_EMPTY == group1) && (MPI_GROUP_EMPTY == group2)) {
/* both group1 and group2 are MPI_GROUP_EMPTY */
*new_group = MPI_GROUP_EMPTY;
return return_value;
} else if ( MPI_GROUP_EMPTY == group1 ) {
/* group1 is MPI_GROUP_EMPTY */
*new_group = group2;
/* increment group count */
OBJ_RETAIN(group2_pointer);
return return_value;
} else if ( MPI_GROUP_EMPTY == group2 ) {
/* group2 is MPI_GROUP_EMPTY */
*new_group = group1;
/* increment group count */
OBJ_RETAIN(group1_pointer);
return return_value;
}
/*
* form union
*/
@ -108,6 +97,9 @@ int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *new_group)
cnt++;
} /* end proc loop */
/* increment proc reference counters */
lam_group_increment_proc_count(new_group_pointer);
/* find my rank */
my_group_rank=group1_pointer->grp_my_rank;
my_proc_pointer=group1_pointer->grp_proc_pointers[my_group_rank];