Cleaning up lam_group_t documentation.
This commit was SVN r1031.
Этот коммит содержится в:
родитель
6bc049829b
Коммит
4c11dc57fe
@ -2,6 +2,12 @@
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file:
|
||||
*
|
||||
* Infrastructure for MPI group support.
|
||||
*/
|
||||
|
||||
#ifndef LAM_GROUP_H
|
||||
#define LAM_GROUP_H
|
||||
|
||||
@ -9,40 +15,41 @@
|
||||
#include "proc/proc.h"
|
||||
#include "lfc/lam_pointer_array.h"
|
||||
|
||||
/* This must correspond to the fortran MPI_GROUP_NULL index */
|
||||
/** This must correspond to the fortran MPI_GROUP_NULL index */
|
||||
#define LAM_GROUP_NULL_FORTRAN 0
|
||||
|
||||
/* This must correspond to the fortran MPI_GROUP_EMPTY index */
|
||||
/** This must correspond to the fortran MPI_GROUP_EMPTY index */
|
||||
#define LAM_GROUP_EMPTY_FORTRAN 1
|
||||
|
||||
extern lam_class_t lam_group_t_class;
|
||||
|
||||
/**
|
||||
* Group structure
|
||||
*/
|
||||
struct lam_group_t {
|
||||
/* base class */
|
||||
lam_object_t super;
|
||||
/* number of processes in group */
|
||||
int grp_proc_count;
|
||||
/* rank in group */
|
||||
int grp_my_rank;
|
||||
/* index in Fortran <-> C translation array */
|
||||
int grp_f_to_c_index;
|
||||
/* list of pointers to lam_proc_t structures for each
|
||||
* process in the group */
|
||||
lam_object_t super; /**< base class */
|
||||
int grp_proc_count; /**< number of processes in group */
|
||||
int grp_my_rank; /**< rank in group */
|
||||
int grp_f_to_c_index; /**< index in Fortran <-> C translation array */
|
||||
lam_proc_t **grp_proc_pointers;
|
||||
/**< list of pointers to lam_proc_t structures
|
||||
for each process in the group */
|
||||
};
|
||||
typedef struct lam_group_t lam_group_t;
|
||||
OBJ_CLASS_DECLARATION(lam_group_t);
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* Table for Fortran <-> C group handle conversion
|
||||
*/
|
||||
extern lam_pointer_array_t *lam_group_f_to_c_table;
|
||||
|
||||
/*
|
||||
* function prototypes
|
||||
|
||||
/*
|
||||
* function prototypes
|
||||
*/
|
||||
|
||||
/**
|
||||
* This routine is used to allocate a new group structure
|
||||
* Allocate a new group structure.
|
||||
*
|
||||
* @param group_size Number of MPI processes in the group
|
||||
*
|
||||
@ -50,36 +57,45 @@ extern lam_pointer_array_t *lam_group_f_to_c_table;
|
||||
*/
|
||||
lam_group_t *lam_group_allocate(int group_size);
|
||||
|
||||
/*
|
||||
* increment the reference count of the proc structures
|
||||
|
||||
/**
|
||||
* Increment the reference count of the proc structures.
|
||||
*
|
||||
* @param group Pointer to lam_group_t structute (IN)
|
||||
*
|
||||
*/
|
||||
void lam_group_increment_proc_count(lam_group_t *group);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize LAM group infrastructure
|
||||
* Initialize LAM group infrastructure.
|
||||
*
|
||||
* @return Error code
|
||||
*/
|
||||
int lam_group_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* Clean up LAM group infrastructure
|
||||
* Clean up LAM group infrastructure.
|
||||
*
|
||||
* @return Error code
|
||||
*/
|
||||
int lam_group_finalize(void);
|
||||
|
||||
|
||||
/**
|
||||
* Get group size
|
||||
* Get group size.
|
||||
*
|
||||
* @param group Pointer to lam_group_t structute (IN)
|
||||
*
|
||||
* @return Group size
|
||||
*/
|
||||
static inline int lam_group_size(lam_group_t *group){
|
||||
static inline int lam_group_size(lam_group_t *group)
|
||||
{
|
||||
return group->grp_proc_count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get group rank
|
||||
*
|
||||
@ -87,10 +103,12 @@ static inline int lam_group_size(lam_group_t *group){
|
||||
*
|
||||
* @return Group rank
|
||||
*/
|
||||
static inline int lam_group_rank(lam_group_t *group){
|
||||
static inline int lam_group_rank(lam_group_t *group)
|
||||
{
|
||||
return group->grp_proc_count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set group rank in the input group structure
|
||||
*
|
||||
|
@ -10,12 +10,10 @@
|
||||
static void lam_group_construct(lam_group_t *);
|
||||
static void lam_group_destruct(lam_group_t *);
|
||||
|
||||
lam_class_t lam_group_t_class = {
|
||||
"lam_group_t",
|
||||
OBJ_CLASS(lam_object_t),
|
||||
(lam_construct_t) lam_group_construct,
|
||||
(lam_destruct_t) lam_group_destruct
|
||||
};
|
||||
OBJ_CLASS_INSTANCE(lam_group_t,
|
||||
lam_object_t,
|
||||
lam_group_construct,
|
||||
lam_group_destruct);
|
||||
|
||||
/*
|
||||
* Table for Fortran <-> C group handle conversion
|
||||
@ -26,29 +24,28 @@ lam_pointer_array_t *lam_group_f_to_c_table;
|
||||
* MPI_GROUP_EMPTY
|
||||
*/
|
||||
lam_group_t lam_mpi_group_empty = {
|
||||
{ NULL, 0 }, /* base class */
|
||||
0, /* number of processes in group */
|
||||
MPI_PROC_NULL, /* rank in group */
|
||||
LAM_ERROR, /* index in Fortran <-> C translation array */
|
||||
(lam_proc_t **)NULL /* pointers to lam_proc_t structures */
|
||||
{ NULL, 0 }, /* base class */
|
||||
0, /* number of processes in group */
|
||||
MPI_PROC_NULL, /* rank in group */
|
||||
LAM_ERROR, /* index in Fortran <-> C translation array */
|
||||
(lam_proc_t **)NULL /* pointers to lam_proc_t structures */
|
||||
};
|
||||
|
||||
/*
|
||||
* MPI_GROUP_NULL - defining this group makes it much easier to
|
||||
* handle this group with out special case code
|
||||
* MPI_GROUP_NULL - defining this group makes it much easier to handle
|
||||
* this group with out special case code
|
||||
*/
|
||||
lam_group_t lam_mpi_group_null = {
|
||||
{ NULL, 0 }, /* base class */
|
||||
0, /* number of processes in group */
|
||||
MPI_PROC_NULL, /* rank in group */
|
||||
LAM_ERROR, /* index in Fortran <-> C translation array */
|
||||
(lam_proc_t **)NULL /* pointers to lam_proc_t structures */
|
||||
{ NULL, 0 }, /* base class */
|
||||
0, /* number of processes in group */
|
||||
MPI_PROC_NULL, /* rank in group */
|
||||
LAM_ERROR, /* index in Fortran <-> C translation array */
|
||||
(lam_proc_t **)NULL /* pointers to lam_proc_t structures */
|
||||
};
|
||||
|
||||
/**
|
||||
* This routine is used to allocate a new group structure
|
||||
*
|
||||
* @return Pointer to new group structure
|
||||
|
||||
/*
|
||||
* Allocate a new group structure
|
||||
*/
|
||||
lam_group_t *lam_group_allocate(int group_size)
|
||||
{
|
||||
@ -56,27 +53,27 @@ lam_group_t *lam_group_allocate(int group_size)
|
||||
lam_group_t *new_group;
|
||||
|
||||
/* create new group group element */
|
||||
new_group=OBJ_NEW(lam_group_t);
|
||||
if( new_group ) {
|
||||
if( LAM_ERROR == new_group->grp_f_to_c_index){
|
||||
new_group = OBJ_NEW(lam_group_t);
|
||||
if (new_group) {
|
||||
if (LAM_ERROR == new_group->grp_f_to_c_index) {
|
||||
OBJ_RELEASE(new_group);
|
||||
new_group=NULL;
|
||||
new_group = NULL;
|
||||
} else {
|
||||
/* 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( 0 < group_size ) {
|
||||
new_group->grp_proc_pointers =
|
||||
malloc(sizeof(lam_proc_t *) * group_size);
|
||||
if (0 < group_size) {
|
||||
/* non-empty group */
|
||||
if( !new_group->grp_proc_pointers ) {
|
||||
/* grp_proc_pointers allocation failed */
|
||||
free(new_group);
|
||||
new_group=NULL;
|
||||
}
|
||||
if (!new_group->grp_proc_pointers) {
|
||||
/* grp_proc_pointers allocation failed */
|
||||
free(new_group);
|
||||
new_group = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the group size */
|
||||
new_group->grp_proc_count=group_size;
|
||||
new_group->grp_proc_count = group_size;
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,14 +81,16 @@ lam_group_t *lam_group_allocate(int group_size)
|
||||
return new_group;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* increment the reference count of the proc structures
|
||||
*/
|
||||
void lam_group_increment_proc_count(lam_group_t *group) {
|
||||
void lam_group_increment_proc_count(lam_group_t *group)
|
||||
{
|
||||
/* local variable */
|
||||
int proc;
|
||||
|
||||
for(proc=0 ; proc < group->grp_proc_count ; proc++ ) {
|
||||
for (proc = 0; proc < group->grp_proc_count; proc++) {
|
||||
OBJ_RETAIN(group->grp_proc_pointers[proc]);
|
||||
}
|
||||
|
||||
@ -99,7 +98,8 @@ void lam_group_increment_proc_count(lam_group_t *group) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/*
|
||||
* group constructor
|
||||
*/
|
||||
static void lam_group_construct(lam_group_t *new_group)
|
||||
@ -107,83 +107,89 @@ static 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;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/*
|
||||
* group destructor
|
||||
*/
|
||||
static void lam_group_destruct(lam_group_t *group)
|
||||
{
|
||||
/* release thegrp_proc_pointers memory */
|
||||
if( NULL != group->grp_proc_pointers )
|
||||
if (NULL != group->grp_proc_pointers)
|
||||
free(group->grp_proc_pointers);
|
||||
|
||||
/* reset the lam_group_f_to_c_table entry - make sure that the
|
||||
* entry is in the table */
|
||||
if( NULL!= lam_pointer_array_get_item(lam_group_f_to_c_table,
|
||||
group->grp_f_to_c_index) ) {
|
||||
if (NULL != lam_pointer_array_get_item(lam_group_f_to_c_table,
|
||||
group->grp_f_to_c_index)) {
|
||||
lam_pointer_array_set_item(lam_group_f_to_c_table,
|
||||
group->grp_f_to_c_index, NULL);
|
||||
group->grp_f_to_c_index, NULL);
|
||||
}
|
||||
|
||||
/* return */
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/*
|
||||
* Initialize LAM group infrastructure
|
||||
*/
|
||||
|
||||
int lam_group_init(void)
|
||||
{
|
||||
/* local variables */
|
||||
int return_value,ret_val;
|
||||
int return_value, ret_val;
|
||||
|
||||
return_value=LAM_SUCCESS;
|
||||
return_value = LAM_SUCCESS;
|
||||
|
||||
/* initialize lam_group_f_to_c_table */
|
||||
lam_group_f_to_c_table=OBJ_NEW(lam_pointer_array_t);
|
||||
if( NULL == lam_group_f_to_c_table ){
|
||||
lam_group_f_to_c_table = OBJ_NEW(lam_pointer_array_t);
|
||||
if (NULL == lam_group_f_to_c_table) {
|
||||
return LAM_ERROR;
|
||||
}
|
||||
|
||||
/* add MPI_GROUP_NULL to table */
|
||||
ret_val=lam_pointer_array_add(lam_group_f_to_c_table,&lam_mpi_group_null);
|
||||
if( LAM_ERROR == ret_val ){
|
||||
ret_val =
|
||||
lam_pointer_array_add(lam_group_f_to_c_table, &lam_mpi_group_null);
|
||||
if (LAM_ERROR == ret_val) {
|
||||
return LAM_ERROR;
|
||||
};
|
||||
/* make sure that MPI_GROUP_NULL is in location in the table */
|
||||
if( LAM_GROUP_NULL_FORTRAN != ret_val ){
|
||||
if (LAM_GROUP_NULL_FORTRAN != ret_val) {
|
||||
return LAM_ERROR;
|
||||
};
|
||||
lam_mpi_group_null.grp_f_to_c_index=ret_val;
|
||||
lam_mpi_group_null.grp_f_to_c_index = ret_val;
|
||||
|
||||
/* add MPI_GROUP_EMPTY to table */
|
||||
ret_val=lam_pointer_array_add(lam_group_f_to_c_table,&lam_mpi_group_empty);
|
||||
if( LAM_ERROR == ret_val ){
|
||||
ret_val =
|
||||
lam_pointer_array_add(lam_group_f_to_c_table,
|
||||
&lam_mpi_group_empty);
|
||||
if (LAM_ERROR == ret_val) {
|
||||
return LAM_ERROR;
|
||||
};
|
||||
/* make sure that MPI_GROUP_NULL is in location in the table */
|
||||
if( LAM_GROUP_EMPTY_FORTRAN != ret_val ){
|
||||
if (LAM_GROUP_EMPTY_FORTRAN != ret_val) {
|
||||
return LAM_ERROR;
|
||||
};
|
||||
lam_mpi_group_empty.grp_f_to_c_index=ret_val;
|
||||
lam_mpi_group_empty.grp_f_to_c_index = ret_val;
|
||||
|
||||
/* return */
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/*
|
||||
* Clean up group infrastructure
|
||||
*/
|
||||
int lam_group_finalize(void){
|
||||
int lam_group_finalize(void)
|
||||
{
|
||||
/* local variables */
|
||||
int return_value=LAM_SUCCESS;
|
||||
int return_value = LAM_SUCCESS;
|
||||
|
||||
/* remove group for MPI_COMM_WORLD */
|
||||
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include "group/group.h"
|
||||
#include "include/constants.h"
|
||||
|
||||
/*
|
||||
* Set group rank in a group structure.
|
||||
*/
|
||||
void lam_set_group_rank(lam_group_t *group, lam_proc_t *proc_pointer)
|
||||
{
|
||||
/* local variables */
|
||||
@ -14,15 +17,15 @@ void lam_set_group_rank(lam_group_t *group, lam_proc_t *proc_pointer)
|
||||
* in this group
|
||||
*/
|
||||
group->grp_my_rank = MPI_PROC_NULL;
|
||||
if( NULL != proc_pointer ) {
|
||||
if (NULL != proc_pointer) {
|
||||
/* loop over all procs in the group */
|
||||
for ( proc=0 ; proc < group->grp_proc_count ; proc++ ){
|
||||
for (proc = 0; proc < group->grp_proc_count; proc++) {
|
||||
/* check and see if this proc pointer matches proc_pointer
|
||||
*/
|
||||
if( group->grp_proc_pointers[proc] == proc_pointer ) {
|
||||
if (group->grp_proc_pointers[proc] == proc_pointer) {
|
||||
group->grp_my_rank = proc;
|
||||
}
|
||||
} /* end proc loop */
|
||||
} /* end proc loop */
|
||||
}
|
||||
|
||||
/* return */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user