33 public :: prof_papi_rapstart
34 public :: prof_papi_rapstop
35 public :: prof_papi_rapreport
38 public :: prof_valcheck
40 interface prof_valcheck
41 module procedure prof_valcheck_sp_1d
42 module procedure prof_valcheck_sp_2d
43 module procedure prof_valcheck_sp_3d
44 module procedure prof_valcheck_sp_4d
45 module procedure prof_valcheck_sp_5d
46 module procedure prof_valcheck_sp_6d
47 module procedure prof_valcheck_dp_1d
48 module procedure prof_valcheck_dp_2d
49 module procedure prof_valcheck_dp_3d
50 module procedure prof_valcheck_dp_4d
51 module procedure prof_valcheck_dp_5d
52 module procedure prof_valcheck_dp_6d
53 end interface prof_valcheck
69 integer,
private,
parameter :: PROF_rapnlimit = 300
70 character(len=H_SHORT),
private :: PROF_prefix =
''
71 integer,
private :: PROF_rapnmax = 0
72 character(len=H_SHORT),
private :: PROF_rapname(PROF_rapnlimit)
73 integer,
private :: PROF_grpnmax = 0
74 character(len=H_SHORT),
private :: PROF_grpname(PROF_rapnlimit)
75 integer,
private :: PROF_grpid (PROF_rapnlimit)
76 real(DP),
private :: PROF_raptstr(PROF_rapnlimit)
77 real(DP),
private :: PROF_rapttot(PROF_rapnlimit)
78 integer,
private :: PROF_rapnstr(PROF_rapnlimit)
79 integer,
private :: PROF_rapcnt (PROF_rapnlimit)
80 integer,
private :: PROF_rapnend(PROF_rapnlimit)
81 integer,
private :: PROF_raplevel(PROF_rapnlimit)
83 integer,
private,
parameter :: PROF_default_rap_level = 2
84 integer,
private :: PROF_rap_level = 2
85 logical,
private :: PROF_mpi_barrier = .false.
88 integer(DP),
private :: PROF_PAPI_flops = 0
89 real(SP),
private :: PROF_PAPI_real_time = 0.0
90 real(SP),
private :: PROF_PAPI_proc_time = 0.0
91 real(SP),
private :: PROF_PAPI_mflops = 0.0
92 integer,
private :: PROF_PAPI_check
95 character(len=7),
private :: PROF_header
96 character(len=16),
private :: PROF_item
97 real(DP),
private :: PROF_max
98 real(DP),
private :: PROF_min
99 real(DP),
private :: PROF_sum
101 logical,
private :: PROF_barrier_flag
111 namelist / param_prof / &
118 log_info(
"PROF_setup",*)
'Setup'
124 log_info(
"PROF_setup",*)
'Not found namelist. Default used.'
125 elseif( ierr > 0 )
then
126 log_error(
"PROF_setup",*)
'Not appropriate names in namelist PARAM_PROF. Check!'
132 log_info(
"PROF_setup",*)
'Rap output level = ', prof_rap_level
133 log_info(
"PROF_setup",*)
'Add MPI_barrier in every rap? = ', prof_mpi_barrier
143 prof_mpi_barrier = .false.
146 prof_papi_real_time = 0.0
147 prof_papi_proc_time = 0.0
148 prof_papi_mflops = 0.0
162 character(len=*),
intent(in) :: prefxname
166 prof_prefix = prefxname
173 subroutine prof_rapstart( rapname_base, level, disable_barrier )
179 character(len=*),
intent(in) :: rapname_base
180 integer,
intent(in),
optional :: level
181 logical,
intent(in),
optional :: disable_barrier
183 character(len=H_SHORT) :: rapname
189 logical :: disable_barrier_
197 if (
present(level) )
then
200 level_ = prof_default_rap_level
203 if (
present(disable_barrier) )
then
204 disable_barrier_ = disable_barrier
206 disable_barrier_ = .false.
209 if( level_ > prof_rap_level )
return
211 if ( len_trim(prof_prefix) > 0 )
then
212 rapname = trim(prof_prefix)//
" "//trim(rapname_base)
214 rapname = rapname_base
217 id = get_rapid( rapname, level_ )
219 prof_rapcnt(id) = prof_rapcnt(id) + 1
221 if ( prof_rapcnt(id) > 1 )
return
223 if ( ( .not. disable_barrier_ ) .and. prof_mpi_barrier )
call prc_mpibarrier
226 prof_rapnstr(id) = prof_rapnstr(id) + 1
232 i = index(rapname,
" ")
233 if ( i == 0 .or. i > len_trim(rapname))
then
234 call fapp_start( rapname, id, level_ )
236 call fapp_start( rapname(1:i-1)//
"_"//trim(rapname(i+1:)), id, level_ )
245 subroutine prof_rapend( rapname_base, level, disable_barrier )
251 character(len=*),
intent(in) :: rapname_base
252 integer,
intent(in),
optional :: level
253 logical,
intent(in),
optional :: disable_barrier
255 character(len=H_SHORT) :: rapname
261 logical :: disable_barrier_
269 if (
present(level) )
then
270 if( level > prof_rap_level )
return
273 if ( len_trim(prof_prefix) > 0 )
then
274 rapname = trim(prof_prefix)//
" "//trim(rapname_base)
276 rapname = rapname_base
279 if (
present(disable_barrier) )
then
280 disable_barrier_ = disable_barrier
282 disable_barrier_ = .false.
287 id = get_rapid( rapname, level_ )
289 if( level_ > prof_rap_level )
return
291 prof_rapcnt(id) = prof_rapcnt(id) - 1
293 if ( prof_rapcnt(id) > 0 )
return
296 i = index(rapname,
" ")
297 if ( i == 0 .or. i > len_trim(rapname))
then
298 call fapp_stop( rapname, id, level_ )
300 call fapp_stop( rapname(1:i-1)//
"_"//trim(rapname(i+1:)), id, level_ )
304 prof_rapttot(id) = prof_rapttot(id) + (
prc_mpitime()-prof_raptstr(id) )
305 prof_rapnend(id) = prof_rapnend(id) + 1
307 if ( ( .not. disable_barrier_ ) .and. prof_mpi_barrier )
call prc_mpibarrier
321 real(dp) :: avgvar(prof_rapnlimit)
322 real(dp) :: maxvar(prof_rapnlimit)
323 real(dp) :: minvar(prof_rapnlimit)
324 integer :: maxidx(prof_rapnlimit)
325 integer :: minidx(prof_rapnlimit)
327 integer :: idx(prof_rapnlimit)
335 do id = 1, prof_rapnmax
336 if ( prof_rapnstr(id) /= prof_rapnend(id) )
then
337 log_warn(
"PROF_rapreport",*)
'Mismatch Report',id,prof_rapname(id),prof_rapnstr(id),prof_rapnend(id)
342 log_info(
"PROF_rapreport",
'(1x,A,I2,A)')
'Computational Time Report (Rap level = ', prof_rap_level,
')'
346 do gid = 1, prof_rapnmax
348 do id = 1, prof_rapnmax
349 if ( prof_raplevel(id) <= prof_rap_level &
350 .AND. prof_grpid(id) == gid )
then
357 if ( prof_raplevel(idx(i)) < prof_raplevel(idx(j)) .or. &
358 ( prof_raplevel(idx(i)) == prof_raplevel(idx(j)) &
359 .and. prof_rapname(idx(i)) < prof_rapname(idx(j)) ) )
then
368 log_info_cont(
'(1x,2A,I2,A,F10.3,A,I9)') &
369 prof_rapname(id),
' lev=', prof_raplevel(id), &
370 ': T=',prof_rapttot(id),
' N=',prof_rapnstr(id)
377 call prc_timereorder( prof_rapnlimit, prof_rapnmax, prof_rapttot, prof_rapname )
380 maxvar(1:prof_rapnmax), &
381 minvar(1:prof_rapnmax), &
382 maxidx(1:prof_rapnmax), &
383 minidx(1:prof_rapnmax), &
384 prof_rapttot(1:prof_rapnmax) )
389 write(*,*)
'INFO [PROF_rapreport] Computational Time Report'
397 do gid = 1, prof_rapnmax
399 do id = 1, prof_rapnmax
400 if ( prof_raplevel(id) <= prof_rap_level &
401 .AND. prof_grpid(id) == gid )
then
408 if ( prof_raplevel(idx(i)) < prof_raplevel(idx(j)) .or. &
409 ( prof_raplevel(idx(i)) == prof_raplevel(idx(j)) &
410 .and. prof_rapname(idx(i)) < prof_rapname(idx(j)) ) )
then
419 write(fid,
'(1x,2A,I2,A,F10.3,2(A,F10.3,A,I6,A),A,I9)') &
420 prof_rapname(id),
' lev=', prof_raplevel(id), &
421 ': T(avg)=',avgvar(id), &
422 ', T(max)=',maxvar(id),
'[',maxidx(id),
']', &
423 ', T(min)=',minvar(id),
'[',minidx(id),
']', &
424 ', N=',prof_rapnstr(id)
437 subroutine prof_papi_rapstart
441 call papif_flops( prof_papi_real_time, prof_papi_proc_time, prof_papi_flops, prof_papi_mflops, prof_papi_check )
444 end subroutine prof_papi_rapstart
448 subroutine prof_papi_rapstop
452 call papif_flops( prof_papi_real_time, prof_papi_proc_time, prof_papi_flops, prof_papi_mflops, prof_papi_check )
455 end subroutine prof_papi_rapstop
459 subroutine prof_papi_rapreport
466 real(dp) :: avgvar(3)
467 real(dp) :: maxvar(3)
468 real(dp) :: minvar(3)
473 real(dp) :: prof_papi_gflop
474 real(dp) :: statistics(3)
477 prof_papi_gflop = real(prof_papi_flops,kind=8) / 1024.0_dp**3
482 log_info(
"PROF_PAPI_rapreport",*)
'PAPI Report [Local PE information]'
483 log_info(
"PROF_PAPI_rapreport",
'(1x,A,F15.3)')
'Real time [sec] : ', prof_papi_real_time
484 log_info(
"PROF_PAPI_rapreport",
'(1x,A,F15.3)')
'CPU time [sec] : ', prof_papi_proc_time
485 log_info(
"PROF_PAPI_rapreport",
'(1x,A,F15.3)')
'FLOP [GFLOP] : ', prof_papi_gflop
486 log_info(
"PROF_PAPI_rapreport",
'(1x,A,F15.3)')
'FLOPS by PAPI [GFLOPS] : ', prof_papi_mflops/1024.0_dp
487 log_info(
"PROF_PAPI_rapreport",
'(1x,A,F15.3)')
'FLOP / CPU Time [GFLOPS] : ', prof_papi_gflop/prof_papi_proc_time
490 statistics(1) = real(prof_papi_real_time,kind=8)
491 statistics(2) = real(prof_papi_proc_time,kind=8)
492 statistics(3) = prof_papi_gflop
501 zerosw = 0.5_dp - sign(0.5_dp,maxvar(2)-1.d-12)
504 log_info(
"PROF_PAPI_rapreport",*)
'PAPI Report'
505 log_info(
"PROF_PAPI_rapreport",
'(1x,A,A,F10.3,A,F10.3,A,I6,A,A,F10.3,A,I6,A)') &
506 'Real time [sec]',
' T(avg)=',avgvar(1), &
507 ', T(max)=',maxvar(1),
'[',maxidx(1),
']',
', T(min)=',minvar(1),
'[',minidx(1),
']'
508 log_info(
"PROF_PAPI_rapreport",
'(1x,A,A,F10.3,A,F10.3,A,I6,A,A,F10.3,A,I6,A)') &
509 'CPU time [sec]',
' T(avg)=',avgvar(2), &
510 ', T(max)=',maxvar(2),
'[',maxidx(2),
']',
', T(min)=',minvar(2),
'[',minidx(2),
']'
511 log_info(
"PROF_PAPI_rapreport",
'(1x,A,A,F10.3,A,F10.3,A,I6,A,A,F10.3,A,I6,A)') &
512 'FLOP [GFLOP]',
' N(avg)=',avgvar(3), &
513 ', N(max)=',maxvar(3),
'[',maxidx(3),
']',
', N(min)=',minvar(3),
'[',minidx(3),
']'
515 log_info(
"PROF_PAPI_rapreport",
'(1x,A,F15.3,A,I6,A)') &
517 log_info(
"PROF_PAPI_rapreport",
'(1x,A,F15.3)') &
518 'FLOPS [GFLOPS] : ', avgvar(3)*
prc_nprocs * ( 1.0_dp-zerosw ) / ( maxvar(2)+zerosw )
519 log_info(
"PROF_PAPI_rapreport",
'(1x,A,F15.3)') &
520 'FLOPS per PE [GFLOPS] : ', avgvar(3) * ( 1.0_dp-zerosw ) / ( maxvar(2)+zerosw )
526 write(*,*)
'*** PAPI Report'
527 write(*,
'(1x,A,A,F10.3,A,F10.3,A,I6,A,A,F10.3,A,I6,A)') &
528 '*** Real time [sec]',
' T(avg)=',avgvar(1), &
529 ', T(max)=',maxvar(1),
'[',maxidx(1),
']',
', T(min)=',minvar(1),
'[',minidx(1),
']'
530 write(*,
'(1x,A,A,F10.3,A,F10.3,A,I6,A,A,F10.3,A,I6,A)') &
531 '*** CPU time [sec]',
' T(avg)=',avgvar(2), &
532 ', T(max)=',maxvar(2),
'[',maxidx(2),
']',
', T(min)=',minvar(2),
'[',minidx(2),
']'
533 write(*,
'(1x,A,A,F10.3,A,F10.3,A,I6,A,A,F10.3,A,I6,A)') &
534 '*** FLOP [GFLOP]',
' N(avg)=',avgvar(3), &
535 ', N(max)=',maxvar(3),
'[',maxidx(3),
']',
', N(min)=',minvar(3),
'[',minidx(3),
']'
537 write(*,
'(1x,A,F15.3,A,I6,A)') &
539 write(*,
'(1x,A,F15.3)') &
540 '*** FLOPS [GFLOPS] : ', avgvar(3)*
prc_nprocs * ( 1.0_dp-zerosw ) / ( maxvar(2)+zerosw )
541 write(*,
'(1x,A,F15.3)') &
542 '*** FLOPS per PE [GFLOPS] : ', avgvar(3) * ( 1.0_dp-zerosw ) / ( maxvar(2)+zerosw )
548 end subroutine prof_papi_rapreport
553 function get_rapid( rapname, level )
result(id)
558 character(len=*),
intent(in) :: rapname
559 integer,
intent(inout) :: level
561 character (len=H_SHORT) :: trapname
567 trapname = trim(rapname)
569 do id = 1, prof_rapnmax
570 if ( trapname == prof_rapname(id) )
then
571 lev = prof_raplevel(id)
573 if ( level > 0 .and. lev .ne. level )
then
574 log_error(
"PROF_get_rapid",*)
'level is different ', trim(rapname), lev, level
583 prof_rapnmax = prof_rapnmax + 1
585 prof_rapname(id) = trapname
589 prof_rapttot(id) = 0.0_dp
593 prof_raplevel(id) = level
596 end function get_rapid
600 function get_grpid( rapname )
result(gid)
603 character(len=*),
intent(in) :: rapname
605 character(len=H_SHORT) :: grpname
611 idx = index(rapname,
" ")
613 grpname = rapname(1:idx-1)
618 do gid = 1, prof_grpnmax
619 if( grpname == prof_grpname(gid) )
return
622 prof_grpnmax = prof_grpnmax + 1
624 prof_grpname(gid) = grpname
630 subroutine prof_valcheck_sp_1d( &
636 character(len=*),
intent(in) :: header
637 character(len=*),
intent(in) :: varname
638 real(sp),
intent(in) :: var(:)
641 prof_header = trim(header)
642 prof_item = trim(varname)
643 prof_max = real(maxval(var),kind=dp)
644 prof_min = real(minval(var),kind=dp)
645 prof_sum = real(sum(var),kind=dp)
646 log_info(
"PROF_valcheck_SP_1D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
647 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
650 end subroutine prof_valcheck_sp_1d
653 subroutine prof_valcheck_sp_2d( &
659 character(len=*),
intent(in) :: header
660 character(len=*),
intent(in) :: varname
661 real(sp),
intent(in) :: var(:,:)
664 prof_header = trim(header)
665 prof_item = trim(varname)
666 prof_max = real(maxval(var),kind=dp)
667 prof_min = real(minval(var),kind=dp)
668 prof_sum = real(sum(var),kind=dp)
669 log_info(
"PROF_valcheck_SP_2D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
670 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
673 end subroutine prof_valcheck_sp_2d
676 subroutine prof_valcheck_sp_3d( &
682 character(len=*),
intent(in) :: header
683 character(len=*),
intent(in) :: varname
684 real(sp),
intent(in) :: var(:,:,:)
687 prof_header = trim(header)
688 prof_item = trim(varname)
689 prof_max = real(maxval(var),kind=dp)
690 prof_min = real(minval(var),kind=dp)
691 prof_sum = real(sum(var),kind=dp)
692 log_info(
"PROF_valcheck_SP_3D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
693 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
696 end subroutine prof_valcheck_sp_3d
699 subroutine prof_valcheck_sp_4d( &
705 character(len=*),
intent(in) :: header
706 character(len=*),
intent(in) :: varname
707 real(sp),
intent(in) :: var(:,:,:,:)
710 prof_header = trim(header)
711 prof_item = trim(varname)
712 prof_max = real(maxval(var),kind=dp)
713 prof_min = real(minval(var),kind=dp)
714 prof_sum = real(sum(var),kind=dp)
715 log_info(
"PROF_valcheck_SP_4D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
716 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
719 end subroutine prof_valcheck_sp_4d
722 subroutine prof_valcheck_sp_5d( &
728 character(len=*),
intent(in) :: header
729 character(len=*),
intent(in) :: varname
730 real(sp),
intent(in) :: var(:,:,:,:,:)
733 prof_header = trim(header)
734 prof_item = trim(varname)
735 prof_max = real(maxval(var),kind=dp)
736 prof_min = real(minval(var),kind=dp)
737 prof_sum = real(sum(var),kind=dp)
738 log_info(
"PROF_valcheck_SP_5D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
739 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
742 end subroutine prof_valcheck_sp_5d
745 subroutine prof_valcheck_sp_6d( &
751 character(len=*),
intent(in) :: header
752 character(len=*),
intent(in) :: varname
753 real(sp),
intent(in) :: var(:,:,:,:,:,:)
756 prof_header = trim(header)
757 prof_item = trim(varname)
758 prof_max = real(maxval(var),kind=dp)
759 prof_min = real(minval(var),kind=dp)
760 prof_sum = real(sum(var),kind=dp)
761 log_info(
"PROF_valcheck_SP_6D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
762 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
765 end subroutine prof_valcheck_sp_6d
768 subroutine prof_valcheck_dp_1d( &
774 character(len=*),
intent(in) :: header
775 character(len=*),
intent(in) :: varname
776 real(dp),
intent(in) :: var(:)
779 prof_header = trim(header)
780 prof_item = trim(varname)
781 prof_max = real(maxval(var),kind=dp)
782 prof_min = real(minval(var),kind=dp)
783 prof_sum = real(sum(var),kind=dp)
784 log_info(
"PROF_valcheck_DP_1D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
785 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
788 end subroutine prof_valcheck_dp_1d
791 subroutine prof_valcheck_dp_2d( &
797 character(len=*),
intent(in) :: header
798 character(len=*),
intent(in) :: varname
799 real(dp),
intent(in) :: var(:,:)
802 prof_header = trim(header)
803 prof_item = trim(varname)
804 prof_max = real(maxval(var),kind=dp)
805 prof_min = real(minval(var),kind=dp)
806 prof_sum = real(sum(var),kind=dp)
807 log_info(
"PROF_valcheck_DP_2D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
808 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
811 end subroutine prof_valcheck_dp_2d
814 subroutine prof_valcheck_dp_3d( &
820 character(len=*),
intent(in) :: header
821 character(len=*),
intent(in) :: varname
822 real(dp),
intent(in) :: var(:,:,:)
825 prof_header = trim(header)
826 prof_item = trim(varname)
827 prof_max = real(maxval(var),kind=dp)
828 prof_min = real(minval(var),kind=dp)
829 prof_sum = real(sum(var),kind=dp)
830 log_info(
"PROF_valcheck_DP_3D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
831 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
834 end subroutine prof_valcheck_dp_3d
837 subroutine prof_valcheck_dp_4d( &
843 character(len=*),
intent(in) :: header
844 character(len=*),
intent(in) :: varname
845 real(dp),
intent(in) :: var(:,:,:,:)
848 prof_header = trim(header)
849 prof_item = trim(varname)
850 prof_max = real(maxval(var),kind=dp)
851 prof_min = real(minval(var),kind=dp)
852 prof_sum = real(sum(var),kind=dp)
853 log_info(
"PROF_valcheck_DP_4D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
854 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
857 end subroutine prof_valcheck_dp_4d
860 subroutine prof_valcheck_dp_5d( &
866 character(len=*),
intent(in) :: header
867 character(len=*),
intent(in) :: varname
868 real(dp),
intent(in) :: var(:,:,:,:,:)
871 prof_header = trim(header)
872 prof_item = trim(varname)
873 prof_max = real(maxval(var),kind=dp)
874 prof_min = real(minval(var),kind=dp)
875 prof_sum = real(sum(var),kind=dp)
876 log_info(
"PROF_valcheck_DP_5D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
877 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
880 end subroutine prof_valcheck_dp_5d
883 subroutine prof_valcheck_dp_6d( &
889 character(len=*),
intent(in) :: header
890 character(len=*),
intent(in) :: varname
891 real(dp),
intent(in) :: var(:,:,:,:,:,:)
894 prof_header = trim(header)
895 prof_item = trim(varname)
896 prof_max = real(maxval(var),kind=dp)
897 prof_min = real(minval(var),kind=dp)
898 prof_sum = real(sum(var),kind=dp)
899 log_info(
"PROF_valcheck_DP_6D",
'(1x,A,A7,A,A16,3(A,ES24.16))') &
900 '+',prof_header,
'[',prof_item,
'] max=',prof_max,
',min=',prof_min,
',sum=',prof_sum
903 end subroutine prof_valcheck_dp_6d