2005-12-19 19:37:05 +03:00
|
|
|
/*
|
2006-01-25 05:21:34 +03:00
|
|
|
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
|
2005-12-19 19:37:05 +03:00
|
|
|
* 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.
|
|
|
|
* 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.
|
2006-06-20 21:13:44 +04:00
|
|
|
* Copyright (c) 2006 Sandia National Laboratories. All rights
|
|
|
|
* reserved.
|
2005-12-19 19:37:05 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/class/opal_hash_table.h"
|
|
|
|
#include "ompi/mca/pml/base/pml_base_module_exchange.h"
|
2005-12-19 19:37:05 +03:00
|
|
|
|
|
|
|
#include "btl_udapl.h"
|
2006-06-20 21:13:44 +04:00
|
|
|
#include "btl_udapl_endpoint.h"
|
2005-12-19 19:37:05 +03:00
|
|
|
#include "btl_udapl_proc.h"
|
|
|
|
|
|
|
|
static void mca_btl_udapl_proc_construct(mca_btl_udapl_proc_t* proc);
|
|
|
|
static void mca_btl_udapl_proc_destruct(mca_btl_udapl_proc_t* proc);
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(mca_btl_udapl_proc_t,
|
|
|
|
opal_list_item_t, mca_btl_udapl_proc_construct,
|
|
|
|
mca_btl_udapl_proc_destruct);
|
|
|
|
|
|
|
|
void mca_btl_udapl_proc_construct(mca_btl_udapl_proc_t* proc)
|
|
|
|
{
|
|
|
|
proc->proc_ompi = 0;
|
|
|
|
proc->proc_addr_count = 0;
|
|
|
|
proc->proc_endpoints = 0;
|
|
|
|
proc->proc_endpoint_count = 0;
|
|
|
|
OBJ_CONSTRUCT(&proc->proc_lock, opal_mutex_t);
|
2006-03-21 03:12:55 +03:00
|
|
|
|
2005-12-19 19:37:05 +03:00
|
|
|
/* add to list of all proc instance */
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_udapl_component.udapl_lock);
|
|
|
|
opal_list_append(&mca_btl_udapl_component.udapl_procs, &proc->super);
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_udapl_component.udapl_lock);
|
|
|
|
}
|
|
|
|
|
2006-03-21 03:12:55 +03:00
|
|
|
|
2005-12-19 19:37:05 +03:00
|
|
|
/*
|
2006-01-25 05:21:34 +03:00
|
|
|
* Cleanup uDAPL proc instance
|
2005-12-19 19:37:05 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
void mca_btl_udapl_proc_destruct(mca_btl_udapl_proc_t* proc)
|
|
|
|
{
|
|
|
|
/* remove from list of all proc instances */
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_udapl_component.udapl_lock);
|
|
|
|
opal_list_remove_item(&mca_btl_udapl_component.udapl_procs, &proc->super);
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_udapl_component.udapl_lock);
|
|
|
|
|
|
|
|
/* release resources */
|
|
|
|
if(NULL != proc->proc_endpoints) {
|
|
|
|
free(proc->proc_endpoints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for an existing uDAPL process instances based on the associated
|
|
|
|
* ompi_proc_t instance.
|
|
|
|
*/
|
|
|
|
static mca_btl_udapl_proc_t* mca_btl_udapl_proc_lookup_ompi(ompi_proc_t* ompi_proc)
|
|
|
|
{
|
|
|
|
mca_btl_udapl_proc_t* udapl_proc;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&mca_btl_udapl_component.udapl_lock);
|
|
|
|
|
|
|
|
for(udapl_proc = (mca_btl_udapl_proc_t*)
|
|
|
|
opal_list_get_first(&mca_btl_udapl_component.udapl_procs);
|
|
|
|
udapl_proc != (mca_btl_udapl_proc_t*)
|
|
|
|
opal_list_get_end(&mca_btl_udapl_component.udapl_procs);
|
|
|
|
udapl_proc = (mca_btl_udapl_proc_t*)opal_list_get_next(udapl_proc)) {
|
|
|
|
|
|
|
|
if(udapl_proc->proc_ompi == ompi_proc) {
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_udapl_component.udapl_lock);
|
|
|
|
return udapl_proc;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&mca_btl_udapl_component.udapl_lock);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a uDAPL process structure. There is a one-to-one correspondence
|
|
|
|
* between a ompi_proc_t and a mca_btl_udapl_proc_t instance. We cache
|
|
|
|
* additional data (specifically the list of mca_btl_udapl_endpoint_t instances,
|
|
|
|
* and published addresses) associated w/ a given destination on this
|
|
|
|
* datastructure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mca_btl_udapl_proc_t* mca_btl_udapl_proc_create(ompi_proc_t* ompi_proc)
|
|
|
|
{
|
2006-01-12 07:05:02 +03:00
|
|
|
mca_btl_udapl_proc_t* udapl_proc = NULL;
|
|
|
|
size_t size;
|
|
|
|
int rc;
|
2005-12-19 19:37:05 +03:00
|
|
|
|
|
|
|
/* Check if we have already created a uDAPL proc
|
|
|
|
* structure for this ompi process */
|
2006-01-12 07:05:02 +03:00
|
|
|
udapl_proc = mca_btl_udapl_proc_lookup_ompi(ompi_proc);
|
|
|
|
if(udapl_proc != NULL) {
|
|
|
|
return udapl_proc;
|
2005-12-19 19:37:05 +03:00
|
|
|
}
|
|
|
|
|
2006-01-12 07:05:02 +03:00
|
|
|
/* create a new udapl proc out of the ompi_proc ... */
|
|
|
|
udapl_proc = OBJ_NEW(mca_btl_udapl_proc_t);
|
|
|
|
udapl_proc->proc_endpoint_count = 0;
|
|
|
|
udapl_proc->proc_ompi = ompi_proc;
|
|
|
|
udapl_proc->proc_guid = ompi_proc->proc_name;
|
|
|
|
|
|
|
|
/* query for the peer address info */
|
|
|
|
rc = mca_pml_base_modex_recv(
|
|
|
|
&mca_btl_udapl_component.super.btl_version,
|
|
|
|
ompi_proc,
|
|
|
|
(void*)&udapl_proc->proc_addrs,
|
|
|
|
&size);
|
|
|
|
if(OMPI_SUCCESS != rc) {
|
2007-03-08 21:39:40 +03:00
|
|
|
opal_output(0, "[%s:%d] mca_pml_base_modex_recv failed for peer [%lu,%lu,%lu]",
|
2006-01-12 07:05:02 +03:00
|
|
|
__FILE__,__LINE__,ORTE_NAME_ARGS(&ompi_proc->proc_name));
|
|
|
|
OBJ_RELEASE(udapl_proc);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-12-19 19:37:05 +03:00
|
|
|
|
2006-01-12 07:05:02 +03:00
|
|
|
if((size % sizeof(mca_btl_udapl_addr_t)) != 0) {
|
2007-03-08 21:39:40 +03:00
|
|
|
opal_output(0, "[%s:%d] invalid udapl address for peer [%lu,%lu,%lu]",
|
2006-01-12 07:05:02 +03:00
|
|
|
__FILE__,__LINE__,ORTE_NAME_ARGS(&ompi_proc->proc_name));
|
|
|
|
OBJ_RELEASE(udapl_proc);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-12-19 19:37:05 +03:00
|
|
|
|
2006-01-12 07:05:02 +03:00
|
|
|
udapl_proc->proc_addr_count = size/sizeof(mca_btl_udapl_addr_t);
|
|
|
|
if (0 == udapl_proc->proc_addr_count) {
|
|
|
|
udapl_proc->proc_endpoints = NULL;
|
|
|
|
} else {
|
|
|
|
udapl_proc->proc_endpoints = (mca_btl_base_endpoint_t**)
|
|
|
|
malloc(udapl_proc->proc_addr_count * sizeof(mca_btl_base_endpoint_t*));
|
|
|
|
}
|
|
|
|
if(NULL == udapl_proc->proc_endpoints) {
|
|
|
|
OBJ_RELEASE(udapl_proc);
|
2005-12-19 19:37:05 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2006-01-12 07:05:02 +03:00
|
|
|
return udapl_proc;
|
2005-12-19 19:37:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that this routine must be called with the lock on the process
|
|
|
|
* already held. Insert a btl instance into the proc array and assign
|
|
|
|
* it an address.
|
|
|
|
*/
|
2006-01-12 07:05:02 +03:00
|
|
|
int mca_btl_udapl_proc_insert(
|
|
|
|
mca_btl_udapl_proc_t* udapl_proc,
|
|
|
|
mca_btl_base_endpoint_t* udapl_endpoint)
|
2005-12-19 19:37:05 +03:00
|
|
|
{
|
2006-01-12 07:05:02 +03:00
|
|
|
/* insert into endpoint array */
|
2006-01-25 05:21:34 +03:00
|
|
|
if(udapl_proc->proc_endpoint_count > udapl_proc->proc_addr_count)
|
2006-01-12 07:05:02 +03:00
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2006-01-25 05:21:34 +03:00
|
|
|
|
2006-01-12 07:05:02 +03:00
|
|
|
udapl_endpoint->endpoint_proc = udapl_proc;
|
2006-01-25 05:21:34 +03:00
|
|
|
udapl_endpoint->endpoint_addr =
|
|
|
|
udapl_proc->proc_addrs[udapl_proc->proc_endpoint_count];
|
|
|
|
|
2006-01-12 07:05:02 +03:00
|
|
|
udapl_proc->proc_endpoints[udapl_proc->proc_endpoint_count] = udapl_endpoint;
|
|
|
|
udapl_proc->proc_endpoint_count++;
|
2005-12-19 19:37:05 +03:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2006-01-12 07:05:02 +03:00
|
|
|
|