From: Augustin Degomme Date: Thu, 18 Apr 2019 18:19:09 +0000 (+0200) Subject: Merge branch 'file' into 'master' X-Git-Tag: v3.22.2~101 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/dc1369e2055686dde3d178efb2001dbad8972d54?hp=56f88f273939075ab766b7c8348ef35fa455ea0b Merge branch 'file' into 'master' MPI IO See merge request simgrid/simgrid!6 --- diff --git a/include/smpi/forward.hpp b/include/smpi/forward.hpp index b23b1856af..e3039c42a8 100644 --- a/include/smpi/forward.hpp +++ b/include/smpi/forward.hpp @@ -17,6 +17,7 @@ class Coll; class Colls; class Comm; class Datatype; +class File; class Group; class Info; class Keyval; @@ -35,6 +36,7 @@ class Win; typedef simgrid::smpi::Comm SMPI_Comm; typedef simgrid::smpi::Datatype SMPI_Datatype; +typedef simgrid::smpi::File SMPI_File; typedef simgrid::smpi::Group SMPI_Group; typedef simgrid::smpi::Info SMPI_Info; typedef simgrid::smpi::Op SMPI_Op; @@ -49,6 +51,7 @@ typedef simgrid::smpi::Win SMPI_Win; typedef struct SMPI_Comm SMPI_Comm; typedef struct SMPI_Datatype SMPI_Datatype; +typedef struct SMPI_File SMPI_File; typedef struct SMPI_Group SMPI_Group; typedef struct SMPI_Info SMPI_Info; typedef struct SMPI_Op SMPI_Op; diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 1f19913b04..4bd628459b 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -214,10 +214,7 @@ typedef ptrdiff_t MPI_Aint; typedef long long MPI_Offset; typedef long long MPI_Count; -struct s_MPI_File; -typedef struct s_MPI_File *MPI_File; - - +typedef SMPI_File *MPI_File; typedef SMPI_Datatype *MPI_Datatype; typedef struct { diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index b28d3d846f..6eb42eed54 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -138,10 +138,10 @@ sg_size_t File::write(sg_size_t size) this_actor::parallel_execute(m_host_list, flops_amount, bytes_amount); } - XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", get_path(), local_storage_->get_cname(), size, size_); + XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu' '%llu:%llu'", get_path(), local_storage_->get_cname(), size, size_, sg_storage_get_size_used(local_storage_), sg_storage_get_size(local_storage_)); // If the storage is full before even starting to write - if (sg_storage_get_size_used(local_storage_) >= sg_storage_get_size(local_storage_)) - return 0; + // if (sg_storage_get_size_used(local_storage_) >= sg_storage_get_size(local_storage_)) + // return 0; /* Substract the part of the file that might disappear from the used sized on the storage element */ local_storage_->extension()->decr_used_size(size_ - current_position_); diff --git a/src/smpi/bindings/smpi_mpi.cpp b/src/smpi/bindings/smpi_mpi.cpp index 3a354e0fc8..9f004cd8be 100644 --- a/src/smpi/bindings/smpi_mpi.cpp +++ b/src/smpi/bindings/smpi_mpi.cpp @@ -305,6 +305,28 @@ WRAPPED_PMPI_CALL(int, MPI_Cancel,(MPI_Request* request) ,(request)) WRAPPED_PMPI_CALL(int, MPI_Test_cancelled,(MPI_Status* status, int* flag) ,(status, flag)) WRAPPED_PMPI_CALL(int, MPI_Status_set_cancelled,(MPI_Status *status,int flag),(status,flag)) WRAPPED_PMPI_CALL(int,MPI_Status_set_elements,( MPI_Status *status, MPI_Datatype datatype, int count),( status, datatype, count)) +WRAPPED_PMPI_CALL(int, MPI_File_open,(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh),(comm, filename, amode, info, fh)) +WRAPPED_PMPI_CALL(int, MPI_File_close,(MPI_File *fh), (fh)) +WRAPPED_PMPI_CALL(int, MPI_File_delete,(char *filename, MPI_Info info), (filename, info)) +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)) +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)) +WRAPPED_PMPI_CALL(int, MPI_File_read_at_all,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, offset, buf, count, datatype, status)) +WRAPPED_PMPI_CALL(int, MPI_File_write_at,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, offset, buf, count, datatype, status)) +WRAPPED_PMPI_CALL(int, MPI_File_write_at_all,(MPI_File fh, MPI_Offset offset, void *buf,int count, MPI_Datatype datatype, MPI_Status *status), (fh, offset, buf, count, datatype, status)) +WRAPPED_PMPI_CALL(int, MPI_File_read,(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status), (fh, buf, count, datatype, status)) +WRAPPED_PMPI_CALL(int, MPI_File_read_all,(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, buf, count, datatype, status)) +WRAPPED_PMPI_CALL(int, MPI_File_write,(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, buf, count, datatype, status)) +WRAPPED_PMPI_CALL(int, MPI_File_write_all,(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status), (fh, buf, count, datatype, status)) +WRAPPED_PMPI_CALL(int, MPI_File_seek,(MPI_File fh, MPI_Offset offset, int whenace), (fh, offset, whenace)) +WRAPPED_PMPI_CALL(int, MPI_File_get_position,(MPI_File fh, MPI_Offset *offset), (fh, offset)) +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)) +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)) +WRAPPED_PMPI_CALL(int, MPI_File_read_ordered,(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status), (fh, buf, count, datatype, status)) +WRAPPED_PMPI_CALL(int, MPI_File_write_ordered,(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, buf, count, datatype, status)) +WRAPPED_PMPI_CALL(int, MPI_File_seek_shared,(MPI_File fh, MPI_Offset offset, int whence), (fh, offset, whence)) +WRAPPED_PMPI_CALL(int, MPI_File_get_position_shared,(MPI_File fh, MPI_Offset *offset), (fh, offset)) + /* Unimplemented Calls - both PMPI and MPI calls are generated. When implementing, please move ahead, swap UNIMPLEMENTED_WRAPPED_PMPI_CALL for WRAPPED_PMPI_CALL, @@ -346,45 +368,24 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_call_errhandler,(MPI_File fh, int UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_create_errhandler,(MPI_File_errhandler_function *function, MPI_Errhandler *errhandler),(function, errhandler)) UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int, MPI_File_set_errhandler,( MPI_File file, MPI_Errhandler errhandler), (file, errhandler)) UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int, MPI_File_get_errhandler,( MPI_File file, MPI_Errhandler *errhandler), (file, errhandler)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_open,(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh),(comm, filename, amode, info, fh)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_close,(MPI_File *fh), (fh)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_delete,(char *filename, MPI_Info info), (filename, info)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_set_size,(MPI_File fh, MPI_Offset size), (fh, size)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_preallocate,(MPI_File fh, MPI_Offset size), (fh, size)) 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)) 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)) -UNIMPLEMENTED_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)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_read_at_all,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, offset, buf, count, datatype, status)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_write_at,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Status *status), (fh, offset, buf, count, datatype, status)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_write_at_all,(MPI_File fh, MPI_Offset offset, void *buf,int count, MPI_Datatype datatype, MPI_Status *status), (fh, offset, buf, count, datatype, status)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iread_at,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Request *request), (fh, offset, buf, count, datatype, request)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iwrite_at,(MPI_File fh, MPI_Offset offset, void *buf,int count, MPI_Datatype datatype, MPI_Request *request), (fh, offset, buf, count, datatype, request)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iread_at_all,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Request *request), (fh, offset, buf, count, datatype, request)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iwrite_at_all,(MPI_File fh, MPI_Offset offset, void *buf,int count, MPI_Datatype datatype, MPI_Request *request), (fh, offset, buf, count, datatype, request)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_read,(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_read_all,(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,(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_all,(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_iread,(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,(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_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)) -UNIMPLEMENTED_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)) 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)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_iread_shared,(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_shared,(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_read_ordered,(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_ordered,(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_seek_shared,(MPI_File fh, MPI_Offset offset, int whence), (fh, offset, whence)) -UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_position_shared,(MPI_File fh, MPI_Offset *offset), (fh, offset)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_read_at_all_begin,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype), (fh, offset, buf, count, datatype)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_read_at_all_end,(MPI_File fh, void *buf, MPI_Status *status), (fh, buf, status)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_write_at_all_begin,(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype), (fh, offset, buf, count, datatype)) diff --git a/src/smpi/bindings/smpi_pmpi_file.cpp b/src/smpi/bindings/smpi_pmpi_file.cpp new file mode 100644 index 0000000000..dc03edffba --- /dev/null +++ b/src/smpi/bindings/smpi_pmpi_file.cpp @@ -0,0 +1,327 @@ +/* Copyright (c) 2007-2019. 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. */ + +#include "private.hpp" +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi); + +#include "smpi_file.hpp" +#include "smpi_datatype.hpp" + + +int PMPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh){ + if (comm == MPI_COMM_NULL) + return MPI_ERR_COMM; + if (filename == nullptr) + return MPI_ERR_FILE; + if (amode < 0) + return MPI_ERR_AMODE; + smpi_bench_end(); + *fh = new simgrid::smpi::File(comm, filename, amode, info); + smpi_bench_begin(); + if (((*fh)->size() == 0 && (not amode & MPI_MODE_CREATE)) || + ((*fh)->size() != 0 && (amode & MPI_MODE_EXCL))){ + delete fh; + return MPI_ERR_AMODE; + } + if(amode & MPI_MODE_APPEND) + (*fh)->seek(0,MPI_SEEK_END); + return MPI_SUCCESS; +} + +int PMPI_File_close(MPI_File *fh){ + if (fh==nullptr) + return MPI_ERR_ARG; + smpi_bench_end(); + int ret = simgrid::smpi::File::close(fh); + *fh = MPI_FILE_NULL; + smpi_bench_begin(); + return ret; +} +#define CHECK_FILE(fh) if(fh==MPI_FILE_NULL) return MPI_ERR_FILE; +#define CHECK_BUFFER(buf, count) if (buf==nullptr && count > 0) return MPI_ERR_BUFFER; +#define CHECK_COUNT(count) if (count < 0) return MPI_ERR_COUNT; +#define CHECK_OFFSET(offset) if (offset < 0) return MPI_ERR_DISP; +#define CHECK_DATATYPE(datatype, count) if (datatype == MPI_DATATYPE_NULL && count > 0) return MPI_ERR_TYPE; +#define CHECK_STATUS(status) if (status == nullptr) return MPI_ERR_ARG; +#define CHECK_FLAGS(fh) if (fh->flags() & MPI_MODE_SEQUENTIAL) return MPI_ERR_AMODE; + +#define PASS_ZEROCOUNT(count) if (count == 0) {\ +status->count=0;\ +return MPI_SUCCESS;\ +} + +int PMPI_File_seek(MPI_File fh, MPI_Offset offset, int whence){ + CHECK_FILE(fh); + smpi_bench_end(); + int ret = fh->seek(offset,whence); + smpi_bench_begin(); + return ret; + +} + +int PMPI_File_seek_shared(MPI_File fh, MPI_Offset offset, int whence){ + CHECK_FILE(fh) + smpi_bench_end(); + int ret = fh->seek_shared(offset,whence); + smpi_bench_begin(); + return ret; + +} + +int PMPI_File_get_position(MPI_File fh, MPI_Offset* offset){ + if (offset==nullptr) + return MPI_ERR_DISP; + smpi_bench_end(); + int ret = fh->get_position(offset); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_get_position_shared(MPI_File fh, MPI_Offset* offset){ + CHECK_FILE(fh) + if (offset==nullptr) + return MPI_ERR_DISP; + smpi_bench_end(); + int ret = fh->get_position_shared(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) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + PASS_ZEROCOUNT(count) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read", static_cast(count*datatype->size()))); + int ret = simgrid::smpi::File::read(fh, buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_read_shared(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + PASS_ZEROCOUNT(count) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_shared", static_cast(count*datatype->size()))); + int ret = simgrid::smpi::File::read_shared(fh, buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_write(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + PASS_ZEROCOUNT(count) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", static_cast(count*datatype->size()))); + int ret = simgrid::smpi::File::write(fh, buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_write_shared(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + PASS_ZEROCOUNT(count) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_shared", static_cast(count*datatype->size()))); + int ret = simgrid::smpi::File::write_shared(fh, buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_read_all(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_all", static_cast(count*datatype->size()))); + int ret = fh->op_all(buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_read_ordered(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_ordered", static_cast(count*datatype->size()))); + int ret = simgrid::smpi::File::read_ordered(fh, buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_write_all(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_all", static_cast(count*datatype->size()))); + int ret = fh->op_all(buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_write_ordered(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_ordered", static_cast(count*datatype->size()))); + int ret = simgrid::smpi::File::write_ordered(fh, buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_OFFSET(offset) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + PASS_ZEROCOUNT(count); + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read", static_cast(count*datatype->size()))); + int ret = fh->seek(offset,MPI_SEEK_SET); + if(ret!=MPI_SUCCESS) + return ret; + ret = simgrid::smpi::File::read(fh, buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_OFFSET(offset) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_at_all", static_cast(count*datatype->size()))); + int ret = fh->seek(offset,MPI_SEEK_SET); + if(ret!=MPI_SUCCESS) + return ret; + ret = fh->op_all(buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_write_at(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_OFFSET(offset) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + PASS_ZEROCOUNT(count); + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", static_cast(count*datatype->size()))); + int ret = fh->seek(offset,MPI_SEEK_SET); + if(ret!=MPI_SUCCESS) + return ret; + ret = simgrid::smpi::File::write(fh, buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_write_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){ + CHECK_FILE(fh) + CHECK_BUFFER(buf, count) + CHECK_OFFSET(offset) + CHECK_COUNT(count) + CHECK_DATATYPE(datatype, count) + CHECK_STATUS(status) + CHECK_FLAGS(fh) + smpi_bench_end(); + int rank_traced = simgrid::s4u::this_actor::get_pid(); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_at_all", static_cast(count*datatype->size()))); + int ret = fh->seek(offset,MPI_SEEK_SET); + if(ret!=MPI_SUCCESS) + return ret; + ret = fh->op_all(buf, count, datatype, status); + TRACE_smpi_comm_out(rank_traced); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_delete(char *filename, MPI_Info info){ + if (filename == nullptr) + return MPI_ERR_FILE; + smpi_bench_end(); + int ret = simgrid::smpi::File::del(filename, info); + smpi_bench_begin(); + return ret; +} + +int PMPI_File_get_info(MPI_File fh, MPI_Info* info) +{ + CHECK_FILE(fh) + *info = fh->info(); + return MPI_SUCCESS; +} + +int PMPI_File_set_info(MPI_File fh, MPI_Info info) +{ + CHECK_FILE(fh) + 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 new file mode 100644 index 0000000000..72efd93580 --- /dev/null +++ b/src/smpi/include/smpi_file.hpp @@ -0,0 +1,182 @@ +/* Copyright (c) 2010-2019. 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. */ + +#ifndef SMPI_FILE_HPP_INCLUDED +#define SMPI_FILE_HPP_INCLUDED +#include "simgrid/plugins/file_system.h" +#include "smpi_comm.hpp" +#include "smpi_coll.hpp" +#include "smpi_datatype.hpp" +#include "smpi_info.hpp" +#include + + +namespace simgrid{ +namespace smpi{ +class File{ + MPI_Comm comm_; + int flags_; + simgrid::s4u::File* file_; + MPI_Info info_; + MPI_Offset* shared_file_pointer_; + s4u::MutexPtr shared_mutex_; + MPI_Win win_; + char* list_; + public: + File(MPI_Comm comm, char *filename, int amode, MPI_Info info); + ~File(); + int size(); + int get_position(MPI_Offset* offset); + int get_position_shared(MPI_Offset* offset); + int flags(); + int sync(); + int seek(MPI_Offset offset, int whence); + int seek_shared(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 read_shared(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status); + static int read_ordered(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); + static int write_shared(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status); + static int write_ordered(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); + static int close(MPI_File *fh); + static int del(char *filename, MPI_Info info); +}; + + /* Read_all, Write_all : loosely based on */ + /* @article{Thakur:1996:ETM:245875.245879,*/ + /* author = {Thakur, Rajeev and Choudhary, Alok},*/ + /* title = {An Extended Two-phase Method for Accessing Sections of Out-of-core Arrays},*/ + /* journal = {Sci. Program.},*/ + /* issue_date = {Winter 1996},*/ + /* pages = {301--317},*/ + /* }*/ + template + int File::op_all(void *buf, int count, MPI_Datatype datatype, MPI_Status *status){ + //get min and max offsets from everyone. + int size = comm_->size(); + int rank = comm_-> rank(); + MPI_Offset min_offset = file_->tell(); + MPI_Offset max_offset = (min_offset + count * datatype->size());//cheating, as we don't care about exact data location, we can skip extent + MPI_Offset* min_offsets = xbt_new(MPI_Offset, size); + MPI_Offset* max_offsets = xbt_new(MPI_Offset, size); + simgrid::smpi::Colls::allgather(&min_offset, 1, MPI_OFFSET, min_offsets, 1, MPI_OFFSET, comm_); + simgrid::smpi::Colls::allgather(&max_offset, 1, MPI_OFFSET, max_offsets, 1, MPI_OFFSET, comm_); + MPI_Offset min=min_offset; + MPI_Offset max=max_offset; + MPI_Offset tot= 0; + int empty=1; + for(int i=0;imax) + max=max_offsets[i]; + } + + XBT_DEBUG("my offsets to read : %lld:%lld, global min and max %lld:%lld", min_offset, max_offset, min, max); + if(empty==1){ + status->count=0; + return MPI_SUCCESS; + } + MPI_Offset total = max-min; + if(total==tot && (datatype->flags() & DT_FLAG_CONTIGUOUS)){ + //contiguous. Just have each proc perform its read + status->count=count * datatype->size(); + return T(this,buf,count,datatype, status); + } + + //Interleaved case : How much do I need to read, and whom to send it ? + MPI_Offset my_chunk_start=(max-min+1)/size*rank; + MPI_Offset my_chunk_end=((max-min+1)/size*(rank+1)); + XBT_DEBUG("my chunks to read : %lld:%lld", my_chunk_start, my_chunk_end); + int* send_sizes = xbt_new0(int, size); + int* recv_sizes = xbt_new(int, size); + int* send_disps = xbt_new(int, size); + int* recv_disps = xbt_new(int, size); + int total_sent=0; + for(int i=0;i=min_offsets[i] && my_chunk_start < max_offsets[i])|| + ((my_chunk_end<=max_offsets[i]) && my_chunk_end> min_offsets[i])){ + send_sizes[i]=(std::min(max_offsets[i]-1, my_chunk_end-1)-std::max(min_offsets[i], my_chunk_start)); + //store min and max offest to actually read + min_offset=std::min(min_offset, min_offsets[i]); + send_disps[i]=0;//send_sizes[i]; cheat to avoid issues when send>recv as we use recv buffer + total_sent+=send_sizes[i]; + XBT_DEBUG("will have to send %d bytes to %d", send_sizes[i], i); + } + } + min_offset=std::max(min_offset, my_chunk_start); + + //merge the ranges of every process + std::vector> ranges; + for(int i=0; i> chunks; + chunks.push_back(ranges[0]); + + unsigned int nchunks=0; + unsigned int i=1; + while(i < ranges.size()){ + if(ranges[i].second>chunks[nchunks].second){ + // else range included - ignore + if(ranges[i].first>chunks[nchunks].second){ + //new disjoint range + chunks.push_back(ranges[i]); + nchunks++; + } else { + //merge ranges + chunks[nchunks].second=ranges[i].second; + } + } + i++; + } + //what do I need to read ? + MPI_Offset totreads=0; + for(i=0; i my_chunk_end) + continue; + else + totreads += (std::min(chunks[i].second, my_chunk_end-1)-std::max(chunks[i].first, my_chunk_start)); + } + XBT_DEBUG("will have to access %lld from my chunk", totreads); + + char* sendbuf= static_cast(smpi_get_tmp_sendbuffer(totreads)); + + if(totreads>0){ + seek(min_offset, MPI_SEEK_SET); + T(this,sendbuf,totreads/datatype->size(),datatype, status); + } + simgrid::smpi::Colls::alltoall(send_sizes, 1, MPI_INT, recv_sizes, 1, MPI_INT, comm_); + int total_recv=0; + for(int i=0;icount=count * datatype->size(); + smpi_free_tmp_buffer(sendbuf); + xbt_free(send_sizes); + xbt_free(recv_sizes); + xbt_free(send_disps); + xbt_free(recv_disps); + xbt_free(min_offsets); + xbt_free(max_offsets); + return MPI_SUCCESS; + } +} +} + +#endif diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index 4d3ab5a2b4..50112e0ede 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -74,7 +74,9 @@ static std::map smpi_colors = {{"recv", "1 0 0"}, {"win_flush", "1 0 0.3"}, {"win_flush_local", "1 0 0.8"}, {"win_flush_all", "1 0.8 0"}, - {"win_flush_local_all", "1 0 0.3"} + {"win_flush_local_all", "1 0 0.3"}, + + {"file_read", "1 1 0.3"} }; static const char* instr_find_color(const char* c_state) diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 9ad0c6d881..5f0e9887db 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -5,6 +5,7 @@ #include "mc/mc.h" #include "simgrid/s4u/Engine.hpp" +#include "simgrid/plugins/file_system.h" #include "smpi_coll.hpp" #include "smpi_f2c.hpp" #include "smpi_host.hpp" @@ -663,7 +664,7 @@ int smpi_main(const char* executable, int argc, char* argv[]) SIMIX_global_init(&argc, argv); SMPI_switch_data_segment = &smpi_switch_data_segment; - + sg_storage_file_system_init(); // parse the platform file: get the host list simgrid::s4u::Engine::get_instance()->load_platform(argv[1]); SIMIX_comm_set_copy_data_callback(smpi_comm_copy_buffer_callback); diff --git a/src/smpi/mpi/smpi_file.cpp b/src/smpi/mpi/smpi_file.cpp new file mode 100644 index 0000000000..46937ceed6 --- /dev/null +++ b/src/smpi/mpi/smpi_file.cpp @@ -0,0 +1,239 @@ +/* Copyright (c) 2007-2019. 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. */ +#include "private.hpp" + +#include "smpi_comm.hpp" +#include "smpi_coll.hpp" +#include "smpi_datatype.hpp" +#include "smpi_info.hpp" +#include "smpi_win.hpp" +#include "smpi_request.hpp" + +//setup here, because we have templates in smpi_file we want to log +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_io, smpi, "Logging specific to SMPI (RMA operations)"); + +#include "smpi_file.hpp" +#include "smpi_status.hpp" +#include "simgrid/plugins/file_system.h" + +#define FP_SIZE sizeof(MPI_Offset) + + +namespace simgrid{ +namespace smpi{ + + File::File(MPI_Comm comm, char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info) { + file_= new simgrid::s4u::File(filename, nullptr); + list_=nullptr; + if (comm_->rank() == 0) { + int size= comm_->size() + FP_SIZE; + list_ = new char[size]; + memset(list_, 0, size); + shared_file_pointer_ = new MPI_Offset[1]; + shared_mutex_ = s4u::Mutex::create(); + *shared_file_pointer_ = 0; + win_=new Win(list_, size, 1, MPI_INFO_NULL, comm_); + }else{ + win_=new Win(list_, 0, 1, MPI_INFO_NULL, comm_); + } + simgrid::smpi::Colls::bcast(&shared_file_pointer_, 1, MPI_AINT, 0, comm); + simgrid::smpi::Colls::bcast(&shared_mutex_, 1, MPI_AINT, 0, comm); + if(comm_->rank() != 0) + intrusive_ptr_add_ref(&*shared_mutex_); + } + + File::~File(){ + delete file_; + } + + int File::close(MPI_File *fh){ + XBT_DEBUG("Closing MPI_File %s", (*fh)->file_->get_path()); + (*fh)->sync(); + if((*fh)->flags() & MPI_MODE_DELETE_ON_CLOSE) + (*fh)->file_->unlink(); + delete (*fh); + return MPI_SUCCESS; + } + + int File::del(char *filename, MPI_Info info){ + //get the file with MPI_MODE_DELETE_ON_CLOSE and then close it + File* f = new File(MPI_COMM_SELF,filename,MPI_MODE_DELETE_ON_CLOSE|MPI_MODE_RDWR, nullptr); + close(&f); + return MPI_SUCCESS; + } + + int File::get_position(MPI_Offset* offset){ + *offset=file_->tell(); + return MPI_SUCCESS; + } + + int File::get_position_shared(MPI_Offset* offset){ + shared_mutex_->lock(); + *offset=*shared_file_pointer_; + shared_mutex_->unlock(); + return MPI_SUCCESS; + } + + int File::seek(MPI_Offset offset, int whence){ + switch(whence){ + case(MPI_SEEK_SET): + XBT_VERB("Seeking in MPI_File %s, setting offset %lld", file_->get_path(), offset); + file_->seek(offset,SEEK_SET); + break; + case(MPI_SEEK_CUR): + XBT_VERB("Seeking in MPI_File %s, current offset + %lld", file_->get_path(), offset); + file_->seek(offset,SEEK_CUR); + break; + case(MPI_SEEK_END): + XBT_VERB("Seeking in MPI_File %s, end offset + %lld", file_->get_path(), offset); + file_->seek(offset,SEEK_END); + break; + default: + return MPI_ERR_FILE; + } + return MPI_SUCCESS; + } + + int File::seek_shared(MPI_Offset offset, int whence){ + shared_mutex_->lock(); + seek(offset,whence); + *shared_file_pointer_=offset; + shared_mutex_->unlock(); + return MPI_SUCCESS; + } + + int File::read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){ + //get position first as we may be doing non contiguous reads and it will probably be updated badly + MPI_Offset position = fh->file_->tell(); + MPI_Offset movesize = datatype->get_extent()*count; + MPI_Offset readsize = datatype->size()*count; + XBT_DEBUG("Position before read in MPI_File %s : %llu",fh->file_->get_path(),fh->file_->tell()); + MPI_Offset read = fh->file_->read(readsize); + XBT_VERB("Read in MPI_File %s, %lld bytes read, readsize %lld bytes, movesize %lld", fh->file_->get_path(), read, readsize, movesize); + if(readsize!=movesize){ + fh->file_->seek(position+movesize, SEEK_SET); + } + XBT_VERB("Position after read in MPI_File %s : %llu",fh->file_->get_path(), fh->file_->tell()); + status->count=count*datatype->size(); + return MPI_SUCCESS; + } + + /*Ordered and Shared Versions, with RMA-based locks : Based on the model described in :*/ + /* @InProceedings{10.1007/11557265_15,*/ + /* author="Latham, Robert and Ross, Robert and Thakur, Rajeev and Toonen, Brian",*/ + /* title="Implementing MPI-IO Shared File Pointers Without File System Support",*/ + /* booktitle="Recent Advances in Parallel Virtual Machine and Message Passing Interface",*/ + /* year="2005",*/ + /* publisher="Springer Berlin Heidelberg",*/ + /* address="Berlin, Heidelberg",*/ + /* pages="84--93"*/ + /* }*/ + int File::read_shared(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){ + fh->shared_mutex_->lock(); + fh->seek(*(fh->shared_file_pointer_),MPI_SEEK_SET); + read(fh, buf, count, datatype, status); + *(fh->shared_file_pointer_)=fh->file_->tell(); + fh->shared_mutex_->unlock(); + return MPI_SUCCESS; + } + + int File::read_ordered(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){ + //0 needs to get the shared pointer value + MPI_Offset val; + if(fh->comm_->rank()==0){ + val=*(fh->shared_file_pointer_); + }else{ + val=count*datatype->size(); + } + + MPI_Offset result; + simgrid::smpi::Colls::scan(&val, &result, 1, MPI_OFFSET, MPI_SUM, fh->comm_); + fh->seek(result, MPI_SEEK_SET); + int ret = fh->op_all(buf, count, datatype, status); + if(fh->comm_->rank()==fh->comm_->size()-1){ + fh->shared_mutex_->lock(); + *(fh->shared_file_pointer_)=fh->file_->tell(); + fh->shared_mutex_->unlock(); + } + char c; + simgrid::smpi::Colls::bcast(&c, 1, MPI_BYTE, fh->comm_->size()-1, fh->comm_); + return ret; + } + + int File::write(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){ + //get position first as we may be doing non contiguous reads and it will probably be updated badly + MPI_Offset position = fh->file_->tell(); + MPI_Offset movesize = datatype->get_extent()*count; + MPI_Offset writesize = datatype->size()*count; + XBT_DEBUG("Position before write in MPI_File %s : %llu",fh->file_->get_path(),fh->file_->tell()); + MPI_Offset write = fh->file_->write(writesize); + XBT_VERB("Write in MPI_File %s, %lld bytes written, readsize %lld bytes, movesize %lld", fh->file_->get_path(), write, writesize, movesize); + if(writesize!=movesize){ + fh->file_->seek(position+movesize, SEEK_SET); + } + XBT_VERB("Position after write in MPI_File %s : %llu",fh->file_->get_path(), fh->file_->tell()); + status->count=count*datatype->size(); + return MPI_SUCCESS; + } + + int File::write_shared(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){ + fh->shared_mutex_->lock(); + fh->seek(*(fh->shared_file_pointer_),MPI_SEEK_SET); + write(fh, buf, count, datatype, status); + *(fh->shared_file_pointer_)=fh->file_->tell(); + fh->shared_mutex_->unlock(); + return MPI_SUCCESS; + } + + int File::write_ordered(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){ + //0 needs to get the shared pointer value + MPI_Offset val; + if(fh->comm_->rank()==0){ + val=*(fh->shared_file_pointer_); + }else{ + val=count*datatype->size(); + } + MPI_Offset result; + simgrid::smpi::Colls::scan(&val, &result, 1, MPI_OFFSET, MPI_SUM, fh->comm_); + fh->seek(result, MPI_SEEK_SET); + int ret = fh->op_all(buf, count, datatype, status); + if(fh->comm_->rank()==fh->comm_->size()-1){ + fh->shared_mutex_->lock(); + *(fh->shared_file_pointer_)=fh->file_->tell(); + fh->shared_mutex_->unlock(); + } + char c; + simgrid::smpi::Colls::bcast(&c, 1, MPI_BYTE, fh->comm_->size()-1, fh->comm_); + return ret; + } + + int File::size(){ + return file_->size(); + } + + int File::flags(){ + return flags_; + } + + int File::sync(){ + //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; +} + +} +} diff --git a/teshsuite/smpi/CMakeLists.txt b/teshsuite/smpi/CMakeLists.txt index 800ae86f93..8dc3a021a0 100644 --- a/teshsuite/smpi/CMakeLists.txt +++ b/teshsuite/smpi/CMakeLists.txt @@ -8,7 +8,8 @@ if(enable_smpi) include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi") foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong - type-hvector type-indexed type-struct type-vector bug-17132 timers privatization ) + type-hvector type-indexed type-struct type-vector bug-17132 timers privatization + io-simple io-simple-at io-all io-shared io-ordered) add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.c) target_link_libraries(${x} simgrid) set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) @@ -36,7 +37,8 @@ endif() foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong type-hvector type-indexed type-struct type-vector bug-17132 timers privatization - macro-shared macro-partial-shared macro-partial-shared-communication) + macro-shared macro-partial-shared macro-partial-shared-communication + io-simple io-simple-at io-all io-shared io-ordered) set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh) set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c) endforeach() @@ -63,7 +65,7 @@ if(enable_smpi) foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong - type-hvector type-indexed type-struct type-vector bug-17132 timers) + type-hvector type-indexed type-struct type-vector bug-17132 timers io-simple io-simple-at io-all io-shared io-ordered) ADD_TESH_FACTORIES(tesh-smpi-${x} "thread;ucontext;raw;boost" --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/${x} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/${x} ${x}.tesh) endforeach() diff --git a/teshsuite/smpi/hostfile_io b/teshsuite/smpi/hostfile_io new file mode 100644 index 0000000000..6b4158a214 --- /dev/null +++ b/teshsuite/smpi/hostfile_io @@ -0,0 +1,2 @@ +bob +carl diff --git a/teshsuite/smpi/io-all/io-all.c b/teshsuite/smpi/io-all/io-all.c new file mode 100644 index 0000000000..56d95b3b27 --- /dev/null +++ b/teshsuite/smpi/io-all/io-all.c @@ -0,0 +1,74 @@ +#include "mpi.h" +#include +#include +#include +#include + +/* Test reading and writing zero bytes (set status correctly) */ + +int main( int argc, char *argv[] ) +{ + int errs = 0; + int size, rank, i, *buf, count; + MPI_File fh; + MPI_Comm comm; + MPI_Status status; + + MPI_Init( &argc, &argv ); + + comm = MPI_COMM_WORLD; + MPI_File_open( comm, (char*)"/scratch/lib/libsimgrid.so.3.6.2", MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh ); + MPI_Comm_size( comm, &size ); + MPI_Comm_rank( comm, &rank ); + buf = (int *)malloc( 10+ size * sizeof(int) ); + buf[0] = rank; + + /* Write to file */ + MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET ); + MPI_File_write_all( fh, buf, 1, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 1) { + errs++; + fprintf( stderr, "Wrong count (%d) on write\n", count );fflush(stderr); + } + /* Write to file, overlapping */ + MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET ); + MPI_File_write_all( fh, buf, 10, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 10) { + errs++; + fprintf( stderr, "Wrong count (%d) on write\n", count );fflush(stderr); + } + /* Read nothing (check status) */ + memset( &status, 0xff, sizeof(MPI_Status) ); + MPI_File_read_all( fh, buf, 0, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 0) { + errs++; + fprintf( stderr, "Count not zero (%d) on read\n", count );fflush(stderr); + } + + /* Write nothing (check status) */ + memset( &status, 0xff, sizeof(MPI_Status) ); + MPI_File_write_all( fh, buf, 0, MPI_INT, &status ); + if (count != 0) { + errs++; + fprintf( stderr, "Count not zero (%d) on write\n", count );fflush(stderr); + } + + MPI_Barrier( comm ); + + MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET ); + for (i=0; i You requested to use 4 ranks, but there is only 2 processes in your hostfile... +> [rank 0] -> bob +> [rank 1] -> carl +> [rank 2] -> bob +> [rank 3] -> carl +> [ 0.000282] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000358] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 8 +> [ 0.000534] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 12 +> [ 0.000534] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 4 +> [ 0.000737] (3@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000737] (3@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 16 +> [ 0.000737] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 12 +> [ 0.000737] (1@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000737] (1@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 8 +> [ 0.000737] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 4 +> [ 0.000838] (2@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000838] (2@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 12 +> [ 0.000838] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 8 +> [ 0.000838] (0@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000838] (0@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 4 +> [ 0.000838] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001040] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 39 +> [ 0.001040] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 26 +> [ 0.001040] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001040] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 13 +> [ 0.001041] (3@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 12 bytes written, readsize 12 bytes, movesize 12 +> [ 0.001041] (3@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 51 +> [ 0.001041] (1@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 12 bytes written, readsize 12 bytes, movesize 12 +> [ 0.001041] (1@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 25 +> [ 0.001141] (0@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 12 bytes written, readsize 12 bytes, movesize 12 +> [ 0.001141] (0@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 12 +> [ 0.001141] (2@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 12 bytes written, readsize 12 bytes, movesize 12 +> [ 0.001141] (2@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 38 +> [ 0.001799] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001814] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 8 +> [ 0.001849] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 12 +> [ 0.001849] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 4 +> [ 0.002052] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.002052] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 26 +> [ 0.002052] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 39 +> [ 0.002052] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 13 +> [ 0.002052] (3@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 12 bytes read, readsize 12 bytes, movesize 12 +> [ 0.002052] (3@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 51 +> [ 0.002052] (1@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 12 bytes read, readsize 12 bytes, movesize 12 +> [ 0.002052] (1@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 25 +> [ 0.002153] (2@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 12 bytes read, readsize 12 bytes, movesize 12 +> [ 0.002153] (2@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 38 +> [ 0.002153] (0@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 12 bytes read, readsize 12 bytes, movesize 12 +> [ 0.002153] (0@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 12 diff --git a/teshsuite/smpi/io-ordered/io-ordered.c b/teshsuite/smpi/io-ordered/io-ordered.c new file mode 100644 index 0000000000..e5225dfbbd --- /dev/null +++ b/teshsuite/smpi/io-ordered/io-ordered.c @@ -0,0 +1,46 @@ +#include "mpi.h" +#include +#include +#include +#include + +/* Test reading and writing zero bytes (set status correctly) */ + +int main( int argc, char *argv[] ) +{ + int errs = 0; + int size, rank, i, *buf, count; + MPI_File fh; + MPI_Comm comm; + MPI_Status status; + + MPI_Init( &argc, &argv ); + + comm = MPI_COMM_WORLD; + MPI_File_open( comm, (char*)"/scratch/lib/libsimgrid.so.3.6.2", MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh ); + MPI_Comm_size( comm, &size ); + MPI_Comm_rank( comm, &rank ); + buf = (int *)malloc( 10+size * sizeof(int) ); + buf[0] = rank; + + /* Write to file */ + MPI_File_write_ordered( fh, buf, 10, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 10) { + errs++; + fprintf( stderr, "Wrong count (%d) on write-ordered\n", count );fflush(stderr); + } + MPI_Barrier( comm ); + MPI_File_seek_shared( fh, 0, MPI_SEEK_SET ); + for (i=0; i You requested to use 4 ranks, but there is only 2 processes in your hostfile... +> [rank 0] -> bob +> [rank 1] -> carl +> [rank 2] -> bob +> [rank 3] -> carl +> [ 0.000282] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000635] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 80 +> [ 0.000635] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 40 +> [ 0.000635] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 120 +> [ 0.000839] (3@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes written, readsize 40 bytes, movesize 40 +> [ 0.000839] (3@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 160 +> [ 0.000839] (1@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes written, readsize 40 bytes, movesize 40 +> [ 0.000839] (1@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 80 +> [ 0.000940] (2@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes written, readsize 40 bytes, movesize 40 +> [ 0.000940] (2@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 120 +> [ 0.000940] (0@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes written, readsize 40 bytes, movesize 40 +> [ 0.000940] (0@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 40 +> [ 0.001091] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001091] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001106] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001141] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001141] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001242] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 80 +> [ 0.001242] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 40 +> [ 0.001242] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 120 +> [ 0.001446] (3@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes read, readsize 40 bytes, movesize 40 +> [ 0.001446] (3@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 160 +> [ 0.001446] (1@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes read, readsize 40 bytes, movesize 40 +> [ 0.001446] (1@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 80 +> [ 0.001548] (2@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes read, readsize 40 bytes, movesize 40 +> [ 0.001548] (2@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 120 +> [ 0.001548] (0@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes read, readsize 40 bytes, movesize 40 +> [ 0.001548] (0@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 40 +> [ 0.001699] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001714] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001749] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001749] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 diff --git a/teshsuite/smpi/io-shared/io-shared.c b/teshsuite/smpi/io-shared/io-shared.c new file mode 100644 index 0000000000..d83c8baad0 --- /dev/null +++ b/teshsuite/smpi/io-shared/io-shared.c @@ -0,0 +1,66 @@ +#include "mpi.h" +#include +#include +#include +#include + +/* Test reading and writing zero bytes (set status correctly) */ + +int main( int argc, char *argv[] ) +{ + int errs = 0; + int size, rank, i, *buf, count; + MPI_File fh; + MPI_Comm comm; + MPI_Status status; + + MPI_Init( &argc, &argv ); + + comm = MPI_COMM_WORLD; + MPI_File_open( comm, (char*)"/scratch/lib/libsimgrid.so.3.6.2", MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh ); + MPI_Comm_size( comm, &size ); + MPI_Comm_rank( comm, &rank ); + buf = (int *)malloc( 10+size * sizeof(int) ); + buf[0] = rank; + + /* Write nothing (check status) */ + memset( &status, 0xff, sizeof(MPI_Status) ); + MPI_File_write( fh, buf, 0, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 0) { + errs++; + fprintf( stderr, "Count not zero (%d) on write\n", count );fflush(stderr); + } + + MPI_Barrier( comm ); + MPI_File_seek_shared( fh, 0, MPI_SEEK_SET ); + for (i=0; i You requested to use 4 ranks, but there is only 2 processes in your hostfile... +> [rank 0] -> bob +> [rank 1] -> carl +> [rank 2] -> bob +> [rank 3] -> carl +> [ 0.000584] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000584] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000599] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000634] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000634] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000735] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 80 +> [ 0.000735] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 40 +> [ 0.000735] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 120 +> [ 0.000939] (3@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes read, readsize 40 bytes, movesize 40 +> [ 0.000939] (3@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 160 +> [ 0.000939] (1@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes read, readsize 40 bytes, movesize 40 +> [ 0.000939] (1@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 80 +> [ 0.001041] (2@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes read, readsize 40 bytes, movesize 40 +> [ 0.001041] (2@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 120 +> [ 0.001041] (0@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 40 bytes read, readsize 40 bytes, movesize 40 +> [ 0.001041] (0@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 40 +> [ 0.001192] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001192] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001292] (0@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.001292] (0@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 4 +> [ 0.001292] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001292] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001292] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001292] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001393] (2@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.001393] (2@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 4 +> [ 0.001393] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 4 +> [ 0.001393] (3@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.001393] (3@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 8 +> [ 0.001393] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 8 +> [ 0.001393] (1@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.001393] (1@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 12 +> [ 0.001443] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001443] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001544] (0@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.001544] (0@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 4 +> [ 0.001544] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001544] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001544] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001544] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.001645] (2@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.001645] (2@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 4 +> [ 0.001645] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 4 +> [ 0.001645] (3@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.001645] (3@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 8 +> [ 0.001645] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 8 +> [ 0.001645] (1@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.001645] (1@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 12 diff --git a/teshsuite/smpi/io-simple-at/io-simple-at.c b/teshsuite/smpi/io-simple-at/io-simple-at.c new file mode 100644 index 0000000000..6a6e161a3f --- /dev/null +++ b/teshsuite/smpi/io-simple-at/io-simple-at.c @@ -0,0 +1,65 @@ +#include "mpi.h" +#include +#include +#include +#include + +/* Test reading and writing zero bytes (set status correctly) */ + +int main( int argc, char *argv[] ) +{ + int errs = 0; + int size, rank, i, *buf, count; + MPI_File fh; + MPI_Comm comm; + MPI_Status status; + + MPI_Init( &argc, &argv ); + + comm = MPI_COMM_WORLD; + MPI_File_open( comm, (char*)"/scratch/lib/libsimgrid.so.3.6.2", MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh ); + MPI_Comm_size( comm, &size ); + MPI_Comm_rank( comm, &rank ); + buf = (int *)malloc( size * sizeof(int) ); + buf[0] = rank; + + /* Write to file */ + MPI_File_write_at( fh, sizeof(int)*rank, buf, 1, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 1) { + errs++; + fprintf( stderr, "Wrong count (%d) on write_at\n", count );fflush(stderr); + } + + /* Read nothing (check status) */ + memset( &status, 0xff, sizeof(MPI_Status) ); + MPI_File_read_at( fh, sizeof(int)*rank, buf, 0, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 0) { + errs++; + fprintf( stderr, "Count not zero (%d) on read\n", count );fflush(stderr); + } + + /* Write nothing (check status) */ + memset( &status, 0xff, sizeof(MPI_Status) ); + MPI_File_write_at( fh, sizeof(int)*rank, buf, 0, MPI_INT, &status ); + if (count != 0) { + errs++; + fprintf( stderr, "Count not zero (%d) on write\n", count );fflush(stderr); + } + + MPI_Barrier( comm ); + + for (i=0; i You requested to use 4 ranks, but there is only 2 processes in your hostfile... +> [rank 0] -> bob +> [rank 1] -> carl +> [rank 2] -> bob +> [rank 3] -> carl +> [ 0.000282] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000358] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 8 +> [ 0.000383] (0@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000383] (0@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 4 +> [ 0.000459] (2@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000459] (2@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 12 +> [ 0.000534] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 12 +> [ 0.000534] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 4 +> [ 0.000534] (3@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000534] (3@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 16 +> [ 0.000534] (1@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000534] (1@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 8 +> [ 0.000584] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000599] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 8 +> [ 0.000634] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 12 +> [ 0.000634] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 4 +> [ 0.000634] (3@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.000634] (3@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 16 +> [ 0.000634] (1@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.000634] (1@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 8 +> [ 0.000685] (0@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.000685] (0@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 4 +> [ 0.000700] (2@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.000700] (2@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 12 diff --git a/teshsuite/smpi/io-simple/io-simple.c b/teshsuite/smpi/io-simple/io-simple.c new file mode 100644 index 0000000000..33d8ef069e --- /dev/null +++ b/teshsuite/smpi/io-simple/io-simple.c @@ -0,0 +1,67 @@ +#include "mpi.h" +#include +#include +#include +#include + +/* Test reading and writing zero bytes (set status correctly) */ + +int main( int argc, char *argv[] ) +{ + int errs = 0; + int size, rank, i, *buf, count; + MPI_File fh; + MPI_Comm comm; + MPI_Status status; + + MPI_Init( &argc, &argv ); + + comm = MPI_COMM_WORLD; + MPI_File_open( comm, (char*)"/scratch/lib/libsimgrid.so.3.6.2", MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh ); + MPI_Comm_size( comm, &size ); + MPI_Comm_rank( comm, &rank ); + buf = (int *)malloc( size * sizeof(int) ); + buf[0] = rank; + + /* Write to file */ + MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET ); + MPI_File_write( fh, buf, 1, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 1) { + errs++; + fprintf( stderr, "Wrong count (%d) on write\n", count );fflush(stderr); + } + + /* Read nothing (check status) */ + memset( &status, 0xff, sizeof(MPI_Status) ); + MPI_File_read( fh, buf, 0, MPI_INT, &status ); + MPI_Get_count( &status, MPI_INT, &count ); + if (count != 0) { + errs++; + fprintf( stderr, "Count not zero (%d) on read\n", count );fflush(stderr); + } + + /* Write nothing (check status) */ + memset( &status, 0xff, sizeof(MPI_Status) ); + MPI_File_write( fh, buf, 0, MPI_INT, &status ); + if (count != 0) { + errs++; + fprintf( stderr, "Count not zero (%d) on write\n", count );fflush(stderr); + } + + MPI_Barrier( comm ); + + MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET ); + for (i=0; i You requested to use 4 ranks, but there is only 2 processes in your hostfile... +> [rank 0] -> bob +> [rank 1] -> carl +> [rank 2] -> bob +> [rank 3] -> carl +> [ 0.000282] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000358] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 8 +> [ 0.000383] (0@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000383] (0@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 4 +> [ 0.000459] (2@bob) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000459] (2@bob) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 12 +> [ 0.000534] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 12 +> [ 0.000534] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 4 +> [ 0.000534] (3@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000534] (3@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 16 +> [ 0.000534] (1@carl) Write in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes written, readsize 4 bytes, movesize 4 +> [ 0.000534] (1@carl) Position after write in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 8 +> [ 0.000584] (0@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 0 +> [ 0.000599] (2@bob) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 8 +> [ 0.000634] (3@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 12 +> [ 0.000634] (1@carl) Seeking in MPI_File /scratch/lib/libsimgrid.so.3.6.2, setting offset 4 +> [ 0.000634] (3@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.000634] (3@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 16 +> [ 0.000634] (1@carl) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.000634] (1@carl) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 8 +> [ 0.000685] (0@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.000685] (0@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 4 +> [ 0.000700] (2@bob) Read in MPI_File /scratch/lib/libsimgrid.so.3.6.2, 4 bytes read, readsize 4 bytes, movesize 4 +> [ 0.000700] (2@bob) Position after read in MPI_File /scratch/lib/libsimgrid.so.3.6.2 : 12 diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 3e7a0a114b..b856d198b7 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -92,6 +92,7 @@ set(SMPI_SRC src/smpi/bindings/smpi_pmpi.cpp src/smpi/bindings/smpi_pmpi_coll.cpp src/smpi/bindings/smpi_pmpi_comm.cpp + src/smpi/bindings/smpi_pmpi_file.cpp src/smpi/bindings/smpi_pmpi_group.cpp src/smpi/bindings/smpi_pmpi_info.cpp src/smpi/bindings/smpi_pmpi_op.cpp @@ -226,6 +227,7 @@ set(SMPI_SRC src/smpi/mpi/smpi_datatype.cpp src/smpi/mpi/smpi_datatype_derived.cpp src/smpi/mpi/smpi_f2c.cpp + src/smpi/mpi/smpi_file.cpp src/smpi/mpi/smpi_group.cpp src/smpi/mpi/smpi_info.cpp src/smpi/mpi/smpi_keyvals.cpp @@ -240,6 +242,7 @@ set(SMPI_SRC src/smpi/include/smpi_datatype_derived.hpp src/smpi/include/smpi_datatype.hpp src/smpi/include/smpi_f2c.hpp + src/smpi/include/smpi_file.hpp src/smpi/include/smpi_group.hpp src/smpi/include/smpi_host.hpp src/smpi/include/smpi_info.hpp