diff --git a/buildBP.sh b/buildBP.sh new file mode 100755 index 0000000000000000000000000000000000000000..1da55d54d515cf4f8448e69297e89e79150ea609 --- /dev/null +++ b/buildBP.sh @@ -0,0 +1,52 @@ +#!/bin/bash + + +# buildTest.sh for BP Writer example +# Created on: Feb 9, 2017 +# Author: wfg +# Recommended: do a "make clean" the first time + +MPICOMPILER=mpic++ + +if [ "$(uname)" == "Darwin" ]; then + CCOMPILER=clang++ +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + CCOMPILER=g++ +fi +echo "######################################################################################" +echo "Start building ADIOS ./lib/libadios.a ./libadios_nompi.a" +echo "######################################################################################" +echo +make -j4 CC=$CCOMPILER MPICC=$MPICOMPILER #build the ./lib/libadios.a and ./libadios_nompi.a +echo +echo "#################################################################" +echo "Building BPWriter example" +echo "#################################################################" +make -j4 -C ./examples/hello/bpWriter CC=$CCOMPILER MPICC=$MPICOMPILER +#make -j4 -C ./examples/hello/bpReader CC=$CCOMPILER MPICC=$MPICOMPILER +echo +echo +echo +echo "#################################################################" +echo "Running nompi.exe example" +echo "#################################################################" +echo +echo +echo "#################################################################" +echo "BP writer" +echo "#################################################################" +./examples/hello/bpWriter/helloBPWriter_nompi.exe +echo "DONE...check for myDoubles_nompi.bp directory" + +echo "#################################################################" +echo "BP reader..not ready yet" +echo "#################################################################" +#./examples/hello/bpWriter/helloBPReader.exe +echo +echo +echo "#################################################################" +echo "To run mpi version with 4 mpi processes: " +echo "mpirun -n 4 ./examples/hello/bpWriter/helloBPWriter.exe" +echo "mpirun -n 4 ./examples/hello/bpReader/helloBPReader.exe" +echo "END" +echo "################################################################" diff --git a/examples/hello/bpReader/Makefile b/examples/hello/bpReader/Makefile index b63e867e402f007f5e7d78eb9bb6241b778968cb..b5705da1c7f7e406623c9aafd9380d3dc94ead07 100644 --- a/examples/hello/bpReader/Makefile +++ b/examples/hello/bpReader/Makefile @@ -2,7 +2,7 @@ # Created on: Oct 4, 2016 # Author: wfg -BASE_NAME=helloWriter +BASE_NAME=helloBPReader #COMPILERS CC=g++ diff --git a/examples/hello/bpReader/helloBPReader.cpp b/examples/hello/bpReader/helloBPReader.cpp index 6bb1ef383a39ec044c7feffac6047381cd857ba3..bb1bc35d9134b8fbe4bf5131aea99ff820e7a31c 100644 --- a/examples/hello/bpReader/helloBPReader.cpp +++ b/examples/hello/bpReader/helloBPReader.cpp @@ -28,16 +28,15 @@ int main( int argc, char* argv [] ) try { //Define method for engine creation, it is basically straight-forward parameters - adios::Method& bpWriterSettings = adios.DeclareMethod( "SingleFile" ); //default method type is BPWriter - bpWriterSettings.AddTransport( "File" ); //uses default POSIX library + adios::Method& bpReaderSettings = adios.DeclareMethod( "SingleFile" ); //default method type is BPWriter + bpReaderSettings.AddTransport( "File" ); //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( "myDoubles.bp", "r", bpWriterSettings ); - - if( bpWriter == nullptr ) - throw std::ios_base::failure( "ERROR: couldn't create bpWriter at Open\n" ); + auto bpReader = adios.Open( "myDoubles_nompi.bp", "r", bpReaderSettings ); + if( bpReader == nullptr ) + throw std::ios_base::failure( "ERROR: couldn't create bpReader at Open\n" ); } catch( std::invalid_argument& e ) diff --git a/examples/hello/bpReader/helloBPReader_nompi.cpp b/examples/hello/bpReader/helloBPReader_nompi.cpp index b15518a2e1a4323f123047a83f36431e848b1c56..b5e437deabafc50c5e8ec80c7d0010fb10bb6f27 100644 --- a/examples/hello/bpReader/helloBPReader_nompi.cpp +++ b/examples/hello/bpReader/helloBPReader_nompi.cpp @@ -16,28 +16,18 @@ int main( int argc, char* argv [] ) const bool adiosDebug = true; adios::ADIOS adios( adiosDebug ); - //Application variable - std::vector<double> myDoubles = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - const std::size_t Nx = myDoubles.size(); - try { - //Define variable and local size - auto& ioMyDoubles = adios.DefineVariable<double>( "myDoubles", adios::Dims{Nx} ); - - //Define method for engine creation, it is basically straight-forward parameters - adios::Method& bpWriterSettings = adios.DeclareMethod( "SinglePOSIXFile" ); //default method type is Writer - bpWriterSettings.AddTransport( "File", "have_metadata_file=yes" ); - - //Create engine smart pointer due to polymorphism, - //Open returns a smart pointer to Engine containing the Derived class Writer - auto bpWriter = adios.Open( "myDoubles_nompi.bp", "w", bpWriterSettings ); + //Define method for engine creation, it is basically straight-forward parameters + adios::Method& bpReaderSettings = adios.DeclareMethod( "SingleFile" ); //default method type is BPWriter/BPReader + bpReaderSettings.AddTransport( "File" ); //uses default POSIX library - if( bpWriter == nullptr ) - throw std::ios_base::failure( "ERROR: couldn't create bpWriter at Open\n" ); + //Create engine smart pointer due to polymorphism, + //Open returns a smart pointer to Engine containing the Derived class Writer + auto bpReader = adios.Open( "myDoubles.bp", "r", bpReaderSettings ); - bpWriter->Write<double>( ioMyDoubles, myDoubles.data() ); // Base class Engine own the Write<T> that will call overloaded Write from Derived - bpWriter->Close( ); + if( bpReader == nullptr ) + throw std::ios_base::failure( "ERROR: couldn't create bpReader at Open\n" ); } catch( std::invalid_argument& e ) { diff --git a/include/ADIOS.h b/include/ADIOS.h index c21977d78d999564fef88ebbb4e7c7ce8227a996..e0e4e19bff15d9b1f97a61438559a4d907efe677 100644 --- a/include/ADIOS.h +++ b/include/ADIOS.h @@ -11,7 +11,7 @@ /// \cond EXCLUDE_FROM_DOXYGEN #include <string> #include <vector> -#include <memory> //shared_ptr +#include <memory> //std::shared_ptr #include <ostream> #include <set> #include <map> @@ -134,7 +134,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO * @param name must be unique * @param type supported type : "Writer" (default), "DataMan"...future: "Sirius" */ - Method& DeclareMethod( const std::string methodName, const std::string type = "BPWriter" ); + Method& DeclareMethod( const std::string methodName, const std::string type = "" ); /** diff --git a/include/core/Method.h b/include/core/Method.h index 1decbd7aac2511d23145e055d78393d4fbca8403..84ed0f95ecc7ff13fa97f971f083c07f4f760aff 100644 --- a/include/core/Method.h +++ b/include/core/Method.h @@ -34,7 +34,7 @@ public: /** * Constructor - * @param type must be an engine type, default = SingleBP + * @param type must be an engine type */ Method( const std::string type, const bool debugMode = false ); diff --git a/include/format/BP1.h b/include/format/BP1.h index 1696c143b89073b894790b59a0f2d5aef080852c..cfccc7d47f543e1e432eea561ec5349130498d74 100644 --- a/include/format/BP1.h +++ b/include/format/BP1.h @@ -24,6 +24,7 @@ namespace adios namespace format { + /** * Struct that tracks metadata indices in bp format */ diff --git a/include/format/BP1Writer.h b/include/format/BP1Writer.h index 32bb42e3e40d95d8ce23a2115c521c9c494027db..e618b11d06c538e251961c62a56cd5dd7a663895 100644 --- a/include/format/BP1Writer.h +++ b/include/format/BP1Writer.h @@ -39,7 +39,7 @@ public: unsigned int m_Cores = 1; ///< number of cores for thread operations in large array (min,max) unsigned int m_Verbosity = 0; ///< statistics verbosity, can change if redefined in Engine method. float m_GrowthFactor = 1.5; ///< memory growth factor, can change if redefined in Engine method. - const std::uint8_t m_Version = 3; + const std::uint8_t m_Version = 3; ///< BP format version /** * Calculates the Process Index size in bytes according to the BP format, including list of method with no parameters (for now) @@ -230,14 +230,16 @@ public: /** - * Function that collects metadata (if first close) and writes to a single transport - * @param metadataSet - * @param capsule - * @param transport - * @param isFirstClose + * Function that sets metadata (if first close) and writes to a single transport + * @param metadataSet current rank metadata set + * @param capsule contains data and metadata buffers + * @param transport does a write after data and metadata is setup + * @param isFirstClose true: metadata has been set and aggregated + * @param haveMetadata true: attach metadata buffer to each data buffer and do a transport write + * @param haveTiming true: add timing.log file */ - void Close( BP1MetadataSet& metadataSet, Capsule& capsule, Transport& transport, bool& isFirstClose ) const noexcept; - + void Close( BP1MetadataSet& metadataSet, Capsule& capsule, Transport& transport, bool& isFirstClose, + const bool haveMetadata = true, const bool haveTiming = false ) const noexcept; private: diff --git a/src/engine/bp/BPReader.cpp b/src/engine/bp/BPReader.cpp index c893d00478f9c31701f39145f12364a343d161e7..dd6481a2aaeecc6acfb99e60152055c7880b7b4e 100644 --- a/src/engine/bp/BPReader.cpp +++ b/src/engine/bp/BPReader.cpp @@ -135,20 +135,20 @@ void BPReader::InitTransports( ) //maybe move this? if( itLibrary == parameters.end() || itLibrary->second == "POSIX" ) //use default POSIX { auto file = std::make_shared<transport::FD>( m_MPIComm, m_DebugMode ); - //m_BP1Writer.OpenRankFiles( m_Name, m_AccessMode, *file ); + //m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); m_Transports.push_back( std::move( file ) ); } else if( itLibrary->second == "FILE*" || itLibrary->second == "stdio.h" ) { auto file = std::make_shared<transport::FP>( m_MPIComm, m_DebugMode ); - //m_BP1Writer.OpenRankFiles( m_Name, m_AccessMode, *file ); + //m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); m_Transports.push_back( std::move( file ) ); } else if( itLibrary->second == "fstream" || itLibrary->second == "std::fstream" ) { auto file = std::make_shared<transport::FStream>( m_MPIComm, m_DebugMode ); - //m_BP1Writer.OpenRankFiles( m_Name, m_AccessMode, *file ); + //m_BP1Reader.OpenRankFiles( m_Name, m_AccessMode, *file ); m_Transports.push_back( std::move( file ) ); } else if( itLibrary->second == "MPI-IO" ) diff --git a/src/format/BP1Writer.cpp b/src/format/BP1Writer.cpp index fbbd68c3dac422ca3dc10fc770eece3230169604..a4ac52cf81ad29bd66c9807b8ad19bba28ebf722 100644 --- a/src/format/BP1Writer.cpp +++ b/src/format/BP1Writer.cpp @@ -93,21 +93,28 @@ void BP1Writer::WriteProcessGroupIndex( const bool isFortran, const std::string } -void BP1Writer::Close( BP1MetadataSet& metadataSet, Capsule& capsule, - Transport& transport, bool& isFirstClose ) const noexcept +void BP1Writer::Close( BP1MetadataSet& metadataSet, Capsule& capsule, Transport& transport, bool& isFirstClose, + const bool haveMetadata, const bool haveTiming ) const noexcept { if( isFirstClose == true ) { - FlattenMetadata( metadataSet, capsule ); //now capsule + FlattenMetadata( metadataSet, capsule ); isFirstClose = false; } //implementing N-to-N for now, no aggregation transport.Write( capsule.GetData(), capsule.m_DataPosition ); - transport.Write( capsule.GetMetadata(), capsule.GetMetadataSize() ); //we can improve this by copying metadata to data + + if( haveMetadata == true ) + transport.Write( capsule.GetMetadata(), capsule.GetMetadataSize() ); //we can improve this by copying metadata to data + + //here accumulate in metadata file + transport.Close(); } + +//PRIVATE FUNCTIONS void BP1Writer::WriteProcessGroupIndexCommon( const bool isFortran, const std::string name, const unsigned int processID, const std::string timeStepName, const unsigned int timeStep, const std::vector<int>& methodIDs,