1
1

Merge pull request #3739 from cniethammer/sharedfp_sm_file_dir

Create file for file backed shared memory in process job session dir.
Этот коммит содержится в:
Edgar Gabriel 2017-08-15 11:53:30 -05:00 коммит произвёл GitHub
родитель ec1a9a8218 e1fc6ae304
Коммит 99c7482dd8

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

@ -58,11 +58,13 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
mca_io_ompio_file_t * shfileHandle, *ompio_fh; mca_io_ompio_file_t * shfileHandle, *ompio_fh;
char * filename_basename; char * filename_basename;
char * sm_filename; char * sm_filename;
int sm_filename_length;
struct mca_sharedfp_sm_offset * sm_offset_ptr; struct mca_sharedfp_sm_offset * sm_offset_ptr;
struct mca_sharedfp_sm_offset sm_offset; struct mca_sharedfp_sm_offset sm_offset;
mca_io_ompio_data_t *data; mca_io_ompio_data_t *data;
int sm_fd; int sm_fd;
int rank; int rank;
uint32_t comm_cid;
/*----------------------------------------------------*/ /*----------------------------------------------------*/
/*Open the same file again without shared file pointer*/ /*Open the same file again without shared file pointer*/
@ -130,28 +132,21 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
/* the shared memory segment is identified opening a file /* the shared memory segment is identified opening a file
** and then mapping it to memory ** and then mapping it to memory
** For sharedfp we also want to put the file backed shared memory into the tmp directory ** For sharedfp we also want to put the file backed shared memory into the tmp directory
** TODO: properly name the file so that different jobs can run on the same system w/o
** overwriting each other, e.g. orte_process_info.proc_session_dir
*/ */
/*sprintf(sm_filename,"%s%s",filename,".sm");*/ filename_basename = basename(filename);
filename_basename = basename((void *)filename); /* format is "%s/%s_cid-%d.sm", see below */
sm_filename = (char*) malloc( sizeof(char) * (strlen(filename_basename)+64) ); sm_filename_length = strlen(ompi_process_info.job_session_dir) + 1 + strlen(filename_basename) + 5 + (3*sizeof(uint32_t)+1) + 4;
sm_filename = (char*) malloc( sizeof(char) * sm_filename_length);
if (NULL == sm_filename) { if (NULL == sm_filename) {
opal_output(0, "mca_sharedfp_sm_file_open: Error, unable to malloc sm_filename\n");
free(sm_data); free(sm_data);
free(sh); free(sh);
free(shfileHandle); free(shfileHandle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
opal_jobid_t masterjobid; comm_cid = ompi_comm_get_cid(comm);
if ( 0 == comm->c_my_rank ) { sprintf(sm_filename, "%s/%s_cid-%d.sm", ompi_process_info.job_session_dir, filename_basename, comm_cid);
ompi_proc_t *masterproc = ompi_group_peer_lookup(comm->c_local_group, 0 );
masterjobid = OMPI_CAST_RTE_NAME(&masterproc->super.proc_name)->jobid;
}
comm->c_coll->coll_bcast ( &masterjobid, 1, MPI_UNSIGNED, 0, comm,
comm->c_coll->coll_bcast_module );
sprintf(sm_filename,"/tmp/OMPIO_%s_%d_%s",filename_basename, masterjobid, ".sm");
/* open shared memory file, initialize to 0, map into memory */ /* open shared memory file, initialize to 0, map into memory */
sm_fd = open(sm_filename, O_RDWR | O_CREAT, sm_fd = open(sm_filename, O_RDWR | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);