2005-06-30 06:09:50 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-06-30 06:09:50 +04:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2005-07-03 20:52:32 +04:00
|
|
|
#include "class/opal_hash_table.h"
|
2005-07-03 04:52:18 +04:00
|
|
|
#include "mca/pml/base/pml_base_module_exchange.h"
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
#include "btl_mvapi.h"
|
|
|
|
#include "btl_mvapi_proc.h"
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
static void mca_btl_mvapi_proc_construct(mca_btl_mvapi_proc_t* proc);
|
|
|
|
static void mca_btl_mvapi_proc_destruct(mca_btl_mvapi_proc_t* proc);
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
OBJ_CLASS_INSTANCE(mca_btl_mvapi_proc_t,
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t, mca_btl_mvapi_proc_construct,
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_mvapi_proc_destruct);
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
void mca_btl_mvapi_proc_construct(mca_btl_mvapi_proc_t* proc)
|
2005-06-30 06:09:50 +04:00
|
|
|
{
|
|
|
|
proc->proc_ompi = 0;
|
2005-09-02 07:04:28 +04:00
|
|
|
proc->proc_port_count = 0;
|
2005-06-30 06:09:50 +04:00
|
|
|
proc->proc_endpoints = 0;
|
|
|
|
proc->proc_endpoint_count = 0;
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&proc->proc_lock, opal_mutex_t);
|
2005-06-30 06:09:50 +04:00
|
|
|
/* add to list of all proc instance */
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mca_btl_mvapi_component.ib_lock);
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&mca_btl_mvapi_component.ib_procs, &proc->super);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_mvapi_component.ib_lock);
|
2005-06-30 06:09:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cleanup ib proc instance
|
|
|
|
*/
|
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
void mca_btl_mvapi_proc_destruct(mca_btl_mvapi_proc_t* proc)
|
2005-06-30 06:09:50 +04:00
|
|
|
{
|
|
|
|
/* remove from list of all proc instances */
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mca_btl_mvapi_component.ib_lock);
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(&mca_btl_mvapi_component.ib_procs, &proc->super);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_mvapi_component.ib_lock);
|
2005-06-30 06:09:50 +04:00
|
|
|
|
|
|
|
/* release resources */
|
|
|
|
if(NULL != proc->proc_endpoints) {
|
|
|
|
free(proc->proc_endpoints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for an existing IB process instances based on the associated
|
|
|
|
* ompi_proc_t instance.
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
static mca_btl_mvapi_proc_t* mca_btl_mvapi_proc_lookup_ompi(ompi_proc_t* ompi_proc)
|
2005-06-30 06:09:50 +04:00
|
|
|
{
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_mvapi_proc_t* ib_proc;
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mca_btl_mvapi_component.ib_lock);
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
for(ib_proc = (mca_btl_mvapi_proc_t*)
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_first(&mca_btl_mvapi_component.ib_procs);
|
2005-06-30 09:50:55 +04:00
|
|
|
ib_proc != (mca_btl_mvapi_proc_t*)
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_get_end(&mca_btl_mvapi_component.ib_procs);
|
|
|
|
ib_proc = (mca_btl_mvapi_proc_t*)opal_list_get_next(ib_proc)) {
|
2005-06-30 06:09:50 +04:00
|
|
|
|
|
|
|
if(ib_proc->proc_ompi == ompi_proc) {
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_mvapi_component.ib_lock);
|
2005-06-30 06:09:50 +04:00
|
|
|
return ib_proc;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_mvapi_component.ib_lock);
|
2005-06-30 06:09:50 +04:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a IB process structure. There is a one-to-one correspondence
|
2005-06-30 09:50:55 +04:00
|
|
|
* between a ompi_proc_t and a mca_btl_mvapi_proc_t instance. We cache
|
|
|
|
* additional data (specifically the list of mca_btl_mvapi_endpoint_t instances,
|
2005-06-30 06:09:50 +04:00
|
|
|
* and published addresses) associated w/ a given destination on this
|
|
|
|
* datastructure.
|
|
|
|
*/
|
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_mvapi_proc_t* mca_btl_mvapi_proc_create(ompi_proc_t* ompi_proc)
|
2005-06-30 06:09:50 +04:00
|
|
|
{
|
2005-08-15 23:39:56 +04:00
|
|
|
mca_btl_mvapi_proc_t* mvapi_proc = NULL;
|
|
|
|
size_t size;
|
|
|
|
int rc;
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-08-15 23:39:56 +04:00
|
|
|
|
2005-06-30 06:09:50 +04:00
|
|
|
/* Check if we have already created a IB proc
|
|
|
|
* structure for this ompi process */
|
2005-08-15 23:39:56 +04:00
|
|
|
mvapi_proc = mca_btl_mvapi_proc_lookup_ompi(ompi_proc);
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-08-15 23:39:56 +04:00
|
|
|
if(mvapi_proc != NULL) {
|
2005-06-30 06:09:50 +04:00
|
|
|
|
|
|
|
/* Gotcha! */
|
2005-08-15 23:39:56 +04:00
|
|
|
return mvapi_proc;
|
2005-06-30 06:09:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Oops! First time, gotta create a new IB proc
|
|
|
|
* out of the ompi_proc ... */
|
|
|
|
|
2005-08-15 23:39:56 +04:00
|
|
|
mvapi_proc = OBJ_NEW(mca_btl_mvapi_proc_t);
|
2005-06-30 06:09:50 +04:00
|
|
|
|
|
|
|
/* Initialize number of peer */
|
2005-08-15 23:39:56 +04:00
|
|
|
mvapi_proc->proc_endpoint_count = 0;
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-08-15 23:39:56 +04:00
|
|
|
mvapi_proc->proc_ompi = ompi_proc;
|
2005-06-30 06:09:50 +04:00
|
|
|
|
|
|
|
/* build a unique identifier (of arbitrary
|
|
|
|
* size) to represent the proc */
|
2005-08-15 23:39:56 +04:00
|
|
|
mvapi_proc->proc_guid = ompi_proc->proc_name;
|
|
|
|
|
|
|
|
/* query for the peer address info */
|
|
|
|
rc = mca_pml_base_modex_recv(
|
|
|
|
&mca_btl_mvapi_component.super.btl_version,
|
|
|
|
ompi_proc,
|
2005-09-02 07:04:28 +04:00
|
|
|
(void*)&mvapi_proc->proc_ports,
|
2005-08-15 23:39:56 +04:00
|
|
|
&size
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(OMPI_SUCCESS != rc) {
|
|
|
|
opal_output(0, "[%s:%d] mca_pml_base_modex_recv failed for peer [%d,%d,%d]",
|
|
|
|
__FILE__,__LINE__,ORTE_NAME_ARGS(&ompi_proc->proc_name));
|
|
|
|
OBJ_RELEASE(mvapi_proc);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-09-02 07:04:28 +04:00
|
|
|
if((size % sizeof(mca_btl_mvapi_port_info_t)) != 0) {
|
2005-08-15 23:39:56 +04:00
|
|
|
opal_output(0, "[%s:%d] invalid mvapi address for peer [%d,%d,%d]",
|
|
|
|
__FILE__,__LINE__,ORTE_NAME_ARGS(&ompi_proc->proc_name));
|
|
|
|
OBJ_RELEASE(mvapi_proc);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-06-30 06:09:50 +04:00
|
|
|
|
|
|
|
|
2005-09-02 07:04:28 +04:00
|
|
|
mvapi_proc->proc_port_count = size/sizeof(mca_btl_mvapi_port_info_t);
|
2005-08-15 23:39:56 +04:00
|
|
|
|
2005-09-02 19:18:36 +04:00
|
|
|
|
2005-09-30 08:39:44 +04:00
|
|
|
if (0 == mvapi_proc->proc_port_count) {
|
|
|
|
mvapi_proc->proc_endpoints = NULL;
|
|
|
|
} else {
|
|
|
|
mvapi_proc->proc_endpoints = (mca_btl_base_endpoint_t**)
|
|
|
|
malloc(mvapi_proc->proc_port_count * sizeof(mca_btl_base_endpoint_t*));
|
|
|
|
}
|
2005-06-30 06:09:50 +04:00
|
|
|
|
2005-08-15 23:39:56 +04:00
|
|
|
if(NULL == mvapi_proc->proc_endpoints) {
|
|
|
|
OBJ_RELEASE(mvapi_proc);
|
2005-06-30 06:09:50 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-08-15 23:39:56 +04:00
|
|
|
return mvapi_proc;
|
2005-06-30 06:09:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that this routine must be called with the lock on the process
|
2005-06-30 06:12:23 +04:00
|
|
|
* already held. Insert a btl instance into the proc array and assign
|
2005-06-30 06:09:50 +04:00
|
|
|
* it an address.
|
|
|
|
*/
|
2005-08-15 23:39:56 +04:00
|
|
|
int mca_btl_mvapi_proc_insert(mca_btl_mvapi_proc_t* mvapi_proc,
|
|
|
|
mca_btl_base_endpoint_t* mvapi_endpoint)
|
2005-06-30 06:09:50 +04:00
|
|
|
{
|
2005-09-02 07:04:28 +04:00
|
|
|
|
2005-06-30 06:09:50 +04:00
|
|
|
/* insert into endpoint array */
|
2005-09-02 07:04:28 +04:00
|
|
|
if(mvapi_proc->proc_port_count <= mvapi_proc->proc_endpoint_count)
|
2005-08-15 23:39:56 +04:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
|
|
|
|
mvapi_endpoint->endpoint_proc = mvapi_proc;
|
|
|
|
mvapi_proc->proc_endpoints[mvapi_proc->proc_endpoint_count++] = mvapi_endpoint;
|
|
|
|
|
2005-06-30 06:09:50 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|