Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jun 3, 2024
1 parent 869a3ec commit ce5bfc3
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 6 deletions.
28 changes: 22 additions & 6 deletions include/openPMD/IO/IOTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,36 @@ Writable *getWritable(Attributable *);
/** Type of IO operation between logical and persistent data.
*/
OPENPMDAPI_EXPORT_ENUM_CLASS(Operation){
CREATE_FILE, CHECK_FILE, OPEN_FILE, CLOSE_FILE,
CREATE_FILE,
CHECK_FILE,
OPEN_FILE,
CLOSE_FILE,
DELETE_FILE,

CREATE_PATH, CLOSE_PATH, OPEN_PATH, DELETE_PATH,
CREATE_PATH,
CLOSE_PATH,
OPEN_PATH,
DELETE_PATH,
LIST_PATHS,

CREATE_DATASET, EXTEND_DATASET, OPEN_DATASET, DELETE_DATASET,
WRITE_DATASET, READ_DATASET, LIST_DATASETS, GET_BUFFER_VIEW,
CREATE_DATASET,
EXTEND_DATASET,
OPEN_DATASET,
DELETE_DATASET,
WRITE_DATASET,
READ_DATASET,
LIST_DATASETS,
GET_BUFFER_VIEW,

DELETE_ATT, WRITE_ATT, READ_ATT, LIST_ATTS,
DELETE_ATT,
WRITE_ATT,
READ_ATT,
LIST_ATTS,

ADVANCE,
AVAILABLE_CHUNKS, //!< Query chunks that can be loaded in a dataset
DEREGISTER //!< Inform the backend that an object has been deleted.
DEREGISTER, //!< Inform the backend that an object has been deleted.
TOUCH //!< tell the backend that the file is to be considered active
}; // note: if you change the enum members here, please update
// docs/source/dev/design.rst

Expand Down
6 changes: 6 additions & 0 deletions src/IO/ADIOS/ADIOS2File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "openPMD/Error.hpp"
#include "openPMD/IO/ADIOS/ADIOS2IOHandler.hpp"
#include "openPMD/auxiliary/Environment.hpp"
#include <mpi.h>

#if openPMD_USE_VERIFY
#define VERIFY(CONDITION, TEXT) \
Expand Down Expand Up @@ -1045,6 +1046,11 @@ void ADIOS2File::flush_impl(ADIOS2FlushParams flushParams, bool writeLatePuts)
break;
}
performDataWrite = performDataWrite && m_engineType == "bp5";
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
std::cout << "[" << rank
<< "] Performing data write: " << performDataWrite
<< std::endl;

if (performDataWrite)
{
Expand Down
8 changes: 8 additions & 0 deletions src/IO/ADIOS/ADIOS2IOHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ overrideFlushTarget(FlushTarget &inplace, FlushTarget new_val)
std::future<void>
ADIOS2IOHandlerImpl::flush(internal::ParsedFlushParams &flushParams)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
std::cout << "[" << rank << "] Flushing ADIOS2" << std::endl;
auto res = AbstractIOHandlerImpl::flush();

detail::ADIOS2File::ADIOS2FlushParams adios2FlushParams{
Expand Down Expand Up @@ -536,10 +539,14 @@ ADIOS2IOHandlerImpl::flush(internal::ParsedFlushParams &flushParams)
{
if (m_dirty.find(p.first) != m_dirty.end())
{
std::cout << "[" << rank << "] Flush " << p.second->m_file
<< std::endl;
p.second->flush(adios2FlushParams, /* writeLatePuts = */ false);
}
else
{
std::cout << "[" << rank << "] Drop " << p.second->m_file
<< std::endl;
p.second->drop();
}
}
Expand Down Expand Up @@ -895,6 +902,7 @@ void ADIOS2IOHandlerImpl::openFile(
// lazy opening is deathly in parallel situations
auto &fileData = getFileData(file, IfFileNotOpen::OpenImplicitly);
*parameters.out_parsePreference = fileData.parsePreference;
m_dirty.emplace(std::move(file));
}

void ADIOS2IOHandlerImpl::closeFile(
Expand Down
35 changes: 35 additions & 0 deletions test/ParallelIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,41 @@ TEST_CASE("hipace_like_write", "[parallel]")
}
#endif

#if openPMD_HAVE_ADIOS2 && openPMD_HAS_ADIOS_2_9
TEST_CASE("independent_write_with_collective_flush", "[parallel]")
{
Series write(
"../samples/independent_write_with_collective_flush.bp5",
Access::CREATE,
MPI_COMM_WORLD,
"adios2.engine.preferred_flush_target = \"buffer\"");
int size, rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
auto iteration = write.iterations[0];
auto E_x = iteration.meshes["E"]["x"];
E_x.resetDataset({Datatype::DOUBLE, {10}});
write.flush();
if (rank == 1)
{
E_x.storeChunk(
std::unique_ptr<double[]>{new double[10]{4.2}}, {0}, {10});
}

Check notice

Code scanning / CodeQL

Commented-out code Note test

This comment appears to contain commented-out code.
/*
* Now, the iteration is dirty only on rank 1. But the following flush must
* run collectively anyway. The test has been designed in such a way that
* the PerformDataWrite() call required by the disk flush target will
* conflict with the default buffer target that will run in the destructor,
* unless the flush in the next line really is collective.
*/
std::cout << "ENTER" << std::endl;
MPI_Barrier(MPI_COMM_WORLD);
iteration.seriesFlush("adios2.engine.preferred_flush_target = \"disk\"");
MPI_Barrier(MPI_COMM_WORLD);
std::cout << "LEAVE" << std::endl;
}
#endif

#if openPMD_HAVE_ADIOS2 && openPMD_HAVE_MPI

void adios2_streaming(bool variableBasedLayout)
Expand Down

0 comments on commit ce5bfc3

Please sign in to comment.