diff --git a/src/mca/ptl/sm/src/ptl_sm.c b/src/mca/ptl/sm/src/ptl_sm.c index 22aa30ae3b..b1a08ff3e3 100644 --- a/src/mca/ptl/sm/src/ptl_sm.c +++ b/src/mca/ptl/sm/src/ptl_sm.c @@ -17,7 +17,7 @@ #include "util/sys_info.h" #include "mca/ptl/sm/src/ptl_sm_peer.h" #include "mca/mpool/sm/mpool_sm.h" - +#include "util/proc_info.h" mca_ptl_sm_t mca_ptl_sm = { { @@ -44,6 +44,9 @@ mca_ptl_sm_t mca_ptl_sm = { } }; +/* track information needed to synchronise a Shared Memory PTL module */ +mca_ptl_sm_module_resource_t mca_ptl_sm_module_resource; + int mca_ptl_sm_add_procs( struct mca_ptl_base_module_t* ptl, @@ -58,6 +61,12 @@ int mca_ptl_sm_add_procs( ompi_proc_t* my_proc; /* pointer to caller's proc structure */ mca_ptl_sm_t *ptl_sm; bool threads; + char file_name[PATH_MAX]; + + /* debug */ + fprintf(stderr," mca_ptlsm_add_procs \n"); + fflush(stderr); + /* end debug */ /* initialize the shared memory pool */ /*mca_mpool_component_lookup("sm"); */ @@ -151,6 +160,33 @@ int mca_ptl_sm_add_procs( } } + /* Allocate Shared Memory PTL process coordination + * data structure. This will reside in shared memory */ + + /* Create backing file */ + memset(&(file_name[0]),0,PATH_MAX); + if( (strlen(ompi_process_info.job_session_dir) + + strlen(ompi_system_info.nodename)+ + /* length of fixed-string name part */ + 23 ) >= PATH_MAX ) { + ompi_output(0, "mca_ptl_sm_add_procs: name of backing file too long \n"); + return_code=OMPI_ERROR; + goto CLEANUP; + } + sprintf(&(file_name[0]),"%s/shared_mem_ptl_module.%s", + ompi_process_info.job_session_dir, + ompi_system_info.nodename); + size=sizeof(mca_ptl_sm_module_resource_t); + if(NULL == + (mca_mpool_sm_component.sm_mmap = + mca_mpool_sm_mmap_init(size, &(file_name[0]), + sizeof(mca_ptl_sm_module_resource_t), 8 ))) + { + ompi_output(0, "mca_ptl_sm_add_procs: unable to create shared memory PTL coordinating strucure\n"); + return_code=OMPI_ERROR; + goto CLEANUP; + } + /* Allocate a fixed size pointer array for the 2-D Shared memory queues. * Excess slots will be allocated for future growth. One could * make this array growable, but then one would need to uses mutexes diff --git a/src/mca/ptl/sm/src/ptl_sm.h b/src/mca/ptl/sm/src/ptl_sm.h index 952c9c1a8d..88e6d642fe 100644 --- a/src/mca/ptl/sm/src/ptl_sm.h +++ b/src/mca/ptl/sm/src/ptl_sm.h @@ -15,6 +15,16 @@ #include "mca/pml/pml.h" #include "mca/ptl/ptl.h" #include "mca/mpool/mpool.h" +#include "mca/mpool/sm/mpool_sm_mmap.h" + +/* + * Shared Memory resource managment + */ +struct mca_ptl_sm_module_resource_t { + mca_mpool_sm_segment_t segment_header; +}; +typedef struct mca_ptl_sm_module_resource_t mca_ptl_sm_module_resource_t; +extern mca_ptl_sm_module_resource_t mca_ptl_sm_module_resource; /** * Shared Memory (SM) PTL module. diff --git a/src/mca/ptl/sm/src/ptl_sm_component.c b/src/mca/ptl/sm/src/ptl_sm_component.c index df9e7f0988..6e4d597b98 100644 --- a/src/mca/ptl/sm/src/ptl_sm_component.c +++ b/src/mca/ptl/sm/src/ptl_sm_component.c @@ -41,34 +41,29 @@ static int mca_ptl_sm_component_exchange(void); mca_ptl_sm_component_t mca_ptl_sm_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_PTL_BASE_VERSION_1_0_0, - - "sm", /* MCA component name */ - 1, /* MCA component major version */ - 0, /* MCA component minor version */ - 0, /* MCA component release version */ - mca_ptl_sm_component_open, /* component open */ - mca_ptl_sm_component_close /* component close */ - }, - - /* Next the MCA v1.0.0 component meta data */ - - { - /* Whether the component is checkpointable or not */ - - false - }, + /* 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_PTL_BASE_VERSION_1_0_0, + "sm", /* MCA component name */ + 1, /* MCA component major version */ + 0, /* MCA component minor version */ + 0, /* MCA component release version */ + mca_ptl_sm_component_open, /* component open */ + mca_ptl_sm_component_close /* component close */ + }, - mca_ptl_sm_component_init, - mca_ptl_sm_component_control, - mca_ptl_sm_component_progress, + /* Next the MCA v1.0.0 component meta data */ + { + /* Whether the component is checkpointable or not */ + false + }, + + mca_ptl_sm_component_init, + mca_ptl_sm_component_control, + mca_ptl_sm_component_progress, } };