From d955753cb89d838fc834c9d7ff11568f1cede78a Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Mon, 20 May 2019 13:35:38 -0500 Subject: [PATCH] common/ompio: abstraction for different convertor types introduce separate convertors for memory vs. file representation. Adjust the interfaces for decode_datatype to provide the convertor to be used for that. Signed-off-by: Edgar Gabriel --- ompi/mca/common/ompio/common_ompio.h | 6 +++-- ompi/mca/common/ompio/common_ompio_buffer.h | 2 +- .../mca/common/ompio/common_ompio_file_open.c | 25 +++++++++++++------ .../mca/common/ompio/common_ompio_file_read.c | 4 +++ .../mca/common/ompio/common_ompio_file_view.c | 22 ++++++++++++++-- .../common/ompio/common_ompio_file_write.c | 4 +++ .../dynamic/fcoll_dynamic_file_read_all.c | 1 + .../dynamic/fcoll_dynamic_file_write_all.c | 1 + .../fcoll_dynamic_gen2_file_read_all.c | 1 + .../fcoll_dynamic_gen2_file_write_all.c | 1 + .../two_phase/fcoll_two_phase_file_read_all.c | 1 + .../fcoll_two_phase_file_write_all.c | 1 + .../fcoll/vulcan/fcoll_vulcan_file_read_all.c | 1 + .../vulcan/fcoll_vulcan_file_write_all.c | 1 + ompi/mca/io/ompio/io_ompio_file_set_view.c | 3 ++- 15 files changed, 60 insertions(+), 14 deletions(-) diff --git a/ompi/mca/common/ompio/common_ompio.h b/ompi/mca/common/ompio/common_ompio.h index 34f51f0fee..1391c1b5e3 100644 --- a/ompi/mca/common/ompio/common_ompio.h +++ b/ompi/mca/common/ompio/common_ompio.h @@ -10,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2008-2016 University of Houston. All rights reserved. + * Copyright (c) 2008-2019 University of Houston. All rights reserved. * Copyright (c) 2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2018 DataDirect Networks. All rights reserved. @@ -157,7 +157,8 @@ struct ompio_file_t { ompi_communicator_t *f_comm; const char *f_filename; char *f_datarep; - opal_convertor_t *f_convertor; + opal_convertor_t *f_mem_convertor; + opal_convertor_t *f_file_convertor; opal_info_t *f_info; int32_t f_flags; void *f_fs_ptr; @@ -330,6 +331,7 @@ OMPI_DECLSPEC int mca_common_ompio_decode_datatype (struct ompio_file_t *fh, int count, const void *buf, size_t *max_data, + opal_convertor_t *convertor, struct iovec **iov, uint32_t *iov_count); diff --git a/ompi/mca/common/ompio/common_ompio_buffer.h b/ompi/mca/common/ompio/common_ompio_buffer.h index 3c0a7faba9..4178f02f91 100644 --- a/ompi/mca/common/ompio/common_ompio_buffer.h +++ b/ompi/mca/common/ompio/common_ompio_buffer.h @@ -23,7 +23,7 @@ #define OMPIO_PREPARE_BUF(_fh,_buf,_count,_datatype,_tbuf,_convertor,_max_data,_decoded_iov,_iov_count){ \ - opal_convertor_clone ( _fh->f_convertor, _convertor, 0); \ + opal_convertor_clone ( _fh->f_file_convertor, _convertor, 0); \ opal_convertor_prepare_for_send ( _convertor, &(_datatype->super), _count, _buf );\ opal_convertor_get_packed_size( _convertor, &_max_data ); \ _tbuf = mca_common_ompio_alloc_buf (_fh, _max_data); \ diff --git a/ompi/mca/common/ompio/common_ompio_file_open.c b/ompi/mca/common/ompio/common_ompio_file_open.c index a626c55c22..54421f7600 100644 --- a/ompi/mca/common/ompio/common_ompio_file_open.c +++ b/ompi/mca/common/ompio/common_ompio_file_open.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2008-2018 University of Houston. All rights reserved. + * Copyright (c) 2008-2019 University of Houston. All rights reserved. * Copyright (c) 2015-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. @@ -75,7 +75,8 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm, ompio_fh->f_rank = ompi_comm_rank (comm); ompio_fh->f_size = ompi_comm_size (comm); remote_arch = opal_local_arch; - ompio_fh->f_convertor = opal_convertor_create (remote_arch, 0); + ompio_fh->f_mem_convertor = opal_convertor_create (remote_arch, 0); + ompio_fh->f_file_convertor = opal_convertor_create (remote_arch, 0); if ( true == use_sharedfp ) { ret = ompi_comm_dup (comm, &ompio_fh->f_comm); @@ -323,17 +324,23 @@ int mca_common_ompio_file_close (ompio_file_t *ompio_fh) ompio_fh->f_decoded_iov = NULL; } - if (NULL != ompio_fh->f_convertor) { - free (ompio_fh->f_convertor); - ompio_fh->f_convertor = NULL; + if (NULL != ompio_fh->f_mem_convertor) { + opal_convertor_cleanup (ompio_fh->f_mem_convertor); + //free (ompio_fh->f_mem_convertor); + ompio_fh->f_mem_convertor = NULL; } + if (NULL != ompio_fh->f_file_convertor) { + opal_convertor_cleanup (ompio_fh->f_file_convertor); + //free (ompio_fh->f_file_convertor); + ompio_fh->f_file_convertor = NULL; + } + if (NULL != ompio_fh->f_datarep) { free (ompio_fh->f_datarep); ompio_fh->f_datarep = NULL; } - if ( NULL != ompio_fh->f_coll_write_time ) { free ( ompio_fh->f_coll_write_time ); ompio_fh->f_coll_write_time = NULL; @@ -557,6 +564,7 @@ int mca_common_ompio_decode_datatype (struct ompio_file_t *fh, int count, const void *buf, size_t *max_data, + opal_convertor_t *conv, struct iovec **iov, uint32_t *iovec_count) { @@ -571,7 +579,7 @@ int mca_common_ompio_decode_datatype (struct ompio_file_t *fh, size_t temp_data; - opal_convertor_clone (fh->f_convertor, &convertor, 0); + opal_convertor_clone (conv, &convertor, 0); if (OMPI_SUCCESS != opal_convertor_prepare_for_send (&convertor, &(datatype->super), @@ -667,7 +675,8 @@ int mca_common_ompio_decode_datatype (struct ompio_file_t *fh, } free (temp_iov); - + opal_convertor_cleanup (&convertor); + return OMPI_SUCCESS; } diff --git a/ompi/mca/common/ompio/common_ompio_file_read.c b/ompi/mca/common/ompio/common_ompio_file_read.c index ee12385d17..8c9d932983 100644 --- a/ompi/mca/common/ompio/common_ompio_file_read.c +++ b/ompi/mca/common/ompio/common_ompio_file_read.c @@ -105,6 +105,7 @@ int mca_common_ompio_file_read (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); } @@ -114,6 +115,7 @@ int mca_common_ompio_file_read (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); #endif @@ -272,6 +274,7 @@ int mca_common_ompio_file_iread (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); } @@ -281,6 +284,7 @@ int mca_common_ompio_file_iread (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); #endif diff --git a/ompi/mca/common/ompio/common_ompio_file_view.c b/ompi/mca/common/ompio/common_ompio_file_view.c index bf8a25345b..ffbcda0aaa 100644 --- a/ompi/mca/common/ompio/common_ompio_file_view.c +++ b/ompi/mca/common/ompio/common_ompio_file_view.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2008-2018 University of Houston. All rights reserved. + * Copyright (c) 2008-2019 University of Houston. All rights reserved. * Copyright (c) 2017-2018 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. @@ -91,6 +91,12 @@ int mca_common_ompio_set_view (ompio_file_t *fh, fh->f_datarep = NULL; } + if (NULL != fh->f_file_convertor) { + opal_convertor_cleanup (fh->f_file_convertor); + //free (fh->f_file_convertor); + fh->f_file_convertor = NULL; + } + /* Reset the flags first */ if ( fh->f_flags & OMPIO_CONTIGUOUS_FVIEW ) { fh->f_flags &= ~OMPIO_CONTIGUOUS_FVIEW; @@ -99,8 +105,19 @@ int mca_common_ompio_set_view (ompio_file_t *fh, fh->f_flags &= ~OMPIO_UNIFORM_FVIEW; } fh->f_datarep = strdup (datarep); - datatype_duplicate (filetype, &fh->f_orig_filetype ); + if ( !(strcmp(datarep, "external32") && strcmp(datarep, "EXTERNAL32"))) { + fh->f_file_convertor = malloc (sizeof(opal_convertor_t)); + if ( NULL == fh->f_file_convertor ) { + return OMPI_ERR_OUT_OF_RESOURCE; + } + opal_convertor_clone (ompi_mpi_external32_convertor, fh->f_file_convertor, 0); + } + else { + fh->f_file_convertor = opal_convertor_create (opal_local_arch, 0); + } + + datatype_duplicate (filetype, &fh->f_orig_filetype ); opal_datatype_get_extent(&filetype->super, &lb, &ftype_extent); opal_datatype_type_size (&filetype->super, &ftype_size); @@ -129,6 +146,7 @@ int mca_common_ompio_set_view (ompio_file_t *fh, 1, NULL, &max_data, + fh->f_file_convertor, &fh->f_decoded_iov, &fh->f_iov_count); diff --git a/ompi/mca/common/ompio/common_ompio_file_write.c b/ompi/mca/common/ompio/common_ompio_file_write.c index dfb1f765d0..baafe3b5c7 100644 --- a/ompi/mca/common/ompio/common_ompio_file_write.c +++ b/ompi/mca/common/ompio/common_ompio_file_write.c @@ -89,6 +89,7 @@ int mca_common_ompio_file_write (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); } @@ -98,6 +99,7 @@ int mca_common_ompio_file_write (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); #endif @@ -250,6 +252,7 @@ int mca_common_ompio_file_iwrite (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); } @@ -259,6 +262,7 @@ int mca_common_ompio_file_iwrite (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); #endif diff --git a/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_read_all.c b/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_read_all.c index 5301f876c2..b743d08a0e 100644 --- a/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_read_all.c +++ b/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_read_all.c @@ -130,6 +130,7 @@ mca_fcoll_dynamic_file_read_all (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); if (OMPI_SUCCESS != ret){ diff --git a/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c b/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c index 258271f72d..5920694b4e 100644 --- a/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c +++ b/ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c @@ -132,6 +132,7 @@ mca_fcoll_dynamic_file_write_all (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); if (OMPI_SUCCESS != ret ){ diff --git a/ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_read_all.c b/ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_read_all.c index f8abcbd274..9c368fe75a 100644 --- a/ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_read_all.c +++ b/ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_read_all.c @@ -130,6 +130,7 @@ mca_fcoll_dynamic_gen2_file_read_all (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); if (OMPI_SUCCESS != ret){ diff --git a/ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_write_all.c b/ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_write_all.c index ca60036221..0f57709ddb 100644 --- a/ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_write_all.c +++ b/ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_write_all.c @@ -170,6 +170,7 @@ int mca_fcoll_dynamic_gen2_file_write_all (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); if (OMPI_SUCCESS != ret ){ diff --git a/ompi/mca/fcoll/two_phase/fcoll_two_phase_file_read_all.c b/ompi/mca/fcoll/two_phase/fcoll_two_phase_file_read_all.c index 2ec05cbd9d..78e44669ce 100644 --- a/ompi/mca/fcoll/two_phase/fcoll_two_phase_file_read_all.c +++ b/ompi/mca/fcoll/two_phase/fcoll_two_phase_file_read_all.c @@ -155,6 +155,7 @@ mca_fcoll_two_phase_file_read_all (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &temp_iov, &iov_count); if (OMPI_SUCCESS != ret ){ diff --git a/ompi/mca/fcoll/two_phase/fcoll_two_phase_file_write_all.c b/ompi/mca/fcoll/two_phase/fcoll_two_phase_file_write_all.c index c23d22d810..fc10caec03 100644 --- a/ompi/mca/fcoll/two_phase/fcoll_two_phase_file_write_all.c +++ b/ompi/mca/fcoll/two_phase/fcoll_two_phase_file_write_all.c @@ -185,6 +185,7 @@ mca_fcoll_two_phase_file_write_all (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &temp_iov, &iov_count); if (OMPI_SUCCESS != ret ){ diff --git a/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_read_all.c b/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_read_all.c index ea2288ce91..0106d653a9 100644 --- a/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_read_all.c +++ b/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_read_all.c @@ -129,6 +129,7 @@ mca_fcoll_vulcan_file_read_all (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); if (OMPI_SUCCESS != ret){ diff --git a/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_write_all.c b/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_write_all.c index 1e43112662..34548c63c1 100644 --- a/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_write_all.c +++ b/ompi/mca/fcoll/vulcan/fcoll_vulcan_file_write_all.c @@ -185,6 +185,7 @@ int mca_fcoll_vulcan_file_write_all (ompio_file_t *fh, count, buf, &max_data, + fh->f_mem_convertor, &decoded_iov, &iov_count); if (OMPI_SUCCESS != ret ){ diff --git a/ompi/mca/io/ompio/io_ompio_file_set_view.c b/ompi/mca/io/ompio/io_ompio_file_set_view.c index 72671c3410..30542b00cd 100644 --- a/ompi/mca/io/ompio/io_ompio_file_set_view.c +++ b/ompi/mca/io/ompio/io_ompio_file_set_view.c @@ -66,7 +66,8 @@ int mca_io_ompio_file_set_view (ompi_file_t *fp, mca_common_ompio_data_t *data; ompio_file_t *fh; - if ( (strcmp(datarep, "native") && strcmp(datarep, "NATIVE"))) { + if ( (strcmp(datarep, "native") && strcmp(datarep, "NATIVE") && + strcmp(datarep, "external32") && strcmp(datarep, "EXTERNAL32"))) { return MPI_ERR_UNSUPPORTED_DATAREP; }