PAPI 7.1.0.0
Loading...
Searching...
No Matches
solaris-niagara2.c File Reference
Include dependency graph for solaris-niagara2.c:

Go to the source code of this file.

Data Structures

struct  __t2_store_t
 
struct  __sol_processor_information_t
 
struct  __t2_pst_table_t
 
struct  __int_syn_table_t
 

Macros

#define hwd_control_state_t   _niagara2_control_state_t
 
#define hwd_context_t   _niagara2_context_t
 
#define hwd_register_t   _niagara2_register_t
 
#define __CHECK_ERR_DFLT(retval)    if(retval != 0){ SUBDBG("RETVAL: %d\n", retval); return PAPI_ECMP;}
 
#define __CHECK_ERR_NULL(retval)    if(retval == NULL){ SUBDBG("RETVAL: NULL\n"); return PAPI_ECMP;}
 
#define __CHECK_ERR_PAPI(retval)    if(retval != PAPI_OK){ SUBDBG("RETVAL: %d\n", retval); return PAPI_ECMP;}
 
#define __CHECK_ERR_INVA(retval)    if(retval != 0){ SUBDBG("RETVAL: %d\n", retval); return PAPI_EINVAL;}
 
#define __CHECK_ERR_NEGV(retval)    if(retval < 0){ SUBDBG("RETVAL: %d\n", retval); return PAPI_ECMP;}
 
#define SYNTHETIC_EVENTS_SUPPORTED   1
 

Enumerations

enum  { SYNTHETIC_CYCLES_ELAPSED = 1 , SYNTHETIC_RETURN_ONE , SYNTHETIC_RETURN_TWO }
 

Functions

int __int_setup_synthetic_event (int, hwd_control_state_t *, void *)
 
uint64_t __int_get_synthetic_event (int, hwd_control_state_t *, void *)
 
void __int_walk_synthetic_events_action_count (void)
 
void __int_walk_synthetic_events_action_store (void)
 
int _niagara2_set_domain (hwd_control_state_t *ctrl, int domain)
 PAPI HWD LAYER RELATED FUNCTIONS ///////////////////////////////////////////.
 
int _niagara2_ctl (hwd_context_t *ctx, int code, _papi_int_option_t *option)
 
void _niagara2_dispatch_timer (int signal, siginfo_t *si, void *info)
 
static void * _niagara2_get_overflow_address (void *context)
 
int _niagara2_init_control_state (hwd_control_state_t *ctrl)
 
int _niagara2_init_component (int cidx)
 
static void _niagara2_lock_init (void)
 
int _niagara2_ntv_code_to_bits (unsigned int EventCode, hwd_register_t *bits)
 
int _niagara2_ntv_code_to_descr (unsigned int EventCode, char *ntv_descr, int len)
 
int _niagara2_ntv_code_to_name (unsigned int EventCode, char *ntv_name, int len)
 
int _niagara2_ntv_enum_events (unsigned int *EventCode, int modifier)
 
int _niagara2_read (hwd_context_t *ctx, hwd_control_state_t *ctrl, long_long **events, int flags)
 
int _niagara2_reset (hwd_context_t *ctx, hwd_control_state_t *ctrl)
 
int _niagara2_set_profile (EventSetInfo_t *ESI, int EventIndex, int threshold)
 
int _niagara2_set_overflow (EventSetInfo_t *ESI, int EventIndex, int threshold)
 
int _niagara2_shutdown (hwd_context_t *ctx)
 
int _niagara2_shutdown_global (void)
 
int _niagara2_start (hwd_context_t *ctx, hwd_control_state_t *ctrl)
 
int _niagara2_stop (hwd_context_t *ctx, hwd_control_state_t *ctrl)
 
int _niagara2_update_control_state (hwd_control_state_t *ctrl, NativeInfo_t *native, int count, hwd_context_t *ctx)
 
int _niagara2_update_shlib_info (papi_mdi_t *mdi)
 
static int __cpc_build_ntv_table (void)
 UTILITY FUNCTIONS FOR ACCESS TO LIBCPC AND SOLARIS /////////////////////////.
 
static int __cpc_search_ntv_event (char *event_name, int *event_code)
 
static int __cpc_build_pst_table (void)
 
static int __cpc_recreate_set (hwd_control_state_t *ctrl)
 
static int __cpc_domain_translator (const int papi_domain)
 
void __cpc_error_handler (const char *fn, int subcode, const char *fmt, va_list ap)
 
static int __cpc_enable_sigemt (hwd_control_state_t *ctrl, int position)
 
void __cpc_walk_events_pic_action_count (void *arg, uint_t picno, const char *event)
 
void __cpc_walk_events_pic_action_store (void *arg, uint_t picno, const char *event)
 
static int __sol_get_processor_clock (void)
 
static int __sol_get_itimer_ns (int ns)
 
static lwpstatus_t * __sol_get_lwp_status (const pid_t pid, const lwpid_t lwpid)
 
static psinfo_t * __sol_get_proc_info (const pid_t pid)
 
static pstatus_t * __sol_get_proc_status (const pid_t pid)
 

Variables

vptr_t _start
 
vptr_t _end
 
vptr_t _etext
 
vptr_t _edata
 
papi_vector_t _niagara2_vector
 
papi_mdi_t _papi_hwi_system_info
 
static cpc_t * cpc = NULL
 
static __t2_store_t __t2_store
 
static char ** __t2_ntv_events
 
static int pid
 
static __t2_pst_table_t __t2_table []
 
hwi_search_tpreset_table
 
enum { ... }  __int_synthetic_enum
 
static __int_syn_table_t __int_syn_table []
 
papi_os_vector_t _papi_os_vector
 

Macro Definition Documentation

◆ __CHECK_ERR_DFLT

#define __CHECK_ERR_DFLT (   retval)     if(retval != 0){ SUBDBG("RETVAL: %d\n", retval); return PAPI_ECMP;}

Definition at line 78 of file solaris-niagara2.c.

◆ __CHECK_ERR_INVA

#define __CHECK_ERR_INVA (   retval)     if(retval != 0){ SUBDBG("RETVAL: %d\n", retval); return PAPI_EINVAL;}

Definition at line 87 of file solaris-niagara2.c.

◆ __CHECK_ERR_NEGV

#define __CHECK_ERR_NEGV (   retval)     if(retval < 0){ SUBDBG("RETVAL: %d\n", retval); return PAPI_ECMP;}

Definition at line 90 of file solaris-niagara2.c.

◆ __CHECK_ERR_NULL

#define __CHECK_ERR_NULL (   retval)     if(retval == NULL){ SUBDBG("RETVAL: NULL\n"); return PAPI_ECMP;}

Definition at line 81 of file solaris-niagara2.c.

◆ __CHECK_ERR_PAPI

#define __CHECK_ERR_PAPI (   retval)     if(retval != PAPI_OK){ SUBDBG("RETVAL: %d\n", retval); return PAPI_ECMP;}

Definition at line 84 of file solaris-niagara2.c.

◆ hwd_context_t

Definition at line 65 of file solaris-niagara2.c.

◆ hwd_control_state_t

Definition at line 64 of file solaris-niagara2.c.

◆ hwd_register_t

Definition at line 66 of file solaris-niagara2.c.

◆ SYNTHETIC_EVENTS_SUPPORTED

#define SYNTHETIC_EVENTS_SUPPORTED   1

Definition at line 129 of file solaris-niagara2.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SYNTHETIC_CYCLES_ELAPSED 
SYNTHETIC_RETURN_ONE 
SYNTHETIC_RETURN_TWO 

Definition at line 194 of file solaris-niagara2.c.

195{
@ SYNTHETIC_CYCLES_ELAPSED
@ SYNTHETIC_RETURN_TWO
@ SYNTHETIC_RETURN_ONE
enum @188 __int_synthetic_enum

Function Documentation

◆ __cpc_build_ntv_table()

static int __cpc_build_ntv_table ( void  )
inlinestatic

Definition at line 1545 of file solaris-niagara2.c.

1546{
1547 int i, tmp;
1548
1549#ifdef DEBUG
1550 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1551 __LINE__ );
1552#endif
1553
1554 __t2_store.pic_ntv_count = papi_calloc( __t2_store.npic, sizeof ( int ) );
1556
1557#ifdef DEBUG
1558 SUBDBG( " -> %s: Checking PICs for functionality\n", __func__ );
1559#endif
1560
1561 for ( i = 0; i < __t2_store.npic; i++ ) {
1562 cpc_walk_events_pic( cpc, i, NULL, __cpc_walk_events_pic_action_count );
1563
1564#ifdef DEBUG
1565 SUBDBG( " -> %s: Found %d events on PIC#%d\n", __func__,
1567#endif
1568 }
1569
1571
1572 /* There should be at least one counter... */
1573 if ( tmp == 0 ) {
1574#ifdef DEBUG
1575 SUBDBG( " -> %s: PIC#0 has 0 events\n", __func__ );
1576#endif
1577
1578 return PAPI_ECMP;
1579 }
1580
1581 /* Check if all PICs have the same number of counters */
1582 for ( i = 0; i < __t2_store.npic; i++ ) {
1583 if ( __t2_store.pic_ntv_count[i] != tmp ) {
1584#ifdef DEBUG
1585 SUBDBG( " -> %s: PIC#%d has %d events, should have %d\n",
1586 __func__, i, __t2_store.pic_ntv_count[i], tmp );
1587#endif
1588
1589 return PAPI_ECMP;
1590 }
1591 }
1592
1593 /* Count synthetic events which add functionality to libcpc */
1594#ifdef SYNTHETIC_EVENTS_SUPPORTED
1597#endif
1598
1599 /* Store the count of events available in central data structure */
1600#ifndef SYNTHETIC_EVENTS_SUPPORTED
1602#else
1605#endif
1606
1607
1608 /* Allocate memory for storing all events found, including the first empty
1609 slot */
1612 sizeof ( char * ) );
1613
1614 __t2_ntv_events[0] = "THIS IS A BUG!";
1615
1616 tmp = 1;
1617 cpc_walk_events_pic( cpc, 0, ( void * ) &tmp,
1619
1620#ifdef SYNTHETIC_EVENTS_SUPPORTED
1622#endif
1623
1624#ifdef DEBUG
1625 for ( i = 1; i < __t2_store.pic_ntv_count[0]; i++ ) {
1626 SUBDBG( " -> %s: Event #%d: %s\n", __func__, i, __t2_ntv_events[i] );
1627 }
1628#endif
1629
1630#ifdef DEBUG
1631 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1632 __LINE__ );
1633#endif
1634
1635 return PAPI_OK;
1636}
double tmp
int i
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ECMP
Definition: f90papi.h:214
#define SUBDBG(format, args...)
Definition: papi_debug.h:64
#define papi_calloc(a, b)
Definition: papi_memory.h:37
static cpc_t * cpc
void __cpc_walk_events_pic_action_count(void *arg, uint_t picno, const char *event)
static char ** __t2_ntv_events
void __int_walk_synthetic_events_action_count(void)
void __cpc_walk_events_pic_action_store(void *arg, uint_t picno, const char *event)
papi_vector_t _niagara2_vector
void __int_walk_synthetic_events_action_store(void)
static __t2_store_t __t2_store
#define __CHECK_ERR_NULL(retval)
PAPI_component_info_t cmp_info
Definition: papi_vector.h:20
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __cpc_build_pst_table()

static int __cpc_build_pst_table ( void  )
inlinestatic

Definition at line 1656 of file solaris-niagara2.c.

1657{
1658 int num_psts, i, j, event_code, pst_events;
1660
1661#ifdef DEBUG
1662 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1663 __LINE__ );
1664#endif
1665
1666 num_psts = 0;
1667
1668 while ( __t2_table[num_psts].papi_pst != 0 ) {
1669 num_psts++;
1670 }
1671
1672#ifdef DEBUG
1673 SUBDBG( " -> %s: Found %d presets\n", __func__, num_psts );
1674#endif
1675
1676 preset_table = papi_calloc( num_psts + 1, sizeof ( hwi_search_t ) );
1678
1679 pst_events = 0;
1680
1681 for ( i = 0; i < num_psts; i++ ) {
1682 memset( &tmp, PAPI_NULL, sizeof ( tmp ) );
1683
1684 /* Mark counters as unused. If they are needed, they will be overwritten
1685 later. See papi_preset.c:51 for more details. */
1686 for ( j = 0; j < PAPI_EVENTS_IN_DERIVED_EVENT; j++ ) {
1687 tmp.data.native[j] = PAPI_NULL;
1688 }
1689
1690 tmp.event_code = __t2_table[i].papi_pst;
1691 tmp.data.derived = __t2_table[i].ntv_opcode;
1692 tmp.data.operation[0] = '\0';
1693
1694 switch ( __t2_table[i].ntv_opcode ) {
1695 case DERIVED_ADD:
1696 tmp.data.operation[0] = '+';
1697 break;
1698 case DERIVED_SUB:
1699 tmp.data.operation[0] = '-';
1700 break;
1701 }
1702
1703 for ( j = 0; j < __t2_table[i].ntv_ctrs; j++ ) {
1705 ( __t2_table[i].ntv_event[j], &event_code )
1706 >= PAPI_OK ) {
1707 tmp.data.native[j] = event_code;
1708 } else {
1709 continue;
1710 }
1711 }
1712
1713#ifdef DEBUG
1714 SUBDBG( " -> %s: pst row %d - event_code=%d\n",
1715 __func__, i, tmp.event_code );
1716 SUBDBG( " -> %s: pst row %d - data.derived=%d, data.operation=%c\n",
1717 __func__, i, tmp.data.derived, tmp.data.operation[0] );
1718 SUBDBG( " -> %s: pst row %d - native event codes:\n", __func__, i );
1719 {
1720 int d_i;
1721
1722 for ( d_i = 0; d_i < PAPI_EVENTS_IN_DERIVED_EVENT; d_i++ ) {
1723 SUBDBG( " -> %s: pst row %d - +++ data.native[%d]=%d\n",
1724 __func__, i, d_i, tmp.data.native[d_i] );
1725 }
1726 }
1727#endif
1728
1729 memcpy( &preset_table[i], &tmp, sizeof ( tmp ) );
1730
1731 pst_events++;
1732 }
1733
1734 // Check!
1735 memset( &preset_table[num_psts], 0, sizeof ( hwi_search_t ) );
1736
1738
1739#ifdef DEBUG
1740 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1741 __LINE__ );
1742#endif
1743
1744 return PAPI_OK;
1745}
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_EVENTS_IN_DERIVED_EVENT
#define DERIVED_SUB
Definition: papi_internal.h:73
#define DERIVED_ADD
Definition: papi_internal.h:69
static __t2_pst_table_t __t2_table[]
hwi_search_t * preset_table
static int __cpc_search_ntv_event(char *event_name, int *event_code)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __cpc_domain_translator()

static int __cpc_domain_translator ( const int  papi_domain)
inlinestatic

Definition at line 1822 of file solaris-niagara2.c.

1823{
1824 int domain = 0;
1825
1826#ifdef DEBUG
1827 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1828 __LINE__ );
1829 SUBDBG( " -> %s: papi_domain=%d requested\n", __func__, papi_domain );
1830#endif
1831
1832 if ( papi_domain & PAPI_DOM_USER ) {
1833#ifdef DEBUG
1834 SUBDBG( " -> %s: Domain PAPI_DOM_USER/CPC_COUNT_USER selected\n",
1835 __func__ );
1836#endif
1837 domain |= CPC_COUNT_USER;
1838 }
1839
1840 if ( papi_domain & PAPI_DOM_KERNEL ) {
1841#ifdef DEBUG
1842 SUBDBG( " -> %s: Domain PAPI_DOM_KERNEL/CPC_COUNT_SYSTEM selected\n",
1843 __func__ );
1844#endif
1845 domain |= CPC_COUNT_SYSTEM;
1846 }
1847
1848 if ( papi_domain & PAPI_DOM_SUPERVISOR ) {
1849#ifdef DEBUG
1850 SUBDBG( " -> %s: Domain PAPI_DOM_SUPERVISOR/CPC_COUNT_HV selected\n",
1851 __func__ );
1852#endif
1853 domain |= CPC_COUNT_HV;
1854 }
1855#ifdef DEBUG
1856 SUBDBG( " -> %s: domain=%d\n", __func__, domain );
1857#endif
1858
1859 return domain;
1860}
#define PAPI_DOM_USER
Definition: f90papi.h:174
#define PAPI_DOM_KERNEL
Definition: f90papi.h:254
#define PAPI_DOM_SUPERVISOR
Definition: f90papi.h:109
Here is the caller graph for this function:

◆ __cpc_enable_sigemt()

static int __cpc_enable_sigemt ( hwd_control_state_t ctrl,
int  position 
)
inlinestatic

Definition at line 1881 of file solaris-niagara2.c.

1882{
1883#ifdef DEBUG
1884 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1885 __LINE__ );
1886#endif
1887
1888 if ( position >= MAX_COUNTERS ) {
1889#ifdef DEBUG
1890 SUBDBG( " -> %s: Position of the counter does not exist\n", __func__ );
1891#endif
1892
1893 return PAPI_EINVAL;
1894 }
1895
1896 ctrl->flags[position] = ctrl->flags[position] | CPC_OVF_NOTIFY_EMT;
1897
1898#ifdef DEBUG
1899 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1900 __LINE__ );
1901#endif
1902
1903 return __cpc_recreate_set( ctrl );
1904}
#define PAPI_EINVAL
Definition: f90papi.h:115
#define MAX_COUNTERS
Definition: perfctr-x86.h:8
static int __cpc_recreate_set(hwd_control_state_t *ctrl)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ __cpc_error_handler()

void __cpc_error_handler ( const char *  fn,
int  subcode,
const char *  fmt,
va_list  ap 
)

Definition at line 1863 of file solaris-niagara2.c.

1864{
1865#ifdef DEBUG
1866 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1867 __LINE__ );
1868#endif
1869
1870 /* From the libcpc manpages */
1871 fprintf( stderr, "ERROR - libcpc error handler in %s() called!\n", fn );
1872 vfprintf( stderr, fmt, ap );
1873
1874#ifdef DEBUG
1875 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1876 __LINE__ );
1877#endif
1878}
FILE * stderr
const char * fmt
Definition: pscanf.h:10
Here is the caller graph for this function:

◆ __cpc_recreate_set()

static int __cpc_recreate_set ( hwd_control_state_t ctrl)
inlinestatic

Definition at line 1748 of file solaris-niagara2.c.

1749{
1750#ifdef SYNTHETIC_EVENTS_SUPPORTED
1751 const int syn_barrier = _niagara2_vector.cmp_info.num_native_events
1753#endif
1754
1755 int i;
1756
1757#ifdef DEBUG
1758 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1759 __LINE__ );
1760#endif
1761
1762 /* Destroy the old buffer and the old set if they exist, we need to do a full
1763 recreate as changing flags or events through libcpc is not possible */
1764 if ( ctrl->counter_buffer != NULL ) {
1765 __CHECK_ERR_DFLT( cpc_buf_destroy( cpc, ctrl->counter_buffer ) );
1766 }
1767
1768 if ( ctrl->set != NULL ) {
1769 __CHECK_ERR_DFLT( cpc_set_destroy( cpc, ctrl->set ) );
1770 }
1771
1772 /* Create a new set */
1773 ctrl->set = cpc_set_create( cpc );
1774 __CHECK_ERR_NULL( ctrl->set );
1775
1776 for ( i = 0; i < ctrl->count; i++ ) {
1777#ifdef DEBUG
1778 SUBDBG( " -> %s: Adding native event %#x (%s) on position %d\n",
1779 __func__, ctrl->code[i].event_code,
1780 __t2_ntv_events[ctrl->code[i].event_code], i );
1781 SUBDBG( " -> %s: Event setup: ctrl->code[%d].event_code=%#x\n",
1782 __func__, i, ctrl->code[i].event_code );
1783 SUBDBG( " -> %s: Event setup: ctrl->preset[%d]=%d\n",
1784 __func__, i, ctrl->preset[i] );
1785 SUBDBG( " -> %s: Event setup: ctrl->flags[%d]=%#x\n",
1786 __func__, i, ctrl->flags[i] );
1787#endif
1788
1789#ifdef SYNTHETIC_EVENTS_SUPPORTED
1790 /* Ensure that synthetic events are skipped */
1791 if ( ctrl->code[i].event_code >= syn_barrier ) {
1792#ifdef DEBUG
1793 SUBDBG( " -> %s: Skipping counter %d, synthetic event found\n",
1794 __func__, i );
1795#endif
1796
1797 /* Next iteration */
1798 continue;
1799 }
1800#endif
1801
1802 ctrl->idx[i] = cpc_set_add_request( cpc, ctrl->set,
1803 __t2_ntv_events[ctrl->code[i].
1804 event_code],
1805 ctrl->preset[i], ctrl->flags[i], 0,
1806 NULL );
1807 __CHECK_ERR_NEGV( ctrl->idx[i] );
1808 }
1809
1810 ctrl->counter_buffer = cpc_buf_create( cpc, ctrl->set );
1811 __CHECK_ERR_NULL( ctrl->counter_buffer );
1812
1813#ifdef DEBUG
1814 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1815 __LINE__ );
1816#endif
1817
1818 return PAPI_OK;
1819}
#define __CHECK_ERR_NEGV(retval)
#define __CHECK_ERR_DFLT(retval)
Here is the caller graph for this function:

