diff --git a/Makefile b/Makefile index 7dc1c449713f6f3163a65a3f05e686ddce49a2db..0581afa17e57133858bfc748cb81c681fb987621 100644 --- a/Makefile +++ b/Makefile @@ -2,16 +2,11 @@ # Created on: Oct 4, 2016 # Author: wfg -#SYSTEM DIRECTORIES, USER MUST MODIFY THESE VALUES -SYS_BIN:=/usr/bin -SYS_LIB:=/usr/lib/x86_64-linux-gnu -LOCAL_LIB:=/usr/local/lib - -#COMPILERS IN PATH AND LIBRARY LOCATIONS +#DEFAULT COMPILERS IN PATH, LIBS will be modified in Makefile.libs CC:=g++ AR:=ar MPICC:=mpic++ -LIBS:= -L$(SYS_LIB) -L$(LOCAL_LIB) +LIBS:= CFLAGS:=-c -Wall -Wpedantic -std=c++11 -O0 -g ARFLAGS:=rcs @@ -27,8 +22,8 @@ VPATH = ./src ./src/core ./src/functions \ ./src/transform \ ./src/format -#SEPARATE EXTERNAL LIBRARIES HANDLING in Makefile.libs -export $(HFiles) $(CPPFiles) $(CFLAGS) $(LIBS) +#SEPARATE EXTERNAL HEADERS AND LIBRARIES HANDLING in Makefile.libs, export variables +export $(HFiles) $(CPPFiles) $(CFLAGS) $(INC) $(LIBS) include Makefile.libs OBJMPI:=$(patsubst %.cpp, ./bin/mpi/%.o, $(notdir $(CPPFiles)) ) diff --git a/Makefile.libs b/Makefile.libs index 22bfe36681cbd0129d4ba66c63952a8e79602daa..c0a08b1f09d4e6b823080f361eb2dc42268a2c3c 100644 --- a/Makefile.libs +++ b/Makefile.libs @@ -8,11 +8,29 @@ else CPPFiles:=$(filter-out $(LANGUAGE_SRC)/ADIOS_C.cpp,$(CPPFiles)) endif - -#TRANSPORTS WITH EXTERNAL DEPENDENCIES +#EXTERNAL DEPENDECIES +ENGINE_INC:=./include/engine +ENGINE_SRC:=./src/engine TRANSPORT_INC:=./include/transport TRANSPORT_SRC:=./src/transport +ifeq ($(HAVE_DATAMAN),yes) + DATAMAN_LOC:=/home/wfg/Applications/DataMan# need to change this to your local dataman location + CFLAGS += -DHAVE_DATAMAN + INC += -I$(DATAMAN_LOC)/include + LIBS += -L$(DATAMAN_LOC)/lib -lcacheman -lstreamman -lzmqman +else + HFiles:=$(filter-out $(ENGINE_INC)/dataman/DataManWriter.h,$(HFiles)) + HFiles:=$(filter-out $(ENGINE_INC)/dataman/DataManReader.h,$(HFiles)) + HFiles:=$(filter-out $(TRANSPORT_INC)/wan/MdtmMan.h,$(HFiles)) + + CPPFiles:=$(filter-out $(ENGINE_SRC)/dataman/DataManWriter.cpp,$(CPPFiles)) + CPPFiles:=$(filter-out $(ENGINE_SRC)/dataman/DataManReader.cpp,$(CPPFiles)) + CPPFiles:=$(filter-out $(TRANSPORT_SRC)/wan/MdtmMan.cpp,$(CPPFiles)) +endif + + +#EXTERNAL DEPENDENCIES ifeq ($(HAVE_NETCDF),yes) LIBS += -lnetcdf CFLAGS += -DHAVE_NETCDF @@ -30,10 +48,6 @@ else endif -#TRANSFORMS WITH EXTERNAL DEPENDENCIES -TRANSFORM_INC:=./include/transform -TRANSFORM_SRC:=./src/transform - ifeq ($(HAVE_BZIP2),yes) LIBS += -lbz2 CFLAGS += -DHAVE_BZIP2 diff --git a/buildDataman.sh b/buildDataMan.sh similarity index 82% rename from buildDataman.sh rename to buildDataMan.sh index 3a942c6ef72596fbd44fa272e65d9f895b459452..9a298da4bbc366d1f2c680fa354b657e41178062 100755 --- a/buildDataman.sh +++ b/buildDataMan.sh @@ -5,10 +5,10 @@ # Created on: Feb 9, 2017 # Author: wfg - +DATAMAN_LOCATION=/home/wfg/Applications/DataMan echo "#################################################################" echo "Start building ADIOS ./lib/libadios.a ./libadios_nompi.a" -make #build the ./lib/libadios.a and ./libadios_nompi.a +make HAVE_DATAMAN=yes DATAMAN_LOC=$DATAMAN_LOCATION #build the ./lib/libadios.a and ./libadios_nompi.a echo "#################################################################" echo @@ -16,9 +16,9 @@ echo echo "#################################################################" echo "Building Dataman Reader and Writer examples" echo "#################################################################" -make -C ./examples/hello/datamanWriter +make -C ./examples/hello/datamanWriter HAVE_DATAMAN=yes DATAMAN_LOC=$DATAMAN_LOCATION echo -make -C ./examples/hello/datamanReader +make -C ./examples/hello/datamanReader HAVE_DATAMAN=yes DATAMAN_LOC=$DATAMAN_LOCATION echo echo diff --git a/examples/hello/datamanReader/Makefile b/examples/hello/datamanReader/Makefile index 1da287a7e01fec8e580095ecf3f2be153decbce1..62ccd004b36c087fa9d5836dfe6621d4c02c8291 100644 --- a/examples/hello/datamanReader/Makefile +++ b/examples/hello/datamanReader/Makefile @@ -7,25 +7,36 @@ BASE_NAME=helloDataManReader CC=g++ # Compiling with defaults MPICC=mpic++ +INC= +LIB= +LIB_NOMPI= -#ADIOS LOCATION +#ADIOS ADIOS_DIR=../../.. -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a +LIB+= $(ADIOS_DIR)/lib/libadios.a +LIB_NOMPI+= $(ADIOS_DIR)/lib/libadios_nompi.a +INC+= -I$(ADIOS_DIR)/include -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include +#DATAMAN +DATAMAN_LOC=/home/wfg/Applications/DataMan +INC+= -I$(DATAMAN_LOC)/include +LIB+= -L$(DATAMAN_LOC)/lib -lcacheman -lstreamman -lzmqman - -#FLAGS +#COMPILER FLAGS CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11 +#SYSTEM LIBS +LIB+= -lpthread +LIB_NOMPI+= -lpthread + + all: mpi nompi mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME).exe $(ADIOS_LIB) -lpthread + $(MPICC) $(CFLAGS) $(INC) -DHAVE_MPI -DHAVE_DATAMAN $(BASE_NAME).cpp -o $(BASE_NAME).exe $(LIB) -lpthread nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(ADIOS_NOMPI_LIB) -lpthread + $(CC) $(CFLAGS) $(INC) -DHAVE_DATAMAN $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(LIB_NOMPI) -lpthread clean: rm *.exe; diff --git a/examples/hello/datamanWriter/Makefile b/examples/hello/datamanWriter/Makefile index 3b8cfcce537bbe8ddce4a3e116cfcff7059e272a..e915be6bf9ae0cd5fafdb2efba35f90f47eab843 100644 --- a/examples/hello/datamanWriter/Makefile +++ b/examples/hello/datamanWriter/Makefile @@ -7,25 +7,36 @@ BASE_NAME=helloDataManWriter CC=g++ # Compiling with defaults MPICC=mpic++ +INC= +LIB= +LIB_NOMPI= -#ADIOS LOCATION +#ADIOS ADIOS_DIR=../../.. -ADIOS_LIB=$(ADIOS_DIR)/lib/libadios.a -ADIOS_NOMPI_LIB=$(ADIOS_DIR)/lib/libadios_nompi.a +LIB+= $(ADIOS_DIR)/lib/libadios.a +LIB_NOMPI+= $(ADIOS_DIR)/lib/libadios_nompi.a +INC+= -I$(ADIOS_DIR)/include -ADIOS_INCLUDE=-I$(ADIOS_DIR)/include +#DATAMAN +DATAMAN_LOC=/home/wfg/Applications/DataMan +INC+= -I$(DATAMAN_LOC)/include +LIB+= -L$(DATAMAN_LOC)/lib -lcacheman -lstreamman -lzmqman - -#FLAGS +#COMPILER FLAGS CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11 +#SYSTEM LIBS +LIB+= -lpthread +LIB_NOMPI+= -lpthread + + all: mpi nompi mpi: $(ADIOS_LIB) $(ADIOS_HFiles) - $(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME).exe $(ADIOS_LIB) -lpthread + $(MPICC) $(CFLAGS) $(INC) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME).exe $(LIB) -lpthread nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles) - $(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(ADIOS_NOMPI_LIB) -lpthread + $(CC) $(CFLAGS) $(INC) $(BASE_NAME)_nompi.cpp -o $(BASE_NAME)_nompi.exe $(LIB_NOMPI) -lpthread clean: rm *.exe; diff --git a/examples/hello/datamanWriter/helloDataManWriter.cpp b/examples/hello/datamanWriter/helloDataManWriter.cpp index e9e961e997f3b706d7b8f6dae20bfba3a82a5dc9..7eff00a7eaa191c08d6f9b2409b9a58d341e6bd2 100644 --- a/examples/hello/datamanWriter/helloDataManWriter.cpp +++ b/examples/hello/datamanWriter/helloDataManWriter.cpp @@ -38,6 +38,10 @@ int main( int argc, char* argv [] ) adios::Method& datamanSettings = adios.DeclareMethod( "WAN", "DataManWriter" ); //default method type is Writer datamanSettings.SetParameters( "peer-to-peer=yes", "real_time=yes", "compress=no" ); datamanSettings.AddTransport( "Mdtm", "localIP=128.0.0.0.1", "remoteIP=128.0.0.0.2", "tolerances=1,2,3" ); + //datamanSettings.AddTransport( "file", "name=myfile.bp", "remoteIP=128.0.0.0.2", "tolerances=1,2,3" ); + //datamanSettings.AddTransport( "file", "name=myfile.bp", "remoteIP=128.0.0.0.2", "tolerances=1,2,3" ); + //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", "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 //Create engine smart pointer to DataMan Engine due to polymorphism, diff --git a/include/ADIOS.h b/include/ADIOS.h index a1e8c701e06e9c6eb1f8525fcbb11b7bdded49e0..93a152e9adfc47d196a5471900aea234e3970692 100644 --- a/include/ADIOS.h +++ b/include/ADIOS.h @@ -98,12 +98,14 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO const Dims globalDimensions = Dims( ), const Dims globalOffsets = Dims() ) { - //throw std::invalid_argument( "ERROR: type not supported for variable " + name + "\n" ); + throw std::invalid_argument( "ERROR: type not supported for variable " + name + " in call to DefineVariable\n" ); } template<class T> inline Variable<T>& GetVariable( const std::string name ) - { } + { + throw std::invalid_argument( "ERROR: type not supported for variable " + name + " in call to GetVariable\n" ); + } template<class T> diff --git a/include/ADIOS_CPP.h b/include/ADIOS_CPP.h index 0292313fd538bdbe9667780bc486d0dd45ac0d40..1dd00e3337f8c95c876708e5650da00575449989 100644 --- a/include/ADIOS_CPP.h +++ b/include/ADIOS_CPP.h @@ -15,7 +15,13 @@ #include "core/Engine.h" #include "core/Transform.h" #include "engine/bp/BPWriter.h" + +//Will allow to create engines directly (no polymorphism) +#ifdef HAVE_DATAMAN #include "engine/dataman/DataManWriter.h" +#include "engine/dataman/DataManReader.h" +#endif + #include "transform/BZip2.h" diff --git a/include/core/Engine.h b/include/core/Engine.h index a3b2d4ca39d7f9f6a318983815b0e288acbfdb5c..942cc8ae737890e7358cfeea946c4913633f2c69 100644 --- a/include/core/Engine.h +++ b/include/core/Engine.h @@ -168,6 +168,12 @@ public: virtual void Write( const std::string variableName, const std::complex<long double>* values ); virtual void Write( const std::string variableName, const void* values ); + /** + * Indicates that a new step is going to be written as new variables come in. + */ + virtual void AdvanceStep( ); + + //Read API /** * Inquires and (optionally) allocates and copies the contents of a variable diff --git a/include/engine/bp/BPWriter.h b/include/engine/bp/BPWriter.h index 33d09c7d6d790e12a0361b0475b530630d778215..105361c58caae7636b1eb70dc46a91e978ddef9b 100644 --- a/include/engine/bp/BPWriter.h +++ b/include/engine/bp/BPWriter.h @@ -72,6 +72,8 @@ public: void Write( const std::string variableName, const std::complex<long double>* values ); void Write( const std::string variableName, const void* values ); + void AdvanceStep( ); + void Close( const int transportIndex = -1 ); private: @@ -92,13 +94,13 @@ private: /** - * Common function + * Common function for primitive (including std::complex) writes * @param group * @param variableName * @param variable */ template< class T > - void WriteVariable( Variable<T>& variable, const T* values ) + void WriteVariableCommon( Variable<T>& variable, const T* values ) { //set variable variable.m_AppValues = values; diff --git a/include/engine/dataman/DataManReader.h b/include/engine/dataman/DataManReader.h index d0a51d079a1ca16630ceaeb800cdfb2d7b2f43ca..ade638d4140e74bbd9f4aff9ea4bd3c5cf0a7154 100644 --- a/include/engine/dataman/DataManReader.h +++ b/include/engine/dataman/DataManReader.h @@ -85,6 +85,7 @@ private: template< class T > Variable<T>* InquireVariableCommon( const std::string name, const bool readIn ) { + std::cout << "I am hooked to the DataMan library\n"; std::cout << "Hello DatamanReader from rank " << m_RankMPI << "\n"; std::cout << "Trying to read variable " << name << " from one of the variables coming from a WAN transport\n"; diff --git a/include/engine/dataman/DataManWriter.h b/include/engine/dataman/DataManWriter.h index 9df1c6b60799791d77b7c2d7eba65f00479a679f..be07b1abaf2398209275bd7e9bb2ddcd3b0aa2c2 100644 --- a/include/engine/dataman/DataManWriter.h +++ b/include/engine/dataman/DataManWriter.h @@ -17,6 +17,10 @@ //supported capsules #include "capsule/heap/STLVector.h" + +#include "DataMan.h" //here comes your DataMan header + + namespace adios { @@ -74,6 +78,8 @@ private: capsule::STLVector m_Buffer; ///< heap capsule, contains data and metadata buffers 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; + void Init( ); ///< calls InitCapsules and InitTransports based on Method, called from constructor void InitCapsules( ); void InitTransports( ); ///< from Transports @@ -96,6 +102,7 @@ private: m_WrittenVariables.insert( variable.m_Name ); //This part will go away, this is just to monitor variables per rank + std::cout << "I am hooked to the DataMan library\n"; MPI_Barrier( m_MPIComm ); for( int i = 0; i < m_SizeMPI; ++i ) diff --git a/include/format/BP1Writer.h b/include/format/BP1Writer.h index 9b697dc6d87bd27745c9fc8516567bf9bd43965a..1a1e5653f839ac2ddbf4f690958e387aeb873f60 100644 --- a/include/format/BP1Writer.h +++ b/include/format/BP1Writer.h @@ -85,7 +85,6 @@ public: std::vector< std::shared_ptr<Capsule> >& capsules, std::vector<BP1MetadataSet>& metadataSets ) const noexcept; - /** * Returns the estimated variable index size * @param group @@ -367,26 +366,10 @@ private: } else // Stat -> Min, Max for arrays, { + characteristicID = characteristic_stat; if( m_Verbosity == 0 ) //default verbose { - //Get min and max - const std::size_t valuesSize = variable.TotalSize(); - T min, max; - - if( valuesSize >= 10000000 ) //ten million? this needs actual results //here we can make decisions for threads based on valuesSize - GetMinMax( variable.m_AppValues, valuesSize, min, max, m_Cores ); //here we can add cores from constructor - else - GetMinMax( variable.m_AppValues, valuesSize, min, max ); - - //set characteristic ids for min and max - characteristicID = characteristic_stat; - constexpr std::int8_t statisticMinID = statistic_min; - constexpr std::int8_t statisticMaxID = statistic_max; - - WriteStatisticsRecord( statisticMinID, min, metadataBuffers, metadataPositions ); - WriteStatisticsRecord( statisticMaxID, max, metadataBuffers, metadataPositions ); - WriteStatisticsRecord( statisticMinID, min, dataBuffers, dataPositions, true ); //addLength in between - WriteStatisticsRecord( statisticMaxID, max, dataBuffers, dataPositions, true ); //addLength in between + WriteMinMax( variable, dataBuffers, dataPositions, metadataBuffers, metadataPositions ); } } ++characteristicsCounter; @@ -465,7 +448,50 @@ private: const bool addType = false ) const noexcept; /** - * + * Function that writes min and max into data and metadata, called from WriteVariableIndex common. + * Will be specialized for complex types, this is the version for primitive types + * @param variable + * @param dataBuffers + * @param dataPositions + * @param metadataBuffers + * @param metadataPositions + */ + template<class T> inline + void WriteMinMax( const Variable<T>& variable, + std::vector<char*>& dataBuffers, std::vector<size_t>& dataPositions, + std::vector<char*>& metadataBuffers, std::vector<size_t>& metadataPositions ) const noexcept + { + T min, max; + const std::size_t valuesSize = variable.TotalSize(); + if( valuesSize >= 10000000 ) //ten million? this needs actual results //here we can make decisions for threads based on valuesSize + GetMinMax( variable.m_AppValues, valuesSize, min, max, m_Cores ); //here we can add cores from constructor + else + GetMinMax( variable.m_AppValues, valuesSize, min, max ); + + WriteStatisticsMinMax( min, max, dataBuffers, dataPositions, metadataBuffers, metadataPositions ); + } + + + /** + * Common part of WriteMinMax specialized templates. Writes to buffers after min and max are calculated. + */ + template<class T> + void WriteStatisticsMinMax( const T min, const T max, + std::vector<char*>& dataBuffers, std::vector<size_t>& dataPositions, + std::vector<char*>& metadataBuffers, std::vector<size_t>& metadataPositions ) const noexcept + { + constexpr std::int8_t statisticMinID = statistic_min; + constexpr std::int8_t statisticMaxID = statistic_max; + + WriteStatisticsRecord( statisticMinID, min, metadataBuffers, metadataPositions ); + WriteStatisticsRecord( statisticMaxID, max, metadataBuffers, metadataPositions ); + WriteStatisticsRecord( statisticMinID, min, dataBuffers, dataPositions, true ); //addLength in between + WriteStatisticsRecord( statisticMaxID, max, dataBuffers, dataPositions, true ); //addLength in between) + } + + + /** + * Write a statistics record to buffer * @param id * @param value * @param buffers @@ -491,6 +517,7 @@ private: } + /** * * @param capsule @@ -505,6 +532,63 @@ private: +/** + * Specilized version of WriteMinMax for std::complex<float> + * @param variable + * @param dataBuffers + * @param dataPositions + * @param metadataBuffers + * @param metadataPositions + */ +template<> inline +void BP1Writer::WriteMinMax<std::complex<float>>( const Variable<std::complex<float>>& variable, + std::vector<char*>& dataBuffers, std::vector<size_t>& dataPositions, + std::vector<char*>& metadataBuffers, std::vector<size_t>& metadataPositions ) const noexcept +{ + float min, max; + const std::size_t valuesSize = variable.TotalSize(); + if( valuesSize >= 10000000 ) //ten million? this needs actual results //here we can make decisions for threads based on valuesSize + GetMinMax( variable.m_AppValues, valuesSize, min, max, m_Cores ); //here we can add cores from constructor + else + GetMinMax( variable.m_AppValues, valuesSize, min, max ); + + WriteStatisticsMinMax( min, max, dataBuffers, dataPositions, metadataBuffers, metadataPositions ); +} + + +template<> inline +void BP1Writer::WriteMinMax<std::complex<double>>( const Variable<std::complex<double>>& variable, + std::vector<char*>& dataBuffers, std::vector<size_t>& dataPositions, + std::vector<char*>& metadataBuffers, std::vector<size_t>& metadataPositions ) const noexcept +{ + double min, max; + const std::size_t valuesSize = variable.TotalSize(); + if( valuesSize >= 10000000 ) //ten million? this needs actual results //here we can make decisions for threads based on valuesSize + GetMinMax( variable.m_AppValues, valuesSize, min, max, m_Cores ); //here we can add cores from constructor + else + GetMinMax( variable.m_AppValues, valuesSize, min, max ); + + WriteStatisticsMinMax( min, max, dataBuffers, dataPositions, metadataBuffers, metadataPositions ); +} + + +template<> inline +void BP1Writer::WriteMinMax<std::complex<long double>>( const Variable<std::complex<long double>>& variable, + std::vector<char*>& dataBuffers, std::vector<size_t>& dataPositions, + std::vector<char*>& metadataBuffers, std::vector<size_t>& metadataPositions ) const noexcept +{ + long double min, max; + const std::size_t valuesSize = variable.TotalSize(); + if( valuesSize >= 10000000 ) //ten million? this needs actual results //here we can make decisions for threads based on valuesSize + GetMinMax( variable.m_AppValues, valuesSize, min, max, m_Cores ); //here we can add cores from constructor + else + GetMinMax( variable.m_AppValues, valuesSize, min, max ); + + WriteStatisticsMinMax( min, max, dataBuffers, dataPositions, metadataBuffers, metadataPositions ); +} + + + } //end namespace format } //end namespace adios diff --git a/include/functions/adiosTemplates.h b/include/functions/adiosTemplates.h index b13e6fcb51530440b92d5c8cf96e9ccef2a146cf..89036f38bfd53e83cf20022faf9370dbbea1760e 100644 --- a/include/functions/adiosTemplates.h +++ b/include/functions/adiosTemplates.h @@ -14,11 +14,10 @@ #include <thread> #include <set> #include <complex> +#include <cmath> //std::sqrt /// \endcond - - namespace adios { /** @@ -69,27 +68,64 @@ bool IsTypeAlias( const std::string type, /** * Get the minimum and maximum values in one loop - * @param values - * @param size - * @param min - * @param max + * @param values array of primitives + * @param size of the values array + * @param min from values + * @param max from values */ -template<class T> +template<class T> inline void GetMinMax( const T* values, const std::size_t size, T& min, T& max, const unsigned int cores = 1 ) noexcept { min = values[0]; max = values[0]; - for( unsigned int i = 0; i < size; ++i ) + for( std::size_t i = 1; i < size; ++i ) { - if( min < values[0] ) - min = values[0]; - - if( max > values[0] ) - max = values[0]; + if( min < values[i] ) + { + min = values[i]; + continue; + } + + if( max > values[i] ) + max = values[i]; } } +/** + * Overloaded version for complex types, gets the "doughnut" range between min and max modulus + * @param values array of complex numbers + * @param size of the values array + * @param min modulus from values + * @param max modulus from values + * @param cores + */ +template<class T> inline +void GetMinMax( const std::complex<T>* values, const std::size_t size, T& min, T& max, const unsigned int cores = 1 ) noexcept +{ + + min = std::norm( values[0] ); + max = min; + + for( std::size_t i = 1; i < size; ++i ) + { + T norm = std::norm( values[i] ); + + if( min < norm ) + { + min = norm; + continue; + } + + if( max > norm ) + { + max = norm; + } + } + + min = std::sqrt( min ); + max = std::sqrt( max ); +} /** * threaded version of std::memcpy @@ -146,7 +182,7 @@ void MemcpyToBuffers( std::vector<char*>& buffers, std::vector<std::size_t>& pos { char* buffer = buffers[i]; std::memcpy( &buffer[ positions[i] ], source, size ); - //std::copy( source, source+size, &buffers[ positions[i] ] ); + //std::copy( source, source+size, &buffers[ positions[i] ] ); wrong version positions[i] += size; } } diff --git a/include/transport/wan/MdtmMan.h b/include/transport/wan/MdtmMan.h index 6752a58d3f562c302d7f2f00fe83aaa30430b4c9..d0fed7848cdaea502b49fe21953965a8bf71f681 100644 --- a/include/transport/wan/MdtmMan.h +++ b/include/transport/wan/MdtmMan.h @@ -12,6 +12,7 @@ #include "external/json.hpp" #include "core/Transport.h" +#include "DataMan.h" //here comes your DataMan header namespace adios { diff --git a/src/ADIOS.cpp b/src/ADIOS.cpp index a7b36c80ed3baf9c2d73d728c499577e6b4a3615..480645d81fc813faa82b6d699c3fbe6837ce3a8c 100644 --- a/src/ADIOS.cpp +++ b/src/ADIOS.cpp @@ -19,9 +19,11 @@ //Engines #include "engine/bp/BPWriter.h" + +#ifdef HAVE_DATAMAN //external dependencies #include "engine/dataman/DataManWriter.h" #include "engine/dataman/DataManReader.h" - +#endif namespace adios { @@ -107,11 +109,20 @@ std::shared_ptr<Engine> ADIOS::Open( const std::string name, const std::string a } else if( type == "DataManWriter" ) { - return std::make_shared<DataManWriter>( *this, name, accessMode, mpiComm, method, m_DebugMode, cores ); + #ifdef HAVE_DATAMAN + return std::make_shared<DataManWriter>( *this, name, accessMode, mpiComm, method, m_DebugMode, cores ); + #else + throw std::invalid_argument( "ERROR: this version didn't compile with Dataman library, can't Open DataManWriter\n" ); + #endif + } else if( type == "DataManReader" ) { + #ifdef HAVE_DATAMAN return std::make_shared<DataManReader>( *this, name, accessMode, mpiComm, method, m_DebugMode, cores ); + #else + throw std::invalid_argument( "ERROR: this version didn't compile with Dataman library, can't Open DataManReader\n" ); + #endif } else if( type == "Vis" ) { diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index c41544fe2f3ae89857ac0c1bb333e16a8385404d..d9765feac704fa595400e9f87f55211e69aa3861 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -74,6 +74,7 @@ void Engine::Write( const std::string variableName, const std::complex<double>* void Engine::Write( const std::string variableName, const std::complex<long double>* values ){ } void Engine::Write( const std::string variableName, const void* values ){ } +void Engine::AdvanceStep( ){ } //READ Variable<void>* Engine::InquireVariable( const std::string name, const bool readIn ){ return nullptr; } diff --git a/src/engine/bp/BPWriter.cpp b/src/engine/bp/BPWriter.cpp index 9157987336394f953b9c4ca8ccb51b0465cfe39d..01c7b7fadb78efdf29e7edc7f3e9f5f4c3ec8b88 100644 --- a/src/engine/bp/BPWriter.cpp +++ b/src/engine/bp/BPWriter.cpp @@ -56,109 +56,116 @@ void BPWriter::Init( ) void BPWriter::Write( Variable<char>& variable, const char* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<unsigned char>& variable, const unsigned char* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<short>& variable, const short* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<unsigned short>& variable, const unsigned short* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<int>& variable, const int* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<unsigned int>& variable, const unsigned int* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<long int>& variable, const long int* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<unsigned long int>& variable, const unsigned long int* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<long long int>& variable, const long long int* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<unsigned long long int>& variable, const unsigned long long int* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<float>& variable, const float* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<double>& variable, const double* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<long double>& variable, const long double* values ) -{ WriteVariable( variable, values ); } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<std::complex<float>>& variable, const std::complex<float>* values ) -{ } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<std::complex<double>>& variable, const std::complex<double>* values ) -{ } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( Variable<std::complex<long double>>& variable, const std::complex<long double>* values ) -{ } +{ WriteVariableCommon( variable, values ); } void BPWriter::Write( VariableCompound& variable, const void* values ) { } //String version void BPWriter::Write( const std::string variableName, const char* values ) -{ WriteVariable( m_ADIOS.GetVariable<char>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<char>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const unsigned char* values ) -{ WriteVariable( m_ADIOS.GetVariable<unsigned char>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned char>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const short* values ) -{ WriteVariable( m_ADIOS.GetVariable<short>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<short>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const unsigned short* values ) -{ WriteVariable( m_ADIOS.GetVariable<unsigned short>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned short>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const int* values ) -{ WriteVariable( m_ADIOS.GetVariable<int>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<int>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const unsigned int* values ) -{ WriteVariable( m_ADIOS.GetVariable<unsigned int>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned int>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const long int* values ) -{ WriteVariable( m_ADIOS.GetVariable<long int>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<long int>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const unsigned long int* values ) -{ WriteVariable( m_ADIOS.GetVariable<unsigned long int>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned long int>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const long long int* values ) -{ WriteVariable( m_ADIOS.GetVariable<long long int>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<long long int>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const unsigned long long int* values ) -{ WriteVariable( m_ADIOS.GetVariable<unsigned long long int>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<unsigned long long int>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const float* values ) -{ WriteVariable( m_ADIOS.GetVariable<float>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<float>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const double* values ) -{ WriteVariable( m_ADIOS.GetVariable<double>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<double>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const long double* values ) -{ WriteVariable( m_ADIOS.GetVariable<long double>( variableName ), values ); } +{ WriteVariableCommon( m_ADIOS.GetVariable<long double>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const std::complex<float>* values ) -{ } +{ WriteVariableCommon( m_ADIOS.GetVariable<std::complex<float>>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const std::complex<double>* values ) -{ } +{ WriteVariableCommon( m_ADIOS.GetVariable<std::complex<double>>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const std::complex<long double>* values ) -{ } +{ WriteVariableCommon( m_ADIOS.GetVariable<std::complex<long double>>( variableName ), values ); } void BPWriter::Write( const std::string variableName, const void* values ) { } +void BPWriter::AdvanceStep( ) +{ + + + +} + void BPWriter::Close( const int transportIndex ) { @@ -187,6 +194,8 @@ void BPWriter::Close( const int transportIndex ) } + +//PRIVATE FUNCTIONS void BPWriter::InitTransports( ) { if( m_DebugMode == true ) diff --git a/src/engine/dataman/DataManReader.cpp b/src/engine/dataman/DataManReader.cpp index d740001784acc8529ba4f98f158ff66f586fbfa7..ef17b90885d07f03ee808a1f154a6ecfe8f452e9 100644 --- a/src/engine/dataman/DataManReader.cpp +++ b/src/engine/dataman/DataManReader.cpp @@ -17,6 +17,7 @@ #include "transport/file/FStream.h" // uses C++ fstream #include "transport/wan/MdtmMan.h" //uses Mdtm library +#include "DataMan.h" //here comes your DataMan header from external dataman library namespace adios { diff --git a/src/engine/dataman/DataManWriter.cpp b/src/engine/dataman/DataManWriter.cpp index a549f6ae456530366050ec0fa33d109c39d091ff..13d1e41bbff128e567157b0e5c30ebe26b930cd1 100644 --- a/src/engine/dataman/DataManWriter.cpp +++ b/src/engine/dataman/DataManWriter.cpp @@ -19,6 +19,7 @@ #include "transport/wan/MdtmMan.h" //uses Mdtm library + namespace adios { @@ -45,6 +46,15 @@ void DataManWriter::Init( ) ", in call to ADIOS Open or DataManWriter constructor\n" ); } + auto itRealTime = m_Method.m_Parameters.find( "real_time" ); + if( itRealTime != m_Method.m_Parameters.end() ) + { + if( itRealTime->second == "yes" || itRealTime->second == "true" ) + m_DoRealTime = true; + } + + + InitCapsules( ); InitTransports( ); }