diff --git a/examples/dataman/datamanNoXML.cpp b/examples/dataman/datamanNoXML.cpp index 4db4d4bb48aaa5e8a8f72fa1f4fe25534839bfd4..2323b6467149ba64849f4cdaa33320981a7d9d26 100644 --- a/examples/dataman/datamanNoXML.cpp +++ b/examples/dataman/datamanNoXML.cpp @@ -1,17 +1,16 @@ /* - * dataman.cpp: Example for DataMan Transport usage + * datamanNoXML.cpp: Example for DataMan Transport usage also using POSIX as additional transport * * Created on: Nov 15, 2016 * Author: wfg */ - - - #ifdef HAVE_MPI #include <mpi.h> #else #include "public/mpidummy.h" + using adios::MPI_Init; + using adios::MPI_Comm_rank; #endif #include "public/ADIOS.h" @@ -25,46 +24,30 @@ int main( int argc, char* argv [] ) try //need to think carefully how to handle C++ exceptions with MPI to avoid deadlocking { + //APP variables const unsigned int myCharsSize = 10; std::vector<char> myChars( myCharsSize, '1' ); // 10 chars with value '1' - //Equivalent to adios_init debug mode is on, MPI_COMM_WORLD is dummy nothing to worry about + //ADIOS init here, non-XML, debug mode is ON adios::ADIOS adios( MPI_COMM_WORLD, true ); - //Create group TCP and set up, this can be done from XML config file - const std::string group1( "TCP" ); - const std::string group2( "TCP" ); - - - adios.CreateGroup( group ); - adios.CreateVariable( group, "myCharsSize", "unsigned int" ); //scalar : group, name, type - adios.CreateVariable( group, "myChars", "char", "myCharsSize,Ny,Nz", "gNx,gNy,gNz", "oNx,oNy,oNz" ); //group, name, type, integer variable defining size - //adios.SetVariableTransform( group, "myCharsSize", transform ); - //here we tell group to be associate with a DataMan transport - //we can add more parameters if you require - //adios.SetTransport( group, "DataMan" ); - - const std::string streamName( "TCPStream" ); - adios.Open( streamName, "write", "DataMan" ); //here open a stream called TCPStream for writing (w or write) - adios.AddTransport( streamName, "POSIX" ); - - adios.Write( streamName1, "myChars" ); - - //adios.Open( streamName, "read", "DataMan" ); //here open a stream called TCPStream for writing (w or write) - //adios.Write( "TCPStream", group, "myCharsSize", &myCharsSize ); //calls your transport - capsule.SetGroup( group ); - - - adios.Write( streamName2, group1, "myChars" , &myChars[0], transport1, transport2, transport3 ); //calls your transport - adios.Write( "TCPStream", group2, "myChars" , &myChars[0] ); //calls current transport - adios.Close( streamName ); - - adios.Write( streamName, group1, "myChars" , &myChars[0] ); //calls your transport - - adios.Open( group, "G", "write" ); //here open a stream called TCPStream for writing (w or write) - adios.Write( group, "myCharsSize", &myCharsSize ); //calls your transport - adios.Write( group, "myChars" , &myChars[0] ); //calls your transport - adios.Close( "TCPStream" ); + //Create group TCP and define variables + const std::string groupTCP( "TCP" ); + adios.DeclareGroup( groupTCP ); + adios.DefineVariable( groupTCP, "myCharsSize", "unsigned int" ); //scalar : group, name, type + adios.DefineVariable( groupTCP, "myChars", "char", "myCharsSize" ); //group, name, type, integer variables defining dimensions + + //Open stream using two transports, DataMan is default, POSIX is an additional one + const std::string streamTCP( "TCP" ); + adios.Open( streamTCP, "write", "DataMan" ); //here open a stream called TCPStream for writing (w or write), name is the same as stream + adios.AddTransport( streamTCP, "write", "POSIX", "name=TCP.bp" ); //add POSIX transport with .bp name + + //Writing + adios.SetCurrentGroup( streamTCP, groupTCP ); //no need to add group field in Write + adios.Write( streamTCP, "myCharsSize", &myCharsSize ); + adios.Write( streamTCP, "myChars", &myChars ); + //Close + adios.Close( streamTCP ); // Flush to all transports, DataMan and POSIX } catch( std::bad_alloc& e ) { @@ -99,6 +82,7 @@ int main( int argc, char* argv [] ) } } + MPI_Finalize( ); return 0; } diff --git a/include/core/CCapsule.h b/include/core/CCapsule.h index a8c7d2a8b15ed4f96faa9bc55d14c67507406ebe..b71a9e8fc0eb334247f2c88b9287bc1f4d38ccb1 100644 --- a/include/core/CCapsule.h +++ b/include/core/CCapsule.h @@ -95,7 +95,7 @@ public: WriteToBuffer( data, size, transportIndex, m_Transports, m_MaxBufferSize, m_Buffer ); } - void Close( int transportIndex ); ///< Closes current Transport + void Close( int transportIndex ); ///< Closes a particular transport private: diff --git a/include/core/CGroup.h b/include/core/CGroup.h index 6a6d83ec634d8740e188a43aa932a9fdccf8b2db..695f094936ef207c4a9021a7fe64ae637eced84e 100644 --- a/include/core/CGroup.h +++ b/include/core/CGroup.h @@ -27,13 +27,13 @@ #include "core/SVariable.h" #include "core/SAttribute.h" #include "core/CTransport.h" +#include "core/CTransform.h" namespace adios { - /** - * Class that defines each ADIOS Group composed of Variables, Attributes and a Transport method + * Class that defines each ADIOS Group composed of Variables, Attributes and GlobalBounds (if global variables exist) */ class CGroup { @@ -44,17 +44,18 @@ public: * @brief Constructor for XML config file * @param hostLanguage reference from ADIOS class * @param xmlGroup contains <adios-group (tag excluded)....</adios-group> single group definition from XML config file + * @param transforms passed from ADIOS.m_Transforms * @param debugMode from ADIOS */ - CGroup( const std::string& hostLanguage, const std::string& xmlGroup, const bool debugMode ); - + CGroup( const std::string hostLanguage, const std::string& xmlGroup, + std::vector< std::shared_ptr<CTransform> >& transforms, const bool debugMode ); /** * Non-XML empty constructor * @param hostLanguage reference from ADIOS class * @param debugMode */ - CGroup( const std::string& hostLanguage, const bool debugMode ); + CGroup( const std::string hostLanguage, const bool debugMode ); ~CGroup( ); ///< Using STL containers, no deallocation @@ -69,7 +70,8 @@ public: */ void DefineVariable( const std::string variableName, const std::string type, const std::string dimensionsCSV, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ); + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV, + const int transformIndex = -1, const int compressionLevel = 0 ); /** * Sets a variable transform contained in ADIOS.m_Transforms (single container for all groups and variables) @@ -95,15 +97,20 @@ public: */ void Monitor( std::ostream& logStream ) const; + /** + * Looks for variables defining a variable dimensions and return their actual values in a vector + * @param dimensionsCSV comma separated dimensions "Nx,Ny,Nz" + * @return actual vector values = { Nx, Ny, Nz } + */ + std::vector<unsigned long long int> GetDimensions( const std::string dimensionsCSV ) const; - std::vector<unsigned long long int> CGroup::GetDimensions( const std::string dimensionsCSV ) const; unsigned long long int m_SerialSize = 0; ///< size used for potential serialization of metadata into a std::vector<char>. Counts sizes from m_Variables, m_Attributes, m_GlobalBounds private: - const std::string& m_HostLanguage; ///< reference to class ADIOS m_HostLanguage, this erases the copy constructor. Might be moved later to non-reference const + const std::string m_HostLanguage; ///< copy of ADIOS m_HostLanguage const bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code, known at compile time std::map< std::string, std::pair< std::string, unsigned int > > m_Variables; ///< Makes variable name unique, key: variable name, value: pair.first = type, pair.second = index in corresponding vector of CVariable @@ -139,10 +146,7 @@ private: * Called from XML constructor * @param xmlGroup contains <adios-group....</adios-group> single group definition from XML config file passing by reference as it could be big */ - void ParseXMLGroup( const std::string& xmlGroup ); - - - const unsigned int CurrentTypeIndex( const std::string type ) const noexcept; + void ParseXMLGroup( const std::string& xmlGroup, std::vector< std::shared_ptr<CTransform> >& transforms ); /** * Used by SetVariable and SetAttribute to check if global bounds exist in m_GlobalBounds @@ -159,6 +163,13 @@ private: */ const int SetTransforms( const std::string transform ) noexcept; + /** + * Retrieves the value of a variable representing another's variable dimensions. Set with Write + * Must of integer type (from short to unsigned long long int) and positive. + * used by function GetDimensions + * @param variableName variable to be searched in m_SetVariables + * @return variable value + */ const unsigned long long int GetIntVariableValue( const std::string variableName ) const; }; diff --git a/include/core/CTransform.h b/include/core/CTransform.h index fcdef4ce36c520ac84388f31aaa66748251a6031..979e4545bfd39016d5352f67175dc046cdc96c10 100644 --- a/include/core/CTransform.h +++ b/include/core/CTransform.h @@ -41,9 +41,9 @@ public: virtual ~CTransform( ){ }; - void Compress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ); + virtual void Compress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ) = 0; - void DeCompress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ); + virtual void Decompress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ) = 0; }; diff --git a/include/functions/ADIOSFunctions.h b/include/functions/ADIOSFunctions.h index f6bd0e6e3b7fbaf0b1c290a4e17fc8ba737bd60c..ea077e643e68d7e507b32e8a7095beef2ba3c349 100644 --- a/include/functions/ADIOSFunctions.h +++ b/include/functions/ADIOSFunctions.h @@ -46,6 +46,7 @@ void DumpFileToStream( const std::string fileName, std::string& fileContents ); */ void GetSubString ( const std::string initialTag, const std::string finalTag, const std::string content, std::string& subString, std::string::size_type& currentPosition ); + /** * Extracts the value inside quotes in a string currentTag ( Example: currentTag --> field1="value1" field2="value2" ) * @param quote double " or single ' @@ -56,6 +57,7 @@ void GetSubString ( const std::string initialTag, const std::string finalTag, co void GetQuotedValue( const char quote, const std::string::size_type& quotePosition, std::string& currentTag, std::string& value ); + /** * Get attributes field1="value1" field2="value2" by looping through a single XML tag * @param tag field0="value0" field1="value1" in a single string @@ -73,6 +75,7 @@ void GetPairs( const std::string tag, std::vector< std::pair<const std::string, void GetPairsFromTag( const std::string& fileContent, const std::string tag, std::vector< std::pair<const std::string, const std::string> >& pairs ); + /** * Set members m_Groups and m_HostLanguage from XML file content, called within Init functions * @param fileContent file Content in a single string @@ -83,6 +86,7 @@ void GetPairsFromTag( const std::string& fileContent, const std::string tag, void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm, std::string& hostLanguage, std::map< std::string, CGroup >& groups ); + /** * Called inside the ADIOS XML constructors to get contents from file, broadcast and set hostLanguage and groups from ADIOS class * @param xmlConfigFile xml config file name @@ -92,8 +96,9 @@ void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm, std::st * @param groups passed returns the map of groups defined in fileContent * @param debugMode if true will do more checks, exceptions, warnings, expect slower code */ -void InitXML( const std::string xmlConfigFile, const MPI_Comm mpiComm, const bool debugMode, std::string& hostLanguage, - std::map< std::string, CGroup >& groups ); +void InitXML( const std::string xmlConfigFile, const MPI_Comm mpiComm, const bool debugMode, + std::string& hostLanguage, std::map< std::string, CGroup >& groups ); + /** * Loops through a vector containing dimensions and returns the product of all elements @@ -113,17 +118,19 @@ void CreateDirectory( const std::string fullPath ) noexcept; /** - * Identifies a char* variable, assigns a reference to the proper variable, and sends data to capsule so it can write to buffer - * @param group - * @param variableName - * @param values - * @param capsule + * Identifies, verifies the corresponding transform method and adds it the transforms container if neccesary. + * This functions must be updated as new transform methods are supported. + * @param transform method to be added to transforms with format "method:compressionLevel", or "method" with compressionLevel=0 (default) + * @param transforms container of existing transform methods, owned by ADIOS class + * @param debugMode if true will do more checks, exceptions, warnings, expect slower code + * @param transformIndex returns the corresponding transformIndex in transforms for this transport method + * @param compressionLevel returns the corresponding compression level from transport = "method:compressionLevel" */ -void WriteChar( CGroup& group, const std::string variableName, const char* values, CCapsule& capsule ); - - +void SetTransformHelper( const std::string transform, std::vector< std::shared_ptr<CTransform> >& transforms, + const bool debugMode, int& transformIndex, int& compressionLevel ); +bool IsTypeAlias( const std::string type, const std::set<std::string>& types ); diff --git a/include/functions/ADIOSTemplates.h b/include/functions/ADIOSTemplates.h index 25df2c21cc4817e8b08bb7721bf33adbae6ff2fb..858eccd95a82fe884bbf408e1460e566ddcd13fa 100644 --- a/include/functions/ADIOSTemplates.h +++ b/include/functions/ADIOSTemplates.h @@ -25,7 +25,7 @@ namespace adios template<class T> void WriteHelperToCapsule( CCapsule& capsule, CGroup& group, SVariable<T>& variable, const T* values, - const unsigned int cores ) noexcept + const int transportIndex ) noexcept { variable.m_Values = values; auto localDimensions = group.GetDimensions( variable.m_DimensionsCSV ); @@ -38,12 +38,11 @@ void WriteHelperToCapsule( CCapsule& capsule, CGroup& group, SVariable<T>& varia } else //write local variable { - capsule.Write( variable.m_Values, GetTotalSize( localDimensions ), cores ); + capsule.Write( variable.m_Values, GetTotalSize( localDimensions ), transportIndex ); } } - /** * Helper function called from ADIOS Write template function. Checks variable type, adds to group.m_SetVariables, * and calls corresponding Capsule virtual function. @@ -53,10 +52,19 @@ void WriteHelperToCapsule( CCapsule& capsule, CGroup& group, SVariable<T>& varia * @param capsule */ template<class T> -void WriteHelper( CCapsule& capsule, CGroup& group, const std::string variableName, const T* values, const bool debugMode, - const unsigned int cores ) +void WriteHelper( CCapsule& capsule, CGroup& group, const std::string variableName, const T* values, + const int transportIndex, const bool debugMode ) { - //variable + auto lf_DebugType = []( const bool debugMode, const std::string type, const std::set<std::string>& typeAliases ) + { + if( debugMode == true ) + { + if( typeAliases.count( type ) == 0 ) + throw std::invalid_argument( "ERROR: variable " + variableName + " is not of type " + type + + " in call to Write\n" ); + } + }; + const auto itVariable = group.m_Variables.find( variableName ); if( debugMode == true ) @@ -64,57 +72,77 @@ void WriteHelper( CCapsule& capsule, CGroup& group, const std::string variableNa if( itVariable == group.m_Variables.end() ) throw std::invalid_argument( "ERROR: from Write function, variable " + variableName + " doesn't exist\n" ); } + const std::string type( itVariable->first ); const unsigned int index = itVariable->second; group.m_SetVariables.insert( variableName ); //should be done before writing to buffer, in case there is a crash? + //will need to add a lambda function later and put types in a set if( std::is_same<T,char>::value ) { - if( debugMode == true ) - { - if( type != "char" ) - throw std::invalid_argument( "ERROR: variable " + variableName + " is not char\n" ); - } - WriteHelperToCapsule( capsule, group, group.m_Char[index], values, cores ); - } - -// else if( std::is_same<T,unsigned char>::value ) -// group.m_UChar[index].m_Values = values; -// -// else if( std::is_same<T,short>::value ) -// group.m_Short[index].m_Values = values; -// -// else if( std::is_same<T,unsigned short>::value ) -// group.m_UShort[index].m_Values = values; -// -// else if( std::is_same<T,int>::value ) -// group.m_Int[index].m_Values = values; -// -// else if( std::is_same<T,unsigned int>::value ) -// group.m_UInt[index].m_Values = values; -// -// else if( std::is_same<T,long int>::value ) -// group.m_LInt[index].m_Values = values; -// -// else if( std::is_same<T,unsigned long int>::value ) -// group.m_ULInt[index].m_Values = values; -// -// else if( std::is_same<T,long long int>::value ) -// group.m_LLInt[index].m_Values = values; -// -// else if( std::is_same<T,unsigned long long int>::value ) -// group.m_ULLInt[index].m_Values = values; -// -// else if( std::is_same<T,float>::value ) -// group.m_Float[index].m_Values = values; -// -// else if( std::is_same<T,double>::value ) -// group.m_Double[index].m_Values = values; -// -// else if( std::is_same<T,long double>::value ) -// group.m_LDouble[index].m_Values = values; - - + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("char") ); + WriteHelperToCapsule( capsule, group, group.m_Char[index], values, transportIndex ); + } + else if( std::is_same<T,unsigned char>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("unsigned char") ); + WriteHelperToCapsule( capsule, group, group.m_UChar[index], values, transportIndex ); + } + else if( std::is_same<T,short>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("short") ); + WriteHelperToCapsule( capsule, group, group.m_Short[index], values, transportIndex ); + } + else if( std::is_same<T,unsigned short>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("unsigned short") ); + WriteHelperToCapsule( capsule, group, group.m_UShort[index], values, transportIndex ); + } + else if( std::is_same<T,int>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("int") ); + WriteHelperToCapsule( capsule, group, group.m_Int[index], values, transportIndex ); + } + else if( std::is_same<T,unsigned int>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("unsigned int") ); + WriteHelperToCapsule( capsule, group, group.m_UInt[index], values, transportIndex ); + } + else if( std::is_same<T,long int>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("long int") ); + WriteHelperToCapsule( capsule, group, group.m_LInt[index], values, transportIndex ); + } + else if( std::is_same<T,unsigned long int>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("unsigned long int") ); + WriteHelperToCapsule( capsule, group, group.m_ULInt[index], values, transportIndex ); + } + else if( std::is_same<T,long long int>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("long long int") ); + WriteHelperToCapsule( capsule, group, group.m_LLInt[index], values, transportIndex ); + } + else if( std::is_same<T,unsigned long long int>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("unsigned long long int") ); + WriteHelperToCapsule( capsule, group, group.m_ULLInt[index], values, transportIndex ); + } + else if( std::is_same<T,float>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("float") ); + WriteHelperToCapsule( capsule, group, group.m_Float[index], values, transportIndex ); + } + else if( std::is_same<T,double>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("double") ); + WriteHelperToCapsule( capsule, group, group.m_Double[index], values, transportIndex ); + } + else if( std::is_same<T,long double>::value ) + { + lf_DebugType( debugMode, type, SSupport::DatatypesAliases.at("long double") ); + WriteHelperToCapsule( capsule, group, group.m_LDouble[index], values, transportIndex ); + } } diff --git a/include/public/ADIOS.h b/include/public/ADIOS.h index 3fa2eaafc8c0391fa05d1e3f30e1857766726198..35fc2dabffb21e369d9e0a12c49b3dbb6d44cfbb 100644 --- a/include/public/ADIOS.h +++ b/include/public/ADIOS.h @@ -101,7 +101,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO * Sets a new transport method to be associated with a current stream. * @param streamName must be created with Open * @param transport - * @return + * @return transport index */ template< class... Args > int AddTransport( const std::string streamName, const std::string accessMode, const std::string transport, Args... args ) @@ -132,7 +132,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO template<class T> void Write( const std::string streamName, const std::string groupName, const std::string variableName, const T* values, - const int transportIndex ) + const int transportIndex = -1 ) { auto itCapsule = m_Capsules.find( streamName ); auto itGroup = m_Groups.find( groupName ); @@ -141,9 +141,12 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO { CheckCapsule( itCapsule, streamName, " from call to Write variable " + variableName ); CheckGroup( itGroup, groupName, " from call to Write variable " + variableName ); + if( transportIndex < -1 ) + throw std::invalid_argument( "ERROR: transport index " + std::to_string( transportIndex ) + + " must be >= -1, in call to Write\n" ); } - WriteHelper( itCapsule->second, itGroup->second, variableName, values, m_DebugMode ); + WriteHelper( itCapsule->second, itGroup->second, variableName, values, transportIndex, m_DebugMode ); } @@ -157,7 +160,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO */ template<class T> void Write( const std::string streamName, const std::string variableName, const T* values, - const int transportIndex ) + const int transportIndex = -1 ) { auto itCapsule = m_Capsules.find( streamName ); if( m_DebugMode == true ) @@ -168,7 +171,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO if( m_DebugMode == true ) CheckGroup( itGroup, groupName, " from call to Write variable " + variableName ); - WriteHelper( itCapsule->second, itGroup->second, variableName, values, m_DebugMode ); + WriteHelper( itCapsule->second, itGroup->second, variableName, values, transportIndex, m_DebugMode ); } /** diff --git a/include/public/SSupport.h b/include/public/SSupport.h index 6584f145ed557701a9e7da3df324f64956df7833..9b90c520fdbdeee8657592ce4f249ace42355ade 100644 --- a/include/public/SSupport.h +++ b/include/public/SSupport.h @@ -25,6 +25,7 @@ struct SSupport static const std::set<std::string> Transports; ///< supported transport methods static const std::set<std::string> Transforms; ///< supported data transform methods static const std::map<std::string, std::set<std::string> > Datatypes; ///< supported data types + static const std::map<std::string, std::set<std::string> > DatatypesAliases; }; diff --git a/include/transform/CBZIP2.h b/include/transform/CBZIP2.h index f71dc8240d354dbcb381471051737a448116e03b..4fac24a2551f3272388f2317fbaf3098a8ccc767 100644 --- a/include/transform/CBZIP2.h +++ b/include/transform/CBZIP2.h @@ -9,9 +9,6 @@ #define CBZIP2_H_ -#include <bzip2.h> //bzip2 library header - - #include "core/CTransform.h" @@ -33,33 +30,9 @@ public: ~CBZIP2( ); - void Compress( const SVariable<char>& variableIn, SVariable<char>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<unsigned char>& variableIn, SVariable<unsigned char>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<short>& variableIn, SVariable<short>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<unsigned short>& variableIn, SVariable<unsigned short>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<int>& variableIn, SVariable<int>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<unsigned int>& variableIn, SVariable<unsigned int>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<long int>& variableIn, SVariable<long int>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<unsigned long int>& variableIn, SVariable<unsigned long int>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<long long int>& variableIn, SVariable<long long int>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<unsigned long long int>& variableIn, SVariable<unsigned long long int>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<float>& variableIn, SVariable<float>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<double>& variableIn, SVariable<double>& variableOut, const unsigned int level ) const; - void Compress( const SVariable<long double>& variableIn, SVariable<long double>& variableOut, const unsigned int level ) const; - - void Decompress( const SVariable<char>& variableIn, SVariable<char>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<unsigned char>& variableIn, SVariable<unsigned char>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<short>& variableIn, SVariable<short>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<unsigned short>& variableIn, SVariable<unsigned short>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<int>& variableIn, SVariable<int>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<unsigned int>& variableIn, SVariable<unsigned int>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<long int>& variableIn, SVariable<long int>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<unsigned long int>& variableIn, SVariable<unsigned long int>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<long long int>& variableIn, SVariable<long long int>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<unsigned long long int>& variableIn, SVariable<unsigned long long int>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<float>& variableIn, SVariable<float>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<double>& variableIn, SVariable<double>& variableOut, const unsigned int level ) const; - void Decompress( const SVariable<long double>& variableIn, SVariable<long double>& variableOut, const unsigned int level ) const; + void Compress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ); + + void Decompress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ); }; diff --git a/src/core/CGroup.cpp b/src/core/CGroup.cpp index 015271e483e99e5bb2555198a26e6ee604b086b0..f9485989bc73d2e2686f46c0f78deab640945835 100644 --- a/src/core/CGroup.cpp +++ b/src/core/CGroup.cpp @@ -20,17 +20,18 @@ namespace adios { -CGroup::CGroup( const std::string& hostLanguage, const bool debugMode ): +CGroup::CGroup( const std::string hostLanguage, const bool debugMode ): m_HostLanguage{ hostLanguage }, m_DebugMode{ debugMode } { } -CGroup::CGroup( const std::string& hostLanguage, const std::string& xmlGroup, const bool debugMode ): +CGroup::CGroup( const std::string hostLanguage, const std::string& xmlGroup, + std::vector< std::shared_ptr<CTransform> >& transforms, const bool debugMode ): m_HostLanguage{ hostLanguage }, m_DebugMode{ debugMode } { - ParseXMLGroup( xmlGroup ); + ParseXMLGroup( xmlGroup, transforms ); } @@ -40,62 +41,86 @@ CGroup::~CGroup( ) void CGroup::DefineVariable( const std::string variableName, const std::string type, const std::string dimensionsCSV, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV, + const int transformIndex, const int compressionLevel ) { if( m_DebugMode == true ) { if( SSupport::Datatypes.at( m_HostLanguage ).count( type ) == 0 ) - throw std::invalid_argument( "ERROR: type " + type + " for variable " + variableName + " is not supported.\n" ); - if( m_Variables.count( variableName ) == 0 ) //variable doesn't exists - m_Variables[variableName] = std::make_pair( type, CurrentTypeIndex( type ) ); - else //name is found - throw std::invalid_argument( "ERROR: variable " + variableName + " exists more than once.\n" ); - } - else - { - m_Variables[variableName] = std::make_pair( type, CurrentTypeIndex( type ) ); + throw std::invalid_argument( "ERROR: type " + type + " for variable " + variableName + + " is not supported, in call to DefineVariable\n" ); + + if( m_Variables.count( variableName ) == 1 ) + throw std::invalid_argument( "ERROR: variable " + variableName + " already exists, in call to DefineVariable\n" ); } int globalBoundsIndex = SetGlobalBounds( globalDimensionsCSV, globalOffsetsCSV ); - if( type == "char" || type == "character" ) - m_Char.push_back( SVariable<char>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "unsigned char" ) - m_UChar.push_back( SVariable<unsigned char>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "short" || type == "integer*2" ) - m_Short.push_back( SVariable<short>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "unsigned short" ) - m_UShort.push_back( SVariable<unsigned short>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "int" || type == "integer" ) - m_Int.push_back( SVariable<int>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "unsigned int" || type == "unsigned integer" ) - m_UInt.push_back( SVariable<unsigned int>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "long int" || type == "long" || type == "long integer" ) - m_LInt.push_back( SVariable<long int>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "unsigned long int" || type == "unsigned long" || type == "unsigned long integer" ) - m_ULInt.push_back( SVariable<unsigned long int>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "long long int" || type == "long long" || type == "long long integer" ) - m_LLInt.push_back( SVariable<long long int>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "unsigned long long int" || type == "unsigned long long" || type == "unsigned long long integer" ) - m_ULLInt.push_back( SVariable<unsigned long long int>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "float" || type == "real" || type == "real*4" ) - m_Float.push_back( SVariable<float>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "double" || type == "double precision" || type == "real*8" ) - m_Double.push_back( SVariable<double>{ dimensionsCSV, nullptr, globalBoundsIndex } ); - - else if( type == "long double" || type == "real*16" ) - m_LDouble.push_back( SVariable<long double>{ dimensionsCSV, nullptr, globalBoundsIndex } ); + if( IsTypeAlias( type, SSupport::DatatypesAliases.at("char") ) == true ) + { + m_Char.push_back( SVariable<char>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_Char.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned char") ) == true ) + { + m_UChar.push_back( SVariable<unsigned char>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_UChar.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("short") ) == true ) + { + m_Short.push_back( SVariable<short>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_Short.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned short") ) == true ) + { + m_UShort.push_back( SVariable<unsigned short>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_UShort.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("int") ) == true ) + { + m_Int.push_back( SVariable<int>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_Int.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned int") ) == true ) + { + m_UInt.push_back( SVariable<unsigned int>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_UInt.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("long int") ) == true ) + { + m_LInt.push_back( SVariable<long int>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_LInt.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned long int") ) == true ) + { + m_ULInt.push_back( SVariable<unsigned long int>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_ULInt.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("long long int") ) == true ) + { + m_LLInt.push_back( SVariable<long long int>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_LLInt.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned long long int") ) == true ) + { + m_ULLInt.push_back( SVariable<unsigned long long int>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_ULLInt.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("float") ) == true ) + { + m_Float.push_back( SVariable<float>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_Float.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("double") ) == true ) + { + m_Double.push_back( SVariable<double>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_Double.size()-1 ); + } + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("long double") ) == true ) + { + m_LDouble.push_back( SVariable<long double>{ dimensionsCSV, nullptr, globalBoundsIndex, transformIndex, compressionLevel } ); + m_Variables[variableName] = std::make_pair( type, m_LDouble.size()-1 ); + } m_SerialSize += variableName.size() + type.size() + dimensionsCSV.size() + 4 * sizeof( char ); //4, adding one more for globalBoundsIndex } @@ -114,67 +139,62 @@ void CGroup::SetTransform( const std::string variableName, const unsigned int tr const std::string type( itVariable->second.first ); const unsigned int index = itVariable->second.second; - if( type == "char" || type == "character" ) + if( IsTypeAlias( type, SSupport::DatatypesAliases.at("char") ) == true ) { m_Char[index].TransformIndex = transformIndex; m_Char[index].CompressionLevel = compressionLevel; } - else if( type == "unsigned char" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned char") ) == true ) { m_UChar[index].TransformIndex = transformIndex; m_UChar[index].CompressionLevel = compressionLevel; } - else if( type == "short" || type == "integer*2" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("short") ) == true ) { m_Short[index].TransformIndex = transformIndex; m_Short[index].CompressionLevel = compressionLevel; } - else if( type == "unsigned short" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned short") ) == true ) { m_UShort[index].TransformIndex = transformIndex; m_UShort[index].CompressionLevel = compressionLevel; } - else if( type == "int" || type == "integer" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("int") ) == true ) { m_Int[index].TransformIndex = transformIndex; m_Int[index].CompressionLevel = compressionLevel; } - else if( type == "unsigned int" || type == "unsigned integer" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned int") ) == true ) { m_UInt[index].TransformIndex = transformIndex; m_UInt[index].CompressionLevel = compressionLevel; } - else if( type == "long int" || type == "long" || type == "long integer" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("long int") ) == true ) { m_LInt[index].TransformIndex = transformIndex; m_LInt[index].CompressionLevel = compressionLevel; } - else if( type == "unsigned long int" || type == "unsigned long" || type == "unsigned long integer" ) - { - m_ULInt[index].TransformIndex = transformIndex; - m_ULInt[index].CompressionLevel = compressionLevel; - } - else if( type == "long long int" || type == "long long" || type == "long long integer" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned long int") ) == true ) { m_ULInt[index].TransformIndex = transformIndex; m_ULInt[index].CompressionLevel = compressionLevel; } - else if( type == "unsigned long long int" || type == "unsigned long long" || type == "unsigned long long integer" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned long long int") ) == true ) { m_ULLInt[index].TransformIndex = transformIndex; m_ULLInt[index].CompressionLevel = compressionLevel; } - else if( type == "float" || type == "real" || type == "real*4" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("float") ) == true ) { m_Float[index].TransformIndex = transformIndex; m_Float[index].CompressionLevel = compressionLevel; } - else if( type == "double" || type == "double precision" || type == "real*8" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("double") ) == true ) { m_Double[index].TransformIndex = transformIndex; m_Double[index].CompressionLevel = compressionLevel; } - else if( type == "long double" || type == "real*16" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("long double") ) == true ) { m_LDouble[index].TransformIndex = transformIndex; m_LDouble[index].CompressionLevel = compressionLevel; @@ -210,34 +230,40 @@ const unsigned long long int CGroup::GetIntVariableValue( const std::string vari const std::string type( m_Variables.at( variableName ).first ); const unsigned int index = m_Variables.at( variableName ).second; - const unsigned long long int value = 0; + const long long int value = -1; - if( type == "short" ) + if( IsTypeAlias( type, SSupport::DatatypesAliases.at("short") ) == true ) value = *( m_Short[index].Values ); - else if( type == "unsigned short" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned short") ) == true ) value = *( m_UShort[index].Values ); - else if( type == "int" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("int") ) == true ) value = *( m_Int[index].Values ); - else if( type == "unsigned int" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned int") ) == true ) value = *( m_UInt[index].Values ); - else if( type == "long int" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("long int") ) == true ) value = *( m_LInt[index].Values ); - else if( type == "unsigned long int" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned long int") ) == true ) value = *( m_ULInt[index].Values ); - else if( type == "long long int" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("long long int") ) == true ) value = *( m_LLInt[index].Values ); - else if( type == "unsigned long long int" ) + else if( IsTypeAlias( type, SSupport::DatatypesAliases.at("unsigned long long int") ) == true ) value = *( m_ULLInt[index].Values ); else - throw std::invalid_argument( "ERROR: variable " + variableName + " must be of short, int or associated type (long int, unsigned long int, etc.)\n" ); + throw std::invalid_argument( "ERROR: variable " + variableName + " must be of integer type : short, int or associated type (long int, unsigned long int, etc.)\n" ); + + if( m_DebugMode == true ) + { + if( value <= 0 ) + throw std::invalid_argument( "ERROR: variable " + variableName + " must be >= 0 to represent a dimension\n" ); + } return value; } @@ -256,7 +282,7 @@ std::vector<unsigned long long int> CGroup::GetDimensions( const std::string dim std::istringstream dimensionsSS( dimensionsCSV ); std::string dimension; - while( std::getline( dimensionsSS, dimension, ',' ) ) + while( std::getline( dimensionsSS, dimension, ',' ) ) //need to test { dimensions.push_back( GetIntVariableValue( dimension ) ); } @@ -284,7 +310,7 @@ void CGroup::Monitor( std::ostream& logStream ) const } -void CGroup::ParseXMLGroup( const std::string& xmlGroup ) +void CGroup::ParseXMLGroup( const std::string& xmlGroup, std::vector< std::shared_ptr<CTransform> >& transforms ) { std::string::size_type currentPosition( 0 ); std::string globalDimensionsCSV; //used to set variables @@ -328,7 +354,14 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) else if( pair.first == "dimensions" ) dimensionsCSV = pair.second; else if( pair.first == "transform" ) transform = pair.second; } - DefineVariable( name, type, dimensionsCSV, globalDimensionsCSV, globalOffsetsCSV ); + + int transformIndex = -1; + int compressionLevel = 0; + + if( transform.empty() == false ) //if transform is present + SetTransformHelper( transform, transforms, m_DebugMode, transformIndex, compressionLevel ); + + DefineVariable( name, type, dimensionsCSV, globalDimensionsCSV, globalOffsetsCSV, transformIndex, compressionLevel ); } else if( tagName == "attribute" ) { @@ -364,53 +397,6 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) } -const unsigned int CGroup::CurrentTypeIndex( const std::string type ) const noexcept -{ - unsigned int index; - - if( type == "char" || type == "character" ) - index = m_Char.size(); - - else if( type == "unsigned char" ) - index = m_UChar.size(); - - else if( type == "short" || type == "integer*2" ) - index = m_Short.size(); - - else if( type == "unsigned short" ) - index = m_UShort.size(); - - else if( type == "int" || type == "integer" ) - index = m_Int.size(); - - else if( type == "unsigned int" || type == "unsigned integer" ) - index = m_UInt.size(); - - else if( type == "long int" || type == "long" || type == "long integer" ) - index = m_LInt.size(); - - else if( type == "unsigned long int" || type == "unsigned long" || type == "unsigned long integer" ) - index = m_ULInt.size(); - - else if( type == "long long int" || type == "long long" || type == "long long integer" ) - index = m_LLInt.size(); - - else if( type == "unsigned long long int" || type == "unsigned long long" || type == "unsigned long long integer" ) - index = m_ULLInt.size(); - - else if( type == "float" || type == "real" || type == "real*4" ) - index = m_Float.size(); - - else if( type == "double" || type == "double precision" || type == "real*8" ) - index = m_Double.size(); - - else if( type == "long double" || type == "real*16" ) - index = m_LDouble.size(); - - return index; -} - - const int CGroup::SetGlobalBounds( const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) noexcept { if( globalDimensionsCSV.empty() || globalOffsetsCSV.empty() ) diff --git a/src/functions/ADIOSFunctions.cpp b/src/functions/ADIOSFunctions.cpp index 8c059b2b4077727139a01801abea5a8a4c767704..8f8fef3ac757e3e7f6517796311f1f5eda05144d 100644 --- a/src/functions/ADIOSFunctions.cpp +++ b/src/functions/ADIOSFunctions.cpp @@ -284,6 +284,7 @@ void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm, const b } }; + //this section will have to change, doing nothing for now currentPosition = 0; while( currentPosition != std::string::npos ) { @@ -312,8 +313,6 @@ void SetMembers( const std::string& fileContent, const MPI_Comm mpiComm, const b int priority, iteration; lf_UIntCheck( method, priorityStr, "priority", debugMode, priority ); lf_UIntCheck( method, iterationStr, "iteration", debugMode, iteration ); - - itGroup->second.m_Transport = method; //here do something with the capsule } } @@ -396,59 +395,54 @@ void CreateDirectory( const std::string fullPath ) noexcept } - -//Write helper functions -void WriteChar( CGroup& group, const std::string variableName, const char* values, CCapsule& capsule, const unsigned int cores ) +void SetTransformHelper( const std::string transform, std::vector< std::shared_ptr<CTransform> >& transforms, + const bool debugMode, int& transformIndex, int& compressionLevel ) { - if( group.m_DebugMode == true ) + //get method:compressionLevel from transform + std::string method( transform ); //default + compressionLevel = 0; //default + + auto colonPosition = transform.find( ":" ); + + if( colonPosition != transform.npos ) { - const std::string type( group.m_Variables.at( variableName ).first ); - if( type != "char" ) - throw std::invalid_argument( "ERROR: variable " + variableName + " is not char\n" ); - } + if( debugMode == true ) + { + if( colonPosition == transform.size() - 1 ) + throw std::invalid_argument( "ERROR: wrong format for transform " + transform + ", in call to SetTransform\n" ); + } - const unsigned int index = group.m_Variables.at( variableName ).second; - SVariable<char>& variable = group.m_Char[index]; - variable.m_Values = values; - auto localDimensions = group.GetDimensions( variable.m_DimensionsCSV ); + method = transform.substr( 0, colonPosition ); + compressionLevel = std::stoi( transform.substr( colonPosition+1 ) ); //need to test + } - if( variable.m_GlobalBoundsIndex > -1 ) //global variable + transformIndex = -1; + for( unsigned int i = 0; i < transforms.size(); ++i ) { - auto globalDimensions = group.GetDimensions( group.m_GlobalBounds[ variable.m_GlobalBoundsIndex ].first ); - auto globalOffsets = group.GetDimensions( group.m_GlobalBounds[ variable.m_GlobalBoundsIndex ].second ); - //capsule.Write( group.m_StreamName, variable.m_Values, sizeof(char), localDimensions, globalDimensions, globalOffsets ); + if( transforms[i]->m_Method == transform ) + { + transformIndex = i; + break; + } } - else //write local variable + + if( transformIndex == -1 ) //not found, then create a new transform { - capsule.Write( group.m_StreamName, variable.m_Values, GetTotalSize( localDimensions ), cores ); + if( transform == "bzip2" ) + transforms.push_back( std::make_shared<CBZIP2>( ) ); } + + transformIndex = static_cast<int>( transforms.size() - 1 ); } -void WriteUChar( CGroup& group, const std::string variableName, const char* values, CCapsule& capsule, const unsigned int cores ) +bool IsTypeAlias( const std::string type, const std::set<std::string>& types ) { - if( group.m_DebugMode == true ) - { - const std::string type( group.m_Variables.at( variableName ).first ); - if( type != "unsigned char" ) - throw std::invalid_argument( "ERROR: variable " + variableName + " is not char\n" ); - } + bool isAlias = false; + if( types.count( type ) == 1 ) + isAlias = true; - const unsigned int index = group.m_Variables.at( variableName ).second; - SVariable<unsigned char>& variable = group.m_UChar[index]; - variable.m_Values = values; - auto localDimensions = group.GetDimensions( variable.m_DimensionsCSV ); - - if( variable.m_GlobalBoundsIndex > -1 ) //global variable - { - auto globalDimensions = group.GetDimensions( group.m_GlobalBounds[ variable.m_GlobalBoundsIndex ].first ); - auto globalOffsets = group.GetDimensions( group.m_GlobalBounds[ variable.m_GlobalBoundsIndex ].second ); - //capsule.Write( group.m_StreamName, variable.m_Values, sizeof(char), localDimensions, globalDimensions, globalOffsets ); - } - else //write local variable - { - capsule.Write( group.m_StreamName, variable.m_Values, GetTotalSize( localDimensions ), cores ); - } + return isAlias; } diff --git a/src/public/ADIOS.cpp b/src/public/ADIOS.cpp index 961d1d8e213ef8587cd27b0e7efde3a1b1faa790..bb8027c5b1ebf83151e9ddc8805e8c24ef29f21d 100644 --- a/src/public/ADIOS.cpp +++ b/src/public/ADIOS.cpp @@ -122,52 +122,18 @@ void ADIOS::SetTransform( const std::string groupName, const std::string variabl CheckGroup( itGroup, groupName, " from call to SetTransform \n" ); if( SSupport::Transforms.count( transform ) == 0 ) - throw std::invalid_argument( "ERROR: transform method " + transform + " not supported, in call to SetTransform\n" ); - } - - //get method:compressionLevel from transform - std::string method( transform ); - int compressionLevel = 0; - - auto colonPosition = transform.find( ":" ); - - if( colonPosition != transform.npos ) - { - if( m_DebugMode == true ) - { - if( colonPosition == transform.size() - 1 ) - throw std::invalid_argument( "ERROR: wrong format for transform " + transform + ", in call to SetTransform\n" ); - } - - method = transform.substr( 0, colonPosition ); - compressionLevel = std::stoi( transform.substr( colonPosition+1 ) ); - } - - int transformIndex = -1; - for( unsigned int i = 0; i < m_Transforms.size(); ++i ) - { - if( m_Transforms[i]->m_Method == transform ) - { - transformIndex = i; - break; - } - } - - if( transformIndex == -1 ) //not found, then create a new transform - { - if( transform == "bzip2" ) - { - m_Transforms.push_back( std::make_shared<CBZIP2>( ) ); - } + throw std::invalid_argument( "ERROR: transform method " + transform + + " not supported, in call to SetTransform\n" ); } + int transformIndex, compressionLevel; + //set m_Transforms, transformIndex, compressionLevel + SetTransformHelper( transform, m_Transforms, m_DebugMode, transformIndex, compressionLevel ); + //set Variable with transformIndex, compressionLevel itGroup->second.SetTransform( variableName, transformIndex, compressionLevel ); } - - - void ADIOS::DefineAttribute( const std::string groupName, const std::string attributeName, const std::string type, const std::string value ) diff --git a/src/public/SSupport.cpp b/src/public/SSupport.cpp index b0a2d38084a14dab88f4cc032d35138df8e41097..893e28fc519ada6be0a9beff44b64bb8e69a8dd5 100644 --- a/src/public/SSupport.cpp +++ b/src/public/SSupport.cpp @@ -85,6 +85,23 @@ const std::map<std::string, std::set<std::string> > SSupport::Datatypes }; +const std::map<std::string, std::set<std::string> > SSupport::DatatypesAliases +{ + { "char", { "char", "character" } }, + { "unsigned char", { "unsigned char", "unsigned character" } }, + { "short", { "short", "integer*2" } }, + { "unsigned short", { "unsigned short" } }, + { "int", { "int", "integer" } }, + { "unsigned int", { "unsigned int", "unsigned integer" } }, + { "long int", { "long int", "long", "long integer" } }, + { "unsigned long int", { "unsigned long int", "unsigned long", "unsigned long integer" } }, + { "long long int", { "long long int", "long long", "long long integer" } }, + { "unsigned long long int", { "unsigned long long int", "unsigned long long", "unsigned long long integer" } }, + { "float", { "float", "real", "real*4" } }, + { "double", { "double", "double precision", "real*8" } }, + { "long double", { "long double", "long double precision", "real*16" } } +}; + } //end namespace diff --git a/src/transform/CBZIP2.cpp b/src/transform/CBZIP2.cpp index 4678fb0a33c3fb74ef95400fd1afffd2e94d5494..23d32c495fcb2a5a333dd24c93ba6c35d7405965 100644 --- a/src/transform/CBZIP2.cpp +++ b/src/transform/CBZIP2.cpp @@ -15,7 +15,8 @@ namespace adios { -CBZIP2::CBZIP2( ) +CBZIP2::CBZIP2( ): + CTransform( "bzip2" ) { } @@ -23,108 +24,18 @@ CBZIP2::~CBZIP2( ) { } -void CBZIP2::Compress( const SVariable<char>& variableIn, SVariable<char>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<unsigned char>& variableIn, SVariable<unsigned char>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<short>& variableIn, SVariable<short>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<unsigned short>& variableIn, SVariable<unsigned short>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<int>& variableIn, SVariable<int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<unsigned int>& variableIn, SVariable<unsigned int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<long int>& variableIn, SVariable<long int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<unsigned long int>& variableIn, SVariable<unsigned long int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<long long int>& variableIn, SVariable<long long int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<unsigned long long int>& variableIn, SVariable<unsigned long long int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<float>& variableIn, SVariable<float>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<double>& variableIn, SVariable<double>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Compress( const SVariable<long double>& variableIn, SVariable<long double>& variableOut, const unsigned int level ) const -{ } - -//DECOMPRESS -void CBZIP2::Decompress( const SVariable<char>& variableIn, SVariable<char>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Decompress( const SVariable<unsigned char>& variableIn, SVariable<unsigned char>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Decompress( const SVariable<short>& variableIn, SVariable<short>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Decompress( const SVariable<unsigned short>& variableIn, SVariable<unsigned short>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Decompress( const SVariable<int>& variableIn, SVariable<int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Decompress( const SVariable<unsigned int>& variableIn, SVariable<unsigned int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Decompress( const SVariable<long int>& variableIn, SVariable<long int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Decompress( const SVariable<unsigned long int>& variableIn, SVariable<unsigned long int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Decompress( const SVariable<long long int>& variableIn, SVariable<long long int>& variableOut, const unsigned int level ) const -{ } - - -void CBZIP2::Decompress( const SVariable<unsigned long long int>& variableIn, SVariable<unsigned long long int>& variableOut, const unsigned int level ) const -{ } +void CBZIP2::Compress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ) +{ -void CBZIP2::Decompress( const SVariable<float>& variableIn, SVariable<float>& variableOut, const unsigned int level ) const -{ } +} -void CBZIP2::Decompress( const SVariable<double>& variableIn, SVariable<double>& variableOut, const unsigned int level ) const -{ } +void CBZIP2::Decompress( const std::vector<char>& bufferIn, std::vector<char>& bufferOut ) +{ +} -void CBZIP2::Decompress( const SVariable<long double>& variableIn, SVariable<long double>& variableOut, const unsigned int level ) const -{ } } //end namespace