◆ __cpc_search_ntv_event()

static int __cpc_search_ntv_event ( char *  event_name,
int event_code 
)
inlinestatic

Definition at line 1641 of file solaris-niagara2.c.

1642{
1643 int i;
1644
1645 for ( i = 0; i < _niagara2_vector.cmp_info.num_native_events; i++ ) {
1646 if ( strcmp( event_name, __t2_ntv_events[i] ) == 0 ) {
1647 *event_code = i;
1648 return PAPI_OK;
1649 }
1650 }
1651
1652 return PAPI_ENOEVNT;
1653}
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_ENOEVNT
Definition: f90papi.h:139
Here is the caller graph for this function:

◆ __cpc_walk_events_pic_action_count()

void __cpc_walk_events_pic_action_count ( void *  arg,
uint_t  picno,
const char *  event 
)

Definition at line 1907 of file solaris-niagara2.c.

1908{
1909#ifdef DEBUG
1910 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1911 __LINE__ );
1912#endif
1913
1914 __t2_store.pic_ntv_count[picno]++;
1915
1916#ifdef DEBUG
1917 SUBDBG
1918 ( " -> %s: Found one native event on PIC#%d (now totally %d events)\n",
1919 __func__, picno, __t2_store.pic_ntv_count[picno] );
1920#endif
1921
1922#ifdef DEBUG
1923 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1924 __LINE__ );
1925#endif
1926}
Here is the caller graph for this function:

◆ __cpc_walk_events_pic_action_store()

void __cpc_walk_events_pic_action_store ( void *  arg,
uint_t  picno,
const char *  event 
)

Definition at line 1929 of file solaris-niagara2.c.

1930{
1931 int *tmp = ( int * ) arg;
1932
1933#ifdef DEBUG
1934 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1935 __LINE__ );
1936#endif
1937
1938 __t2_ntv_events[*tmp] = papi_strdup( event );
1939
1940#ifdef DEBUG
1941 SUBDBG( " -> %s: Native event >>%s<< registered\n",
1942 __func__, __t2_ntv_events[*tmp] );
1943#endif
1944
1945 *tmp = *tmp + 1;
1946
1947#ifdef DEBUG
1948 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1949 __LINE__ );
1950#endif
1951}
#define papi_strdup(a)
Definition: papi_memory.h:39
Here is the caller graph for this function:

◆ __int_get_synthetic_event()

uint64_t __int_get_synthetic_event ( int  code,
hwd_control_state_t ctrl,
void *  arg 
)

Definition at line 2099 of file solaris-niagara2.c.

2100{
2101#ifdef DEBUG
2102 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2103 __LINE__ );
2104#endif
2105
2106 switch ( code ) {
2108 /* Return the count of ticks this set was bound. If a reset of the set
2109 has been executed the last count will be subtracted. */
2110 {
2111 int *i = ( int * ) arg;
2112 return cpc_buf_tick( cpc,
2113 ctrl->counter_buffer ) - ctrl->syn_hangover[*i];
2114 }
2116 // The name says it - only for testing purposes.
2117#ifdef DEBUG
2118 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2119 __LINE__ );
2120#endif
2121 return 1;
2123 // The name says it - only for testing purposes.
2124#ifdef DEBUG
2125 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2126 __LINE__ );
2127#endif
2128 return 2;
2129 default:
2130
2131#ifdef DEBUG
2132 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2133 __LINE__ );
2134#endif
2135 return PAPI_EINVAL;
2136 }
2137}
Here is the caller graph for this function:

◆ __int_setup_synthetic_event()

int __int_setup_synthetic_event ( int  code,
hwd_control_state_t ctrl,
void *  arg 
)

Definition at line 2143 of file solaris-niagara2.c.

2144{
2145#ifdef DEBUG
2146 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2147 __LINE__ );
2148#endif
2149
2150 switch ( code ) {
2152
2153#ifdef DEBUG
2154 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2155 __LINE__ );
2156#endif
2157 return PAPI_OK;
2158 default:
2159
2160#ifdef DEBUG
2161 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2162 __LINE__ );
2163#endif
2164 return PAPI_EINVAL;
2165 }
2166#ifdef DEBUG
2167 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2168 __LINE__ );
2169#endif
2170}
Here is the caller graph for this function:

◆ __int_walk_synthetic_events_action_count()

void __int_walk_synthetic_events_action_count ( void  )

Definition at line 2176 of file solaris-niagara2.c.

2177{
2178 int i = 0;
2179
2180#ifdef DEBUG
2181 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2182 __LINE__ );
2183#endif
2184
2185 /* Count all synthetic events in __int_syn_table, the last event is marked
2186 with an event code of -1. */
2187 while ( __int_syn_table[i].code != -1 ) {
2189 i++;
2190 }
2191
2192#ifdef DEBUG
2193 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2194 __LINE__ );
2195#endif
2196}
static __int_syn_table_t __int_syn_table[]
Here is the caller graph for this function:

◆ __int_walk_synthetic_events_action_store()

void __int_walk_synthetic_events_action_store ( void  )

Definition at line 2202 of file solaris-niagara2.c.

2203{
2204 /* The first index of a synthetic event starts after last native event */
2205 int i = 0;
2208
2209#ifdef DEBUG
2210 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2211 __LINE__ );
2212#endif
2213
2214 while ( i < __t2_store.syn_evt_count ) {
2216 i++;
2217 }
2218
2219#ifdef DEBUG
2220 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2221 __LINE__ );
2222#endif
2223}
const char * name
Definition: rocs.c:225
Here is the caller graph for this function:

◆ __sol_get_itimer_ns()

static int __sol_get_itimer_ns ( int  ns)
inlinestatic

Definition at line 1986 of file solaris-niagara2.c.

1987{
1988 if ( ns < _papi_os_info.itimer_res_ns ) {
1990 } else {
1991 int leftover_ns = ns % _papi_os_info.itimer_res_ns;
1992 return ns + leftover_ns;
1993 }
1994}
PAPI_os_info_t _papi_os_info
Definition: aix.c:1210
Here is the caller graph for this function:

◆ __sol_get_lwp_status()

static lwpstatus_t * __sol_get_lwp_status ( const pid_t  pid,
const lwpid_t  lwpid 
)
inlinestatic

Definition at line 1997 of file solaris-niagara2.c.

1998{
1999 char *pattern = "/proc/%d/lwp/%d/lwpstatus";
2000 char filename[PAPI_MIN_STR_LEN];
2001 int fd;
2002 static lwpstatus_t lwp;
2003
2004#ifdef DEBUG
2005 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2006 __LINE__ );
2007#endif
2008
2009 memset( &lwp, 0, sizeof ( lwp ) );
2010 snprintf( filename, PAPI_MIN_STR_LEN, pattern, pid, lwpid );
2011
2012 fd = open( filename, O_RDONLY );
2013 if ( fd == -1 )
2014 return NULL;
2015
2016 read( fd, ( void * ) &lwp, sizeof ( lwp ) );
2017
2018 close( fd );
2019
2020#ifdef DEBUG
2021 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2022 __LINE__ );
2023#endif
2024
2025 return &lwp;
2026}
int open(const char *pathname, int flags, mode_t mode)
Definition: appio.c:188
int close(int fd)
Definition: appio.c:179
ssize_t read(int fd, void *buf, size_t count)
Definition: appio.c:229
#define PAPI_MIN_STR_LEN
Definition: f90papi.h:208
static int pid
Here is the call graph for this function:

◆ __sol_get_proc_info()

static psinfo_t * __sol_get_proc_info ( const pid_t  pid)
inlinestatic

Definition at line 2029 of file solaris-niagara2.c.

2030{
2031 char *pattern = "/proc/%d/psinfo";
2032 char filename[PAPI_MIN_STR_LEN];
2033 int fd;
2034 static psinfo_t proc;
2035
2036#ifdef DEBUG
2037 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2038 __LINE__ );
2039#endif
2040
2041 memset( &proc, 0, sizeof ( proc ) );
2042 snprintf( filename, PAPI_MIN_STR_LEN, pattern, pid );
2043
2044 fd = open( filename, O_RDONLY );
2045 if ( fd == -1 )
2046 return NULL;
2047
2048 read( fd, ( void * ) &proc, sizeof ( proc ) );
2049
2050 close( fd );
2051
2052#ifdef DEBUG
2053 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2054 __LINE__ );
2055#endif
2056
2057 return &proc;
2058}
Here is the call graph for this function:

◆ __sol_get_proc_status()

static pstatus_t * __sol_get_proc_status ( const pid_t  pid)
inlinestatic

Definition at line 2061 of file solaris-niagara2.c.

2062{
2063 char *pattern = "/proc/%d/status";
2064 char filename[PAPI_MIN_STR_LEN];
2065 int fd;
2066 static pstatus_t proc;
2067
2068#ifdef DEBUG
2069 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2070 __LINE__ );
2071#endif
2072
2073 memset( &proc, 0, sizeof ( proc ) );
2074 snprintf( filename, PAPI_MIN_STR_LEN, pattern, pid );
2075
2076 fd = open( filename, O_RDONLY );
2077 if ( fd == -1 )
2078 return NULL;
2079
2080 read( fd, ( void * ) &proc, sizeof ( proc ) );
2081
2082 close( fd );
2083
2084#ifdef DEBUG
2085 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
2086 __LINE__ );
2087#endif
2088
2089 return &proc;
2090}
Here is the call graph for this function:

◆ __sol_get_processor_clock()

static int __sol_get_processor_clock ( void  )
inlinestatic

Definition at line 1954 of file solaris-niagara2.c.

