-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented use of iterations for longer tests
- Loading branch information
1 parent
cf1c7e0
commit d0c978d
Showing
1 changed file
with
45 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,59 @@ | ||
/** Example in which every process writes its own data | ||
* via POSIX I/O **/ | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <errno.h> | ||
#include <limits.h> | ||
#include <assert.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <unistd.h> | ||
#include "omp.h" | ||
|
||
#include "mpi.h" | ||
#include <stdio.h> | ||
#define BUFSIZE 100 | ||
|
||
void usage (void) { | ||
printf("USAGE: mpirun mpi_file_io [ITERATIONS]\n"); | ||
printf(" \n"); | ||
printf("Runs MPI File I/O tests on mpi_file_io. If the optional ITERATIONS\n"); | ||
printf("is not specified, this will indefinitely write into file mpi_fil_io.txt\n"); | ||
printf("filling up Your file-system.\n"); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
int main(int argc, char *argv[]){ | ||
int max_iterations = INT_MAX; // Iterate indefinitely | ||
|
||
if (argc > 1) { | ||
char * endptr; | ||
max_iterations = strtol(argv[1], &endptr, 10); | ||
if (*endptr != '\0' || max_iterations < 0) | ||
usage(); | ||
} | ||
|
||
int i, rank, buf[BUFSIZE]; | ||
char filename[128]; | ||
FILE *file; | ||
for (int j = 0; j < max_iterations; j++) { | ||
int i, rank, buf[BUFSIZE]; | ||
char filename[128]; | ||
FILE *file; | ||
|
||
MPI_Init(&argc, &argv); | ||
MPI_Init(&argc, &argv); | ||
|
||
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | ||
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | ||
|
||
for (i=0; i<BUFSIZE; i++){ | ||
buf[i] = rank * BUFSIZE + i; | ||
} | ||
for (i=0; i<BUFSIZE; i++){ | ||
buf[i] = rank * BUFSIZE + i; | ||
} | ||
|
||
sprintf(filename, "testfile.%d", rank); | ||
file = fopen(filename, "w"); | ||
fwrite(buf, sizeof(int), BUFSIZE, file); | ||
fclose(file); | ||
sprintf(filename, "testfile.%d", rank); | ||
file = fopen(filename, "w"); | ||
fwrite(buf, sizeof(int), BUFSIZE, file); | ||
fclose(file); | ||
|
||
MPI_Finalize(); | ||
|
||
return 0; | ||
} | ||
MPI_Finalize(); | ||
|
||
return 0; | ||
} | ||
} |