PAPI 7.1.0.0
Loading...
Searching...
No Matches
template.c File Reference
Include dependency graph for template.c:

Go to the source code of this file.

Data Structures

struct  templ_context_t
 
struct  templ_control_t
 

Macros

#define TEMPLATE_MAX_COUNTERS   (16)
 

Functions

static int templ_init_component (int cid)
 
static int templ_init_thread (hwd_context_t *ctx)
 
static int templ_init_control_state (hwd_control_state_t *ctl)
 
static int templ_init_private (void)
 
static int templ_shutdown_component (void)
 
static int templ_shutdown_thread (hwd_context_t *ctx)
 
static int templ_cleanup_eventset (hwd_control_state_t *ctl)
 
static int templ_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *ntv_info, int ntv_count, hwd_context_t *ctx)
 
static int templ_start (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int templ_read (hwd_context_t *ctx, hwd_control_state_t *ctl, long long **val, int flags)
 
static int templ_stop (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int templ_reset (hwd_context_t *ctx, hwd_control_state_t *ctl)
 
static int templ_ntv_enum_events (unsigned int *event_code, int modifier)
 
static int templ_ntv_code_to_name (unsigned int event_code, char *name, int len)
 
static int templ_ntv_name_to_code (const char *name, unsigned int *event_code)
 
static int templ_ntv_code_to_descr (unsigned int event_code, char *descr, int len)
 
static int templ_ntv_code_to_info (unsigned int event_code, PAPI_event_info_t *info)
 
static int templ_set_domain (hwd_control_state_t *ctl, int domain)
 
static int templ_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
static int check_n_initialize (void)
 
int templ_init_control_state (hwd_control_state_t *ctl __attribute__((unused)))
 
static int evt_get_count (int *count)
 
static int update_native_events (templ_control_t *, NativeInfo_t *, int)
 
static int try_open_events (templ_control_t *)
 
int templ_update_control_state (hwd_control_state_t *ctl, NativeInfo_t *ntv_info, int ntv_count, hwd_context_t *ctx __attribute__((unused)))
 
int templ_read (hwd_context_t *ctx __attribute__((unused)), hwd_control_state_t *ctl, long long **val, int flags __attribute__((unused)))
 
int templ_reset (hwd_context_t *ctx __attribute__((unused)), hwd_control_state_t *ctl)
 
int templ_set_domain (hwd_control_state_t *ctl __attribute__((unused)), int domain __attribute__((unused)))
 
int templ_ctl (hwd_context_t *ctx __attribute__((unused)), int code __attribute__((unused)), _papi_int_option_t *option __attribute__((unused)))
 

Variables

papi_vector_t _template_vector
 

Macro Definition Documentation

◆ TEMPLATE_MAX_COUNTERS

#define TEMPLATE_MAX_COUNTERS   (16)

Definition at line 9 of file template.c.

Function Documentation

◆ check_n_initialize()

int check_n_initialize ( void  )
static

Definition at line 409 of file template.c.

410{
412 return templ_init_private();
413 }
415}
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
papi_vector_t _template_vector
Definition: template.c:51
static int templ_init_private(void)
Definition: template.c:148
Here is the call graph for this function:
Here is the caller graph for this function:

◆ evt_get_count()

static int evt_get_count ( int count)
static

Definition at line 133 of file template.c.

134{
135 unsigned int event_code = 0;
136
137 if (vendord_evt_enum(&event_code, PAPI_ENUM_FIRST) == PAPI_OK) {
138 ++(*count);
139 }
140 while (vendord_evt_enum(&event_code, PAPI_ENUM_EVENTS) == PAPI_OK) {
141 ++(*count);
142 }
143
144 return PAPI_OK;
145}
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
int vendord_evt_enum(unsigned int *event_code, int modifier)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ templ_cleanup_eventset()

int templ_cleanup_eventset ( hwd_control_state_t ctl)
static

Definition at line 199 of file template.c.

200{
202 papi_free(templ_ctl->events_id);
203 templ_ctl->events_id = NULL;
204 templ_ctl->num_events = 0;
205 return PAPI_OK;
206}
#define papi_free(a)
Definition: papi_memory.h:35
static int templ_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ templ_ctl() [1/2]

int templ_ctl ( hwd_context_t *ctx   __attribute__(unused),
int code   __attribute__(unused),
_papi_int_option_t *option   __attribute__(unused) 
)

Definition at line 403 of file template.c.

404{
405 return PAPI_OK;
406}

◆ templ_ctl() [2/2]

static int templ_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)
static
Here is the caller graph for this function:

◆ templ_init_component()

int templ_init_component ( int  cid)
static

Definition at line 94 of file template.c.

95{
100
101 int papi_errno = vendord_init_pre();
102 if (papi_errno != PAPI_OK) {
105 const char *err_string;
106 vendord_err_get_last(&err_string);
107 snprintf(_template_vector.cmp_info.disabled_reason, PAPI_MAX_STR_LEN, "%s", err_string);
108 return papi_errno;
109 }
110
111 sprintf(_template_vector.cmp_info.disabled_reason, "Not initialized. Access component events to initialize it.");
113 return PAPI_EDELAY_INIT;
114}
#define PAPI_NUM_LOCK
Definition: f90papi.h:80
#define PAPI_EDELAY_INIT
Definition: f90papi.h:271
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define NUM_INNER_LOCK
Definition: papi_lock.h:17
char disabled_reason[PAPI_HUGE_STR_LEN]
Definition: papi.h:634
unsigned int _templ_lock
Definition: vendor_common.c:4
int vendord_init_pre(void)
int vendord_err_get_last(const char **error)
Here is the call graph for this function:

◆ templ_init_control_state() [1/2]

int templ_init_control_state ( hwd_control_state_t *ctl   __attribute__(unused))

Definition at line 127 of file template.c.

128{
129 return check_n_initialize();
130}
static int check_n_initialize(void)
Definition: template.c:409
Here is the call graph for this function:

◆ templ_init_control_state() [2/2]

static int templ_init_control_state ( hwd_control_state_t ctl)
static

◆ templ_init_private()

int templ_init_private ( void  )
static

Definition at line 148 of file template.c.