1955{
1956 processor_info_t pinfo;
1957
1958#ifdef DEBUG
1959 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1960 __LINE__ );
1961#endif
1962
1963 // Fetch information from the first processor in the system
1964 if ( processor_info( getcpuid( ), &pinfo ) == 0 ) {
1965
1966#ifdef DEBUG
1967 SUBDBG( " -> %s: Clock at %d MHz\n", __func__, pinfo.pi_clock );
1968#endif
1969
1970 return pinfo.pi_clock;
1971 }
1972#ifdef DEBUG
1973 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1974 __LINE__ );
1975#endif
1976
1977 return PAPI_ESYS;
1978}
#define PAPI_ESYS
Definition: f90papi.h:136

◆ _niagara2_ctl()

int _niagara2_ctl ( hwd_context_t ctx,
int  code,
_papi_int_option_t option 
)

Definition at line 275 of file solaris-niagara2.c.

276{
277#ifdef DEBUG
278 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
279 __LINE__ );
280 SUBDBG( " -> %s: Option #%d requested\n", __func__, code );
281#endif
282
283 /* Only these options are handled which are handled in PAPI_set_opt, as many
284 of the left out options are not settable, like PAPI_MAX_CPUS. */
285
286 switch ( code ) {
287 case PAPI_DEFDOM:
288 /* From papi.h: Domain for all new eventsets. Takes non-NULL option
289 pointer. */
290
292
293 return PAPI_OK;
294 case PAPI_DOMAIN:
295 /* From papi.h: Domain for an eventset */
296
297 return _niagara2_set_domain( ctx, option->domain.domain );
298 case PAPI_DEFGRN:
299 /* From papi.h: Granularity for all new eventsets */
300
302 option->granularity.granularity;
303
304 return PAPI_OK;
305 case PAPI_GRANUL:
306 /* From papi.h: Granularity for an eventset */
307
308 /* Only supported granularity is PAPI_GRN_THREAD */
309
310 return PAPI_OK;
311 case PAPI_DEF_MPX_NS:
312 /* From papi.h: Multiplexing/overflowing interval in ns, same as
313 PAPI_DEF_ITIMER_NS */
314
315 /* From the old component */
316 option->itimer.ns = __sol_get_itimer_ns( option->itimer.ns );
317
318#ifdef DEBUG
319 SUBDBG( " -> %s: PAPI_DEF_MPX_NS, option->itimer.ns=%d\n",
320 __func__, option->itimer.ns );
321#endif
322
323 return PAPI_OK;
324 case PAPI_DEF_ITIMER: // IN THE OLD COMPONENT // USED
325 /* From papi.h: Option to set the type of itimer used in both software
326 multiplexing, overflowing and profiling */
327
328 /* These tests are taken from the old component. For Solaris 10 the
329 same rules apply as documented in getitimer(2). */
330
331 if ( ( option->itimer.itimer_num == ITIMER_REAL ) &&
332 ( option->itimer.itimer_sig != SIGALRM ) ) {
333#ifdef DEBUG
334 SUBDBG( " -> %s: PAPI_DEF_ITIMER, ITIMER_REAL needs SIGALRM\n",
335 __func__ );
336#endif
337
338 return PAPI_EINVAL;
339 }
340
341
342 if ( ( option->itimer.itimer_num == ITIMER_VIRTUAL ) &&
343 ( option->itimer.itimer_sig != SIGVTALRM ) ) {
344#ifdef DEBUG
345 SUBDBG( " -> %s: PAPI_DEF_ITIMER, ITIMER_VIRTUAL needs SIGVTALRM\n",
346 __func__ );
347#endif
348
349 return PAPI_EINVAL;
350 }
351
352
353 if ( ( option->itimer.itimer_num == ITIMER_PROF ) &&
354 ( option->itimer.itimer_sig != SIGPROF ) ) {
355#ifdef DEBUG
356 SUBDBG( " -> %s: PAPI_DEF_ITIMER, ITIMER_PROF needs SIGPROF\n",
357 __func__ );
358#endif
359
360 return PAPI_EINVAL;
361 }
362
363
364 /* As in the old component defined, timer values below 0 are NOT
365 filtered out, but timer values greater than 0 are rounded, either to
366 a value which is at least itimer_res_ns or padded to a multiple of
367 itimer_res_ns. */
368
369 if ( option->itimer.ns > 0 ) {
370 option->itimer.ns = __sol_get_itimer_ns( option->itimer.ns );
371
372#ifdef DEBUG
373 SUBDBG( " -> %s: PAPI_DEF_ITIMER, option->itimer.ns=%d\n",
374 __func__, option->itimer.ns );
375#endif
376 }
377
378 return PAPI_OK;
379 case PAPI_DEF_ITIMER_NS: // IN THE OLD COMPONENT // USED
380 /* From papi.h: Multiplexing/overflowing interval in ns, same as
381 PAPI_DEF_MPX_NS */
382
383 /* From the old component */
384 option->itimer.ns = __sol_get_itimer_ns( option->itimer.ns );
385
386#ifdef DEBUG
387 SUBDBG( " -> %s: PAPI_DEF_ITIMER_NS, option->itimer.ns=%d\n",
388 __func__, option->itimer.ns );
389#endif
390
391 return PAPI_OK;
392 }
393
394#ifdef DEBUG
395 SUBDBG( " -> %s: Option not found\n", __func__ );
396 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
397 __LINE__ );
398#endif
399
400 /* This place should never be reached */
401 return PAPI_EINVAL;
402}
#define PAPI_DEFGRN
Definition: f90papi.h:26
#define PAPI_GRANUL
Definition: f90papi.h:179
#define PAPI_DOMAIN
Definition: f90papi.h:159
#define PAPI_DEF_MPX_NS
Definition: f90papi.h:235
#define PAPI_DEFDOM
Definition: f90papi.h:188
#define PAPI_DEF_ITIMER
Definition: papi.h:462
#define PAPI_DEF_ITIMER_NS
Definition: papi.h:463
static int __sol_get_itimer_ns(int ns)
int _niagara2_set_domain(hwd_control_state_t *ctrl, int domain)
PAPI HWD LAYER RELATED FUNCTIONS ///////////////////////////////////////////.
int default_granularity
Definition: papi.h:644
_papi_int_domain_t domain
_papi_int_granularity_t granularity
_papi_int_itimer_t itimer
Here is the call graph for this function:

◆ _niagara2_dispatch_timer()

void _niagara2_dispatch_timer ( int  signal,
siginfo_t si,
void *  info 
)

Definition at line 405 of file solaris-niagara2.c.

406{
407 EventSetInfo_t *ESI = NULL;
408 ThreadInfo_t *thread = NULL;
409 int overflow_vector = 0;
410 hwd_control_state_t *ctrl = NULL;
411 long_long results[MAX_COUNTERS];
412 int i;
413 // Hint from perf_events.c
415
416
417#ifdef DEBUG
418 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
419 __LINE__ );
420 SUBDBG( " -> %s: Overflow handler called by signal #%d\n", __func__,
421 signal );
422#endif
423
424 /* From the old component */
426 ESI = ( EventSetInfo_t * ) thread->running_eventset[cidx];
427
428 /* From the old component, modified */
429 //
430 if ( ESI == NULL || ESI->master != thread || ESI->ctl_state == NULL ||
431 ( ( ESI->state & PAPI_OVERFLOWING ) == 0 ) ) {
432#ifdef DEBUG
433 SUBDBG( " -> %s: Problems with ESI, not necessarily serious\n",
434 __func__ );
435
436 if ( ESI == NULL ) {
437 SUBDBG( " -> %s: +++ ESI is NULL\n", __func__ );
438 }
439
440 if ( ESI->master != thread ) {
441 SUBDBG( " -> %s: +++ Thread mismatch, ESI->master=%#x thread=%#x\n",
442 __func__, ESI->master, thread );
443 }
444
445 if ( ESI->ctl_state == NULL ) {
446 SUBDBG( " -> %s: +++ Counter state invalid\n", __func__ );
447 }
448
449 if ( ( ( ESI->state & PAPI_OVERFLOWING ) == 0 ) ) {
450 SUBDBG
451 ( " -> %s: +++ Overflow flag missing, ESI->overflow.flags=%#x\n",
452 __func__, ESI->overflow.flags );
453 }
454#endif
455
456 return;
457 }
458#ifdef DEBUG
459 printf( " -> %s: Preconditions valid, trying to read counters\n",
460 __func__ );
461#endif
462
463 ctrl = ESI->ctl_state;
464
465 if ( _niagara2_read
466 ( ctrl, ctrl, ( long_long ** ) & results, NOT_A_PAPI_HWD_READ )
467 != PAPI_OK ) {
468 /* Failure */
469
470#ifdef DEBUG
471 printf( "%s: Failed to read counters\n", __func__ );
472#endif
473
474 return;
475 } else {
476 /* Success */
477
478#ifdef DEBUG
479 SUBDBG( " -> %s: Counters read\n", __func__ );
480#endif
481
482 /* Iterate over all available counters in order to detect which counter
483 overflowed (counter value should be 0 if an hw overflow happened),
484 store the position in the overflow_vector, calculte the offset and
485 shift (value range signed long long vs. unsigned long long). */
486 for ( i = 0; i < ctrl->count; i++ ) {
487 if ( results[i] >= 0 ) {
488#ifdef DEBUG
489 SUBDBG( " -> %s: Overflow detected at PIC #%d\n", __func__, i );
490#endif
491
492 /* Set the bit in the overflow_vector */
493 overflow_vector = overflow_vector | ( 1 << i );
494
495 /* hoose which method to use depending on the overflow signal. */
496 if ( signal == SIGEMT ) {
497 /* Store the counter value, but only if we have a real *
498 hardware overflow counting with libcpc/SIGEMT. */
499 ctrl->preset[i] = UINT64_MAX - ctrl->threshold[i];
500 ctrl->hangover[i] += ctrl->threshold[i];
501 } else {
502 /* Push the value back, this time PAPI does the work. This is
503 software overflow handling. */
504 cpc_request_preset( cpc, ctrl->idx[i], ctrl->result[i] );
505 }
506 } else {
507#ifdef DEBUG
508 SUBDBG( " -> %s: No overflow detected at PIC #%d, value=%ld\n",
509 __func__, i, results[i] );
510#endif
511
512 /* Save the results read from the counter as we can not store the
513 temporary value in hardware or libcpc. */
514 if ( signal == SIGEMT ) {
515 ctrl->preset[i] += results[i];
516 ctrl->hangover[i] = results[i];
517 }
518 }
519 }
520
521#ifdef DEBUG
522 SUBDBG( " -> %s: Restarting set to push values back\n", __func__ );
523#endif
524
525 /* Push all values back to the counter as preset */
526 cpc_set_restart( cpc, ctrl->set );
527 }
528
529#ifdef DEBUG
530 SUBDBG( " -> %s: Passing overflow to PAPI with overflow_vector=%p\n",
531 __func__, overflow_vector );
532#endif
533
534 {
535 /* hw is used as pointer in the dispatching routine of PAPI and might be
536 changed. For safety it is not a pseudo pointer to NULL. */
537 int hw;
538
539 if ( signal == SIGEMT ) {
540 /* This is a hardware overflow */
541 hw = 1;
544 ( info ), &hw, overflow_vector,
545 1, &thread, ESI->CmpIdx );
546 } else {
547 /* This is a software overflow */
548 hw = 0;
551 ( info ), &hw, overflow_vector,
552 1, &thread, ESI->CmpIdx );
553 }
554 }
555
556#ifdef DEBUG
557 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
558 __LINE__ );
559#endif
560}
int _papi_hwi_dispatch_overflow_signal(void *papiContext, vptr_t address, int *isHardware, long long overflow_bit, int genOverflowBit, ThreadInfo_t **t, int cidx)
Definition: extras.c:216
#define PAPI_OVERFLOWING
Definition: f90papi.h:240
void * thread(void *arg)
Definition: kufrin.c:38
#define long_long
Definition: papi.h:559
void * vptr_t
Definition: papi.h:576
__sighandler_t signal(int __sig, __sighandler_t __handler) __attribute__((__nothrow__
static int cidx
if(file==NULL) goto out
static void * _niagara2_get_overflow_address(void *context)
int _niagara2_read(hwd_context_t *ctx, hwd_control_state_t *ctrl, long_long **events, int flags)
#define NOT_A_PAPI_HWD_READ
struct _ThreadInfo * master
hwd_control_state_t * ctl_state
EventSetOverflowInfo_t overflow
inline_static ThreadInfo_t * _papi_hwi_lookup_thread(int custom_tid)
Definition: threads.h:97
Here is the call graph for this function:

◆ _niagara2_get_overflow_address()

static void * _niagara2_get_overflow_address ( void *  context)
inlinestatic

Definition at line 563 of file solaris-niagara2.c.

564{
565 ucontext_t *ctx = ( ucontext_t * ) context;
566
567#ifdef DEBUG
568 SUBDBG( "ENTERING/LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
569 __LINE__ );
570#endif
571
572 return ( void * ) ctx->uc_mcontext.gregs[REG_PC];
573}
gregset_t gregs
mcontext_t uc_mcontext
Here is the caller graph for this function:

◆ _niagara2_init_component()

int _niagara2_init_component ( int  cidx)

Definition at line 654 of file solaris-niagara2.c.

655{
656#ifdef DEBUG
657 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
658 __LINE__ );
659#endif
660
661 /* Create an instance of libcpc */
662#ifdef DEBUG
663 SUBDBG( " -> %s: Trying to initalize libcpc\n", __func__ );
664#endif
665 cpc = cpc_open( CPC_VER_CURRENT );
667
668#ifdef DEBUG
669 SUBDBG( " -> %s: Registering libcpc error handler\n", __func__ );
670#endif
671 cpc_seterrhndlr( cpc, __cpc_error_handler );
672
673#ifdef DEBUG
674 SUBDBG( " -> %s: Detecting supported PICs", __func__ );
675#endif
676 __t2_store.npic = cpc_npic( cpc );
677
678#ifdef DEBUG
679 SUBDBG( " -> %s: Storing component index, cidx=%d\n", __func__, cidx );
680#endif
682
683#ifdef DEBUG
684 SUBDBG( " -> %s: Gathering system information for PAPI\n", __func__ );
685#endif
686 /* Store system info in central data structure */
687 __CHECK_ERR_PAPI( _niagara2_get_system_info( &_papi_hwi_system_info ) );
688
689#ifdef DEBUG
690 SUBDBG( " -> %s: Initializing locks\n", __func__ );
691#endif
692 /* Set up the lock after initialization */
694
695 // Copied from the old component, _papi_init_component()
696 SUBDBG( "Found %d %s %s CPUs at %d Mhz.\n",
701
702 /* Build native event table */
703#ifdef DEBUG
704 SUBDBG( " -> %s: Building native event table\n", __func__ );
705#endif
707
708 /* Build preset event table */
709#ifdef DEBUG
710 SUBDBG( " -> %s: Building PAPI preset table\n", __func__ );
711#endif
713
714 /* Register presets and finish event related setup */
715#ifdef DEBUG
716 SUBDBG( " -> %s: Registering presets in PAPI\n", __func__ );
717#endif
719
720#ifdef DEBUG
721 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
722 __LINE__ );
723#endif
724
725 /* Everything is ok */
726 return PAPI_OK;
727}
int _papi_hwi_setup_all_presets(hwi_search_t *findem, int cidx)
Definition: papi_preset.c:44
static void _niagara2_lock_init(void)
papi_mdi_t _papi_hwi_system_info
Definition: papi_internal.c:56
#define __CHECK_ERR_PAPI(retval)
void __cpc_error_handler(const char *fn, int subcode, const char *fmt, va_list ap)
static int __cpc_build_pst_table(void)
static int __cpc_build_ntv_table(void)
UTILITY FUNCTIONS FOR ACCESS TO LIBCPC AND SOLARIS /////////////////////////.
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:782
int totalcpus
Definition: papi.h:780
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:784
int cpu_max_mhz
Definition: papi.h:790
PAPI_hw_info_t hw_info
Here is the call graph for this function:

◆ _niagara2_init_control_state()

int _niagara2_init_control_state ( hwd_control_state_t ctrl)

Although the created set in this function will be destroyed by _papi_update_control_state later, at least the functionality of the underlying CPU driver will be tested completly.

Definition at line 582 of file solaris-niagara2.c.

583{
584 int i;
585
586#ifdef DEBUG
587 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
588 __LINE__ );
589#endif
590
591 // cpc_seterrhndlr(cpc, myapp_errfn);
592
593 /* Clear the buffer */
594 if ( ctrl->counter_buffer != NULL ) {
595#ifdef DEBUG
596 SUBDBG( " -> %s: Cleaning buffer\n", __func__ );
597#endif
598
599 cpc_buf_destroy( cpc, ctrl->counter_buffer );
600 ctrl->counter_buffer = NULL;
601 }
602
603 /* Clear the set */
604 if ( ctrl->set != NULL ) {
605#ifdef DEBUG
606 SUBDBG( " -> %s: Cleaning set\n", __func__ );
607#endif
608
609 cpc_set_destroy( cpc, ctrl->set );
610 ctrl->set = NULL;
611 }
612
613 /* Indicate this idx has no request associated, this counter is unused. */
614 for ( i = 0; i < MAX_COUNTERS; i++ ) {
615#ifdef DEBUG
616 SUBDBG( " -> %s: Cleaning counter state #%d\n", __func__, i );
617#endif
618
619 /* Indicate missing setup values */
620 ctrl->idx[i] = EVENT_NOT_SET;
621 ctrl->code[i].event_code = EVENT_NOT_SET;
622
623 /* No flags yet set, this is for overflow and binding */
624 ctrl->flags[i] = 0;
625
626 /* Preset value for counting results */
627 ctrl->preset[i] = DEFAULT_CNTR_PRESET;
628
629 /* Needed for overflow handling, will be set later */
630 ctrl->threshold[i] = 0;
631 ctrl->hangover[i] = 0;
632
633#ifdef SYNTHETIC_EVENTS_SUPPORTED
634 ctrl->syn_hangover[i] = 0;
635#endif
636 }
637
638 /* No counters active in this set */
639 ctrl->count = 0;
640
641#ifdef SYNTHETIC_EVENTS_SUPPORTED
642 ctrl->syn_count = 0;
643#endif
644
645#ifdef DEBUG
646 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
647 __LINE__ );
648#endif
649
650 return PAPI_OK;
651}
#define EVENT_NOT_SET
#define DEFAULT_CNTR_PRESET

◆ _niagara2_lock_init()

static void _niagara2_lock_init ( void  )
static

Definition at line 730 of file solaris-niagara2.c.

731{
732#ifdef DEBUG
733 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
734 __LINE__ );
735#endif
736
737 /* Copied from old component, lock_init() */
738 memset( lock, 0x0, sizeof ( rwlock_t ) * PAPI_MAX_LOCK );
739
740#ifdef DEBUG
741 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
742 __LINE__ );
743#endif
744}
atomic_p lock[]
Definition: aix.c:25
#define PAPI_MAX_LOCK
Definition: papi_lock.h:18
Here is the caller graph for this function:

◆ _niagara2_ntv_code_to_bits()

int _niagara2_ntv_code_to_bits ( unsigned int  EventCode,
hwd_register_t bits 
)

Definition at line 747 of file solaris-niagara2.c.

748{
749 int event_code = EventCode & PAPI_NATIVE_AND_MASK;
750
751#ifdef DEBUG
752 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
753 __LINE__ );
754#endif
755
756 if ( event_code >= 0 &&
758 return PAPI_ENOEVNT;
759 }
760
761 bits->event_code = event_code;
762
763#ifdef DEBUG
764 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
765 __LINE__ );
766#endif
767
768 return PAPI_OK;
769}
#define PAPI_NATIVE_AND_MASK

◆ _niagara2_ntv_code_to_descr()

int _niagara2_ntv_code_to_descr ( unsigned int  EventCode,
char *  ntv_descr,
int  len 
)

Definition at line 772 of file solaris-niagara2.c.

773{
774#ifdef DEBUG
775 SUBDBG( "ENTERING/LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
776 __LINE__ );
777#endif
778
779 /* libcpc offers no descriptions, just a link to the reference manual */
780 return _niagara2_ntv_code_to_name( EventCode, ntv_descr, len );
781}
int _niagara2_ntv_code_to_name(unsigned int EventCode, char *ntv_name, int len)
Here is the call graph for this function:

◆ _niagara2_ntv_code_to_name()

int _niagara2_ntv_code_to_name ( unsigned int  EventCode,
char *  ntv_name,
int  len 
)

Definition at line 784 of file solaris-niagara2.c.

