From 9a962d01cf93520e9d28b2df1e0f5087f2796ede Mon Sep 17 00:00:00 2001 From: Jason Wang <wangr1@ornl.gov> Date: Thu, 2 Mar 2017 20:18:13 -0500 Subject: [PATCH] Fixed a number of minor things for DataMan engine. The first real-world demo code ran successfully with the AdiosPP framework --- buildDataMan.sh | 4 +- .../datamanReader/helloDataManReader.cpp | 2 +- .../helloDataManReader_nompi.cpp | 2 +- .../datamanWriter/helloDataManWriter.cpp | 4 +- .../helloDataManWriter_nompi.cpp | 6 +-- include/engine/dataman/DataManWriter.h | 42 +++++++++---------- src/engine/dataman/DataManWriter.cpp | 7 ++++ 7 files changed, 37 insertions(+), 30 deletions(-) diff --git a/buildDataMan.sh b/buildDataMan.sh index 0e65f3f0c..886d96447 100755 --- a/buildDataMan.sh +++ b/buildDataMan.sh @@ -9,7 +9,7 @@ DATAMAN_LOCATION=/Users/w4g/Dropbox/lib/DataMan MPICOMPILER=mpic++ if [ "$(uname)" == "Darwin" ]; then - CCOMPILER=clang++ + CCOMPILER=g++ export DYLD_LIBRARY_PATH=$DATAMAN_LOCATION/lib:$DYLD_LIBRARY_PATH elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then CCOMPILER=g++ @@ -43,7 +43,7 @@ echo "#################################################################" echo "#################################################################" echo "DataMan reader" echo "#################################################################" -./examples/hello/datamanReader/helloDataManReader_nompi.exe +#./examples/hello/datamanReader/helloDataManReader_nompi.exe echo echo diff --git a/examples/hello/datamanReader/helloDataManReader.cpp b/examples/hello/datamanReader/helloDataManReader.cpp index 0943c6c40..d3569ff6d 100644 --- a/examples/hello/datamanReader/helloDataManReader.cpp +++ b/examples/hello/datamanReader/helloDataManReader.cpp @@ -27,7 +27,7 @@ void getcb( const void *data, std::string doid, std::string var, std::string dty std::size_t varsize = std::accumulate(varshape.begin(), varshape.end(), 1, std::multiplies<std::size_t>()); - for (int i=0; i<varsize; i++) + for (size_t i=0; i<varsize; i++) std::cout << ((float*)data)[i] << " "; std::cout << std::endl; } diff --git a/examples/hello/datamanReader/helloDataManReader_nompi.cpp b/examples/hello/datamanReader/helloDataManReader_nompi.cpp index be16f1149..12d44b873 100644 --- a/examples/hello/datamanReader/helloDataManReader_nompi.cpp +++ b/examples/hello/datamanReader/helloDataManReader_nompi.cpp @@ -19,7 +19,7 @@ void getcb( const void *data, std::string doid, std::string var, std::string dty std::size_t varsize = std::accumulate(varshape.begin(), varshape.end(), 1, std::multiplies<std::size_t>()); - for (int i=0; i<varsize; i++) + for (size_t i=0; i<varsize; i++) std::cout << ((float*)data)[i] << " "; std::cout << std::endl; } diff --git a/examples/hello/datamanWriter/helloDataManWriter.cpp b/examples/hello/datamanWriter/helloDataManWriter.cpp index 574308aa4..48817643b 100644 --- a/examples/hello/datamanWriter/helloDataManWriter.cpp +++ b/examples/hello/datamanWriter/helloDataManWriter.cpp @@ -38,8 +38,8 @@ int main( int argc, char* argv [] ) try { //Define variable and local size - auto& ioMyDoubles = adios.DefineVariable<double>( "myDoubles", {Nx} ); - auto& ioMyCFloats = adios.DefineVariable<std::complex<float>>( "myCFloats", {3} ); + auto ioMyDoubles = adios.DefineVariable<double>( "myDoubles", {Nx} ); + auto ioMyCFloats = adios.DefineVariable<std::complex<float>>( "myCFloats", {3} ); //Define method for engine creation, it is basically straight-forward parameters adios::Method& datamanSettings = adios.DeclareMethod( "WAN", "DataManWriter" ); //default method type is Writer diff --git a/examples/hello/datamanWriter/helloDataManWriter_nompi.cpp b/examples/hello/datamanWriter/helloDataManWriter_nompi.cpp index c5c68a96b..817652514 100644 --- a/examples/hello/datamanWriter/helloDataManWriter_nompi.cpp +++ b/examples/hello/datamanWriter/helloDataManWriter_nompi.cpp @@ -31,14 +31,14 @@ int main( int argc, char* argv [] ) { //Define variable and local size //Define variable and local size - auto& ioMyFloats = adios.DefineVariable<float>( "myfloats", adios::Dims{Nx} ); - auto& ioMyFloat = adios.DefineVariable<float>( "myfloat", adios::Dims{1} ); + auto ioMyFloats = adios.DefineVariable<float>( "myfloats", adios::Dims{Nx} ); + auto ioMyFloat = adios.DefineVariable<float>( "myfloat", adios::Dims{1} ); // auto& ioMyDoubles = adios.DefineVariable<double>( "myDoubles", adios::Dims{Nx} ); // auto& ioMyCFloats = adios.DefineVariable<std::complex<float>>( "myCFloats", {3} ); //Define method for engine creation, it is basically straight-forward parameters adios::Method& datamanSettings = adios.DeclareMethod( "WAN", "DataManWriter" ); //default method type is Writer - datamanSettings.SetParameters( "real_time=yes", "method_type=stream", "method=dump", "local_ip=127.0.0.1", "remote_ip=127.0.0.1", "local_port=12306", "remote_port=12307" ); + datamanSettings.SetParameters( "real_time=yes", "method_type=stream", "method=dump", "monitoring=yes", "local_ip=127.0.0.1", "remote_ip=127.0.0.1", "local_port=12306", "remote_port=12307" ); // datamanSettings.AddTransport( "Mdtm", "localIP=128.0.0.0.1", "remoteIP=128.0.0.0.2", "tolerances=1,2,3" ); //datamanSettings.AddTransport( "ZeroMQ", "localIP=128.0.0.0.1.1", "remoteIP=128.0.0.0.2.1", "tolerances=1,2,3" ); not yet supported , will throw an exception diff --git a/include/engine/dataman/DataManWriter.h b/include/engine/dataman/DataManWriter.h index 2d85c1fb1..a5c4706c8 100644 --- a/include/engine/dataman/DataManWriter.h +++ b/include/engine/dataman/DataManWriter.h @@ -88,6 +88,7 @@ private: format::BP1Writer m_BP1Writer; ///< format object will provide the required BP functionality to be applied on m_Buffer and m_Transports bool m_DoRealTime = false; + bool m_DoMonitor = false; DataManager m_Man; std::function<void( const void*, std::string, std::string, std::string, Dims )> m_CallBack; ///< call back function @@ -118,36 +119,35 @@ private: jmsg["doid"] = m_Name; jmsg["var"] = variable.m_Name; jmsg["dtype"] = GetType<T>(); - std::cout << "variable.m_Dimensions.size() = " << variable.m_Dimensions.size() << endl; jmsg["putshape"] = variable.m_Dimensions; -// if(variable.m_GlobalDimensions.size() == 0) variable.m_GlobalDimensions = variable.m_Dimensions; + if(variable.m_GlobalDimensions.size() == 0) variable.m_GlobalDimensions = variable.m_Dimensions; jmsg["varshape"] = variable.m_GlobalDimensions; -// if(variable.m_GlobalOffsets.size() == 0) variable.m_GlobalOffsets.assign(variable.m_Dimensions.size(),0); + if(variable.m_GlobalOffsets.size() == 0) variable.m_GlobalOffsets.assign(variable.m_Dimensions.size(),0); jmsg["offset"] = variable.m_GlobalOffsets; jmsg["timestep"] = 0; m_Man.put(values, jmsg); - std::cout << "putshape " << variable.m_Dimensions.size() << endl; - std::cout << "varshape " << variable.m_GlobalDimensions.size() << endl; - std::cout << "offset " << variable.m_GlobalOffsets.size() << endl; - - std::cout << "I am hooked to the DataMan library\n"; - MPI_Barrier( m_MPIComm ); - - for( int i = 0; i < m_SizeMPI; ++i ) - { - if( i == m_RankMPI ) - { - std::cout << "Rank: " << m_RankMPI << "\n"; - variable.Monitor( std::cout ); - std::cout << std::endl; - } - else + if(m_DoMonitor){ + MPI_Barrier( m_MPIComm ); + std::cout << "I am hooked to the DataMan library\n"; + std::cout << "putshape " << variable.m_Dimensions.size() << endl; + std::cout << "varshape " << variable.m_GlobalDimensions.size() << endl; + std::cout << "offset " << variable.m_GlobalOffsets.size() << endl; + for( int i = 0; i < m_SizeMPI; ++i ) { - sleep( 1 ); + if( i == m_RankMPI ) + { + std::cout << "Rank: " << m_RankMPI << "\n"; + variable.Monitor( std::cout ); + std::cout << std::endl; + } + else + { + sleep( 1 ); + } } + MPI_Barrier( m_MPIComm ); } - MPI_Barrier( m_MPIComm ); } }; diff --git a/src/engine/dataman/DataManWriter.cpp b/src/engine/dataman/DataManWriter.cpp index 9152f6b15..87c54aa74 100644 --- a/src/engine/dataman/DataManWriter.cpp +++ b/src/engine/dataman/DataManWriter.cpp @@ -165,6 +165,13 @@ void DataManWriter::Init( ) m_DoRealTime = true; } + itRealTime = m_Method.m_Parameters.find( "monitoring" ); + if( itRealTime != m_Method.m_Parameters.end() ) + { + if( itRealTime->second == "yes" || itRealTime->second == "true" ) + m_DoMonitor = true; + } + if(m_DoRealTime) { /** -- GitLab