C++ mpi module for stochmagnet_main Package
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
MPI_IOFile Class Reference

This class manges the reading & writing in one file. More...

#include <MPI_IOFile.h>

Inheritance diagram for MPI_IOFile:
Inheritance graph
[legend]
Collaboration diagram for MPI_IOFile:
Collaboration graph
[legend]

Public Member Functions

 MPI_IOFile ()
 create a root environment
 
virtual ~MPI_IOFile (void)
 destroy
 
virtual tMemSize getMemorySize () const override
 return the memory size of the class
 
void setFileName (const tString &fn)
 set the file name More...
 
const tString & getFileName () const
 get the filename More...
 
const tMPIError & getError () const
 get the error of the last instruction
 
tMPIError setView (const MPI_View &view)
 set the view More...
 
tMPIError setView (const tMPIIOIndex &index, const MPI_View &view)
 set the view More...
 
tBoolean open (const MPI_Environment &env, const tMPIIOMode &mode)
 open the file for the environment More...
 
tBoolean close ()
 close the file
 
template<typename T >
tBoolean writeAt (const tMPIIOIndex &pos, const std::valarray< T > &values, tMPIStatus &status)
 write the value at individual core by explicit file cursor position with blocking action More...
 
template<typename T >
tBoolean iWriteAt (const tMPIIOIndex &pos, const std::valarray< T > &values, tMPIStatus &status)
 write the value at individual core by explicit file cursor position non blocking action More...
 
template<typename T >
tBoolean writeAll (const std::valarray< T > &values, tMPIStatus &status)
 write the value at shared core by explicit file cursor position with blocking action More...
 
tBoolean writeOrdered (const tString &str)
 write the value at shared core by explicit file cursor position with blocking action More...
 
template<typename T >
tBoolean writeOrdered (const std::valarray< T > &values)
 write the value at shared core by explicit file cursor position with blocking action More...
 
template<typename T >
tBoolean allWriteAt (const tMPIIOIndex &pos, const std::valarray< T > &values, tMPIStatus &status)
 write the value at shared core by explicit file cursor position with blocking action More...
 
template<typename T >
tBoolean iAllWriteAt (const tMPIIOIndex &pos, const std::valarray< T > &values, tMPIStatus &status)
 write the value at shared core by explicit file cursor position non blocking action More...
 
template<typename T >
tBoolean readAt (const tMPIIOIndex &pos, std::valarray< T > &values, tMPIStatus &status)
 read the value at individual core by epplicit file cursor position with blocking action More...
 
template<typename T >
tBoolean iReadAt (const tMPIIOIndex &pos, std::valarray< T > &values, tMPIRequest &request)
 read the value at individual core by explicit file cursor position with none blocking action More...
 
template<typename T >
tBoolean read (const tMPICount &n, T *values, tMPIStatus &status)
 read the value at individual core by implplicit file cursor position with blocking action More...
 
template<typename T >
tBoolean iRead (const tMPICount &n, T *values, tMPIRequest &request)
 read the value at individual core by implicit file cursor position with blocking action More...
 
template<typename T >
tBoolean allReadAt (const tMPIIOIndex &pos, std::valarray< T > &values, tMPIStatus &status)
 read the value at explicit shared position with blocking action More...
 
template<typename T >
tBoolean iAllReadAt (const tMPIIOIndex &pos, std::valarray< T > &values, tMPIRequest &request)
 read the value at explicit shared position with none blocking action More...
 
template<typename T >
tBoolean allRead (const tMPICount &n, T *values, tMPIStatus &status)
 read the value at implicit shared position with blocking action More...
 
template<typename T >
tBoolean allRead (std::valarray< T > &values, tMPIStatus &status)
 read the value at implicit shared position with blocking action More...
 
template<typename T >
tBoolean iAllRead (const tMPICount &n, T *values, tMPIRequest &request)
 read the value at implicit shared position with none blocking action More...
 
template<typename T >
tBoolean sharedRead (const tMPICount &n, T *values, tMPIStatus &status)
 read the value at implicit shared position and all the core execute the action randomly with blocking action. The shared cursor move at each call. More...
 
