Ifpack Package Browser (Single Doxygen Collection)
Development
Toggle main menu visibility
Loading...
Searching...
No Matches
src
euclid
TimeLog_dh.c
Go to the documentation of this file.
1
/*@HEADER
2
// ***********************************************************************
3
//
4
// Ifpack: Object-Oriented Algebraic Preconditioner Package
5
// Copyright (2002) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38
//
39
// ***********************************************************************
40
//@HEADER
41
*/
42
43
#include "
TimeLog_dh.h
"
44
#include "
Timer_dh.h
"
45
#include "
Mem_dh.h
"
46
47
#define MAX_TIME_MARKS 100
48
#define MAX_DESC_LENGTH 60
49
50
struct
_timeLog_dh
51
{
52
int
first
;
53
int
last
;
54
double
time
[
MAX_TIME_MARKS
];
55
char
desc
[
MAX_TIME_MARKS
][
MAX_DESC_LENGTH
];
56
Timer_dh
timer
;
57
};
58
59
#undef __FUNC__
60
#define __FUNC__ "TimeLog_dhCreate"
61
void
62
TimeLog_dhCreate
(
TimeLog_dh
* t)
63
{
64
START_FUNC_DH
int
i;
65
struct
_timeLog_dh
*tmp =
66
(
struct
_timeLog_dh
*)
MALLOC_DH
(
sizeof
(
struct
_timeLog_dh
));
67
CHECK_V_ERROR
;
68
*t = tmp;
69
tmp->
first
= tmp->
last
= 0;
70
Timer_dhCreate
(&tmp->
timer
);
71
for
(i = 0; i <
MAX_TIME_MARKS
; ++i)
72
strcpy (tmp->
desc
[i],
"X"
);
73
END_FUNC_DH
}
74
75
#undef __FUNC__
76
#define __FUNC__ "TimeLog_dhDestroy"
77
void
78
TimeLog_dhDestroy
(
TimeLog_dh
t)
79
{
80
START_FUNC_DH
Timer_dhDestroy
(t->
timer
);
81
FREE_DH
(t);
82
END_FUNC_DH
}
83
84
85
#undef __FUNC__
86
#define __FUNC__ "TimeLog_dhStart"
87
void
88
TimeLog_dhStart
(
TimeLog_dh
t)
89
{
90
START_FUNC_DH
Timer_dhStart
(t->
timer
);
91
END_FUNC_DH
}
92
93
#undef __FUNC__
94
#define __FUNC__ "TimeLog_dhStop"
95
void
96
TimeLog_dhStop
(
TimeLog_dh
t)
97
{
98
START_FUNC_DH
Timer_dhStop
(t->
timer
);
99
END_FUNC_DH
}
100
101
#undef __FUNC__
102
#define __FUNC__ "TimeLog_dhMark"
103
void
104
TimeLog_dhMark
(
TimeLog_dh
t,
char
*
desc
)
105
{
106
START_FUNC_DH
if
(t->
last
<
MAX_TIME_MARKS
- 3)
107
{
108
/* SET_V_ERROR("overflow; please increase MAX_TIME_MARKS and recompile"); */
109
Timer_dhStop
(t->
timer
);
110
t->
time
[t->
last
] =
Timer_dhReadWall
(t->
timer
);
111
Timer_dhStart
(t->
timer
);
112
sprintf (t->
desc
[t->
last
],
desc
);
113
t->
last
+= 1;
114
}
115
END_FUNC_DH
}
116
117
#undef __FUNC__
118
#define __FUNC__ "TimeLog_dhReset"
119
void
120
TimeLog_dhReset
(
TimeLog_dh
t)
121
{
122
START_FUNC_DH
if
(t->
last
<
MAX_TIME_MARKS
- 2)
123
{
124
double
total = 0.0;
125
int
i,
first
= t->
first
,
last
= t->
last
;
126
for
(i =
first
; i <
last
; ++i)
127
total += t->
time
[i];
128
t->
time
[
last
] = total;
129
sprintf (t->
desc
[
last
],
"========== totals, and reset ==========\n"
);
130
t->
last
+= 1;
131
t->
first
= t->
last
;
132
Timer_dhStart
(t->
timer
);
133
}
134
END_FUNC_DH
}
135
136
137
#undef __FUNC__
138
#define __FUNC__ "TimeLog_dhPrint"
139
void
140
TimeLog_dhPrint
(
TimeLog_dh
t, FILE * fp,
bool
allPrint)
141
{
142
START_FUNC_DH
int
i;
143
double
total = 0.0;
144
double
timeMax[
MAX_TIME_MARKS
];
145
double
timeMin[
MAX_TIME_MARKS
];
146
static
bool
wasSummed =
false
;
147
148
149
if
(!wasSummed)
150
{
151
for
(i = t->
first
; i < t->
last
; ++i)
152
total += t->
time
[i];
153
t->
time
[t->
last
] = total;
154
sprintf (t->
desc
[t->
last
],
"========== totals, and reset ==========\n"
);
155
t->
last
+= 1;
156
157
MPI_Allreduce (t->
time
, timeMax, t->
last
, MPI_DOUBLE, MPI_MAX,
comm_dh
);
158
MPI_Allreduce (t->
time
, timeMin, t->
last
, MPI_DOUBLE, MPI_MIN,
comm_dh
);
159
wasSummed =
true
;
160
}
161
162
if
(fp != NULL)
163
{
164
if
(
myid_dh
== 0 || allPrint)
165
{
166
fprintf (fp,
167
"\n----------------------------------------- timing report\n"
);
168
fprintf (fp,
"\n self max min\n"
);
169
for
(i = 0; i < t->
last
; ++i)
170
{
171
fprintf (fp,
"%7.3f %7.3f %7.3f #%s\n"
, t->
time
[i],
172
timeMax[i], timeMin[i], t->
desc
[i]);
173
}
174
fflush (fp);
175
}
176
}
/* if (fp != NULL) */
177
END_FUNC_DH
}
Mem_dh.h
TimeLog_dhStart
void TimeLog_dhStart(TimeLog_dh t)
Definition
TimeLog_dh.c:88
TimeLog_dhCreate
void TimeLog_dhCreate(TimeLog_dh *t)
Definition
TimeLog_dh.c:62
MAX_DESC_LENGTH
#define MAX_DESC_LENGTH
Definition
TimeLog_dh.c:48
TimeLog_dhStop
void TimeLog_dhStop(TimeLog_dh t)
Definition
TimeLog_dh.c:96
TimeLog_dhDestroy
void TimeLog_dhDestroy(TimeLog_dh t)
Definition
TimeLog_dh.c:78
MAX_TIME_MARKS
#define MAX_TIME_MARKS
Definition
TimeLog_dh.c:47
TimeLog_dhPrint
void TimeLog_dhPrint(TimeLog_dh t, FILE *fp, bool allPrint)
Definition
TimeLog_dh.c:140
TimeLog_dhMark
void TimeLog_dhMark(TimeLog_dh t, char *desc)
Definition
TimeLog_dh.c:104
TimeLog_dhReset
void TimeLog_dhReset(TimeLog_dh t)
Definition
TimeLog_dh.c:120
TimeLog_dh.h
Timer_dhCreate
void Timer_dhCreate(Timer_dh *t)
Definition
Timer_dh.c:49
Timer_dhStop
void Timer_dhStop(Timer_dh t)
Definition
Timer_dh.c:217
Timer_dhReadWall
double Timer_dhReadWall(Timer_dh t)
Definition
Timer_dh.c:224
Timer_dhStart
void Timer_dhStart(Timer_dh t)
Definition
Timer_dh.c:210
Timer_dhDestroy
void Timer_dhDestroy(Timer_dh t)
Definition
Timer_dh.c:80
Timer_dh.h
myid_dh
int myid_dh
Definition
globalObjects.c:63
TimeLog_dh
struct _timeLog_dh * TimeLog_dh
Definition
euclid_common.h:83
comm_dh
MPI_Comm comm_dh
Definition
globalObjects.c:64
Timer_dh
struct _timer_dh * Timer_dh
Definition
euclid_common.h:81
MALLOC_DH
#define MALLOC_DH(s)
Definition
euclid_config.h:123
FREE_DH
#define FREE_DH(p)
Definition
euclid_config.h:124
START_FUNC_DH
#define START_FUNC_DH
Definition
macros_dh.h:181
CHECK_V_ERROR
#define CHECK_V_ERROR
Definition
macros_dh.h:138
END_FUNC_DH
#define END_FUNC_DH
Definition
macros_dh.h:187
_timeLog_dh
Definition
TimeLog_dh.c:51
_timeLog_dh::time
double time[MAX_TIME_MARKS]
Definition
TimeLog_dh.c:54
_timeLog_dh::timer
Timer_dh timer
Definition
TimeLog_dh.c:56
_timeLog_dh::first
int first
Definition
TimeLog_dh.c:52
_timeLog_dh::last
int last
Definition
TimeLog_dh.c:53
_timeLog_dh::desc
char desc[MAX_TIME_MARKS][MAX_DESC_LENGTH]
Definition
TimeLog_dh.c:55
Generated by
1.17.0