This source file includes following definitions.
- datatype_duplicate
- mca_io_ompio_file_set_view
- mca_io_ompio_file_get_view
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include "ompi_config.h"
24
25 #include "ompi/communicator/communicator.h"
26 #include "ompi/info/info.h"
27 #include "ompi/file/file.h"
28 #include "ompi/mca/pml/pml.h"
29 #include "opal/datatype/opal_convertor.h"
30 #include "ompi/datatype/ompi_datatype.h"
31 #include <stdlib.h>
32 #include <stdio.h>
33
34 #include <unistd.h>
35 #include "io_ompio.h"
36
37 static int datatype_duplicate (ompi_datatype_t *oldtype, ompi_datatype_t **newtype );
38 static int datatype_duplicate (ompi_datatype_t *oldtype, ompi_datatype_t **newtype )
39 {
40 ompi_datatype_t *type;
41 if( ompi_datatype_is_predefined(oldtype) ) {
42 OBJ_RETAIN(oldtype);
43 *newtype = oldtype;
44 return OMPI_SUCCESS;
45 }
46
47 if ( OMPI_SUCCESS != ompi_datatype_duplicate (oldtype, &type)){
48 ompi_datatype_destroy (&type);
49 return MPI_ERR_INTERN;
50 }
51
52 ompi_datatype_set_args( type, 0, NULL, 0, NULL, 1, &oldtype, MPI_COMBINER_DUP );
53
54 *newtype = type;
55 return OMPI_SUCCESS;
56 }
57
58 int mca_io_ompio_file_set_view (ompi_file_t *fp,
59 OMPI_MPI_OFFSET_TYPE disp,
60 ompi_datatype_t *etype,
61 ompi_datatype_t *filetype,
62 const char *datarep,
63 opal_info_t *info)
64 {
65 int ret=OMPI_SUCCESS;
66 mca_common_ompio_data_t *data;
67 ompio_file_t *fh;
68
69 if ( (strcmp(datarep, "native") && strcmp(datarep, "NATIVE") &&
70 strcmp(datarep, "external32") && strcmp(datarep, "EXTERNAL32"))) {
71 return MPI_ERR_UNSUPPORTED_DATAREP;
72 }
73
74 data = (mca_common_ompio_data_t *) fp->f_io_selected_data;
75
76
77
78
79 fh = &data->ompio_fh;
80
81 OPAL_THREAD_LOCK(&fp->f_lock);
82 ret = mca_common_ompio_set_view(fh, disp, etype, filetype, datarep, info);
83 OPAL_THREAD_UNLOCK(&fp->f_lock);
84 return ret;
85 }
86
87 int mca_io_ompio_file_get_view (struct ompi_file_t *fp,
88 OMPI_MPI_OFFSET_TYPE *disp,
89 struct ompi_datatype_t **etype,
90 struct ompi_datatype_t **filetype,
91 char *datarep)
92 {
93 mca_common_ompio_data_t *data;
94 ompio_file_t *fh;
95
96 data = (mca_common_ompio_data_t *) fp->f_io_selected_data;
97 fh = &data->ompio_fh;
98
99 OPAL_THREAD_LOCK(&fp->f_lock);
100 *disp = fh->f_disp;
101 datatype_duplicate (fh->f_etype, etype);
102 datatype_duplicate (fh->f_orig_filetype, filetype);
103 strcpy (datarep, fh->f_datarep);
104 OPAL_THREAD_UNLOCK(&fp->f_lock);
105
106 return OMPI_SUCCESS;
107 }
108