template<typename T >
tBoolean iSharedRead (const tMPICount &n, T *values, tMPIRequest &request)
 read the value at implicit shared position and all the core execute the action randomly with blocking action. The shared cursor move at each call. More...
 
template<typename T >
tBoolean orderedRead (const tMPICount &n, T *values, tMPIStatus &status)
 read the value at implicit shared position and all the core execute the action with respect of there core id with blocking action. The shared cursor move at each call. More...
 
template<typename T >
tBoolean orderedRead (std::valarray< T > &values, tMPIStatus &status)
 read the value at implicit shared position and all the core execute the action with respect of there core id with blocking action. The shared cursor move at each call. More...
 
template<typename T >
tBoolean iOrderedRead (const tMPICount &n, T *values, tMPIRequest &request)
 read the value at implicit shared position and all the core execute the action with respect of there core id with non blocking action More...
 
tBoolean getCorePosition (tMPIIOIndex &pos)
 
tBoolean setCorePosition (const tMPIIOIndex &pos)
 
tBoolean setCorePositionToEnd ()
 
tBoolean moveCorePosition (const tMPIIOIndex &dis)
 
tBoolean moveFromEndCorePosition (const tMPIIOIndex &dis)
 
tBoolean getEnvironmentPosition (tMPIIOIndex &pos)
 get th eposition of the pointer of the file shared by all core of the environment More...
 
tBoolean setEnvironmentPosition (const tMPIIOIndex &pos)
 get th eposition of the pointer of the file shared by all core of the environment More...
 
tBoolean setEnvironmentPositionToEnd ()
 
tBoolean moveEnvironmentPosition (const tMPIIOIndex &dis)
 
tBoolean moveFromEndEnvironmentPosition (const tMPIIOIndex &dis)
 
tBoolean getSize (tMPIIOIndex &s) const
 get the size of the file More...
 
void setErrorMode (const tMPIErrorMode &mode)
 set the error mode More...
 
tString printError () const
 print Error More...
 
- Public Member Functions inherited from CORE_Object
template<class T >
std::shared_ptr< T > getSharedPointer ()
 return the shared pointer for this More...
 
template<class T >
std::shared_ptr< const T > getConstSharedPointer () const
 return a const shared pointer for this More...
 
virtual tMemSize getContentsMemorySize () const
 return nthe memory size of the included associations More...
 
template<class T >
tBoolean isInstanceOf () const
 test if the clas T is an instance of this class More...
 
tString getClassName () const
 return the name of the class More...
 
tString getPointerString () const
 retrun the pointer of the class as a string More...
 
tString getIdentityString () const
 retrun the string identification of the class More...
 
virtual tString toString () const
 return the string representation of the object node More...
 

Static Public Member Functions

static CORE_UniquePointer< MPI_IOFileNew ()
 create a new instance of class within an unique pointer More...
 
static tBoolean Open (const MPI_Environment &env, const tString &fn, const tMPIIOMode &mode, tMPIIOFile &fdesc)
 open the file for the environment More...
 
static tMPIError Close (tMPIIOFile &f)
 close the file More...
 
- Static Public Member Functions inherited from CORE_Object
static tBoolean EnableMemoryStack (const tBoolean &isMemoryChecked)
 enable the memory stack More...
 
static void EnableMemoryStack ()
 enable the memory stack
 
static void DisableMemoryStack ()
 disable the memory stack
 
static tBoolean IsMemoryStackEnabled ()
 return trur if the memory stack is enabled
 
static tString MemoryStackToString ()
 get the memory stack in string More...
 
static tIndex GetRegisteredClassesNumber ()
 get the memory stack in string More...
 

Static Public Attributes

static const tMPIIOMode READ_ONLY =MPI_MODE_RDONLY
 read only mode
 
static const tMPIIOMode WRITE_ONLY =MPI_MODE_WRONLY
 write only mode
 
static const tMPIIOMode READ_WRITE =MPI_MODE_RDWR
 read and write mode
 
static const tMPIIOMode CREATE =MPI_MODE_CREATE
 file creation tag
 
static const tMPIErrorMode FATAL_ERROR =MPI_ERRORS_ARE_FATAL
 fatal error tag
 
static const tMPIErrorMode RETURN_ERROR =MPI_ERRORS_RETURN
 return error tag
 

