HPCToolkit
hpcpapi.h
Go to the documentation of this file.
1 // -*-Mode: C++;-*- // technically C99
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 /****************************************************************************
48 //
49 // File:
50 // $HeadURL$
51 //
52 // Purpose:
53 // General PAPI support.
54 //
55 // Description:
56 // [The set of functions, macros, etc. defined in the file]
57 //
58 // Author:
59 // Written by John Mellor-Crummey and Nathan Tallent, Rice University.
60 //
61 *****************************************************************************/
62 
63 #ifndef hpcpapi_h
64 #define hpcpapi_h
65 
66 /************************** System Include Files ****************************/
67 
68 #include <stdlib.h>
69 #include <inttypes.h>
70 
71 #include <papi.h>
72 #if !(defined(PAPI_VERSION) && (PAPI_VERSION_MAJOR(PAPI_VERSION) >= 3))
73 # error "Must use PAPI version 3 or greater."
74 #endif
75 
76 /**************************** User Include Files ****************************/
77 
78 /**************************** Forward Declarations **************************/
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
84 /* hpc_init_papi: Initialize the PAPI library if not already
85  initialized and perform error checking. If an error is
86  encountered, print an error message and return non-zero; otherwise
87  return 0. May be called multiple times. */
88 extern int
89 hpc_init_papi(int (*is_init)(void), int (*init)(int));
90 
91 
92 /* hpc_init_papi_force: Force initialization of the PAPI library
93  perform error checking. If an error is encountered, print an error
94  message and return non-zero; otherwise return 0. May be called
95  only once. */
96 extern int
97 hpc_init_papi_force(int (*init)(int));
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 /**************************** Forward Declarations **************************/
104 
105 // hpcpapi_flagdesc_t: PAPI_sprofil() flags
106 typedef struct {
107  int code; /* PAPI flag value */
108  const char *name; /* PAPI flag name */
110 
111 
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
115 
116 extern const hpcpapi_flagdesc_t *
117 hpcpapi_flag_by_name(const char *name);
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 /**************************** Forward Declarations **************************/
124 
125 // hpcpapi_profile_desc_t: Collects all information to describe one
126 // call to PAPI_sprofil(). Note that the segmented-profile buffers
127 // will correspond to data in the run-time-load-map.
128 typedef struct {
129  PAPI_event_info_t einfo; // PAPI's info for the event
130  int ecode; // PAPI's event code
131  uint64_t period; // sampling period
132  int flags; // profiling flags
133 
134  unsigned int bytesPerCodeBlk; // bytes per block of monitored code
135  unsigned int bytesPerCntr; // bytes per histogram counter
136  unsigned int scale; // relationship between the two
137 
138  PAPI_sprofil_t* sprofs; // vector of histogram buffers, one for each
139  unsigned int numsprofs; // run time load module
141 
142 void
144 
145 void
147  const char* prefix);
148 
149 
150 // hpcpapi_profile_desc_vec_t: A vector of hpcpapi_profile_desc_t.
151 typedef struct {
152  int eset; // the event set
153 
154  unsigned int size; // vector size
155  hpcpapi_profile_desc_t* vec; // one for each event
157 
158 
159 void
161 
162 
163 /****************************************************************************/
164 
165 #endif /* hpcpapi_h */
unsigned int bytesPerCodeBlk
Definition: hpcpapi.h:134
static int is_init
Definition: sample_prob.c:67
PAPI_sprofil_t * sprofs
Definition: hpcpapi.h:138
int hpc_init_papi_force(int(*init)(int))
Definition: hpcpapi.c:91
unsigned int bytesPerCntr
Definition: hpcpapi.h:135
static char * prefix
Definition: common.c:164
const char * name
Definition: hpcpapi.h:108
void dump_hpcpapi_profile_desc_buf(hpcpapi_profile_desc_t *desc, int idx, const char *prefix)
Definition: hpcpapi.c:170
void dump_hpcpapi_profile_desc(hpcpapi_profile_desc_t *desc, const char *prefix)
Definition: hpcpapi.c:152
void dump_hpcpapi_profile_desc_vec(hpcpapi_profile_desc_vec_t *descvec)
Definition: hpcpapi.c:139
unsigned int scale
Definition: hpcpapi.h:136
hpcpapi_profile_desc_t * vec
Definition: hpcpapi.h:155
unsigned int numsprofs
Definition: hpcpapi.h:139
int hpc_init_papi(int(*is_init)(void), int(*init)(int))
Definition: hpcpapi.c:78
PAPI_event_info_t einfo
Definition: hpcpapi.h:129
const hpcpapi_flagdesc_t * hpcpapi_flag_by_name(const char *name)
Definition: hpcpapi.c:126