1
1

a "template" bmi, implements some of the tedious bookkeeping required for all bmis

This commit was SVN r6197.
Этот коммит содержится в:
Tim Woodall 2005-06-27 21:21:15 +00:00
родитель 39c7bfe63a
Коммит 818d6474fd
13 изменённых файлов: 1694 добавлений и 0 удалений

0
src/mca/bmi/template/.ompi_ignore Обычный файл
Просмотреть файл

2
src/mca/bmi/template/.ompi_unignore Обычный файл
Просмотреть файл

@ -0,0 +1,2 @@
twoodall
gshipman

56
src/mca/bmi/template/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,56 @@
#
# 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.
# 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$
#
# Use the top-level Makefile.options
include $(top_ompi_srcdir)/config/Makefile.options
sources = \
bmi_template.c \
bmi_template.h \
bmi_template_component.c \
bmi_template_endpoint.c \
bmi_template_endpoint.h \
bmi_template_frag.c \
bmi_template_frag.h \
bmi_template_proc.c \
bmi_template_proc.h \
bmi_template_error.h
# Make the output lgmrary in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or lgmmca_<type>_<name>.la
# (for static builds).
if OMPI_BUILD_bmi_template_DSO
lgm =
lgm_sources =
component = mca_bmi_template.la
component_sources = $(sources)
else
lgm = lgmmca_bmi_template.la
lgm_sources = $(sources)
component =
component_sources =
endif
mcacomponentdir = $(lgmdir)/openmpi
mcacomponent_LTLIBRARIES = $(component)
mca_bmi_template_la_SOURCES = $(component_sources)
mca_bmi_template_la_LDFLAGS = -module -avoid-version
noinst_LTLIBRARIES = $(lgm)
lgmmca_bmi_template_la_SOURCES = $(lgm_sources)
lgmmca_bmi_template_la_LDFLAGS = -module -avoid-version

621
src/mca/bmi/template/bmi_template.c Обычный файл
Просмотреть файл