Additional Inherited Members

- Protected Member Functions inherited from MPI_Object
 MPI_Object (void)
 create
 
virtual ~MPI_Object (void)
 destroy
 
- Protected Member Functions inherited from CORE_Object
 CORE_Object ()
 build an instance of the object
 
virtual ~CORE_Object ()
 destroy the instance of object std

 

Detailed Description

This class manges the reading & writing in one file.

A file can by managed by individualy operation with explicit individual file cursor position:

A file can by managed by individualy operation with implicit inidividual file cursor moving position by core:

A file can be read by by individualy operation with shared file shared cursor moving position

A file can by managed by shared operation with explicit file shared cursor moving position by core:

A file can by managed by shared operation with implicit file shared cursor moving position by core:

There is a corresponding version with none blocking acces with the method by adding i before the method name:

The explicit setting & getting individual core position are done with the methods:

The explicit setting & getting shared environment position are done with the methods:

An example of using :

Author
Stephane Despreaux
Version
2.0

Member Function Documentation

◆ allRead() [1/2]

template<typename T >
tBoolean MPI_IOFile::allRead ( const tMPICount &  n,
T *  values,
tMPIStatus &  status 
)
inline

read the value at implicit shared position with blocking action

Template Parameters
T: type of value to read
Parameters
[in]n: number of values to read
[out]values: values to read
[out]statusstatus of the reading

The acces are ordered with respect of the id of the core. This method is more efficient. An example:

◆ allRead() [2/2]

template<typename T >
tBoolean MPI_IOFile::allRead ( std::valarray< T > &  values,
tMPIStatus &  status 
)
inline

read the value at implicit shared position with blocking action

Parameters
[out]values: values to read
[out]statusstatus of the reading

The acces are ordered with respect of the id of the core. This method is more efficient. An example:

◆ allReadAt()

template<typename T >
tBoolean MPI_IOFile::allReadAt ( const tMPIIOIndex &  pos,
std::valarray< T > &  values,
tMPIStatus &  status 
)
inline

read the value at explicit shared position with blocking action

Template Parameters
T: type of value to read
Parameters
[in]pospos of the file to read
[out]values: values to read
[out]statusstatus of the read

The acces are ordered with respect of the id of the core. This method is more efficient. An example:

◆ allWriteAt()

template<typename T >
tBoolean MPI_IOFile::allWriteAt ( const tMPIIOIndex &  pos,
const std::valarray< T > &  values,
tMPIStatus &  status 
)
inline

write the value at shared core by explicit file cursor position with blocking action

Template Parameters
T: type of value to write
Parameters
[in]pospos of the file to write
[in]values: values to write
[out]statusstatus of the writing

An example: \imag html ioWriteAt.jpg

◆ Close()

static tMPIError MPI_IOFile::Close ( tMPIIOFile &  f)
inlinestatic

close the file

Parameters
[in]ffile to close

◆ getEnvironmentPosition()

tBoolean MPI_IOFile::getEnvironmentPosition ( tMPIIOIndex &  pos)
inline

get th eposition of the pointer of the file shared by all core of the environment

Parameters
[out]posenvironment position of the cursor on file

◆ getFileName()

const tString& MPI_IOFile::getFileName ( ) const
inline

get the filename

Returns
the file name

◆ getSize()

tBoolean MPI_IOFile::getSize ( tMPIIOIndex &  s) const
inline

get the size of the file

Parameters
[out]ssize of the file

◆ iAllRead()

template<typename T >
tBoolean MPI_IOFile::iAllRead ( const tMPICount &  n,
T *  values,
tMPIRequest &  request 
)
inline

read the value at implicit shared position with none blocking action

Template Parameters
T: type of value to read
Parameters
[in]n: number of values to read
[out]values: values to read
[out]statusstatus of the reading see MPI_IOFile::allRead()

◆ iAllReadAt()

template<typename T >
tBoolean MPI_IOFile::iAllReadAt ( const tMPIIOIndex &  pos,
std::valarray< T > &  values,
tMPIRequest &  request 
)
inline

read the value at explicit shared position with none blocking action

Template Parameters
T: type of value to read
Parameters
[in]pospos of the file to read
[out]values: values to read
[out]statusstatus of the read

