From 99bdf0f53ee37b983b0e1e0c8e060ccb9ad5198d Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Wed, 17 Apr 2019 22:37:04 +0200 Subject: [PATCH] MPI_File_set_info, MPI_File_get_info, MPI_File_get_position --- src/smpi/bindings/smpi_mpi.cpp | 6 ++--- src/smpi/bindings/smpi_pmpi_file.cpp | 38 +++++++++++++++++++++++++--- src/smpi/include/smpi_file.hpp | 4 +++ src/smpi/mpi/smpi_file.cpp | 18 +++++++++++++ 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/smpi/bindings/smpi_mpi.cpp b/src/smpi/bindings/smpi_mpi.cpp index 16018837e1..d1fb99864c 100644 --- a/src/smpi/bindings/smpi_mpi.cpp +++ b/src/smpi/bindings/smpi_mpi.cpp @@ -354,8 +354,8 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_preallocate,(MPI_File fh, MPI_Offs UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_size,(MPI_File fh, MPI_Offset *size), (fh, size)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_group,(MPI_File fh, MPI_Group *group), (fh, group)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_amode,(MPI_File fh, int *amode), (fh, amode)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_set_info,(MPI_File fh, MPI_Info info), (fh, info)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_info,(MPI_File fh, MPI_Info *info_used), (fh, info_used)) +WRAPPED_PMPI_CALL(int, MPI_File_set_info,(MPI_File fh, MPI_Info info), (fh, info)) +WRAPPED_PMPI_CALL(int, MPI_File_get_info,(MPI_File fh, MPI_Info *info_used), (fh, info_used)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_set_view,(MPI_File fh, MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, char *datarep, MPI_Info info), (fh, disp, etype, filetype, datarep, info)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_view,(MPI_File fh, MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep), (fh, disp, etype, filetype, datarep)) WRAPPED_PMPI_CALL(int, MPI_File_read_at,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, offset, buf, count, datatype, status)) @@ -375,7 +375,7 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iwrite,(MPI_File fh, void *buf, in UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iread_all,(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Request *request), (fh, buf, count, datatype, request)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iwrite_all,(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Request *request), (fh, buf, count, datatype, request)) WRAPPED_PMPI_CALL(int, MPI_File_seek,(MPI_File fh, MPI_Offset offset, int whenace), (fh, offset, whenace)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_position,(MPI_File fh, MPI_Offset *offset), (fh, offset)) +WRAPPED_PMPI_CALL(int, MPI_File_get_position,(MPI_File fh, MPI_Offset *offset), (fh, offset)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_byte_offset,(MPI_File fh, MPI_Offset offset, MPI_Offset *disp), (fh, offset, disp)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_read_shared,(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, buf, count, datatype, status)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_write_shared,(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, buf, count, datatype, status)) diff --git a/src/smpi/bindings/smpi_pmpi_file.cpp b/src/smpi/bindings/smpi_pmpi_file.cpp index 607ce16303..1317eb7e30 100644 --- a/src/smpi/bindings/smpi_pmpi_file.cpp +++ b/src/smpi/bindings/smpi_pmpi_file.cpp @@ -44,10 +44,10 @@ int PMPI_File_close(MPI_File *fh){ } #define CHECK_FILE(fh) if(fh==MPI_FILE_NULL) return MPI_ERR_FILE #define CHECK_BUFFER(buf, count) else if (buf==nullptr && count > 0) return MPI_ERR_BUFFER -#define CHECK_COUNT(count) else if ( count < 0) return MPI_ERR_COUNT -#define CHECK_OFFSET(offset) else if ( offset < 0) return MPI_ERR_DISP -#define PASS_ZEROCOUNT(count) else if ( count == 0) return MPI_SUCCESS -#define CHECK_DATATYPE(datatype, count) else if ( datatype == MPI_DATATYPE_NULL && count > 0) return MPI_ERR_TYPE +#define CHECK_COUNT(count) else if (count < 0) return MPI_ERR_COUNT +#define CHECK_OFFSET(offset) else if (offset < 0) return MPI_ERR_DISP +#define PASS_ZEROCOUNT(count) else if (count == 0) return MPI_SUCCESS +#define CHECK_DATATYPE(datatype, count) else if (datatype == MPI_DATATYPE_NULL && count > 0) return MPI_ERR_TYPE #define CHECK_STATUS(status) else if (status == nullptr) return MPI_ERR_ARG #define CHECK_FLAGS(fh) else if (fh->flags() & MPI_MODE_SEQUENTIAL) return MPI_ERR_AMODE @@ -61,6 +61,19 @@ int PMPI_File_seek(MPI_File fh, MPI_Offset offset, int whence){ } } + +int PMPI_File_get_position(MPI_File fh, MPI_Offset* offset){ + CHECK_FILE(fh); + else if (offset==nullptr) + return MPI_ERR_DISP; + else { + smpi_bench_end(); + int ret = fh->get_position(offset); + smpi_bench_begin(); + return ret; + } +} + int PMPI_File_read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ CHECK_FILE(fh); CHECK_BUFFER(buf, count); @@ -236,3 +249,20 @@ int PMPI_File_delete(char *filename, MPI_Info info){ } } +int PMPI_File_get_info(MPI_File fh, MPI_Info* info) +{ + CHECK_FILE(fh); + else { + *info = fh->info(); + return MPI_SUCCESS; + } +} + +int PMPI_File_set_info(MPI_File fh, MPI_Info info) +{ + CHECK_FILE(fh); + else { + fh->set_info(info); + return MPI_SUCCESS; + } +} \ No newline at end of file diff --git a/src/smpi/include/smpi_file.hpp b/src/smpi/include/smpi_file.hpp index 7b2cdff441..7c89f8bd6c 100644 --- a/src/smpi/include/smpi_file.hpp +++ b/src/smpi/include/smpi_file.hpp @@ -21,13 +21,17 @@ class File{ int flags_; simgrid::s4u::File* file_; MPI_Info info_; + MPI_Offset shared_file_pointer_; public: File(MPI_Comm comm, char *filename, int amode, MPI_Info info); ~File(); int size(); + int get_position(MPI_Offset* offset); int flags(); int sync(); int seek(MPI_Offset offset, int whence); + MPI_Info info(); + void set_info( MPI_Info info); static int read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status); static int write(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status); template int op_all(void *buf, int count,MPI_Datatype datatype, MPI_Status *status); diff --git a/src/smpi/mpi/smpi_file.cpp b/src/smpi/mpi/smpi_file.cpp index a7cfe397f5..6006b4d848 100644 --- a/src/smpi/mpi/smpi_file.cpp +++ b/src/smpi/mpi/smpi_file.cpp @@ -40,6 +40,11 @@ namespace smpi{ return MPI_SUCCESS; } + int File::get_position(MPI_Offset* offset){ + *offset=file_->tell(); + return MPI_SUCCESS; + } + int File::seek(MPI_Offset offset, int whence){ switch(whence){ case(MPI_SEEK_SET): @@ -103,5 +108,18 @@ namespace smpi{ //no idea return simgrid::smpi::Colls::barrier(comm_); } +MPI_Info File::info(){ + if(info_== MPI_INFO_NULL) + info_ = new Info(); + info_->ref(); + return info_; +} + +void File::set_info(MPI_Info info){ + if(info_!= MPI_INFO_NULL) + info->ref(); + info_=info; +} + } } -- 2.20.1