adding the *homogeneous* version of the functions which we discussed
here yesterday. Heterogeneous version will require the datatype engine to work heterogeneously ... This commit was SVN r1869.
Этот коммит содержится в:
родитель
fe9f18c03b
Коммит
0b1fc511be
108
src/proc/proc.c
108
src/proc/proc.c
@ -162,3 +162,111 @@ ompi_proc_t * ompi_proc_find ( const ompi_process_name_t * name )
|
|||||||
return proc;
|
return proc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The functions in this chapter are at the moment purely for
|
||||||
|
** homogeneous environments. Support for heterogeneous environments
|
||||||
|
** to follow as soon as the datatype engine supports heterogeneous envs.
|
||||||
|
** I just wanted to avoid duplicating data conversion code here...
|
||||||
|
*/
|
||||||
|
int ompi_proc_get_namebuf_by_proc ( ompi_proc_t **proclist, int proclistsize,
|
||||||
|
char **namebuf, size_t *namebuflen )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
ompi_process_name_t *nbuf=NULL;
|
||||||
|
|
||||||
|
nbuf = ( ompi_process_name_t *) calloc (proclistsize, sizeof(ompi_process_name_t));
|
||||||
|
if ( NULL == nbuf ) {
|
||||||
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
OMPI_THREAD_LOCK(&ompi_proc_lock);
|
||||||
|
for (i=0; i<proclistsize; i++) {
|
||||||
|
nbuf[i] = proclist[i]->proc_name;
|
||||||
|
}
|
||||||
|
OMPI_THREAD_UNLOCK(&ompi_proc_lock);
|
||||||
|
|
||||||
|
*namebuf = (char *)nbuf;
|
||||||
|
*namebuflen = (proclistsize * sizeof(ompi_process_name_t));
|
||||||
|
|
||||||
|
return OMPI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ompi_proc_namebuf_returnbuf ( char *namebuf )
|
||||||
|
{
|
||||||
|
if ( NULL != namebuf ) {
|
||||||
|
free (namebuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OMPI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ompi_proc_get_proclist (char *namebuf, size_t namebuflen,
|
||||||
|
int proclistsize, ompi_proc_t ***proclist)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
ompi_proc_t **plist=NULL;
|
||||||
|
ompi_process_name_t *nlist= (ompi_process_name_t *) namebuf;
|
||||||
|
|
||||||
|
plist = (ompi_proc_t **) calloc ( proclistsize, sizeof (ompi_proc_t *));
|
||||||
|
if ( NULL == plist ) {
|
||||||
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i=0; i<proclistsize; i++ ){
|
||||||
|
plist[i] = ompi_proc_find ( &(nlist[i]));
|
||||||
|
if ( NULL == plist[i] ) {
|
||||||
|
/* to do: look the process information for this name up */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*proclist = plist;
|
||||||
|
return OMPI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* These two functions are at the moment trivial */
|
||||||
|
int ompi_proc_get_namebuf_by_name ( ompi_process_name_t **namelist, int namelistsize,
|
||||||
|
char **namebuf, size_t *namebuflen )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
ompi_process_name_t *nbuf=NULL;
|
||||||
|
|
||||||
|
nbuf = ( ompi_process_name_t *) calloc (namelistsize, sizeof(ompi_process_name_t));
|
||||||
|
if ( NULL == nbuf ) {
|
||||||
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<namelistsize; i++) {
|
||||||
|
nbuf[i] = *(namelist[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
*namebuf = (char *)nbuf;
|
||||||
|
*namebuflen = (namelistsize * sizeof(ompi_process_name_t));
|
||||||
|
|
||||||
|
return OMPI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ompi_proc_get_namelist ( char *namebuf, size_t namebuflen,
|
||||||
|
int namelistsize, ompi_process_name_t ***namelist )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
ompi_proc_t *proc;
|
||||||
|
ompi_process_name_t **plist=NULL;
|
||||||
|
ompi_process_name_t *nlist= (ompi_process_name_t *) namebuf;
|
||||||
|
|
||||||
|
plist = (ompi_process_name_t**)calloc(namelistsize,sizeof(ompi_process_name_t *));
|
||||||
|
if ( NULL == plist ) {
|
||||||
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( i=0; i<namelistsize; i++ ){
|
||||||
|
proc = ompi_proc_find ( &(nlist[i]));
|
||||||
|
if ( NULL == plist[i] ) {
|
||||||
|
/* to do: look the process information for this name up */
|
||||||
|
}
|
||||||
|
plist[i] = &(proc->proc_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return OMPI_SUCCESS;
|
||||||
|
}
|
||||||
|
@ -66,5 +66,80 @@ static inline ompi_proc_t* ompi_proc_local(void)
|
|||||||
*/
|
*/
|
||||||
ompi_proc_t * ompi_proc_find ( const ompi_process_name_t* name );
|
ompi_proc_t * ompi_proc_find ( const ompi_process_name_t* name );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* INPUT: ompi_proc_t **proclist : list of process pointers
|
||||||
|
* INPUT: int proclistsize : lenght of the proclist array
|
||||||
|
* OUTPUT: char **namebuf : a buffer pointer to an array
|
||||||
|
* of packed ompi_process_name_t objects
|
||||||
|
* OUTPUT: size_t *namebuflen : length of namebuf
|
||||||
|
|
||||||
|
* The function takes a list of ompi_proc_t pointers (e.g. as given in groups)
|
||||||
|
* and returns a buffer, which contains a list of 'packed' ompi_process_name_t
|
||||||
|
* objects, in the same order as provided in proclist.
|
||||||
|
* By 'packed' we mean, that the buffer should be able to be sent across
|
||||||
|
* heterogeneous environments (e.g. it has to be big endian, ilp32 ).
|
||||||
|
* This buffer could be sent using MPI_Send using MPI_BYTE or OOB_Send.
|
||||||
|
*
|
||||||
|
* Return values:
|
||||||
|
* OMPI_SUCCESS on success
|
||||||
|
* OMPI_ERR_OUT_OF_RESOURCE buffer could not be allocated
|
||||||
|
* OMPI_ERROR: other errors
|
||||||
|
*/
|
||||||
|
int ompi_proc_get_namebuf_by_proc ( ompi_proc_t **proclist, int proclistsize,
|
||||||
|
char **namebuf, size_t *namebuflen );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Since ompi_proc_get_namebuf_by_proc allocates the namebuf, we decided to
|
||||||
|
* define a second function to return this buffer. It is up to the implementation,
|
||||||
|
* whether it frees the buffer or reuses it.
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* OMPI_SUCCESS on success
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ompi_proc_namebuf_returnbuf ( char *namebuf );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* INPUT: char *namebuf : buffer containing the opaque, portable
|
||||||
|
* form of the process_names
|
||||||
|
* INPUT: size_t namebuflen : length of namebuf
|
||||||
|
* INPUT: int proclistsize : number of expected proc-pointres
|
||||||
|
* OUTPUT: ompi_proc_t ***proclist : list of process pointers
|
||||||
|
*
|
||||||
|
* This function 'unpacks' the ompi_process_name_t structures and looks
|
||||||
|
* the according ompi_proc_t structure up. If the 'environment' does not
|
||||||
|
* find a proc-structure, it tries to look it up from the name_service or
|
||||||
|
* any other service involved in such an operation (this is required for
|
||||||
|
* the dynamic MPI-2 scenarios). The buffer allocated by
|
||||||
|
* ompi_proc_get_proclist will not be returned to the 'environment'.
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* OMPI_SUCCESS on success
|
||||||
|
* OMPI_ERROR else
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ompi_proc_get_proclist (char *namebuf, size_t namebuflen,
|
||||||
|
int proclistsize, ompi_proc_t ***proclist);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* identical to ompi_proc_get_namebuf_by_proc, the input is however a list
|
||||||
|
* of process_name_t structures instead of ompi_proc_t structures. This is
|
||||||
|
* required for some OOB routines.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int ompi_proc_get_namebuf_by_name ( ompi_process_name_t **namelist, int namelistsize,
|
||||||
|
char **namebuf, size_t *namebuflen );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* similar to ompi_proc_get_proclist, returns however a list of
|
||||||
|
* ompi_process_name_t pointers.
|
||||||
|
*/
|
||||||
|
int ompi_proc_get_namelist ( char *namebuf, size_t namebuflen,
|
||||||
|
int namelistlen, ompi_process_name_t ***namelist );
|
||||||
|
|
||||||
|
|
||||||
#endif /* OMPI_PROC */
|
#endif /* OMPI_PROC */
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user