|
PAPI
5.0.1.0
|
00001 /******************************************************************************* 00002 * >>>>>> "Development of a PAPI Backend for the Sun Niagara 2 Processor" <<<<<< 00003 * ----------------------------------------------------------------------------- 00004 * 00005 * Fabian Gorsler <fabian.gorsler@smail.inf.h-bonn-rhein-sieg.de> 00006 * 00007 * Hochschule Bonn-Rhein-Sieg, Sankt Augustin, Germany 00008 * University of Applied Sciences 00009 * 00010 * ----------------------------------------------------------------------------- 00011 * 00012 * File: solaris-niagara2.c 00013 * Author: fg215045 00014 * 00015 * Description: Data structures used for the communication between PAPI and the 00016 * component. Additionally some macros are defined here. See solaris-niagara2.c. 00017 * 00018 * ***** Feel free to convert this header to the PAPI default ***** 00019 * 00020 * ----------------------------------------------------------------------------- 00021 * Created on April 23, 2009, 7:31 PM 00022 ******************************************************************************/ 00023 00024 #ifndef _SOLARIS_NIAGARA2_H 00025 #define _SOLARIS_NIAGARA2_H 00026 00027 #include <stdio.h> 00028 #include <stdlib.h> 00029 #include <fcntl.h> 00030 #include <unistd.h> 00031 #include <assert.h> 00032 #include <string.h> 00033 #include <libgen.h> 00034 #include <limits.h> 00035 #include <synch.h> 00036 #include <procfs.h> 00037 #include <libcpc.h> 00038 #include <libgen.h> 00039 #include <ctype.h> 00040 #include <errno.h> 00041 #include <sys/times.h> 00042 #include <sys/time.h> 00043 #include <sys/types.h> 00044 #include <sys/processor.h> 00045 #include <sys/procset.h> 00046 #include <sys/ucontext.h> 00047 #include <syms.h> 00048 #include <dlfcn.h> 00049 #include <sys/stat.h> 00050 #include <sys/time.h> 00051 #include <stdarg.h> 00052 00053 #include "papi_defines.h" 00054 00058 /* DESCRIPTION: 00059 * ----------------------------------------------------------------------------- 00060 * The following lines are taken from the old Solaris port of PAPI. If changes 00061 * have been made there are (additional) comments. 00062 * 00063 ******************************************************************************/ 00064 00065 #define MAX_COUNTERS 2 00066 #define MAX_COUNTER_TERMS MAX_COUNTERS 00067 #define PAPI_MAX_NATIVE_EVENTS 71 00068 #define MAX_NATIVE_EVENT PAPI_MAX_NATIVE_EVENTS 00069 00070 typedef int niagara2_reg_alloc_t; 00071 00072 /* libcpc 2 does not need any bit masks */ 00073 typedef struct _niagara2_register 00074 { 00075 int event_code; 00076 } _niagara2_register_t; 00077 00078 00079 #define BUF_T0 0 00080 #define BUF_T1 1 00081 00082 #define EVENT_NOT_SET -1; 00083 00084 #define SYNTHETIC_EVENTS_SUPPORTED 1 00085 00086 /* This structured bundles everything needed for sampling up to MAX_COUNTERS */ 00087 typedef struct _niagara2_control_state 00088 { 00089 /* A set instruments the hardware counters */ 00090 cpc_set_t *set; 00091 00092 /* A buffer stores the events counted. For measuring a start of measurment 00093 and an end is needed as measurement does not always start from 0. This is 00094 done by using an array of bufs, accessed by the indexes BUF_T0 as start 00095 and BUF_T1 as end. */ 00096 cpc_buf_t *counter_buffer; 00097 00098 /* The indexes are needed for accessing the single counter events, if the 00099 value of these indexes is equal to EVENT_NOT_SET this means it is unused */ 00100 int idx[MAX_COUNTERS]; 00101 00102 /* The event codes applied to this set */ 00103 _niagara2_register_t code[MAX_COUNTERS]; 00104 00105 /* The total number of events being counted */ 00106 int count; 00107 00108 /* The values retrieved from the counter */ 00109 uint64_t result[MAX_COUNTERS]; 00110 00111 /* Flags for controlling overflow handling and binding, see 00112 cpc_set_create(3CPC) for more details on this topic. */ 00113 uint_t flags[MAX_COUNTERS]; 00114 00115 /* Preset values for the counters */ 00116 uint64_t preset[MAX_COUNTERS]; 00117 00118 /* Memory to store values when an overflow occours */ 00119 long_long threshold[MAX_COUNTERS]; 00120 long_long hangover[MAX_COUNTERS]; 00121 00122 #ifdef SYNTHETIC_EVENTS_SUPPORTED 00123 int syn_count; 00124 uint64_t syn_hangover[MAX_COUNTERS]; 00125 #endif 00126 } _niagara2_control_state_t; 00127 00128 #define GET_OVERFLOW_ADDRESS(ctx) (void*)(ctx->ucontext->uc_mcontext.gregs[REG_PC]) 00129 00130 typedef int hwd_register_map_t; 00131 00132 #include "solaris-context.h" 00133 00134 typedef _niagara2_control_state_t _niagara2_context_t; 00135 00136 // Needs an explicit declaration, no longer externally found. 00137 rwlock_t lock[PAPI_MAX_LOCK]; 00138 00139 // For setting and releasing locks. 00140 #define _papi_hwd_lock(lck) rw_wrlock(&lock[lck]); 00141 #define _papi_hwd_unlock(lck) rw_unlock(&lock[lck]); 00142 00143 #define DEFAULT_CNTR_PRESET (0) 00144 #define NOT_A_PAPI_HWD_READ -666 00145 #define CPC_COUNTING_DOMAINS (CPC_COUNT_USER|CPC_COUNT_SYSTEM|CPC_COUNT_HV) 00146 #define EVENT_NOT_SET -1; 00147 00148 /* Clean the stubbed data structures from framework initialization */ 00149 #undef hwd_context_t 00150 #define hwd_context_t _niagara2_context_t 00151 00152 #undef hwd_control_state_t 00153 #define hwd_control_state_t _niagara2_control_state_t 00154 00155 #undef hwd_register_t 00156 #define hwd_register_t _niagara2_register_t 00157 00158 #endif