QR_MUMPS
 All Classes Files Functions Variables Enumerations Enumerator Pages
qrm_trace_mod.F90
Go to the documentation of this file.
1 !! ##############################################################################################
2 !!
3 !! Copyright 2012 CNRS, INPT
4 !!
5 !! This file is part of qr_mumps.
6 !!
7 !! qr_mumps is free software: you can redistribute it and/or modify
8 !! it under the terms of the GNU Lesser General Public License as
9 !! published by the Free Software Foundation, either version 3 of
10 !! the License, or (at your option) any later version.
11 !!
12 !! qr_mumps is distributed in the hope that it will be useful,
13 !! but WITHOUT ANY WARRANTY; without even the implied warranty of
14 !! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 !! GNU Lesser General Public License for more details.
16 !!
17 !! You can find a copy of the GNU Lesser General Public License
18 !! in the qr_mumps/doc directory.
19 !!
20 !! ##############################################################################################
21 
22 
23 !! ##############################################################################################
33 
34 
35 #include "qrm_common.h"
36 
41  use qrm_common_mod
42  use qrm_error_mod
43 
47 
48  interface qrm_trace_init
49  module procedure qrm_trace_init
50  end interface
51 
53  module procedure qrm_trace_create_event
54  end interface
55 
57  module procedure qrm_trace_event_start
58  end interface
59 
61  module procedure qrm_trace_event_stop
62  end interface
63 
65  module procedure qrm_trace_log_dump
66  end interface
67 
68  private
69 
71  integer :: id, thn
72  real(kind(1.d0)) :: start, stop
73  end type event_type
74 
75  real(kind(1.d0)), save :: timezero, start, stop
76  integer, parameter :: maxevents=15000, maxtypes=20, maxth=32
77  logical, save :: pendings(0:maxth-1)
78  real(kind(1.d0)), save :: starts(0:maxth-1), stops(0:maxth-1), ttimes(1:maxtypes)
79 
80  type(event_type), allocatable, save :: events(:,:)
81  character(len=20), save :: labels(maxtypes)
82  integer, save :: nevtype, nodeid
83  integer, save :: nevents(0:maxth-1)
84  character(len=7) :: colors(maxtypes)
85 
86 contains
87 
88  subroutine qrm_trace_init(node)
89  integer :: node
90 
91  nodeid = node
92  pendings = .false.
93  nevtype = 0
94  nevents = 0
95  ttimes = 0
96  allocate(events(0:maxth-1,maxevents))
97  colors(1:7) = (/'#d38d5f', '#ffdd55', '#8dd35f', '#80b3ff', '#e580ff', '#ac9d93', '#bcd35f'/)
98  timezero = qrm_swtime()
99  return
100 
101  end subroutine qrm_trace_init
102 
103 
104 
105  subroutine qrm_trace_create_event(label, id)
106  character :: label*(*)
107  integer :: id
108 
109  nevtype = nevtype+1
110  id = nevtype
111  labels(id) = label
112 
113  return
114 
115  end subroutine qrm_trace_create_event
116 
117 
118  subroutine qrm_trace_event_start(id, thn)
119  integer :: id, thn
120  if(pendings(thn)) then
121  __qrm_prnt_err('("Tracing error!!! events nesting not supported")')
122  return
123  end if
124  pendings(thn) = .true.
125  starts(thn) = qrm_swtime()
126  return
127  end subroutine qrm_trace_event_start
128 
129  subroutine qrm_trace_event_stop(id, thn)
130  integer :: id, thn
131 
132  stops(thn) = qrm_swtime()
133  nevents(thn) = nevents(thn)+1
134  events(thn, min(nevents(thn),maxevents)) = event_type(id, thn, starts(thn)-timezero, stops(thn)-timezero)
135  ttimes(id) = ttimes(id)+stops(thn)-starts(thn)
136  pendings(thn) = .false.
137 
138  return
139  end subroutine qrm_trace_event_stop
140 
141 
142  subroutine qrm_trace_log_dump(ofile)
143 
144  character :: ofile*(*)
145 
146  integer :: i, j
147  real(kind(1.d0)) :: tottime
148  real(kind(1.d0)), parameter :: h=20.d0, scale=10000
149 
150  open(4, file=ofile, action='write')
151 
152  write(4,'("<svg>")')
153  do i=0, maxth-1
154  do j=1, min(nevents(i),maxevents)
155  write(4,'("<rect style=""fill:",a7,";stroke:#000000;stroke-width:0;fill-opacity:1""&
156  & height=""",f5.1,""" width=""",f10.2""" y=""",f10.2,""" x=""",f10.2,""" />")')&
157  & colors(events(i,j)%id), h, &
158  & (events(i,j)%stop-events(i,j)%start)*scale, &
159 ! & h*(i-1), events(i,j)%start*scale
160  & real(h)*real(maxth-i), events(i,j)%start*scale
161  end do
162  end do
163 
164  tottime = sum(ttimes)
165 
166  do i=1, nevtype
167  write(4,'("<text x=""0"" y=""",f10.2,""" font-size=""",i3,""" fill=""",a7,""">",a20," -- ",f4.1,"%</text>")')&
168  & real(h)*real(maxth+i+2),floor(h),colors(i),labels(i),(ttimes(i)/tottime)*100
169  end do
170 
171  write(4,'("</svg>")')
172  close(4)
173 
174 
175  deallocate(events)
176 
177  return
178 
179  end subroutine qrm_trace_log_dump
180 
181 end module qrm_trace_mod
This module contains all the error management routines and data.
This module contains all the facilities for visualizing the execution profile of a parallel code...
This module contains the interfaces of all non-typed routines.
Generic interface for the ::qrm_swtime routine.
int i
Definition: secs.c:40