Same metod as MPI_IOFile::allReadAt()

◆ iAllWriteAt()

template<typename T >
tBoolean MPI_IOFile::iAllWriteAt ( const tMPIIOIndex &  pos,
const std::valarray< T > &  values,
tMPIStatus &  status 
)
inline

write the value at shared core by explicit file cursor position non blocking action

Template Parameters
T: type of value to write
Parameters
[in]pospos of the file to write
[in]values: values to write
[out]statusstatus of the writing

the same method as EMM_FileIO::writeAt()

◆ iOrderedRead()

template<typename T >
tBoolean MPI_IOFile::iOrderedRead ( const tMPICount &  n,
T *  values,
tMPIRequest &  request 
)
inline

read the value at implicit shared position and all the core execute the action with respect of there core id with non blocking action

Template Parameters
T: type of value to read
Parameters
[in]n: number of values to read
[out]values: values to read
[out]requestrequest of the reading

see MPI_IOFile::orderedRead()

◆ iRead()

template<typename T >
tBoolean MPI_IOFile::iRead ( const tMPICount &  n,
T *  values,
tMPIRequest &  request 
)
inline

read the value at individual core by implicit file cursor position with blocking action

Parameters
[in]n: number of values to read
[out]values: values to read with sufficient memory size
[out]statusstatus of the writing

Same method as EMM_IOFile::read()

◆ iReadAt()

template<typename T >
tBoolean MPI_IOFile::iReadAt ( const tMPIIOIndex &  pos,
std::valarray< T > &  values,
tMPIRequest &  request 
)
inline

read the value at individual core by explicit file cursor position with none blocking action

Template Parameters
T: type of value to read
Parameters
[in]pospos of the file to read
[in]values: values to read
[out]requeststatus of the reading

Same method as EMM_IOFile::readAt()

◆ iSharedRead()

template<typename T >
tBoolean MPI_IOFile::iSharedRead ( const tMPICount &  n,
T *  values,
tMPIRequest &  request 
)
inline

read the value at implicit shared position and all the core execute the action randomly with blocking action. The shared cursor move at each call.

Template Parameters
T: type of value to read
Parameters
[in]n: number of values to read
[out]values: values to read
[out]statusstatus of the reading

The acces are ordered with respect of the id of the core. This method is more efficient. An example:

◆ iWriteAt()

template<typename T >
tBoolean MPI_IOFile::iWriteAt ( const tMPIIOIndex &  pos,
const std::valarray< T > &  values,
tMPIStatus &  status 
)
inline

write the value at individual core by explicit file cursor position non blocking action

Template Parameters
T: type of value to write
Parameters
[in]pospos of the file to write
[in]values: values to write
[out]statusstatus of the writing

the same method as EMM_FileIO::writeAt()

◆ New()

static CORE_UniquePointer<MPI_IOFile> MPI_IOFile::New ( )
inlinestatic

create a new instance of class within an unique pointer

Returns
a new uniqe pointer of this class

◆ open()

tBoolean MPI_IOFile::open ( const MPI_Environment env,
const tMPIIOMode &  mode 
)
inline

open the file for the environment

Parameters
[in]envenvironment of the process
[in]mode: mod of opening

◆ Open()

static tBoolean MPI_IOFile::Open ( const MPI_Environment env,
const tString &  fn,
const tMPIIOMode &  mode,
tMPIIOFile &  fdesc 
)
inlinestatic

open the file for the environment

Parameters
[in]envenvironment of the process
[in]fn: name of the file
[in]mode: mod of opening
[out]fdesc: file descriptor

◆ orderedRead() [1/2]

template<typename T >
tBoolean MPI_IOFile::orderedRead ( const tMPICount &  n,
T *  values,
tMPIStatus &  status 
)
inline

read the value at implicit shared position and all the core execute the action with respect of there core id with blocking action. The shared cursor move at each call.

Template Parameters
T: type of value to read
Parameters
[in]n: number of values to read
[out]values: values to read
[out]statusstatus of the reading

The acces are ordered with respect of the id of the core. This method is more efficient. An example:

◆ orderedRead() [2/2]