785{
786 int event_code = EventCode & PAPI_NATIVE_AND_MASK;
787
788#ifdef DEBUG
789 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
790 __LINE__ );
791#endif
792
793 if ( event_code >= 0 &&
795 strlcpy( ntv_name, __t2_ntv_events[event_code], len );
796
797 if ( strlen( __t2_ntv_events[event_code] ) > len - 1 ) {
798#ifdef DEBUG
799 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
800 __LINE__ );
801#endif
802
803 /* It's not a real error, but at least a hint */
804 return PAPI_EBUF;
805 }
806#ifdef DEBUG
807 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
808 __LINE__ );
809#endif
810
811 return PAPI_OK;
812 }
813#ifdef DEBUG
814 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
815 __LINE__ );
816#endif
817
818 return PAPI_ENOEVNT;
819}
#define PAPI_EBUF
Definition: f90papi.h:253
Here is the caller graph for this function:

◆ _niagara2_ntv_enum_events()

int _niagara2_ntv_enum_events ( unsigned int EventCode,
int  modifier 
)

Definition at line 822 of file solaris-niagara2.c.

823{
824 /* This code is very similar to the code from the old component. */
825
826 int event_code = *EventCode & PAPI_NATIVE_AND_MASK;
827
828#ifdef DEBUG
829 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
830 __LINE__ );
831#endif
832
833 if ( modifier == PAPI_ENUM_FIRST ) {
834 *EventCode = PAPI_NATIVE_MASK + 1;
835
836#ifdef DEBUG
837 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
838 __LINE__ );
839#endif
840
841 return PAPI_OK;
842 }
843
844 /* The table needs to be shifted by one position (starting index 1), as PAPI
845 expects native event codes not to be 0 (papi_internal.c:744). */
846
847 if ( event_code >= 1 &&
848 event_code <= _niagara2_vector.cmp_info.num_native_events - 1 ) {
849 *EventCode = *EventCode + 1;
850
851#ifdef DEBUG
852 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
853 __LINE__ );
854#endif
855
856 return PAPI_OK;
857 }
858#ifdef DEBUG
859 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
860 __LINE__ );
861#endif
862
863 // If nothing found report an error
864 return PAPI_ENOEVNT;
865}
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_NATIVE_MASK

◆ _niagara2_read()

int _niagara2_read ( hwd_context_t ctx,
hwd_control_state_t ctrl,
long_long **  events,
int  flags 
)

Definition at line 868 of file solaris-niagara2.c.

870{
871 int i;
872
873#ifdef DEBUG
874 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
875 __LINE__ );
876 SUBDBG( " -> %s: called with flags=%p\n", __func__, flags );
877#endif
878
879 /* Take a new sample from the PIC to the buffer */
880 __CHECK_ERR_DFLT( cpc_set_sample( cpc, ctrl->set, ctrl->counter_buffer ) );
881
882 /* Copy the buffer values from all active counters */
883 for ( i = 0; i < ctrl->count; i++ ) {
884 /* Retrieve the counting results of libcpc */
885 __CHECK_ERR_DFLT( cpc_buf_get( cpc, ctrl->counter_buffer, ctrl->idx[i],
886 &ctrl->result[i] ) );
887
888 /* As libcpc uses uint64_t and PAPI uses int64_t, we need to normalize
889 the result back to a value that PAPI can handle, otherwise the result
890 is not usable as its in the negative range of int64_t and the result
891 becomes useless for PAPI. */
892 if ( ctrl->threshold[i] > 0 ) {
893#ifdef DEBUG
894 SUBDBG( " -> %s: Normalizing result on PIC#%d to %lld\n",
895 __func__, i, ctrl->result[i] );
896#endif /* DEBUG */
897
898 /* This shifts the retrieved value back to the PAPI value range */
899 ctrl->result[i] = ctrl->result[i] -
900 ( UINT64_MAX - ctrl->threshold[i] ) - 1;
901
902 /* Needed if called internally if a PIC didn't really overflow, but
903 was programmed in the same set. */
904 if ( flags != NOT_A_PAPI_HWD_READ ) {
905 ctrl->result[i] = ctrl->hangover[i];
906 }
907#ifdef DEBUG
908 SUBDBG( " -> %s: Overflow scaling on PIC#%d:\n", __func__, i );
909 SUBDBG( " -> %s: +++ ctrl->result[%d]=%llu\n",
910 __func__, i, ctrl->result[i] );
911 SUBDBG( " -> %s: +++ ctrl->threshold[%d]=%lld\n",
912 __func__, i, ctrl->threshold[i] );
913 SUBDBG( " -> %s: +++ ctrl->hangover[%d]=%lld\n",
914 __func__, i, ctrl->hangover[i] );
915#endif
916 }
917#ifdef DEBUG
918 SUBDBG( " -> %s: +++ ctrl->result[%d]=%llu\n",
919 __func__, i, ctrl->result[i] );
920#endif
921 }
922
923#ifdef SYNTHETIC_EVENTS_SUPPORTED
924 {
925 int i;
926 const int syn_barrier = _niagara2_vector.cmp_info.num_native_events
928
929 for ( i = 0; i < ctrl->count; i++ ) {
930 if ( ctrl->code[i].event_code >= syn_barrier ) {
931 ctrl->result[i] =
932 __int_get_synthetic_event( ctrl->code[i].event_code
933 - syn_barrier, ctrl, &i );
934 }
935 }
936 }
937#endif
938
939 /* Pass the address of the results back to the calling function */
940 *events = ( long_long * ) & ctrl->result[0];
941
942#ifdef DEBUG
943 SUBDBG( "LEAVING: %s\n", "_papi_read" );
944#endif
945
946 return PAPI_OK;
947}
char events[MAX_EVENTS][BUFSIZ]
uint64_t __int_get_synthetic_event(int, hwd_control_state_t *, void *)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _niagara2_reset()

int _niagara2_reset ( hwd_context_t ctx,
hwd_control_state_t ctrl 
)

Definition at line 950 of file solaris-niagara2.c.

951{
952#ifdef DEBUG
953 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
954 __LINE__ );
955#endif
956
957 /* This does a restart of the whole set, setting the internal counters back
958 to the value passed as preset of the last call of cpc_set_add_request or
959 cpc_request_preset. */
960 cpc_set_restart( cpc, ctrl->set );
961
962#ifdef SYNTHETIC_EVENTS_SUPPORTED
963 {
964 const int syn_barrier = _niagara2_vector.cmp_info.num_native_events
966 int i;
967
968 if ( ctrl->syn_count > 0 ) {
969 for ( i = 0; i < MAX_COUNTERS; i++ ) {
970 if ( ctrl->code[i].event_code >= syn_barrier ) {
971
972 ctrl->syn_hangover[i] +=
973 __int_get_synthetic_event( ctrl->code[i].event_code -
974 syn_barrier, ctrl, &i );
975 }
976 }
977 }
978 }
979#endif
980
981#ifdef DEBUG
982 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
983 __LINE__ );
984#endif
985
986 return PAPI_OK;
987}
Here is the call graph for this function:

◆ _niagara2_set_domain()

int _niagara2_set_domain ( hwd_control_state_t ctrl,
int  domain 
)

Definition at line 231 of file solaris-niagara2.c.

232{
233 int i;
234
235#ifdef DEBUG
236 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
237 __LINE__ );
238#endif
239
240 /* Clean and set the new flag for each counter */
241
242 for ( i = 0; i < MAX_COUNTERS; i++ ) {
243#ifdef DEBUG
244 SUBDBG( " -> %s: Setting flags for PIC#%d, old value: %p\n",
245 __func__, i, ctrl->flags[i] );
246#endif
247
248 ctrl->flags[i] &= ~( CPC_COUNTING_DOMAINS );
249
250#ifdef DEBUG
251 SUBDBG( " -> %s: +++ cleaned value: %p\n",
252 __func__, ctrl->flags[i] );
253#endif
254
255 ctrl->flags[i] |= __cpc_domain_translator( domain );
256
257#ifdef DEBUG
258 SUBDBG( " -> %s: +++ new value: %p\n",
259 __func__, ctrl->flags[i] );
260#endif
261 }
262
263 /* Recreate the set */
265
266#ifdef DEBUG
267 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
268 __LINE__ );
269#endif
270
271 return PAPI_OK;
272}
static int __cpc_domain_translator(const int papi_domain)
#define CPC_COUNTING_DOMAINS
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _niagara2_set_overflow()

int _niagara2_set_overflow ( EventSetInfo_t ESI,
int  EventIndex,
int  threshold 
)

Definition at line 1003 of file solaris-niagara2.c.