@ -0,0 +1,621 @@
/*
* 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.
* 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"
#include <string.h>
#include "util/output.h"
#include "util/if.h"
#include "mca/pml/pml.h"
#include "mca/bmi/bmi.h"
#include "bmi_template.h"
#include "bmi_template_frag.h"
#include "bmi_template_proc.h"
#include "bmi_template_endpoint.h"
#include "datatype/convertor.h"
#include "mca/mpool/base/base.h"
#include "mca/mpool/mpool.h"
mca_bmi_template_module_t mca_bmi_template_module = {
{
&mca_bmi_template_component.super,
0, /* max size of first fragment */
0, /* min send fragment size */
0, /* max send fragment size */
0, /* min rdma fragment size */
0, /* max rdma fragment size */
0, /* exclusivity */
0, /* latency */
0, /* bandwidth */
0, /* flags */
mca_bmi_template_add_procs,
mca_bmi_template_del_procs,
mca_bmi_template_register,
mca_bmi_template_finalize,
mca_bmi_template_alloc,
mca_bmi_template_free,
mca_bmi_template_prepare_src,
mca_bmi_template_prepare_dst,
mca_bmi_template_send,
mca_bmi_template_put,
NULL /* get */
}
};
/**
*
*/
int mca_bmi_template_add_procs(
struct mca_bmi_base_module_t* bmi,
size_t nprocs,
struct ompi_proc_t **ompi_procs,
struct mca_bmi_base_endpoint_t** peers,
ompi_bitmap_t* reachable)
{
mca_bmi_template_module_t* template_bmi = (mca_bmi_template_module_t*)bmi;
int i, rc;
for(i = 0; i < (int) nprocs; i++) {
struct ompi_proc_t* ompi_proc = ompi_procs[i];
mca_bmi_template_proc_t* template_proc;
mca_bmi_base_endpoint_t* template_endpoint;
if(NULL == (template_proc = mca_bmi_template_proc_create(ompi_proc))) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
/*
* Check to make sure that the peer has at least as many interface
* addresses exported as we are trying to use. If not, then
* don't bind this PTL instance to the proc.
*/
OMPI_THREAD_LOCK(&template_proc->proc_lock);
/* The bmi_proc datastructure is shared by all TEMPLATE PTL
* instances that are trying to reach this destination.
* Cache the peer instance on the bmi_proc.
*/
template_endpoint = OBJ_NEW(mca_bmi_template_endpoint_t);
if(NULL == template_endpoint) {
OMPI_THREAD_UNLOCK(&module_proc->proc_lock);
return OMPI_ERR_OUT_OF_RESOURCE;
}
template_endpoint->endpoint_bmi = template_bmi;
rc = mca_bmi_template_proc_insert(template_proc, template_endpoint);
if(rc != OMPI_SUCCESS) {
OBJ_RELEASE(template_endpoint);
OMPI_THREAD_UNLOCK(&module_proc->proc_lock);
continue;
}
ompi_bitmap_set_bit(reachable, i);
OMPI_THREAD_UNLOCK(&module_proc->proc_lock);
peers[i] = template_endpoint;
}
return OMPI_SUCCESS;
}
int mca_bmi_template_del_procs(struct mca_bmi_base_module_t* bmi,
size_t nprocs,
struct ompi_proc_t **procs,
struct mca_bmi_base_endpoint_t ** peers)
{
/* TODO */
return OMPI_SUCCESS;
}
/**
* Register callback function to support send/recv semantics
*/
int mca_bmi_template_register(
struct mca_bmi_base_module_t* bmi,
mca_bmi_base_tag_t tag,
mca_bmi_base_module_recv_cb_fn_t cbfunc,
void* cbdata)
{
mca_bmi_template_module_t* template_bmi = (mca_bmi_template_module_t*) bmi;
template_bmi->template_reg[tag].cbfunc = cbfunc;
template_bmi->template_reg[tag].cbdata = cbdata;
return OMPI_SUCCESS;
}
/**
* Allocate a segment.
*
* @param bmi (IN) BMI module
* @param size (IN) Request segment size.
*/
mca_bmi_base_descriptor_t* mca_bmi_template_alloc(
struct mca_bmi_base_module_t* bmi,
size_t size)
{
mca_bmi_template_module_t* template_bmi = (mca_bmi_template_module_t*) bmi;
mca_bmi_template_frag_t* frag;
int rc;
if(size <= bmi->bmi_eager_limit){
MCA_BMI_TEMPLATE_FRAG_ALLOC_EAGER(template_bmi, frag, rc);
frag->segment.seg_len =
size <= bmi->bmi_eager_limit ?
size : bmi->bmi_eager_limit ;
} else {
MCA_BMI_TEMPLATE_FRAG_ALLOC_MAX(template_bmi, frag, rc);
frag->segment.seg_len =
size <= bmi->bmi_max_send_size ?
size : bmi->bmi_max_send_size ;
}
frag->base.des_flags = 0;
return (mca_bmi_base_descriptor_t*)frag;
}
/**
* Return a segment
*/
int mca_bmi_template_free(
struct mca_bmi_base_module_t* bmi,
mca_bmi_base_descriptor_t* des)
{
mca_bmi_template_frag_t* frag = (mca_bmi_template_frag_t*)des;
if(frag->size == 0) {
#if MCA_BMI_HAS_MPOOL
OBJ_RELEASE(frag->registration);
#endif
MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi, frag);
} else if(frag->size == bmi->bmi_eager_limit){
MCA_BMI_TEMPLATE_FRAG_RETURN_EAGER(bmi, frag);
} else if(frag->size == bmi->bmi_max_send_size) {
MCA_BMI_TEMPLATE_FRAG_RETURN_EAGER(bmi, frag);
} else {
return OMPI_ERR_BAD_PARAM;
}
return OMPI_SUCCESS;
}
/**
* Pack data and return a descriptor that can be
* used for send/put.
*
* @param bmi (IN) BMI module
* @param peer (IN) BMI peer addressing
*/
mca_bmi_base_descriptor_t* mca_bmi_template_prepare_src(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* endpoint,
struct mca_mpool_base_registration_t* registration,
struct ompi_convertor_t* convertor,
size_t reserve,
size_t* size
)
{
mca_bmi_template_module_t* template_bmi = (mca_bmi_template_module_t*)bmi;
mca_bmi_template_frag_t* frag;
struct iovec iov;
uint32_t iov_count = 1;
size_t max_data = *size;
int32_t free_after;
int rc;
#if MCA_BMI_HAS_MPOOL
/*
* If the data has already been pinned and is contigous than we can
* use it in place.
*/
if (NULL != registration && 0 == ompi_convertor_need_buffers(convertor)) {
size_t reg_len;
MCA_BMI_TEMPLATE_FRAG_ALLOC_USER(template_bmi, frag, rc);
if(NULL == frag){
return NULL;
}
iov.iov_len = max_data;
iov.iov_base = NULL;
ompi_convertor_pack(convertor, &iov, &iov_count, &max_data, &free_after);
frag->segment.seg_len = max_data;
frag->segment.seg_addr.pval = iov.iov_base;
reg_len = (unsigned char*)registration->bound - (unsigned char*)iov.iov_base + 1;
if(frag->segment.seg_len > reg_len) {
mca_mpool_base_module_t* mpool = template_bmi->template_mpool;
size_t new_len = (unsigned char*)iov.iov_base - registration->base + max_data;
void* base_addr = registration->base;
/* remove old registration from tree and decrement reference count */
mca_mpool_base_remove(base_addr);
OBJ_RELEASE(registration);
/* re-register at new size */
rc = mpool->mpool_register(
mpool,
base_addr,
new_len,
&registration);
if(rc != OMPI_SUCCESS) {
MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi,frag);
return NULL;
}
/* re-insert into tree with new registration */
rc = mca_mpool_base_insert(
base_addr,
new_len,
mpool,
bmi,
registration);
if(rc != OMPI_SUCCESS) {
MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi,frag);
OBJ_RELEASE(registration);
return NULL;
}
}
/* bump reference count as so that the registration
* doesn't go away when the operation completes
*/
OBJ_RETAIN(registration);
frag->registration = registration;
/*
* if the data is not already pinned - but the leave pinned option is set,
* then go ahead and pin contigous data. however, if a reserve is required
* then we must allocated a fragment w/ buffer space
*/
} else if ((mca_bmi_template_component.leave_pinned || max_data > bmi->bmi_max_send_size) &&
ompi_convertor_need_buffers(convertor) == 0 &&
reserve == 0) {
mca_mpool_base_module_t* mpool = template_bmi->template_mpool;
MCA_BMI_TEMPLATE_FRAG_ALLOC_USER(template_bmi, frag, rc);
if(NULL == frag){
return NULL;
}
iov.iov_len = max_data;
iov.iov_base = NULL;
ompi_convertor_pack(convertor, &iov, &iov_count, &max_data, &free_after);
frag->segment.seg_len = max_data;
frag->segment.seg_addr.pval = iov.iov_base;
rc = mpool->mpool_register(
mpool,
iov.iov_base,
max_data,
&registration);
if(rc != OMPI_SUCCESS) {
MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi,frag);
return NULL;
}
if(mca_bmi_template_component.leave_pinned) {
/*
* insert the registration into the tree and bump the reference
* count so that it doesn't go away on completion.
*/
rc = mca_mpool_base_insert(
iov.iov_base,
iov.iov_len,
mpool,
bmi,
registration);
if(rc != OMPI_SUCCESS) {
MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi,frag);
OBJ_RELEASE(registration);
return NULL;
}
OBJ_RETAIN(registration);
}
frag->registration = registration;
} else
#endif
/*
* if we aren't pinning the data and the requested size is less
* than the eager limit pack into a fragment from the eager pool
*/
if (max_data+reserve <= bmi->bmi_eager_limit) {
MCA_BMI_TEMPLATE_FRAG_ALLOC_EAGER(bmi, frag, rc);
if(NULL == frag) {
return NULL;
}
iov.iov_len = max_data;
iov.iov_base = (unsigned char*) frag->segment.seg_addr.pval + reserve;
rc = ompi_convertor_pack(convertor, &iov, &iov_count, &max_data, &free_after);
*size = max_data;
if( rc < 0 ) {
MCA_BMI_TEMPLATE_FRAG_RETURN_EAGER(bmi, frag);
return NULL;
}
frag->segment.seg_len = max_data + reserve;
}
/*
* otherwise pack as much data as we can into a fragment
* that is the max send size.
*/
else {
MCA_BMI_TEMPLATE_FRAG_ALLOC_MAX(bmi, frag, rc);
if(NULL == frag) {
return NULL;
}
if(max_data + reserve > frag->size){
max_data = frag->size - reserve;
}
iov.iov_len = max_data;
iov.iov_base = (unsigned char*) frag->segment.seg_addr.pval + reserve;
rc = ompi_convertor_pack(convertor, &iov, &iov_count, &max_data, &free_after);
*size = max_data;
if( rc < 0 ) {
MCA_BMI_TEMPLATE_FRAG_RETURN_MAX(bmi, frag);
return NULL;
}
frag->segment.seg_len = max_data + reserve;
}
frag->base.des_src = &frag->segment;
frag->base.des_src_cnt = 1;
frag->base.des_dst = NULL;
frag->base.des_dst_cnt = 0;
frag->base.des_flags = 0;
return &frag->base;
}
/**
* Prepare a descriptor for send/rdma using the supplied
* convertor. If the convertor references data that is contigous,
* the descriptor may simply point to the user buffer. Otherwise,
* this routine is responsible for allocating buffer space and
* packing if required.
*
* @param bmi (IN) BMI module
* @param endpoint (IN) BMI peer addressing
* @param convertor (IN) Data type convertor
* @param reserve (IN) Additional bytes requested by upper layer to precede user data
* @param size (IN/OUT) Number of bytes to prepare (IN), number of bytes actually prepared (OUT)
*/
mca_bmi_base_descriptor_t* mca_bmi_template_prepare_dst(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* endpoint,
struct mca_mpool_base_registration_t* registration,
struct ompi_convertor_t* convertor,
size_t reserve,
size_t* size)
{
mca_bmi_template_module_t* template_bmi = (mca_bmi_template_module_t*) bmi;
mca_bmi_template_frag_t* frag;
int rc;
MCA_BMI_TEMPLATE_FRAG_ALLOC_USER(bmi, frag, rc);
if(NULL == frag) {
return NULL;
}
frag->segment.seg_len = *size;
frag->segment.seg_addr.pval = convertor->pBaseBuf + convertor->bConverted;
frag->base.des_src = NULL;
frag->base.des_src_cnt = 0;
frag->base.des_dst = &frag->segment;
frag->base.des_dst_cnt = 1;
frag->base.des_flags = 0;
#if MCA_BMI_HAS_MPOOL
if(NULL != registration) {
size_t reg_len = (unsigned char*)registration->bound - (unsigned char*)frag->segment.seg_addr.pval + 1;
if(frag->segment.seg_len > reg_len) {
mca_mpool_base_module_t* mpool = template_bmi->template_mpool;
size_t new_len = (unsigned char*)frag->segment.seg_addr.pval - registration->base + frag->segment.seg_len;
void* base_addr = registration->base;
/* remove old registration from tree and decrement reference count */
mca_mpool_base_remove(base_addr);
OBJ_RELEASE(registration);
/* re-register at new size */
rc = mpool->mpool_register(
mpool,
base_addr,
new_len,
&registration);
if(rc != OMPI_SUCCESS) {
MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi,frag);
return NULL;
}
/* re-insert into tree with new registration */
rc = mca_mpool_base_insert(
base_addr,
new_len,
mpool,
bmi,
registration);
if(rc != OMPI_SUCCESS) {
MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi,frag);
OBJ_RELEASE(registration);
return NULL;
}
}
/* bump reference count as so that the registration
* doesn't go away when the operation completes
*/
OBJ_RETAIN(registration);
frag->registration = registration;
} else {
mca_mpool_base_module_t* mpool = template_bmi->template_mpool;
rc = mpool->mpool_register(
mpool,
frag->segment.seg_addr.pval,
frag->segment.seg_len,
&registration);
if(rc != OMPI_SUCCESS) {
MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi,frag);
return NULL;
}
if(mca_bmi_template_component.leave_pinned) {
/*
* insert the registration into the tree and bump the reference
* count so that it doesn't go away on completion.
*/
rc = mca_mpool_base_insert(
frag->segment.seg_addr.pval,
frag->segment.seg_len,
mpool,
bmi,
registration);
if(rc != OMPI_SUCCESS) {
MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi,frag);
OBJ_RELEASE(registration);
return NULL;
}
OBJ_RETAIN(registration);
}
frag->registration = registration;
}
#endif
return &frag->base;
}
/**
* Initiate an asynchronous send.
*
* @param bmi (IN) BMI module
* @param endpoint (IN) BMI addressing information
* @param descriptor (IN) Description of the data to be transfered
* @param tag (IN) The tag value used to notify the peer.
*/
int mca_bmi_template_send(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* endpoint,
struct mca_bmi_base_descriptor_t* descriptor,
mca_bmi_base_tag_t tag)
{
/* mca_bmi_template_module_t* template_bmi = (mca_bmi_template_module_t*) bmi; */
mca_bmi_template_frag_t* frag = (mca_bmi_template_frag_t*)descriptor;
frag->endpoint = endpoint;
/* TODO */
return OMPI_ERR_NOT_IMPLEMENTED;
}
/**
* Initiate an asynchronous put.
*
* @param bmi (IN) BMI module
* @param endpoint (IN) BMI addressing information
* @param descriptor (IN) Description of the data to be transferred
*/
int mca_bmi_template_put(
mca_bmi_base_module_t* bmi,
mca_bmi_base_endpoint_t* endpoint,
mca_bmi_base_descriptor_t* descriptor)
{
/* mca_bmi_template_module_t* template_bmi = (mca_bmi_template_module_t*) bmi; */
mca_bmi_template_frag_t* frag = (mca_bmi_template_frag_t*) descriptor;
frag->endpoint = endpoint;
/* TODO */
return OMPI_ERR_NOT_IMPLEMENTED;
}
/**
* Initiate an asynchronous get.
*
* @param bmi (IN) BMI module
* @param endpoint (IN) BMI addressing information
* @param descriptor (IN) Description of the data to be transferred
*
*/
int mca_bmi_template_get(
mca_bmi_base_module_t* bmi,
mca_bmi_base_endpoint_t* endpoint,
mca_bmi_base_descriptor_t* descriptor)
{
/* mca_bmi_template_module_t* template_bmi = (mca_bmi_template_module_t*) bmi; */
mca_bmi_template_frag_t* frag = (mca_bmi_template_frag_t*) descriptor;
frag->endpoint = endpoint;
/* TODO */
return OMPI_ERR_NOT_IMPLEMENTED;
}
/*
* Cleanup/release module resources.
*/
int mca_bmi_template_finalize(struct mca_bmi_base_module_t* bmi)
{
mca_bmi_template_module_t* template_bmi = (mca_bmi_template_module_t*) bmi;
if(template_bmi->template_frag_eager.fl_num_allocated !=
template_bmi->template_frag_eager.super.ompi_list_length){
ompi_output(0, "bmi template_frag_eager: %d allocated %d returned \n",
template_bmi->template_frag_eager.fl_num_allocated,
template_bmi->template_frag_eager.super.ompi_list_length);
}
if(template_bmi->template_frag_max.fl_num_allocated !=
template_bmi->template_frag_max.super.ompi_list_length) {
ompi_output(0, "bmi template_frag_max: %d allocated %d returned \n",
template_bmi->template_frag_max.fl_num_allocated,
template_bmi->template_frag_max.super.ompi_list_length);
}
if(template_bmi->template_frag_user.fl_num_allocated !=
template_bmi->template_frag_user.super.ompi_list_length){
ompi_output(0, "bmi template_frag_user: %d allocated %d returned \n",
template_bmi->template_frag_user.fl_num_allocated,
template_bmi->template_frag_user.super.ompi_list_length);
}
OBJ_DESTRUCT(&template_bmi->template_lock);
OBJ_DESTRUCT(&template_bmi->template_frag_eager);
OBJ_DESTRUCT(&template_bmi->template_frag_max);
OBJ_DESTRUCT(&template_bmi->template_frag_user);
free(template_bmi);
return OMPI_SUCCESS;
}

