Skip to content

Commit d955753

Browse files
committed
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 <egabriel@central.uh.edu>
1 parent 35be18b commit d955753

15 files changed

+60
-14
lines changed

ompi/mca/common/ompio/common_ompio.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* University of Stuttgart. All rights reserved.
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
13-
* Copyright (c) 2008-2016 University of Houston. All rights reserved.
13+
* Copyright (c) 2008-2019 University of Houston. All rights reserved.
1414
* Copyright (c) 2018 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
1616
* Copyright (c) 2018 DataDirect Networks. All rights reserved.
@@ -157,7 +157,8 @@ struct ompio_file_t {
157157
ompi_communicator_t *f_comm;
158158
const char *f_filename;
159159
char *f_datarep;
160-
opal_convertor_t *f_convertor;
160+
opal_convertor_t *f_mem_convertor;
161+
opal_convertor_t *f_file_convertor;
161162
opal_info_t *f_info;
162163
int32_t f_flags;
163164
void *f_fs_ptr;
@@ -330,6 +331,7 @@ OMPI_DECLSPEC int mca_common_ompio_decode_datatype (struct ompio_file_t *fh,
330331
int count,
331332
const void *buf,
332333
size_t *max_data,
334+
opal_convertor_t *convertor,
333335
struct iovec **iov,
334336
uint32_t *iov_count);
335337

ompi/mca/common/ompio/common_ompio_buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
#define OMPIO_PREPARE_BUF(_fh,_buf,_count,_datatype,_tbuf,_convertor,_max_data,_decoded_iov,_iov_count){ \
26-
opal_convertor_clone ( _fh->f_convertor, _convertor, 0); \
26+
opal_convertor_clone ( _fh->f_file_convertor, _convertor, 0); \
2727
opal_convertor_prepare_for_send ( _convertor, &(_datatype->super), _count, _buf );\
2828
opal_convertor_get_packed_size( _convertor, &_max_data ); \
2929
_tbuf = mca_common_ompio_alloc_buf (_fh, _max_data); \

ompi/mca/common/ompio/common_ompio_file_open.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2018 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2019 University of Houston. All rights reserved.
1313
* Copyright (c) 2015-2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
@@ -75,7 +75,8 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm,
7575
ompio_fh->f_rank = ompi_comm_rank (comm);
7676
ompio_fh->f_size = ompi_comm_size (comm);
7777
remote_arch = opal_local_arch;
78-
ompio_fh->f_convertor = opal_convertor_create (remote_arch, 0);
78+
ompio_fh->f_mem_convertor = opal_convertor_create (remote_arch, 0);
79+
ompio_fh->f_file_convertor = opal_convertor_create (remote_arch, 0);
7980

8081
if ( true == use_sharedfp ) {
8182
ret = ompi_comm_dup (comm, &ompio_fh->f_comm);
@@ -323,17 +324,23 @@ int mca_common_ompio_file_close (ompio_file_t *ompio_fh)
323324
ompio_fh->f_decoded_iov = NULL;
324325
}
325326

326-
if (NULL != ompio_fh->f_convertor) {
327-
free (ompio_fh->f_convertor);
328-
ompio_fh->f_convertor = NULL;
327+
if (NULL != ompio_fh->f_mem_convertor) {
328+
opal_convertor_cleanup (ompio_fh->f_mem_convertor);
329+
//free (ompio_fh->f_mem_convertor);
330+
ompio_fh->f_mem_convertor = NULL;
329331
}
330332

333+
if (NULL != ompio_fh->f_file_convertor) {
334+
opal_convertor_cleanup (ompio_fh->f_file_convertor);
335+
//free (ompio_fh->f_file_convertor);
336+
ompio_fh->f_file_convertor = NULL;
337+
}
338+
331339
if (NULL != ompio_fh->f_datarep) {
332340
free (ompio_fh->f_datarep);
333341
ompio_fh->f_datarep = NULL;
334342
}
335343

336-
337344
if ( NULL != ompio_fh->f_coll_write_time ) {
338345
free ( ompio_fh->f_coll_write_time );
339346
ompio_fh->f_coll_write_time = NULL;
@@ -557,6 +564,7 @@ int mca_common_ompio_decode_datatype (struct ompio_file_t *fh,
557564
int count,
558565
const void *buf,
559566
size_t *max_data,
567+
opal_convertor_t *conv,
560568
struct iovec **iov,
561569
uint32_t *iovec_count)
562570
{
@@ -571,7 +579,7 @@ int mca_common_ompio_decode_datatype (struct ompio_file_t *fh,
571579
size_t temp_data;
572580

573581

574-
opal_convertor_clone (fh->f_convertor, &convertor, 0);
582+
opal_convertor_clone (conv, &convertor, 0);
575583

576584
if (OMPI_SUCCESS != opal_convertor_prepare_for_send (&convertor,
577585
&(datatype->super),
@@ -667,7 +675,8 @@ int mca_common_ompio_decode_datatype (struct ompio_file_t *fh,
667675
}
668676

669677
free (temp_iov);
670-
678+
opal_convertor_cleanup (&convertor);
679+
671680
return OMPI_SUCCESS;
672681
}
673682

ompi/mca/common/ompio/common_ompio_file_read.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ int mca_common_ompio_file_read (ompio_file_t *fh,
105105
count,
106106
buf,
107107
&max_data,
108+
fh->f_mem_convertor,
108109
&decoded_iov,
109110
&iov_count);
110111
}
@@ -114,6 +115,7 @@ int mca_common_ompio_file_read (ompio_file_t *fh,
114115
count,
115116
buf,
116117
&max_data,
118+
fh->f_mem_convertor,
117119
&decoded_iov,
118120
&iov_count);
119121
#endif
@@ -272,6 +274,7 @@ int mca_common_ompio_file_iread (ompio_file_t *fh,
272274
count,
273275
buf,
274276
&max_data,
277+
fh->f_mem_convertor,
275278
&decoded_iov,
276279
&iov_count);
277280
}
@@ -281,6 +284,7 @@ int mca_common_ompio_file_iread (ompio_file_t *fh,
281284
count,
282285
buf,
283286
&max_data,
287+
fh->f_mem_convertor,
284288
&decoded_iov,
285289
&iov_count);
286290
#endif

ompi/mca/common/ompio/common_ompio_file_view.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2008-2018 University of Houston. All rights reserved.
12+
* Copyright (c) 2008-2019 University of Houston. All rights reserved.
1313
* Copyright (c) 2017-2018 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2017 IBM Corporation. All rights reserved.
@@ -91,6 +91,12 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
9191
fh->f_datarep = NULL;
9292
}
9393

94+
if (NULL != fh->f_file_convertor) {
95+
opal_convertor_cleanup (fh->f_file_convertor);
96+
//free (fh->f_file_convertor);
97+
fh->f_file_convertor = NULL;
98+
}
99+
94100
/* Reset the flags first */
95101
if ( fh->f_flags & OMPIO_CONTIGUOUS_FVIEW ) {
96102
fh->f_flags &= ~OMPIO_CONTIGUOUS_FVIEW;
@@ -99,8 +105,19 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
99105
fh->f_flags &= ~OMPIO_UNIFORM_FVIEW;
100106
}
101107
fh->f_datarep = strdup (datarep);
102-
datatype_duplicate (filetype, &fh->f_orig_filetype );
103108

109+
if ( !(strcmp(datarep, "external32") && strcmp(datarep, "EXTERNAL32"))) {
110+
fh->f_file_convertor = malloc (sizeof(opal_convertor_t));
111+
if ( NULL == fh->f_file_convertor ) {
112+
return OMPI_ERR_OUT_OF_RESOURCE;
113+
}
114+
opal_convertor_clone (ompi_mpi_external32_convertor, fh->f_file_convertor, 0);
115+
}
116+
else {
117+
fh->f_file_convertor = opal_convertor_create (opal_local_arch, 0);
118+
}
119+
120+
datatype_duplicate (filetype, &fh->f_orig_filetype );
104121
opal_datatype_get_extent(&filetype->super, &lb, &ftype_extent);
105122
opal_datatype_type_size (&filetype->super, &ftype_size);
106123

@@ -129,6 +146,7 @@ int mca_common_ompio_set_view (ompio_file_t *fh,
129146
1,
130147
NULL,
131148
&max_data,
149+
fh->f_file_convertor,
132150
&fh->f_decoded_iov,
133151
&fh->f_iov_count);
134152

ompi/mca/common/ompio/common_ompio_file_write.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ int mca_common_ompio_file_write (ompio_file_t *fh,
8989
count,
9090
buf,
9191
&max_data,
92+
fh->f_mem_convertor,
9293
&decoded_iov,
9394
&iov_count);
9495
}
@@ -98,6 +99,7 @@ int mca_common_ompio_file_write (ompio_file_t *fh,
9899
count,
99100
buf,
100101
&max_data,
102+
fh->f_mem_convertor,
101103
&decoded_iov,
102104
&iov_count);
103105
#endif
@@ -250,6 +252,7 @@ int mca_common_ompio_file_iwrite (ompio_file_t *fh,
250252
count,
251253
buf,
252254
&max_data,
255+
fh->f_mem_convertor,
253256
&decoded_iov,
254257
&iov_count);
255258
}
@@ -259,6 +262,7 @@ int mca_common_ompio_file_iwrite (ompio_file_t *fh,
259262
count,
260263
buf,
261264
&max_data,
265+
fh->f_mem_convertor,
262266
&decoded_iov,
263267
&iov_count);
264268
#endif

ompi/mca/fcoll/dynamic/fcoll_dynamic_file_read_all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ mca_fcoll_dynamic_file_read_all (ompio_file_t *fh,
130130
count,
131131
buf,
132132
&max_data,
133+
fh->f_mem_convertor,
133134
&decoded_iov,
134135
&iov_count);
135136
if (OMPI_SUCCESS != ret){

ompi/mca/fcoll/dynamic/fcoll_dynamic_file_write_all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ mca_fcoll_dynamic_file_write_all (ompio_file_t *fh,
132132
count,
133133
buf,
134134
&max_data,
135+
fh->f_mem_convertor,
135136
&decoded_iov,
136137
&iov_count);
137138
if (OMPI_SUCCESS != ret ){

ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_read_all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ mca_fcoll_dynamic_gen2_file_read_all (ompio_file_t *fh,
130130
count,
131131
buf,
132132
&max_data,
133+
fh->f_mem_convertor,
133134
&decoded_iov,
134135
&iov_count);
135136
if (OMPI_SUCCESS != ret){

ompi/mca/fcoll/dynamic_gen2/fcoll_dynamic_gen2_file_write_all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ int mca_fcoll_dynamic_gen2_file_write_all (ompio_file_t *fh,
170170
count,
171171
buf,
172172
&max_data,
173+
fh->f_mem_convertor,
173174
&decoded_iov,
174175
&iov_count);
175176
if (OMPI_SUCCESS != ret ){

0 commit comments

Comments
 (0)