template<typename T >
tBoolean MPI_IOFile::orderedRead ( std::valarray< T > &  values,
tMPIStatus &  status 
)
inline

read the value at implicit shared position and all the core execute the action with respect of there core id with blocking action. The shared cursor move at each call.

Template Parameters
T: type of value to read
Parameters
[out]values: values to read
[out]statusstatus of the reading

The acces are ordered with respect of the id of the core. This method is more efficient. An example:

◆ printError()

tString MPI_IOFile::printError ( ) const
inline

print Error

Returns
the string reprensation of the error

◆ read()

template<typename T >
tBoolean MPI_IOFile::read ( const tMPICount &  n,
T *  values,
tMPIStatus &  status 
)
inline

read the value at individual core by implplicit file cursor position with blocking action

Template Parameters
T: type of value to read
Parameters
[in]n: number of values to read
[out]values: values to read with sufficient memory size
[out]statusstatus of the writing

an example

◆ readAt()

template<typename T >
tBoolean MPI_IOFile::readAt ( const tMPIIOIndex &  pos,
std::valarray< T > &  values,
tMPIStatus &  status 
)
inline

read the value at individual core by epplicit file cursor position with blocking action

Template Parameters
T: type of value to read
Parameters
[in]pospos of the file to read
[out]values: values to read
[out]statius: status of readind

an example

◆ setEnvironmentPosition()

tBoolean MPI_IOFile::setEnvironmentPosition ( const tMPIIOIndex &  pos)
inline

get th eposition of the pointer of the file shared by all core of the environment

Parameters
[out]posenvironment position of the cursor on file

◆ setErrorMode()

void MPI_IOFile::setErrorMode ( const tMPIErrorMode &  mode)
inline

set the error mode

Parameters
[in]modeerror mode

◆ setFileName()

void MPI_IOFile::setFileName ( const tString &  fn)
inline

set the file name

Parameters
[in]fn: name of the file

◆ setView() [1/2]

tMPIError MPI_IOFile::setView ( const MPI_View view)
inline

set the view

Parameters
[in]viewview to set at first element

◆ setView() [2/2]

tMPIError MPI_IOFile::setView ( const tMPIIOIndex &  index,
const MPI_View view 
)
inline

set the view

Parameters
[in]index: index to start the view
[in]viewview to set at index element

◆ sharedRead()

template<typename T >
tBoolean MPI_IOFile::sharedRead ( const tMPICount &  n,
T *  values,
tMPIStatus &  status 
)
inline

read the value at implicit shared position and all the core execute the action randomly with blocking action. The shared cursor move at each call.

Template Parameters
T: type of value to read
Parameters
[in]n: number of values to read
[out]values: values to read
[out]statusstatus of the reading

The acces are ordered with respect of the id of the core. This method is more efficient. An example:

◆ writeAll()

template<typename T >
tBoolean MPI_IOFile::writeAll ( const std::valarray< T > &  values,
tMPIStatus &  status 
)
inline

write the value at shared core by explicit file cursor position with blocking action

Template Parameters
T: type of value to write
Parameters
[in]values: values to write
[out]statusstatus of the writing

An example: \imag html ioWriteAt.jpg

◆ writeAt()

template<typename T >
tBoolean MPI_IOFile::writeAt ( const tMPIIOIndex &  pos,
const std::valarray< T > &  values,
tMPIStatus &  status 
)
inline

write the value at individual core by explicit file cursor position with blocking action

Template Parameters
T: type of value to write
Parameters
[in]pospos of the file to write
[in]values: values to write
[out]statusstatus of the writing

An example: \imag html ioWriteAt.jpg

◆ writeOrdered() [1/2]

template<typename T >
tBoolean MPI_IOFile::writeOrdered ( const std::valarray< T > &  values)
inline

write the value at shared core by explicit file cursor position with blocking action

Template Parameters
T: type of value to write
Parameters
[in]values: values to write

An example: \imag html ioWriteAt.jpg

◆ writeOrdered() [2/2]

tBoolean MPI_IOFile::writeOrdered ( const tString &  str)
inline

write the value at shared core by explicit file cursor position with blocking action

Parameters
[in]str: values to write

An example: \imag html ioWriteAt.jpg


The documentation for this class was generated from the following files: