[97] | 1 | // -*- c++ -*- |
---|
| 2 | // |
---|
| 3 | // Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana |
---|
| 4 | // University Research and Technology |
---|
| 5 | // Corporation. All rights reserved. |
---|
| 6 | // Copyright (c) 2004-2005 The University of Tennessee and The University |
---|
| 7 | // of Tennessee Research Foundation. All rights |
---|
| 8 | // reserved. |
---|
| 9 | // Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, |
---|
| 10 | // University of Stuttgart. All rights reserved. |
---|
| 11 | // Copyright (c) 2004-2005 The Regents of the University of California. |
---|
| 12 | // All rights reserved. |
---|
| 13 | // Copyright (c) 2006-2008 Cisco Systems, Inc. All rights reserved. |
---|
| 14 | // $COPYRIGHT$ |
---|
| 15 | // |
---|
| 16 | // Additional copyrights may follow |
---|
| 17 | // |
---|
| 18 | // $HEADER$ |
---|
| 19 | // |
---|
| 20 | |
---|
| 21 | // Typedefs for C++ callbacks registered via MPI::Register_datarep |
---|
| 22 | typedef void Datarep_extent_function(const Datatype& datatype, |
---|
| 23 | Aint& file_extent, void* extra_state); |
---|
| 24 | typedef void Datarep_conversion_function(void* userbuf, Datatype& datatype, |
---|
| 25 | int count, void* filebuf, |
---|
| 26 | Offset position, void* extra_state); |
---|
| 27 | |
---|
| 28 | // Both callback functions in C++ |
---|
| 29 | void Register_datarep(const char* datarep, |
---|
| 30 | Datarep_conversion_function* read_conversion_fn, |
---|
| 31 | Datarep_conversion_function* write_conversion_fn, |
---|
| 32 | Datarep_extent_function* dtype_file_extent_fn, |
---|
| 33 | void* extra_state); |
---|
| 34 | |
---|
| 35 | // Overload for C read callback function (MPI_CONVERSION_FN_NULL) |
---|
| 36 | void Register_datarep(const char* datarep, |
---|
| 37 | MPI_Datarep_conversion_function* read_conversion_fn, |
---|
| 38 | Datarep_conversion_function* write_conversion_fn, |
---|
| 39 | Datarep_extent_function* dtype_file_extent_fn, |
---|
| 40 | void* extra_state); |
---|
| 41 | |
---|
| 42 | // Overload for C write callback function (MPI_CONVERSION_FN_NULL) |
---|
| 43 | void Register_datarep(const char* datarep, |
---|
| 44 | Datarep_conversion_function* read_conversion_fn, |
---|
| 45 | MPI_Datarep_conversion_function* write_conversion_fn, |
---|
| 46 | Datarep_extent_function* dtype_file_extent_fn, |
---|
| 47 | void* extra_state); |
---|
| 48 | |
---|
| 49 | // Overload for C read and write callback functions (MPI_CONVERSION_FN_NULL) |
---|
| 50 | void Register_datarep(const char* datarep, |
---|
| 51 | MPI_Datarep_conversion_function* read_conversion_fn, |
---|
| 52 | MPI_Datarep_conversion_function* write_conversion_fn, |
---|
| 53 | Datarep_extent_function* dtype_file_extent_fn, |
---|
| 54 | void* extra_state); |
---|
| 55 | |
---|
| 56 | class File { |
---|
| 57 | #if 0 /* OMPI_ENABLE_MPI_PROFILING */ |
---|
| 58 | // friend class P; |
---|
| 59 | |
---|
| 60 | #endif |
---|
| 61 | friend class MPI::Comm; //so I can access pmpi_file data member in comm.cc |
---|
| 62 | friend class MPI::Request; //and also from request.cc |
---|
| 63 | |
---|
| 64 | public: |
---|
| 65 | #if 0 /* OMPI_ENABLE_MPI_PROFILING */ |
---|
| 66 | |
---|
| 67 | // construction / destruction |
---|
| 68 | File() { } |
---|
| 69 | virtual ~File() { } |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | // copy / assignment |
---|
| 73 | File(const File& data) : pmpi_file(data.pmpi_file) { } |
---|
| 74 | |
---|
| 75 | File(MPI_File i) : pmpi_file(i) { } |
---|
| 76 | |
---|
| 77 | File& operator=(const File& data) { |
---|
| 78 | pmpi_file = data.pmpi_file; return *this; } |
---|
| 79 | |
---|
| 80 | // comparison, don't need for file |
---|
| 81 | |
---|
| 82 | // inter-language operability |
---|
| 83 | File& operator= (const MPI_File &i) { |
---|
| 84 | pmpi_file = i; return *this; } |
---|
| 85 | operator MPI_File () const { return pmpi_file; } |
---|
| 86 | // operator MPI_File* () const { return pmpi_file; } |
---|
| 87 | operator const PMPI::File&() const { return pmpi_file; } |
---|
| 88 | |
---|
| 89 | #else |
---|
| 90 | |
---|
| 91 | File() : mpi_file(MPI_FILE_NULL) { } |
---|
| 92 | // copy |
---|
| 93 | File(const File& data) : mpi_file(data.mpi_file) { } |
---|
| 94 | |
---|
| 95 | File(MPI_File i) : mpi_file(i) { } |
---|
| 96 | |
---|
| 97 | virtual ~File() { } |
---|
| 98 | |
---|
| 99 | File& operator=(const File& data) { |
---|
| 100 | mpi_file = data.mpi_file; return *this; } |
---|
| 101 | |
---|
| 102 | // comparison, don't need for file |
---|
| 103 | |
---|
| 104 | // inter-language operability |
---|
| 105 | File& operator= (const MPI_File &i) { |
---|
| 106 | mpi_file = i; return *this; } |
---|
| 107 | operator MPI_File () const { return mpi_file; } |
---|
| 108 | // operator MPI_File* () const { return (MPI_File*)&mpi_file; } |
---|
| 109 | |
---|
| 110 | #endif |
---|
| 111 | |
---|
| 112 | // from the I/o chapter of MPI - 2 |
---|
| 113 | |
---|
| 114 | void Close(); |
---|
| 115 | |
---|
| 116 | static void Delete(const char* filename, const MPI::Info& info); |
---|
| 117 | |
---|
| 118 | int Get_amode() const; |
---|
| 119 | |
---|
| 120 | bool Get_atomicity() const; |
---|
| 121 | |
---|
| 122 | MPI::Offset Get_byte_offset(const MPI::Offset disp) const; |
---|
| 123 | |
---|
| 124 | MPI::Group Get_group() const; |
---|
| 125 | |
---|
| 126 | MPI::Info Get_info() const; |
---|
| 127 | |
---|
| 128 | MPI::Offset Get_position() const; |
---|
| 129 | |
---|
| 130 | MPI::Offset Get_position_shared() const; |
---|
| 131 | |
---|
| 132 | MPI::Offset Get_size() const; |
---|
| 133 | |
---|
| 134 | MPI::Aint Get_type_extent(const MPI::Datatype& datatype) const; |
---|
| 135 | |
---|
| 136 | void Get_view(MPI::Offset& disp, MPI::Datatype& etype, |
---|
| 137 | MPI::Datatype& filetype, char* datarep) const; |
---|
| 138 | |
---|
| 139 | MPI::Request Iread(void* buf, int count, |
---|
| 140 | const MPI::Datatype& datatype); |
---|
| 141 | |
---|
| 142 | MPI::Request Iread_at(MPI::Offset offset, void* buf, int count, |
---|
| 143 | const MPI::Datatype& datatype); |
---|
| 144 | |
---|
| 145 | MPI::Request Iread_shared(void* buf, int count, |
---|
| 146 | const MPI::Datatype& datatype); |
---|
| 147 | |
---|
| 148 | MPI::Request Iwrite(const void* buf, int count, |
---|
| 149 | const MPI::Datatype& datatype); |
---|
| 150 | |
---|
| 151 | MPI::Request Iwrite_at(MPI::Offset offset, const void* buf, |
---|
| 152 | int count, const MPI::Datatype& datatype); |
---|
| 153 | |
---|
| 154 | MPI::Request Iwrite_shared(const void* buf, int count, |
---|
| 155 | const MPI::Datatype& datatype); |
---|
| 156 | |
---|
| 157 | static MPI::File Open(const MPI::Intracomm& comm, |
---|
| 158 | const char* filename, int amode, |
---|
| 159 | const MPI::Info& info); |
---|
| 160 | |
---|
| 161 | void Preallocate(MPI::Offset size); |
---|
| 162 | |
---|
| 163 | void Read(void* buf, int count, const MPI::Datatype& datatype); |
---|
| 164 | |
---|
| 165 | void Read(void* buf, int count, const MPI::Datatype& datatype, |
---|
| 166 | MPI::Status& status); |
---|
| 167 | |
---|
| 168 | void Read_all(void* buf, int count, const MPI::Datatype& datatype); |
---|
| 169 | |
---|
| 170 | void Read_all(void* buf, int count, const MPI::Datatype& datatype, |
---|
| 171 | MPI::Status& status); |
---|
| 172 | |
---|
| 173 | void Read_all_begin(void* buf, int count, |
---|
| 174 | const MPI::Datatype& datatype); |
---|
| 175 | |
---|
| 176 | void Read_all_end(void* buf); |
---|
| 177 | |
---|
| 178 | void Read_all_end(void* buf, MPI::Status& status); |
---|
| 179 | |
---|
| 180 | void Read_at(MPI::Offset offset, |
---|
| 181 | void* buf, int count, const MPI::Datatype& datatype); |
---|
| 182 | |
---|
| 183 | void Read_at(MPI::Offset offset, void* buf, int count, |
---|
| 184 | const MPI::Datatype& datatype, MPI::Status& status); |
---|
| 185 | |
---|
| 186 | void Read_at_all(MPI::Offset offset, void* buf, int count, |
---|
| 187 | const MPI::Datatype& datatype); |
---|
| 188 | |
---|
| 189 | void Read_at_all(MPI::Offset offset, void* buf, int count, |
---|
| 190 | const MPI::Datatype& datatype, MPI::Status& status); |
---|
| 191 | |
---|
| 192 | void Read_at_all_begin(MPI::Offset offset, void* buf, int count, |
---|
| 193 | const MPI::Datatype& datatype); |
---|
| 194 | |
---|
| 195 | void Read_at_all_end(void* buf); |
---|
| 196 | |
---|
| 197 | void Read_at_all_end(void* buf, MPI::Status& status); |
---|
| 198 | |
---|
| 199 | void Read_ordered(void* buf, int count, |
---|
| 200 | const MPI::Datatype& datatype); |
---|
| 201 | |
---|
| 202 | void Read_ordered(void* buf, int count, |
---|
| 203 | const MPI::Datatype& datatype, |
---|
| 204 | MPI::Status& status); |
---|
| 205 | |
---|
| 206 | void Read_ordered_begin(void* buf, int count, |
---|
| 207 | const MPI::Datatype& datatype); |
---|
| 208 | |
---|
| 209 | void Read_ordered_end(void* buf); |
---|
| 210 | |
---|
| 211 | void Read_ordered_end(void* buf, MPI::Status& status); |
---|
| 212 | |
---|
| 213 | void Read_shared(void* buf, int count, |
---|
| 214 | const MPI::Datatype& datatype); |
---|
| 215 | |
---|
| 216 | void Read_shared(void* buf, int count, |
---|
| 217 | const MPI::Datatype& datatype, MPI::Status& status); |
---|
| 218 | |
---|
| 219 | void Seek(MPI::Offset offset, int whence); |
---|
| 220 | |
---|
| 221 | void Seek_shared(MPI::Offset offset, int whence); |
---|
| 222 | |
---|
| 223 | void Set_atomicity(bool flag); |
---|
| 224 | |
---|
| 225 | void Set_info(const MPI::Info& info); |
---|
| 226 | |
---|
| 227 | void Set_size(MPI::Offset size); |
---|
| 228 | |
---|
| 229 | void Set_view(MPI::Offset disp, const MPI::Datatype& etype, |
---|
| 230 | const MPI::Datatype& filetype, const char* datarep, |
---|
| 231 | const MPI::Info& info); |
---|
| 232 | |
---|
| 233 | void Sync(); |
---|
| 234 | |
---|
| 235 | void Write(const void* buf, int count, |
---|
| 236 | const MPI::Datatype& datatype); |
---|
| 237 | |
---|
| 238 | void Write(const void* buf, int count, |
---|
| 239 | const MPI::Datatype& datatype, MPI::Status& status); |
---|
| 240 | |
---|
| 241 | void Write_all(const void* buf, int count, |
---|
| 242 | const MPI::Datatype& datatype); |
---|
| 243 | |
---|
| 244 | void Write_all(const void* buf, int count, |
---|
| 245 | const MPI::Datatype& datatype, MPI::Status& status); |
---|
| 246 | |
---|
| 247 | void Write_all_begin(const void* buf, int count, |
---|
| 248 | const MPI::Datatype& datatype); |
---|
| 249 | |
---|
| 250 | void Write_all_end(const void* buf); |
---|
| 251 | |
---|
| 252 | void Write_all_end(const void* buf, MPI::Status& status); |
---|
| 253 | |
---|
| 254 | void Write_at(MPI::Offset offset, const void* buf, int count, |
---|
| 255 | const MPI::Datatype& datatype); |
---|
| 256 | |
---|
| 257 | void Write_at(MPI::Offset offset, const void* buf, int count, |
---|
| 258 | const MPI::Datatype& datatype, MPI::Status& status); |
---|
| 259 | |
---|
| 260 | void Write_at_all(MPI::Offset offset, const void* buf, int count, |
---|
| 261 | const MPI::Datatype& datatype); |
---|
| 262 | |
---|
| 263 | void Write_at_all(MPI::Offset offset, const void* buf, int count, |
---|
| 264 | const MPI::Datatype& datatype, |
---|
| 265 | MPI::Status& status); |
---|
| 266 | |
---|
| 267 | void Write_at_all_begin(MPI::Offset offset, const void* buf, |
---|
| 268 | int count, const MPI::Datatype& datatype); |
---|
| 269 | |
---|
| 270 | void Write_at_all_end(const void* buf); |
---|
| 271 | |
---|
| 272 | void Write_at_all_end(const void* buf, MPI::Status& status); |
---|
| 273 | |
---|
| 274 | void Write_ordered(const void* buf, int count, |
---|
| 275 | const MPI::Datatype& datatype); |
---|
| 276 | |
---|
| 277 | void Write_ordered(const void* buf, int count, |
---|
| 278 | const MPI::Datatype& datatype, MPI::Status& status); |
---|
| 279 | |
---|
| 280 | void Write_ordered_begin(const void* buf, int count, |
---|
| 281 | const MPI::Datatype& datatype); |
---|
| 282 | |
---|
| 283 | void Write_ordered_end(const void* buf); |
---|
| 284 | |
---|
| 285 | void Write_ordered_end(const void* buf, MPI::Status& status); |
---|
| 286 | |
---|
| 287 | void Write_shared(const void* buf, int count, |
---|
| 288 | const MPI::Datatype& datatype); |
---|
| 289 | |
---|
| 290 | void Write_shared(const void* buf, int count, |
---|
| 291 | const MPI::Datatype& datatype, MPI::Status& status); |
---|
| 292 | |
---|
| 293 | // |
---|
| 294 | // Errhandler |
---|
| 295 | // |
---|
| 296 | typedef void Errhandler_fn(MPI::File &, int *, ... ); |
---|
| 297 | |
---|
| 298 | static MPI::Errhandler Create_errhandler(Errhandler_fn* function); |
---|
| 299 | |
---|
| 300 | MPI::Errhandler Get_errhandler() const; |
---|
| 301 | |
---|
| 302 | void Set_errhandler(const MPI::Errhandler& errhandler) const; |
---|
| 303 | |
---|
| 304 | void Call_errhandler(int errorcode) const; |
---|
| 305 | |
---|
| 306 | protected: |
---|
| 307 | #if 0 /* OMPI_ENABLE_MPI_PROFILING */ |
---|
| 308 | PMPI::File pmpi_file; |
---|
| 309 | |
---|
| 310 | #else |
---|
| 311 | MPI_File mpi_file; |
---|
| 312 | |
---|
| 313 | #endif |
---|
| 314 | }; |
---|
| 315 | |
---|