|
PAPI
5.0.1.0
|
This component is intended to access CPU On-Die Thermal Sensors in the Intel Core architecture in a FreeBSD machine using the coretemp.ko kernel module. More...

Go to the source code of this file.
Definition in file coretemp_freebsd.c.
| #define CORETEMP_MAX_COUNTERS 32 /* Can we tune this dynamically? */ |
Definition at line 37 of file coretemp_freebsd.c.
| #define FALSE (1!=1) |
Definition at line 39 of file coretemp_freebsd.c.
| #define TRUE (1==1) |
Definition at line 38 of file coretemp_freebsd.c.
| #define UNREFERENCED | ( | x | ) | (void)x |
Definition at line 40 of file coretemp_freebsd.c.
| int coretemp_ctl | ( | hwd_context_t * | ctx, |
| int | code, | ||
| _papi_int_option_t * | option | ||
| ) |
This function sets various options in the component
| ctx | unused |
| code | valid are PAPI_SET_DEFDOM, PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL and PAPI_SET_INHERIT |
| option | unused |
Definition at line 395 of file coretemp_freebsd.c.
{
UNREFERENCED(ctx);
UNREFERENCED(code);
UNREFERENCED(option);
SUBDBG( "coretemp_ctl... %p %d %p\n", ctx, code, option );
/* FIXME. This should maybe set up more state, such as which counters are active and */
/* counter mappings. */
return PAPI_OK;
}

