5 #include "MPI_Object.h"
8 #include "MPI_Environment.h"
14 #include "MPI_Error.h"
87 static const tMPIIOMode
CREATE=MPI_MODE_CREATE;
133 inline static CORE_UniquePointer<MPI_IOFile>
New() {
134 CORE_UniquePointer<MPI_IOFile> p(
new MPI_IOFile(),
170 return MPI_File_set_view(mFile,0,view.
getType(),view.
getMPIView(),
"native",MPI_INFO_NULL);
177 return MPI_File_set_view(mFile,index,view.
getType(),view.
getMPIView(),
"native",MPI_INFO_NULL);
189 mError=MPI_File_open(env.
getWorld(),mFileName.c_str(),mode,MPI_INFO_NULL,&mFile);
190 return (mError==MPI_SUCCESS);
201 const tString& fn,
const tMPIIOMode& mode,
203 return (MPI_File_open(env.
getWorld(),fn.c_str(),mode,MPI_INFO_NULL,&fdesc)==MPI_SUCCESS);
210 inline static tMPIError
Close(tMPIIOFile& f) {
211 return MPI_File_close(&f);
216 mError=MPI_File_close(&mFile);
217 return (mError==MPI_SUCCESS);
233 inline tBoolean
writeAt(
const tMPIIOIndex& pos,
const std::valarray<T>& values,tMPIStatus& status) {
234 mError=MPI_File_write_at(mFile,pos,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&status);
235 return (mError==MPI_SUCCESS);
246 inline tBoolean
iWriteAt(
const tMPIIOIndex& pos,
const std::valarray<T>& values,tMPIStatus& status) {
247 mError=MPI_File_iwrite_at(mFile,pos,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&status);
248 return (mError==MPI_SUCCESS);
261 inline tBoolean
writeAll(
const std::valarray<T>& values,tMPIStatus& status) {
262 mError=MPI_File_write_all(mFile,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&status);
263 return (mError==MPI_SUCCESS);
272 std::valarray<tUChar> values;
273 values.resize(str.length());
274 memcpy(&values[0],str.c_str(),
sizeof(tUChar)*values.size());
275 mError=MPI_File_write_ordered(mFile,&values[0],values.size(),MPI_Type::GetPrimaryType<tUChar>(),MPI_STATUS_IGNORE);
276 return (mError==MPI_SUCCESS);
288 mError=MPI_File_write_ordered(mFile,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),MPI_STATUS_IGNORE);
289 return (mError==MPI_SUCCESS);
304 inline tBoolean
allWriteAt(
const tMPIIOIndex& pos,
const std::valarray<T>& values,tMPIStatus& status) {
305 mError=MPI_File_write_at_all(mFile,pos,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&status);
306 return (mError==MPI_SUCCESS);
317 inline tBoolean
iAllWriteAt(
const tMPIIOIndex& pos,
const std::valarray<T>& values,tMPIStatus& status) {
318 mError=MPI_File_iwrite_at_all(mFile,pos,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&status);
319 return (mError==MPI_SUCCESS);
334 inline tBoolean
readAt(
const tMPIIOIndex& pos,std::valarray<T>& values,tMPIStatus& status) {
335 mError=MPI_File_read_at(mFile,pos,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&status);
336 return (mError==MPI_SUCCESS);
348 inline tBoolean
iReadAt(
const tMPIIOIndex& pos,std::valarray<T>& values,tMPIRequest& request) {
349 mError=MPI_File_iread_at(mFile,pos,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&request);
350 return (mError==MPI_SUCCESS);
362 inline tBoolean
read(
const tMPICount& n,T* values,tMPIStatus& status) {
363 mError=MPI_File_read(mFile,values,n,MPI_Type::GetPrimaryType<T>(),&status);
364 return (mError==MPI_SUCCESS);
375 inline tBoolean
iRead(
const tMPICount& n,T* values,tMPIRequest& request) {
376 mError=MPI_File_iread(mFile,values,n,MPI_Type::GetPrimaryType<T>(),&request);
377 return (mError==MPI_SUCCESS);
393 inline tBoolean
allReadAt(
const tMPIIOIndex& pos,std::valarray<T>& values,tMPIStatus& status) {
394 mError=MPI_File_read_at_all(mFile,pos,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&status);
395 return (mError==MPI_SUCCESS);
406 inline tBoolean
iAllReadAt(
const tMPIIOIndex& pos,std::valarray<T>& values,tMPIRequest& request) {
407 mError=MPI_File_iread_at_all(mFile,pos,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&request);
408 return (mError==MPI_SUCCESS);
421 inline tBoolean
allRead(
const tMPICount& n,T* values,tMPIStatus& status) {
422 mError=MPI_File_read_all(mFile,values,n,MPI_Type::GetPrimaryType<T>(),&status);
423 return (mError==MPI_SUCCESS);
433 inline tBoolean
allRead(std::valarray<T>& values,tMPIStatus& status) {
434 mError=MPI_File_read_all(mFile,&values[0],values.size(),MPI_Type::GetPrimaryType<T>(),&status);
435 return (mError==MPI_SUCCESS);
445 inline tBoolean
iAllRead(
const tMPICount& n,T* values,tMPIRequest& request) {
446 mError=MPI_File_iread_all(mFile,values,n,MPI_Type::GetPrimaryType<T>(),&request);
447 return (mError==MPI_SUCCESS);
461 inline tBoolean
sharedRead(
const tMPICount& n,T* values,tMPIStatus& status) {
462 mError=MPI_File_read_shared(mFile,values,n,MPI_Type::GetPrimaryType<T>(),&status);
463 return (mError==MPI_SUCCESS);
475 inline tBoolean
iSharedRead(
const tMPICount& n,T* values,tMPIRequest& request) {
476 mError=MPI_File_iread_shared(mFile,values,n,MPI_Type::GetPrimaryType<T>(),&request);
477 return (mError==MPI_SUCCESS);
490 inline tBoolean
orderedRead(
const tMPICount& n,T* values,tMPIStatus& status) {
491 mError=MPI_File_read_ordered(mFile,values,n,MPI_Type::GetPrimaryType<T>(),&status);
492 return (mError==MPI_SUCCESS);
503 inline tBoolean
orderedRead(std::valarray<T>& values,tMPIStatus& status) {
504 mError=MPI_File_read_ordered(mFile,values,values.size(),MPI_Type::GetPrimaryType<T>(),&status);
505 return (mError==MPI_SUCCESS);
516 inline tBoolean
iOrderedRead(
const tMPICount& n,T* values,tMPIRequest& request) {
517 mError=MPI_File_iread_ordered(mFile,values,n,MPI_Type::GetPrimaryType<T>(),&request);
518 return (mError==MPI_SUCCESS);
527 tBoolean getCorePosition(tMPIIOIndex& pos) {
528 mError=MPI_File_get_position(mFile,&pos);
529 return (mError==MPI_SUCCESS);
535 tBoolean setCorePosition(
const tMPIIOIndex& pos) {
536 mError=MPI_File_seek(mFile,pos,MPI_SEEK_SET);
537 return (mError==MPI_SUCCESS);
542 tBoolean setCorePositionToEnd() {
543 mError=MPI_File_seek(mFile,0,MPI_SEEK_END);
544 return (mError==MPI_SUCCESS);
549 tBoolean moveCorePosition(
const tMPIIOIndex& dis) {
550 mError=MPI_File_seek(mFile,dis,MPI_SEEK_CUR);
551 return (mError==MPI_SUCCESS);
556 tBoolean moveFromEndCorePosition(
const tMPIIOIndex& dis) {
557 mError=MPI_File_seek(mFile,dis,MPI_SEEK_END);
558 return (mError==MPI_SUCCESS);
565 mError=MPI_File_get_position_shared(mFile,&pos);
566 return (mError==MPI_SUCCESS);
573 mError=MPI_File_seek_shared(mFile,pos,MPI_SEEK_SET);
574 return (mError==MPI_SUCCESS);
579 tBoolean setEnvironmentPositionToEnd() {
580 mError=MPI_File_seek_shared(mFile,0,MPI_SEEK_END);
581 return (mError==MPI_SUCCESS);
586 tBoolean moveEnvironmentPosition(
const tMPIIOIndex& dis) {
587 mError=MPI_File_seek_shared(mFile,dis,MPI_SEEK_CUR);
588 return (mError==MPI_SUCCESS);
593 tBoolean moveFromEndEnvironmentPosition(
const tMPIIOIndex& dis) {
594 mError=MPI_File_seek_shared(mFile,dis,MPI_SEEK_END);
595 return (mError==MPI_SUCCESS);
602 inline tBoolean
getSize(tMPIIOIndex& s)
const {
603 return (MPI_File_get_size(mFile,&s)==MPI_SUCCESS);
614 MPI_File_set_errhandler(mFile,mode);
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
This class is a Environment class to define MPI world.
Definition: MPI_Environment.h:36
const tMPIComm & getWorld() const
get the world of the environment for reading
Definition: MPI_Environment.h:165
static tString ToString(const tMPIError &err)
get the string representation of the error
Definition: MPI_Error.h:45
This class manges the reading & writing in one file.
Definition: MPI_IOFile.h:72
static const tMPIIOMode READ_WRITE
read and write mode
Definition: MPI_IOFile.h:84
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
Definition: MPI_IOFile.h:317
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
Definition: MPI_IOFile.h:304
const tString & getFileName() const
get the filename
Definition: MPI_IOFile.h:157
void setErrorMode(const tMPIErrorMode &mode)
set the error mode
Definition: MPI_IOFile.h:613
static tBoolean Open(const MPI_Environment &env, const tString &fn, const tMPIIOMode &mode, tMPIIOFile &fdesc)
open the file for the environment
Definition: MPI_IOFile.h:200
tBoolean allRead(const tMPICount &n, T *values, tMPIStatus &status)
read the value at implicit shared position with blocking action
Definition: MPI_IOFile.h:421
static CORE_UniquePointer< MPI_IOFile > New()
create a new instance of class within an unique pointer
Definition: MPI_IOFile.h:133
tBoolean close()
close the file
Definition: MPI_IOFile.h:215
static tMPIError Close(tMPIIOFile &f)
close the file
Definition: MPI_IOFile.h:210
tMPIError setView(const tMPIIOIndex &index, const MPI_View &view)
set the view
Definition: MPI_IOFile.h:176
tBoolean read(const tMPICount &n, T *values, tMPIStatus &status)
read the value at individual core by implplicit file cursor position with blocking action
Definition: MPI_IOFile.h:362
MPI_IOFile()
create a root environment
Definition: MPI_IOFile.h:109
tBoolean iAllReadAt(const tMPIIOIndex &pos, std::valarray< T > &values, tMPIRequest &request)
read the value at explicit shared position with none blocking action
Definition: MPI_IOFile.h:406
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
Definition: MPI_IOFile.h:246
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 ...
Definition: MPI_IOFile.h:490
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...
Definition: MPI_IOFile.h:475
tBoolean open(const MPI_Environment &env, const tMPIIOMode &mode)
open the file for the environment
Definition: MPI_IOFile.h:187
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...
Definition: MPI_IOFile.h:461
virtual tMemSize getMemorySize() const override
return the memory size of the class
Definition: MPI_IOFile.h:124
tString printError() const
print Error
Definition: MPI_IOFile.h:619
const tMPIError & getError() const
get the error of the last instruction
Definition: MPI_IOFile.h:162
tBoolean getEnvironmentPosition(tMPIIOIndex &pos)
get th eposition of the pointer of the file shared by all core of the environment
Definition: MPI_IOFile.h:564
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 ...
Definition: MPI_IOFile.h:503
tBoolean iAllRead(const tMPICount &n, T *values, tMPIRequest &request)
read the value at implicit shared position with none blocking action
Definition: MPI_IOFile.h:445
tBoolean getSize(tMPIIOIndex &s) const
get the size of the file
Definition: MPI_IOFile.h:602
tBoolean iRead(const tMPICount &n, T *values, tMPIRequest &request)
read the value at individual core by implicit file cursor position with blocking action
Definition: MPI_IOFile.h:375
tBoolean allReadAt(const tMPIIOIndex &pos, std::valarray< T > &values, tMPIStatus &status)
read the value at explicit shared position with blocking action
Definition: MPI_IOFile.h:393
static const tMPIIOMode READ_ONLY
read only mode
Definition: MPI_IOFile.h:78
tBoolean writeAll(const std::valarray< T > &values, tMPIStatus &status)
write the value at shared core by explicit file cursor position with blocking action
Definition: MPI_IOFile.h:261
static const tMPIErrorMode RETURN_ERROR
return error tag
Definition: MPI_IOFile.h:93
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
Definition: MPI_IOFile.h:233
static const tMPIIOMode CREATE
file creation tag
Definition: MPI_IOFile.h:87
void setFileName(const tString &fn)
set the file name
Definition: MPI_IOFile.h:150
tBoolean allRead(std::valarray< T > &values, tMPIStatus &status)
read the value at implicit shared position with blocking action
Definition: MPI_IOFile.h:433
virtual ~MPI_IOFile(void)
destroy
Definition: MPI_IOFile.h:117
tMPIError setView(const MPI_View &view)
set the view
Definition: MPI_IOFile.h:169
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
Definition: MPI_IOFile.h:334
tBoolean setEnvironmentPosition(const tMPIIOIndex &pos)
get th eposition of the pointer of the file shared by all core of the environment
Definition: MPI_IOFile.h:572
static const tMPIErrorMode FATAL_ERROR
fatal error tag
Definition: MPI_IOFile.h:90
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 ...
Definition: MPI_IOFile.h:516
tBoolean writeOrdered(const std::valarray< T > &values)
write the value at shared core by explicit file cursor position with blocking action
Definition: MPI_IOFile.h:287
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
Definition: MPI_IOFile.h:348
tBoolean writeOrdered(const tString &str)
write the value at shared core by explicit file cursor position with blocking action
Definition: MPI_IOFile.h:271
static const tMPIIOMode WRITE_ONLY
write only mode
Definition: MPI_IOFile.h:81
This class is a base class of E-MicromM core package.
Definition: MPI_Object.h:32
This class describes a view as follow:
Definition: MPI_View.h:20
const tMPIType & getType() const
get the type of the element of the view
Definition: MPI_View.h:75
const tMPIView & getMPIView() const
get the mpi view of the view
Definition: MPI_View.h:80