311
src/mca/bmi/template/bmi_template.h Обычный файл
Просмотреть файл

@ -0,0 +1,311 @@
/*
* 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.
* 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$
*/
/**
* @file
*/
#ifndef MCA_PTL_TEMPLATE_H
#define MCA_PTL_TEMPLATE_H
/* Standard system includes */
#include <sys/types.h>
#include <string.h>
/* Open MPI includes */
#include "class/ompi_free_list.h"
#include "class/ompi_bitmap.h"
#include "event/event.h"
#include "mca/pml/pml.h"
#include "mca/bmi/bmi.h"
#include "mca/bmi/base/base.h"
#include "util/output.h"
#include "mca/mpool/mpool.h"
#include "mca/bmi/bmi.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
#define MCA_BMI_HAS_MPOOL 1
/**
* Infiniband (TEMPLATE) BMI component.
*/
struct mca_bmi_template_component_t {
mca_bmi_base_component_1_0_0_t super; /**< base BMI component */
uint32_t template_num_bmis;
/**< number of hcas available to the TEMPLATE component */
struct mca_bmi_template_module_t *template_bmis;
/**< array of available BMI modules */
int template_free_list_num;
/**< initial size of free lists */
int template_free_list_max;
/**< maximum size of free lists */
int template_free_list_inc;
/**< number of elements to alloc when growing free lists */
ompi_list_t template_procs;
/**< list of template proc structures */
ompi_mutex_t template_lock;
/**< lock for accessing module state */
char* template_mpool_name;
/**< name of memory pool */
bool leave_pinned;
/**< pin memory on first use and leave pinned */
};
typedef struct mca_bmi_template_component_t mca_bmi_template_component_t;
extern mca_bmi_template_component_t mca_bmi_template_component;
/**
* BMI Module Interface
*/
struct mca_bmi_template_module_t {
mca_bmi_base_module_t super; /**< base BMI interface */
mca_bmi_base_recv_reg_t template_reg[256];
/* free list of fragment descriptors */
ompi_free_list_t template_frag_eager;
ompi_free_list_t template_frag_max;
ompi_free_list_t template_frag_user;
/* lock for accessing module state */
ompi_mutex_t template_lock;
#if MCA_BMI_HAS_MPOOL
struct mca_mpool_base_module_t* template_mpool;
#endif
};
typedef struct mca_bmi_template_module_t mca_bmi_template_module_t;
extern mca_bmi_template_module_t mca_bmi_template_module;
/**
* Register TEMPLATE component parameters with the MCA framework
*/
extern int mca_bmi_template_component_open(void);
/**
* Any final cleanup before being unloaded.
*/
extern int mca_bmi_template_component_close(void);
/**
* TEMPLATE component initialization.
*
* @param num_bmi_modules (OUT) Number of BMIs returned in BMI array.
* @param allow_multi_user_threads (OUT) Flag indicating wether BMI supports user threads (TRUE)
* @param have_hidden_threads (OUT) Flag indicating wether BMI uses threads (TRUE)
*/
extern mca_bmi_base_module_t** mca_bmi_template_component_init(
int *num_bmi_modules,
bool allow_multi_user_threads,
bool have_hidden_threads
);
/**
* TEMPLATE component progress.
*/
extern int mca_bmi_template_component_progress(void);
/**
* Cleanup any resources held by the BMI.
*
* @param bmi BMI instance.
* @return OMPI_SUCCESS or error status on failure.
*/
extern int mca_bmi_template_finalize(
struct mca_bmi_base_module_t* bmi
);
/**
* PML->BMI notification of change in the process list.
*
* @param bmi (IN)
* @param nprocs (IN) Number of processes
* @param procs (IN) Set of processes
* @param peers (OUT) Set of (optional) peer addressing info.
* @param peers (IN/OUT) Set of processes that are reachable via this BMI.
* @return OMPI_SUCCESS or error status on failure.
*
*/
extern int mca_bmi_template_add_procs(
struct mca_bmi_base_module_t* bmi,
size_t nprocs,
struct ompi_proc_t **procs,
struct mca_bmi_base_endpoint_t** peers,
ompi_bitmap_t* reachable
);
/**
* PML->BMI notification of change in the process list.
*
* @param bmi (IN) BMI instance
* @param nproc (IN) Number of processes.
* @param procs (IN) Set of processes.
* @param peers (IN) Set of peer data structures.
* @return Status indicating if cleanup was successful
*
*/
extern int mca_bmi_template_del_procs(
struct mca_bmi_base_module_t* bmi,
size_t nprocs,
struct ompi_proc_t **procs,
struct mca_bmi_base_endpoint_t** peers
);
/**
* Initiate an asynchronous send.
*
* @param bmi (IN) BMI module
* @param endpoint (IN) BMI addressing information
* @param descriptor (IN) Description of the data to be transfered
* @param tag (IN) The tag value used to notify the peer.
*/
extern int mca_bmi_template_send(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* bmi_peer,
struct mca_bmi_base_descriptor_t* descriptor,
mca_bmi_base_tag_t tag
);
/**
* Initiate an asynchronous put.
*
* @param bmi (IN) BMI module
* @param endpoint (IN) BMI addressing information
* @param descriptor (IN) Description of the data to be transferred
*/
extern int mca_bmi_template_put(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* bmi_peer,
struct mca_bmi_base_descriptor_t* decriptor
);
/**
* Initiate an asynchronous get.
*
* @param bmi (IN) BMI module
* @param endpoint (IN) BMI addressing information
* @param descriptor (IN) Description of the data to be transferred
*/
extern int mca_bmi_template_get(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* bmi_peer,
struct mca_bmi_base_descriptor_t* decriptor
);
/**
* Register a callback function that is called on receipt
* of a fragment.
*
* @param bmi (IN) BMI module
* @return Status indicating if registration was successful
*
*/
extern int mca_bmi_template_register(
struct mca_bmi_base_module_t* bmi,
mca_bmi_base_tag_t tag,
mca_bmi_base_module_recv_cb_fn_t cbfunc,
void* cbdata);
/**
* Allocate a descriptor with a segment of the requested size.
* Note that the BMI layer may choose to return a smaller size
* if it cannot support the request.
*
* @param bmi (IN) BMI module
* @param size (IN) Request segment size.
*/
extern mca_bmi_base_descriptor_t* mca_bmi_template_alloc(
struct mca_bmi_base_module_t* bmi,
size_t size);
/**
* Return a segment allocated by this BMI.
*
* @param bmi (IN) BMI module
* @param descriptor (IN) Allocated descriptor.
*/
extern int mca_bmi_template_free(
struct mca_bmi_base_module_t* bmi,
mca_bmi_base_descriptor_t* des);
/**
* Prepare a descriptor for send/rdma using the supplied
* convertor. If the convertor references data that is contigous,
* the descriptor may simply point to the user buffer. Otherwise,
* this routine is responsible for allocating buffer space and
* packing if required.
*
* @param bmi (IN) BMI module
* @param endpoint (IN) BMI peer addressing
* @param convertor (IN) Data type convertor
* @param reserve (IN) Additional bytes requested by upper layer to precede user data
* @param size (IN/OUT) Number of bytes to prepare (IN), number of bytes actually prepared (OUT)
*/
mca_bmi_base_descriptor_t* mca_bmi_template_prepare_src(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* peer,
struct mca_mpool_base_registration_t*,
struct ompi_convertor_t* convertor,
size_t reserve,
size_t* size
);
extern mca_bmi_base_descriptor_t* mca_bmi_template_prepare_dst(
struct mca_bmi_base_module_t* bmi,
struct mca_bmi_base_endpoint_t* peer,
struct mca_mpool_base_registration_t*,
struct ompi_convertor_t* convertor,
size_t reserve,
size_t* size);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif

