2004-07-08 14:48:34 +00:00
|
|
|
/*
|
2004-11-22 01:38:40 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-22 00:37:56 +00:00
|
|
|
* $HEADER$
|
2004-07-08 14:48:34 +00:00
|
|
|
*/
|
|
|
|
|
2004-08-18 23:24:27 +00:00
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2004-02-13 13:56:55 +00:00
|
|
|
#include <string.h>
|
2004-07-08 14:48:34 +00:00
|
|
|
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "threads/mutex.h"
|
|
|
|
#include "util/output.h"
|
2005-03-14 20:57:21 +00:00
|
|
|
#include "util/proc_info.h"
|
|
|
|
#include "dps/dps.h"
|
2004-03-17 18:45:16 +00:00
|
|
|
#include "proc/proc.h"
|
2004-07-01 14:49:54 +00:00
|
|
|
#include "mca/oob/oob.h"
|
2005-03-14 20:57:21 +00:00
|
|
|
#include "mca/ns/ns.h"
|
2004-09-30 20:54:26 +00:00
|
|
|
#include "mca/pml/pml.h"
|
2005-06-08 19:14:07 +00:00
|
|
|
#include "datatype/convertor.h"
|
2004-01-29 15:34:47 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
static ompi_list_t ompi_proc_list;
|
|
|
|
static ompi_mutex_t ompi_proc_lock;
|
|
|
|
ompi_proc_t* ompi_proc_local_proc = NULL;
|
2004-02-13 13:56:55 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
static void ompi_proc_construct(ompi_proc_t* proc);
|
|
|
|
static void ompi_proc_destruct(ompi_proc_t* proc);
|
2004-01-16 00:31:58 +00:00
|
|
|
|
|
|
|
|
2004-10-26 11:39:16 +00:00
|
|
|
OBJ_CLASS_INSTANCE(
|
|
|
|
ompi_proc_t,
|
|
|
|
ompi_list_item_t,
|
|
|
|
ompi_proc_construct,
|
|
|
|
ompi_proc_destruct
|
|
|
|
);
|
|
|
|
|
2004-01-16 00:31:58 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
void ompi_proc_construct(ompi_proc_t* proc)
|
2004-01-16 00:31:58 +00:00
|
|
|
{
|
2004-02-13 22:16:39 +00:00
|
|
|
proc->proc_pml = NULL;
|
|
|
|
proc->proc_modex = NULL;
|
2004-06-07 15:33:53 +00:00
|
|
|
OBJ_CONSTRUCT(&proc->proc_lock, ompi_mutex_t);
|
2004-03-26 14:15:20 +00:00
|
|
|
|
|
|
|
/* FIX - need to determine remote process architecture */
|
2004-06-07 15:33:53 +00:00
|
|
|
proc->proc_convertor = ompi_convertor_create(0, 0);
|
2004-10-12 21:50:25 +00:00
|
|
|
proc->proc_arch = 0;
|
2004-01-29 15:34:47 +00:00
|
|
|
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_LOCK(&ompi_proc_lock);
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_list_append(&ompi_proc_list, (ompi_list_item_t*)proc);
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_UNLOCK(&ompi_proc_lock);
|
2004-01-16 00:31:58 +00:00
|
|
|
}
|
|
|
|
|
2004-01-29 15:34:47 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
void ompi_proc_destruct(ompi_proc_t* proc)
|
2004-01-16 00:31:58 +00:00
|
|
|
{
|
2004-10-14 21:04:45 +00:00
|
|
|
if(proc->proc_modex != NULL)
|
|
|
|
OBJ_RELEASE(proc->proc_modex);
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_LOCK(&ompi_proc_lock);
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_list_remove_item(&ompi_proc_list, (ompi_list_item_t*)proc);
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_UNLOCK(&ompi_proc_lock);
|
2004-03-31 16:59:06 +00:00
|
|
|
OBJ_DESTRUCT(&proc->proc_lock);
|
2004-01-16 00:31:58 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 13:56:55 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
int ompi_proc_init(void)
|
2004-02-13 13:56:55 +00:00
|
|
|
{
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_process_name_t *peers;
|
|
|
|
size_t i, npeers, self;
|
2004-02-13 13:56:55 +00:00
|
|
|
int rc;
|
|
|
|
|
2004-10-14 21:04:45 +00:00
|
|
|
OBJ_CONSTRUCT(&ompi_proc_list, ompi_list_t);
|
|
|
|
OBJ_CONSTRUCT(&ompi_proc_lock, ompi_mutex_t);
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
if(OMPI_SUCCESS != (rc = orte_ns.get_peers(&peers, &npeers, &self))) {
|
|
|
|
ompi_output(0, "ompi_proc_init: get_peers failed with errno=%d", rc);
|
2004-02-13 13:56:55 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-07-01 14:49:54 +00:00
|
|
|
for(i=0; i<npeers; i++) {
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_proc_t *proc = OBJ_NEW(ompi_proc_t);
|
2004-07-01 14:49:54 +00:00
|
|
|
proc->proc_name = peers[i];
|
2005-03-14 20:57:21 +00:00
|
|
|
if( i == self ) {
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_proc_local_proc = proc;
|
2004-03-03 16:44:41 +00:00
|
|
|
}
|
2004-02-13 13:56:55 +00:00
|
|
|
}
|
2005-03-14 20:57:21 +00:00
|
|
|
free(peers);
|
2004-06-07 15:33:53 +00:00
|
|
|
return OMPI_SUCCESS;
|
2004-02-13 13:56:55 +00:00
|
|
|
}
|
|
|
|
|
2004-12-02 13:28:10 +00:00
|
|
|
int ompi_proc_finalize (void)
|
|
|
|
{
|
|
|
|
ompi_proc_t *proc, *nextproc, *endproc;
|
|
|
|
|
|
|
|
proc = (ompi_proc_t*)ompi_list_get_first(&ompi_proc_list);
|
|
|
|
nextproc = (ompi_proc_t*)ompi_list_get_next(proc);
|
|
|
|
endproc = (ompi_proc_t*)ompi_list_get_end(&ompi_proc_list);
|
|
|
|
|
|
|
|
OBJ_RELEASE(proc);
|
|
|
|
while ( nextproc != endproc ) {
|
|
|
|
proc = nextproc;
|
|
|
|
nextproc = (ompi_proc_t *)ompi_list_get_next(proc);
|
|
|
|
OBJ_RELEASE(proc);
|
|
|
|
}
|
|
|
|
OBJ_DESTRUCT(&ompi_proc_list);
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2004-02-13 13:56:55 +00:00
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_proc_t** ompi_proc_world(size_t *size)
|
2004-02-13 13:56:55 +00:00
|
|
|
{
|
2004-10-18 16:11:14 +00:00
|
|
|
ompi_proc_t **procs =
|
|
|
|
(ompi_proc_t**) malloc(ompi_list_get_size(&ompi_proc_list) * sizeof(ompi_proc_t*));
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_proc_t *proc;
|
2004-02-13 13:56:55 +00:00
|
|
|
size_t count = 0;
|
|
|
|
|
|
|
|
if(NULL == procs)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* return only the procs that match this jobid */
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_LOCK(&ompi_proc_lock);
|
2004-06-07 15:33:53 +00:00
|
|
|
for(proc = (ompi_proc_t*)ompi_list_get_first(&ompi_proc_list);
|
|
|
|
proc != (ompi_proc_t*)ompi_list_get_end(&ompi_proc_list);
|
|
|
|
proc = (ompi_proc_t*)ompi_list_get_next(proc)) {
|
2004-07-01 14:49:54 +00:00
|
|
|
/* TSW - FIX */
|
|
|
|
procs[count++] = proc;
|
2004-02-13 13:56:55 +00:00
|
|
|
}
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_UNLOCK(&ompi_proc_lock);
|
2004-02-13 13:56:55 +00:00
|
|
|
*size = count;
|
|
|
|
return procs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_proc_t** ompi_proc_all(size_t* size)
|
2004-02-13 13:56:55 +00:00
|
|
|
{
|
2004-10-18 16:11:14 +00:00
|
|
|
ompi_proc_t **procs =
|
|
|
|
(ompi_proc_t**) malloc(ompi_list_get_size(&ompi_proc_list) * sizeof(ompi_proc_t*));
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_proc_t *proc;
|
2004-02-13 13:56:55 +00:00
|
|
|
size_t count = 0;
|
|
|
|
|
|
|
|
if(NULL == procs)
|
|
|
|
return NULL;
|
|
|
|
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_LOCK(&ompi_proc_lock);
|
2004-06-07 15:33:53 +00:00
|
|
|
for(proc = (ompi_proc_t*)ompi_list_get_first(&ompi_proc_list);
|
|
|
|
proc != (ompi_proc_t*)ompi_list_get_end(&ompi_proc_list);
|
|
|
|
proc = (ompi_proc_t*)ompi_list_get_next(proc)) {
|
2004-02-13 13:56:55 +00:00
|
|
|
OBJ_RETAIN(proc);
|
|
|
|
procs[count++] = proc;
|
|
|
|
}
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_UNLOCK(&ompi_proc_lock);
|
2004-02-13 13:56:55 +00:00
|
|
|
*size = count;
|
|
|
|
return procs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-07 15:33:53 +00:00
|
|
|
ompi_proc_t** ompi_proc_self(size_t* size)
|
2004-02-13 13:56:55 +00:00
|
|
|
{
|
2004-10-18 16:11:14 +00:00
|
|
|
ompi_proc_t **procs = (ompi_proc_t**) malloc(sizeof(ompi_proc_t*));
|
2004-02-13 13:56:55 +00:00
|
|
|
if(NULL == procs)
|
|
|
|
return NULL;
|
2004-06-07 15:33:53 +00:00
|
|
|
OBJ_RETAIN(ompi_proc_local_proc);
|
|
|
|
*procs = ompi_proc_local_proc;
|
2004-02-13 13:56:55 +00:00
|
|
|
*size = 1;
|
|
|
|
return procs;
|
|
|
|
}
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
ompi_proc_t * ompi_proc_find ( const orte_process_name_t * name )
|
2004-05-17 21:28:32 +00:00
|
|
|
{
|
2004-09-17 10:10:24 +00:00
|
|
|
ompi_proc_t *proc, *rproc=NULL;
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_ns_cmp_bitmask_t mask;
|
2004-05-17 21:28:32 +00:00
|
|
|
|
|
|
|
/* return the proc-struct which matches this jobid+process id */
|
2004-07-08 14:48:34 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
mask = ORTE_NS_CMP_CELLID | ORTE_NS_CMP_JOBID | ORTE_NS_CMP_VPID;
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_LOCK(&ompi_proc_lock);
|
2004-06-07 15:33:53 +00:00
|
|
|
for(proc = (ompi_proc_t*)ompi_list_get_first(&ompi_proc_list);
|
|
|
|
proc != (ompi_proc_t*)ompi_list_get_end(&ompi_proc_list);
|
|
|
|
proc = (ompi_proc_t*)ompi_list_get_next(proc)) {
|
2005-03-14 20:57:21 +00:00
|
|
|
if (orte_ns.compare(mask, &proc->proc_name, name) == 0) {
|
|
|
|
rproc = proc;
|
|
|
|
break;
|
|
|
|
}
|
2004-05-17 21:28:32 +00:00
|
|
|
}
|
2004-06-24 21:39:08 +00:00
|
|
|
OMPI_THREAD_UNLOCK(&ompi_proc_lock);
|
2004-09-17 10:10:24 +00:00
|
|
|
return rproc;
|
2004-05-17 21:28:32 +00:00
|
|
|
}
|
2004-07-01 14:49:54 +00:00
|
|
|
|
2004-08-04 17:05:22 +00:00
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
ompi_proc_t * ompi_proc_find_and_add ( const orte_process_name_t * name, bool* isnew )
|
2004-09-17 10:10:24 +00:00
|
|
|
{
|
|
|
|
ompi_proc_t *proc, *rproc=NULL;
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_ns_cmp_bitmask_t mask;
|
2004-09-17 10:10:24 +00:00
|
|
|
|
|
|
|
/* return the proc-struct which matches this jobid+process id */
|
2005-03-14 20:57:21 +00:00
|
|
|
mask = ORTE_NS_CMP_CELLID | ORTE_NS_CMP_JOBID | ORTE_NS_CMP_VPID;
|
2004-09-17 10:10:24 +00:00
|
|
|
OMPI_THREAD_LOCK(&ompi_proc_lock);
|
|
|
|
for(proc = (ompi_proc_t*)ompi_list_get_first(&ompi_proc_list);
|
|
|
|
proc != (ompi_proc_t*)ompi_list_get_end(&ompi_proc_list);
|
|
|
|
proc = (ompi_proc_t*)ompi_list_get_next(proc)) {
|
2005-03-14 20:57:21 +00:00
|
|
|
if(orte_ns.compare(mask, &proc->proc_name, name) == 0) {
|
|
|
|
*isnew = false;
|
|
|
|
rproc = proc;
|
|
|
|
break;
|
|
|
|
}
|
2004-09-17 10:10:24 +00:00
|
|
|
}
|
2004-09-30 20:54:26 +00:00
|
|
|
OMPI_THREAD_UNLOCK(&ompi_proc_lock);
|
2004-09-17 10:10:24 +00:00
|
|
|
|
|
|
|
if ( NULL == rproc ) {
|
2004-09-30 20:54:26 +00:00
|
|
|
ompi_proc_t *tproc = OBJ_NEW(ompi_proc_t);
|
|
|
|
rproc = tproc;
|
|
|
|
rproc->proc_name = *name;
|
2004-10-25 19:52:37 +00:00
|
|
|
*isnew = true;
|
2004-09-17 10:10:24 +00:00
|
|
|
}
|
|
|
|
return rproc;
|
|
|
|
}
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
int ompi_proc_get_namebuf ( ompi_proc_t **proclist, int proclistsize, orte_buffer_t* buf)
|
2004-08-04 17:05:22 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
OMPI_THREAD_LOCK(&ompi_proc_lock);
|
|
|
|
for (i=0; i<proclistsize; i++) {
|
2005-03-14 20:57:21 +00:00
|
|
|
int rc = orte_dps.pack(buf, &(proclist[i]->proc_name), 1, ORTE_NAME);
|
|
|
|
if(rc != OMPI_SUCCESS) {
|
|
|
|
OMPI_THREAD_UNLOCK(&ompi_proc_lock);
|
|
|
|
return rc;
|
|
|
|
}
|
2004-08-04 17:05:22 +00:00
|
|
|
}
|
|
|
|
OMPI_THREAD_UNLOCK(&ompi_proc_lock);
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-14 20:57:21 +00:00
|
|
|
int ompi_proc_get_proclist (orte_buffer_t* buf, int proclistsize, ompi_proc_t ***proclist)
|
2004-08-04 17:05:22 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
ompi_proc_t **plist=NULL;
|
2005-03-14 20:57:21 +00:00
|
|
|
orte_process_name_t name;
|
2004-10-25 19:52:37 +00:00
|
|
|
bool isnew = false;
|
|
|
|
|
2004-09-16 10:07:14 +00:00
|
|
|
/* do not free plist *ever*, since it is used in the remote group structure
|
|
|
|
of a communicator */
|
|
|
|
plist = (ompi_proc_t **) calloc (proclistsize, sizeof (ompi_proc_t *));
|
2004-08-04 17:05:22 +00:00
|
|
|
if ( NULL == plist ) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i=0; i<proclistsize; i++ ){
|
2005-03-14 20:57:21 +00:00
|
|
|
size_t count=1;
|
|
|
|
int rc = orte_dps.unpack(buf, &name, &count, ORTE_NAME);
|
|
|
|
if(rc != OMPI_SUCCESS)
|
|
|
|
return rc;
|
2004-10-25 19:52:37 +00:00
|
|
|
plist[i] = ompi_proc_find_and_add ( &name, &isnew );
|
|
|
|
if(isnew) {
|
2005-04-13 03:19:48 +00:00
|
|
|
MCA_PML_CALL(add_procs(&plist[i], 1));
|
2004-10-25 19:52:37 +00:00
|
|
|
}
|
2004-08-04 17:05:22 +00:00
|
|
|
}
|
|
|
|
*proclist = plist;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|