17#include <sys/socket.h>
86#if defined(MAIA_CLANG_COMPILER)
87#pragma clang diagnostic push
88#pragma clang diagnostic ignored "-Wuninitialized"
91#if defined(MAIA_CLANG_COMPILER)
92#pragma clang diagnostic pop
137 void open(
const MString& filename,
const MString& projectName, MPI_Comm mpiComm = MPI_COMM_WORLD);
167 MBool rootOnlyHardwired =
false);
169 void open(
const MString& filename,
const MString& projectName, MPI_Comm mpiComm = MPI_COMM_WORLD,
170 MBool rootOnlyHardwired =
false);
201 void initialize(std::ostream* os, MPI_Comm mpiComm = MPI_COMM_WORLD,
MBool printDomainId =
true);
225 MBool rootOnlyHardwired =
false);
227 void open(
const MString& filename,
const MString& projectName,
MInt fileType = 0, MPI_Comm mpiComm = MPI_COMM_WORLD,
228 MBool rootOnlyHardwired =
false);
249 InfoOutStream(std::ostream* os, MPI_Comm mpiComm = MPI_COMM_WORLD,
MBool printDomainId =
true);
251 void initialize(std::ostream* os, MPI_Comm mpiComm = MPI_COMM_WORLD,
MBool printDomainId =
true);
virtual void flushBuffer()=0
MInt m_minFlushSize
Minimum length of the internal buffer before flushing.
MInt m_domainId
Contains the MPI rank (= domain id) of this process.
virtual MInt setMinFlushSize(MInt minFlushSize)
Sets the minimum buffer length that has to be reached before the buffer is flushed.
InfoOut_buffer()
Generic constructor is used when no information is provided during declaration.
MString m_prefixMessage
Stores the prefix that is prepended to each output.
MString m_suffixMessage
Stores the suffix that is apended to each output.
std::ostringstream m_tmpBuffer
Temporary buffer to hold string until flushing.
virtual void createSuffixMessage()
Creates an XML suffix that is appended to each message.
std::vector< std::pair< MString, MString > > m_prefixAttributes
virtual MBool setRootOnly(MBool rootOnly=true)
Sets interal state of whether only the root domain (rank 0) should write to file.
virtual MString getXmlHeader()
Return an XML header that should written at the beginning of each log file.
virtual void createPrefixMessage()
Creates an XML prefix using the domain id that is prepended to each message.
MInt m_noDomains
Contains the MPI rank count (= number of domains)
MString m_projectName
Name of the current Project.
MBool m_rootOnly
Stores whether only the root domain writes a log file.
virtual MString encodeXml(const std::string &str)
Parses the string input and returns the string with XML entities escaped.
static const MInt m_fileFormatVersion
virtual MString getXmlFooter()
Return an XML footer that should written at the end of each log file.
Customized buffer to facilitate MPI I/O usage for a single file for all domains within an MPI communi...
void close(MBool forceClose=false)
Closes the MPI file.
MChar * m_mpiWriteBuffer
MPI write buffer.
virtual void flushBuffer()
Flushes the buffer by writing the contents to the MPI file.
MBool m_isOpen
Stores whether the MPI file was already opened.
MInt setMpiWriteBuffer(MInt newBufferSize)
Delete the current MPI write buffer and allocate a new one.
MInt m_mpiWriteBufferSize
Size of the MPI write buffer.
void open(const MString &filename, const MString &projectName, MPI_Comm mpiComm=MPI_COMM_WORLD)
Initialization of the MPI I/O environment.
MPI_Request m_mpiRequest
MPI request object (nonblocking I/O)
MInt m_maxMessageLength
Maximum message length (excluding formatting)
MString m_filename
Filename on disk.
MPI_File m_mpiFileHandle
MPI file handle.
virtual MInt sync()
Flushes the buffer if flushing conditions are met.
static const MInt m_maxStringLength
Maximum string length (including formatting, default: 4096)
MInt setMinFlushSize(MInt minFlushSize)
Sets the minimum buffer length that has to be reached before the buffer is flushed.
InfoOut_mpiFileBuffer()
Generic constructor is used when no information is provided during declaration.
~InfoOut_mpiFileBuffer()
Destructor calls close() to close the MPI file (if opened) and deletes the MPI write buffer.
MPI_Comm m_mpiComm
MPI communicator group.
Customized buffer to facilitate of a regular physical file for each processor within an MPI communica...
~InfoOut_simpleFileBuffer()
Destructor calls close() to close the file.
MString m_filename
Filename on disk.
void close(MBool forceClose=false)
Closes the file.
virtual void flushBuffer()
Flushes the buffer by writing the contents to the file.
MBool m_isOpen
Stores whether the file(s) were already opened.
virtual MInt sync()
Flushes the buffer by writing the contents to the file.
MBool m_rootOnlyHardwired
If true, only domain 0 opens and uses a file.
void open(const MString &filename, const MString &projectName, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool rootOnlyHardwired=false)
Initialization of the file I/O environment.
InfoOut_simpleFileBuffer()
Generic constructor is used when no information is provided during declaration.
MPI_Comm m_mpiComm
MPI communicator group.
std::ofstream m_file
File stream tied to physical file on disk.
Customized string buffer to prepend cout/cerr with the domain id.
virtual MString addPrefix(const MString &str)
virtual void flushBuffer()
This function does nothing for this class, since as of now there is no intermediate buffering.
virtual MInt sync()
Flushes the buffer by writing the contents to the asssociated output stream.
std::ostream * m_output
Stores the output stream (usually cout or cerr) that will be modified.
InfoOut_streamBuffer()
Default constructor does basically nothing.
void initialize(std::ostream *os, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool printDomainId=true)
Initializes the buffer to make it ready for use.
MPI_Comm m_mpiComm
MPI communicator group.
MBool m_isInitialized
Stores whether a stream was already associated with this buffer.
MBool m_isDisabled
Stores wether output in streamBuffer should be written.
MBool m_printDomainId
Stores whether the domain id should be prepended to each output.
Class to create a create an output stream for a writable file, using either MPI I/O or a physical fil...
MBool m_isOpen
Stores whether a file was already opened or not.
InfoOutFile()
Default constructor creates (virtual) file that cannot yet be used.
~InfoOutFile()
Destructor closes the stream.
MInt m_fileType
File type that is opened.
void open(const MString &filename, const MString &projectName, MInt fileType=0, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool rootOnlyHardwired=false)
Opens a file by passing the parameters to InfoOut_<xyz>FileBuffer::open(...).
void close(MBool forceClose=false)
Pass the close call to the respective internal buffer.
MBool setRootOnly(MBool rootOnly=true)
Sets interal state of whether only the root domain (rank 0) should write to file.
MInt setMinFlushSize(MInt minFlushSize)
Sets the minimum buffer length that has to be reached before the buffer is flushed.
Base class for all InfoOut<xyz> classes.
void modifyAttribute(MInt, std::pair< MString, MString >)
Modifies an attribute of the prefix of the XML string.
void eraseAttribute(MInt)
Erases an attribute from the prefix of the XML string.
virtual MBool setRootOnly(MBool rootOnly=true)=0
InfoOut_buffer * m_buffer
MInt addAttribute(std::pair< MString, MString >)
Adds an attribute to the prefix of the XML string.
Class to create an output stream that writes to cout or cerr but prepends each line with the MPI rank...
InfoOutStream()
Default construtor creates InfoOutStream that is not (yet) usable.
MBool setRootOnly(MBool rootOnly=true)
Sets interal state of whether only the root domain (rank 0) should write to file. Author Michael Schl...
MBool m_isInitialized
Stores whether a stream was already opened or not.
void initialize(std::ostream *os, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool printDomainId=true)
Passes the parameters to a call of InfoOut_streamBuffer::initialize().
~InfoOutStream()
Destructor deletes the internal buffer object.
std::basic_string< char > MString
Namespace to hold all supported filetypes within the InfoOutFile.
const MInt MAIA_INFOOUT_SIMPLE_FILE
Use a physical file for each domain.
const MInt MAIA_INFOOUT_MPI_FILE
Use a single file for all domains (MPI I/O)