Removing duplicate code while setting default file view and using internal file-set-view for setting the default file view
This commit was SVN r25679.
Этот коммит содержится в:
родитель
6ca186fb64
Коммит
738a67b704
@ -58,56 +58,52 @@ int ompi_io_ompio_set_file_defaults (mca_io_ompio_file_t *fh)
|
||||
OPAL_PTRDIFF_TYPE d[2], base;
|
||||
int i;
|
||||
|
||||
fh->f_info = MPI_INFO_NULL;
|
||||
fh->f_comm = MPI_COMM_NULL;
|
||||
fh->f_rank = -1;
|
||||
fh->f_size = 0;
|
||||
fh->f_io_array = NULL;
|
||||
fh->f_perm = OMPIO_PERM_NULL;
|
||||
fh->f_flags = 0;
|
||||
fh->f_bytes_per_agg = mca_io_ompio_bytes_per_agg;
|
||||
fh->f_datarep = strdup ("native");
|
||||
|
||||
fh->f_offset = 0;
|
||||
fh->f_disp = 0;
|
||||
fh->f_position_in_file_view = 0;
|
||||
fh->f_index_in_file_view = 0;
|
||||
fh->f_total_bytes = 0;
|
||||
|
||||
fh->f_procs_in_group = NULL;
|
||||
fh->f_procs_per_group = -1;
|
||||
|
||||
ompi_datatype_create_contiguous(1048576, &ompi_mpi_byte.dt, &default_file_view);
|
||||
ompi_datatype_commit (&default_file_view);
|
||||
|
||||
fh->f_etype = default_file_view;
|
||||
fh->f_etype = &ompi_mpi_byte.dt;
|
||||
fh->f_filetype = default_file_view;
|
||||
|
||||
|
||||
|
||||
/* Default file View */
|
||||
fh->f_iov_type = MPI_DATATYPE_NULL;
|
||||
fh->f_iov_count = 1;
|
||||
fh->f_decoded_iov = (struct iovec*)malloc(fh->f_iov_count *
|
||||
sizeof(struct iovec));
|
||||
if (NULL == fh->f_decoded_iov) {
|
||||
opal_output (1, "OUT OF MEMORY\n");
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
fh->f_cc_size = 1;
|
||||
fh->f_stripe_size = mca_io_ompio_bytes_per_agg;
|
||||
fh->f_decoded_iov[0].iov_len = 1048576;
|
||||
fh->f_decoded_iov[0].iov_base = 0;
|
||||
/*Decoded iovec of the file-view*/
|
||||
fh->f_decoded_iov = NULL;
|
||||
|
||||
mca_io_ompio_set_view_internal(fh,
|
||||
0,
|
||||
&ompi_mpi_byte.dt,
|
||||
default_file_view,
|
||||
"native",
|
||||
fh->f_info);
|
||||
|
||||
|
||||
|
||||
/*Create a derived datatype for the created iovec */
|
||||
|
||||
types[0] = &ompi_mpi_long.dt;
|
||||
types[1] = &ompi_mpi_long.dt;
|
||||
|
||||
MPI_Address( fh->f_decoded_iov, d);
|
||||
MPI_Address( &fh->f_decoded_iov[0].iov_len, d+1);
|
||||
|
||||
base = d[0];
|
||||
for (i=0 ; i<2 ; i++) {
|
||||
d[i] -= base;
|
||||
}
|
||||
|
||||
ompi_datatype_create_struct (2,
|
||||
blocklen,
|
||||
d,
|
||||
@ -115,10 +111,6 @@ int ompi_io_ompio_set_file_defaults (mca_io_ompio_file_t *fh)
|
||||
&fh->f_iov_type);
|
||||
ompi_datatype_commit (&fh->f_iov_type);
|
||||
|
||||
fh->f_view_extent = 1048576;
|
||||
fh->f_view_size = 1048576;
|
||||
fh->f_etype_size = 1;
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
else {
|
||||
@ -132,9 +124,6 @@ int ompi_io_ompio_generate_current_file_view (mca_io_ompio_file_t *fh,
|
||||
int *iov_count)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
struct iovec *iov = NULL;
|
||||
size_t bytes_to_write;
|
||||
size_t sum_previous_counts = 0;
|
||||
@ -149,10 +138,6 @@ int ompi_io_ompio_generate_current_file_view (mca_io_ompio_file_t *fh,
|
||||
IOVBASE_TYPE * merge_offset = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* allocate an initial iovec, will grow if needed */
|
||||
iov = (struct iovec *) malloc
|
||||
(OMPIO_IOVEC_INITIAL_SIZE * sizeof (struct iovec));
|
||||
@ -281,7 +266,6 @@ int ompi_io_ompio_set_explicit_offset (mca_io_ompio_file_t *fh,
|
||||
OMPI_MPI_OFFSET_TYPE offset)
|
||||
{
|
||||
|
||||
|
||||
size_t i = 0;
|
||||
size_t k = 0;
|
||||
|
||||
|
@ -483,6 +483,12 @@ int mca_io_ompio_file_set_view (struct ompi_file_t *fh,
|
||||
struct ompi_datatype_t *filetype,
|
||||
char *datarep,
|
||||
struct ompi_info_t *info);
|
||||
int mca_io_ompio_set_view_internal (struct mca_io_ompio_file_t *fh,
|
||||
OMPI_MPI_OFFSET_TYPE disp,
|
||||
struct ompi_datatype_t *etype,
|
||||
struct ompi_datatype_t *filetype,
|
||||
char *datarep,
|
||||
struct ompi_info_t *info);
|
||||
int mca_io_ompio_file_get_view (struct ompi_file_t *fh,
|
||||
OMPI_MPI_OFFSET_TYPE *disp,
|
||||
struct ompi_datatype_t **etype,
|
||||
|
@ -73,11 +73,19 @@ mca_io_ompio_file_open (ompi_communicator_t *comm,
|
||||
data = (mca_io_ompio_data_t *) fh->f_io_selected_data;
|
||||
|
||||
data->ompio_fh.f_iov_type = MPI_DATATYPE_NULL;
|
||||
ompi_io_ompio_set_file_defaults (&data->ompio_fh);
|
||||
|
||||
ompi_comm_dup (comm, &data->ompio_fh.f_comm);
|
||||
data->ompio_fh.f_rank = ompi_comm_rank (fh->f_comm);
|
||||
data->ompio_fh.f_size = ompi_comm_size (fh->f_comm);
|
||||
remote_arch = opal_local_arch;
|
||||
data->ompio_fh.f_convertor = opal_convertor_create (remote_arch, 0);
|
||||
|
||||
ompi_comm_dup (comm, &data->ompio_fh.f_comm);
|
||||
|
||||
data->ompio_fh.f_fstype = NONE;
|
||||
data->ompio_fh.f_amode = amode;
|
||||
data->ompio_fh.f_info = fh->f_info;
|
||||
data->ompio_fh.f_atomicity = 0;
|
||||
|
||||
ompi_io_ompio_set_file_defaults (&data->ompio_fh);
|
||||
|
||||
data->ompio_fh.f_filename = fh->f_filename;
|
||||
if (NULL == data->ompio_fh.f_filename) {
|
||||
@ -85,9 +93,6 @@ mca_io_ompio_file_open (ompi_communicator_t *comm,
|
||||
goto fn_fail;
|
||||
}
|
||||
|
||||
data->ompio_fh.f_amode = amode;
|
||||
data->ompio_fh.f_info = fh->f_info;
|
||||
data->ompio_fh.f_atomicity = 0;
|
||||
/*
|
||||
if (MPI_INFO_NULL != info)
|
||||
{
|
||||
@ -98,10 +103,8 @@ mca_io_ompio_file_open (ompi_communicator_t *comm,
|
||||
goto fn_fail;
|
||||
}
|
||||
*/
|
||||
remote_arch = opal_local_arch;
|
||||
data->ompio_fh.f_convertor = opal_convertor_create (remote_arch, 0);
|
||||
|
||||
data->ompio_fh.f_fstype = NONE;
|
||||
|
||||
|
||||
if (OMPI_SUCCESS != (ret = mca_fs_base_file_select (&data->ompio_fh,
|
||||
NULL))) {
|
||||
|
@ -37,6 +37,44 @@
|
||||
|
||||
OMPI_MPI_OFFSET_TYPE get_contiguous_chunk_size (mca_io_ompio_file_t *);
|
||||
|
||||
|
||||
int mca_io_ompio_set_view_internal(mca_io_ompio_file_t *fh,
|
||||
OMPI_MPI_OFFSET_TYPE disp,
|
||||
ompi_datatype_t *etype,
|
||||
ompi_datatype_t *filetype,
|
||||
char *datarep,
|
||||
ompi_info_t *info)
|
||||
{
|
||||
|
||||
|
||||
size_t max_data = 0;
|
||||
MPI_Aint lb,ub;
|
||||
|
||||
fh->f_iov_count = 0;
|
||||
fh->f_disp = disp;
|
||||
fh->f_offset += disp;
|
||||
|
||||
|
||||
ompi_io_ompio_decode_datatype (fh,
|
||||
filetype,
|
||||
1,
|
||||
NULL,
|
||||
&max_data,
|
||||
&fh->f_decoded_iov,
|
||||
&fh->f_iov_count);
|
||||
|
||||
opal_datatype_get_extent(&filetype->super, &lb, &fh->f_view_extent);
|
||||
opal_datatype_type_ub (&filetype->super, &ub);
|
||||
opal_datatype_type_size (&etype->super, &fh->f_etype_size);
|
||||
opal_datatype_type_size (&filetype->super, &fh->f_view_size);
|
||||
ompi_datatype_duplicate (etype, &fh->f_etype);
|
||||
ompi_datatype_duplicate (filetype, &fh->f_filetype);
|
||||
|
||||
fh->f_cc_size = get_contiguous_chunk_size (fh);
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
int mca_io_ompio_file_set_view (ompi_file_t *fp,
|
||||
OMPI_MPI_OFFSET_TYPE disp,
|
||||
ompi_datatype_t *etype,
|
||||
@ -46,8 +84,8 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
|
||||
{
|
||||
mca_io_ompio_data_t *data;
|
||||
mca_io_ompio_file_t *fh;
|
||||
size_t max_data = 0;
|
||||
MPI_Aint lb,ub;
|
||||
|
||||
|
||||
|
||||
data = (mca_io_ompio_data_t *) fp->f_io_selected_data;
|
||||
fh = &data->ompio_fh;
|
||||
@ -63,95 +101,28 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp,
|
||||
}
|
||||
|
||||
fh->f_flags |= OMPIO_FILE_VIEW_IS_SET;
|
||||
fh->f_disp = disp;
|
||||
fh->f_offset += disp;
|
||||
fh->f_datarep = strdup (datarep);
|
||||
|
||||
fh->f_iov_count = 0;
|
||||
|
||||
if (opal_datatype_is_contiguous_memory_layout(&etype->super,1)) {
|
||||
if (opal_datatype_is_contiguous_memory_layout(&filetype->super,1)) {
|
||||
fh->f_flags |= OMPIO_CONTIGUOUS_FVIEW;
|
||||
}
|
||||
}
|
||||
|
||||
ompi_io_ompio_decode_datatype (fh,
|
||||
filetype,
|
||||
1,
|
||||
NULL,
|
||||
&max_data,
|
||||
&fh->f_decoded_iov,
|
||||
&fh->f_iov_count);
|
||||
/*
|
||||
if (0 == fh->f_rank) {
|
||||
int i;
|
||||
printf ("%d Entries: \n",fh->f_iov_count);
|
||||
for (i=0 ; i<fh->f_iov_count ; i++) {
|
||||
printf ("\t{%p, %lld}\n",
|
||||
fh->f_decoded_iov[i].iov_base,
|
||||
fh->f_decoded_iov[i].iov_len);
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* Create a derived datatype for the created iovec
|
||||
|
||||
types[0] = &ompi_mpi_long.dt;
|
||||
types[1] = &ompi_mpi_long.dt;
|
||||
MPI_Address( fh->f_decoded_iov, d);
|
||||
MPI_Address( &fh->f_decoded_iov[0].iov_len, d+1);
|
||||
base = d[0];
|
||||
for (i=0 ; i<2 ; i++) {
|
||||
d[i] -= base;
|
||||
}
|
||||
ompi_datatype_create_struct (2,
|
||||
blocklen,
|
||||
d,
|
||||
types,
|
||||
&fh->f_iov_type);
|
||||
ompi_datatype_commit (&fh->f_iov_type);
|
||||
*/
|
||||
opal_datatype_get_extent(&filetype->super, &lb, &fh->f_view_extent);
|
||||
opal_datatype_type_ub (&filetype->super, &ub);
|
||||
opal_datatype_type_size (&etype->super, &fh->f_etype_size);
|
||||
opal_datatype_type_size (&filetype->super, &fh->f_view_size);
|
||||
ompi_datatype_duplicate (etype, &fh->f_etype);
|
||||
ompi_datatype_duplicate (filetype, &fh->f_filetype);
|
||||
|
||||
fh->f_cc_size = get_contiguous_chunk_size (fh);
|
||||
/*
|
||||
mca_fcoll_base_param = mca_base_param_find("fcoll", NULL, NULL);
|
||||
mca_base_param_lookup_string (mca_fcoll_base_param, &names);
|
||||
|
||||
if (NULL == names) {
|
||||
if ((int)cc_size >= mca_io_ompio_bytes_per_agg &&
|
||||
cc_size >= fh->f_stripe_size) {
|
||||
mca_base_param_set_string(mca_fcoll_base_param, "individual");
|
||||
}
|
||||
if ((int)cc_size < mca_io_ompio_bytes_per_agg &&
|
||||
cc_size >= fh->f_stripe_size) {
|
||||
mca_base_param_set_string(mca_fcoll_base_param, "dynamic");
|
||||
}
|
||||
else if ((int)cc_size < mca_io_ompio_bytes_per_agg &&
|
||||
cc_size < fh->f_stripe_size) {
|
||||
mca_base_param_set_string(mca_fcoll_base_param, "two_phase");
|
||||
}
|
||||
}
|
||||
*/
|
||||
mca_io_ompio_set_view_internal (fh,
|
||||
disp,
|
||||
etype,
|
||||
filetype,
|
||||
datarep,
|
||||
info);
|
||||
|
||||
|
||||
if (OMPI_SUCCESS != mca_fcoll_base_file_select (&data->ompio_fh,
|
||||
NULL)) {
|
||||
opal_output(1, "mca_fcoll_base_file_select() failed\n");
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
/*
|
||||
printf ("%d: LB=%d UB=%d Extent=%d Size=%d\n",
|
||||
fh->f_rank,lb,ub,fh->f_view_extent,fh->f_view_size);
|
||||
*/
|
||||
/*
|
||||
ompi_ddt_type_extent (fh->f_etype, &fh->f_etype_extent);
|
||||
ompi_ddt_type_extent (fh->f_filetype, &fh->f_filetype_extent);
|
||||
*/
|
||||
|
||||
return OMPI_SUCCESS;
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user