1004{
1005 hwd_control_state_t *ctrl = ESI->ctl_state;
1006 struct sigaction sigact;
1007
1008#ifdef DEBUG
1009 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1010 __LINE__ );
1011 SUBDBG( " -> %s: Overflow handling for %#x on PIC#%d requested\n",
1012 __func__, ctrl, EventIndex );
1013 SUBDBG( " -> %s: ESI->overflow.flags=%#x\n\n", __func__, ctrl,
1014 ESI->overflow.flags );
1015#endif
1016
1017 /* If threshold > 0, then activate hardware overflow handling, otherwise
1018 disable it. */
1019 if ( threshold > 0 ) {
1020#ifdef DEBUG
1021 SUBDBG( " -> %s: Activating overflow handling\n", __func__ );
1022#endif
1023
1024 ctrl->preset[EventIndex] = UINT64_MAX - threshold;
1025 ctrl->threshold[EventIndex] = threshold;
1026
1027 /* If SIGEMT is not yet enabled, enable it. In libcpc this means to re-
1028 recreate the used set. In order not to break PAPI operations only the
1029 event referred by EventIndex will be updated to use SIGEMT. */
1030 if ( !( ctrl->flags[EventIndex] & CPC_OVF_NOTIFY_EMT ) ) {
1031#ifdef DEBUG
1032 SUBDBG( " -> %s: Need to activate SIGEMT on PIC %d\n",
1033 __func__, EventIndex );
1034#endif
1035
1036 /* Enable overflow handling */
1037 if ( __cpc_enable_sigemt( ctrl, EventIndex ) != PAPI_OK ) {
1038#ifdef DEBUG
1039 SUBDBG( " -> %s: Activating SIGEMT failed for PIC %d\n",
1040 __func__, EventIndex );
1041#endif
1042
1043 return PAPI_ESYS;
1044 }
1045 }
1046#ifdef DEBUG
1047 SUBDBG( " -> %s: SIGEMT activated, will install signal handler\n",
1048 __func__ );
1049#endif
1050
1051 // FIXME: Not really sure that this construct is working
1052 return _papi_hwi_start_signal( SIGEMT, 1, 0 );
1053
1054 } else {
1055#ifdef DEBUG
1056 SUBDBG( " -> %s: Disabling overflow handling\n", __func__ );
1057#endif
1058
1059 /* Resetting values which were used for overflow handling */
1060 ctrl->preset[EventIndex] = DEFAULT_CNTR_PRESET;
1061 ctrl->flags[EventIndex] &= ~( CPC_OVF_NOTIFY_EMT );
1062 ctrl->threshold[EventIndex] = 0;
1063 ctrl->hangover[EventIndex] = 0;
1064
1065#ifdef DEBUG
1066 SUBDBG( " -> %s:ctrl->preset[%d]=%d, ctrl->flags[%d]=%p\n",
1067 __func__, EventIndex, ctrl->preset[EventIndex],
1068 EventIndex, ctrl->flags[EventIndex] );
1069#endif
1070
1071 /* Recreate the undelying set and disable the signal handler */
1074 }
1075
1076
1077
1078#ifdef DEBUG
1079 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1080 __LINE__ );
1081#endif
1082
1083 return PAPI_OK;
1084}
int _papi_hwi_start_signal(int signal, int need_context, int cidx)
Definition: extras.c:403
int _papi_hwi_stop_signal(int signal)
Definition: extras.c:443
static int threshold
int sigaction(int __sig, const struct sigaction *__restrict __act, struct sigaction *__restrict __oact) __attribute__((__nothrow__
static int __cpc_enable_sigemt(hwd_control_state_t *ctrl, int position)
Here is the call graph for this function:

◆ _niagara2_set_profile()

int _niagara2_set_profile ( EventSetInfo_t ESI,
int  EventIndex,
int  threshold 
)

Definition at line 990 of file solaris-niagara2.c.

991{
992 /* Seems not to be used. */
993
994#ifdef DEBUG
995 SUBDBG( "ENTERING/LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
996 __LINE__ );
997#endif
998
999 return PAPI_ENOSUPP;
1000}
#define PAPI_ENOSUPP
Definition: f90papi.h:244

◆ _niagara2_shutdown()

int _niagara2_shutdown ( hwd_context_t ctx)

Definition at line 1087 of file solaris-niagara2.c.

1088{
1089#ifdef DEBUG
1090 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1091 __LINE__ );
1092#endif
1093
1094 cpc_buf_destroy( cpc, ctx->counter_buffer );
1095 cpc_set_destroy( cpc, ctx->set );
1096
1097#ifdef DEBUG
1098 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1099 __LINE__ );
1100#endif
1101
1102 return PAPI_OK;
1103}

◆ _niagara2_shutdown_global()

int _niagara2_shutdown_global ( void  )

Definition at line 1106 of file solaris-niagara2.c.

1107{
1108#ifdef DEBUG
1109 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1110 __LINE__ );
1111#endif
1112
1113 /* Free allocated memory */
1114
1115 // papi_calloc in __cpc_build_ntv_table
1117 // papi_calloc in __cpc_build_ntv_table
1119 // papi_calloc in __cpc_build_pst_table
1121
1122 /* Shutdown libcpc */
1123
1124 // cpc_open in _papi_init_component
1125 cpc_close( cpc );
1126
1127#ifdef DEBUG
1128 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1129 __LINE__ );
1130#endif
1131
1132 return PAPI_OK;
1133}
#define papi_free(a)
Definition: papi_memory.h:35

◆ _niagara2_start()

int _niagara2_start ( hwd_context_t ctx,
hwd_control_state_t ctrl 
)

Definition at line 1136 of file solaris-niagara2.c.

1137{
1138 int retval;
1139
1140#ifdef DEBUG
1141 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1142 __LINE__ );
1143 SUBDBG( " -> %s: Starting EventSet %p\n", __func__, ctrl );
1144#endif
1145
1146
1147#ifdef SYNTHETIC_EVENTS_SUPPORTED
1148 {
1149#ifdef DEBUG
1150 SUBDBG( " -> %s: Event count: ctrl->count=%d, ctrl->syn_count=%d\n",
1151 __func__, ctrl->count, ctrl->syn_count );
1152#endif
1153
1154 if ( ctrl->count > 0 && ctrl->count == ctrl->syn_count ) {
1155 ctrl->idx[0] = cpc_set_add_request( cpc, ctrl->set, "Instr_cnt",
1156 ctrl->preset[0], ctrl->flags[0],
1157 0, NULL );
1158 ctrl->counter_buffer = cpc_buf_create( cpc, ctrl->set );
1159 }
1160 }
1161#endif
1162
1163#ifdef DEBUG
1164 {
1165 int i;
1166
1167 for ( i = 0; i < MAX_COUNTERS; i++ ) {
1168 SUBDBG( " -> %s: Flags for PIC#%d: ctrl->flags[%d]=%d\n", __func__,
1169 i, i, ctrl->flags[i] );
1170 }
1171 }
1172#endif
1173
1174 __CHECK_ERR_DFLT( cpc_bind_curlwp( cpc, ctrl->set, CPC_BIND_LWP_INHERIT ) );
1175
1176 /* Ensure the set is working properly */
1177 retval = cpc_set_sample( cpc, ctrl->set, ctrl->counter_buffer );
1178
1179 if ( retval != 0 ) {
1180 printf( "%s: cpc_set_sample failed, return=%d, errno=%d\n",
1181 __func__, retval, errno );
1182 return PAPI_ECMP;
1183 }
1184#ifdef DEBUG
1185 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1186 __LINE__ );
1187#endif
1188
1189 return PAPI_OK;
1190}
int errno
int retval
Definition: zero_fork.c:53

◆ _niagara2_stop()

int _niagara2_stop ( hwd_context_t ctx,
hwd_control_state_t ctrl 
)

Definition at line 1193 of file solaris-niagara2.c.

1194{
1195#ifdef DEBUG
1196 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1197 __LINE__ );
1198#endif
1199
1200 __CHECK_ERR_DFLT( cpc_unbind( cpc, ctrl->set ) );
1201
1202#ifdef DEBUG
1203 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1204 __LINE__ );
1205#endif
1206
1207 return PAPI_OK;
1208}

◆ _niagara2_update_control_state()

int _niagara2_update_control_state ( hwd_control_state_t ctrl,
NativeInfo_t native,
int  count,
hwd_context_t ctx 
)

Definition at line 1211 of file solaris-niagara2.c.

1214{
1215 int i;
1216
1217#ifdef DEBUG
1218 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1219 __LINE__ );
1220#endif
1221
1222 /* Delete everything as we can't change an existing set */
1223 if ( ctrl->counter_buffer != NULL ) {
1224 __CHECK_ERR_DFLT( cpc_buf_destroy( cpc, ctrl->counter_buffer ) );
1225 }
1226
1227 if ( ctrl->set != NULL ) {
1228 __CHECK_ERR_DFLT( cpc_set_destroy( cpc, ctrl->set ) );
1229 }
1230
1231 for ( i = 0; i < MAX_COUNTERS; i++ ) {
1232 ctrl->idx[i] = EVENT_NOT_SET;
1233 }
1234
1235 /* New setup */
1236
1237 ctrl->set = cpc_set_create( cpc );
1238 __CHECK_ERR_NULL( ctrl->set );
1239
1240 ctrl->count = count;
1241 ctrl->syn_count = 0;
1242
1243 for ( i = 0; i < count; i++ ) {
1244 /* Store the active event */
1245 ctrl->code[i].event_code = native[i].ni_event & PAPI_NATIVE_AND_MASK;
1246
1247 ctrl->flags[i] = __cpc_domain_translator( PAPI_DOM_USER );
1248 ctrl->preset[i] = DEFAULT_CNTR_PRESET;
1249
1250#ifdef DEBUG
1251 SUBDBG
1252 ( " -> %s: EventSet@%p/PIC#%d - ntv request >>%s<< (%d), flags=%#x\n",
1253 __func__, ctrl, i, __t2_ntv_events[ctrl->code[i].event_code],
1254 ctrl->code[i].event_code, ctrl->flags[i] );
1255#endif
1256
1257 /* Store the counter position (???) */
1258 native[i].ni_position = i;
1259
1260#ifdef SYNTHETIC_EVENTS_SUPPORTED
1261 {
1262 int syn_code = ctrl->code[i].event_code -
1264 - __t2_store.syn_evt_count ) - 1;
1265
1266 /* Check if the event code is bigger than the CPC provided events. */
1267 if ( syn_code >= 0 ) {
1268#ifdef DEBUG
1269 SUBDBG
1270 ( " -> %s: Adding synthetic event %#x (%s) on position %d\n",
1271 __func__, native[i].ni_event,
1272 __t2_ntv_events[ctrl->code[i].event_code], i );
1273#endif
1274
1275 /* Call the setup routine */
1276 __int_setup_synthetic_event( syn_code, ctrl, NULL );
1277
1278 /* Clean the hangover count as this event is new */
1279 ctrl->syn_hangover[i] = 0;
1280
1281 /* Register this event as being synthetic, as an event set only
1282 based on synthetic events can not be actived through libcpc */
1283 ctrl->syn_count++;
1284
1285 /* Jump to next iteration */
1286 continue;
1287 }
1288 }
1289#endif
1290
1291#ifdef DEBUG
1292 SUBDBG( " -> %s: Adding native event %#x (%s) on position %d\n",
1293 __func__, native[i].ni_event,
1294 __t2_ntv_events[ctrl->code[i].event_code], i );
1295#endif
1296
1297 /* Pass the event as request to libcpc */
1298 ctrl->idx[i] = cpc_set_add_request( cpc, ctrl->set,
1299 __t2_ntv_events[ctrl->code[i].
1300 event_code],
1301 ctrl->preset[i], ctrl->flags[i], 0,
1302 NULL );
1303 __CHECK_ERR_NEGV( ctrl->idx[i] );
1304 }
1305
1306#ifdef DEBUG
1307 if ( i == 0 ) {
1308 SUBDBG( " -> %s: nothing added\n", __func__ );
1309 }
1310#endif
1311
1312 ctrl->counter_buffer = cpc_buf_create( cpc, ctrl->set );
1313 __CHECK_ERR_NULL( ctrl->counter_buffer );
1314
1315 /* Finished the new setup */
1316
1317 /* Linking to context (same data type by typedef!) */
1318 ctx = ctrl;
1319
1320#ifdef DEBUG
1321 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1322 __LINE__ );
1323#endif
1324
1325 return PAPI_OK;
1326}
static long count
static int native
int __int_setup_synthetic_event(int, hwd_control_state_t *, void *)
Here is the call graph for this function:

◆ _niagara2_update_shlib_info()

int _niagara2_update_shlib_info ( papi_mdi_t mdi)

