From efe367ed9db533d8a7d28fd099ac7b7d4d687618 Mon Sep 17 00:00:00 2001 From: wfg <wfg@pc0098504.ornl.gov> Date: Mon, 7 Nov 2016 17:19:16 -0500 Subject: [PATCH] Added Write template function and started working on CCapsule class 1) Moved write out of transport 2) Moved transport and transform members into CCapsule 3) Completely rearranged CGroup to move functionality to CCapsule To do: Test template implementation. --- include/core/CCapsule.h | 70 ++++++++++ include/core/CGroup.h | 107 +++++++------- include/core/CTransform.h | 9 +- include/core/CTransport.h | 6 - include/core/CVariable.h | 55 -------- include/core/SVariable.h | 40 ++++++ include/functions/ADIOSTemplates.h | 107 ++++++++++++++ include/functions/GroupFunctions.h | 70 ---------- include/public/ADIOS.h | 21 ++- include/transport/CDIMES.h | 1 - include/transport/CDataspaces.h | 1 - include/transport/CFStream.h | 2 - include/transport/CFlexpath.h | 1 - include/transport/CICEE.h | 2 - include/transport/CMPI.h | 1 - include/transport/CMPIAggregate.h | 1 - include/transport/CMPILustre.h | 1 - include/transport/CNetCDF4.h | 2 - include/transport/CPHDF5.h | 1 - include/transport/CPOSIX.h | 2 - include/transport/CVarMerge.h | 2 - src/core/CCapsule.cpp | 22 +++ src/core/CGroup.cpp | 214 ++++++++++++++++++++-------- src/core/CVariable.cpp | 33 ----- src/functions/GroupFunctions.cpp | 215 ----------------------------- src/public/ADIOS.cpp | 19 +-- src/public/SSupport.cpp | 2 - src/transport/CFStream.cpp | 4 +- 28 files changed, 476 insertions(+), 535 deletions(-) create mode 100644 include/core/CCapsule.h delete mode 100644 include/core/CVariable.h create mode 100644 include/core/SVariable.h create mode 100644 include/functions/ADIOSTemplates.h delete mode 100644 include/functions/GroupFunctions.h create mode 100644 src/core/CCapsule.cpp delete mode 100644 src/core/CVariable.cpp delete mode 100644 src/functions/GroupFunctions.cpp diff --git a/include/core/CCapsule.h b/include/core/CCapsule.h new file mode 100644 index 000000000..b5673c337 --- /dev/null +++ b/include/core/CCapsule.h @@ -0,0 +1,70 @@ +/* + * CCapsule.h + * + * Created on: Nov 7, 2016 + * Author: wfg + */ + +#ifndef CCAPSULE_H_ +#define CCAPSULE_H_ + +#include <vector> + +#ifdef HAVE_MPI + #include <mpi.h> +#else + #include "public/mpidummy.h" +#endif + +#include "core/CGroup.h" +#include "core/SVariable.h" +#include "core/CTransform.h" +#include "core/CTransport.h" + + +namespace adios +{ + +class CCapsule +{ + +public: + + #ifdef HAVE_MPI + MPI_Comm m_MPIComm = NULL; ///< only used as reference to MPI communicator passed from parallel constructor, MPI_Comm is a pointer itself. Public as called from C + #else + MPI_Comm m_MPIComm = 0; ///< only used as reference to MPI communicator passed from parallel constructor, MPI_Comm is a pointer itself. Public as called from C + #endif + + + std::vector<char> m_Buffer; ///< buffer to be managed, just one type for now + std::map< std::string, std::shared_ptr<CTransform> > m_Transforms; ///< transforms associated with ADIOS run + std::map< std::string, std::shared_ptr<CTransport> > m_Transports; ///< transports associated with ADIOS run + + + CCapsule( ); ///< default empty constructor + + ~CCapsule( ); + + /** + * This will add to the m_Transports and m_Transforms map + * @param group + */ + void OpenGroupBuffer( const CGroup& group ); + + + template< class T> + void WriteVariableToBuffer( const CGroup& group, const SVariable<T>& variable ); + + /** + * Closes the buffer and moves it into the + * @param group + */ + void CloseGroupBuffer( const CGroup& group ); + +}; + + +} //end namespace + +#endif /* CCAPSULE_H_ */ diff --git a/include/core/CGroup.h b/include/core/CGroup.h index 4cb83d8a3..c94f99c15 100644 --- a/include/core/CGroup.h +++ b/include/core/CGroup.h @@ -23,7 +23,7 @@ #endif -#include "core/CVariable.h" +#include <core/SVariable.h> #include "core/SAttribute.h" #include "core/CTransport.h" @@ -62,28 +62,15 @@ public: ~CGroup( ); ///< Using STL containers, no deallocation /** - * Opens group and passes fileName and accessMode to m_Transport - * @param fileName - * @param accessMode + * Called from ADIOS open, sets group as active and passes associated bufferName and accessMode + * @param bufferName associated buffer for this group + * @param accessMode associated access mode (read, write, append) for bufferName */ - void Open( const std::string fileName, const std::string accessMode = "w" ); + void Open( const std::string bufferName, const std::string accessMode ); /** - * Passes variableName and values to m_Transport - * @param variableName - * @param values - */ - void Write( const std::string variableName, const void* values ); - - /** - * Must think what to do with Capsule and Transport - */ - void Close( ); - - - /** - * Sets a new variable in the group object + * Creates a new variable in the group object * @param name variable name, must be unique. If name exists it removes the current variable. In debug mode program will exit. * @param type variable type, must be in SSupport::Datatypes[hostLanguage] in public/SSupport.h * @param dimensionsCSV comma separated variable local dimensions (e.g. "Nx,Ny,Nz") @@ -91,29 +78,23 @@ public: * @param globalDimensionsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local * @param globalOffsetsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local */ - void SetVariable( const std::string name, const std::string type, - const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ); + void CreateVariable( const std::string name, const std::string type, + const std::string dimensionsCSV, const std::string transform, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ); /** - * @brief Sets a new attribute in current Group - * @param name attribute name, must be unique. If name exists it removes the current variable. In debug mode program will exit. - * @param isGlobal - * @param type - * @param value + * + * @param name attribute name, must be unique. If name exists it removes the current variable. In debug mode program will exit. + * @param type attribute type string or numeric type + * @param value information about the attribute + * @param globalDimensionsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local + * @param globalOffsetsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local */ - void SetAttribute( const std::string name, const bool isGlobal, const std::string type, const std::string value ); + void CreateAttribute( const std::string name, const std::string type, const std::string value, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ); - /** - * @brief Sets m_Transport with available supported method - * @param method supported values in SSupport.h TransportMethods - * @param priority numeric priority for the I/O to schedule this write with others that might be pending - * @param iteration iterations between writes of a group to gauge how quickly this data should be evacuated from the compute node - * @param mpiComm MPI communicator from User->ADIOS->Group - */ - void SetTransport( const std::string method, const unsigned int priority, const unsigned int iteration, - const MPI_Comm mpiComm ); + void Close( ); ///< set m_IsOpen to false and sets m_BufferName and m_AccessMode to empty /** @@ -127,18 +108,27 @@ public: 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 bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code + const bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code, known at compile time - /** - * @brief Contains all group variables (from XML Config file). - * <pre> - * Key: std::string unique variable name - * Value: Polymorphic value is always unique child defined in SVariableTemplate.h, allow different variable types - * </pre> - */ - std::map< std::string, CVariable > m_Variables; - std::vector< std::string > m_VariableTransforms; ///< if a variable has a transform it fills this container, the variable hold an index + 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 + + std::vector< SVariable<char> > m_Char; ///< Key: variable name, Value: variable of type char + std::vector< SVariable<unsigned char> > m_UChar; ///< Key: variable name, Value: variable of type unsigned char + std::vector< SVariable<short> > m_Short; ///< Key: variable name, Value: variable of type short + std::vector< SVariable<unsigned short> > m_UShort; ///< Key: variable name, Value: variable of type unsigned short + std::vector< SVariable<int> > m_Int; ///< Key: variable name, Value: variable of type int + std::vector< SVariable<unsigned int> > m_UInt; ///< Key: variable name, Value: variable of type unsigned int + std::vector< SVariable<long int> > m_LInt; ///< Key: variable name, Value: variable of type long int + std::vector< SVariable<unsigned long int> > m_ULInt; ///< Key: variable name, Value: variable of type unsigned long int + std::vector< SVariable<long long int> > m_LLInt; ///< Key: variable name, Value: variable of type long long int + std::vector< SVariable<unsigned long long int> > m_ULLInt; ///< Key: variable name, Value: variable of type unsigned long long int + std::vector< SVariable<float> > m_Float; ///< Key: variable name, Value: variable of type float + std::vector< SVariable<double> > m_Double; ///< Key: variable name, Value: variable of type double + std::vector< SVariable<long double> > m_LDouble; ///< Key: variable name, Value: variable of type double + + std::set<std::string> m_SetVariables; ///< set of variables whose T* values have been set (no nullptr) + std::vector< std::string > m_Transforms; ///< if a variable has a transform it fills this container, the variable holds an index /** * @brief Contains all group attributes from SAttribute.h @@ -151,8 +141,9 @@ private: std::vector< std::pair< std::string, std::string > > m_GlobalBounds; ///< if a variable or an attribute is global it fills this container, from global-bounds in XML File, data in global space, pair.first = global dimensions, pair.second = global bounds - std::string m_CurrentTransport; ///< current transport method associated with this group - std::string m_OutputName; ///< associated output (file, stream, buffer, etc.) if the Group is opened. + std::string m_Transport; ///< current transport method associated with this group + std::string m_BufferName; ///< associated buffer (file, stream, vector, etc.) if the Group is opened. + std::string m_AccessMode; /// associated access mode for associated buffer from m_BufferName unsigned long int m_SerialSize; ///< size used for potential serialization of metadata into a std::vector<char>. Counts sizes from m_Variables, m_Attributes, m_GlobalBounds @@ -162,11 +153,23 @@ private: */ void ParseXMLGroup( const std::string& xmlGroup ); + + const unsigned int CurrentTypeIndex( const std::string type ) const noexcept; + + /** + * Used by SetVariable and SetAttribute to check if global bounds exist in m_GlobalBounds + * @param globalDimensionsCSV comma separated variables defining global dimensions (e.g. "Nx,NY,Nz") + * @param globalOffsetsCSV comma separated variables defining global offsets (e.g. "oNx,oNY,oNz") + * @return -1 if not global -> both inputs are empty, otherwise index in m_GlobalBounds if exist or create a new element in m_GlobalBounds; + */ + const int SetGlobalBounds( const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) noexcept; + /** - * Function that checks if transport method is valid, called from overloaded SetTransform functions - * @param method transport method to be checked from SSupport + * Used by SetVariable to check if transform exists in m_Transform + * @param transform variable transformation method (e.g. bzip2, szip, zlib ) + * @return -1 variable is not associated with a transform, otherwise index in m_Transforms */ - void CheckTransport( const std::string method ); + const int SetTransforms( const std::string transform ) noexcept; }; diff --git a/include/core/CTransform.h b/include/core/CTransform.h index 97c899e0f..7d5e45703 100644 --- a/include/core/CTransform.h +++ b/include/core/CTransform.h @@ -10,7 +10,7 @@ /// \cond EXCLUDE_FROM_DOXYGEN -#include <core/CVariable.h> +#include <core/SVariable.h> #include <string> /// \endcond @@ -29,17 +29,14 @@ public: const std::string m_Method; ///< name of the transformation method const unsigned int m_CompressionLevel; ///< depends on library implementation - CVariableBase& m_Variable; ///< variable to be transformed /** * Initialize parent method * @param method zlib, bzip2, szip * @param variable */ - CTransform( const std::string method, const unsigned int compressionLevel, CVariableBase& variable ): - m_Method( method ), - m_CompressionLevel( compressionLevel ), - m_Variable( variable ) + CTransform( const unsigned int compressionLevel ): + m_CompressionLevel( compressionLevel ) { } virtual ~CTransform( ){ }; diff --git a/include/core/CTransport.h b/include/core/CTransport.h index c68219caf..b125e74ac 100644 --- a/include/core/CTransport.h +++ b/include/core/CTransport.h @@ -18,7 +18,6 @@ #include "public/mpidummy.h" #endif -#include <core/CVariable.h> namespace adios @@ -29,7 +28,6 @@ class CTransport public: - const std::string m_Method; ///< method name, must be defined in SSupport.h TransportMethods const unsigned int m_Priority; ///< writing priority for this transport const unsigned int m_Iteration; ///< iteration number for this transport MPI_Comm m_MPIComm; ///< passed MPI communicator @@ -50,7 +48,6 @@ public: */ CTransport( const std::string method, const unsigned int priority, const unsigned int iteration, MPI_Comm mpiComm, const bool debugMode ): - m_Method( method ), m_Priority( priority ), m_Iteration( iteration ), m_MPIComm( mpiComm ), @@ -71,9 +68,6 @@ public: */ virtual void Open( const std::string outputName, const std::string accessMode ) = 0; - virtual void Write( const CVariableBase& variable ) - { }; - virtual void Close( ) = 0; //here think what needs to be passed virtual void Finalize( ) diff --git a/include/core/CVariable.h b/include/core/CVariable.h deleted file mode 100644 index 82e575b01..000000000 --- a/include/core/CVariable.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * CVariable.h - * - * Created on: Oct 6, 2016 - * Author: wfg - */ - -#ifndef CVARIABLE_H_ -#define CVARIABLE_H_ - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <string> -#include <vector> -#include <typeinfo> // for typeid -#include <sstream> -/// \endcond - - -namespace adios -{ -/** - * @param Base (parent) class for template derived (child) class CVariable. Required to put CVariable objects in STL containers. - */ -class CVariable -{ - -public: - - /** - * Unique constructor for local and global variables - * @param type variable type, must be in SSupport::Datatypes[hostLanguage] in public/SSupport.h - * @param dimensionsCSV comma separated variable local dimensions (e.g. "Nx,Ny,Nz") - * @param transformIndex - * @param globalIndex - */ - CVariable( const std::string type, const std::string dimensionsCSV, - const int globalIndex, const int transformIndex ); - - virtual ~CVariable( ); - - void* m_Values; - - -protected: - - const std::string m_Type; ///< mandatory, double, float, unsigned integer, integer, etc. - const std::string m_DimensionsCSV; ///< comma separated list for variables to search for local dimensions -}; - - -} //end namespace - - - -#endif /* CVARIABLE_H_ */ diff --git a/include/core/SVariable.h b/include/core/SVariable.h new file mode 100644 index 000000000..f4dc47385 --- /dev/null +++ b/include/core/SVariable.h @@ -0,0 +1,40 @@ +/* + * CVariable.h + * + * Created on: Oct 6, 2016 + * Author: wfg + */ + +#ifndef SVARIABLE_H_ +#define SVARIABLE_H_ + +/// \cond EXCLUDE_FROM_DOXYGEN +#include <string> +#include <vector> +#include <typeinfo> // for typeid +#include <sstream> +/// \endcond + +#include "core/CGroup.h" //friend class (manager) + +namespace adios +{ + +/** + * @param Base (parent) class for template derived (child) class CVariable. Required to put CVariable objects in STL containers. + */ +template< class T > +struct SVariable +{ + const std::string m_DimensionsCSV; ///< comma separated list for variables to search for local dimensions + const T* m_Values; + const int m_TransformIndex; ///< if global > 0, index corresponds to , if local then = -1 + const int m_GlobalBoundsIndex; ///< if global > 0, index corresponds to global-bounds in m_GlobalBounds in CGroup, if local then = -1 +}; + + +} //end namespace + + + +#endif /* SVARIABLE_H_ */ diff --git a/include/functions/ADIOSTemplates.h b/include/functions/ADIOSTemplates.h new file mode 100644 index 000000000..4ad576df0 --- /dev/null +++ b/include/functions/ADIOSTemplates.h @@ -0,0 +1,107 @@ +/* + * GroupTemplates.h + * + * Created on: Nov 7, 2016 + * Author: wfg + */ + +#ifndef ADIOSTEMPLATES_H_ +#define ADIOSTEMPLATES_H_ + +#include "core/CGroup.h" +#include "core/SVariable.h" +#include "core/CCapsule.h" + + +namespace adios +{ + +template< class T > +void WriteVariable( const std::string variableName, const T* values, CGroup& group, CCapsule& capsule ) noexcept +{ + auto itVariable = group.m_Variables.find( variableName ); + const std::string type( itVariable->second.first ); + const unsigned int index( itVariable->second.second ); + group.m_SetVariables.insert( variableName ); + + if( std::is_same<T,char> ) + { + SVariable<char>& variable = group.m_Char[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,unsigned char> ) + { + SVariable<unsigned char>& variable = group.m_UChar[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,short> ) + { + SVariable<short>& variable = group.m_Short[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,unsigned short> ) + { + SVariable<unsigned short>& variable = group.m_UShort[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,int> ) + { + SVariable<int>& variable = group.m_Int[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,unsigned int> ) + { + SVariable<unsigned int>& variable = group.m_Int[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,long int> ) + { + SVariable<long int>& variable = group.m_LInt[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,long long int> ) + { + SVariable<long int>& variable = group.m_LLInt[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,unsigned long long int> ) + { + SVariable<unsigned long long int>& variable = group.m_ULLInt[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,float> ) + { + SVariable<float>& variable = group.m_Float[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,double> ) + { + SVariable<double>& variable = group.m_Double[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } + else if( std::is_same<T,long double> ) + { + SVariable<double>& variable = group.m_Double[index]; + variable.m_Values = values; + capsule.WriteVariableToBuffer( group, variable ); + } +} + + + +} //end namespace + + + +#endif /* ADIOSTEMPLATES_H_ */ diff --git a/include/functions/GroupFunctions.h b/include/functions/GroupFunctions.h deleted file mode 100644 index 81d3c6697..000000000 --- a/include/functions/GroupFunctions.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -ri * GroupFunctions.h helper functions for class CGroup - * - * Created on: Oct 27, 2016 - * Author: wfg - */ - -#ifndef GROUPFUNCTIONS_H_ -#define GROUPFUNCTIONS_H_ - -/// \cond EXCLUDE_FROM_DOXYGEN -#include <string> -#include <map> -#include <memory> //unique_ptr -/// \endcond - -#ifdef HAVE_MPI - #include <mpi.h> -#else - #include "public/mpidummy.h" -#endif - -#include <core/CVariable.h> -#include "core/CTransport.h" - - -namespace adios -{ - -/** - * Create a language (C++, C, Fortran, etc.) supported type variable and add it to variables map - * @param name key in variables map - * @param type variable type, must be in SSupport::Datatypes[hostLanguage] in public/SSupport.h - * @param dimensionsCSV comma separated variable local dimensions (e.g. "Nx,Ny,Nz") - * @param transform method, format = lib or lib:level, where lib = zlib, bzip2, szip, and level=1:9 - * @param globalDimensionsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local - * @param globalOffsetsCSV comma separated variable global dimensions (e.g. "gNx,gNy,gNz"), if globalOffsetsCSV is also empty variable is local - * @param variables map belonging to class CGroup - */ -void CreateVariableLanguage( const std::string name, const std::string type, - const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV, - std::map<std::string, std::shared_ptr<CVariableBase> >& variables ) noexcept; - - -/** - * Looks up the variable type and cast the appropriate values type to m_Value in CVariable - * @param variables always a derived CVariable object from CVariableBase - * @param values to be casted to the right type - */ -void SetVariableValues( CVariableBase& variable, const void* values ) noexcept; - - - -/** - * Create a derived (child) class of CTransport in transport unique_ptr - * @param method supported values in SSupport.h TransportMethods - * @param priority numeric priority for the I/O to schedule this write with others that might be pending - * @param iteration iterations between writes of a group to gauge how quickly this data should be evacuated from the compute node - * @param mpiComm MPI communicator from User->ADIOS->Group - * @param transport passed from CGroup m_Transport member - */ -void CreateTransport( const std::string method, const unsigned int priority, const unsigned int iteration, - const MPI_Comm mpiComm, const bool debugMode, std::shared_ptr<CTransport>& transport ) noexcept; - - - -} //end namespace - -#endif /* GROUPFUNCTIONS_H_ */ diff --git a/include/public/ADIOS.h b/include/public/ADIOS.h index d0c3687cb..cab0a5465 100644 --- a/include/public/ADIOS.h +++ b/include/public/ADIOS.h @@ -21,9 +21,9 @@ #endif #include "core/CGroup.h" -#include "core/CTransport.h" -#include "core/CTransform.h" +#include "core/CCapsule.h" #include "public/SSupport.h" +#include "functions/ADIOSTemplates.h" namespace adios @@ -70,6 +70,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO */ ADIOS( const MPI_Comm mpiComm, const bool debugMode = false ); + ~ADIOS( ); ///< virtual destructor overriden by children's own destructors /** @@ -86,7 +87,19 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO * @param variableName name of existing scalar or vector variable in the XML file or created with CreateVariable * @param values pointer to the variable values passed from the user application, use dynamic_cast to check that pointer is of the same value type */ - void Write( const std::string groupName, const std::string variableName, const void* values ); + template< class T> + void Write( const std::string groupName, const std::string variableName, T* values ) + { + auto itGroup = m_Groups.find( groupName ); + if( m_DebugMode == true ) + { + CheckGroup( itGroup, groupName, " from call to Write with variable " + variableName ); + + if( itGroup->second.m_IsOpen == false ) + throw std::invalid_argument( "ERROR: group " + groupName + " is not open in Write function.\n" ); + } + WriteVariable( variableName, values, itGroup->second, m_Capsule ); + } /** * Close a particular group, group will be out of scope and destroyed @@ -118,7 +131,7 @@ private: */ std::map< std::string, CGroup > m_Groups; - std::map< std::string, std::shared_ptr<CTransform> > m_Transforms; + CCapsule m_Capsule; ///< manager of data transports, transforms and movement operations /** * @brief Maximum buffer size in ADIOS write() operation. From buffer max - size - MB in XML file diff --git a/include/transport/CDIMES.h b/include/transport/CDIMES.h index 81f7a4fd8..e9589b8a6 100644 --- a/include/transport/CDIMES.h +++ b/include/transport/CDIMES.h @@ -26,7 +26,6 @@ public: ~CDIMES( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CDataspaces.h b/include/transport/CDataspaces.h index d0aec4748..b07bda23b 100644 --- a/include/transport/CDataspaces.h +++ b/include/transport/CDataspaces.h @@ -25,7 +25,6 @@ public: ~CDataspaces( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CFStream.h b/include/transport/CFStream.h index b31419ed0..084c88ee8 100644 --- a/include/transport/CFStream.h +++ b/include/transport/CFStream.h @@ -30,8 +30,6 @@ public: void Open( const std::string fileName, const std::string accessMode ); - void Write( const CVariableBase& variable ); - void Close( ); private: diff --git a/include/transport/CFlexpath.h b/include/transport/CFlexpath.h index f789369cb..d4ded095a 100644 --- a/include/transport/CFlexpath.h +++ b/include/transport/CFlexpath.h @@ -24,7 +24,6 @@ public: ~CFlexpath( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CICEE.h b/include/transport/CICEE.h index a9aef64a9..d151badbe 100644 --- a/include/transport/CICEE.h +++ b/include/transport/CICEE.h @@ -24,8 +24,6 @@ public: ~CICEE( ); - void Write( const CVariable& variable ); - }; diff --git a/include/transport/CMPI.h b/include/transport/CMPI.h index 5f44ee743..b48582664 100644 --- a/include/transport/CMPI.h +++ b/include/transport/CMPI.h @@ -26,7 +26,6 @@ public: ~CMPI( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CMPIAggregate.h b/include/transport/CMPIAggregate.h index dbec7c8c7..24f387f96 100644 --- a/include/transport/CMPIAggregate.h +++ b/include/transport/CMPIAggregate.h @@ -26,7 +26,6 @@ public: ~CMPIAggregate( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CMPILustre.h b/include/transport/CMPILustre.h index bb3d01203..28ec77c95 100644 --- a/include/transport/CMPILustre.h +++ b/include/transport/CMPILustre.h @@ -25,7 +25,6 @@ public: ~CMPILustre( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CNetCDF4.h b/include/transport/CNetCDF4.h index a84f14b56..5108040e2 100644 --- a/include/transport/CNetCDF4.h +++ b/include/transport/CNetCDF4.h @@ -26,8 +26,6 @@ public: ~CNetCDF4( ); - void Write( const CVariable& variable ); - }; diff --git a/include/transport/CPHDF5.h b/include/transport/CPHDF5.h index 74d9cecb1..285ead7b2 100644 --- a/include/transport/CPHDF5.h +++ b/include/transport/CPHDF5.h @@ -26,7 +26,6 @@ public: ~CPHDF5( ); - void Write( const CVariable& variable ); }; diff --git a/include/transport/CPOSIX.h b/include/transport/CPOSIX.h index ee6567fca..e1ca3b8ca 100644 --- a/include/transport/CPOSIX.h +++ b/include/transport/CPOSIX.h @@ -27,8 +27,6 @@ public: void Open( const std::string fileName, const std::string accessMode ); - void Write( const CVariableBase& variable ); - void Close( ); }; diff --git a/include/transport/CVarMerge.h b/include/transport/CVarMerge.h index b2dfe6172..bb80499ca 100644 --- a/include/transport/CVarMerge.h +++ b/include/transport/CVarMerge.h @@ -25,8 +25,6 @@ public: ~CVarMerge( ); - void Write( const CVariable& variable ); - }; diff --git a/src/core/CCapsule.cpp b/src/core/CCapsule.cpp new file mode 100644 index 000000000..6e39ebbe6 --- /dev/null +++ b/src/core/CCapsule.cpp @@ -0,0 +1,22 @@ +/* + * CCapsule.cpp + * + * Created on: Nov 7, 2016 + * Author: wfg + */ + + + +#include "core/CCapsule.h" + + + +namespace adios +{ + + + + +} + + diff --git a/src/core/CGroup.cpp b/src/core/CGroup.cpp index a178628e4..0a266f382 100644 --- a/src/core/CGroup.cpp +++ b/src/core/CGroup.cpp @@ -5,13 +5,14 @@ * Author: wfg */ + #include <iostream> +#include <algorithm> // find #include "core/CGroup.h" -#include "functions/GroupFunctions.h" //for CreateVariableLanguage +#include "core/SVariable.h" //for cast implementation of CVariableBase::Set that calls CVariable::Set #include "public/SSupport.h" #include "functions/ADIOSFunctions.h" //for XML Parsing functions (e.g. GetTag) -#include "core/CVariable.h" //for cast implementation of CVariableBase::Set that calls CVariable::Set namespace adios @@ -38,87 +39,99 @@ CGroup::~CGroup( ) { } -void CGroup::Open( const std::string fileName, const std::string accessMode ) +void CGroup::Open( const std::string bufferName, const std::string accessMode ) { m_IsOpen = true; + m_BufferName = bufferName; + m_AccessMode = accessMode; } -void CGroup::SetVariable( const std::string name, const std::string type, - const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) +void CGroup::CreateVariable( const std::string name, const std::string type, + const std::string dimensionsCSV, const std::string transform, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) { if( m_DebugMode == true ) { if( SSupport::Datatypes.at( m_HostLanguage ).count( type ) == 0 ) throw std::invalid_argument( "ERROR: type " + type + " for variable " + name + " is not supported.\n" ); - if( m_Variables.count( name ) == 0 ) //variable doesn't exists - CreateVariableLanguage( name, type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV, m_Variables ); + m_Variables[name] = std::make_pair( type, CurrentTypeIndex( type ) ); else //name is found throw std::invalid_argument( "ERROR: variable " + name + " exists more than once.\n" ); } else { - CreateVariableLanguage( name, type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV, m_Variables ); + m_Variables[name] = std::make_pair( type, CurrentTypeIndex( type ) ); } -} + int transformIndex = SetTransforms( transform ); + int globalBoundsIndex = SetGlobalBounds( globalDimensionsCSV, globalOffsetsCSV ); -void CGroup::SetAttribute( const std::string name, const bool isGlobal, const std::string type, - const std::string value ) -{ - if( m_DebugMode == true ) - { - if( m_Attributes.count( name ) == 0 ) //variable doesn't exists - m_Attributes.emplace( name, SAttribute{ isGlobal, type, value } ); - else //name is found - throw std::invalid_argument( "ERROR: attribute " + name + " exists, NOT setting a new variable\n" ); - } - else - { - m_Attributes.emplace( name, SAttribute{ isGlobal, type, value } ); - } -} + if( type == "char" || type == "character" ) + m_Char.push_back( SVariable<char>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + else if( type == "unsigned char" ) + m_UChar.push_back( SVariable<unsigned char>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); -void CGroup::SetTransport( const std::string method, const unsigned int priority, const unsigned int iteration, - const MPI_Comm mpiComm ) -{ - if( m_DebugMode == true ) - { - if( SSupport::Transports.count( method ) == 0 ) - throw std::invalid_argument( "ERROR: transport method " + method + " not supported. Check spelling or case sensitivity.\n" ); - } + else if( type == "short" || type == "integer*2" ) + m_Short.push_back( SVariable<short>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "unsigned short" ) + m_UShort.push_back( SVariable<unsigned short>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); - if( m_ActiveTransport.empty() == false ) //there is an existing transport method, so reset - m_Transport.reset(); + else if( type == "int" || type == "integer" ) + m_Int.push_back( SVariable<int>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); - CreateTransport( method, priority, iteration, mpiComm, m_DebugMode, m_Transport ); - m_ActiveTransport = method; + else if( type == "unsigned int" || type == "unsigned integer" ) + m_UInt.push_back( SVariable<unsigned int>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "long int" || type == "long" || type == "long integer" ) + m_LInt.push_back( SVariable<long int>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "long long int" || type == "long long" || type == "long long integer" ) + m_LLInt.push_back( SVariable<long long int>{ dimensionsCSV, nullptr, transformIndex, 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, transformIndex, globalBoundsIndex } ); + + else if( type == "float" || type == "real" || type == "real*4" ) + m_Float.push_back( SVariable<float>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "double" || type == "double precision" || type == "real*8" ) + m_Double.push_back( SVariable<double>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); + + else if( type == "long double" || type == "real*16" ) + m_LDouble.push_back( SVariable<long double>{ dimensionsCSV, nullptr, transformIndex, globalBoundsIndex } ); } -void CGroup::Write( const std::string variableName, const void* values ) +void CGroup::CreateAttribute( const std::string name, const std::string type, const std::string value, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) { - auto itVariable = m_Variables.find( variableName ); + auto lf_EmplaceVariable = [&]( const std::string name, const std::string type, const std::string value, + const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) + { + const int globalBoundsIndex = SetGlobalBounds( globalDimensionsCSV, globalOffsetsCSV ); + m_Attributes.emplace( name, SAttribute{ type, value, globalBoundsIndex } ); + }; if( m_DebugMode == true ) { - if( itVariable == m_Variables.end() ) - throw std::invalid_argument( "ERROR: variable " + variableName + " is undefined.\n" ); + if( m_Attributes.count( name ) == 0 ) //variable doesn't exists + lf_EmplaceVariable( name, type, value, globalDimensionsCSV, globalOffsetsCSV ); + else //name is found + throw std::invalid_argument( "ERROR: attribute " + name + " exists, NOT setting a new variable\n" ); } - - SetVariableValues( *itVariable->second, values ); //will check type and cast to appropriate template<type> - //here must do something with Capsule or transport - m_Transport->Write( *itVariable->second ); //transport will write? + else + lf_EmplaceVariable( name, type, value, globalDimensionsCSV, globalOffsetsCSV ); } - void CGroup::Close( ) { - //here must think what to do with Capsule and close Transport - m_Transport->Close( ); + m_IsOpen = false; + m_BufferName.clear(); + m_AccessMode.clear(); } //PRIVATE FUNCTIONS BELOW @@ -127,7 +140,7 @@ void CGroup::Monitor( std::ostream& logStream ) const logStream << "\tVariable \t Type\n"; for( auto& variablePair : m_Variables ) { - logStream << "\t" << variablePair.first << " \t " << variablePair.second->m_Type << "\n"; + logStream << "\t" << variablePair.first << " \t " << variablePair.second.first << "\n"; } std::cout << "\n"; @@ -138,7 +151,7 @@ void CGroup::Monitor( std::ostream& logStream ) const } std::cout << "\n"; - logStream << "\tTransport Method " << m_ActiveTransport << "\n"; + logStream << "\tTransport Method " << m_Transport << "\n"; std::cout << "\n"; } @@ -146,7 +159,6 @@ void CGroup::Monitor( std::ostream& logStream ) const void CGroup::ParseXMLGroup( const std::string& xmlGroup ) { std::string::size_type currentPosition( 0 ); - bool isGlobal = false; //used to set attributes std::string globalDimensionsCSV; //used to set variables std::string globalOffsetsCSV; //used to set variables @@ -159,7 +171,6 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) if( tag == "</global-bounds>" ) { - isGlobal = false; //used for attributes globalDimensionsCSV.clear(); //used for variables globalOffsetsCSV.clear(); //used for variables } @@ -189,7 +200,7 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) else if( pair.first == "dimensions" ) dimensionsCSV = pair.second; else if( pair.first == "transform" ) transform = pair.second; } - SetVariable( name, type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); + CreateVariable( name, type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); } else if( tagName == "attribute" ) { @@ -200,7 +211,7 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) else if( pair.first == "value" ) value = pair.second; else if( pair.first == "type" ) type = pair.second; } - SetAttribute( name, isGlobal, type, value ); + CreateAttribute( name, type, value, globalDimensionsCSV, globalOffsetsCSV ); } else if( tagName == "global-bounds" ) { @@ -217,14 +228,103 @@ void CGroup::ParseXMLGroup( const std::string& xmlGroup ) if( globalDimensionsCSV.empty() ) throw std::invalid_argument( "ERROR: dimensions missing in global-bounds tag\n"); - if( globalDimensionsCSV.empty() ) + if( globalOffsetsCSV.empty() ) throw std::invalid_argument( "ERROR: offsets missing in global-bounds tag\n"); } - - isGlobal = true; } } //end while loop } +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() ) + return -1; + + int globalBoundsIndex = -1; + const auto globalBounds = std::make_pair( globalDimensionsCSV, globalOffsetsCSV ); + auto itGlobalBounds = std::find( m_GlobalBounds.begin(), m_GlobalBounds.end(), globalBounds ); + + if( itGlobalBounds != m_GlobalBounds.end() ) + { + globalBoundsIndex = std::distance( m_GlobalBounds.begin(), itGlobalBounds ); + } + else + { + m_GlobalBounds.push_back( globalBounds ); + globalBoundsIndex = m_GlobalBounds.size(); + } + + return globalBoundsIndex; +} + + +const int CGroup::SetTransforms( const std::string transform ) noexcept +{ + if( transform.empty() ) + return -1; + + int transformIndex = -1; + auto itTransform = std::find( m_Transforms.begin(), m_Transforms.end(), transform ); + if( itTransform != m_Transforms.end() ) + { + transformIndex = std::distance( m_Transforms.begin(), itTransform ); + } + else + { + m_Transforms.push_back( transform ); + transformIndex = m_Transforms.size(); + } + + return transformIndex; +} + + } //end namespace diff --git a/src/core/CVariable.cpp b/src/core/CVariable.cpp deleted file mode 100644 index eec3520ee..000000000 --- a/src/core/CVariable.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * CVariable.cpp - * - * Created on: Oct 18, 2016 - * Author: wfg - */ - - -#include "core/CVariable.h" - -namespace adios -{ - -CVariable::CVariable( const std::string type, const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ): - m_Type{ type }, - m_DimensionsCSV{ dimensionsCSV }, - m_Transform{ transform }, - m_GlobalDimensionsCSV{ globalDimensionsCSV }, - m_GlobalOffsetsCSV{ globalOffsetsCSV } -{ - if( m_GlobalDimensionsCSV.empty() || m_GlobalOffsetsCSV.empty() ) - m_IsGlobal = false; - else - m_IsGlobal = true; -} - - -CVariable::~CVariable() -{ } - - -} //end namespace diff --git a/src/functions/GroupFunctions.cpp b/src/functions/GroupFunctions.cpp deleted file mode 100644 index dafe410d5..000000000 --- a/src/functions/GroupFunctions.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * GroupFunctions.cpp - * - * Created on: Oct 27, 2016 - * Author: wfg - */ -#include <complex> - -#include "functions/GroupFunctions.h" -#include "core/CVariable.h" - -//transports -#include "transport/CPOSIX.h" -#include "transport/CFStream.h" - - -namespace adios -{ - - -void CreateVariableLanguage( const std::string name, const std::string type, - const std::string dimensionsCSV, const std::string transform, - const std::string globalDimensionsCSV, const std::string globalOffsetsCSV, - std::map<std::string, std::shared_ptr<CVariableBase> >& variables ) noexcept -{ - std::shared_ptr<CVariableBase> variable; - //Common Primitive types to most languages - if( type == "char" || type == "character" ) - variable = std::make_shared< CVariable<char> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "unsigned char" ) - variable = std::make_shared< CVariable<unsigned char> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "short" || type == "integer*2" ) - variables = std::make_shared< CVariable<short> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "unsigned short" ) - variables = std::make_shared< CVariable<unsigned short> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "int" || type == "integer" ) - variables = std::make_shared< CVariable<int> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "unsigned int" || type == "unsigned integer" ) - variable = std::make_shared< CVariable<unsigned int> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "long int" || type == "long" || type == "long integer" ) - variable = std::make_shared< CVariable<long int> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "long long int" || type == "long long" || type == "long long integer" ) - variable = std::make_shared< CVariable<long long int> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "float" || type == "real" || type == "real*4" ) - variable = std::make_shared< CVariable<float> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "double" || type == "double precision" || type == "real*8" ) - variable = std::make_shared< CVariable<double> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "long double" || type == "real*16" ) - variable = std::make_shared< CVariable<long double> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - //C++ - else if( type == "std::string" || type == "string" ) - variable = std::make_shared< CVariable<std::string> >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<char>" || type == "vector<char>" ) - variable = std::make_shared< CVariable< std::vector<char> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<int>" || type == "vector<int>" ) - variable = std::make_shared< CVariable< std::vector<int> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<unsigned int>" || type == "vector<unsigned int>" ) - variable = std::make_shared< CVariable< std::vector<unsigned int> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<long int>" || type == "std::vector<long>" || - type == "vector<long int>" || type == "vector<long>" ) - variable = std::make_shared< CVariable<std::vector<long int> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<long long int>" || type == "std::vector<long long>" || - type == "vector<long long int>" || type == "vector<long long>" ) - variable = std::make_shared< CVariable< std::vector<long long int> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<float>" || type == "vector<float>" ) - variable = std::make_shared< CVariable< std::vector<float> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<double>" || type == "vector<double>" ) - variable = std::make_shared< CVariable< std::vector<double> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<long double>" || type == "vector<long double>" ) - variable = std::make_shared< CVariable< std::vector<long double> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - //STL Complex types - else if( type == "std::complex<float>" || type == "complex<float>" ) - variable = std::make_shared< CVariable< std::complex<float> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::complex<double>" || type == "complex<double>" ) - variable = std::make_shared< CVariable< std::complex<double> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::complex<long double>" || type == "complex<long double>" ) - variable = std::make_shared< CVariable< std::complex<long double> > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<std::complex<float>>" || type == "vector<complex<float>>" ) - variable = std::make_shared< CVariable< std::vector< std::complex<float> > > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<std::complex<double>>" || type == "vector<complex<double>>" ) - variable = std::make_shared< CVariable< std::vector< std::complex<double> > > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - else if( type == "std::vector<std::complex<long double>>" || type == "vector<complex<long double>>" ) - variable = std::make_shared< CVariable< std::vector< std::complex<long double> > > >( type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV ); - - variables[name] = variable; -} - - -void SetVariableValues( CVariableBase& variable, const void* values ) noexcept -{ - const std::string type( variable.m_Type ); - - if( type == "char" || type == "character" ) - variable.Set<char>( values ); - - else if( type == "unsigned char" ) - variable.Set<unsigned char>( values ); - - else if( type == "short" || type == "integer*2" ) - variable.Set<short>( values ); - - else if( type == "unsigned short" ) - variable.Set<unsigned short>( values ); - - else if( type == "int" || type == "integer" ) - variable.Set<int>( values ); - - else if( type == "unsigned int" || type == "unsigned integer" ) - variable.Set<unsigned int>( values ); - - else if( type == "long int" || type == "long" || type == "long integer" ) - variable.Set<long int>( values ); - - else if( type == "long long int" || type == "long long" || type == "long long integer" ) - variable.Set<long long int>( values ); - - else if( type == "float" || type == "real" || type == "real*4" ) - variable.Set<float>( values ); - - else if( type == "double" || type == "double precision" || type == "real*8" ) - variable.Set<double>( values ); - - else if( type == "long double" || type == "real*16" ) - variable.Set<long double>( values ); - - //C++ - else if( type == "std::string" || type == "string" ) - variable.Set<std::string>( values ); - - else if( type == "std::vector<char>" || type == "vector<char>" ) - variable.Set< std::vector<char> >( values ); - - else if( type == "std::vector<int>" || type == "vector<int>" ) - variable.Set< std::vector<int> >( values ); - - else if( type == "std::vector<unsigned int>" || type == "vector<unsigned int>" ) - variable.Set< std::vector<unsigned int> >( values ); - - else if( type == "std::vector<long int>" || type == "std::vector<long>" || - type == "vector<long int>" || type == "vector<long>" ) - variable.Set<std::vector<long int> >( values ); - - else if( type == "std::vector<long long int>" || type == "std::vector<long long>" || - type == "vector<long long int>" || type == "vector<long long>" ) - variable.Set< std::vector<long long int> >( values ); - - else if( type == "std::vector<float>" || type == "vector<float>" ) - variable.Set< std::vector<float> >( values ); - - else if( type == "std::vector<double>" || type == "vector<double>" ) - variable.Set< std::vector<double> >( values ); - - else if( type == "std::vector<long double>" || type == "vector<long double>" ) - variable.Set< std::vector<long double> >( values ); - - //STL Complex types - else if( type == "std::complex<float>" || type == "complex<float>" ) - variable.Set< std::complex<float> >( values ); - - else if( type == "std::complex<double>" || type == "complex<double>" ) - variable.Set< std::complex<double> >( values ); - - else if( type == "std::complex<long double>" || type == "complex<long double>" ) - variable.Set< std::complex<long double> >( values ); - - else if( type == "std::vector<std::complex<float>>" || type == "vector<complex<float>>" ) - variable.Set< std::vector< std::complex<float> > >( values ); - - else if( type == "std::vector<std::complex<double>>" || type == "vector<complex<double>>" ) - variable.Set< std::vector< std::complex<double> > >( values ); - - else if( type == "std::vector<std::complex<long double>>" || type == "vector<complex<long double>>" ) - variable.Set< std::vector< std::complex<long double> > >( values ); -} - - -void CreateTransport( const std::string method, const unsigned int priority, const unsigned int iteration, - const MPI_Comm mpiComm, const bool debugMode, std::shared_ptr<CTransport>& transport ) noexcept -{ - if( method == "POSIX" ) - transport = std::make_shared<CPOSIX>( priority, iteration, mpiComm, debugMode ); - - else if( method == "FStream" ) - transport = std::make_shared<CFStream>( priority, iteration, mpiComm, debugMode ); -} - - -} //end namespace - - diff --git a/src/public/ADIOS.cpp b/src/public/ADIOS.cpp index 1683c65ff..b22826238 100644 --- a/src/public/ADIOS.cpp +++ b/src/public/ADIOS.cpp @@ -53,21 +53,7 @@ void ADIOS::Open( const std::string groupName, const std::string fileName, const CheckGroup( itGroup, groupName, " from call to Open with file " + fileName ); itGroup->second.Open( fileName, accessMode ); -} - - -void ADIOS::Write( const std::string groupName, const std::string variableName, const void* values ) -{ - auto itGroup = m_Groups.find( groupName ); - if( m_DebugMode == true ) - { - CheckGroup( itGroup, groupName, " from call to Write with variable " + variableName ); - - if( itGroup->second.m_IsOpen == false ) - throw std::invalid_argument( "ERROR: group " + groupName + " is not open in Write function.\n" ); - } - itGroup->second.Write( variableName, values ); } @@ -82,8 +68,9 @@ void ADIOS::Close( const std::string groupName ) throw std::invalid_argument( "ERROR: group " + groupName + " is not open in Write function.\n" ); } - itGroup->second.Close( ); //calling capsule and transport - //m_Groups.erase( groupName ); //make group unavailable ? + m_Capsule.CloseGroupBuffer( itGroup->second ); + + itGroup->second.Close( ); } diff --git a/src/public/SSupport.cpp b/src/public/SSupport.cpp index 94dae63fe..eeafd7c17 100644 --- a/src/public/SSupport.cpp +++ b/src/public/SSupport.cpp @@ -31,8 +31,6 @@ const std::set<std::string> SSupport::Transforms{ }; - - const std::map<std::string, std::set<std::string> > SSupport::Datatypes { { "C++", diff --git a/src/transport/CFStream.cpp b/src/transport/CFStream.cpp index ea14fa2f8..cf5f49241 100644 --- a/src/transport/CFStream.cpp +++ b/src/transport/CFStream.cpp @@ -6,7 +6,8 @@ */ /// \cond EXCLUDED_FROM_DOXYGEN -#include <core/CVariable.h> +#include <core/SVariable.h> +#include <core/SVariable.h> #include <iostream> #include <sstream> #include <cmath> @@ -15,7 +16,6 @@ /// \endcond #include "transport/CFStream.h" -#include "core/CVariable.h" #include "functions/GroupFunctions.h" #include "functions/Templates.h" -- GitLab