Skip to content

Commit

Permalink
Only fail on EOF when we know it's OK
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer committed Jan 16, 2024
1 parent ad97ac4 commit 7c6c62a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
12 changes: 12 additions & 0 deletions source/adios2/engine/bp5/BP5Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ std::pair<double, double> 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 =
Expand All @@ -225,6 +231,12 @@ std::pair<double, double> 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);
Expand Down
12 changes: 11 additions & 1 deletion source/adios2/toolkit/transport/file/FilePOSIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<std::ios_base::failure>(
"Toolkit", "transport::file::FilePOSIX", "Read",
Expand Down Expand Up @@ -599,5 +600,14 @@ void FilePOSIX::Truncate(const size_t length)

void FilePOSIX::MkDir(const std::string &fileName) {}

void FilePOSIX::SetParameters(const Params &params)
{
// 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
5 changes: 3 additions & 2 deletions source/adios2/toolkit/transport/file/FilePOSIX.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
*
* FileDescriptor.h wrapper of POSIX library functions for file I/O
*
* Created on: Oct 6, 2016
* Author: William F Godoy [email protected]
*/

#ifndef ADIOS2_TOOLKIT_TRANSPORT_FILE_FILEDESCRIPTOR_H_
Expand Down Expand Up @@ -68,10 +66,13 @@ class FilePOSIX : public Transport

void MkDir(const std::string &fileName) final;

void SetParameters(const Params &params) 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<int> m_OpenFuture;
bool m_DirectIO = false;
Expand Down
10 changes: 8 additions & 2 deletions source/adios2/toolkit/transportman/TransportMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
*
* TransportMan.cpp
*
* Created on: May 23, 2017
* Author: William F Godoy [email protected]
*/

#include "TransportMan.h"
Expand Down Expand Up @@ -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 &params, 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)
Expand Down
9 changes: 7 additions & 2 deletions source/adios2/toolkit/transportman/TransportMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
*
* TransportMan.h : manages a vector of transports
*
* Created on: May 23, 2017
* Author: William F Godoy [email protected]
*/

#ifndef ADIOS2_TOOLKIT_TRANSPORT_TRANSPORTMANAGER_H_
Expand Down Expand Up @@ -210,6 +208,13 @@ class TransportMan
*/
bool FileExists(const std::string &name, const Params &parameters, const bool profile);

/**
* Set Transport Paramers
* @param params
* @param transportIndex
*/
void SetParameters(const Params &params, const size_t transportIndex = 0);

protected:
core::IO &m_IO;
helper::Comm const &m_Comm;
Expand Down

0 comments on commit 7c6c62a

Please sign in to comment.