PEXSI
Main Page
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Pages
include
pexsi
timer.h
Go to the documentation of this file.
1
/*
2
Copyright (c) 2012 The Regents of the University of California,
3
through Lawrence Berkeley National Laboratory.
4
5
Author: Edgar Solomonik and Mathias Jacquelin
6
7
This file is part of Cyclops Tensor Framework (CTF) and PEXSI. All rights
8
reserved.
9
10
Redistribution and use in source and binary forms, with or without
11
modification, are permitted provided that the following conditions are met:
12
13
(1) Redistributions of source code must retain the above copyright notice, this
14
list of conditions and the following disclaimer.
15
(2) Redistributions in binary form must reproduce the above copyright notice,
16
this list of conditions and the following disclaimer in the documentation
17
and/or other materials provided with the distribution.
18
(3) Neither the name of the University of California, Lawrence Berkeley
19
National Laboratory, U.S. Dept. of Energy nor the names of its contributors may
20
be used to endorse or promote products derived from this software without
21
specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
27
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34
You are under no obligation whatsoever to provide any bug fixes, patches, or
35
upgrades to the features, functionality or performance of the source code
36
("Enhancements") to anyone; however, if you choose to make your Enhancements
37
available either publicly, or directly to Lawrence Berkeley National
38
Laboratory, without imposing a separate written license agreement for such
39
Enhancements, then you hereby grant the following license: a non-exclusive,
40
royalty-free perpetual license to install, use, modify, prepare derivative
41
works, incorporate into other computer software, distribute, and sublicense
42
such enhancements or derivative works thereof, in binary and source code form.
43
*/
47
#ifndef _PEXSI_TIMER_H_
48
#define _PEXSI_TIMER_H_
49
50
#define VAL(str) #str
51
#define TOSTRING(str) VAL(str)
52
53
#ifdef USE_TAU
54
#include "pexsi/TAU.h"
55
#define TIMER_START(a) TAU_START(TOSTRING(a));
56
#define TIMER_STOP(a) TAU_STOP(TOSTRING(a));
57
58
#elif defined (PROFILE) || defined(PMPI)
59
#define TAU
60
#define TIMER_START(a) TAU_FSTART(a);
61
#define TIMER_STOP(a) TAU_FSTOP(a);
62
63
#else
64
65
#define TIMER_START(a)
66
#define TIMER_STOP(a)
67
#endif
68
69
70
71
#include <mpi.h>
72
73
74
class
CTF_timer
{
75
public
:
76
char
const
* timer_name;
77
int
index;
78
int
exited;
79
int
original;
80
81
public
:
82
CTF_timer
(
char
const
* name);
83
~
CTF_timer
();
84
void
stop();
85
void
start();
86
void
exit();
87
88
};
89
90
void
CTF_set_main_args(
int
argc,
char
*
const
* argv);
91
void
CTF_set_context(MPI_Comm ctxt);
92
93
#ifdef TAU
94
#define TAU_FSTART(ARG) \
95
do { CTF_timer t(#ARG); t.start(); } while (0);
96
97
#define TAU_FSTOP(ARG) \
98
do { CTF_timer t(#ARG); t.stop(); } while (0);
99
100
#define TAU_PROFILE_TIMER(ARG1, ARG2, ARG3, ARG4)
101
102
#define TAU_PROFILE_INIT(argc, argv) \
103
CTF_set_main_args(argc, argv);
104
105
#define TAU_PROFILE_SET_NODE(ARG)
106
107
#define TAU_PROFILE_START(ARG) \
108
CTF_timer __CTF_timer##ARG(#ARG);
109
110
#define TAU_PROFILE_STOP(ARG) \
111
__CTF_timer##ARG.stop();
112
113
#define TAU_PROFILE_SET_CONTEXT(ARG) \
114
if (ARG==0) CTF_set_context(MPI_COMM_WORLD); \
115
else CTF_set_context((MPI_Comm)ARG);
116
#endif
117
118
#ifdef PMPI
119
#define MPI_Bcast(...) \
120
{ CTF_timer __t("MPI_Bcast"); \
121
__t.start(); \
122
PMPI_Bcast(__VA_ARGS__); \
123
__t.stop(); }
124
#define MPI_Reduce(...) \
125
{ CTF_timer __t("MPI_Reduce"); \
126
__t.start(); \
127
PMPI_Reduce(__VA_ARGS__); \
128
__t.stop(); }
129
#define MPI_Wait(...) \
130
{ CTF_timer __t("MPI_Wait"); \
131
__t.start(); \
132
PMPI_Wait(__VA_ARGS__); \
133
__t.stop(); }
134
#define MPI_Send(...) \
135
{ CTF_timer __t("MPI_Send"); \
136
__t.start(); \
137
PMPI_Send(__VA_ARGS__); \
138
__t.stop(); }
139
#define MPI_Allreduce(...) \
140
{ CTF_timer __t("MPI_Allreduce"); \
141
__t.start(); \
142
PMPI_Allreduce(__VA_ARGS__); \
143
__t.stop(); }
144
#define MPI_Allgather(...) \
145
{ CTF_timer __t("MPI_Allgather"); \
146
__t.start(); \
147
PMPI_Allgather(__VA_ARGS__); \
148
__t.stop(); }
149
#define MPI_Scatter(...) \
150
{ CTF_timer __t("MPI_Scatter"); \
151
__t.start(); \
152
PMPI_Scatter(__VA_ARGS__); \
153
__t.stop(); }
154
#define MPI_Alltoall(...) \
155
{ CTF_timer __t("MPI_Alltoall"); \
156
__t.start(); \
157
PMPI_Alltoall(__VA_ARGS__); \
158
__t.stop(); }
159
#define MPI_Alltoallv(...) \
160
{ CTF_timer __t("MPI_Alltoallv"); \
161
__t.start(); \
162
PMPI_Alltoallv(__VA_ARGS__); \
163
__t.stop(); }
164
#define MPI_Gatherv(...) \
165
{ CTF_timer __t("MPI_Gatherv"); \
166
__t.start(); \
167
PMPI_Gatherv(__VA_ARGS__); \
168
__t.stop(); }
169
#define MPI_Scatterv(...) \
170
{ CTF_timer __t("MPI_Scatterv"); \
171
__t.start(); \
172
PMPI_Scatterv(__VA_ARGS__); \
173
__t.stop(); }
174
#define MPI_Waitall(...) \
175
{ CTF_timer __t("MPI_Waitall"); \
176
__t.start(); \
177
PMPI_Waitall(__VA_ARGS__); \
178
__t.stop(); }
179
#define MPI_Barrier(...) \
180
{ CTF_timer __t("MPI_Barrier"); \
181
__t.start(); \
182
PMPI_Barrier(__VA_ARGS__); \
183
__t.stop(); }
184
#endif
185
186
#endif //_PEXSI_TIMER_H_
187
CTF_timer
Definition:
timer.h:74
Generated on Wed Mar 16 2016 13:35:03 for PEXSI by
1.8.6