rename data structure for clarifications, remove code in favor of using
aspintf, fix a file naming bug. This commit was SVN r2199.
Этот коммит содержится в:
родитель
8ba268c8dd
Коммит
99b3506ef5
@ -65,7 +65,7 @@ static int mca_common_sm_mmap_open(char* path)
|
||||
*
|
||||
* @param size_ctl_structure size of the control structure at
|
||||
* the head of the file. The control structure
|
||||
* is assumed to have mca_common_sm_segment_t
|
||||
* is assumed to have mca_common_sm_file_header_t
|
||||
* as its first segment (IN)
|
||||
*
|
||||
* @param data_set_alignment alignment of the data segment. this
|
||||
@ -77,16 +77,17 @@ mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name,
|
||||
{
|
||||
int fd,return_code=OMPI_SUCCESS;
|
||||
bool file_previously_opened;
|
||||
mca_common_sm_segment_t* seg;
|
||||
mca_common_sm_file_header_t* seg;
|
||||
mca_common_sm_mmap_t* map;
|
||||
struct stat s_stat;
|
||||
unsigned char *addr;
|
||||
size_t tmp,mem_offset;
|
||||
|
||||
/* input parameter error checks */
|
||||
if( (size < sizeof(mca_common_sm_segment_t) ) ||
|
||||
if( (size < sizeof(mca_common_sm_file_header_t) ) ||
|
||||
( file_name == NULL ) ||
|
||||
( size_ctl_structure < sizeof(mca_common_sm_segment_t ) ) ||
|
||||
( size_ctl_structure <
|
||||
sizeof(mca_common_sm_file_header_t ) ) ||
|
||||
( data_seg_alignment == 0 ) ) {
|
||||
return NULL;
|
||||
}
|
||||
@ -142,7 +143,7 @@ mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name,
|
||||
map = OBJ_NEW(mca_common_sm_mmap_t);
|
||||
strncpy(map->map_path, file_name, PATH_MAX);
|
||||
/* the first entry in the file is the control strcuture. the first
|
||||
entry in the control structure is an mca_common_sm_segment_t
|
||||
entry in the control structure is an mca_common_sm_file_header_t
|
||||
element */
|
||||
map->map_seg = seg;
|
||||
|
||||
@ -197,7 +198,7 @@ mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name,
|
||||
void* mca_common_sm_mmap_alloc(size_t* size)
|
||||
{
|
||||
mca_common_sm_mmap_t* map = mca_common_sm_mmap;
|
||||
mca_common_sm_segment_t* seg = map->map_seg;
|
||||
mca_common_sm_file_header_t* seg = map->map_seg;
|
||||
void* addr;
|
||||
|
||||
spinlock(&seg->seg_lock);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "os/atomic.h"
|
||||
#include "class/ompi_list.h"
|
||||
|
||||
struct mca_common_sm_segment_t {
|
||||
struct mca_common_sm_file_header_t {
|
||||
/* lock to control atomic access */
|
||||
ompi_lock_data_t seg_lock;
|
||||
/* is the segment ready for use */
|
||||
@ -15,13 +15,14 @@ struct mca_common_sm_segment_t {
|
||||
/* total size of the segment */
|
||||
size_t seg_size;
|
||||
};
|
||||
typedef struct mca_common_sm_segment_t mca_common_sm_segment_t;
|
||||
typedef struct mca_common_sm_file_header_t mca_common_sm_file_header_t;
|
||||
|
||||
|
||||
struct mca_common_sm_mmap_t {
|
||||
/* double link list element */
|
||||
ompi_list_item_t map_item;
|
||||
mca_common_sm_segment_t* map_seg;
|
||||
/* pointer to header imbeded in the shared memory file */
|
||||
mca_common_sm_file_header_t* map_seg;
|
||||
/* base address of the mmap'ed file */
|
||||
unsigned char *map_addr;
|
||||
/* base address of data segment */
|
||||
@ -46,11 +47,13 @@ OBJ_CLASS_DECLARATION(mca_common_sm_mmap_t);
|
||||
*
|
||||
* @param size_ctl_structure size of the control structure at
|
||||
* the head of the file. The control structure
|
||||
* is assumed to have mca_common_sm_segment_t
|
||||
* is assumed to have mca_common_sm_file_header_t
|
||||
* as its first segment (IN)
|
||||
*
|
||||
* @param data_set_alignment alignment of the data segment. this
|
||||
* follows the control structure (IN)
|
||||
*
|
||||
* @returnvalue pointer to control structure at head of file.
|
||||
*/
|
||||
|
||||
mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name,
|
||||
|
@ -3,6 +3,8 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "util/output.h"
|
||||
#include "util/if.h"
|
||||
#include "mca/pml/pml.h"
|
||||
@ -156,31 +158,16 @@ int mca_ptl_sm_add_procs(
|
||||
* data structure. This will reside in shared memory */
|
||||
|
||||
/* Create backing file */
|
||||
len=strlen(ompi_process_info.job_session_dir) +
|
||||
strlen(ompi_system_info.nodename)+
|
||||
/* length of fixed-string name part */
|
||||
23;
|
||||
memset(&(file_name[0]),0,PATH_MAX);
|
||||
if( PATH_MAX <= len ) {
|
||||
ompi_output(0, "mca_ptl_sm_add_procs: name of backing file too long %ld \n",
|
||||
len);
|
||||
return_code=OMPI_ERROR;
|
||||
goto CLEANUP;
|
||||
}
|
||||
mca_ptl_sm_component.sm_resouce_ctl_file= (char *)
|
||||
malloc(len+1);
|
||||
if( NULL == mca_ptl_sm_component.sm_resouce_ctl_file ){
|
||||
return_code=OMPI_ERR_OUT_OF_RESOURCE;
|
||||
/* set file name */
|
||||
len=asprintf(&(mca_ptl_sm_component.sm_resouce_ctl_file),
|
||||
"%s/shared_mem_ptl_module.%s",ompi_process_info.job_session_dir,
|
||||
ompi_system_info.nodename);
|
||||
if( 0 > len ) {
|
||||
goto CLEANUP;
|
||||
}
|
||||
memset(mca_ptl_sm_component.sm_resouce_ctl_file,0,len+1);
|
||||
sprintf(mca_ptl_sm_component.sm_resouce_ctl_file,
|
||||
"%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_ptl_sm_component.resource_ctl =
|
||||
(mca_ptl_sm_component.mmap_file =
|
||||
mca_common_sm_mmap_init(size,
|
||||
mca_ptl_sm_component.sm_resouce_ctl_file,
|
||||
sizeof(mca_ptl_sm_module_resource_t), 8 )))
|
||||
@ -196,9 +183,14 @@ int mca_ptl_sm_add_procs(
|
||||
* make this array growable, but then one would need to uses mutexes
|
||||
* for any access to these queues to ensure data consistancy when
|
||||
* the array is grown */
|
||||
if(0 == ptl_sm->my_smp_rank ) {
|
||||
mca_ptl_sm_component.mmap_file->map_seg->seg_inited=true;
|
||||
}
|
||||
|
||||
/* Note: Need to make sure that proc 0 initializes control
|
||||
* structures before any of the other procs can progress */
|
||||
if( 0 != ptl_sm->my_smp_rank ) {
|
||||
}
|
||||
|
||||
/* Initizlize queue data structures
|
||||
* - proc with lowest local rank does this
|
||||
|
@ -21,7 +21,7 @@
|
||||
* Shared Memory resource managment
|
||||
*/
|
||||
struct mca_ptl_sm_module_resource_t {
|
||||
mca_common_sm_segment_t segment_header;
|
||||
mca_common_sm_file_header_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;
|
||||
@ -44,9 +44,8 @@ struct mca_ptl_sm_component_t {
|
||||
ompi_mutex_t sm_lock;
|
||||
char* sm_resouce_ctl_file; /**< name of shared memory file used
|
||||
to coordinate resource usage */
|
||||
mca_ptl_sm_module_resource_t *resource_ctl;
|
||||
/**< shared memory coordination data.
|
||||
Resides in shared memory */
|
||||
mca_common_sm_mmap_t *mmap_file; /**< description of mmap'ed
|
||||
file */
|
||||
};
|
||||
typedef struct mca_ptl_sm_component_t mca_ptl_sm_component_t;
|
||||
extern mca_ptl_sm_component_t mca_ptl_sm_component;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user