|
Packit |
577717 |
/*******************************************************************************
|
|
Packit |
577717 |
* >>>>>> "Development of a PAPI Backend for the Sun Niagara 2 Processor" <<<<<<
|
|
Packit |
577717 |
* -----------------------------------------------------------------------------
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Fabian Gorsler <fabian.gorsler@smail.inf.h-bonn-rhein-sieg.de>
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Hochschule Bonn-Rhein-Sieg, Sankt Augustin, Germany
|
|
Packit |
577717 |
* University of Applied Sciences
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* -----------------------------------------------------------------------------
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* File: solaris-niagara2.c
|
|
Packit |
577717 |
* Author: fg215045
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* Description: Data structures used for the communication between PAPI and the
|
|
Packit |
577717 |
* component. Additionally some macros are defined here. See solaris-niagara2.c.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* ***** Feel free to convert this header to the PAPI default *****
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
* -----------------------------------------------------------------------------
|
|
Packit |
577717 |
* Created on April 23, 2009, 7:31 PM
|
|
Packit |
577717 |
******************************************************************************/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#ifndef _SOLARIS_NIAGARA2_H
|
|
Packit |
577717 |
#define _SOLARIS_NIAGARA2_H
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
#include <fcntl.h>
|
|
Packit |
577717 |
#include <unistd.h>
|
|
Packit |
577717 |
#include <assert.h>
|
|
Packit |
577717 |
#include <string.h>
|
|
Packit |
577717 |
#include <libgen.h>
|
|
Packit |
577717 |
#include <limits.h>
|
|
Packit |
577717 |
#include <synch.h>
|
|
Packit |
577717 |
#include <procfs.h>
|
|
Packit |
577717 |
#include <libcpc.h>
|
|
Packit |
577717 |
#include <libgen.h>
|
|
Packit |
577717 |
#include <ctype.h>
|
|
Packit |
577717 |
#include <errno.h>
|
|
Packit |
577717 |
#include <sys/times.h>
|
|
Packit |
577717 |
#include <sys/time.h>
|
|
Packit |
577717 |
#include <sys/types.h>
|
|
Packit |
577717 |
#include <sys/processor.h>
|
|
Packit |
577717 |
#include <sys/procset.h>
|
|
Packit |
577717 |
#include <sys/ucontext.h>
|
|
Packit |
577717 |
#include <syms.h>
|
|
Packit |
577717 |
#include <dlfcn.h>
|
|
Packit |
577717 |
#include <sys/stat.h>
|
|
Packit |
577717 |
#include <sys/time.h>
|
|
Packit |
577717 |
#include <stdarg.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "papi_defines.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
////////////////////////////////////////////////////////////////////////////////
|
|
Packit |
577717 |
/// COPIED ITEMS FROM THE OLD PORT TO SOLARIS //////////////////////////////////
|
|
Packit |
577717 |
////////////////////////////////////////////////////////////////////////////////
|
|
Packit |
577717 |
/* DESCRIPTION:
|
|
Packit |
577717 |
* -----------------------------------------------------------------------------
|
|
Packit |
577717 |
* The following lines are taken from the old Solaris port of PAPI. If changes
|
|
Packit |
577717 |
* have been made there are (additional) comments.
|
|
Packit |
577717 |
*
|
|
Packit |
577717 |
******************************************************************************/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define MAX_COUNTERS 2
|
|
Packit |
577717 |
#define MAX_COUNTER_TERMS MAX_COUNTERS
|
|
Packit |
577717 |
#define PAPI_MAX_NATIVE_EVENTS 71
|
|
Packit |
577717 |
#define MAX_NATIVE_EVENT PAPI_MAX_NATIVE_EVENTS
|
|
Packit |
577717 |
|
|
Packit |
577717 |
typedef int niagara2_reg_alloc_t;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* libcpc 2 does not need any bit masks */
|
|
Packit |
577717 |
typedef struct _niagara2_register
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int event_code;
|
|
Packit |
577717 |
} _niagara2_register_t;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define BUF_T0 0
|
|
Packit |
577717 |
#define BUF_T1 1
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define EVENT_NOT_SET -1;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define SYNTHETIC_EVENTS_SUPPORTED 1
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* This structured bundles everything needed for sampling up to MAX_COUNTERS */
|
|
Packit |
577717 |
typedef struct _niagara2_control_state
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
/* A set instruments the hardware counters */
|
|
Packit |
577717 |
cpc_set_t *set;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* A buffer stores the events counted. For measuring a start of measurment
|
|
Packit |
577717 |
and an end is needed as measurement does not always start from 0. This is
|
|
Packit |
577717 |
done by using an array of bufs, accessed by the indexes BUF_T0 as start
|
|
Packit |
577717 |
and BUF_T1 as end. */
|
|
Packit |
577717 |
cpc_buf_t *counter_buffer;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* The indexes are needed for accessing the single counter events, if the
|
|
Packit |
577717 |
value of these indexes is equal to EVENT_NOT_SET this means it is unused */
|
|
Packit |
577717 |
int idx[MAX_COUNTERS];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* The event codes applied to this set */
|
|
Packit |
577717 |
_niagara2_register_t code[MAX_COUNTERS];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* The total number of events being counted */
|
|
Packit |
577717 |
int count;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* The values retrieved from the counter */
|
|
Packit |
577717 |
uint64_t result[MAX_COUNTERS];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Flags for controlling overflow handling and binding, see
|
|
Packit |
577717 |
cpc_set_create(3CPC) for more details on this topic. */
|
|
Packit |
577717 |
uint_t flags[MAX_COUNTERS];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Preset values for the counters */
|
|
Packit |
577717 |
uint64_t preset[MAX_COUNTERS];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Memory to store values when an overflow occours */
|
|
Packit |
577717 |
long_long threshold[MAX_COUNTERS];
|
|
Packit |
577717 |
long_long hangover[MAX_COUNTERS];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#ifdef SYNTHETIC_EVENTS_SUPPORTED
|
|
Packit |
577717 |
int syn_count;
|
|
Packit |
577717 |
uint64_t syn_hangover[MAX_COUNTERS];
|
|
Packit |
577717 |
#endif
|
|
Packit |
577717 |
} _niagara2_control_state_t;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define GET_OVERFLOW_ADDRESS(ctx) (void*)(ctx->ucontext->uc_mcontext.gregs[REG_PC])
|
|
Packit |
577717 |
|
|
Packit |
577717 |
typedef int hwd_register_map_t;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "solaris-context.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
typedef _niagara2_control_state_t _niagara2_context_t;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
// Needs an explicit declaration, no longer externally found.
|
|
Packit |
577717 |
rwlock_t lock[PAPI_MAX_LOCK];
|
|
Packit |
577717 |
|
|
Packit |
577717 |
// For setting and releasing locks.
|
|
Packit |
577717 |
#define _papi_hwd_lock(lck) rw_wrlock(&lock[lck]);
|
|
Packit |
577717 |
#define _papi_hwd_unlock(lck) rw_unlock(&lock[lck]);
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#define DEFAULT_CNTR_PRESET (0)
|
|
Packit |
577717 |
#define NOT_A_PAPI_HWD_READ -666
|
|
Packit |
577717 |
#define CPC_COUNTING_DOMAINS (CPC_COUNT_USER|CPC_COUNT_SYSTEM|CPC_COUNT_HV)
|
|
Packit |
577717 |
#define EVENT_NOT_SET -1;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* Clean the stubbed data structures from framework initialization */
|
|
Packit |
577717 |
#undef hwd_context_t
|
|
Packit |
577717 |
#define hwd_context_t _niagara2_context_t
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#undef hwd_control_state_t
|
|
Packit |
577717 |
#define hwd_control_state_t _niagara2_control_state_t
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#undef hwd_register_t
|
|
Packit |
577717 |
#define hwd_register_t _niagara2_register_t
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#endif
|