25#include <sys/utsname.h>
31#define LASTULTRA3 CPC_ULTRA3_I
33#define LASTULTRA3 CPC_ULTRA3_PLUS
38static void action(
void *arg,
int regno,
const char *
name, uint8_t bits );
41typedef struct ctr_info
54 {
PAPI_FP_INS,
"FA_pipe_completion+FM_pipe_completion"},
68 {
PAPI_BR_MSP,
"IU_Stat_Br_miss_taken+IU_Stat_Br_miss_untaken"},
122 SUBDBG(
"cpc_event_t.ce_cpuver %d\n", t->
cmd.ce_cpuver );
123 SUBDBG(
"ce_tick %llu\n", t->
cmd.ce_tick );
124 SUBDBG(
"ce_pic[0] %llu ce_pic[1] %llu\n", t->
cmd.ce_pic[0],
126 SUBDBG(
"ce_pcr %#llx\n", t->
cmd.ce_pcr );
141 if ( sip->
si_code == EMT_CPCOVF ) {
145 int t, overflow_vector, readvalue;
152 OVFDBG(
"Either no eventset or eventset not set to overflow.\n" );
158 (
"eventset->thread %%lx vs. current thread %#lx mismatch",
178 if ( cpc_take_sample( &
sample->cmd ) == -1 )
180 if ( event_counter == 1 ) {
184 overflow_vector = 1 << t;
190 readvalue =
sample->cmd.ce_pic[0];
191 if ( readvalue >= 0 ) {
204 readvalue =
sample->cmd.ce_pic[1];
205 if ( readvalue >= 0 ) {
209 overflow_vector ^= 1 << 1;
218 SUBDBG(
"overflow_vector, = %d\n", overflow_vector );
220 if ( overflow_vector == 0 ) {
221 PAPIERROR(
"BUG! overflow_vector is 0, dropping interrupt" );
227 if (
thread->running_eventset[
cidx]->overflow.
231 overflow_vector, 0, &
thread,
234 PAPIERROR(
"Additional implementation needed in dispatch_emt!" );
241 if ( cpc_bind_event( &
sample->cmd,
sample->flags ) == -1 )
244 SUBDBG(
"dispatch_emt() dropped, si_code = %d\n", sip->
si_code );
261 char line[256], cmd[80],
name[256];
264 unsigned int matched;
270 SUBDBG(
"Temporary name %s\n", fname );
272 sprintf( cmd_line,
"/usr/sbin/prtconf -vp > %s", fname );
273 SUBDBG(
"Executing %s\n", cmd_line );
274 if ( system( cmd_line ) == -1 ) {
279 f = fopen( fname,
"r" );
289 while ( fgets( line, 256,
f ) != NULL ) {
291 if ( ( sscanf( line,
"%s", cmd ) == 1 )
292 && strstr( line,
"Node 0x" ) ) {
296 if ( strstr( cmd,
"device_type:" ) && strstr( line,
"'cpu'" ) ) {
298 SUBDBG(
"Found 'cpu'. (%#2.2x)\n", matched );
299 }
else if ( !strcmp( cmd,
"sparc-version:" ) &&
300 ( sscanf( line,
"%s %#x", cmd, &
version ) == 2 ) ) {
303 }
else if ( !strcmp( cmd,
"clock-frequency:" ) &&
304 ( sscanf( line,
"%s %#x", cmd, &ihz ) == 2 ) ) {
306 SUBDBG(
"Found ihz=%d. (%#2.2x)\n", ihz, matched );
307 }
else if ( !strcmp( cmd,
"name:" ) &&
308 ( sscanf( line,
"%s %s", cmd,
name ) == 2 ) ) {
310 SUBDBG(
"Found name: %s. (%#2.2x)\n",
name, matched );
313 if ( ( matched & 0xF ) == 0xF )
316 SUBDBG(
"Parsing found name=%s, speed=%dHz, version=%d\n",
name, ihz,
319 if ( matched ^ 0x0F )
324 strncpy( cpuname,
name, len_cpuname );
336 cpc_event_t *
event = &command->
cmd;
337 uint64_t pcr =
event->ce_pcr;
344 pcr = pcr | 1 << CPC_ULTRA_PCR_USR;
348 pcr = pcr | 1 << CPC_ULTRA_PCR_SYS;
397 npic = cpc_getnpic(
cpuver );
399 for ( regno = 0; regno < npic; ++regno ) {
407 for ( regno = 0; regno < npic; ++regno ) {
428 if (
ctrs[
i].bitmask & 1 )
432 if (
ctrs[
i].bitmask & 2 )
440 if (
cpuver <= CPC_ULTRA2 ) {
450 for (
i = 0;
i < n; ++
i ) {
462 SUBDBG(
"\nPreset table: %d\n", npresets );
464 SUBDBG(
"%8x: op %2d e0 %8x e1 %8x\n",
514 while ( isspace( *p ) )
518 while ( isalnum( *p ) || ( *p ==
'_' ) ) {
525 if ( *p ==
'+' || *p ==
'-' )
529 while ( isspace( *p ) )
533 while ( isalnum( *p ) || ( *p ==
'_' ) ) {
541 if ( e2[0] == 0 && e1[0] == 0 ) {
544 if ( e2[0] == 0 || op == 0 ) {
559 if ( ne == -1 || ne2 == -1 )
571action(
void *arg,
int regno,
const char *
name, uint8_t bits )
579 assert( regno == 0 || regno == 1 );
582 ctrs[
i].bits[regno] = bits;
583 ctrs[
i].bitmask |= ( 1 << regno );
589 ctrs[
i].bits[regno] = bits;
590 ctrs[
i].bitmask = ( 1 << regno );
612 if ( command->flags & CPC_BIND_LWP_INHERIT )
613 command->flags = command->flags ^ CPC_BIND_LWP_INHERIT;
614 }
else if ( arg == 1 ) {
615 command->flags = command->flags | CPC_BIND_LWP_INHERIT;
651 ( void ) cpc_rele( );
676 SUBDBG(
"Found %d %s %s CPUs at %d Mhz.\n",
705 long long **
events,
int flags )
771 int overflow_vector = 0;
785 PAPIERROR(
"thread == NULL in _papi_hwd_dispatch_timer");
799 PAPIERROR(
"Thread mismatch, ESI->master=%#x thread=%#x\n",
816 PAPIERROR (
"Need to implement additional code in _papi_hwd_dispatch_timer!" );
830 arg->
flags ^= CPC_BIND_EMT_OVF;
845 memset( &act.sa_mask, 0x0, sizeof ( act.sa_mask ) );
846 act.sa_flags = SA_RESTART | SA_SIGINFO;
852 arg->
flags |= CPC_BIND_EMT_OVF;
855 arg->
cmd.ce_pic[0] = UINT64_MAX - ( uint64_t )
threshold;
856 else if ( hwcntr == 1 )
857 arg->
cmd.ce_pic[1] = UINT64_MAX - ( uint64_t )
threshold;
910 cpc_bind_event( NULL, 0 );
938 if (
cpuver <= CPC_ULTRA2 ) {
940 *EventCode = *EventCode + 1;
946 *EventCode = *EventCode + 1;
960 if ( event_code >= 0 && event_code <
nctrs ) {
979 strncpy(
names, nam, len );
988 if (
cpuver <= CPC_ULTRA2 ) {
1024 int nidx1, nidx2, hwcntr;
1046 native[0].ni_position = 0;
1049 native[0].ni_position = 1;
1069 if ( ( avail1 | avail2 ) != 0x3 )
1071 if ( avail1 == 0x3 ) {
1072 if ( avail2 == 0x1 ) {
1075 native[0].ni_position = 1;
1076 native[1].ni_position = 0;
1080 native[0].ni_position = 0;
1081 native[1].ni_position = 1;
1084 if ( avail1 == 0x1 ) {
1087 native[0].ni_position = 0;
1088 native[1].ni_position = 1;
1092 native[0].ni_position = 1;
1093 native[1].ni_position = 0;
1118 .
name =
"solaris.ultra",
1119 .description =
"Solaris CPU counters",
1126 .fast_real_timer = 1,
1127 .fast_virtual_timer = 1,
1129 .attach_must_ptrace = 1,
#define GET_OVERFLOW_ADDRESS(ctx)
const char * names[NUM_EVENTS]
#define PAPI_OVERFLOW_FORCE_SW
#define PAPI_HUGE_STR_LEN
char events[MAX_EVENTS][BUFSIZ]
static long long values[NUM_EVENTS]
#define PAPI_NATIVE_AND_MASK
Return codes and api definitions.
#define OVFDBG(format, args...)
#define SUBDBG(format, args...)
int remove(const char *__filename) __attribute__((__nothrow__
__sighandler_t signal(int __sig, __sighandler_t __handler) __attribute__((__nothrow__
int sigaction(int __sig, const struct sigaction *__restrict __act, struct sigaction *__restrict __oact) __attribute__((__nothrow__
void PAPIERROR(char *format,...)
papi_mdi_t _papi_hwi_system_info
int _solaris_update_shlib_info(papi_mdi_t *mdi)
long long _solaris_get_real_usec(void)
int _solaris_get_system_info(papi_mdi_t *mdi)
long long _solaris_get_virt_usec(void)
long long _solaris_get_real_cycles(void)
int _solaris_get_memory_info(PAPI_hw_info_t *hw, int id)
int _solaris_get_dmem_info(PAPI_dmem_info_t *d)
int _ultra_hwd_update_control_state(hwd_control_state_t *this_state, NativeInfo_t *native, int count, hwd_context_t *zero)
static void add_preset(hwi_search_t *tab, int *np, einfo_t e)
static native_info_t * native_table
rwlock_t lock[PAPI_MAX_LOCK]
int _ultra_hwd_ntv_code_to_bits(unsigned int EventCode, hwd_register_t *bits)
static struct ctr_info * ctrs
papi_vector_t _solaris_vector
int _ultra_hwd_shutdown_component(void)
int _ultra_hwd_ntv_code_to_name(unsigned int EventCode, char *ntv_name, int len)
static int set_granularity(hwd_control_state_t *this_state, int domain)
static int build_tables(void)
int _ultra_hwd_set_overflow(EventSetInfo_t *ESI, int EventIndex, int threshold)
int _ultra_hwd_ntv_code_to_descr(unsigned int EventCode, char *hwd_descr, int len)
int _ultra_hwd_ntv_enum_events(unsigned int *EventCode, int modifier)
static int srch_event(char *e1)
void _ultra_hwd_dispatch_timer(int signal, siginfo_t *si, void *context)
int _ultra_hwd_start(hwd_context_t *ctx, hwd_control_state_t *ctrl)
int _ultra_set_domain(hwd_control_state_t *this_state, int domain)
static void dispatch_emt(int signal, siginfo_t *sip, void *arg)
static void copy_value(unsigned int val, char *nam, char *names, unsigned int *values, int len)
_ultra_shutdown(hwd_context_t *ctx)
int _ultra_hwd_ctl(hwd_context_t *ctx, int code, _papi_int_option_t *option)
void print_walk_names(void *arg, int regno, const char *name, uint8_t bits)
static int set_default_domain(hwd_control_state_t *ctrl_state, int domain)
int _ultra_hwd_stop(hwd_context_t *ctx, hwd_control_state_t *ctrl)
static void dump_cmd(papi_cpc_event_t *t)
int _ultra_hwd_read(hwd_context_t *ctx, hwd_control_state_t *ctrl, long long **events, int flags)
int _ultra_hwd_encode_native(char *name, int *code)
static int scan_prtconf(char *cpuname, int len_cpuname, int *hz, int *ver)
static int set_default_granularity(hwd_control_state_t *current_state, int granularity)
int _ultra_hwd_init_component(int cidx)
static hwi_search_t * preset_table
int _ultra_hwd_remove_event(hwd_register_map_t *chosen, unsigned int hardware_index, hwd_control_state_t *out)
papi_os_vector_t _papi_os_vector
int _ultra_hwd_init_control_state(hwd_control_state_t *ptr)
static void lock_init(void)
hwi_search_t * preset_search_map
static void action(void *arg, int regno, const char *name, uint8_t bits)
int _ultra_hwd_reset(hwd_context_t *ctx, hwd_control_state_t *ctrl)
static int set_inherit(EventSetInfo_t *global, int arg)
void * _ultra_hwd_get_overflow_address(void *context)
#define MAX_NATIVE_EVENT_USII
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
struct _ThreadInfo * master
EventInfo_t * EventInfoArray
hwd_control_state_t * ctl_state
EventSetOverflowInfo_t overflow
char name[PAPI_MAX_STR_LEN]
char vendor_string[PAPI_MAX_STR_LEN]
char model_string[PAPI_MAX_STR_LEN]
hwd_ucontext_t * ucontext
papi_cpc_event_t counter_cmd
char operation[PAPI_2MAX_STR_LEN]
int native[PAPI_EVENTS_IN_DERIVED_EVENT]
int encoding[MAX_COUNTERS]
int(* get_memory_info)(PAPI_hw_info_t *, int)
PAPI_component_info_t cmp_info
inline_static ThreadInfo_t * _papi_hwi_lookup_thread(int custom_tid)
_papi_int_domain_t domain
_papi_int_granularity_t granularity