Skip to content
Snippets Groups Projects
Commit 52d0a7a6 authored by wfg's avatar wfg
Browse files

Continue working with API changes

parent 94803bd0
No related branches found
No related tags found
1 merge request!8Integrate groupless
...@@ -42,7 +42,17 @@ public: ...@@ -42,7 +42,17 @@ public:
template< class T> template< class T>
void WriteVariableToBuffer( const CGroup& group, const SVariable<T>& variable ); void WriteVariableToBuffer( const CGroup& group, const SVariable<T>& variable )
{
// while
// {
//
// send
// receive status
// if( status )
// switch Transport
// }
}
/** /**
* Closes the buffer and moves it into the * Closes the buffer and moves it into the
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#ifndef CEMPTYCAPSULE_H_ #ifndef CEMPTYCAPSULE_H_
#define CEMPTYCAPSULE_H_ #define CEMPTYCAPSULE_H_
#include "core/CCapsule.h"
namespace adios namespace adios
{ {
...@@ -30,9 +33,6 @@ public: ...@@ -30,9 +33,6 @@ public:
void OpenGroupBuffer( const CGroup& group ); void OpenGroupBuffer( const CGroup& group );
void WriteVariableToBuffer( const CGroup& group, const SVariable<T>& variable );
/** /**
* Closes the buffer and moves it into the * Closes the buffer and moves it into the
* @param group * @param group
......
...@@ -39,21 +39,22 @@ public: ...@@ -39,21 +39,22 @@ public:
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 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 #endif
unsigned long int m_BufferSize; ///< buffer size std::map< std::string, std::vector<char> > m_Buffer; ///< buffer to be managed, just one type for now
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<CTransform> > m_Transforms; ///< transforms associated with ADIOS run
std::map< std::string, std::shared_ptr<CTransport> > m_Transports; ///< transports associated with ADIOS run std::map< std::string, std::shared_ptr<CTransport> > m_Transports; ///< transports associated with ADIOS run
/** /**
* Unique constructor * Unique constructor
* @param mpiComm communicator passed from ADIOS * @param mpiComm communicator passed from ADIOS
* @param bufferSize passed by the user
*/ */
CCapsule( const MPI_Comm mpiComm, const unsigned long int bufferSize ): CCapsule( const MPI_Comm mpiComm, const unsigned long int bufferSize );
m_MPIComm{ mpiComm },
m_BufferSize{ bufferSize }
{ }
virtual ~CCapsule( ){ }; virtual ~CCapsule( );
void CreateTransform( const std::string transform );
void CreateTransport( const std::string transport );
/** /**
* This will add to the m_Transports and m_Transforms map * This will add to the m_Transports and m_Transforms map
...@@ -61,10 +62,19 @@ public: ...@@ -61,10 +62,19 @@ public:
*/ */
void OpenGroupBuffer( const CGroup& group ) = 0; void OpenGroupBuffer( const CGroup& group ) = 0;
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<unsigned int>& variable ); virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<char>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<unsigned char>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<short>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<unsigned short>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<int>& variable ); virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<int>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<unsigned int>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<long int>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<unsigned long int>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<long long int>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<unsigned long long int>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<float>& variable ); virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<float>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<double>& variable ); virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<double>& variable );
virtual void WriteVariableToBuffer( const CGroup& group, const SVariable<long double>& variable );
/** /**
* Closes the buffer and moves it into the * Closes the buffer and moves it into the
......
...@@ -143,7 +143,7 @@ private: ...@@ -143,7 +143,7 @@ private:
std::string m_Transport; ///< current transport method associated with this group 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_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 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 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
...@@ -160,7 +160,7 @@ private: ...@@ -160,7 +160,7 @@ private:
* Used by SetVariable and SetAttribute to check if global bounds exist in m_GlobalBounds * 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 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") * @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; * @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; const int SetGlobalBounds( const std::string globalDimensionsCSV, const std::string globalOffsetsCSV ) noexcept;
......
...@@ -42,11 +42,13 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO ...@@ -42,11 +42,13 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
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 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 #endif
/** /**
* @brief ADIOS empty constructor. Used for non XML config file API calls. * @brief ADIOS empty constructor. Used for non XML config file API calls.
*/ */
ADIOS( ); ADIOS( );
/** /**
* @brief Serial constructor for XML config file * @brief Serial constructor for XML config file
* @param xmlConfigFile passed to m_XMLConfigFile * @param xmlConfigFile passed to m_XMLConfigFile
...@@ -54,6 +56,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO ...@@ -54,6 +56,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
*/ */
ADIOS( const std::string xmlConfigFile, const bool debugMode = false ); ADIOS( const std::string xmlConfigFile, const bool debugMode = false );
/** /**
* @brief Parallel constructor for XML config file and MPI * @brief Parallel constructor for XML config file and MPI
* @param xmlConfigFile passed to m_XMLConfigFile * @param xmlConfigFile passed to m_XMLConfigFile
...@@ -73,6 +76,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO ...@@ -73,6 +76,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
~ADIOS( ); ///< virtual destructor overriden by children's own destructors ~ADIOS( ); ///< virtual destructor overriden by children's own destructors
/** /**
* @brief Open or Append to an output file * @brief Open or Append to an output file
* @param groupName should match an existing group from XML file or created through CreateGroup * @param groupName should match an existing group from XML file or created through CreateGroup
...@@ -81,13 +85,15 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO ...@@ -81,13 +85,15 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
*/ */
void Open( const std::string groupName, const std::string fileName, const std::string accessMode = "w" ); void Open( const std::string groupName, const std::string fileName, const std::string accessMode = "w" );
/** /**
* Submits a data element values for writing and associates it with the given variableName * Submits a data element values for writing and associates it with the given variableName
* @param groupName name of group that owns the variable * @param groupName name of group that owns the variable
* @param variableName name of existing scalar or vector variable in the XML file or created with CreateVariable * @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 * @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, T* values ) template< class T>
void Write( const std::string groupName, const std::string variableName, const T* values )
{ {
auto itGroup = m_Groups.find( groupName ); auto itGroup = m_Groups.find( groupName );
if( m_DebugMode == true ) if( m_DebugMode == true )
...@@ -100,12 +106,14 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO ...@@ -100,12 +106,14 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
WriteVariable( variableName, values, itGroup->second, m_Capsule ); WriteVariable( variableName, values, itGroup->second, m_Capsule );
} }
/** /**
* Close a particular group, group will be out of scope and destroyed * Close a particular group, group will be out of scope and destroyed
* @param groupName group to be closed * @param groupName group to be closed
*/ */
void Close( const std::string groupName ); void Close( const std::string groupName );
/** /**
* @brief Dumps groups information to a file stream or standard output. * @brief Dumps groups information to a file stream or standard output.
* Note that either the user closes this fileStream or it's closed at the end. * Note that either the user closes this fileStream or it's closed at the end.
...@@ -114,10 +122,27 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO ...@@ -114,10 +122,27 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
void MonitorGroups( std::ostream& logStream ) const; void MonitorGroups( std::ostream& logStream ) const;
/**
* @brief Create a new group or replace an existing one
* @param groupName unique name
* @param transport transport method
* @param streamFile
*/
void CreateGroup( const std::string groupName, const std::string transport = "" );
void CreateVariable( const std::string groupName, const std::string variableName, const std::string type,
const std::string dimensionsCSV = "", const std::string transform = "",
const std::string globalDimensionsCSV = "", const std::string globalOffsetsCSV = "" );
void CreateAttribute( const std::string groupName, const std::string attributeName,
const std::string type, const std::string value,
const std::string globalDimensionsCSV = "", const std::string globalOffsetsCSV = "" );
private: private:
std::string m_XMLConfigFile; ///< XML File to be read containing configuration information std::string m_XMLConfigFile; ///< XML File to be read containing configuration information
std::string m_HostLanguage = "C++"; ///< Supported languages: C, C++, Fortran, Python, etc. std::string m_HostLanguage = "C++"; ///< Supported languages: C, C++, Fortran, Python, etc.
bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code
...@@ -138,10 +163,10 @@ private: ...@@ -138,10 +163,10 @@ private:
* ADIOS will allocate two separate buffers each with the specified maximum limit. * ADIOS will allocate two separate buffers each with the specified maximum limit.
* Default = 0 means there is no limit * Default = 0 means there is no limit
*/ */
unsigned int MaxBufferSizeInMB = 0; unsigned long int MaxBufferSizeInMB = 0;
/** /**
* Checks for group existence in m_Groups, if failed throws std::invalid_argument exception * @brief Checks for group existence in m_Groups, if failed throws std::invalid_argument exception
* @param itGroup group iterator, usually from find function * @param itGroup group iterator, usually from find function
* @param groupName passed for thrown exception only * @param groupName passed for thrown exception only
* @param hint adds information to thrown exception * @param hint adds information to thrown exception
......
/*
* CCapsule.cpp
*
* Created on: Nov 11, 2016
* Author: wfg
*/
#include "core/CCapsule.h"
namespace adios
{
CCapsule::CCapsule( const MPI_Comm mpiComm, const unsigned long int bufferSize ):
m_MPIComm{ mpiComm },
m_BufferSize{ bufferSize }
{ }
CCapsule::~CCapsule( )
{ }
}
...@@ -46,14 +46,27 @@ ADIOS::~ADIOS( ) ...@@ -46,14 +46,27 @@ ADIOS::~ADIOS( )
{ } { }
void ADIOS::CreateGroup( const std::string groupName, const std::string transport )
{
if( m_DebugMode == true )
{
if( m_Groups.find( groupName ) != m_Groups.end() )
throw std::invalid_argument( "ERROR: group " + groupName + " already exist, from call to CreateGroup\n" );
}
m_Groups.emplace( groupName, CGroup( m_HostLanguage, m_DebugMode ) );
}
void ADIOS::Open( const std::string groupName, const std::string fileName, const std::string accessMode ) void ADIOS::Open( const std::string groupName, const std::string fileName, const std::string accessMode )
{ {
auto itGroup = m_Groups.find( groupName ); auto itGroup = m_Groups.find( groupName );
if( m_DebugMode == true ) if( m_DebugMode == true )
CheckGroup( itGroup, groupName, " from call to Open with file " + fileName ); CheckGroup( itGroup, groupName, " from call to Open with file " + fileName );
itGroup->second.Open( fileName, accessMode ); itGroup->second.Open( fileName, accessMode );
} }
...@@ -68,12 +81,27 @@ void ADIOS::Close( const std::string groupName ) ...@@ -68,12 +81,27 @@ void ADIOS::Close( const std::string groupName )
throw std::invalid_argument( "ERROR: group " + groupName + " is not open in Write function.\n" ); throw std::invalid_argument( "ERROR: group " + groupName + " is not open in Write function.\n" );
} }
m_Capsule.CloseGroupBuffer( itGroup->second ); m_Capsule->CloseGroupBuffer( itGroup->second );
itGroup->second.Close( ); itGroup->second.Close( );
} }
void ADIOS::CreateVariable( const std::string groupName, const std::string variableName, const std::string type,
const std::string dimensionsCSV, const std::string transform,
const std::string globalDimensionsCSV, const std::string globalOffsetsCSV )
{
auto itGroup = m_Groups.find( groupName );
if( m_DebugMode == true )
{
CheckGroup( itGroup, groupName, " from call to CreateVariable \n" );
}
itGroup->second.CreateVariable( variableName, type, dimensionsCSV, transform, globalDimensionsCSV, globalOffsetsCSV );
}
void ADIOS::MonitorGroups( std::ostream& logStream ) const void ADIOS::MonitorGroups( std::ostream& logStream ) const
{ {
for( auto& groupPair : m_Groups ) for( auto& groupPair : m_Groups )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment