X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ea74f5d95928a521a588737e81f1de94eef25d19..db41dc7d999a5792aca42198b5bc87edb2dbfcce:/src/smpi/bindings/smpi_pmpi_file.cpp diff --git a/src/smpi/bindings/smpi_pmpi_file.cpp b/src/smpi/bindings/smpi_pmpi_file.cpp index 70df57f25d..bf7d6ff1b4 100644 --- a/src/smpi/bindings/smpi_pmpi_file.cpp +++ b/src/smpi/bindings/smpi_pmpi_file.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -38,6 +38,7 @@ extern MPI_Errhandler SMPI_default_File_Errhandler; int PMPI_File_open(MPI_Comm comm, const char *filename, int amode, MPI_Info info, MPI_File *fh){ CHECK_COMM(1) + CHECK_COLLECTIVE(comm, "MPI_File_open") CHECK_NULL(2, MPI_ERR_FILE, filename) if (amode < 0) return MPI_ERR_AMODE; @@ -54,6 +55,7 @@ int PMPI_File_open(MPI_Comm comm, const char *filename, int amode, MPI_Info info int PMPI_File_close(MPI_File *fh){ CHECK_NULL(2, MPI_ERR_ARG, fh) + CHECK_COLLECTIVE((*fh)->comm(), __func__) const SmpiBenchGuard suspend_bench; int ret = simgrid::smpi::File::close(fh); *fh = MPI_FILE_NULL; @@ -63,14 +65,15 @@ int PMPI_File_close(MPI_File *fh){ int PMPI_File_seek(MPI_File fh, MPI_Offset offset, int whence){ CHECK_FILE(1, fh) const SmpiBenchGuard suspend_bench; - int ret = fh->seek(offset,whence); + int ret = fh->seek(offset*fh->etype()->get_extent(),whence); return ret; } int PMPI_File_seek_shared(MPI_File fh, MPI_Offset offset, int whence){ CHECK_FILE(1, fh) + CHECK_COLLECTIVE(fh->comm(), __func__) const SmpiBenchGuard suspend_bench; - int ret = fh->seek_shared(offset,whence); + int ret = fh->seek_shared(offset*fh->etype()->get_extent(),whence); return ret; } @@ -143,6 +146,7 @@ int PMPI_File_write_shared(MPI_File fh, const void *buf, int count,MPI_Datatype int PMPI_File_read_all(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ CHECK_FILE_INPUTS CHECK_WRONLY(fh) + CHECK_COLLECTIVE(fh->comm(), __func__) const SmpiBenchGuard suspend_bench; aid_t rank_traced = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_all", count * datatype->size())); @@ -154,6 +158,7 @@ int PMPI_File_read_all(MPI_File fh, void *buf, int count,MPI_Datatype datatype, int PMPI_File_read_ordered(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ CHECK_FILE_INPUTS CHECK_WRONLY(fh) + CHECK_COLLECTIVE(fh->comm(), __func__) const SmpiBenchGuard suspend_bench; aid_t rank_traced = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(rank_traced, __func__, @@ -166,6 +171,7 @@ int PMPI_File_read_ordered(MPI_File fh, void *buf, int count,MPI_Datatype dataty int PMPI_File_write_all(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ CHECK_FILE_INPUTS CHECK_RDONLY(fh) + CHECK_COLLECTIVE(fh->comm(), __func__) const SmpiBenchGuard suspend_bench; aid_t rank_traced = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_all", count * datatype->size())); @@ -177,6 +183,7 @@ int PMPI_File_write_all(MPI_File fh, const void *buf, int count,MPI_Datatype dat int PMPI_File_write_ordered(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ CHECK_FILE_INPUTS CHECK_RDONLY(fh) + CHECK_COLLECTIVE(fh->comm(), __func__) const SmpiBenchGuard suspend_bench; aid_t rank_traced = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(rank_traced, __func__, @@ -193,9 +200,12 @@ int PMPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_D const SmpiBenchGuard suspend_bench; aid_t rank_traced = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read", count * datatype->size())); + MPI_Offset prev; + fh->get_position(&prev); int ret = fh->seek(offset,MPI_SEEK_SET); if (ret == MPI_SUCCESS) ret = simgrid::smpi::File::read(fh, buf, count, datatype, status); + fh->seek(prev,MPI_SEEK_SET); TRACE_smpi_comm_out(rank_traced); return ret; } @@ -203,13 +213,17 @@ int PMPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_D int PMPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ CHECK_FILE_INPUT_OFFSET CHECK_WRONLY(fh) + CHECK_COLLECTIVE(fh->comm(), __func__) const SmpiBenchGuard suspend_bench; aid_t rank_traced = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_at_all", count * datatype->size())); + MPI_Offset prev; + fh->get_position(&prev); int ret = fh->seek(offset,MPI_SEEK_SET); if (ret == MPI_SUCCESS) ret = fh->op_all(buf, count, datatype, status); + fh->seek(prev,MPI_SEEK_SET); TRACE_smpi_comm_out(rank_traced); return ret; } @@ -221,9 +235,12 @@ int PMPI_File_write_at(MPI_File fh, MPI_Offset offset, const void *buf, int coun const SmpiBenchGuard suspend_bench; aid_t rank_traced = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", count * datatype->size())); + MPI_Offset prev; + fh->get_position(&prev); int ret = fh->seek(offset,MPI_SEEK_SET); if (ret == MPI_SUCCESS) ret = simgrid::smpi::File::write(fh, const_cast(buf), count, datatype, status); + fh->seek(prev,MPI_SEEK_SET); TRACE_smpi_comm_out(rank_traced); return ret; } @@ -231,20 +248,23 @@ int PMPI_File_write_at(MPI_File fh, MPI_Offset offset, const void *buf, int coun int PMPI_File_write_at_all(MPI_File fh, MPI_Offset offset, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ CHECK_FILE_INPUT_OFFSET CHECK_RDONLY(fh) + CHECK_COLLECTIVE(fh->comm(), __func__) const SmpiBenchGuard suspend_bench; aid_t rank_traced = simgrid::s4u::this_actor::get_pid(); TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_at_all", count * datatype->size())); + MPI_Offset prev; + fh->get_position(&prev); int ret = fh->seek(offset,MPI_SEEK_SET); if (ret == MPI_SUCCESS) ret = fh->op_all(const_cast(buf), count, datatype, status); + fh->seek(prev,MPI_SEEK_SET); TRACE_smpi_comm_out(rank_traced); return ret; } int PMPI_File_delete(const char *filename, MPI_Info info){ - if (filename == nullptr) - return MPI_ERR_FILE; + CHECK_NULL(1, MPI_ERR_FILE, filename) const SmpiBenchGuard suspend_bench; int ret = simgrid::smpi::File::del(filename, info); return ret; @@ -252,6 +272,7 @@ int PMPI_File_delete(const char *filename, MPI_Info info){ int PMPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char *datarep, MPI_Info info){ CHECK_FILE(1, fh) + CHECK_COLLECTIVE(fh->comm(), __func__) if(not ((fh->flags() & MPI_MODE_SEQUENTIAL) && (disp == MPI_DISPLACEMENT_CURRENT))) CHECK_OFFSET(2, disp) CHECK_TYPE(3, etype) @@ -295,6 +316,7 @@ int PMPI_File_get_size(MPI_File fh, MPI_Offset* size) int PMPI_File_set_size(MPI_File fh, MPI_Offset size) { CHECK_FILE(1, fh) + CHECK_COLLECTIVE(fh->comm(), __func__) fh->set_size(size); return MPI_SUCCESS; } @@ -348,11 +370,37 @@ int PMPI_File_set_errhandler(MPI_File file, MPI_Errhandler errhandler){ } int PMPI_File_call_errhandler(MPI_File file,int errorcode){ - if (file == nullptr) { - return MPI_ERR_WIN; - } + CHECK_FILE(1, file) MPI_Errhandler err = file->errhandler(); err->call(file, errorcode); simgrid::smpi::Errhandler::unref(err); return MPI_SUCCESS; } + +int PMPI_File_get_type_extent(MPI_File fh, MPI_Datatype + datatype, MPI_Aint *extent){ + CHECK_FILE(1, fh) + CHECK_TYPE(2, datatype) + CHECK_NULL(3, MPI_ERR_OTHER, extent) + *extent = datatype->get_extent(); + return MPI_SUCCESS; +} + +int PMPI_File_set_atomicity(MPI_File fh, int a){ + CHECK_FILE(1, fh) + fh->set_atomicity(a != 0); + return MPI_SUCCESS; +} + +int PMPI_File_get_atomicity(MPI_File fh, int* a){ + CHECK_FILE(1, fh) + *a = fh->get_atomicity(); + return MPI_SUCCESS; +} + +int PMPI_File_get_byte_offset(MPI_File fh, MPI_Offset offset, MPI_Offset *disp){ + CHECK_FILE(1, fh) + CHECK_NULL(3, MPI_ERR_OTHER, disp) + *disp = offset * fh->etype()->get_extent(); + return MPI_SUCCESS; +}