From f7b096023d61a491b297fcaf96b2adcb126247c4 Mon Sep 17 00:00:00 2001 From: William F Godoy Date: Tue, 17 Sep 2019 16:15:13 -0400 Subject: [PATCH 1/2] adding async open to BP4 engine Fix bug in BP3 async open --- source/adios2/engine/bp3/BP3Writer.cpp | 12 ++--- source/adios2/engine/bp4/BP4Writer.cpp | 69 +++++--------------------- 2 files changed, 18 insertions(+), 63 deletions(-) diff --git a/source/adios2/engine/bp3/BP3Writer.cpp b/source/adios2/engine/bp3/BP3Writer.cpp index 9b83c0a811..429a225c1b 100644 --- a/source/adios2/engine/bp3/BP3Writer.cpp +++ b/source/adios2/engine/bp3/BP3Writer.cpp @@ -187,17 +187,17 @@ void BP3Writer::InitTransports() if (m_BP3Serializer.m_Aggregator.m_IsConsumer) { if (m_BP3Serializer.m_Parameters.AsyncTasks) - { - m_FileDataManager.OpenFiles(bpSubStreamNames, m_OpenMode, - m_IO.m_TransportsParameters, - m_BP3Serializer.m_Profiler.m_IsActive); - } - else { m_FutureOpenFiles = m_FileDataManager.OpenFilesAsync( bpSubStreamNames, m_OpenMode, m_IO.m_TransportsParameters, m_BP3Serializer.m_Profiler.m_IsActive); } + else + { + m_FileDataManager.OpenFiles(bpSubStreamNames, m_OpenMode, + m_IO.m_TransportsParameters, + m_BP3Serializer.m_Profiler.m_IsActive); + } } } diff --git a/source/adios2/engine/bp4/BP4Writer.cpp b/source/adios2/engine/bp4/BP4Writer.cpp index 812e64b510..c2fc47f4de 100644 --- a/source/adios2/engine/bp4/BP4Writer.cpp +++ b/source/adios2/engine/bp4/BP4Writer.cpp @@ -184,11 +184,18 @@ void BP4Writer::InitTransports() if (m_BP4Serializer.m_Aggregator.m_IsConsumer) { - // std::cout << "rank " << m_BP4Serializer.m_RankMPI << ": " << - // bpSubStreamNames[0] << std::endl; - m_FileDataManager.OpenFiles(bpSubStreamNames, m_OpenMode, - m_IO.m_TransportsParameters, - m_BP4Serializer.m_Profiler.m_IsActive); + if (m_BP4Serializer.m_Parameters.AsyncTasks) + { + m_FutureOpenFiles = m_FileDataManager.OpenFilesAsync( + bpSubStreamNames, m_OpenMode, m_IO.m_TransportsParameters, + m_BP4Serializer.m_Profiler.m_IsActive); + } + else + { + m_FileDataManager.OpenFiles(bpSubStreamNames, m_OpenMode, + m_IO.m_TransportsParameters, + m_BP4Serializer.m_Profiler.m_IsActive); + } } if (m_BP4Serializer.m_RankMPI == 0) @@ -537,58 +544,6 @@ void BP4Writer::WriteCollectiveMetadataFile(const bool isFinal) currentTimeStamp); } - // /*record the starting position of indices in metadata file*/ - // const uint64_t pgIndexStartMetadataFile = - // m_BP4Serializer.m_MetadataSet.pgIndexStart + - // m_BP4Serializer.m_MetadataSet.metadataFileLength + - // m_BP4Serializer.m_PreMetadataFileLength; - // const uint64_t varIndexStartMetadataFile = - // m_BP4Serializer.m_MetadataSet.varIndexStart + - // m_BP4Serializer.m_MetadataSet.metadataFileLength + - // m_BP4Serializer.m_PreMetadataFileLength; - // const uint64_t attrIndexStartMetadataFile = - // m_BP4Serializer.m_MetadataSet.attrIndexStart + - // m_BP4Serializer.m_MetadataSet.metadataFileLength + - // m_BP4Serializer.m_PreMetadataFileLength; - // size_t currentStepEndPos = - // m_BP4Serializer.m_MetadataSet.metadataFileLength + - // m_BP4Serializer.m_Metadata.m_Position + - // m_BP4Serializer.m_PreMetadataFileLength; - - // BufferSTL metadataIndex; - // metadataIndex.Resize(128, "BP4 Index Table Entry"); - - // uint64_t currentStep; - // if (isFinal && m_BP4Serializer.m_MetadataSet.DataPGCount > 0) - // { - // // Not run with BeginStep() and EndStep(). - // // Only one step of metadata is generated at close. - // currentStep = m_BP4Serializer.m_MetadataSet.TimeStep; - // } - // else - // { - // currentStep = m_BP4Serializer.m_MetadataSet.TimeStep - - // 1; // The current TimeStep has already been - // increased - // // by 1 at this point, so decrease it by 1 - // } - - // // std::cout << "currentStep: " << currentStep << std::endl; - - // if (currentStep == 1) // TimeStep starts from 1 - // { - // m_BP4Serializer.MakeHeader(metadataIndex, "Index Table", - // true); - // } - - // std::time_t currentTimeStamp = std::time(nullptr); - - // PopulateMetadataIndexFileContent( - // metadataIndex, currentStep, m_BP4Serializer.m_RankMPI, - // pgIndexStartMetadataFile, varIndexStartMetadataFile, - // attrIndexStartMetadataFile, currentStepEndPos, - // currentTimeStamp); - m_FileMetadataIndexManager.WriteFiles( m_BP4Serializer.m_MetadataIndex.m_Buffer.data(), m_BP4Serializer.m_MetadataIndex.m_Position); From ec3c4146c8aa9b4e30deb918c6b4cccd0d1c5068 Mon Sep 17 00:00:00 2001 From: William F Godoy Date: Tue, 17 Sep 2019 21:56:45 -0400 Subject: [PATCH 2/2] Future check in append mode --- source/adios2/engine/bp4/BP4Writer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/adios2/engine/bp4/BP4Writer.cpp b/source/adios2/engine/bp4/BP4Writer.cpp index c2fc47f4de..136a384e3f 100644 --- a/source/adios2/engine/bp4/BP4Writer.cpp +++ b/source/adios2/engine/bp4/BP4Writer.cpp @@ -296,6 +296,10 @@ void BP4Writer::InitBPBuffer() if (m_BP4Serializer.m_Aggregator.m_IsConsumer) { + if (m_FutureOpenFiles.valid()) + { + m_FutureOpenFiles.get(); + } m_BP4Serializer.m_PreDataFileLength = m_FileDataManager.GetFileSize(0);