168
src/mca/bmi/template/bmi_template_component.c Обычный файл
Просмотреть файл

@ -0,0 +1,168 @@
/*
* 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.
* 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"
#include "include/constants.h"
#include "event/event.h"
#include "util/if.h"
#include "util/argv.h"
#include "util/output.h"
#include "mca/pml/pml.h"
#include "mca/bmi/bmi.h"
#include "mca/base/mca_base_param.h"
#include "mca/base/mca_base_module_exchange.h"
#include "mca/errmgr/errmgr.h"
#include "mca/mpool/base/base.h"
#include "bmi_template.h"
#include "bmi_template_frag.h"
#include "bmi_template_endpoint.h"
#include "mca/bmi/base/base.h"
#include "datatype/convertor.h"
mca_bmi_template_component_t mca_bmi_template_component = {
{
/* First, the mca_base_component_t struct containing meta information
about the component itself */
{
/* Indicate that we are a pml v1.0.0 component (which also implies a
specific MCA version) */
MCA_BMI_BASE_VERSION_1_0_0,
"ib", /* MCA component name */
1, /* MCA component major version */
0, /* MCA component minor version */
0, /* MCA component release version */
mca_bmi_template_component_open, /* component open */
mca_bmi_template_component_close /* component close */
},
/* Next the MCA v1.0.0 component meta data */
{
/* Whether the component is checkpointable or not */
false
},
mca_bmi_template_component_init,
mca_bmi_template_component_progress,
}
};
/*
* utility routines for parameter registration
*/
static inline char* mca_bmi_template_param_register_string(
const char* param_name,
const char* default_value)
{
char *param_value;
int id = mca_base_param_register_string("bmi","ib",param_name,NULL,default_value);
mca_base_param_lookup_string(id, &param_value);
return param_value;
}
static inline int mca_bmi_template_param_register_int(
const char* param_name,
int default_value)
{
int id = mca_base_param_register_int("bmi","ib",param_name,NULL,default_value);
int param_value = default_value;
mca_base_param_lookup_int(id,&param_value);
return param_value;
}
/*
* Called by MCA framework to open the component, registers
* component parameters.
*/
int mca_bmi_template_component_open(void)
{
/* initialize state */
mca_bmi_template_component.template_num_bmis=0;
mca_bmi_template_component.template_bmis=NULL;
/* initialize objects */
OBJ_CONSTRUCT(&mca_bmi_template_component.template_procs, ompi_list_t);
/* register TEMPLATE component parameters */
mca_bmi_template_component.template_free_list_num =
mca_bmi_template_param_register_int ("free_list_num", 8);
mca_bmi_template_component.template_free_list_max =
mca_bmi_template_param_register_int ("free_list_max", 1024);
mca_bmi_template_component.template_free_list_inc =
mca_bmi_template_param_register_int ("free_list_inc", 32);
mca_bmi_template_component.template_mpool_name =
mca_bmi_template_param_register_string("mpool", "ib");
mca_bmi_template_module.super.bmi_exclusivity =
mca_bmi_template_param_register_int ("exclusivity", 0);
mca_bmi_template_module.super.bmi_eager_limit =
mca_bmi_template_param_register_int ("first_frag_size", 64*1024) - sizeof(mca_bmi_base_header_t);
mca_bmi_template_module.super.bmi_min_send_size =
mca_bmi_template_param_register_int ("min_send_size", 64*1024) - sizeof(mca_bmi_base_header_t);
mca_bmi_template_module.super.bmi_max_send_size =
mca_bmi_template_param_register_int ("max_send_size", 128*1024) - sizeof(mca_bmi_base_header_t);
mca_bmi_template_module.super.bmi_min_rdma_size =
mca_bmi_template_param_register_int("min_rdma_size", 1024*1024);
mca_bmi_template_module.super.bmi_max_rdma_size =
mca_bmi_template_param_register_int("max_rdma_size", 1024*1024);
mca_bmi_template_module.super.bmi_flags =
mca_bmi_template_param_register_int("flags", MCA_BMI_FLAGS_RDMA);
return OMPI_SUCCESS;
}
/*
* component cleanup - sanity checking of queue lengths
*/
int mca_bmi_template_component_close(void)
{
return OMPI_SUCCESS;
}
/*
* TEMPLATE component initialization:
* (1) read interface list from kernel and compare against component parameters
* then create a BMI instance for selected interfaces
* (2) setup TEMPLATE listen socket for incoming connection attempts
* (3) register BMI parameters with the MCA
*/
mca_bmi_base_module_t** mca_bmi_template_component_init(int *num_bmi_modules,
bool enable_progress_threads,
bool enable_mpi_threads)
{
return NULL;
}
/*
* TEMPLATE component progress.
*/
int mca_bmi_template_component_progress()
{
return 0;
}