149{
150 int papi_errno = PAPI_OK;
151
153
156 goto fn_exit;
157 }
158
159 papi_errno = vendord_init();
160 if (papi_errno != PAPI_OK) {
162 const char *err_string;
163 vendord_err_get_last(&err_string);
164 snprintf(_template_vector.cmp_info.disabled_reason, PAPI_MAX_STR_LEN, "%s", err_string);
165 goto fn_fail;
166 }
167
168 int count = 0;
169 papi_errno = evt_get_count(&count);
172
173 fn_exit:
177 return papi_errno;
178 fn_fail:
179 goto fn_exit;
180}
static long count
#define COMPONENT_LOCK
Definition: papi_internal.h:90
static int evt_get_count(int *count)
Definition: template.c:133
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:69
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:83
int vendord_init(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ templ_init_thread()

int templ_init_thread ( hwd_context_t ctx)
static

Definition at line 117 of file template.c.

118{
119 templ_context_t *templ_ctx = (templ_context_t *) ctx;
120 memset(templ_ctx, 0, sizeof(*templ_ctx));
121 templ_ctx->initialized = 1;
123 return PAPI_OK;
124}
int component_id
Definition: template.c:42

◆ templ_ntv_code_to_descr()

int templ_ntv_code_to_descr ( unsigned int  event_code,
char *  descr,
int  len 
)
static

Definition at line 377 of file template.c.

378{
379 int papi_errno = check_n_initialize();
380 if (papi_errno != PAPI_OK) {
381 return papi_errno;
382 }
383 return vendord_evt_code_to_descr(event_code, descr, len);
384}
int vendord_evt_code_to_descr(unsigned int event_code, char *descr, int len)
char * descr
Here is the call graph for this function:

◆ templ_ntv_code_to_info()

int templ_ntv_code_to_info ( unsigned int  event_code,
PAPI_event_info_t info 
)
static

Definition at line 387 of file template.c.

388{
389 int papi_errno = check_n_initialize();
390 if (papi_errno != PAPI_OK) {
391 return papi_errno;
392 }
393 return vendord_evt_code_to_info(event_code, info);
394}
int vendord_evt_code_to_info(unsigned int event_code, PAPI_event_info_t *info)
Here is the call graph for this function:

◆ templ_ntv_code_to_name()

int templ_ntv_code_to_name ( unsigned int  event_code,
char *  name,
int  len 
)
static

Definition at line 357 of file template.c.

358{
359 int papi_errno = check_n_initialize();
360 if (papi_errno != PAPI_OK) {
361 return papi_errno;
362 }
363 return vendord_evt_code_to_name(event_code, name, len);
364}
const char * name
Definition: rocs.c:225
int vendord_evt_code_to_name(unsigned int event_code, char *name, int len)
Here is the call graph for this function:

◆ templ_ntv_enum_events()

int templ_ntv_enum_events ( unsigned int event_code,
int  modifier 
)
static

Definition at line 347 of file template.c.

348{
349 int papi_errno = check_n_initialize();
350 if (papi_errno != PAPI_OK) {
351 return papi_errno;
352 }
353 return vendord_evt_enum(event_code, modifier);
354}
Here is the call graph for this function:

◆ templ_ntv_name_to_code()

int templ_ntv_name_to_code ( const char *  name,
unsigned int event_code 
)
static

Definition at line 367 of file template.c.

368{
369 int papi_errno = check_n_initialize();
370 if (papi_errno != PAPI_OK) {
371 return papi_errno;
372 }
373 return vendord_evt_name_to_code(name, code);
374}
int vendord_evt_name_to_code(const char *name, unsigned int *event_code)
Here is the call graph for this function:

◆ templ_read() [1/2]

int templ_read ( hwd_context_t *ctx   __attribute__(unused),
hwd_control_state_t ctl,
long long **  val,
int flags   __attribute__(unused) 
)

Definition at line 306 of file template.c.

307{
309 return vendord_ctx_read(templ_ctl->vendor_ctx, val);
310}
int vendord_ctx_read(vendord_ctx_t ctx, long long **counters)
Here is the call graph for this function:

◆ templ_read() [2/2]

static int templ_read ( hwd_context_t ctx,
hwd_control_state_t ctl,
long long **  val,
int  flags 
)
static

◆ templ_reset() [1/2]

int templ_reset ( hwd_context_t *ctx   __attribute__(unused),
hwd_control_state_t ctl 
)

Definition at line 340 of file template.c.

341{
343 return vendord_ctx_reset(templ_ctl->vendor_ctx);
344}
int vendord_ctx_reset(vendord_ctx_t ctx)
Here is the call graph for this function:

◆ templ_reset() [2/2]

static int templ_reset ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

◆ templ_set_domain() [1/2]

int templ_set_domain ( hwd_control_state_t *ctl   __attribute__(unused),
int domain   __attribute__(unused) 
)

Definition at line 397 of file template.c.

398{
399 return PAPI_OK;
400}

◆ templ_set_domain() [2/2]

static int templ_set_domain ( hwd_control_state_t ctl,
int  domain 
)
static

◆ templ_shutdown_component()

int templ_shutdown_component ( void  )
static

Definition at line 183 of file template.c.

184{
186 return vendord_shutdown();
187}
int vendord_shutdown(void)
Here is the call graph for this function:

◆ templ_shutdown_thread()

int templ_shutdown_thread ( hwd_context_t ctx)
static

Definition at line 190 of file template.c.

191{
192 templ_context_t *templ_ctx = (templ_context_t *) ctx;
193 templ_ctx->initialized = 0;
194 templ_ctx->state = 0;
195 return PAPI_OK;
196}

◆ templ_start()

int templ_start ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 275 of file template.c.

276{
277 int papi_errno = PAPI_OK;
278 templ_context_t *templ_ctx = (templ_context_t *) ctx;
280
281 if (templ_ctx->state & TEMPL_CTX_OPENED) {
282 return PAPI_EINVAL;
283 }
284
285 papi_errno = vendord_ctx_open(templ_ctl->events_id, templ_ctl->num_events, &templ_ctl->vendor_ctx);
286 if (papi_errno != PAPI_OK) {
287 goto fn_fail;
288 }
289 templ_ctx->state = TEMPL_CTX_OPENED;
290
291 papi_errno = vendord_ctx_start(templ_ctl->vendor_ctx);
292 if (papi_errno != PAPI_OK) {
293 goto fn_fail;
294 }
295 templ_ctx->state |= TEMPL_CTX_RUNNING;
296
297 fn_exit:
298 return papi_errno;
299 fn_fail:
300 vendord_ctx_close(templ_ctl->vendor_ctx);
301 templ_ctx->state = 0;
302 goto fn_exit;
303}
#define PAPI_EINVAL
Definition: f90papi.h:115
#define TEMPL_CTX_RUNNING
Definition: vendor_config.h:5
#define TEMPL_CTX_OPENED
Definition: vendor_config.h:4
int vendord_ctx_start(vendord_ctx_t ctx)
int vendord_ctx_open(unsigned int *events_id, int num_events, vendord_ctx_t *ctx)
int vendord_ctx_close(vendord_ctx_t ctx)
Here is the call graph for this function:

◆ templ_stop()

int templ_stop ( hwd_context_t ctx,
hwd_control_state_t ctl 
)
static

Definition at line 313 of file template.c.

314{
315 int papi_errno = PAPI_OK;
316 templ_context_t *templ_ctx = (templ_context_t *) ctx;
318
319 if (!(templ_ctx->state & TEMPL_CTX_OPENED)) {
320 return PAPI_EINVAL;
321 }
322
323 papi_errno = vendord_ctx_stop(templ_ctl->vendor_ctx);
324 if (papi_errno != PAPI_OK) {
325 return papi_errno;
326 }
327 templ_ctx->state &= ~TEMPL_CTX_RUNNING;
328
329 papi_errno = vendord_ctx_close(templ_ctl->vendor_ctx);
330 if (papi_errno != PAPI_OK) {
331 return papi_errno;
332 }
333 templ_ctx->state = 0;
334 templ_ctl->vendor_ctx = NULL;
335
336 return papi_errno;
337}
int vendord_ctx_stop(vendord_ctx_t ctx)
Here is the call graph for this function:

◆ templ_update_control_state() [1/2]

int templ_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t ntv_info,
int  ntv_count,
hwd_context_t *ctx   __attribute__(unused) 
)

