43#include "../base/base_uses.f90"
67 INTEGER,
INTENT(IN) :: iw
68 REAL(kind=
dp),
INTENT(IN) :: r_timings
69 LOGICAL,
INTENT(IN) :: sort_by_self_time
70 INTEGER,
INTENT(IN) :: cost_type
71 LOGICAL,
INTENT(IN) :: report_maxloc
78 CALL collect_reports_from_ranks(reports, cost_type, para_env)
80 IF (
list_size(reports) > 0 .AND. iw > 0)
THEN
81 CALL print_reports(reports, iw, r_timings, sort_by_self_time, cost_type, report_maxloc, para_env)
100 SUBROUTINE collect_reports_from_ranks(reports, cost_type, para_env)
102 INTEGER,
INTENT(IN) :: cost_type
105 CHARACTER(LEN=default_string_length) :: routinen
106 INTEGER :: local_routine_id, sending_rank
107 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: collected
108 REAL(kind=
dp) :: foobar
109 REAL(kind=
dp),
DIMENSION(2) :: dbuf
114 NULLIFY (r_stat, r_report, timer_env)
125 CALL para_env%bcast(routinen, 0)
127 CALL para_env%max(sending_rank)
128 CALL para_env%sum(sending_rank)
130 CALL para_env%max(foobar)
132 CALL para_env%maxloc(dbuf)
133 CALL para_env%sum(foobar)
138 ALLOCATE (collected(
list_size(timer_env%routine_stats)), source=0)
143 IF (.NOT. all(collected == 1)) sending_rank = para_env%mepos
144 CALL para_env%max(sending_rank)
145 IF (sending_rank < 0)
EXIT
146 IF (sending_rank == para_env%mepos)
THEN
147 local_routine_id = minloc(collected, dim=1)
148 r_stat =>
list_get(timer_env%routine_stats, local_routine_id)
149 routinen = r_stat%routineN
151 CALL para_env%bcast(routinen, sending_rank)
156 r_report%routineN = routinen
161 collected(local_routine_id) = 1
162 r_stat =>
list_get(timer_env%routine_stats, local_routine_id)
163 r_report%max_total_calls = r_stat%total_calls
164 r_report%sum_total_calls = r_stat%total_calls
165 r_report%sum_stackdepth = r_stat%stackdepth_accu
166 SELECT CASE (cost_type)
168 r_report%max_icost = r_stat%incl_energy_accu
169 r_report%sum_icost = r_stat%incl_energy_accu
170 r_report%max_ecost = r_stat%excl_energy_accu
171 r_report%sum_ecost = r_stat%excl_energy_accu
173 r_report%max_icost = r_stat%incl_walltime_accu
174 r_report%sum_icost = r_stat%incl_walltime_accu
175 r_report%max_ecost = r_stat%excl_walltime_accu
176 r_report%sum_ecost = r_stat%excl_walltime_accu
183 CALL para_env%max(r_report%max_total_calls)
184 CALL para_env%sum(r_report%sum_total_calls)
185 CALL para_env%sum(r_report%sum_stackdepth)
188 dbuf = [r_report%max_icost, real(para_env%mepos, kind=
dp)]
189 CALL para_env%maxloc(dbuf)
190 r_report%max_icost = dbuf(1)
191 r_report%max_irank = int(dbuf(2))
193 CALL para_env%sum(r_report%sum_icost)
196 dbuf = [r_report%max_ecost, real(para_env%mepos, kind=
dp)]
197 CALL para_env%maxloc(dbuf)
198 r_report%max_ecost = dbuf(1)
199 r_report%max_erank = int(dbuf(2))
201 CALL para_env%sum(r_report%sum_ecost)
204 END SUBROUTINE collect_reports_from_ranks
219 SUBROUTINE print_reports(reports, iw, threshold, sort_by_exclusiv_cost, cost_type, report_maxloc, para_env)
221 INTEGER,
INTENT(IN) :: iw
222 REAL(kind=
dp),
INTENT(IN) :: threshold
223 LOGICAL,
INTENT(IN) :: sort_by_exclusiv_cost
224 INTEGER,
INTENT(IN) :: cost_type
225 LOGICAL,
INTENT(IN) :: report_maxloc
228 CHARACTER(LEN=4) :: label
229 CHARACTER(LEN=default_string_length) :: fmt, title
230 INTEGER :: decimals, i, j, num_routines
231 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: indices
232 REAL(kind=
dp) :: asd, maxcost, mincost
233 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: max_costs
236 NULLIFY (r_report_i, r_report_j)
242 SELECT CASE (cost_type)
244 title =
"E N E R G Y"
247 title =
"T I M I N G"
254 WRITE (unit=iw, fmt=
"(/,T2,A)") repeat(
"-", 79)
255 WRITE (unit=iw, fmt=
"(T2,A,T80,A)")
"-",
"-"
256 WRITE (unit=iw, fmt=
"(T2,A,T35,A,T80,A)")
"-", trim(title),
"-"
257 WRITE (unit=iw, fmt=
"(T2,A,T80,A)")
"-",
"-"
258 WRITE (unit=iw, fmt=
"(T2,A)") repeat(
"-", 79)
259 IF (report_maxloc)
THEN
260 WRITE (unit=iw, fmt=
"(T2,A,T35,A,T41,A,T45,2A18,A8)") &
261 "SUBROUTINE",
"CALLS",
" ASD",
"SELF "//label,
"TOTAL "//label,
"MAXRANK"
263 WRITE (unit=iw, fmt=
"(T2,A,T35,A,T41,A,T45,2A18)") &
264 "SUBROUTINE",
"CALLS",
" ASD",
"SELF "//label,
"TOTAL "//label
267 WRITE (unit=iw, fmt=
"(T33,A)") &
268 "MAXIMUM AVERAGE MAXIMUM AVERAGE MAXIMUM"
272 ALLOCATE (max_costs(num_routines))
273 DO i = 1, num_routines
275 IF (sort_by_exclusiv_cost)
THEN
276 max_costs(i) = r_report_i%max_ecost
278 max_costs(i) = r_report_i%max_icost
281 ALLOCATE (indices(num_routines))
282 CALL sort(max_costs, num_routines, indices)
284 maxcost = maxval(max_costs)
285 mincost = maxcost*threshold
290 IF (maxcost >= 10000) decimals = 2
291 IF (maxcost >= 100000) decimals = 1
292 IF (maxcost >= 1000000) decimals = 0
293 IF (report_maxloc)
THEN
294 WRITE (unit=fmt, fmt=
"(A,I0,A)") &
295 "(T2,A30,1X,I7,1X,F4.1,4(1X,F8.", decimals,
"),I8)"
297 WRITE (unit=fmt, fmt=
"(A,I0,A)") &
298 "(T2,A30,1X,I7,1X,F4.1,4(1X,F8.", decimals,
"))"
302 DO i = num_routines, 1, -1
303 IF (max_costs(i) >= mincost)
THEN
307 asd = real(r_report_j%sum_stackdepth, kind=
dp)/ &
308 REAL(max(1_int_8, r_report_j%sum_total_calls), kind=
dp)
309 IF (report_maxloc)
THEN
310 WRITE (unit=iw, fmt=fmt) &
311 adjustl(r_report_j%routineN(1:31)), &
312 r_report_j%max_total_calls, &
314 r_report_j%sum_ecost/para_env%num_pe, &
315 r_report_j%max_ecost, &
316 r_report_j%sum_icost/para_env%num_pe, &
317 r_report_j%max_icost, &
320 WRITE (unit=iw, fmt=fmt) &
321 adjustl(r_report_j%routineN(1:31)), &
322 r_report_j%max_total_calls, &
324 r_report_j%sum_ecost/para_env%num_pe, &
325 r_report_j%max_ecost, &
326 r_report_j%sum_icost/para_env%num_pe, &
331 WRITE (unit=iw, fmt=
"(T2,A,/)") repeat(
"-", 79)
333 END SUBROUTINE print_reports
344 CHARACTER(len=*),
INTENT(in) :: filename
346 INTEGER,
PARAMETER :: e = 1000, t = 100000
354 CALL open_file(file_name=filename, file_status=
"REPLACE", file_action=
"WRITE", &
355 file_form=
"FORMATTED", unit_number=unit)
359 r_stat =>
list_get(timer_env%routine_stats, 1)
360 WRITE (unit=unit, fmt=
"(A)")
"events: Walltime Energy"
361 WRITE (unit=unit, fmt=
"(A,I0,1X,I0)")
"summary: ", &
362 int(t*r_stat%incl_walltime_accu, kind=
int_8), &
363 int(e*r_stat%incl_energy_accu, kind=
int_8)
365 DO i = 1,
list_size(timer_env%routine_stats)
366 r_stat =>
list_get(timer_env%routine_stats, i)
367 WRITE (unit=unit, fmt=
"(A,I0,A,A)")
"fn=(", r_stat%routine_id,
") ", r_stat%routineN
368 WRITE (unit=unit, fmt=
"(A,I0,1X,I0)")
"1 ", &
369 int(t*r_stat%excl_walltime_accu, kind=
int_8), &
370 int(e*r_stat%excl_energy_accu, kind=
int_8)
374 DO i = 1,
SIZE(ct_items)
375 c_stat => ct_items(i)%value
376 WRITE (unit=unit, fmt=
"(A,I0,A)")
"fn=(", ct_items(i)%key(1),
")"
377 WRITE (unit=unit, fmt=
"(A,I0,A)")
"cfn=(", ct_items(i)%key(2),
")"
378 WRITE (unit=unit, fmt=
"(A,I0,A)")
"calls=", c_stat%total_calls,
" 1"
379 WRITE (unit=unit, fmt=
"(A,I0,1X,I0)")
"1 ", &
380 int(t*c_stat%incl_walltime_accu, kind=
int_8), &
381 int(e*c_stat%incl_energy_accu, kind=
int_8)
383 DEALLOCATE (ct_items)
385 CALL close_file(unit_number=unit, file_status=
"KEEP")
type(callgraph_item_type) function, dimension(:), pointer, public callgraph_items(hash_map)
Returns a pointer to an array of all key/value-items stored in the hash map. Caution: The caller is r...
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public dp
integer, parameter, public default_string_length
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Interface to the message passing library MPI.
integer(kind=int_4) function, public routine_map_get(hash_map, key, default_value)
Gets a value for a given key from the hash map. If the key is not found the default_value will be ret...
logical function, public routine_map_haskey(hash_map, key)
Checks whether a given key is currently stored in the hash_map.
Types used by timings.F and timings_report.F The types in this module are used within dict or list,...
Timing routines for accounting.
integer, parameter, public cost_type_energy
subroutine, public timings_report_callgraph(filename)
Write accumulated callgraph information as cachegrind-file. http://kcachegrind.sourceforge....
integer, parameter, public cost_type_time
subroutine, public timings_report_print(iw, r_timings, sort_by_self_time, cost_type, report_maxloc, para_env)
Print accumulated information on timers.
Types used by timings.F and timings_report.F Due to the fortran restriction on cicular module-depende...
Timing routines for accounting.
type(timer_env_type) function, pointer, public get_timer_env()
returns the current timer env from the stack
All kind of helpful little routines.
stores all the informations relevant to an mpi environment