Просмотреть файл

@ -0,0 +1,59 @@
/*
* 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.
* 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"
#include <sys/time.h>
#include <time.h>
#include "include/types.h"
#include "mca/ns/base/base.h"
#include "mca/oob/base/base.h"
#include "mca/rml/rml.h"
#include "mca/errmgr/errmgr.h"
#include "dps/dps.h"
#include "bmi_template.h"
#include "bmi_template_endpoint.h"
#include "bmi_template_proc.h"
#include "bmi_template_frag.h"
/*
* Initialize state of the endpoint instance.
*
*/
static void mca_bmi_template_endpoint_construct(mca_bmi_base_endpoint_t* endpoint)
{
endpoint->endpoint_bmi = 0;
endpoint->endpoint_proc = 0;
}
/*
* Destroy a endpoint
*
*/
static void mca_bmi_template_endpoint_destruct(mca_bmi_base_endpoint_t* endpoint)
{
}
OBJ_CLASS_INSTANCE(
mca_bmi_template_endpoint_t,
ompi_list_item_t,
mca_bmi_template_endpoint_construct,
mca_bmi_template_endpoint_destruct);

Просмотреть файл

@ -0,0 +1,56 @@
/*
* 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.
* 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$
*/
#ifndef MCA_BMI_TEMPLATE_ENDPOINT_H
#define MCA_BMI_TEMPLATE_ENDPOINT_H
#include "class/ompi_list.h"
#include "event/event.h"
#include "mca/pml/pml.h"
#include "mca/bmi/bmi.h"
#include "bmi_template_frag.h"
#include "bmi_template.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
OBJ_CLASS_DECLARATION(mca_bmi_template_endpoint_t);
/**
* An abstraction that represents a connection to a endpoint process.
* An instance of mca_bmi_base_endpoint_t is associated w/ each process
* and BMI pair at startup. However, connections to the endpoint
* are established dynamically on an as-needed basis:
*/
struct mca_bmi_base_endpoint_t {
ompi_list_item_t super;
struct mca_bmi_template_module_t* endpoint_bmi;
/**< BMI instance that created this connection */
struct mca_bmi_template_proc_t* endpoint_proc;
/**< proc structure corresponding to endpoint */
};
typedef struct mca_bmi_base_endpoint_t mca_bmi_base_endpoint_t;
typedef mca_bmi_base_endpoint_t mca_bmi_template_endpoint_t;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif

