76 int mpi_mode = MPI_MODE_UNIQUE_OPEN;
77 MPI_Info mpiHints = MPI_INFO_NULL;
79 if ((mode & W_OK) && (mode & R_OK))
80 mpi_mode |= MPI_MODE_RDWR;
82 mpi_mode |= MPI_MODE_WRONLY;
84 mpi_mode |= MPI_MODE_RDONLY;
88 int ret = MPI_File_open(MPI_COMM_SELF, path, mpi_mode, mpiHints, &fd);
93 if (mpiHints != MPI_INFO_NULL)
94 MPI_CHECK(MPI_Info_free(&mpiHints),
"MPI_Info_free failed");
114 int fd_mode = (int)0,
118 struct fileTypeStruct {
119 int globalSizes[2], localSizes[2], startIndices[2];
123 MPI_Info mpiHints = MPI_INFO_NULL;
125 fd = (MPI_File *) malloc(
sizeof(MPI_File));
127 ERR(
"malloc failed()");
134 fd_mode |= MPI_MODE_RDONLY;
137 fd_mode |= MPI_MODE_WRONLY;
140 fd_mode |= MPI_MODE_RDWR;
143 fd_mode |= MPI_MODE_APPEND;
146 fd_mode |= MPI_MODE_CREATE;
149 fd_mode |= MPI_MODE_EXCL;
152 fprintf(stdout,
"File truncation not implemented in MPIIO\n");
155 fprintf(stdout,
"O_DIRECT not implemented in MPIIO\n");
163 fd_mode |= MPI_MODE_UNIQUE_OPEN;
166 comm = MPI_COMM_SELF;
180 fprintf(stdout,
"\nhints passed to MPI_File_open() {\n");
182 fprintf(stdout,
"}\n");
185 MPI_CHECKF(MPI_File_open(comm, testFileName, fd_mode, mpiHints, fd),
186 "cannot open file: %s", testFileName);
191 if (mpiHints != MPI_INFO_NULL)
192 MPI_CHECK(MPI_Info_free(&mpiHints),
"MPI_Info_free failed");
193 MPI_CHECK(MPI_File_get_info(*fd, &mpiHints),
194 "cannot get file info");
195 fprintf(stdout,
"\nhints returned from opened file {\n");
197 fprintf(stdout,
"}\n");
207 "cannot preallocate file");
215 "cannot create contiguous datatype");
217 "cannot commit datatype");
229 fileTypeStruct.globalSizes[0] = 1;
230 fileTypeStruct.globalSizes[1] =
231 transfersPerBlock * tasksPerFile;
232 fileTypeStruct.localSizes[0] = 1;
233 fileTypeStruct.localSizes[1] = transfersPerBlock;
234 fileTypeStruct.startIndices[0] = 0;
235 fileTypeStruct.startIndices[1] =
236 transfersPerBlock * offsetFactor;
239 (2, fileTypeStruct.globalSizes,
240 fileTypeStruct.localSizes,
241 fileTypeStruct.startIndices, MPI_ORDER_C,
243 "cannot create subarray");
245 "cannot commit datatype");
248 MPI_CHECK(MPI_File_set_view(*fd, (MPI_Offset) 0,
251 (MPI_Info) MPI_INFO_NULL),
252 "cannot set file view");
255 if (mpiHints != MPI_INFO_NULL)
256 MPI_CHECK(MPI_Info_free(&mpiHints),
"MPI_Info_free failed");
274 int (
MPIAPI * Access) (MPI_File,
void *, int,
275 MPI_Datatype, MPI_Status *);
276 int (
MPIAPI * Access_at) (MPI_File, MPI_Offset,
void *, int,
277 MPI_Datatype, MPI_Status *);
278 int (
MPIAPI * Access_all) (MPI_File,
void *, int,
279 MPI_Datatype, MPI_Status *);
280 int (
MPIAPI * Access_at_all) (MPI_File, MPI_Offset,
void *, int,
281 MPI_Datatype, MPI_Status *);
291 if (access ==
WRITE) {
292 Access = (int (
MPIAPI *)(MPI_File,
void *, int,
293 MPI_Datatype, MPI_Status *)) MPI_File_write;
294 Access_at = (int (
MPIAPI *)(MPI_File, MPI_Offset,
void *, int,
295 MPI_Datatype, MPI_Status *)) MPI_File_write_at;
296 Access_all = (int (
MPIAPI *) (MPI_File,
void *, int,
297 MPI_Datatype, MPI_Status *)) MPI_File_write_all;
298 Access_at_all = (int (
MPIAPI *) (MPI_File, MPI_Offset,
void *, int,
299 MPI_Datatype, MPI_Status *)) MPI_File_write_at_all;
306 Access = MPI_File_read;
307 Access_at = MPI_File_read_at;
308 Access_all = MPI_File_read_all;
309 Access_at_all = MPI_File_read_at_all;
341 (*(MPI_File *) fd, buffer, length,
343 "cannot access collective");
347 (*(MPI_File *) fd, buffer, length,
349 "cannot access noncollective");
361 (*(MPI_File *) fd, param->
offset, param) < 0) {
374 "useSharedFilePointer not implemented\n");
380 (*(MPI_File *) fd, param->
offset,
381 buffer, length, MPI_BYTE, &status),
382 "cannot access explicit, collective");
386 (*(MPI_File *) fd, param->
offset,
387 buffer, length, MPI_BYTE, &status),
388 "cannot access explicit, noncollective");
404 if (MPI_File_sync(*(MPI_File *)fdp) != MPI_SUCCESS)
405 EWARN(
"fsync() failed");
414 MPI_CHECK(MPI_File_close((MPI_File *) fd),
"cannot close file");
421 "cannot free MPI file datatype");
423 "cannot free MPI transfer datatype");
435 MPI_CHECKF(MPI_File_delete(testFileName, (MPI_Info) MPI_INFO_NULL),
436 "cannot delete file: %s", testFileName);
444 static char ver[1024] = {};
445 int version, subversion;
446 MPI_CHECK(MPI_Get_version(&version, &subversion),
"cannot get MPI version");
447 sprintf(ver,
"(%d.%d)", version, subversion);
457 int offsetFactor, tasksPerFile;
482 + (((tempOffset % (param->
blockSize * tasksPerFile))
487 MPI_CHECK(MPI_File_seek(fd, tempOffset, MPI_SEEK_SET),
488 "cannot seek offset");
501 IOR_offset_t aggFileSizeFromStat, tmpMin, tmpMax, tmpSum;
504 MPI_Info mpiHints = MPI_INFO_NULL;
507 comm = MPI_COMM_SELF;
513 MPI_CHECK(MPI_File_open(comm, testFileName, MPI_MODE_RDONLY,
515 "cannot open file to get file size");
516 MPI_CHECK(MPI_File_get_size(fd, (MPI_Offset *) & aggFileSizeFromStat),
517 "cannot get file size");
518 MPI_CHECK(MPI_File_close(&fd),
"cannot close file");
519 if (mpiHints != MPI_INFO_NULL)
520 MPI_CHECK(MPI_Info_free(&mpiHints),
"MPI_Info_free failed");
523 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpSum, 1,
524 MPI_LONG_LONG_INT, MPI_SUM, testComm),
525 "cannot total data moved");
526 aggFileSizeFromStat = tmpSum;
528 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMin, 1,
529 MPI_LONG_LONG_INT, MPI_MIN, testComm),
530 "cannot total data moved");
531 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMax, 1,
532 MPI_LONG_LONG_INT, MPI_MAX, testComm),
533 "cannot total data moved");
534 if (tmpMin != tmpMax) {
536 WARN(
"inconsistent file size by different tasks");
539 aggFileSizeFromStat = tmpMin;
543 return (aggFileSizeFromStat);
void ShowHints(MPI_Info *mpiHints)
IOR_offset_t segmentCount
IOR_offset_t transferSize
int aiori_posix_rmdir(const char *path, IOR_param_t *param)
MPI_Datatype transferType
int aiori_posix_mkdir(const char *path, mode_t mode, IOR_param_t *param)
#define MPI_CHECKF(MPI_STATUS, FORMAT,...)
int aiori_posix_statfs(const char *path, ior_aiori_statfs_t *stat_buf, IOR_param_t *param)
static void * MPIIO_Create(char *, IOR_param_t *)
#define MPI_CHECK(MPI_STATUS, MSG)
static IOR_offset_t MPIIO_Xfer(int, void *, IOR_size_t *, IOR_offset_t, IOR_param_t *)
void MPIIO_Delete(char *testFileName, IOR_param_t *param)
static IOR_offset_t SeekOffset(MPI_File, IOR_offset_t, IOR_param_t *)
int MPIIO_Access(const char *path, int mode, IOR_param_t *param)
static char * MPIIO_GetVersion()
static void MPIIO_Fsync(void *, IOR_param_t *)
static void MPIIO_Close(void *, IOR_param_t *)
static void * MPIIO_Open(char *, IOR_param_t *)
int aiori_posix_stat(const char *path, struct stat *buf, IOR_param_t *param)
void SetHints(MPI_Info *mpiHints, char *hintsFileName)
long long int IOR_offset_t
IOR_offset_t MPIIO_GetFileSize(IOR_param_t *test, MPI_Comm testComm, char *testFileName)