2005-06-21 23:38:50 +04:00
|
|
|
|
2005-05-24 02:06:50 +04: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.
|
|
|
|
* 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
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
#ifndef MCA_BTL_SM_H
|
|
|
|
#define MCA_BTL_SM_H
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
2005-07-14 08:11:59 +04:00
|
|
|
#ifdef HAVE_NETINET_IN_H
|
2005-05-24 02:06:50 +04:00
|
|
|
#include <netinet/in.h>
|
2005-07-14 08:11:59 +04:00
|
|
|
#endif
|
2005-09-12 00:55:22 +04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2005-05-24 02:06:50 +04:00
|
|
|
#include "class/ompi_free_list.h"
|
|
|
|
#include "class/ompi_bitmap.h"
|
|
|
|
#include "class/ompi_fifo.h"
|
2005-07-04 03:09:55 +04:00
|
|
|
#include "opal/event/event.h"
|
2005-05-24 02:06:50 +04:00
|
|
|
#include "mca/pml/pml.h"
|
2005-06-30 09:50:55 +04:00
|
|
|
#include "mca/btl/btl.h"
|
|
|
|
#include "mca/btl/base/base.h"
|
2005-06-21 23:38:50 +04:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
#include "mca/mpool/mpool.h"
|
|
|
|
#include "mca/common/sm/common_sm_mmap.h"
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Shared Memory resource managment
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
struct mca_btl_sm_module_resource_t {
|
2005-05-24 02:06:50 +04:00
|
|
|
/* base control structures */
|
|
|
|
mca_common_sm_file_header_t segment_header;
|
|
|
|
|
|
|
|
/* fifo queues - offsets relative to the base of the share memory
|
|
|
|
* segment will be stored here */
|
|
|
|
volatile ompi_fifo_t **fifo;
|
|
|
|
};
|
2005-06-30 09:50:55 +04:00
|
|
|
typedef struct mca_btl_sm_module_resource_t mca_btl_sm_module_resource_t;
|
|
|
|
extern mca_btl_sm_module_resource_t mca_btl_sm_module_resource;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
#define SM_CONNECTED 1
|
|
|
|
#define SM_CONNECTED_SAME_BASE_ADDR 2
|
|
|
|
#define SM_CONNECTED_DIFFERENT_BASE_ADDR 3
|
|
|
|
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
|
|
|
#define DATA (char)0
|
|
|
|
#define DONE (char)1
|
|
|
|
#endif
|
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
typedef mca_btl_base_recv_reg_t mca_btl_sm_recv_reg_t;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-06-30 09:50:55 +04:00
|
|
|
* Shared Memory (SM) BTL module.
|
2005-05-24 02:06:50 +04:00
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
struct mca_btl_sm_component_t {
|
|
|
|
mca_btl_base_component_1_0_0_t super; /**< base BTL component */
|
2005-05-24 02:06:50 +04:00
|
|
|
int sm_free_list_num; /**< initial size of free lists */
|
|
|
|
int sm_free_list_max; /**< maximum size of free lists */
|
|
|
|
int sm_free_list_inc; /**< number of elements to alloc when growing free lists */
|
|
|
|
int sm_max_procs; /**< upper limit on the number of processes using the shared memory pool */
|
|
|
|
int sm_extra_procs; /**< number of extra procs to allow */
|
|
|
|
char* sm_mpool_name; /**< name of shared memory pool module */
|
|
|
|
mca_mpool_base_module_t* sm_mpool; /**< shared memory pool */
|
|
|
|
void* sm_mpool_base; /**< base address of shared memory pool */
|
2005-06-02 01:09:43 +04:00
|
|
|
size_t eager_limit; /**< first fragment size */
|
|
|
|
size_t max_frag_size; /**< maximum (second and beyone) fragment size */
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_mutex_t sm_lock;
|
2005-05-24 02:06:50 +04:00
|
|
|
char* sm_resouce_ctl_file; /**< name of shared memory file used
|
|
|
|
to coordinate resource usage */
|
|
|
|
mca_common_sm_mmap_t *mmap_file; /**< description of mmap'ed file */
|
2005-06-30 09:50:55 +04:00
|
|
|
mca_btl_sm_module_resource_t *sm_ctl_header; /* control header in
|
2005-05-24 02:06:50 +04:00
|
|
|
shared memory */
|
|
|
|
ompi_fifo_t **fifo; /**< cached copy of the pointer to the 2D
|
|
|
|
fifo array. The address in the shared
|
|
|
|
memory segment sm_ctl_header is a relative,
|
|
|
|
but this one, in process private memory, is
|
|
|
|
a real virtual address */
|
|
|
|
size_t size_of_cb_queue; /**< size of each circular buffer queue array */
|
|
|
|
size_t cb_lazy_free_freq; /**< frequency of lazy free */
|
|
|
|
ssize_t *sm_offset; /**< offset to be applied to shared memory
|
|
|
|
addresses, per local process value */
|
2005-06-30 09:50:55 +04:00
|
|
|
int *sm_proc_connect; /* scratch array used by the 0'th btl to
|
2005-05-24 02:06:50 +04:00
|
|
|
* set indicate sm connectivty. Used by
|
2005-06-30 09:50:55 +04:00
|
|
|
* the 1'st btl */
|
2005-05-24 02:06:50 +04:00
|
|
|
size_t num_smp_procs; /**< current number of smp procs on this
|
|
|
|
host */
|
|
|
|
int num_smp_procs_same_base_addr; /* number of procs with same
|
|
|
|
base shared memory virtual
|
|
|
|
address as this process */
|
|
|
|
int num_smp_procs_different_base_addr; /* number of procs with
|
|
|
|
different base shared memory
|
|
|
|
virtual address as this
|
|
|
|
process */
|
|
|
|
int *list_smp_procs_same_base_addr; /* number of procs with same
|
|
|
|
base shared memory virtual
|
|
|
|
address as this process */
|
|
|
|
int *list_smp_procs_different_base_addr; /* number of procs with different
|
|
|
|
base shared memory virtual
|
|
|
|
address as this process */
|
|
|
|
uint32_t my_smp_rank; /**< My SMP process rank. Used for accessing
|
|
|
|
* SMP specfic data structures. */
|
|
|
|
ompi_free_list_t sm_frags1; /**< free list of sm first */
|
|
|
|
ompi_free_list_t sm_frags2; /**< free list of sm second */
|
|
|
|
ompi_free_list_t sm_first_frags_to_progress; /**< list of first
|
|
|
|
fragments that are
|
|
|
|
awaiting resources */
|
2005-06-30 09:50:55 +04:00
|
|
|
struct mca_btl_base_endpoint_t **sm_peers;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
|
|
|
char sm_fifo_path[PATH_MAX]; /**< path to fifo used to signal this process */
|
|
|
|
int sm_fifo_fd; /**< file descriptor corresponding to opened fifo */
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_thread_t sm_fifo_thread;
|
2005-05-24 02:06:50 +04:00
|
|
|
#endif
|
|
|
|
};
|
2005-06-30 09:50:55 +04:00
|
|
|
typedef struct mca_btl_sm_component_t mca_btl_sm_component_t;
|
|
|
|
extern mca_btl_sm_component_t mca_btl_sm_component;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register shared memory module parameters with the MCA framework
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_component_open(void);
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Any final cleanup before being unloaded.
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_component_close(void);
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SM module initialization.
|
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param num_btls (OUT) Number of BTLs returned in BTL array.
|
|
|
|
* @param enable_progress_threads (IN) Flag indicating whether BTL is allowed to have progress threads
|
|
|
|
* @param enable_mpi_threads (IN) Flag indicating whether BTL must support multilple simultaneous invocations from different threads
|
2005-05-24 02:06:50 +04:00
|
|
|
*
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
extern mca_btl_base_module_t** mca_btl_sm_component_init(
|
|
|
|
int *num_btls,
|
2005-05-24 02:06:50 +04:00
|
|
|
bool enable_progress_threads,
|
|
|
|
bool enable_mpi_threads
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shared memory component progress.
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_component_progress(void);
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/**
|
2005-06-30 09:50:55 +04:00
|
|
|
* SM BTL Interface
|
2005-05-24 02:06:50 +04:00
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
struct mca_btl_sm_t {
|
|
|
|
mca_btl_base_module_t super; /**< base BTL interface */
|
|
|
|
bool btl_inited; /**< flag indicating if btl has been inited */
|
|
|
|
mca_btl_sm_recv_reg_t sm_reg[256];
|
2005-05-24 02:06:50 +04:00
|
|
|
};
|
2005-06-30 09:50:55 +04:00
|
|
|
typedef struct mca_btl_sm_t mca_btl_sm_t;
|
2005-05-24 02:06:50 +04:00
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
extern mca_btl_sm_t mca_btl_sm[2];
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-06-30 09:50:55 +04:00
|
|
|
* Cleanup any resources held by the BTL.
|
2005-05-24 02:06:50 +04:00
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param btl BTL instance.
|
2005-05-24 02:06:50 +04:00
|
|
|
* @return OMPI_SUCCESS or error status on failure.
|
|
|
|
*/
|
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_finalize(
|
|
|
|
struct mca_btl_base_module_t* btl
|
2005-05-24 02:06:50 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-06-30 09:50:55 +04:00
|
|
|
* PML->BTL notification of change in the process list.
|
|
|
|
* PML->BTL Notification that a receive fragment has been matched.
|
2005-05-24 02:06:50 +04:00
|
|
|
* Called for message that is send from process with the virtual
|
|
|
|
* address of the shared memory segment being different than that of
|
|
|
|
* the receiver.
|
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param btl (IN)
|
2005-05-24 02:06:50 +04:00
|
|
|
* @param proc (IN)
|
|
|
|
* @param peer (OUT)
|
|
|
|
* @return OMPI_SUCCESS or error status on failure.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_add_procs(
|
|
|
|
struct mca_btl_base_module_t* btl,
|
2005-05-24 02:06:50 +04:00
|
|
|
size_t nprocs,
|
|
|
|
struct ompi_proc_t **procs,
|
2005-06-30 09:50:55 +04:00
|
|
|
struct mca_btl_base_endpoint_t** peers,
|
2005-05-24 02:06:50 +04:00
|
|
|
struct ompi_bitmap_t* reachability
|
|
|
|
);
|
|
|
|
|
2005-07-15 19:22:41 +04:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/**
|
2005-06-30 09:50:55 +04:00
|
|
|
* PML->BTL notification of change in the process list.
|
|
|
|
* PML->BTL Notification that a receive fragment has been matched.
|
2005-05-24 02:06:50 +04:00
|
|
|
* Called for message that is send from process with the virtual
|
|
|
|
* address of the shared memory segment being the same as that of
|
|
|
|
* the receiver.
|
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param btl (IN)
|
2005-05-24 02:06:50 +04:00
|
|
|
* @param proc (IN)
|
|
|
|
* @param peer (OUT)
|
|
|
|
* @return OMPI_SUCCESS or error status on failure.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_add_procs_same_base_addr(
|
|
|
|
struct mca_btl_base_module_t* btl,
|
2005-05-24 02:06:50 +04:00
|
|
|
size_t nprocs,
|
|
|
|
struct ompi_proc_t **procs,
|
2005-06-30 09:50:55 +04:00
|
|
|
struct mca_btl_base_endpoint_t** peers,
|
2005-05-24 02:06:50 +04:00
|
|
|
ompi_bitmap_t* reachability
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-06-30 09:50:55 +04:00
|
|
|
* PML->BTL notification of change in the process list.
|
2005-05-24 02:06:50 +04:00
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param btl (IN) BTL instance
|
2005-05-24 02:06:50 +04:00
|
|
|
* @param proc (IN) Peer process
|
|
|
|
* @param peer (IN) Peer addressing information.
|
|
|
|
* @return Status indicating if cleanup was successful
|
|
|
|
*
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_del_procs(
|
|
|
|
struct mca_btl_base_module_t* btl,
|
2005-05-24 02:06:50 +04:00
|
|
|
size_t nprocs,
|
|
|
|
struct ompi_proc_t **procs,
|
2005-06-30 09:50:55 +04:00
|
|
|
struct mca_btl_base_endpoint_t **peers
|
2005-05-24 02:06:50 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a callback function that is called on receipt
|
|
|
|
* of a fragment.
|
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param btl (IN) BTL module
|
2005-05-24 02:06:50 +04:00
|
|
|
* @return Status indicating if cleanup was successful
|
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* When the process list changes, the PML notifies the BTL of the
|
2005-05-24 02:06:50 +04:00
|
|
|
* change, to provide the opportunity to cleanup or release any
|
|
|
|
* resources associated with the peer.
|
|
|
|
*/
|
|
|
|
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_register(
|
|
|
|
struct mca_btl_base_module_t* btl,
|
|
|
|
mca_btl_base_tag_t tag,
|
|
|
|
mca_btl_base_module_recv_cb_fn_t cbfunc,
|
2005-05-24 02:06:50 +04:00
|
|
|
void* cbdata
|
|
|
|
);
|
2005-07-15 19:22:41 +04:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a segment.
|
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param btl (IN) BTL module
|
2005-05-24 02:06:50 +04:00
|
|
|
* @param size (IN) Request segment size.
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
extern mca_btl_base_descriptor_t* mca_btl_sm_alloc(
|
|
|
|
struct mca_btl_base_module_t* btl,
|
2005-05-24 02:06:50 +04:00
|
|
|
size_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
2005-06-30 09:50:55 +04:00
|
|
|
* Return a segment allocated by this BTL.
|
2005-05-24 02:06:50 +04:00
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param btl (IN) BTL module
|
2005-05-24 02:06:50 +04:00
|
|
|
* @param segment (IN) Allocated segment.
|
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_free(
|
|
|
|
struct mca_btl_base_module_t* btl,
|
|
|
|
mca_btl_base_descriptor_t* segment
|
2005-05-24 02:06:50 +04:00
|
|
|
);
|
2005-07-15 19:22:41 +04:00
|
|
|
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/**
|
|
|
|
* Pack data
|
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param btl (IN) BTL module
|
|
|
|
* @param peer (IN) BTL peer addressing
|
2005-05-24 02:06:50 +04:00
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
struct mca_btl_base_descriptor_t* mca_btl_sm_prepare_src(
|
|
|
|
struct mca_btl_base_module_t* btl,
|
|
|
|
struct mca_btl_base_endpoint_t* endpoint,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t* registration,
|
2005-05-24 02:06:50 +04:00
|
|
|
struct ompi_convertor_t* convertor,
|
|
|
|
size_t reserve,
|
|
|
|
size_t* size
|
|
|
|
);
|
2005-07-15 19:22:41 +04:00
|
|
|
|
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
/**
|
|
|
|
* Initiate a send to the peer.
|
|
|
|
*
|
2005-06-30 09:50:55 +04:00
|
|
|
* @param btl (IN) BTL module
|
|
|
|
* @param peer (IN) BTL peer addressing
|
2005-05-24 02:06:50 +04:00
|
|
|
*/
|
2005-06-30 09:50:55 +04:00
|
|
|
extern int mca_btl_sm_send(
|
|
|
|
struct mca_btl_base_module_t* btl,
|
|
|
|
struct mca_btl_base_endpoint_t* endpoint,
|
|
|
|
struct mca_btl_base_descriptor_t* descriptor,
|
|
|
|
mca_btl_base_tag_t tag
|
2005-05-24 02:06:50 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
2005-07-03 20:06:07 +04:00
|
|
|
void mca_btl_sm_component_event_thread(opal_object_t*);
|
2005-05-24 02:06:50 +04:00
|
|
|
#endif
|
2005-07-15 19:22:41 +04:00
|
|
|
|
2005-05-24 02:06:50 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 1
|
2005-06-30 09:50:55 +04:00
|
|
|
#define MCA_BTL_SM_SIGNAL_PEER(peer) \
|
2005-05-24 02:06:50 +04:00
|
|
|
{ \
|
|
|
|
unsigned char cmd = DATA; \
|
|
|
|
if(write(peer->fifo_fd, &cmd, sizeof(cmd)) != sizeof(cmd)) { \
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "mca_btl_sm_send: write fifo failed: errno=%d\n", errno); \
|
2005-05-24 02:06:50 +04:00
|
|
|
} \
|
|
|
|
}
|
|
|
|
#else
|
2005-06-30 09:50:55 +04:00
|
|
|
#define MCA_BTL_SM_SIGNAL_PEER(peer)
|
2005-05-24 02:06:50 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|