58
src/mca/bmi/template/bmi_template_frag.c Обычный файл
Просмотреть файл

@ -0,0 +1,58 @@
#include "bmi_template_frag.h"
static void mca_bmi_template_frag_common_constructor(mca_bmi_template_frag_t* frag)
{
mca_bmi_template_frag_common_constructor(frag);
frag->base.des_src = NULL;
frag->base.des_src_cnt = 0;
frag->base.des_dst = NULL;
frag->base.des_dst_cnt = 0;
}
static void mca_bmi_template_frag_eager_constructor(mca_bmi_template_frag_t* frag)
{
frag->registration = NULL;
frag->size = mca_bmi_template_module.super.bmi_eager_limit;
mca_bmi_template_frag_common_constructor(frag);
}
static void mca_bmi_template_frag_max_constructor(mca_bmi_template_frag_t* frag)
{
frag->registration = NULL;
frag->size = mca_bmi_template_module.super.bmi_max_send_size;
mca_bmi_template_frag_common_constructor(frag);
}
static void mca_bmi_template_frag_user_constructor(mca_bmi_template_frag_t* frag)
{
frag->size = 0;
mca_bmi_template_frag_common_constructor(frag);
}
OBJ_CLASS_INSTANCE(
mca_bmi_template_frag_t,
mca_bmi_base_descriptor_t,
NULL,
NULL);
OBJ_CLASS_INSTANCE(
mca_bmi_template_frag_eager_t,
mca_bmi_base_descriptor_t,
mca_bmi_template_frag_eager_constructor,
NULL);
OBJ_CLASS_INSTANCE(
mca_bmi_template_frag_max_t,
mca_bmi_base_descriptor_t,
mca_bmi_template_frag_max_constructor,
NULL);
OBJ_CLASS_INSTANCE(
mca_bmi_template_frag_user_t,
mca_bmi_base_descriptor_t,
mca_bmi_template_frag_user_constructor,
NULL);

