Skip to content

Commit

Permalink
FLASH-IO: add command-line option -b to use blocking APIs
Browse files Browse the repository at this point in the history
Make command-line option '-f prefix' a requirement
Improve process of command-line arguments
  • Loading branch information
wkliao committed May 22, 2024
1 parent b41a82c commit 2758f5a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 38 deletions.
6 changes: 5 additions & 1 deletion benchmarks/FLASH-IO/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ and the I/O time of which dominates the entire benchmark.
(this will use file base name prefix: "/pvfs2/flash_io_test_")

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


* Example output on screen:
```c
Expand Down
83 changes: 48 additions & 35 deletions benchmarks/FLASH-IO/flash_benchmark_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ program flash_benchmark_io
#endif
integer i, argc, ierr
character(len=128) executable
character(len=8) opt
logical verbose, isArgvRight

double precision time_io(3), time_begin
Expand All @@ -42,48 +43,46 @@ program flash_benchmark_io
MasterPE = 0
verbose = .TRUE.
indep_io = .FALSE.
use_nonblocking_io = .TRUE.
basenm(1:1) = ''

! root process reads command-line arguments
if (MyPE .EQ. MasterPE) then
isArgvRight = .TRUE.
argc = IARGC() ! IARGC() does not count the executable name
call getarg(0, executable)
if (argc .EQ. 0) then
! default file name prefix
basenm = "flash_io_test_"
else if (argc .EQ. 1) then
call getarg(1, basenm)
if (basenm(1:2) .EQ. '-q') then
do i=1, argc
call getarg(i, opt)
if (opt(1:2) .EQ. '-h') then
isArgvRight = .FALSE.
else if (opt(1:2) .EQ. '-q') then
verbose = .FALSE.
basenm = "flash_io_test_"
else if (basenm(1:2) .EQ. '-i') then
else if (opt(1:2) .EQ. '-b') then
use_nonblocking_io = .FALSE.
else if (opt(1:2) .EQ. '-i') then
indep_io = .TRUE.
basenm = "flash_io_test_"
endif
else if (argc .EQ. 2) then
call getarg(1, basenm)
if (basenm(1:2) .EQ. '-q') then
verbose = .FALSE.
call getarg(2, basenm)
else if (basenm(1:2) .EQ. '-i') then
indep_io = .TRUE.
call getarg(2, basenm)
else
isArgvRight = .FALSE.
else if (opt(1:2) .EQ. '-f') then
call getarg(i+1, basenm)
if (i .EQ. argc) then
isArgvRight = .FALSE.
else if (basenm(1:1) .EQ. '-') then
isArgvRight = .FALSE.
else if (LEN_TRIM(basenm(:)) .EQ. 0) then
isArgvRight = .FALSE.
endif
endif
else if (argc .EQ. 3) then
call getarg(3, basenm)
if (basenm(1:2) .EQ. '-q' .OR. basenm(1:2) .EQ. '-i') then
isArgvRight = .FALSE.
endif
verbose = .FALSE.
indep_io = .TRUE.
else if (argc .GT. 2) then
isArgvRight = .FALSE.
endif
enddo

if (.NOT. isArgvRight) then
isArgvRight = .FALSE.
i = INDEX(executable, "/", .TRUE.)
print *, &
'Usage: ',trim(executable),' [-q] <ouput file base name>'
'Usage: ',trim(executable(i+1:)),' [-hqbi] -f <ouput file prefix name>'
print *, ' -h: print this message'
print *, ' -q: quiet mode'
print *, ' -b: use PnetCDF blocking APIs (default: nonblocking)'
print *, ' -i: use MPI independent I/O (default: collective)'
print *, ' -f prefix: output file prefix name (required)'
endif
endif

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

! broadcast if independent I/O should be used
! broadcast whether nonblocking APIs should be used
call MPI_Bcast(use_nonblocking_io, 1, MPI_LOGICAL, MasterPE, &
MPI_COMM_WORLD, ierr)

! broadcast whether independent I/O should be used
call MPI_Bcast(indep_io, 1, MPI_LOGICAL, MasterPE, &
MPI_COMM_WORLD, ierr)

Expand All @@ -119,9 +122,6 @@ program flash_benchmark_io
neigh(:,:,:) = -1
empty(:) = 0

! use nonblocking APIs
use_nonblocking_io = .TRUE.

! initialize the unknowns with the index of the variable
do i = 1, nvar
unk(i,:,:,:,:) = float(i)
Expand Down Expand Up @@ -285,6 +285,19 @@ subroutine report_io_performance(verbose, local_blocks, time_io, &
1006 format(I5, 3x, i3,' x ',i3,' x ',i3, 3x, F7.2 , 2x,F10.2 /)
1007 format(A,A)

print 1004
if (use_nonblocking_io) then
print *,' Using PnetCDF nonblocking APIs'
else
print *,' Using PnetCDF blocking APIs'
endif
if (indep_io) then
print *,' Using MPI independent I/O'
else
print *,' Using MPI collective I/O'
endif
print 1004
print 1001,' number of guards : ',nguard
print 1001,' number of guards : ',nguard
print 1001,' number of blocks : ',local_blocks
print 1001,' number of variables : ',nvar
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/FLASH-IO/parallel_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ for i in ${check_PROGRAMS} ; do
export PNETCDF_SAFE_MODE=$j
# echo "set PNETCDF_SAFE_MODE ${PNETCDF_SAFE_MODE}"

${MPIRUN} ./$i -q ${TESTOUTDIR}/$i.
${MPIRUN} ./$i -q -f ${TESTOUTDIR}/$i.

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

0 comments on commit 2758f5a

Please sign in to comment.