From 68846eb8ecd7b42a6bd3d2198d50857ab1113bbe Mon Sep 17 00:00:00 2001 From: wfg <wfg@pc0098504.ornl.gov> Date: Tue, 28 Mar 2017 10:57:25 -0400 Subject: [PATCH] First working version using time aggregation Will merge into groupless branch --- .../hello/bpWriter/helloBPWriter_nompi.cpp | 12 ++++++------ examples/hello/timeBP/timeBPWriter_nompi.cpp | 19 ++++++++----------- include/engine/bp/BPFileWriter.h | 4 ++-- include/format/BP1.h | 2 +- include/format/BP1Writer.h | 2 +- src/engine/bp/BPFileWriter.cpp | 1 + src/format/BP1Writer.cpp | 9 +++------ 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/examples/hello/bpWriter/helloBPWriter_nompi.cpp b/examples/hello/bpWriter/helloBPWriter_nompi.cpp index 18e965be8..89eb754a1 100644 --- a/examples/hello/bpWriter/helloBPWriter_nompi.cpp +++ b/examples/hello/bpWriter/helloBPWriter_nompi.cpp @@ -34,9 +34,9 @@ int main( int argc, char* argv [] ) { //Define variable and local size adios::Variable<double>& ioMyDoubles = adios.DefineVariable<double>( "myDoubles", adios::Dims{Nx} ); -// adios::Variable<float>& ioMyMatrix = adios.DefineVariable<float>( "myMatrix", adios::Dims{rows,columns} ); -// adios::Variable<float>& ioMyMatrix2 = adios.DefineVariable<float>( "myMatrix2", adios::Dims{rows,columns} ); -// adios::Variable<float>& ioMyMatrix3 = adios.DefineVariable<float>( "myMatrix3", adios::Dims{rows,columns} ); + adios::Variable<float>& ioMyMatrix = adios.DefineVariable<float>( "myMatrix", adios::Dims{rows,columns} ); + adios::Variable<float>& ioMyMatrix2 = adios.DefineVariable<float>( "myMatrix2", adios::Dims{rows,columns} ); + adios::Variable<float>& ioMyMatrix3 = adios.DefineVariable<float>( "myMatrix3", adios::Dims{rows,columns} ); //Define method for engine creation, it is basically straight-forward parameters adios::Method& bpWriterSettings = adios.DeclareMethod( "SinglePOSIXFile" ); //default method type is Writer @@ -51,9 +51,9 @@ int main( int argc, char* argv [] ) throw std::ios_base::failure( "ERROR: couldn't create bpWriter at Open\n" ); bpFileWriter->Write<double>( ioMyDoubles, myDoubles.data() ); // Base class Engine own the Write<T> that will call overloaded Write from Derived -// bpFileWriter->Write<float>( ioMyMatrix, myMatrix.data() ); //2d Example -// bpFileWriter->Write<float>( ioMyMatrix2, myMatrix2.data() ); //2d Example -// bpFileWriter->Write<float>( ioMyMatrix3, myMatrix2.data() ); //2d Example + bpFileWriter->Write<float>( ioMyMatrix, myMatrix.data() ); //2d Example + bpFileWriter->Write<float>( ioMyMatrix2, myMatrix2.data() ); //2d Example + bpFileWriter->Write<float>( ioMyMatrix3, myMatrix2.data() ); //2d Example bpFileWriter->Close( ); // } diff --git a/examples/hello/timeBP/timeBPWriter_nompi.cpp b/examples/hello/timeBP/timeBPWriter_nompi.cpp index 5301a5ac3..4aa813be4 100644 --- a/examples/hello/timeBP/timeBPWriter_nompi.cpp +++ b/examples/hello/timeBP/timeBPWriter_nompi.cpp @@ -18,7 +18,7 @@ int main( int argc, char* argv [] ) adios::ADIOS adios( adiosDebug ); //Application variable - std::vector<double> myDoubles = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + std::vector<double> myDoubles = { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; const std::size_t Nx = myDoubles.size(); const std::size_t rows = 3; @@ -47,21 +47,18 @@ int main( int argc, char* argv [] ) bpWriterSettings.SetParameters( "profile_units=mus" ); bpWriterSettings.AddTransport( "File", "profile_units=mus", "have_metadata_file=no" ); //uses default POSIX library - //Create engine smart pointer due to polymorphism, - //Open returns a smart pointer to Engine containing the Derived class Writer - //auto bpWriter = adios.Open( "time_nompi.bp", "w", bpWriterSettings ); - + //Create object directly rather than using polymorphism with ADIOS.Open adios::BPFileWriter bpWriter( adios, "time_nompi.bp", "w", adios.m_MPIComm, bpWriterSettings, adiosDebug ); - for( unsigned int t = 0; t < 2; ++t ) + for( unsigned int t = 0; t < 3; ++t ) { - myDoubles[0] = t; -// myMatrix[0] = t; -// myMatrix2[0] = t; + myDoubles[0] = t; // t * -1; + myMatrix[0] = t; + myMatrix2[0] = t; bpWriter.Write( ioMyDoubles, myDoubles.data() ); // Base class Engine own the Write<T> that will call overloaded Write from Derived -// bpWriter.Write( ioMyMatrix, myMatrix.data() ); -// bpWriter.Write( ioMyMatrix2, myMatrix2.data() ); + bpWriter.Write( ioMyMatrix, myMatrix.data() ); + bpWriter.Write( ioMyMatrix2, myMatrix2.data() ); bpWriter.Advance(); } diff --git a/include/engine/bp/BPFileWriter.h b/include/engine/bp/BPFileWriter.h index 5a86bf554..6a4660451 100644 --- a/include/engine/bp/BPFileWriter.h +++ b/include/engine/bp/BPFileWriter.h @@ -124,8 +124,8 @@ private: WriteProcessGroupIndex( ); //pre-calculate new metadata and payload sizes - m_TransportFlush = CheckBufferAllocation( m_BP1Writer.GetVariableIndexSize( variable ) + variable.PayLoadSize(), - m_GrowthFactor, m_MaxBufferSize, m_Buffer.m_Data ); +// m_TransportFlush = CheckBufferAllocation( m_BP1Writer.GetVariableIndexSize( variable ) + variable.PayLoadSize(), +// m_GrowthFactor, m_MaxBufferSize, m_Buffer.m_Data ); //WRITE INDEX to data buffer and metadata structure (in memory)// m_BP1Writer.WriteVariableMetadata( variable, m_Buffer, m_MetadataSet ); diff --git a/include/format/BP1.h b/include/format/BP1.h index 799f3933e..eed6b17be 100644 --- a/include/format/BP1.h +++ b/include/format/BP1.h @@ -52,7 +52,7 @@ struct BP1Index */ struct BP1MetadataSet { - std::uint32_t TimeStep = 0; ///< current time step, updated with advance step, if append it will be updated to last + std::uint32_t TimeStep; ///< current time step, updated with advance step, if append it will be updated to last, starts with one in ADIOS1 BP1Index PGIndex = BP1Index( 0 ); ///< single buffer for PGIndex diff --git a/include/format/BP1Writer.h b/include/format/BP1Writer.h index 94a3bed8e..4e7de3424 100644 --- a/include/format/BP1Writer.h +++ b/include/format/BP1Writer.h @@ -253,7 +253,7 @@ private: } else //update characteristics sets count { - const std::size_t characteristicsSetsCountPosition = 13 + variable.m_Name.size(); + const std::size_t characteristicsSetsCountPosition = 15 + variable.m_Name.size(); ++index.Count; CopyToBuffer( buffer, characteristicsSetsCountPosition, &index.Count ); //test } diff --git a/src/engine/bp/BPFileWriter.cpp b/src/engine/bp/BPFileWriter.cpp index 12e70290e..ad704b5ee 100644 --- a/src/engine/bp/BPFileWriter.cpp +++ b/src/engine/bp/BPFileWriter.cpp @@ -24,6 +24,7 @@ BPFileWriter::BPFileWriter( ADIOS& adios, const std::string name, const std::str m_BP1Aggregator{ format::BP1Aggregator( m_MPIComm, debugMode ) }, m_MaxBufferSize{ m_Buffer.m_Data.max_size() } { + m_MetadataSet.TimeStep = 1; //starting at one to be compatible with ADIOS1.x Init( ); } diff --git a/src/format/BP1Writer.cpp b/src/format/BP1Writer.cpp index 662f37ac2..a441e6392 100644 --- a/src/format/BP1Writer.cpp +++ b/src/format/BP1Writer.cpp @@ -7,8 +7,6 @@ /// \cond EXCLUDE_FROM_DOXYGEN #include <string> -#include <iostream> -#include <unistd.h> //sleep must be removed /// \endcond #include "format/BP1Writer.h" @@ -150,7 +148,7 @@ std::string BP1Writer::GetRankProfilingLog( const int rank, const BP1MetadataSet { auto lf_WriterTimer = []( std::string& rankLog, const Timer& timer ) { - rankLog += timer.Process + "_" + timer.GetUnits() + "': " + std::to_string( timer.ProcessTime ) + ", "; + rankLog += "'" + timer.Process + "_" + timer.GetUnits() + "': " + std::to_string( timer.ProcessTime ) + ", "; }; //prepare string dictionary per rank @@ -165,16 +163,15 @@ std::string BP1Writer::GetRankProfilingLog( const int rank, const BP1MetadataSet auto& timers = transports[t]->m_Profiler.m_Timers; rankLog += "'transport_" + std::to_string(t) + "': { "; - rankLog += "'lib:' " + transports[t]->m_Type + ", "; + rankLog += "'lib': " + transports[t]->m_Type + ", "; for( unsigned int i = 0; i < 3; ++i ) lf_WriterTimer( rankLog, timers[i] ); - rankLog += " }, "; + rankLog += "}, "; } rankLog += "}, "; - //std::cout << rankLog << "\n"; return rankLog; } -- GitLab