31 public :: prof_papi_rapstart
32 public :: prof_papi_rapstop
33 public :: prof_papi_rapreport
50 integer,
private,
parameter :: prof_rapnlimit = 300
51 character(len=H_SHORT),
private :: prof_prefix =
'' 52 integer,
private :: prof_rapnmax = 0
53 character(len=H_SHORT*2),
private :: prof_rapname(prof_rapnlimit)
54 integer,
private :: prof_grpnmax = 0
55 character(len=H_SHORT),
private :: prof_grpname(prof_rapnlimit)
56 integer,
private :: prof_grpid (prof_rapnlimit)
57 real(DP),
private :: prof_raptstr(prof_rapnlimit)
58 real(DP),
private :: prof_rapttot(prof_rapnlimit)
59 integer,
private :: prof_rapnstr(prof_rapnlimit)
60 integer,
private :: prof_rapnend(prof_rapnlimit)
61 integer,
private :: prof_raplevel(prof_rapnlimit)
63 integer,
private,
parameter :: prof_default_rap_level = 2
64 integer,
private :: prof_rap_level = 2
65 logical,
private :: prof_mpi_barrier = .false.
68 integer(DP),
private :: prof_papi_flops = 0
69 real(SP),
private :: prof_papi_real_time = 0.0
70 real(SP),
private :: prof_papi_proc_time = 0.0
71 real(SP),
private :: prof_papi_mflops = 0.0
72 integer,
private :: prof_papi_check
83 namelist / param_prof / &
90 if(
io_l )
write(
io_fid_log,*)
'++++++ Module[PROF] / Categ[COMMON] / Origin[SCALElib]' 96 if(
io_l )
write(
io_fid_log,*)
'*** Not found namelist. Default used.' 97 elseif( ierr > 0 )
then 98 write(*,*)
'xxx Not appropriate names in namelist PARAM_PROF. Check!' 103 if(
io_l )
write(
io_fid_log,*)
'*** Rap output level = ', prof_rap_level
104 if(
io_l )
write(
io_fid_log,*)
'*** Add MPI_barrier in every rap? = ', prof_mpi_barrier
116 character(len=*),
intent(in) :: prefxname
120 if ( prefxname ==
'' )
then 123 prof_prefix = trim(prefxname)//
'_' 137 character(len=*),
intent(in) :: rapname_base
138 integer,
intent(in),
optional :: level
140 character(len=H_SHORT*2) :: rapname
146 if (
present(level) )
then 149 level_ = prof_default_rap_level
152 if( level_ > prof_rap_level )
return 154 rapname = trim(prof_prefix)//trim(rapname_base)
156 id = get_rapid( rapname, level_ )
161 prof_rapnstr(id) = prof_rapnstr(id) + 1
166 call fapp_start( trim(prof_grpname(get_grpid(rapname))), id, level_ )
169 call start_collection( rapname )
183 character(len=*),
intent(in) :: rapname_base
184 integer,
intent(in),
optional :: level
186 character(len=H_SHORT*2) :: rapname
192 if (
present(level) )
then 193 if( level > prof_rap_level )
return 196 rapname = trim(prof_prefix)//trim(rapname_base)
198 id = get_rapid( rapname, level_ )
200 if( level_ > prof_rap_level )
return 204 prof_rapttot(id) = prof_rapttot(id) + (
prc_mpitime()-prof_raptstr(id) )
205 prof_rapnend(id) = prof_rapnend(id) + 1
208 call stop_collection( rapname )
211 call fapp_stop( trim(prof_grpname(prof_grpid(id))), id, level_ )
225 real(DP) :: avgvar(prof_rapnlimit)
226 real(DP) :: maxvar(prof_rapnlimit)
227 real(DP) :: minvar(prof_rapnlimit)
228 integer :: maxidx(prof_rapnlimit)
229 integer :: minidx(prof_rapnlimit)
235 do id = 1, prof_rapnmax
236 if ( prof_rapnstr(id) /= prof_rapnend(id) )
then 237 write(*,*)
'*** Mismatch Report',id,prof_rapname(id),prof_rapnstr(id),prof_rapnend(id)
243 if(
io_l )
write(
io_fid_log,*)
'*** Rap level is ', prof_rap_level
247 do gid = 1, prof_rapnmax
248 do id = 1, prof_rapnmax
249 if ( prof_raplevel(id) <= prof_rap_level .AND. &
250 prof_grpid(id) == gid .AND. &
252 write(
io_fid_log,
'(1x,A,I3.3,A,A,A,F10.3,A,I9)') &
253 '*** ID=',id,
' : ',prof_rapname(id),
' T=',prof_rapttot(id),
' N=',prof_rapnstr(id)
261 maxvar(1:prof_rapnmax), &
262 minvar(1:prof_rapnmax), &
263 maxidx(1:prof_rapnmax), &
264 minidx(1:prof_rapnmax), &
265 prof_rapttot(1:prof_rapnmax) )
270 write(*,*)
'*** Computational Time Report' 277 do gid = 1, prof_rapnmax
278 do id = 1, prof_rapnmax
279 if ( prof_raplevel(id) <= prof_rap_level .AND. &
280 prof_grpid(id) == gid .AND. &
282 write(
io_fid_log,
'(1x,A,I3.3,A,A,A,F10.3,A,F10.3,A,I5,A,A,F10.3,A,I5,A,A,I9)') &
283 '*** ID=',id,
' : ',prof_rapname(id), &
284 ' T(avg)=',avgvar(id), &
285 ', T(max)=',maxvar(id),
'[',maxidx(id),
']', &
286 ', T(min)=',minvar(id),
'[',minidx(id),
']', &
287 ' N=',prof_rapnstr(id)
300 subroutine prof_papi_rapstart
304 call papif_flops( prof_papi_real_time, prof_papi_proc_time, prof_papi_flops, prof_papi_mflops, prof_papi_check )
307 end subroutine prof_papi_rapstart
311 subroutine prof_papi_rapstop
315 call papif_flops( prof_papi_real_time, prof_papi_proc_time, prof_papi_flops, prof_papi_mflops, prof_papi_check )
318 end subroutine prof_papi_rapstop
322 subroutine prof_papi_rapreport
329 real(DP) :: avgvar(3)
330 real(DP) :: maxvar(3)
331 real(DP) :: minvar(3)
335 real(DP) :: PROF_PAPI_gflop
336 real(DP) :: statistics(3)
339 prof_papi_gflop =
real(PROF_PAPI_flops,kind=8) / 1024.0_DP**3
344 if(
io_l )
write(
io_fid_log,*)
'*** PAPI Report [Local PE information]' 345 if(
io_l )
write(
io_fid_log,
'(1x,A,F15.3)')
'*** Real time [sec] : ', prof_papi_real_time
346 if(
io_l )
write(
io_fid_log,
'(1x,A,F15.3)')
'*** CPU time [sec] : ', prof_papi_proc_time
347 if(
io_l )
write(
io_fid_log,
'(1x,A,F15.3)')
'*** FLOP [GFLOP] : ', prof_papi_gflop
348 if(
io_l )
write(
io_fid_log,
'(1x,A,F15.3)')
'*** FLOPS by PAPI [GFLOPS] : ', prof_papi_mflops/1024.0_dp
349 if(
io_l )
write(
io_fid_log,
'(1x,A,F15.3)')
'*** FLOP / CPU Time [GFLOPS] : ', prof_papi_gflop/prof_papi_proc_time
352 statistics(1) =
real(prof_papi_real_time,kind=8)
353 statistics(2) =
real(prof_papi_proc_time,kind=8)
354 statistics(3) = prof_papi_gflop
365 if(
io_l )
write(
io_fid_log,
'(1x,A,A,F10.3,A,F10.3,A,I5,A,A,F10.3,A,I5,A,A,I7)') &
366 '*** Real time [sec]',
' T(avg)=',avgvar(1), &
367 ', T(max)=',maxvar(1),
'[',maxidx(1),
']',
', T(min)=',minvar(1),
'[',minidx(1),
']' 368 if(
io_l )
write(
io_fid_log,
'(1x,A,A,F10.3,A,F10.3,A,I5,A,A,F10.3,A,I5,A,A,I7)') &
369 '*** CPU time [sec]',
' T(avg)=',avgvar(2), &
370 ', T(max)=',maxvar(2),
'[',maxidx(2),
']',
', T(min)=',minvar(2),
'[',minidx(2),
']' 371 if(
io_l )
write(
io_fid_log,
'(1x,A,A,F10.3,A,F10.3,A,I5,A,A,F10.3,A,I5,A,A,I7)') &
372 '*** FLOP [GFLOP]',
' N(avg)=',avgvar(3), &
373 ', N(max)=',maxvar(3),
'[',maxidx(3),
']',
', N(min)=',minvar(3),
'[',minidx(3),
']' 378 '*** FLOPS [GFLOPS] : ', avgvar(3)*
prc_nprocs/maxvar(2)
380 '*** FLOPS per PE [GFLOPS] : ', avgvar(3)/maxvar(2)
386 write(*,*)
'*** PAPI Report' 387 write(*,
'(1x,A,A,F10.3,A,F10.3,A,I5,A,A,F10.3,A,I5,A,A,I7)') &
388 '*** Real time [sec]',
' T(avg)=',avgvar(1), &
389 ', T(max)=',maxvar(1),
'[',maxidx(1),
']',
', T(min)=',minvar(1),
'[',minidx(1),
']' 390 write(*,
'(1x,A,A,F10.3,A,F10.3,A,I5,A,A,F10.3,A,I5,A,A,I7)') &
391 '*** CPU time [sec]',
' T(avg)=',avgvar(2), &
392 ', T(max)=',maxvar(2),
'[',maxidx(2),
']',
', T(min)=',minvar(2),
'[',minidx(2),
']' 393 write(*,
'(1x,A,A,F10.3,A,F10.3,A,I5,A,A,F10.3,A,I5,A,A,I7)') &
394 '*** FLOP [GFLOP]',
' N(avg)=',avgvar(3), &
395 ', N(max)=',maxvar(3),
'[',maxidx(3),
']',
', N(min)=',minvar(3),
'[',minidx(3),
']' 397 write(*,
'(1x,A,F15.3,A,I6,A)') &
399 write(*,
'(1x,A,F15.3)') &
400 '*** FLOPS [GFLOPS] : ', avgvar(3)*
prc_nprocs/maxvar(2)
401 write(*,
'(1x,A,F15.3)') &
402 '*** FLOPS per PE [GFLOPS] : ', avgvar(3)/maxvar(2)
408 end subroutine prof_papi_rapreport
413 function get_rapid( rapname, level )
result(id)
416 character(len=*),
intent(in) :: rapname
417 integer,
intent(inout) :: level
420 character (len=H_SHORT*2) :: trapname
421 character (len=H_SHORT) :: trapname2
424 trapname = trim(rapname)
425 trapname2 = trim(rapname)
427 do id = 1, prof_rapnmax
428 if ( trapname == prof_rapname(id) )
then 429 level = prof_raplevel(id)
434 prof_rapnmax = prof_rapnmax + 1
436 prof_rapname(id) = trapname
440 prof_rapttot(id) = 0.0_dp
442 prof_grpid(id) = get_grpid(trapname2)
443 prof_raplevel(id) = level
446 end function get_rapid
450 function get_grpid( rapname )
result(gid)
453 character(len=*),
intent(in) :: rapname
457 character(len=H_SHORT) :: grpname
460 idx = index(rapname,
" ")
462 grpname = rapname(1:idx-1)
467 do gid = 1, prof_grpnmax
468 if( grpname == prof_grpname(gid) )
return 471 prof_grpnmax = prof_grpnmax + 1
473 prof_grpname(gid) = grpname
476 end function get_grpid
subroutine, public prof_setup
logical, public prc_ismaster
master process in local communicator?
subroutine, public prc_mpistop
Abort MPI.
subroutine, public prof_setprefx(prefxname)
logical, public io_l
output log or not? (this process)
logical, public io_log_suppress
suppress all of log output?
subroutine, public prc_mpitimestat(avgvar, maxvar, minvar, maxidx, minidx, var)
Calc global statistics for timer.
logical, public io_log_allnode
output log for each node?
real(dp) function, public prc_mpitime()
Get MPI time.
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
logical, public io_lnml
output log or not? (for namelist, this process)
integer, public io_fid_conf
Config file ID.
subroutine, public prc_mpibarrier
Barrier MPI.
integer, public io_fid_log
Log file ID.
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
integer, public prc_nprocs
myrank in local communicator
subroutine, public prof_rapreport
Report raptime.