libsc  2.8.7
The SC library provides support for parallel scientific applications.
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sc_flops.h
1 /*
2  This file is part of the SC Library.
3  The SC Library provides support for parallel scientific applications.
4 
5  Copyright (C) 2010 The University of Texas System
6  Additional copyright (C) 2011 individual authors
7 
8  The SC Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  The SC Library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with the SC Library; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 */
23 
24 #ifndef SC_FLOPS_H
25 #define SC_FLOPS_H
26 
27 #include <sc.h>
28 
29 SC_EXTERN_C_BEGIN;
30 
31 typedef struct sc_flopinfo
32 {
33  double seconds; /* current time from sc_MPI_Wtime */
34 
35  /* these variables measure onward from from sc_flops_start */
36  double cwtime; /* cumulative wall time */
37  float crtime; /* cumulative real time */
38  float cptime; /* cumulative process time */
39  long long cflpops; /* cumulative floating point operations */
40 
41  /* measure since sc_flops_start or the previous sc_flops_count */
42  double iwtime; /* interval wall time */
43  float irtime; /* interval real time */
44  float iptime; /* interval process time */
45  long long iflpops; /* interval floating point operations */
46  float mflops; /* MFlop/s rate in this interval */
47 
48  /* without SC_PAPI only seconds, ?wtime and ?rtime are meaningful */
49  int use_papi;
50 }
52 
61 void sc_flops_papi (float *rtime, float *ptime,
62  long long *flpops, float *mflops);
63 
71 void sc_flops_start (sc_flopinfo_t * fi);
72 
80 void sc_flops_start_nopapi (sc_flopinfo_t * fi);
81 
90 void sc_flops_count (sc_flopinfo_t * fi);
91 
98 void sc_flops_snap (sc_flopinfo_t * fi,
99  sc_flopinfo_t * snapshot);
100 
110 void sc_flops_shot (sc_flopinfo_t * fi,
111  sc_flopinfo_t * snapshot);
112 
117 void sc_flops_shotv (sc_flopinfo_t * fi, ...);
118 
122 #define SC_FUNC_SNAP(stat,flop,snap) \
123  do { \
124  if (!sc_statistics_has ((stat), __func__)) { \
125  sc_statistics_add_empty ((stat), __func__); \
126  } \
127  sc_flops_snap ((flop), (snap)); \
128  } while (0)
129 
130 #define SC_FUNC_SHOT(stat,flop,snap) \
131  do { \
132  sc_flops_shot ((flop), (snap)); \
133  sc_statistics_accumulate ((stat), __func__, (snap)->iwtime); \
134  } while (0)
135 
136 SC_EXTERN_C_END;
137 
138 #endif /* !SC_FLOPS_H */
Support for process management (memory allocation, logging, etc.)
Definition: sc_flops.h:32