Skip to content

Commit 2758f5a

Browse files
committed
FLASH-IO: add command-line option -b to use blocking APIs
Make command-line option '-f prefix' a requirement Improve process of command-line arguments
1 parent b41a82c commit 2758f5a

File tree

3 files changed

+55
-38
lines changed

3 files changed

+55
-38
lines changed

benchmarks/FLASH-IO/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ and the I/O time of which dominates the entire benchmark.
4949
(this will use file base name prefix: "/pvfs2/flash_io_test_")
5050

5151
+ Command-line options:
52+
* [-h] print this message
5253
* [-q] quiet mode
53-
* [-i] use MPI independent I/O (default is collective I/O)
54+
* [-b] use PnetCDF blocking APIs (default: nonblocking)
55+
* [-i] use MPI independent I/O (default: collective)
56+
* -f prefix: output file prefix name (required)
57+
5458

5559
* Example output on screen:
5660
```c

benchmarks/FLASH-IO/flash_benchmark_io.F90

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ program flash_benchmark_io
2424
#endif
2525
integer i, argc, ierr
2626
character(len=128) executable
27+
character(len=8) opt
2728
logical verbose, isArgvRight
2829

2930
double precision time_io(3), time_begin
@@ -42,48 +43,46 @@ program flash_benchmark_io
4243
MasterPE = 0
4344
verbose = .TRUE.
4445
indep_io = .FALSE.
46+
use_nonblocking_io = .TRUE.
47+
basenm(1:1) = ''
4548

4649
! root process reads command-line arguments
4750
if (MyPE .EQ. MasterPE) then
4851
isArgvRight = .TRUE.
4952
argc = IARGC() ! IARGC() does not count the executable name
5053
call getarg(0, executable)
51-
if (argc .EQ. 0) then
52-
! default file name prefix
53-
basenm = "flash_io_test_"
54-
else if (argc .EQ. 1) then
55-
call getarg(1, basenm)
56-
if (basenm(1:2) .EQ. '-q') then
54+
do i=1, argc
55+
call getarg(i, opt)
56+
if (opt(1:2) .EQ. '-h') then
57+
isArgvRight = .FALSE.
58+
else if (opt(1:2) .EQ. '-q') then
5759
verbose = .FALSE.
58-
basenm = "flash_io_test_"
59-
else if (basenm(1:2) .EQ. '-i') then
60+
else if (opt(1:2) .EQ. '-b') then
61+
use_nonblocking_io = .FALSE.
62+
else if (opt(1:2) .EQ. '-i') then
6063
indep_io = .TRUE.
61-
basenm = "flash_io_test_"
62-
endif
63-
else if (argc .EQ. 2) then
64-
call getarg(1, basenm)
65-
if (basenm(1:2) .EQ. '-q') then
66-
verbose = .FALSE.
67-
call getarg(2, basenm)
68-
else if (basenm(1:2) .EQ. '-i') then
69-
indep_io = .TRUE.
70-
call getarg(2, basenm)
71-
else
72-
isArgvRight = .FALSE.
64+
else if (opt(1:2) .EQ. '-f') then
65+
call getarg(i+1, basenm)
66+
if (i .EQ. argc) then
67+
isArgvRight = .FALSE.
68+
else if (basenm(1:1) .EQ. '-') then
69+
isArgvRight = .FALSE.
70+
else if (LEN_TRIM(basenm(:)) .EQ. 0) then
71+
isArgvRight = .FALSE.
72+
endif
7373
endif
74-
else if (argc .EQ. 3) then
75-
call getarg(3, basenm)
76-
if (basenm(1:2) .EQ. '-q' .OR. basenm(1:2) .EQ. '-i') then
77-
isArgvRight = .FALSE.
78-
endif
79-
verbose = .FALSE.
80-
indep_io = .TRUE.
81-
else if (argc .GT. 2) then
82-
isArgvRight = .FALSE.
83-
endif
74+
enddo
75+
8476
if (.NOT. isArgvRight) then
77+
isArgvRight = .FALSE.
78+
i = INDEX(executable, "/", .TRUE.)
8579
print *, &
86-
'Usage: ',trim(executable),' [-q] <ouput file base name>'
80+
'Usage: ',trim(executable(i+1:)),' [-hqbi] -f <ouput file prefix name>'
81+
print *, ' -h: print this message'
82+
print *, ' -q: quiet mode'
83+
print *, ' -b: use PnetCDF blocking APIs (default: nonblocking)'
84+
print *, ' -i: use MPI independent I/O (default: collective)'
85+
print *, ' -f prefix: output file prefix name (required)'
8786
endif
8887
endif
8988

@@ -92,7 +91,11 @@ program flash_benchmark_io
9291
MPI_COMM_WORLD, ierr)
9392
if (.NOT. isArgvRight) goto 999
9493

95-
! broadcast if independent I/O should be used
94+
! broadcast whether nonblocking APIs should be used
95+
call MPI_Bcast(use_nonblocking_io, 1, MPI_LOGICAL, MasterPE, &
96+
MPI_COMM_WORLD, ierr)
97+
98+
! broadcast whether independent I/O should be used
9699
call MPI_Bcast(indep_io, 1, MPI_LOGICAL, MasterPE, &
97100
MPI_COMM_WORLD, ierr)
98101

@@ -119,9 +122,6 @@ program flash_benchmark_io
119122
neigh(:,:,:) = -1
120123
empty(:) = 0
121124

122-
! use nonblocking APIs
123-
use_nonblocking_io = .TRUE.
124-
125125
! initialize the unknowns with the index of the variable
126126
do i = 1, nvar
127127
unk(i,:,:,:,:) = float(i)
@@ -285,6 +285,19 @@ subroutine report_io_performance(verbose, local_blocks, time_io, &
285285
1006 format(I5, 3x, i3,' x ',i3,' x ',i3, 3x, F7.2 , 2x,F10.2 /)
286286
1007 format(A,A)
287287

288+
print 1004
289+
if (use_nonblocking_io) then
290+
print *,' Using PnetCDF nonblocking APIs'
291+
else
292+
print *,' Using PnetCDF blocking APIs'
293+
endif
294+
if (indep_io) then
295+
print *,' Using MPI independent I/O'
296+
else
297+
print *,' Using MPI collective I/O'
298+
endif
299+
print 1004
300+
print 1001,' number of guards : ',nguard
288301
print 1001,' number of guards : ',nguard
289302
print 1001,' number of blocks : ',local_blocks
290303
print 1001,' number of variables : ',nvar

benchmarks/FLASH-IO/parallel_run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ for i in ${check_PROGRAMS} ; do
3535
export PNETCDF_SAFE_MODE=$j
3636
# echo "set PNETCDF_SAFE_MODE ${PNETCDF_SAFE_MODE}"
3737

38-
${MPIRUN} ./$i -q ${TESTOUTDIR}/$i.
38+
${MPIRUN} ./$i -q -f ${TESTOUTDIR}/$i.
3939

4040
if test $? = 0 ; then
4141
echo "PASS: F90 parallel run on $1 processes --------------- $i"
@@ -55,7 +55,7 @@ for i in ${check_PROGRAMS} ; do
5555
# echo "test burst buffering feature"
5656
saved_PNETCDF_HINTS=${PNETCDF_HINTS}
5757
export PNETCDF_HINTS="${PNETCDF_HINTS};nc_burst_buf=enable;nc_burst_buf_dirname=${TESTOUTDIR};nc_burst_buf_overwrite=enable"
58-
${MPIRUN} ./$i -q ${TESTOUTDIR}/$i.bb.
58+
${MPIRUN} ./$i -q -f ${TESTOUTDIR}/$i.bb.
5959
if test $? = 0 ; then
6060
echo "PASS: F90 parallel run on $1 processes --------------- $i"
6161
fi

0 commit comments

Comments
 (0)