From 7c6c62a195a704376c394f38aa30bd0f6a3eee5e Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Mon, 15 Jan 2024 20:01:50 -0500 Subject: [PATCH] Only fail on EOF when we know it's OK --- source/adios2/engine/bp5/BP5Reader.cpp | 12 ++++++++++++ source/adios2/toolkit/transport/file/FilePOSIX.cpp | 12 +++++++++++- source/adios2/toolkit/transport/file/FilePOSIX.h | 5 +++-- source/adios2/toolkit/transportman/TransportMan.cpp | 10 ++++++++-- source/adios2/toolkit/transportman/TransportMan.h | 9 +++++++-- 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/source/adios2/engine/bp5/BP5Reader.cpp b/source/adios2/engine/bp5/BP5Reader.cpp index 00209ff1f4..4544863f7f 100644 --- a/source/adios2/engine/bp5/BP5Reader.cpp +++ b/source/adios2/engine/bp5/BP5Reader.cpp @@ -214,6 +214,12 @@ std::pair BP5Reader::ReadData(adios2::transportman::TransportMan // check if subfile is already opened TP startSubfile = NOW(); + static bool checkOnce = true; + if (checkOnce) + { + checkOnce = false; + CheckWriterActive(); + } if (FileManager.m_Transports.count(SubfileNum) == 0) { const std::string subFileName = @@ -225,6 +231,12 @@ std::pair BP5Reader::ReadData(adios2::transportman::TransportMan } FileManager.OpenFileID(subFileName, SubfileNum, Mode::Read, m_IO.m_TransportsParameters[0], /*{{"transport", "File"}},*/ false); + if (!m_WriterIsActive) + { + Params transportParameters; + transportParameters["FailOnEOF"] = "true"; + FileManager.SetParameters(transportParameters); + } } TP endSubfile = NOW(); double timeSubfile = DURATION(startSubfile, endSubfile); diff --git a/source/adios2/toolkit/transport/file/FilePOSIX.cpp b/source/adios2/toolkit/transport/file/FilePOSIX.cpp index e3a77f452a..8d27d93a43 100644 --- a/source/adios2/toolkit/transport/file/FilePOSIX.cpp +++ b/source/adios2/toolkit/transport/file/FilePOSIX.cpp @@ -7,6 +7,7 @@ */ #include "FilePOSIX.h" #include "adios2/helper/adiosLog.h" +#include "adios2/helper/adiosString.h" #ifdef ADIOS2_HAVE_O_DIRECT #ifndef _GNU_SOURCE @@ -415,7 +416,7 @@ void FilePOSIX::Read(char *buffer, size_t size, size_t start) "Toolkit", "transport::file::FilePOSIX", "Read", "couldn't read from file " + m_Name + " " + SysErrMsg()); } - else if (readSize == 0) + else if ((readSize == 0) && m_FailOnEOF) { helper::Throw( "Toolkit", "transport::file::FilePOSIX", "Read", @@ -599,5 +600,14 @@ void FilePOSIX::Truncate(const size_t length) void FilePOSIX::MkDir(const std::string &fileName) {} +void FilePOSIX::SetParameters(const Params ¶ms) +{ + // Parameters are set from config parameters if present + // Otherwise, they are set from environment if present + // Otherwise, they remain at their default value + + helper::GetParameter(params, "FailOnEOF", m_FailOnEOF); +} + } // end namespace transport } // end namespace adios2 diff --git a/source/adios2/toolkit/transport/file/FilePOSIX.h b/source/adios2/toolkit/transport/file/FilePOSIX.h index 394aa9ea15..667d63cd0a 100644 --- a/source/adios2/toolkit/transport/file/FilePOSIX.h +++ b/source/adios2/toolkit/transport/file/FilePOSIX.h @@ -4,8 +4,6 @@ * * FileDescriptor.h wrapper of POSIX library functions for file I/O * - * Created on: Oct 6, 2016 - * Author: William F Godoy godoywf@ornl.gov */ #ifndef ADIOS2_TOOLKIT_TRANSPORT_FILE_FILEDESCRIPTOR_H_ @@ -68,10 +66,13 @@ class FilePOSIX : public Transport void MkDir(const std::string &fileName) final; + void SetParameters(const Params ¶ms) final; + private: /** POSIX file handle returned by Open */ int m_FileDescriptor = -1; int m_Errno = 0; + bool m_FailOnEOF = false; // default to false for historic reasons bool m_IsOpening = false; std::future m_OpenFuture; bool m_DirectIO = false; diff --git a/source/adios2/toolkit/transportman/TransportMan.cpp b/source/adios2/toolkit/transportman/TransportMan.cpp index bb7ff8666d..aefd6820d7 100644 --- a/source/adios2/toolkit/transportman/TransportMan.cpp +++ b/source/adios2/toolkit/transportman/TransportMan.cpp @@ -4,8 +4,6 @@ * * TransportMan.cpp * - * Created on: May 23, 2017 - * Author: William F Godoy godoywf@ornl.gov */ #include "TransportMan.h" @@ -410,6 +408,14 @@ void TransportMan::ReadFile(char *buffer, const size_t size, const size_t start, itTransport->second->Read(buffer, size, start); } +void TransportMan::SetParameters(const Params ¶ms, const size_t transportIndex) +{ + auto itTransport = m_Transports.find(transportIndex); + CheckFile(itTransport, + ", in call to SetParameters with index " + std::to_string(transportIndex)); + itTransport->second->SetParameters(params); +} + void TransportMan::FlushFiles(const int transportIndex) { if (transportIndex == -1) diff --git a/source/adios2/toolkit/transportman/TransportMan.h b/source/adios2/toolkit/transportman/TransportMan.h index acf3ac1cd2..f9bb34a89c 100644 --- a/source/adios2/toolkit/transportman/TransportMan.h +++ b/source/adios2/toolkit/transportman/TransportMan.h @@ -4,8 +4,6 @@ * * TransportMan.h : manages a vector of transports * - * Created on: May 23, 2017 - * Author: William F Godoy godoywf@ornl.gov */ #ifndef ADIOS2_TOOLKIT_TRANSPORT_TRANSPORTMANAGER_H_ @@ -210,6 +208,13 @@ class TransportMan */ bool FileExists(const std::string &name, const Params ¶meters, const bool profile); + /** + * Set Transport Paramers + * @param params + * @param transportIndex + */ + void SetParameters(const Params ¶ms, const size_t transportIndex = 0); + protected: core::IO &m_IO; helper::Comm const &m_Comm;