114
src/mca/bmi/template/bmi_template_frag.h Обычный файл
Просмотреть файл

@ -0,0 +1,114 @@
/*
* 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.
* 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$
*/
#ifndef MCA_BMI_TEMPLATE_FRAG_H
#define MCA_BMI_TEMPLATE_FRAG_H
#define MCA_BMI_TEMPLATE_FRAG_ALIGN (8)
#include "ompi_config.h"
#include "bmi_template.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_bmi_template_frag_t);
/**
* TEMPLATE send fratemplateent derived type.
*/
struct mca_bmi_template_frag_t {
mca_bmi_base_descriptor_t base;
mca_bmi_base_segment_t segment;
struct mca_bmi_base_endpoint_t *endpoint;
mca_bmi_base_header_t *hdr;
size_t size;
#if MCA_BMI_HAS_MPOOL
struct mca_mpool_base_registration_t* registration;
#endif
};
typedef struct mca_bmi_template_frag_t mca_bmi_template_frag_t;
OBJ_CLASS_DECLARATION(mca_bmi_template_frag_t);
typedef struct mca_bmi_template_frag_t mca_bmi_template_frag_eager_t;
OBJ_CLASS_DECLARATION(mca_bmi_template_frag_eager_t);
typedef struct mca_bmi_template_frag_t mca_bmi_template_frag_max_t;
OBJ_CLASS_DECLARATION(mca_bmi_template_frag_max_t);
typedef struct mca_bmi_template_frag_t mca_bmi_template_frag_user_t;
OBJ_CLASS_DECLARATION(mca_bmi_template_frag_user_t);
/*
* Macros to allocate/return descriptors from module specific
* free list(s).
*/
#define MCA_BMI_TEMPLATE_FRAG_ALLOC_EAGER(bmi, frag, rc) \
{ \
\
ompi_list_item_t *item; \
OMPI_FREE_LIST_WAIT(&((mca_bmi_template_module_t*)bmi)->template_frag_eager, item, rc); \
frag = (mca_bmi_template_frag_t*) item; \
}
#define MCA_BMI_TEMPLATE_FRAG_RETURN_EAGER(bmi, frag) \
{ \
OMPI_FREE_LIST_RETURN(&((mca_bmi_template_module_t*)bmi)->template_frag_eager, \
(ompi_list_item_t*)(frag)); \
}
#define MCA_BMI_TEMPLATE_FRAG_ALLOC_MAX(bmi, frag, rc) \
{ \
\
ompi_list_item_t *item; \
OMPI_FREE_LIST_WAIT(&((mca_bmi_template_module_t*)bmi)->template_frag_max, item, rc); \
frag = (mca_bmi_template_frag_t*) item; \
}
#define MCA_BMI_TEMPLATE_FRAG_RETURN_MAX(bmi, frag) \
{ \
OMPI_FREE_LIST_RETURN(&((mca_bmi_template_module_t*)bmi)->template_frag_max, \
(ompi_list_item_t*)(frag)); \
}
#define MCA_BMI_TEMPLATE_FRAG_ALLOC_USER(bmi, frag, rc) \
{ \
ompi_list_item_t *item; \
OMPI_FREE_LIST_WAIT(&((mca_bmi_template_module_t*)bmi)->template_frag_user, item, rc); \
frag = (mca_bmi_template_frag_t*) item; \
}
#define MCA_BMI_TEMPLATE_FRAG_RETURN_USER(bmi, frag) \
{ \
OMPI_FREE_LIST_RETURN(&((mca_bmi_template_module_t*)bmi)->template_frag_user, \
(ompi_list_item_t*)(frag)); \
}
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif

160
src/mca/bmi/template/bmi_template_proc.c Обычный файл
Просмотреть файл