| int coretemp_init_component | ( | ) |
Initialize hardware counters, setup the function vector table and get hardware information, this routine is called when the PAPI process is initialized (IE PAPI_library_init)
Definition at line 118 of file coretemp_freebsd.c.
{
int ret;
int i;
int mib[4];
size_t len;
char tmp[128];
SUBDBG("coretemp_init_component...\n");
/* Count the number of cores (counters) that have sensors allocated */
i = 0;
CORETEMP_NUM_EVENTS = 0;
sprintf (tmp, "dev.coretemp.%d.%%driver", i);
len = 4;
ret = sysctlnametomib (tmp, mib, &len);
while (ret != -1)
{
CORETEMP_NUM_EVENTS++;
i++;
sprintf (tmp, "dev.coretemp.%d.%%driver", i);
len = 4;
ret = sysctlnametomib (tmp, mib, &len);
}
/* Allocate memory for the our event table */
coretemp_native_table = (coretemp_native_event_entry_t *)
papi_malloc (sizeof (coretemp_native_event_entry_t) * CORETEMP_NUM_EVENTS);
if (coretemp_native_table == NULL)
{
perror( "malloc():Could not get memory for coretemp events table" );
return PAPI_ENOMEM;
}
/* Allocate native events internal structures */
for (i = 0; i < CORETEMP_NUM_EVENTS; i++)
{
/* Event name */
sprintf (coretemp_native_table[i].name, "CORETEMP_CPU_%d", i);
/* Event description */
sprintf (coretemp_native_table[i].description, "CPU On-Die Thermal Sensor #%d", i);
/* Event extra bits -> save MIB to faster access later */
sprintf (tmp, "dev.cpu.%d.temperature", i);
len = 4;
if (sysctlnametomib (tmp, coretemp_native_table[i].resources.mib, &len) == -1)
return PAPI_ECMP;
coretemp_native_table[i].resources.selector = i+1;
}
return PAPI_OK;
}
| int coretemp_init_control_state | ( | hwd_control_state_t * | ctrl | ) |
Setup the counter control structure
Definition at line 175 of file coretemp_freebsd.c.
{
int i;
SUBDBG("coretemp_init_control_state... %p\n", ctrl);
coretemp_control_state_t *c = (coretemp_control_state_t *) ctrl;
for (i = 0; i < CORETEMP_MAX_COUNTERS; i++)
c->added[i] = FALSE;
return PAPI_OK;
}
| int coretemp_init_thread | ( | hwd_context_t * | ctx | ) |
This is called whenever a thread is initialized
Definition at line 94 of file coretemp_freebsd.c.
{
int mib[4];
size_t len;
UNREFERENCED(ctx);
SUBDBG("coretemp_init_thread %p...\n", ctx);
#if 0
/* what does this do? VMW */
len = 4;
if (sysctlnametomib ("dev.coretemp.0.%driver", mib, &len) == -1)
return PAPI_ECMP;
#endif
return PAPI_OK;
}
| int coretemp_ntv_code_to_bits | ( | unsigned int | EventCode, |
| hwd_register_t * | bits | ||
| ) |
This takes an event and returns the bits that would be written out to the hardware device (this is very much tied to CPU-type support
Definition at line 256 of file coretemp_freebsd.c.
{
UNREFERENCED(EventCode);
UNREFERENCED(bits);
return PAPI_OK;
}
| int coretemp_ntv_code_to_descr | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Takes a native event code and passes back the event description
| EventCode | is the native event code |
| name | is a pointer for the description to be copied to |
| len | is the size of the string |
Definition at line 245 of file coretemp_freebsd.c.
{
int index = EventCode;
strncpy( name, coretemp_native_table[index].description, len );
return PAPI_OK;
}
| int coretemp_ntv_code_to_name | ( | unsigned int | EventCode, |
| char * | name, | ||
| int | len | ||
| ) |
Takes a native event code and passes back the name
| EventCode | is the native event code |
| name | is a pointer for the name to be copied to |
| len | is the size of the string |
Definition at line 231 of file coretemp_freebsd.c.
{
int index = EventCode;
strncpy( name, coretemp_native_table[index].name, len );
return PAPI_OK;
}
| int coretemp_ntv_enum_events | ( | unsigned int * | EventCode, |
| int | modifier | ||
| ) |
Enumerate Native Events
| EventCode | is the event of interest |
| modifier | is one of PAPI_ENUM_FIRST, PAPI_ENUM_EVENTS |
Definition at line 193 of file coretemp_freebsd.c.
{
switch ( modifier )
{
/* return EventCode of first event */
case PAPI_ENUM_FIRST:
*EventCode = 0;
return PAPI_OK;
break;
/* return EventCode of passed-in Event */
case PAPI_ENUM_EVENTS:
{
int index = *EventCode;
if ( index < CORETEMP_NUM_EVENTS - 1 )
{
*EventCode = *EventCode + 1;
return PAPI_OK;
}
else
return PAPI_ENOEVNT;
break;
}
default:
return PAPI_EINVAL;
}
return PAPI_EINVAL;
}
| int coretemp_read | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctrl, | ||
| long_long ** | events, | ||
| int | flags | ||
| ) |
Triggered by PAPI_read()
Definition at line 316 of file coretemp_freebsd.c.
{
int i;
coretemp_control_state_t *c = (coretemp_control_state_t *) ctrl;
UNREFERENCED(ctx);
UNREFERENCED(flags);
SUBDBG("coretemp_read... %p %d\n", ctx, flags);
for (i = 0; i < CORETEMP_MAX_COUNTERS; i++)
if (c->added[i])
{
int tmp;
size_t len = sizeof(tmp);
if (sysctl (coretemp_native_table[i].resources.mib, 4, &tmp, &len, NULL, 0) == -1)
c->counters[i] = 0;
else
c->counters[i] = tmp/10;
/* Coretemp module returns temperature in tenths of kelvin
Kelvin are useful to avoid negative values... but will have
negative temperatures ??? */
}
*events = c->counters;
return PAPI_OK;
}
| int coretemp_reset | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctrl | ||
| ) |
Triggered by PAPI_reset
Definition at line 364 of file coretemp_freebsd.c.
{
UNREFERENCED(ctx);
UNREFERENCED(ctrl);
SUBDBG("coretemp_reset ctx=%p ctrl=%p...\n", ctx, ctrl);
/* These sensors cannot be reseted */
return PAPI_OK;
}
| int coretemp_set_domain | ( | hwd_control_state_t * | cntrl, |
| int | domain | ||
| ) |
This function has to set the bits needed to count different domains In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER By default return PAPI_EINVAL if none of those are specified and PAPI_OK with success PAPI_DOM_USER is only user context is counted PAPI_DOM_KERNEL is only the Kernel/OS context is counted PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses) PAPI_DOM_ALL is all of the domains
Definition at line 418 of file coretemp_freebsd.c.
{
int found = 0;
UNREFERENCED(cntrl);
SUBDBG ("coretemp_set_domain... %p %d\n", cntrl, domain);
if (PAPI_DOM_USER & domain)
{
SUBDBG( " PAPI_DOM_USER \n" );
found = 1;
}
if (PAPI_DOM_KERNEL & domain)
{
SUBDBG( " PAPI_DOM_KERNEL \n" );
found = 1;
}
if (PAPI_DOM_OTHER & domain)
{
SUBDBG( " PAPI_DOM_OTHER \n" );
found = 1;
}
if (PAPI_DOM_ALL & domain)
{
SUBDBG( " PAPI_DOM_ALL \n" );
found = 1;
}
if (!found)
return PAPI_EINVAL ;
return PAPI_OK;
}
| int coretemp_shutdown_component | ( | void | ) |
Triggered by PAPI_shutdown()
Definition at line 377 of file coretemp_freebsd.c.
{
SUBDBG( "coretemp_shutdown_component... %p\n", ctx );
/* Last chance to clean up */
papi_free (coretemp_native_table);
return PAPI_OK;
}
| int coretemp_start | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctrl | ||
| ) |
Triggered by PAPI_start()
Definition at line 288 of file coretemp_freebsd.c.
{
UNREFERENCED(ctx);
UNREFERENCED(ctrl);
SUBDBG( "coretemp_start %p %p...\n", ctx, ctrl );
/* Nothing to be done */
return PAPI_OK;
}
| int coretemp_stop | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctrl | ||
| ) |
Triggered by PAPI_stop()
Definition at line 302 of file coretemp_freebsd.c.
{
UNREFERENCED(ctx);
UNREFERENCED(ctrl);
SUBDBG("coretemp_stop %p %p...\n", ctx, ctrl);
/* Nothing to be done */
return PAPI_OK;
}
| int coretemp_update_control_state | ( | hwd_control_state_t * | ptr, |
| NativeInfo_t * | native, | ||
| int | count, | ||
| hwd_context_t * | ctx | ||
| ) |
Triggered by eventset operations like add or remove
Definition at line 265 of file coretemp_freebsd.c.
{
int i, index;
coretemp_control_state_t *c = (coretemp_control_state_t *) ptr;
UNREFERENCED(ctx);
SUBDBG("coretemp_update_control_state %p %p...\n", ptr, ctx);
for (i = 0; i < count; i++)
{
index = native[i].ni_event;
native[i].ni_position = coretemp_native_table[index].resources.selector - 1;
c->added[native[i].ni_position] = TRUE;
SUBDBG ("\nnative[%i].ni_position = coretemp_native_table[%i].resources.selector-1 = %i;\n",
i, index, native[i].ni_position );
}
return PAPI_OK;
}
| int coretemp_write | ( | hwd_context_t * | ctx, |
| hwd_control_state_t * | ctrl, | ||
| long_long | events[] | ||
| ) |
Triggered by PAPI_write(), but only if the counters are running
Definition at line 348 of file coretemp_freebsd.c.
{
UNREFERENCED(ctx);
UNREFERENCED(events);
UNREFERENCED(ctrl);
SUBDBG("coretemp_write... %p %p\n", ctx, ctrl);
/* These sensor counters cannot be writtn */
return PAPI_OK;
}
Vector that points to entry points for our component
Definition at line 453 of file coretemp_freebsd.c.
This table contains the native events
Definition at line 83 of file coretemp_freebsd.c.
int CORETEMP_NUM_EVENTS = 0 [static] |
number of events in the table
Definition at line 86 of file coretemp_freebsd.c.