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_statistics.h
Go to the documentation of this file.
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 
29 #ifndef SC_STATISTICS_H
30 #define SC_STATISTICS_H
31 
32 #include <sc_keyvalue.h>
33 
34 SC_EXTERN_C_BEGIN;
35 
37 extern const int sc_stats_group_all;
38 
40 extern const int sc_stats_prio_all;
41 
43 typedef struct sc_statinfo
44 {
45  int dirty;
46  long count;
47  double sum_values;
48  double sum_squares;
49  double min;
50  double max;
51  int min_at_rank, max_at_rank; /* out */
52  double average, variance, standev; /* out */
53  double variance_mean, standev_mean; /* out */
54  const char *variable;
56  int group;
57  int prio;
58 }
60 
62 typedef struct sc_stats
63 {
64  sc_MPI_Comm mpicomm;
65  sc_keyvalue_t *kv;
66  sc_array_t *sarray;
67 }
69 
79  double value, const char *variable);
80 
91  double value, const char *variable,
92  int copy_variable,
93  int stats_group, int stats_prio);
94 
105  const char *variable);
106 
119  const char *variable,
120  int copy_variable,
121  int stats_group, int stats_prio);
122 
131 void sc_stats_reset (sc_statinfo_t * stats, int reset_vgp);
132 
140  int stats_group, int stats_prio);
141 
148 void sc_stats_accumulate (sc_statinfo_t * stats, double value);
149 
171 void sc_stats_compute (sc_MPI_Comm mpicomm, int nvars,
172  sc_statinfo_t * stats);
173 
180 void sc_stats_compute1 (sc_MPI_Comm mpicomm, int nvars,
181  sc_statinfo_t * stats);
182 
195 void sc_stats_print (int package_id, int log_priority,
196  int nvars, sc_statinfo_t * stats,
197  int full, int summary);
198 
225 void sc_stats_print_ext (int package_id, int log_priority,
226  int nvars, sc_statinfo_t * stats,
227  int stats_group, int stats_prio,
228  int full, int summary);
229 
233 
238 
243  const char *name);
244 
249  const char *name);
250 
253  const char *name);
259  const char *name, double value);
260 
265  const char *name, double value);
266 
270 
274  int package_id, int log_priority,
275  int full, int summary);
276 
277 SC_EXTERN_C_END;
278 
279 #endif /* !SC_STATISTICS_H */
This file provides a lookup structure for key-value pairs.
struct sc_keyvalue sc_keyvalue_t
The key-value container is an opaque structure.
Definition: sc_keyvalue.h:49
sc3_MPI_Comm_t sc_MPI_Comm
Emulate an MPI communicator.
Definition: sc_mpi.h:450
void sc_statistics_add(sc_statistics_t *stats, const char *name)
Register a statistics variable by name and set its value to 0.
void sc_stats_reset(sc_statinfo_t *stats, int reset_vgp)
Reset all values to zero, optionally unassign name, group, and priority.
void sc_stats_print_ext(int package_id, int log_priority, int nvars, sc_statinfo_t *stats, int stats_group, int stats_prio, int full, int summary)
Print measured statistics, filter by group and/or priority.
void sc_statistics_add_empty(sc_statistics_t *stats, const char *name)
Register a statistics variable by name and set its count to 0.
void sc_stats_accumulate(sc_statinfo_t *stats, double value)
Add an instance of the random variable.
void sc_statistics_set(sc_statistics_t *stats, const char *name, double value)
Set the value of a statistics variable, see sc_stats_set1.
void sc_stats_compute(sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t *stats)
Compute global average and standard deviation.
void sc_stats_init(sc_statinfo_t *stats, const char *variable)
Initialize a sc_statinfo_t structure assuming count=0 and mark it dirty.
int sc_statistics_has(sc_statistics_t *stats, const char *name)
Returns true if the stats include a variable with the given name.
sc_statistics_t * sc_statistics_new(sc_MPI_Comm mpicomm)
Create a new statistics structure that can grow dynamically.
void sc_statistics_destroy(sc_statistics_t *stats)
Destroy a statistics structure.
void sc_stats_set1(sc_statinfo_t *stats, double value, const char *variable)
Populate a sc_statinfo_t structure assuming count=1 and mark it dirty.
void sc_stats_set_group_prio(sc_statinfo_t *stats, int stats_group, int stats_prio)
Set/update the group and priority information for a stats item.
void sc_stats_compute1(sc_MPI_Comm mpicomm, int nvars, sc_statinfo_t *stats)
Version of sc_statistics_statistics that assumes count=1.
void sc_statistics_accumulate(sc_statistics_t *stats, const char *name, double value)
Add an instance of a statistics variable, see sc_stats_accumulate The variable must previously be add...
void sc_stats_init_ext(sc_statinfo_t *stats, const char *variable, int copy_variable, int stats_group, int stats_prio)
Initialize a sc_statinfo_t structure assuming count=0 and mark it dirty.
void sc_stats_set1_ext(sc_statinfo_t *stats, double value, const char *variable, int copy_variable, int stats_group, int stats_prio)
Populate a sc_statinfo_t structure assuming count=1 and mark it dirty.
struct sc_stats sc_statistics_t
The statistics container allows dynamically adding random variables.
void sc_statistics_print(sc_statistics_t *stats, int package_id, int log_priority, int full, int summary)
Print all statistics variables, see sc_stats_print.
const int sc_stats_prio_all
This special group number (negative) will refer to any priority.
const int sc_stats_group_all
This special group number (negative) will refer to any group.
struct sc_statinfo sc_statinfo_t
Store information of one random variable.
void sc_statistics_compute(sc_statistics_t *stats)
Compute statistics for all variables, see sc_stats_compute.
void sc_stats_print(int package_id, int log_priority, int nvars, sc_statinfo_t *stats, int full, int summary)
Print measured statistics.
The sc_array object provides a dynamic array of equal-size elements.
Definition: sc_containers.h:117
Store information of one random variable.
Definition: sc_statistics.h:44
int group
Grouping identifier.
Definition: sc_statistics.h:56
double min
Inout; minimum over values.
Definition: sc_statistics.h:49
const char * variable
Name of the variable for output.
Definition: sc_statistics.h:54
double max
Inout; maximum over values.
Definition: sc_statistics.h:50
double sum_squares
Inout; global sum of squares.
Definition: sc_statistics.h:48
int prio
Priority identifier.
Definition: sc_statistics.h:57
long count
Inout; global count is 52 bit accurate.
Definition: sc_statistics.h:46
int dirty
Only update stats if this is true.
Definition: sc_statistics.h:45
char * variable_owned
NULL or deep copy of variable.
Definition: sc_statistics.h:55
double sum_values
Inout; global sum of values.
Definition: sc_statistics.h:47
The statistics container allows dynamically adding random variables.
Definition: sc_statistics.h:63