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) &
81 CALL print_reports(reports, iw, r_timings, sort_by_self_time, cost_type, report_maxloc, para_env)
99 SUBROUTINE collect_reports_from_ranks(reports, cost_type, para_env)
101 INTEGER,
INTENT(IN) :: cost_type
104 CHARACTER(LEN=default_string_length) :: routinen
105 INTEGER :: local_routine_id, sending_rank
106 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: collected
107 REAL(kind=
dp) :: foobar
108 REAL(kind=
dp),
DIMENSION(2) :: dbuf
113 NULLIFY (r_stat, r_report, timer_env)
123 CALL para_env%bcast(routinen, 0)
125 CALL para_env%max(sending_rank)
126 CALL para_env%sum(sending_rank)
128 CALL para_env%max(foobar)
130 CALL para_env%maxloc(dbuf)
131 CALL para_env%sum(foobar)
136 ALLOCATE (collected(
list_size(timer_env%routine_stats)), source=0)
141 IF (.NOT. all(collected == 1)) sending_rank = para_env%mepos
142 CALL para_env%max(sending_rank)
143 IF (sending_rank < 0)
EXIT
144 IF (sending_rank == para_env%mepos)
THEN
145 local_routine_id = minloc(collected, dim=1)
146 r_stat =>
list_get(timer_env%routine_stats, local_routine_id)
147 routinen = r_stat%routineN
149 CALL para_env%bcast(routinen, sending_rank)
154 r_report%routineN = routinen
159 collected(local_routine_id) = 1
160 r_stat =>
list_get(timer_env%routine_stats, local_routine_id)
161 r_report%max_total_calls = r_stat%total_calls
162 r_report%sum_total_calls = r_stat%total_calls
163 r_report%sum_stackdepth = r_stat%stackdepth_accu
164 SELECT CASE (cost_type)
166 r_report%max_icost = r_stat%incl_energy_accu
167 r_report%sum_icost = r_stat%incl_energy_accu
168 r_report%max_ecost = r_stat%excl_energy_accu
169 r_report%sum_ecost = r_stat%excl_energy_accu
171 r_report%max_icost = r_stat%incl_walltime_accu
172 r_report%sum_icost = r_stat%incl_walltime_accu
173 r_report%max_ecost = r_stat%excl_walltime_accu
174 r_report%sum_ecost = r_stat%excl_walltime_accu
181 CALL para_env%max(r_report%max_total_calls)
182 CALL para_env%sum(r_report%sum_total_calls)
183 CALL para_env%sum(r_report%sum_stackdepth)
186 dbuf = [r_report%max_icost, real(para_env%mepos, kind=
dp)]
187 CALL para_env%maxloc(dbuf)
188 r_report%max_icost = dbuf(1)
189 r_report%max_irank = int(dbuf(2))
191 CALL para_env%sum(r_report%sum_icost)
194 dbuf = [r_report%max_ecost, real(para_env%mepos, kind=
dp)]
195 CALL para_env%maxloc(dbuf)
196 r_report%max_ecost = dbuf(1)
197 r_report%max_erank = int(dbuf(2))
199 CALL para_env%sum(r_report%sum_ecost)
202 END SUBROUTINE collect_reports_from_ranks
217 SUBROUTINE print_reports(reports, iw, threshold, sort_by_exclusiv_cost, cost_type, report_maxloc, para_env)
219 INTEGER,
INTENT(IN) :: iw
220 REAL(kind=
dp),
INTENT(IN) :: threshold
221 LOGICAL,
INTENT(IN) :: sort_by_exclusiv_cost
222 INTEGER,
INTENT(IN) :: cost_type
223 LOGICAL,
INTENT(IN) :: report_maxloc
226 CHARACTER(LEN=4) :: label
227 CHARACTER(LEN=default_string_length) :: fmt, title
228 INTEGER :: decimals, i, j, num_routines
229 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: indices
230 REAL(kind=
dp) :: asd, maxcost, mincost
231 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: max_costs
234 NULLIFY (r_report_i, r_report_j)
239 SELECT CASE (cost_type)
241 title =
"E N E R G Y"
244 title =
"T I M I N G"
251 WRITE (unit=iw, fmt=
"(/,T2,A)") repeat(
"-", 79)
252 WRITE (unit=iw, fmt=
"(T2,A,T80,A)")
"-",
"-"
253 WRITE (unit=iw, fmt=
"(T2,A,T35,A,T80,A)")
"-", trim(title),
"-"
254 WRITE (unit=iw, fmt=
"(T2,A,T80,A)")
"-",
"-"
255 WRITE (unit=iw, fmt=
"(T2,A)") repeat(
"-", 79)
256 IF (report_maxloc)
THEN
257 WRITE (unit=iw, fmt=
"(T2,A,T35,A,T41,A,T45,2A18,A8)") &
258 "SUBROUTINE",
"CALLS",
" ASD",
"SELF "//label,
"TOTAL "//label,
"MAXRANK"
260 WRITE (unit=iw, fmt=
"(T2,A,T35,A,T41,A,T45,2A18)") &
261 "SUBROUTINE",
"CALLS",
" ASD",
"SELF "//label,
"TOTAL "//label
264 WRITE (unit=iw, fmt=
"(T33,A)") &
265 "MAXIMUM AVERAGE MAXIMUM AVERAGE MAXIMUM"
269 ALLOCATE (max_costs(num_routines))
270 DO i = 1, num_routines
272 IF (sort_by_exclusiv_cost)
THEN
273 max_costs(i) = r_report_i%max_ecost
275 max_costs(i) = r_report_i%max_icost
278 ALLOCATE (indices(num_routines))
279 CALL sort(max_costs, num_routines, indices)
281 maxcost = maxval(max_costs)
282 mincost = maxcost*threshold
287 IF (maxcost >= 10000) decimals = 2
288 IF (maxcost >= 100000) decimals = 1
289 IF (maxcost >= 1000000) decimals = 0
290 IF (report_maxloc)
THEN
291 WRITE (unit=fmt, fmt=
"(A,I0,A)") &
292 "(T2,A30,1X,I7,1X,F4.1,4(1X,F8.", decimals,
"),I8)"
294 WRITE (unit=fmt, fmt=
"(A,I0,A)") &
295 "(T2,A30,1X,I7,1X,F4.1,4(1X,F8.", decimals,
"))"
299 DO i = num_routines, 1, -1
300 IF (max_costs(i) >= mincost)
THEN
304 asd = real(r_report_j%sum_stackdepth, kind=
dp)/ &
305 REAL(max(1_int_8, r_report_j%sum_total_calls), kind=
dp)
306 IF (report_maxloc)
THEN
307 WRITE (unit=iw, fmt=fmt) &
308 adjustl(r_report_j%routineN(1:31)), &
309 r_report_j%max_total_calls, &
311 r_report_j%sum_ecost/para_env%num_pe, &
312 r_report_j%max_ecost, &
313 r_report_j%sum_icost/para_env%num_pe, &
314 r_report_j%max_icost, &
317 WRITE (unit=iw, fmt=fmt) &
318 adjustl(r_report_j%routineN(1:31)), &
319 r_report_j%max_total_calls, &
321 r_report_j%sum_ecost/para_env%num_pe, &
322 r_report_j%max_ecost, &
323 r_report_j%sum_icost/para_env%num_pe, &
328 WRITE (unit=iw, fmt=
"(T2,A,/)") repeat(
"-", 79)
330 END SUBROUTINE print_reports
341 CHARACTER(len=*),
INTENT(in) :: filename
343 INTEGER,
PARAMETER :: e = 1000, t = 100000
351 CALL open_file(file_name=filename, file_status=
"REPLACE", file_action=
"WRITE", &
352 file_form=
"FORMATTED", unit_number=unit)
356 r_stat =>
list_get(timer_env%routine_stats, 1)
357 WRITE (unit=unit, fmt=
"(A)")
"events: Walltime Energy"
358 WRITE (unit=unit, fmt=
"(A,I0,1X,I0)")
"summary: ", &
359 int(t*r_stat%incl_walltime_accu, kind=
int_8), &
360 int(e*r_stat%incl_energy_accu, kind=
int_8)
362 DO i = 1,
list_size(timer_env%routine_stats)
363 r_stat =>
list_get(timer_env%routine_stats, i)
364 WRITE (unit=unit, fmt=
"(A,I0,A,A)")
"fn=(", r_stat%routine_id,
") ", r_stat%routineN
365 WRITE (unit=unit, fmt=
"(A,I0,1X,I0)")
"1 ", &
366 int(t*r_stat%excl_walltime_accu, kind=
int_8), &
367 int(e*r_stat%excl_energy_accu, kind=
int_8)
371 DO i = 1,
SIZE(ct_items)
372 c_stat => ct_items(i)%value
373 WRITE (unit=unit, fmt=
"(A,I0,A)")
"fn=(", ct_items(i)%key(1),
")"
374 WRITE (unit=unit, fmt=
"(A,I0,A)")
"cfn=(", ct_items(i)%key(2),
")"
375 WRITE (unit=unit, fmt=
"(A,I0,A)")
"calls=", c_stat%total_calls,
" 1"
376 WRITE (unit=unit, fmt=
"(A,I0,1X,I0)")
"1 ", &
377 int(t*c_stat%incl_walltime_accu, kind=
int_8), &
378 int(e*c_stat%incl_energy_accu, kind=
int_8)
380 DEALLOCATE (ct_items)
382 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