PAPI 7.1.0.0
Loading...
Searching...
No Matches
solaris-niagara2.h
Go to the documentation of this file.
1/*******************************************************************************
2 * >>>>>> "Development of a PAPI Backend for the Sun Niagara 2 Processor" <<<<<<
3 * -----------------------------------------------------------------------------
4 *
5 * Fabian Gorsler <fabian.gorsler@smail.inf.h-bonn-rhein-sieg.de>
6 *
7 * Hochschule Bonn-Rhein-Sieg, Sankt Augustin, Germany
8 * University of Applied Sciences
9 *
10 * -----------------------------------------------------------------------------
11 *
12 * File: solaris-niagara2.c
13 * Author: fg215045
14 *
15 * Description: Data structures used for the communication between PAPI and the
16 * component. Additionally some macros are defined here. See solaris-niagara2.c.
17 *
18 * ***** Feel free to convert this header to the PAPI default *****
19 *
20 * -----------------------------------------------------------------------------
21 * Created on April 23, 2009, 7:31 PM
22 ******************************************************************************/
23
24#ifndef _SOLARIS_NIAGARA2_H
25#define _SOLARIS_NIAGARA2_H
26
27#include <stdio.h>
28#include <stdlib.h>
29#include <fcntl.h>
30#include <unistd.h>
31#include <assert.h>
32#include <string.h>
33#include <libgen.h>
34#include <limits.h>
35#include <synch.h>
36#include <procfs.h>
37#include <libcpc.h>
38#include <libgen.h>
39#include <ctype.h>
40#include <errno.h>
41#include <sys/times.h>
42#include <sys/time.h>
43#include <sys/types.h>
44#include <sys/processor.h>
45#include <sys/procset.h>
46#include <sys/ucontext.h>
47#include <syms.h>
48#include <dlfcn.h>
49#include <sys/stat.h>
50#include <sys/time.h>
51#include <stdarg.h>
52
53#include "papi_defines.h"
54
58/* DESCRIPTION:
59 * -----------------------------------------------------------------------------
60 * The following lines are taken from the old Solaris port of PAPI. If changes
61 * have been made there are (additional) comments.
62 *
63 ******************************************************************************/
64
65#define MAX_COUNTERS 2
66#define MAX_COUNTER_TERMS MAX_COUNTERS
67#define PAPI_MAX_NATIVE_EVENTS 71
68#define MAX_NATIVE_EVENT PAPI_MAX_NATIVE_EVENTS
69
71
72/* libcpc 2 does not need any bit masks */
73typedef struct _niagara2_register
74{
77
78
79#define BUF_T0 0
80#define BUF_T1 1
81
82#define EVENT_NOT_SET -1;
83
84#define SYNTHETIC_EVENTS_SUPPORTED 1
85
86/* This structured bundles everything needed for sampling up to MAX_COUNTERS */
87typedef struct _niagara2_control_state
88{
89 /* A set instruments the hardware counters */
90 cpc_set_t *set;
91
92 /* A buffer stores the events counted. For measuring a start of measurment
93 and an end is needed as measurement does not always start from 0. This is
94 done by using an array of bufs, accessed by the indexes BUF_T0 as start
95 and BUF_T1 as end. */
96 cpc_buf_t *counter_buffer;
97
98 /* The indexes are needed for accessing the single counter events, if the
99 value of these indexes is equal to EVENT_NOT_SET this means it is unused */
100 int idx[MAX_COUNTERS];
101
102 /* The event codes applied to this set */
104
105 /* The total number of events being counted */
106 int count;
107
108 /* The values retrieved from the counter */
110
111 /* Flags for controlling overflow handling and binding, see
112 cpc_set_create(3CPC) for more details on this topic. */
113 uint_t flags[MAX_COUNTERS];
114
115 /* Preset values for the counters */
117
118 /* Memory to store values when an overflow occours */
121
122#ifdef SYNTHETIC_EVENTS_SUPPORTED
124 uint64_t syn_hangover[MAX_COUNTERS];
125#endif
127
128#define GET_OVERFLOW_ADDRESS(ctx) (void*)(ctx->ucontext->uc_mcontext.gregs[REG_PC])
129
131
132#include "solaris-context.h"
133
135
136// Needs an explicit declaration, no longer externally found.
138
139// For setting and releasing locks.
140#define _papi_hwd_lock(lck) rw_wrlock(&lock[lck]);
141#define _papi_hwd_unlock(lck) rw_unlock(&lock[lck]);
142
143#define DEFAULT_CNTR_PRESET (0)
144#define NOT_A_PAPI_HWD_READ -666
145#define CPC_COUNTING_DOMAINS (CPC_COUNT_USER|CPC_COUNT_SYSTEM|CPC_COUNT_HV)
146#define EVENT_NOT_SET -1;
147
148/* Clean the stubbed data structures from framework initialization */
149#undef hwd_context_t
150#define hwd_context_t _niagara2_context_t
151
152#undef hwd_control_state_t
153#define hwd_control_state_t _niagara2_control_state_t
154
155#undef hwd_register_t
156#define hwd_register_t _niagara2_register_t
157
158#endif
volatile int result
static int threshold
#define long_long
Definition: papi.h:559
#define PAPI_MAX_LOCK
Definition: papi_lock.h:18
static int preset
#define MAX_COUNTERS
Definition: perfctr-x86.h:8
rwlock_t lock[PAPI_MAX_LOCK]
int hwd_register_map_t
_niagara2_control_state_t _niagara2_context_t
int niagara2_reg_alloc_t