72 int mpi_mode = MPI_MODE_UNIQUE_OPEN;
74 if ((mode & W_OK) && (mode & R_OK))
75 mpi_mode |= MPI_MODE_RDWR;
77 mpi_mode |= MPI_MODE_WRONLY;
79 mpi_mode |= MPI_MODE_RDONLY;
81 int ret = MPI_File_open(MPI_COMM_SELF, path, mpi_mode,
103 int fd_mode = (int)0,
107 struct fileTypeStruct {
108 int globalSizes[2], localSizes[2], startIndices[2];
112 MPI_Info mpiHints = MPI_INFO_NULL;
114 fd = (MPI_File *) malloc(
sizeof(MPI_File));
116 ERR(
"malloc failed()");
123 fd_mode |= MPI_MODE_RDONLY;
126 fd_mode |= MPI_MODE_WRONLY;
129 fd_mode |= MPI_MODE_RDWR;
132 fd_mode |= MPI_MODE_APPEND;
135 fd_mode |= MPI_MODE_CREATE;
138 fd_mode |= MPI_MODE_EXCL;
141 fprintf(stdout,
"File truncation not implemented in MPIIO\n");
144 fprintf(stdout,
"O_DIRECT not implemented in MPIIO\n");
152 fd_mode |= MPI_MODE_UNIQUE_OPEN;
155 comm = MPI_COMM_SELF;
169 fprintf(stdout,
"\nhints passed to MPI_File_open() {\n");
171 fprintf(stdout,
"}\n");
173 MPI_CHECK(MPI_File_open(comm, testFileName, fd_mode, mpiHints, fd),
178 if (mpiHints != MPI_INFO_NULL)
179 MPI_CHECK(MPI_Info_free(&mpiHints),
"MPI_Info_free failed");
180 MPI_CHECK(MPI_File_get_info(*fd, &mpiHints),
181 "cannot get file info");
182 fprintf(stdout,
"\nhints returned from opened file {\n");
184 fprintf(stdout,
"}\n");
194 "cannot preallocate file");
202 "cannot create contiguous datatype");
204 "cannot commit datatype");
216 fileTypeStruct.globalSizes[0] = 1;
217 fileTypeStruct.globalSizes[1] =
218 transfersPerBlock * tasksPerFile;
219 fileTypeStruct.localSizes[0] = 1;
220 fileTypeStruct.localSizes[1] = transfersPerBlock;
221 fileTypeStruct.startIndices[0] = 0;
222 fileTypeStruct.startIndices[1] =
223 transfersPerBlock * offsetFactor;
226 (2, fileTypeStruct.globalSizes,
227 fileTypeStruct.localSizes,
228 fileTypeStruct.startIndices, MPI_ORDER_C,
230 "cannot create subarray");
232 "cannot commit datatype");
234 MPI_CHECK(MPI_File_set_view(*fd, (MPI_Offset) 0,
237 (MPI_Info) MPI_INFO_NULL),
238 "cannot set file view");
240 if (mpiHints != MPI_INFO_NULL)
241 MPI_CHECK(MPI_Info_free(&mpiHints),
"MPI_Info_free failed");
256 int (
MPIAPI * Access) (MPI_File,
void *, int,
257 MPI_Datatype, MPI_Status *);
258 int (
MPIAPI * Access_at) (MPI_File, MPI_Offset,
void *, int,
259 MPI_Datatype, MPI_Status *);
260 int (
MPIAPI * Access_all) (MPI_File,
void *, int,
261 MPI_Datatype, MPI_Status *);
262 int (
MPIAPI * Access_at_all) (MPI_File, MPI_Offset,
void *, int,
263 MPI_Datatype, MPI_Status *);
273 if (access ==
WRITE) {
274 Access = (int (
MPIAPI *)(MPI_File,
void *, int,
275 MPI_Datatype, MPI_Status *)) MPI_File_write;
276 Access_at = (int (
MPIAPI *)(MPI_File, MPI_Offset,
void *, int,
277 MPI_Datatype, MPI_Status *)) MPI_File_write_at;
278 Access_all = (int (
MPIAPI *) (MPI_File,
void *, int,
279 MPI_Datatype, MPI_Status *)) MPI_File_write_all;
280 Access_at_all = (int (
MPIAPI *) (MPI_File, MPI_Offset,
void *, int,
281 MPI_Datatype, MPI_Status *)) MPI_File_write_at_all;
288 Access = MPI_File_read;
289 Access_at = MPI_File_read_at;
290 Access_all = MPI_File_read_all;
291 Access_at_all = MPI_File_read_at_all;
323 (*(MPI_File *) fd, buffer, length,
325 "cannot access collective");
329 (*(MPI_File *) fd, buffer, length,
331 "cannot access noncollective");
343 (*(MPI_File *) fd, param->
offset, param) < 0) {
356 "useSharedFilePointer not implemented\n");
362 (*(MPI_File *) fd, param->
offset,
363 buffer, length, MPI_BYTE, &status),
364 "cannot access explicit, collective");
368 (*(MPI_File *) fd, param->
offset,
369 buffer, length, MPI_BYTE, &status),
370 "cannot access explicit, noncollective");
384 if (MPI_File_sync(*(MPI_File *)fdp) != MPI_SUCCESS)
385 EWARN(
"fsync() failed");
393 MPI_CHECK(MPI_File_close((MPI_File *) fd),
"cannot close file");
399 "cannot free MPI file datatype");
401 "cannot free MPI transfer datatype");
411 MPI_CHECK(MPI_File_delete(testFileName, (MPI_Info) MPI_INFO_NULL),
412 "cannot delete file");
420 static char ver[1024] = {};
421 int version, subversion;
422 MPI_CHECK(MPI_Get_version(&version, &subversion),
"cannot get MPI version");
423 sprintf(ver,
"(%d.%d)", version, subversion);
433 int offsetFactor, tasksPerFile;
458 + (((tempOffset % (param->
blockSize * tasksPerFile))
463 MPI_CHECK(MPI_File_seek(fd, tempOffset, MPI_SEEK_SET),
464 "cannot seek offset");
475 IOR_offset_t aggFileSizeFromStat, tmpMin, tmpMax, tmpSum;
480 comm = MPI_COMM_SELF;
485 MPI_CHECK(MPI_File_open(comm, testFileName, MPI_MODE_RDONLY,
487 "cannot open file to get file size");
488 MPI_CHECK(MPI_File_get_size(fd, (MPI_Offset *) & aggFileSizeFromStat),
489 "cannot get file size");
490 MPI_CHECK(MPI_File_close(&fd),
"cannot close file");
493 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpSum, 1,
494 MPI_LONG_LONG_INT, MPI_SUM, testComm),
495 "cannot total data moved");
496 aggFileSizeFromStat = tmpSum;
498 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMin, 1,
499 MPI_LONG_LONG_INT, MPI_MIN, testComm),
500 "cannot total data moved");
501 MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMax, 1,
502 MPI_LONG_LONG_INT, MPI_MAX, testComm),
503 "cannot total data moved");
504 if (tmpMin != tmpMax) {
506 WARN(
"inconsistent file size by different tasks");
509 aggFileSizeFromStat = tmpMin;
513 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)
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)