@ -0,0 +1,160 @@
/*
* 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.
* 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"
#include "class/ompi_hash_table.h"
#include "mca/base/mca_base_module_exchange.h"
#include "bmi_template.h"
#include "bmi_template_proc.h"
static void mca_bmi_template_proc_construct(mca_bmi_template_proc_t* proc);
static void mca_bmi_template_proc_destruct(mca_bmi_template_proc_t* proc);
OBJ_CLASS_INSTANCE(mca_bmi_template_proc_t,
ompi_list_item_t, mca_bmi_template_proc_construct,
mca_bmi_template_proc_destruct);
void mca_bmi_template_proc_construct(mca_bmi_template_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, ompi_mutex_t);
/* add to list of all proc instance */
OMPI_THREAD_LOCK(&mca_bmi_template_component.template_lock);
ompi_list_append(&mca_bmi_template_component.template_procs, &proc->super);
OMPI_THREAD_UNLOCK(&mca_bmi_template_component.template_lock);
}
/*
* Cleanup ib proc instance
*/
void mca_bmi_template_proc_destruct(mca_bmi_template_proc_t* proc)
{
/* remove from list of all proc instances */
OMPI_THREAD_LOCK(&mca_bmi_template_component.template_lock);
ompi_list_remove_item(&mca_bmi_template_component.template_procs, &proc->super);
OMPI_THREAD_UNLOCK(&mca_bmi_template_component.template_lock);
/* release resources */
if(NULL != proc->proc_endpoints) {
free(proc->proc_endpoints);
}
}
/*
* Look for an existing TEMPLATE process instances based on the associated
* ompi_proc_t instance.
*/
static mca_bmi_template_proc_t* mca_bmi_template_proc_lookup_ompi(ompi_proc_t* ompi_proc)
{
mca_bmi_template_proc_t* template_proc;
OMPI_THREAD_LOCK(&mca_bmi_template_component.template_lock);
for(template_proc = (mca_bmi_template_proc_t*)
ompi_list_get_first(&mca_bmi_template_component.template_procs);
template_proc != (mca_bmi_template_proc_t*)
ompi_list_get_end(&mca_bmi_template_component.template_procs);
template_proc = (mca_bmi_template_proc_t*)ompi_list_get_next(template_proc)) {
if(template_proc->proc_ompi == ompi_proc) {
OMPI_THREAD_UNLOCK(&mca_bmi_template_component.template_lock);
return template_proc;
}
}
OMPI_THREAD_UNLOCK(&mca_bmi_template_component.template_lock);
return NULL;
}
/*
* Create a TEMPLATE process structure. There is a one-to-one correspondence
* between a ompi_proc_t and a mca_bmi_template_proc_t instance. We cache
* additional data (specifically the list of mca_bmi_template_endpoint_t instances,
* and published addresses) associated w/ a given destination on this
* datastructure.
*/
mca_bmi_template_proc_t* mca_bmi_template_proc_create(ompi_proc_t* ompi_proc)
{
mca_bmi_template_proc_t* module_proc = NULL;
/* Check if we have already created a TEMPLATE proc
* structure for this ompi process */
module_proc = mca_bmi_template_proc_lookup_ompi(ompi_proc);
if(module_proc != NULL) {
/* Gotcha! */
return module_proc;
}
/* Oops! First time, gotta create a new TEMPLATE proc
* out of the ompi_proc ... */
module_proc = OBJ_NEW(mca_bmi_template_proc_t);
/* Initialize number of peer */
module_proc->proc_endpoint_count = 0;
module_proc->proc_ompi = ompi_proc;
/* build a unique identifier (of arbitrary
* size) to represent the proc */
module_proc->proc_guid = ompi_proc->proc_name;
/* TEMPLATE module doesn't have addresses exported at
* initialization, so the addr_count is set to one. */
module_proc->proc_addr_count = 1;
/* XXX: Right now, there can be only 1 peer associated
* with a proc. Needs a little bit change in
* mca_bmi_template_proc_t to allow on demand increasing of
* number of endpoints for this proc */
module_proc->proc_endpoints = (mca_bmi_base_endpoint_t**)
malloc(module_proc->proc_addr_count * sizeof(mca_bmi_base_endpoint_t*));
if(NULL == module_proc->proc_endpoints) {
OBJ_RELEASE(module_proc);
return NULL;
}
return module_proc;
}
/*
* Note that this routine must be called with the lock on the process
* already held. Insert a bmi instance into the proc array and assign
* it an address.
*/
int mca_bmi_template_proc_insert(mca_bmi_template_proc_t* module_proc,
mca_bmi_base_endpoint_t* module_endpoint)
{
/* insert into endpoint array */
module_endpoint->endpoint_proc = module_proc;
module_proc->proc_endpoints[module_proc->proc_endpoint_count++] = module_endpoint;
return OMPI_SUCCESS;
}

67
src/mca/bmi/template/bmi_template_proc.h Обычный файл
Просмотреть файл

@ -0,0 +1,67 @@
/*
* 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.
* 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$
*/
#ifndef MCA_BMI_TEMPLATE_PROC_H
#define MCA_BMI_TEMPLATE_PROC_H
#include "mca/ns/ns.h"
#include "class/ompi_object.h"
#include "proc/proc.h"
#include "bmi_template.h"
#include "bmi_template_endpoint.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
OBJ_CLASS_DECLARATION(mca_bmi_template_proc_t);
/**
* Represents the state of a remote process and the set of addresses
* that it exports. Also cache an instance of mca_bmi_base_endpoint_t for
* each
* BMI instance that attempts to open a connection to the process.
*/
struct mca_bmi_template_proc_t {
ompi_list_item_t super;
/**< allow proc to be placed on a list */
ompi_proc_t *proc_ompi;
/**< pointer to corresponding ompi_proc_t */
orte_process_name_t proc_guid;
/**< globally unique identifier for the process */
size_t proc_addr_count;
/**< number of addresses published by endpoint */
struct mca_bmi_base_endpoint_t **proc_endpoints;
/**< array of endpoints that have been created to access this proc */
size_t proc_endpoint_count;
/**< number of endpoints */
ompi_mutex_t proc_lock;
/**< lock to protect against concurrent access to proc state */
};
typedef struct mca_bmi_template_proc_t mca_bmi_template_proc_t;
mca_bmi_template_proc_t* mca_bmi_template_proc_create(ompi_proc_t* ompi_proc);
int mca_bmi_template_proc_insert(mca_bmi_template_proc_t*, mca_bmi_base_endpoint_t*);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif

22
src/mca/bmi/template/configure.params Обычный файл
Просмотреть файл

@ -0,0 +1,22 @@
# -*- shell-script -*-
#
# 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.
# 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$
#
# Specific to this module
PARAM_INIT_FILE=bmi_template.c
PARAM_CONFIG_HEADER_FILE="template_config.h"
PARAM_CONFIG_FILES="Makefile"