Definition at line 212 of file template.c.

213{
214 int papi_errno = check_n_initialize();
215 if (papi_errno != PAPI_OK) {
216 return papi_errno;
217 }
218
220 if (templ_ctl->vendor_ctx != NULL) {
221 return PAPI_ECMP;
222 }
223
224 papi_errno = update_native_events(templ_ctl, ntv_info, ntv_count);
225 if (papi_errno != PAPI_OK) {
226 return papi_errno;
227 }
228
230}
#define PAPI_ECMP
Definition: f90papi.h:214
static int try_open_events(templ_control_t *)
Definition: template.c:260
static int update_native_events(templ_control_t *, NativeInfo_t *, int)
Definition: template.c:233
Here is the call graph for this function:

◆ templ_update_control_state() [2/2]

static int templ_update_control_state ( hwd_control_state_t ctl,
NativeInfo_t ntv_info,
int  ntv_count,
hwd_context_t ctx 
)
static

◆ try_open_events()

int try_open_events ( templ_control_t templ_ctl)
static

Definition at line 260 of file template.c.

261{
262 int papi_errno = PAPI_OK;
263 vendord_ctx_t vendor_ctx;
264
265 papi_errno = vendord_ctx_open(templ_ctl->events_id, templ_ctl->num_events, &vendor_ctx);
266 if (papi_errno != PAPI_OK) {
268 return papi_errno;
269 }
270
271 return vendord_ctx_close(vendor_ctx);
272}
static int templ_cleanup_eventset(hwd_control_state_t *ctl)
Definition: template.c:199
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_native_events()

int update_native_events ( templ_control_t ctl,
NativeInfo_t ntv_info,
int  ntv_count 
)
static

Definition at line 233 of file template.c.

234{
235 int papi_errno = PAPI_OK;
236
237 if (ntv_count != ctl->num_events) {
238 ctl->events_id = papi_realloc(ctl->events_id, ntv_count * sizeof(*ctl->events_id));
239 if (NULL == ctl->events_id) {
240 papi_errno = PAPI_ENOMEM;
241 goto fn_fail;
242 }
243 ctl->num_events = ntv_count;
244 }
245
246 int i;
247 for (i = 0; i < ntv_count; ++i) {
248 ctl->events_id[i] = ntv_info[i].ni_event;
249 ntv_info[i].ni_position = i;
250 }
251
252 fn_exit:
253 return papi_errno;
254 fn_fail:
255 ctl->num_events = 0;
256 goto fn_exit;
257}
int i
#define PAPI_ENOMEM
Definition: f90papi.h:16
#define papi_realloc(a, b)
Definition: papi_memory.h:36
unsigned int * events_id
Definition: template.c:46
Here is the caller graph for this function:

Variable Documentation

◆ _template_vector

papi_vector_t _template_vector

Definition at line 51 of file template.c.