Definition at line 1329 of file solaris-niagara2.c.

1330{
1331 char *file = "/proc/self/map";
1332 char *resolve_pattern = "/proc/self/path/%s";
1333
1334 char lastobject[PRMAPSZ];
1335 char link[PAPI_HUGE_STR_LEN];
1336 char path[PAPI_HUGE_STR_LEN];
1337
1338 prmap_t mapping;
1339
1340 int fd, count = 0, total = 0, position = -1, first = 1;
1341 vptr_t t_min, t_max, d_min, d_max;
1342
1343 PAPI_address_map_t *pam, *cur;
1344
1345#ifdef DEBUG
1346 SUBDBG( "ENTERING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1347 __LINE__ );
1348#endif
1349
1350 fd = open( file, O_RDONLY );
1351
1352 if ( fd == -1 ) {
1353 return PAPI_ESYS;
1354 }
1355
1356 memset( lastobject, 0, PRMAPSZ );
1357
1358#ifdef DEBUG
1359 SUBDBG( " -> %s: Preprocessing memory maps from procfs\n", __func__ );
1360#endif
1361
1362 /* Search through the list of mappings in order to identify a) how many
1363 mappings are available and b) how many unique mappings are available. */
1364 while ( read( fd, &mapping, sizeof ( prmap_t ) ) > 0 ) {
1365#ifdef DEBUG
1366 SUBDBG( " -> %s: Found a new memory map entry\n", __func__ );
1367#endif
1368 /* Another entry found, just the total count of entries. */
1369 total++;
1370
1371 /* Is the mapping accessible and not anonymous? */
1372 if ( mapping.pr_mflags & ( MA_READ | MA_WRITE | MA_EXEC ) &&
1373 !( mapping.pr_mflags & MA_ANON ) ) {
1374 /* Test if a new library has been found. If a new library has been
1375 found a new entry needs to be counted. */
1376 if ( strcmp( lastobject, mapping.pr_mapname ) != 0 ) {
1377 strncpy( lastobject, mapping.pr_mapname, PRMAPSZ );
1378 count++;
1379
1380#ifdef DEBUG
1381 SUBDBG( " -> %s: Memory mapping entry valid for %s\n", __func__,
1382 mapping.pr_mapname );
1383#endif
1384 }
1385 }
1386 }
1387#ifdef DEBUG
1388 SUBDBG( " -> %s: Preprocessing done, starting to analyze\n", __func__ );
1389#endif
1390
1391
1392 /* Start from the beginning, now fill in the found mappings */
1393 if ( lseek( fd, 0, SEEK_SET ) == -1 ) {
1394 return PAPI_ESYS;
1395 }
1396
1397 memset( lastobject, 0, PRMAPSZ );
1398
1399 /* Allocate memory */
1400 pam =
1402 sizeof ( PAPI_address_map_t ) );
1403
1404 while ( read( fd, &mapping, sizeof ( prmap_t ) ) > 0 ) {
1405
1406 if ( mapping.pr_mflags & MA_ANON ) {
1407#ifdef DEBUG
1408 SUBDBG
1409 ( " -> %s: Anonymous mapping (MA_ANON) found for %s, skipping\n",
1410 __func__, mapping.pr_mapname );
1411#endif
1412 continue;
1413 }
1414
1415 /* Check for a new entry */
1416 if ( strcmp( mapping.pr_mapname, lastobject ) != 0 ) {
1417#ifdef DEBUG
1418 SUBDBG( " -> %s: Analyzing mapping for %s\n", __func__,
1419 mapping.pr_mapname );
1420#endif
1421 cur = &( pam[++position] );
1422 strncpy( lastobject, mapping.pr_mapname, PRMAPSZ );
1423 snprintf( link, PAPI_HUGE_STR_LEN, resolve_pattern, lastobject );
1424 memset( path, 0, PAPI_HUGE_STR_LEN );
1425 readlink( link, path, PAPI_HUGE_STR_LEN );
1426 strncpy( cur->name, path, PAPI_HUGE_STR_LEN );
1427#ifdef DEBUG
1428 SUBDBG( " -> %s: Resolved name for %s: %s\n", __func__,
1429 mapping.pr_mapname, cur->name );
1430#endif
1431 }
1432
1433 if ( mapping.pr_mflags & MA_READ ) {
1434 /* Data (MA_WRITE) or text (MA_READ) segment? */
1435 if ( mapping.pr_mflags & MA_WRITE ) {
1436 cur->data_start = ( vptr_t ) mapping.pr_vaddr;
1437 cur->data_end =
1438 ( vptr_t ) ( mapping.pr_vaddr + mapping.pr_size );
1439
1440 if ( strcmp
1441 ( cur->name,
1444 cur->data_start;
1446 cur->data_end;
1447 }
1448
1449 if ( first )
1450 d_min = cur->data_start;
1451 if ( first )
1452 d_max = cur->data_end;
1453
1454 if ( cur->data_start < d_min ) {
1455 d_min = cur->data_start;
1456 }
1457
1458 if ( cur->data_end > d_max ) {
1459 d_max = cur->data_end;
1460 }
1461 } else if ( mapping.pr_mflags & MA_EXEC ) {
1462 cur->text_start = ( vptr_t ) mapping.pr_vaddr;
1463 cur->text_end =
1464 ( vptr_t ) ( mapping.pr_vaddr + mapping.pr_size );
1465
1466 if ( strcmp
1467 ( cur->name,
1470 cur->text_start;
1472 cur->text_end;
1473 }
1474
1475 if ( first )
1476 t_min = cur->text_start;
1477 if ( first )
1478 t_max = cur->text_end;
1479
1480 if ( cur->text_start < t_min ) {
1481 t_min = cur->text_start;
1482 }
1483
1484 if ( cur->text_end > t_max ) {
1485 t_max = cur->text_end;
1486 }
1487 }
1488 }
1489
1490 first = 0;
1491 }
1492
1493 close( fd );
1494
1495 /* During the walk of shared objects the upper and lower bound of the
1496 segments could be discovered. The bounds are stored in the PAPI info
1497 structure. The information is important for the profiling functions of
1498 PAPI. */
1499
1500/* This variant would pass the addresses of all text and data segments
1501 _papi_hwi_system_info.exe_info.address_info.text_start = t_min;
1502 _papi_hwi_system_info.exe_info.address_info.text_end = t_max;
1503 _papi_hwi_system_info.exe_info.address_info.data_start = d_min;
1504 _papi_hwi_system_info.exe_info.address_info.data_end = d_max;
1505*/
1506
1507#ifdef DEBUG
1508 SUBDBG( " -> %s: Analysis of memory maps done, results:\n", __func__ );
1509 SUBDBG( " -> %s: text_start=%#x, text_end=%#x, text_size=%lld\n", __func__,
1514 SUBDBG( " -> %s: data_start=%#x, data_end=%#x, data_size=%lld\n", __func__,
1519#endif
1520
1521 /* Store the map read and the total count of shlibs found */
1524
1525#ifdef DEBUG
1526 SUBDBG( "LEAVING FUNCTION >>%s<< at %s:%d\n", __func__, __FILE__,
1527 __LINE__ );
1528#endif
1529
1530 return PAPI_OK;
1531}
off_t lseek(int fd, off_t offset, int whence)
Definition: appio.c:214
#define PAPI_HUGE_STR_LEN
Definition: f90papi.h:120
const char FILE * file
Definition: pscanf.h:13
static int total
Definition: rapl_overflow.c:9
get the executable's address space info
Definition: papi.h:684
vptr_t text_start
Definition: papi.h:686
char name[PAPI_HUGE_STR_LEN]
Definition: papi.h:685
vptr_t text_end
Definition: papi.h:687
vptr_t data_end
Definition: papi.h:689
vptr_t data_start
Definition: papi.h:688
char fullname[PAPI_HUGE_STR_LEN]
Definition: papi.h:697
PAPI_address_map_t address_info
Definition: papi.h:698
PAPI_address_map_t * map
Definition: papi.h:703
PAPI_exe_info_t exe_info
PAPI_shlib_info_t shlib_info
Here is the call graph for this function:

Variable Documentation

◆ __int_syn_table

__int_syn_table_t __int_syn_table[]
static
Initial value:
= {
{SYNTHETIC_CYCLES_ELAPSED, "_syn_cycles_elapsed"},
{SYNTHETIC_RETURN_ONE, "_syn_return_one"},
{SYNTHETIC_RETURN_TWO, "_syn_return_two"},
{-1, NULL},
}

Definition at line 211 of file solaris-niagara2.c.

◆ 

enum { ... } __int_synthetic_enum

◆ __t2_ntv_events

char** __t2_ntv_events
static

Definition at line 108 of file solaris-niagara2.c.

◆ __t2_store

__t2_store_t __t2_store
static

Definition at line 107 of file solaris-niagara2.c.

◆ __t2_table

__t2_pst_table_t __t2_table[]
static

Definition at line 132 of file solaris-niagara2.c.

◆ _edata

vptr_t _edata

Definition at line 68 of file solaris-niagara2.c.

◆ _end

vptr_t _end

Definition at line 68 of file solaris-niagara2.c.

◆ _etext

vptr_t _etext

Definition at line 68 of file solaris-niagara2.c.

◆ _niagara2_vector

papi_vector_t _niagara2_vector

Definition at line 2227 of file solaris-niagara2.c.

◆ _papi_hwi_system_info

papi_mdi_t _papi_hwi_system_info
extern

Definition at line 56 of file papi_internal.c.

◆ _papi_os_vector

papi_os_vector_t _papi_os_vector
Initial value:
= {
.get_memory_info = _niagara2_get_memory_info,
.get_dmem_info = _solaris_get_dmem_info,
.get_real_usec = _solaris_get_real_usec,
.get_real_cycles = _solaris_get_real_cycles,
.get_virt_usec = _solaris_get_virt_usec,
.update_shlib_info = _solaris_update_shlib_info,
.get_system_info = _solaris_get_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_dmem_info(PAPI_dmem_info_t *d)
int _niagara2_get_memory_info(PAPI_hw_info_t *hw, int id)

Definition at line 2280 of file solaris-niagara2.c.

◆ _start

vptr_t _start
extern

◆ cpc

cpc_t* cpc = NULL
static

Definition at line 97 of file solaris-niagara2.c.

◆ pid

int pid
static

Definition at line 111 of file solaris-niagara2.c.

◆ preset_table

hwi_search_t* preset_table

Definition at line 191 of file solaris-niagara2.c.