| # Gaudi Framework, version v22r0 |

Home |  | Generated: 9 Feb 2011

# perfmon.h

Go to the documentation of this file.

    00001 /*
    00002  * This file contains the user level interface description for
    00003  * the perfmon3.x interface on Linux.
    00004  *
    00005  * It also includes perfmon2.x interface definitions.
    00006  *
    00007  * Copyright (c) 2001-2006 Hewlett-Packard Development Company, L.P.
    00008  * Contributed by Stephane Eranian <eranian@hpl.hp.com>
    00009  */
    00010 #ifndef __PERFMON_H__
    00011 #define __PERFMON_H__
    00012
    00013 #include <sys/types.h>
    00014 #include <stdint.h>
    00015
    00016 #ifdef __cplusplus
    00017 extern "C" {
    00018 #endif
    00019
    00020 #ifdef __ia64__
    00021 #include <perfmon/perfmon_ia64.h>
    00022 #endif
    00023
    00024 #ifdef __x86_64__
    00025 #include <perfmon/perfmon_x86_64.h>
    00026 #endif
    00027
    00028 #ifdef __i386__
    00029 #include <perfmon/perfmon_i386.h>
    00030 #endif
    00031
    00032 #if defined(__powerpc__) || defined(__cell__)
    00033 #include <perfmon/perfmon_powerpc.h>
    00034 #endif
    00035
    00036 #ifdef __sparc__
    00037 #include <perfmon/perfmon_sparc.h>
    00038 #endif
    00039
    00040 #ifdef __mips__
    00041 #include <perfmon/perfmon_mips64.h>
    00042 #endif
    00043
    00044 #ifdef __crayx2
    00045 #include <perfmon/perfmon_crayx2.h>
    00046 #endif
    00047
    00048 #define PFM_MAX_PMCS    PFM_ARCH_MAX_PMCS
    00049 #define PFM_MAX_PMDS    PFM_ARCH_MAX_PMDS
    00050
    00051 #ifndef SWIG
    00052 /*
    00053  * number of element for each type of bitvector
    00054  */
    00055 #define PFM_BPL         (sizeof(uint64_t)<<3)
    00056 #define PFM_BVSIZE(x)   (((x)+PFM_BPL-1) / PFM_BPL)
    00057 #define PFM_PMD_BV      PFM_BVSIZE(PFM_MAX_PMDS)
    00058 #define PFM_PMC_BV      PFM_BVSIZE(PFM_MAX_PMCS)
    00059 #endif
    00060
    00061 /*
    00062  * special data type for syscall error value used to help
    00063  * with Python support and in particular for SWIG. By using
    00064  * a specific type we can detect syscalls and trap errors
    00065  * in one SWIG statement as opposed to having to keep track of
    00066  * each syscall individually. Programs can use 'int' safely for
    00067  * the return value.
    00068  */
    00069 typedef int os_err_t;                   /* error if -1 */
    00070
    00071 /*
    00072  * passed to pfm_create
    00073  * contains list of available register upon return
    00074  */
    00075 typedef struct {
    00076         uint64_t        sif_avail_pmcs[PFM_PMC_BV]; /* out: available PMCs */
    00077         uint64_t        sif_avail_pmds[PFM_PMD_BV]; /* out: available PMDs */
    00078         uint64_t        sif_reserved[4];
    00079 } pfarg_sinfo_t;
    00080
    00081 //os_err_t pfm_create(int flags, pfarg_sinfo_t *sif,
    00082 //                    char *smpl_name, void *smpl_arg, size_t arg_size);
    00083 extern os_err_t pfm_create(int flags, pfarg_sinfo_t *sif, ...);
    00084
    00085
    00086 /*
    00087  * pfm_create flags:
    00088  * bits[00-15]: generic flags
    00089  * bits[16-31]: arch-specific flags (see perfmon_const.h)
    00090  */
    00091 #define PFM_FL_NOTIFY_BLOCK     0x01 /* block task on user notifications */
    00092 #define PFM_FL_SYSTEM_WIDE      0x02 /* create a system wide context */
    00093 #define PFM_FL_SMPL_FMT         0x04 /* session uses sampling format */
    00094 #define PFM_FL_OVFL_NO_MSG      0x80 /* no overflow msgs */
    00095
    00096 /*
    00097  * PMC and PMD generic (simplified) register description
    00098  */
    00099 typedef struct {
    00100         uint16_t reg_num;       /* which register */
    00101         uint16_t reg_set;       /* which event set */
    00102         uint32_t reg_flags;     /* REGFL flags */
    00103         uint64_t reg_value;     /* 64-bit value */
    00104 } pfarg_pmr_t;
    00105
    00106 /*
    00107  * pfarg_pmr_t flags:
    00108  * bit[00-15] : generic flags
    00109  * bit[16-31] : arch-specific flags
    00110  *
    00111  * PFM_REGFL_NO_EMUL64: must be set on the PMC controlling the PMD
    00112  */
    00113 #define PFM_REGFL_OVFL_NOTIFY   0x1     /* PMD: send notification on event */
    00114 #define PFM_REGFL_RANDOM        0x2     /* PMD: randomize value after event */
    00115 #define PFM_REGFL_NO_EMUL64     0x4     /* PMC: no 64-bit emulation */
    00116
    00117 /*
    00118  * PMD extended description
    00119  * to be used with pfm_writeand pfm_read
    00120  * must be used with type = PFM_RW_PMD_ATTR
    00121  */
    00122 typedef struct {
    00123         uint16_t reg_num;               /* which register */
    00124         uint16_t reg_set;               /* which event set */
    00125         uint32_t reg_flags;             /* REGFL flags */
    00126         uint64_t reg_value;             /* 64-bit value */
    00127         uint64_t reg_long_reset;        /* write: value to reload after notification */
    00128         uint64_t reg_short_reset;       /* write: reset after counter overflow */
    00129         uint64_t reg_random_mask;       /* write: bitmask used to limit random value */
    00130         uint64_t reg_smpl_pmds[PFM_PMD_BV];  /* write: record in sample */
    00131         uint64_t reg_reset_pmds[PFM_PMD_BV]; /* write: reset on overflow */
    00132         uint64_t reg_ovfl_swcnt;        /* write: # overflows before switch */
    00133         uint64_t reg_smpl_eventid;      /* write: opaque event identifier */
    00134         uint64_t reg_last_value;        /* read: PMD last reset value */
    00135         uint64_t reg_reserved[8];       /* for future use */
    00136 } pfarg_pmd_attr_t;
    00137
    00138
    00139 /*
    00140  * pfm_write, pfm_read type:
    00141  */
    00142 #define PFM_RW_PMD      1 /* simplified PMD (pfarg_pmr_t) */
    00143 #define PFM_RW_PMC      2 /* PMC registers (pfarg_pmr_t) */
    00144 #define PFM_RW_PMD_ATTR 3 /* extended PMD (pfarg_pmd_attr) */
    00145
    00146 /*
    00147  * pfm_attach special target for detach
    00148  */
    00149 #define PFM_NO_TARGET   -1 /* no target, detach */
    00150
    00151
    00152 /*
    00153  * pfm_set_state state:
    00154  */
    00155 #define PFM_ST_START            0x1 /* start monitoring */
    00156 #define PFM_ST_STOP             0x2 /* stop monitoring */
    00157 #define PFM_ST_RESTART          0x3 /* resume after notify */
    00158
    00159 #ifndef PFMLIB_OLD_PFMV2
    00160 typedef struct {
    00161         uint16_t        set_id;           /* which set */
    00162         uint16_t        set_reserved1;    /* for future use */
    00163         uint32_t        set_flags;        /* SETFL flags */
    00164         uint64_t        set_timeout;      /* requested/effective switch timeout in nsecs */
    00165         uint64_t        reserved[6];      /* for future use */
    00166 } pfarg_set_desc_t;
    00167
    00168 typedef struct {
    00169         uint16_t        set_id;             /* which set */
    00170         uint16_t        set_reserved1;      /* for future use */
    00171         uint32_t        set_reserved2;      /* for future use */
    00172         uint64_t        set_ovfl_pmds[PFM_PMD_BV]; /* out: last ovfl PMDs */
    00173         uint64_t        set_runs;           /* out: #times set was active */
    00174         uint64_t        set_timeout;        /* out: leftover switch timeout (nsecs) */
    00175         uint64_t        set_duration;       /* out: time set was active (nsecs) */
    00176         uint64_t        set_reserved3[4];   /* for future use */
    00177 } pfarg_set_info_t;
    00178 #endif
    00179
    00180 /*
    00181  * pfm_set_desc_t flags:
    00182  */
    00183 #define PFM_SETFL_OVFL_SWITCH   0x01 /* enable switch on overflow (subject to individual switch_cnt */
    00184 #define PFM_SETFL_TIME_SWITCH   0x02 /* switch set on timeout */
    00185
    00186 #ifndef PFMLIB_OLD_PFMV2
    00187 typedef struct {
    00188         uint32_t        msg_type;               /* PFM_MSG_OVFL */
    00189         uint32_t        msg_ovfl_pid;           /* process id */
    00190         uint16_t        msg_active_set;         /* active set at the time of overflow */
    00191         uint16_t        msg_ovfl_cpu;           /* cpu on which the overflow occurred */
    00192         uint32_t        msg_ovfl_tid;           /* thread id */
    00193         uint64_t        msg_ovfl_ip;            /* instruction pointer where overflow interrupt happened */
    00194         uint64_t        msg_ovfl_pmds[PFM_PMD_BV];/* which PMDs overflowed */
    00195 } pfarg_ovfl_msg_t;
    00196
    00197 extern os_err_t pfm_write(int fd, int flags, int type, void *reg, size_t n);
    00198 extern os_err_t pfm_read(int fd, int flags, int type, void *reg, size_t n);
    00199 extern os_err_t pfm_set_state(int fd, int flags, int state);
    00200 extern os_err_t pfm_create_sets(int fd, int flags, pfarg_set_desc_t *s, size_t sz);
    00201 extern os_err_t pfm_getinfo_sets(int fd, int flags, pfarg_set_info_t *s, size_t sz);
    00202 extern os_err_t pfm_attach(int fd, int flags, int target);
    00203
    00204 #endif
    00205
    00206 #include "perfmon_v2.h"
    00207
    00208 typedef union {
    00209         uint32_t                type;
    00210         pfarg_ovfl_msg_t        pfm_ovfl_msg;
    00211 } pfarg_msg_t;
    00212
    00213 #define PFM_MSG_OVFL    1       /* an overflow happened */
    00214 #define PFM_MSG_END     2       /* thread to which context was attached ended */
    00215
    00216 #define PFM_VERSION_MAJOR(x)     (((x)>>16) & 0xffff)
    00217 #define PFM_VERSION_MINOR(x)     ((x) & 0xffff)
    00218
    00219 #ifdef __cplusplus
    00220 };
    00221 #endif
    00222
    00223 #endif /* _PERFMON_H */

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines