PAPI  5.0.1.0
freebsd.c File Reference
Include dependency graph for freebsd.c:

Go to the source code of this file.

Functions

long long _papi_freebsd_get_real_cycles (void)
int _papi_freebsd_ntv_code_to_name (unsigned int EventCode, char *ntv_name, int len)
static void show_counter (char *string, int id, char *name, const char *function, char *file, int line)
int init_mdi (void)
int init_presets (int cidx)
int _papi_freebsd_init_component (int cidx)
int _papi_freebsd_init_thread (void *ctx)
int _papi_freebsd_shutdown_thread (void *ctx)
int _papi_freebsd_shutdown_component (void)
int _papi_freebsd_init_control_state (void *ptr)
int _papi_freebsd_update_control_state (void *ptr, NativeInfo_t *native, int count, void *ctx)
int _papi_freebsd_start (void *ctx, void *ctrl)
int _papi_freebsd_read (void *ctx, void *ctrl, long long **events, int flags)
int _papi_freebsd_stop (void *ctx, void *ctrl)
int _papi_freebsd_reset (void *ctx, void *ctrl)
int _papi_freebsd_write (void *ctx, void *ctrl, long long *from)
void _papi_freebsd_dispatch_timer (int signal, void *info, void *context)
int _papi_freebsd_stop_profiling (ThreadInfo_t *master, EventSetInfo_t *ESI)
int _papi_freebsd_set_overflow (EventSetInfo_t *ESI, int EventIndex, int threshold)
int _papi_freebsd_set_profile (EventSetInfo_t *ESI, int EventIndex, int threashold)
int _papi_freebsd_set_domain (void *cntrl, int domain)
int _papi_freebsd_ctl (void *ctx, int code, _papi_int_option_t *option)
long long _papi_freebsd_get_real_usec (void)
long long _papi_freebsd_get_virt_usec (void)
int _papi_freebsd_ntv_enum_events (unsigned int *EventCode, int modifier)
int _papi_freebsd_ntv_name_to_code (char *name, unsigned int *event_code)
int _papi_freebsd_ntv_code_to_descr (unsigned int EventCode, char *descr, int len)
int _papi_freebsd_allocate_registers (EventSetInfo_t *ESI)
int _papi_freebsd_update_shlib_info (papi_mdi_t *mdi)
int _papi_freebsd_detect_hypervisor (char *virtual_vendor_name)
int _papi_freebsd_get_system_info (papi_mdi_t *mdi)
int _papi_hwi_init_os (void)

Variables

PAPI_os_info_t _papi_os_info
papi_vector_t _papi_freebsd_vector
static hwd_libpmc_context_t Context
papi_os_vector_t _papi_os_vector

Function Documentation

< No error

< Event exists, but cannot be counted due to counter resource limitations

< No error

Definition at line 808 of file freebsd.c.

{
    char name[1024];
    int failed, allocated_counters, i, j, ret;
    pmc_id_t *pmcs;

    SUBDBG("Entering\n");

    failed = 0;
    pmcs = (pmc_id_t*) malloc(sizeof(pmc_id_t)*ESI->NativeCount);
    if (pmcs != NULL)
    {
        allocated_counters = 0;
        /* Check if we can allocate all the counters needed */
        for (i = 0; i < ESI->NativeCount; i++)
        {
            ret = _papi_freebsd_ntv_code_to_name (ESI->NativeInfoArray[i].ni_event, name, sizeof(name));
            if (ret != PAPI_OK)
                return ret;
            if ( (ret = pmc_allocate (name, PMC_MODE_TC, 0, PMC_CPU_ANY, &pmcs[i])) < 0)
            {
#if defined(DEBUG)
                fprintf (stderr, "DEBUG: %s FAILED to allocate '%s' (0x%08x) [%d of %d] ERROR = %d\n", FUNC, name, ESI->NativeInfoArray[i].ni_event, i+1, ESI->NativeCount, ret);
#endif
                failed = 1;
                break;
            }
            else
            {
#if defined(DEBUG)
                fprintf (stderr, "DEBUG: %s SUCCEEDED allocating '%s' (0x%08x) [%d of %d]\n", FUNC, name, ESI->NativeInfoArray[i].ni_event, i+1, ESI->NativeCount);
#endif
                allocated_counters++;
            }
        }
        /* Free the counters */
        for (j = 0; j < allocated_counters; j++)
            pmc_release (pmcs[j]);
        free (pmcs);
    }
    else
        failed = 1;

    return failed?PAPI_ECNFLCT:PAPI_OK;
}

Here is the call graph for this function:

int _papi_freebsd_ctl ( void *  ctx,
int  code,
_papi_int_option_t option 
)

< Domain for an eventset

< Domain for all new eventsets. Takes non-NULL option pointer.

< Granularity for an eventset

< Granularity for all new eventsets

< Not supported by component

< Invalid argument

Definition at line 627 of file freebsd.c.

{
  (void)ctx;
    SUBDBG("Entering\n");
    switch (code)
    {
        case PAPI_DOMAIN:
        case PAPI_DEFDOM:
            /*return _papi_freebsd_set_domain(&option->domain.ESI->machdep, option->domain.domain);*/
            return _papi_freebsd_set_domain(option->domain.ESI->ctl_state, option->domain.domain);
        case PAPI_GRANUL:
        case PAPI_DEFGRN:
            return PAPI_ECMP;
        default:
            return PAPI_EINVAL;
   }
}

Here is the call graph for this function:

int _papi_freebsd_detect_hypervisor ( char *  virtual_vendor_name)

Definition at line 866 of file freebsd.c.

                                                           {

  int retval=0;

#if defined(__i386__)||defined(__x86_64__)
  retval=_x86_detect_hypervisor(virtual_vendor_name);
#else
  (void) virtual_vendor_name;
#endif
        
  return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void _papi_freebsd_dispatch_timer ( int  signal,
void *  info,
void *  context 
)

Definition at line 551 of file freebsd.c.

{
  (void)signal;
  (void)info;
  (void)context;
  /* Real function would call the function below with the proper args
   * _papi_hwi_dispatch_overflow_signal(...);
   */
  SUBDBG("Entering\n");
  return;
}
long long _papi_freebsd_get_real_cycles ( void  )

Definition at line 678 of file freebsd.c.

{
    /* Hey, I've seen somewhere a define called __x86_64__! Should I support it? */
#if !defined(__i386__) && !defined(__amd64__)
    SUBDBG("Entering\n");
    /* This will surely work, but with low precision and high overhead */
   return ((long long) _papi_freebsd_get_real_usec() * _papi_hwi_system_info.hw_info.cpu_max_mhz);
#else
    SUBDBG("Entering\n");
    if (Context.use_rdtsc)
    {
        long long cycles;
        __asm __volatile(".byte 0x0f, 0x31" : "=A" (cycles));
      return cycles;
    }
    else
    {
        return ((long long) _papi_freebsd_get_real_usec() * _papi_hwi_system_info.hw_info.cpu_max_mhz);
    }
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

long long _papi_freebsd_get_real_usec ( void  )

< A System/C library call failed

Definition at line 650 of file freebsd.c.

{
    /* Hey, I've seen somewhere a define called __x86_64__! Should I support it? */
#if !defined(__i386__) && !defined(__amd64__)
    /* This will surely work, but with low precision and high overhead */
    struct rusage res;

    SUBDBG("Entering\n");
    if ((getrusage(RUSAGE_SELF, &res) == -1))
        return PAPI_ESYS;
    return (res.ru_utime.tv_sec * 1000000) + res.ru_utime.tv_usec;
#else
    SUBDBG("Entering\n");
    if (Context.use_rdtsc)
    {
        return _papi_freebsd_get_real_cycles() / _papi_hwi_system_info.hw_info.cpu_max_mhz;
    }
    else
    {
        struct rusage res;
        if ((getrusage(RUSAGE_SELF, &res) == -1))
            return PAPI_ESYS;
        return (res.ru_utime.tv_sec * 1000000) + res.ru_utime.tv_usec;
    }
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

< No error

Definition at line 882 of file freebsd.c.

                                                 {

  int retval;

  retval=_freebsd_get_memory_info(&mdi->hw_info, mdi->hw_info.model );

  /* Get virtualization info */
  mdi->hw_info.virtualized=_papi_freebsd_detect_hypervisor(mdi->hw_info.virtual_vendor_string);

  
  return PAPI_OK;

}

Here is the call graph for this function:

Here is the caller graph for this function:

long long _papi_freebsd_get_virt_usec ( void  )

< A System/C library call failed

Definition at line 702 of file freebsd.c.

{
    struct rusage res;

    SUBDBG("Entering\n");

    if ((getrusage(RUSAGE_SELF, &res) == -1))
        return PAPI_ESYS;
    return (res.ru_utime.tv_sec * 1000000) + res.ru_utime.tv_usec;
}
int _papi_freebsd_init_component ( int  cidx)

Definition at line 213 of file freebsd.c.

{
   (void)cidx;

   int retval;

   SUBDBG("Entering\n");

   /* Internal function, doesn't necessarily need to be a function */
   retval=init_presets(cidx);
   
   return retval;
}

Here is the call graph for this function:

int _papi_freebsd_init_control_state ( void *  ptr)

< User context counted

< Kernel/OS context counted

< No error

Definition at line 258 of file freebsd.c.

{
    /* We will default to gather counters in USER|KERNEL mode */
    SUBDBG("Entering\n");
    ptr->hwc_domain = PAPI_DOM_USER|PAPI_DOM_KERNEL;
    ptr->pmcs = NULL;
    ptr->counters = NULL;
    ptr->n_counters = 0;
    return PAPI_OK;
}
int _papi_freebsd_init_thread ( void *  ctx)

< No error

Definition at line 233 of file freebsd.c.

{
    (void)ctx;
    SUBDBG("Entering\n");
    return PAPI_OK;
}
int _papi_freebsd_ntv_code_to_descr ( unsigned int  EventCode,
char *  descr,
int  len 
)

< Event does not exist

< Buffer size exceeded

< No error

Definition at line 784 of file freebsd.c.

{
    SUBDBG("Entering\n");
    int nidx;

    nidx = EventCode & PAPI_NATIVE_AND_MASK;
    if (nidx >= _papi_freebsd_vector.cmp_info.num_native_events) {
       return PAPI_ENOEVNT;
    }

    strncpy (descr, _papi_hwd_native_info[Context.CPUtype].info[nidx].description, len);
    if (strlen(_papi_hwd_native_info[Context.CPUtype].info[nidx].description) > (size_t)len-1) {
       return PAPI_EBUF;
    }
    return PAPI_OK;
}
int _papi_freebsd_ntv_code_to_name ( unsigned int  EventCode,
char *  ntv_name,
int  len 
)

< Event does not exist

< Buffer size exceeded

< No error

Definition at line 763 of file freebsd.c.

{
    SUBDBG("Entering\n");

    int nidx;

    nidx = EventCode & PAPI_NATIVE_AND_MASK;
    
    if (nidx >= _papi_freebsd_vector.cmp_info.num_native_events) {
       return PAPI_ENOEVNT;
    }

    strncpy (ntv_name, 
         _papi_hwd_native_info[Context.CPUtype].info[nidx].name, len);
    if (strlen(_papi_hwd_native_info[Context.CPUtype].info[nidx].name) > (size_t)len-1) {
        return PAPI_EBUF;
    }
    return PAPI_OK;
}

Here is the caller graph for this function:

int _papi_freebsd_ntv_enum_events ( unsigned int *  EventCode,
int  modifier 
)

< No error

< No error

< No error

< Event does not exist

Definition at line 718 of file freebsd.c.

{
     int res;
     char name[1024];
     unsigned int nextCode = 1 + *EventCode;

     SUBDBG("Entering\n");

     if (modifier==PAPI_ENUM_FIRST) {

       *EventCode=0;

    return PAPI_OK;
     }

     if (modifier==PAPI_ENUM_EVENTS) {

    res = _papi_freebsd_ntv_code_to_name(nextCode, name, sizeof(name));
    if (res != PAPI_OK) {
          return res;
    } else {
          *EventCode = nextCode;
    }
    return PAPI_OK;
     }

     return PAPI_ENOEVNT;

}

Here is the call graph for this function:

int _papi_freebsd_ntv_name_to_code ( char *  name,
unsigned int *  event_code 
)

< No error

< Event does not exist

Definition at line 748 of file freebsd.c.

                                                                         {

   SUBDBG("Entering\n");

   int i;

   for(i = 0; i < _papi_freebsd_vector.cmp_info.num_native_events; i++) {
      if (strcmp (name, _papi_hwd_native_info[Context.CPUtype].info[i].name) == 0) {
     *event_code = i;
     return PAPI_OK;
      }
   }
   return PAPI_ENOEVNT;
}
int _papi_freebsd_read ( void *  ctx,
void *  ctrl,
long long **  events,
int  flags 
)

< A System/C library call failed

< No error

Definition at line 390 of file freebsd.c.

{
    int i, ret;
    (void)ctx;
    (void)flags;

    SUBDBG("Entering\n");

    for (i = 0; i < ctrl->n_counters; i++)
        if ((ret = pmc_read (ctrl->pmcs[i], &(ctrl->values[i]))) < 0)
        {
#if defined(DEBUG)
            fprintf (stderr, "DEBUG: %s FAILED to read '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
            return PAPI_ESYS;
        }
    *events = (long long *)ctrl->values;

#if defined(DEBUG)
    for (i = 0; i < ctrl->n_counters; i++)
        fprintf (stderr, "DEBUG: %s counter '%s' has value %lld\n", 
             FUNC, ctrl->counters[i], (long long)ctrl->values[i]);
#endif
    return PAPI_OK;
}
int _papi_freebsd_reset ( void *  ctx,
void *  ctrl 
)

< A System/C library call failed

< A System/C library call failed

< A System/C library call failed

< Not supported by component

< No error

Definition at line 444 of file freebsd.c.

{
    int i, ret;
    (void)ctx;

    SUBDBG("Entering\n");

    for (i = 0; i < ctrl->n_counters; i++)
    {
        /* Can we write on the counters? */
        if (ctrl->caps[i] & PMC_CAP_WRITE)
        {
            show_counter("DEBUG: _papi_freebsd_reset is about "
                     "to stop the counter i+1",
                     ctrl->pmcs[i],ctrl->counters[i],
                     __FUNCTION__,__FILE__,__LINE__);

            if ((ret = pmc_stop (ctrl->pmcs[i])) < 0)
            {
#if defined(DEBUG)
                fprintf (stderr, "DEBUG: %s FAILED to stop '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
                return PAPI_ESYS;
            }

            show_counter(
                     "DEBUG: _papi_freebsd_reset is about "
                     "to write the counter i+1\n",
                     ctrl->pmcs[i],ctrl->counters[i],
                     __FUNCTION__,__FILE__,__LINE__);

            if ((ret = pmc_write (ctrl->pmcs[i], 0)) < 0)
            {
#if defined(DEBUG)
                fprintf (stderr, "DEBUG: %s FAILED to write '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
                return PAPI_ESYS;
            }

            show_counter("DEBUG: _papi_freebsd_reset is about to "
                     "start the counter %i+1",
                     ctrl->pmcs[i],ctrl->counters[i],
                     __FUNCTION__,__FILE__,__LINE__);

            if ((ret = pmc_start (ctrl->pmcs[i])) < 0)
            {
#if defined(DEBUG)
                fprintf (stderr, "DEBUG: %s FAILED to start '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
                return PAPI_ESYS;
            }

            show_counter("DEBUG: _papi_freebsd_reset after "
                     "starting the counter i+1",
                     ctrl->pmcs[i],ctrl->counters[i],
                     __FUNCTION__,__FILE__,__LINE__);

        }
        else
            return PAPI_ECMP;
    }
    return PAPI_OK;
}

Here is the call graph for this function:

int _papi_freebsd_set_domain ( void *  cntrl,
int  domain 
)

< User context counted

< Kernel/OS context counted

< User context counted

< Kernel/OS context counted

< No error

< Invalid argument

< Not supported by component

Definition at line 603 of file freebsd.c.

{
  int found = 0;

    SUBDBG("Entering\n");
    /* libpmc supports USER/KERNEL mode only when counters are native */
    if (Context.CPUtype != CPU_UNKNOWN)
    {
        if (domain & (PAPI_DOM_USER|PAPI_DOM_KERNEL))
        {
            cntrl->hwc_domain = domain & (PAPI_DOM_USER|PAPI_DOM_KERNEL);
            found = 1;
        }
        return found?PAPI_OK:PAPI_EINVAL;
    }
    else
        return PAPI_ECMP;
}

Here is the caller graph for this function:

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

< No error

Definition at line 571 of file freebsd.c.

{
  (void)ESI;
  (void)EventIndex;
  (void)threshold;
    SUBDBG("Entering\n");
  return PAPI_OK;
}
int _papi_freebsd_set_profile ( EventSetInfo_t ESI,
int  EventIndex,
int  threashold 
)

< No error

Definition at line 580 of file freebsd.c.

{
  (void)ESI;
  (void)EventIndex;
  (void)threashold;
    SUBDBG("Entering\n");
  return PAPI_OK;
}

< No error

Definition at line 247 of file freebsd.c.

{
    SUBDBG("Entering\n");
    return PAPI_OK;
}
int _papi_freebsd_shutdown_thread ( void *  ctx)

< No error

Definition at line 240 of file freebsd.c.

{
  (void)ctx;
    SUBDBG("Entering\n");
    return PAPI_OK;
}
int _papi_freebsd_start ( void *  ctx,
void *  ctrl 
)

< A System/C library call failed

< A System/C library call failed

< No error

Definition at line 352 of file freebsd.c.

{
    int i, ret;
    (void)ctx;

    SUBDBG("Entering\n");

    for (i = 0; i < ctrl->n_counters; i++)
    {
        if ((ret = pmc_allocate (ctrl->counters[i], PMC_MODE_TC, 0, PMC_CPU_ANY, &(ctrl->pmcs[i]))) < 0)
        {
#if defined(DEBUG)
            /* This shouldn't happen, it's tested previously on _papi_freebsd_allocate_registers */
            fprintf (stderr, "DEBUG: %s FAILED to allocate '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
            return PAPI_ESYS;
        }
        if ((ret = pmc_capabilities (ctrl->pmcs[i],&(ctrl->caps[i]))) < 0)
        {
#if defined(DEBUG)
            fprintf (stderr, "DEBUG: %s FAILED to get capabilites for '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
            ctrl->caps[i] = 0;
        }
#if defined(DEBUG)
        fprintf (stderr, "DEBUG: %s got counter '%s' is %swrittable! [%d of %d]\n", FUNC, ctrl->counters[i], (ctrl->caps[i]&PMC_CAP_WRITE)?"":"NOT", i+1, ctrl->n_counters);
#endif
        if ((ret = pmc_start (ctrl->pmcs[i])) < 0)
        {
#if defined(DEBUG)
            fprintf (stderr, "DEBUG: %s FAILED to start '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
            return PAPI_ESYS;
        }
    }
    return PAPI_OK;
}
int _papi_freebsd_stop ( void *  ctx,
void *  ctrl 
)

< A System/C library call failed

< A System/C library call failed

< No error

Definition at line 416 of file freebsd.c.

{
    int i, ret;
    (void)ctx;

    SUBDBG("Entering\n");

    for (i = 0; i < ctrl->n_counters; i++)
    {
        if ((ret = pmc_stop (ctrl->pmcs[i])) < 0)
        {
#if defined(DEBUG)
            fprintf (stderr, "DEBUG: %s FAILED to stop '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
            return PAPI_ESYS;
        }
        if ((ret = pmc_release (ctrl->pmcs[i])) < 0)
        {
#if defined(DEBUG)
            /* This shouldn't happen, it's tested previously on _papi_freebsd_allocate_registers */
            fprintf (stderr, "DEBUG: %s FAILED to release '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
            return PAPI_ESYS;
        }
    }
    return PAPI_OK;
}

< No error

Definition at line 563 of file freebsd.c.

{
  (void)master;
  (void)ESI;
    SUBDBG("Entering\n");
  return PAPI_OK;
}
int _papi_freebsd_update_control_state ( void *  ptr,
NativeInfo_t native,
int  count,
void *  ctx 
)

< No error

< User context counted

< Kernel/OS context counted

< A System/C library call failed

< User context counted

< A System/C library call failed

< A System/C library call failed

< A System/C library call failed

< No error

Definition at line 269 of file freebsd.c.

{
    char name[1024];
    int i;
    int res;
    (void)ctx;

    SUBDBG("Entering\n");

    /* We're going to store which counters are being used in this EventSet.
       As this ptr structure can be reused within many PAPI_add_event calls,
       and domain can change we will reconstruct the table of counters
       (ptr->counters) everytime where here.
    */
    if (ptr->counters != NULL && ptr->n_counters > 0)
    {
        for (i = 0; i < ptr->n_counters; i++)
            if (ptr->counters[i] != NULL)
                free (ptr->counters[i]);
        free (ptr->counters);
    }
    if (ptr->pmcs != NULL)
        free (ptr->pmcs);
    if (ptr->values != NULL)
        free (ptr->values);
    if (ptr->caps != NULL)
        free (ptr->caps);

    ptr->n_counters = count;
    ptr->pmcs = (pmc_id_t*) malloc (sizeof(pmc_id_t)*count);
    ptr->caps = (uint32_t*) malloc (sizeof(uint32_t)*count);
    ptr->values = (pmc_value_t*) malloc (sizeof(pmc_value_t)*count);
    ptr->counters = (char **) malloc (sizeof(char*)*count);
    for (i = 0; i < count; i++)
        ptr->counters[i] = NULL;

    for (i = 0; i < count; i++)
    {
        res = _papi_freebsd_ntv_code_to_name (native[i].ni_event, name, sizeof(name));
        if (res != PAPI_OK)
            return res;

        native[i].ni_position = i;

        /* Domains can be applied to canonical events in libpmc (not "generic") */
        if (Context.CPUtype != CPU_UNKNOWN)
        {
            if (ptr->hwc_domain == (PAPI_DOM_USER|PAPI_DOM_KERNEL))
            {
                /* PMC defaults domain to OS & User. So simply copy the name of the counter */
                ptr->counters[i] = strdup (name);
                if (ptr->counters[i] == NULL)
                    return PAPI_ESYS;
            }
            else if (ptr->hwc_domain == PAPI_DOM_USER)
            {
                /* This is user-domain case. Just add unitmask=usr */
                ptr->counters[i] = malloc ((strlen(name)+strlen(",usr")+1)*sizeof(char));
                if (ptr->counters[i] == NULL)
                    return PAPI_ESYS;
                sprintf (ptr->counters[i], "%s,usr", name);
            }
            else /* if (ptr->hwc_domain == PAPI_DOM_KERNEL) */
            {
                /* This is the last case. Just add unitmask=os */
                ptr->counters[i] = malloc ((strlen(name)+strlen(",os")+1)*sizeof(char));
                if (ptr->counters[i] == NULL)
                    return PAPI_ESYS;
                sprintf (ptr->counters[i], "%s,os", name);
            }
        }
        else
        {
            /* PMC defaults domain to OS & User. So simply copy the name of the counter */
            ptr->counters[i] = strdup (name);
            if (ptr->counters[i] == NULL)
                return PAPI_ESYS;
        }
    }

    return PAPI_OK;
}

Here is the call graph for this function:

< No error

Definition at line 857 of file freebsd.c.

                                                    {
    SUBDBG("Entering\n");
    (void)mdi;
  return PAPI_OK;
}
int _papi_freebsd_write ( void *  ctx,
void *  ctrl,
long long *  from 
)

< A System/C library call failed

< A System/C library call failed

< A System/C library call failed

< Not supported by component

< No error

Definition at line 508 of file freebsd.c.

{
    int i, ret;
    (void)ctx;

    SUBDBG("Entering\n");

    for (i = 0; i < ctrl->n_counters; i++)
    {
        /* Can we write on the counters? */
        if (ctrl->caps[i] & PMC_CAP_WRITE)
        {
            if ((ret = pmc_stop (ctrl->pmcs[i])) < 0)
            {
#if defined(DEBUG)
                fprintf (stderr, "DEBUG: %s FAILED to stop '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
                return PAPI_ESYS;
            }
            if ((ret = pmc_write (ctrl->pmcs[i], from[i])) < 0)
            {
#if defined(DEBUG)
                fprintf (stderr, "DEBUG: %s FAILED to write '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
                return PAPI_ESYS;
            }
            if ((ret = pmc_start (ctrl->pmcs[i])) < 0)
            {
#if defined(DEBUG)
                fprintf (stderr, "DEBUG: %s FAILED to stop '%s' [%d of %d] ERROR = %d\n", FUNC, ctrl->counters[i], i+1, ctrl->n_counters, ret);
#endif
                return PAPI_ESYS;
            }
        }
        else
            return PAPI_ECMP;
    }
    return PAPI_OK;
}
int _papi_hwi_init_os ( void  )

< No error

Definition at line 897 of file freebsd.c.

                        {

   struct utsname uname_buffer;

   /* Internal function, doesn't necessarily need to be a function */
   init_mdi();

   uname(&uname_buffer);

   strncpy(_papi_os_info.name,uname_buffer.sysname,PAPI_MAX_STR_LEN);

   strncpy(_papi_os_info.version,uname_buffer.release,PAPI_MAX_STR_LEN);

   _papi_os_info.itimer_sig = PAPI_INT_MPX_SIGNAL;
   _papi_os_info.itimer_num = PAPI_INT_ITIMER;
   _papi_os_info.itimer_ns = PAPI_INT_MPX_DEF_US * 1000;    /* Not actually supported */
   _papi_os_info.itimer_res_ns = 1;

   _papi_freebsd_get_system_info(&_papi_hwi_system_info);

   return PAPI_OK;
}

Here is the call graph for this function:

int init_mdi ( void  )

< A System/C library call failed

< A System/C library call failed

< A System/C library call failed

< A System/C library call failed

< A System/C library call failed

< A System/C library call failed

< A System/C library call failed

Definition at line 76 of file freebsd.c.

{
    const struct pmc_cpuinfo *info;
   
    SUBDBG("Entering\n");

    /* Initialize PMC library */
    if (pmc_init() < 0)
        return PAPI_ESYS;
      
    if (pmc_cpuinfo (&info) != 0)
        return PAPI_ESYS;
   
    if (info != NULL)
    {
        /* Get CPU clock rate from HW.CLOCKRATE sysctl value, and
           MODEL from HW.MODEL */
        int mib[5];
        size_t len;
        int hw_clockrate;
        char hw_model[PAPI_MAX_STR_LEN];
     
#if !defined(__i386__) && !defined(__amd64__)
        Context.use_rdtsc = FALSE;
#else
        /* Ok, I386s/AMD64s can use RDTSC. But be careful, if the cpufreq
           module is loaded, then CPU frequency can vary and this method
           does not work properly! We'll use use_rdtsc to know if this
           method is available */
        len = 5; 
        Context.use_rdtsc = sysctlnametomib ("dev.cpufreq.0.%driver", mib, &len) == -1;
#endif

        len = 3;
        if (sysctlnametomib ("hw.clockrate", mib, &len) == -1)
            return PAPI_ESYS;
        len = sizeof(hw_clockrate);
        if (sysctl (mib, 2, &hw_clockrate, &len, NULL, 0) == -1)
            return PAPI_ESYS;

        len = 3;
        if (sysctlnametomib ("hw.model", mib, &len) == -1)
            return PAPI_ESYS;
        len = PAPI_MAX_STR_LEN;
        if (sysctl (mib, 2, &hw_model, &len, NULL, 0) == -1)
            return PAPI_ESYS;
        
        /*strcpy (_papi_hwi_system_info.hw_info.vendor_string, pmc_name_of_cputype(info->pm_cputype));*/
        sprintf (_papi_hwi_system_info.hw_info.vendor_string, "%s (TSC:%c)", pmc_name_of_cputype(info->pm_cputype), Context.use_rdtsc?'Y':'N');
        strcpy (_papi_hwi_system_info.hw_info.model_string, hw_model);
        _papi_hwi_system_info.hw_info.mhz = (float) hw_clockrate;
        _papi_hwi_system_info.hw_info.cpu_max_mhz = hw_clockrate;
        _papi_hwi_system_info.hw_info.cpu_min_mhz = hw_clockrate;
        _papi_hwi_system_info.hw_info.ncpu = info->pm_ncpu;
        _papi_hwi_system_info.hw_info.nnodes = 1;
        _papi_hwi_system_info.hw_info.totalcpus = info->pm_ncpu;
        /* Right now, PMC states that TSC is an additional counter. However
           it's only available as a system-wide counter and this requires
           root access */
        _papi_freebsd_vector.cmp_info.num_cntrs = info->pm_npmc - 1;

        if ( strstr(pmc_name_of_cputype(info->pm_cputype), "INTEL"))
          _papi_hwi_system_info.hw_info.vendor = PAPI_VENDOR_INTEL;
        else if ( strstr(pmc_name_of_cputype(info->pm_cputype), "AMD"))
          _papi_hwi_system_info.hw_info.vendor = PAPI_VENDOR_AMD;
        else
          fprintf(stderr,"We didn't actually find a supported vendor...\n\n\n");
        }
        else
            return PAPI_ESYS;

    return 1;
}

Here is the caller graph for this function:

int init_presets ( int  cidx)

< A System/C library call failed

Definition at line 151 of file freebsd.c.

{
    const struct pmc_cpuinfo *info;

    SUBDBG("Entering\n");

    if (pmc_cpuinfo (&info) != 0)
        return PAPI_ESYS;

    init_freebsd_libpmc_mappings();

    if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_P6") == 0)
        Context.CPUtype = CPU_P6;

    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_PII") == 0)
        Context.CPUtype = CPU_P6_2;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_PIII") == 0)
        Context.CPUtype = CPU_P6_3;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_CL") == 0)
        Context.CPUtype = CPU_P6_C;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_PM") == 0)
        Context.CPUtype = CPU_P6_M;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "AMD_K7") == 0)
        Context.CPUtype = CPU_K7;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "AMD_K8") == 0)
        Context.CPUtype = CPU_K8;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_PIV") == 0)
        Context.CPUtype = CPU_P4;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_ATOM") == 0)
        Context.CPUtype = CPU_ATOM;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_CORE") == 0)
        Context.CPUtype = CPU_CORE;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_CORE2") == 0)
        Context.CPUtype = CPU_CORE2;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_CORE2EXTREME") == 0)
        Context.CPUtype = CPU_CORE2EXTREME;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_COREI7") == 0)
        Context.CPUtype = CPU_COREI7;
    else if (strcmp(pmc_name_of_cputype(info->pm_cputype), "INTEL_WESTMERE") == 0)
        Context.CPUtype = CPU_COREWESTMERE;
    else
        /* Unknown processor! */
        Context.CPUtype = CPU_UNKNOWN;


    _papi_freebsd_vector.cmp_info.num_native_events = freebsd_number_of_events (Context.CPUtype);
    _papi_freebsd_vector.cmp_info.attach = 0;

    _papi_load_preset_table((char *)pmc_name_of_cputype(info->pm_cputype),
                0,cidx);

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void show_counter ( char *  string,
int  id,
char *  name,
const char *  function,
char *  file,
int  line 
) [static]

Definition at line 40 of file freebsd.c.

                                                         {

#if defined(DEBUG)
     pmc_value_t tmp_value;
     int ret = pmc_read (id, &tmp_value);
     
     fprintf(stderr,"%s\n",string);
     if (ret < 0) {
    fprintf (stderr, "DEBUG: Unable to read counter %s (ID: %08x) "
                         "on routine %s (file: %s, line: %d)\n", 
                 name, id, function,file,line);
     } else {
    fprintf (stderr, "DEBUG: Read counter %s (ID: %08x) - "
                 "value %llu on routine %s (file: %s, line: %d)\n", 
                 name, id, (long long unsigned int)tmp_value, 
                 function, file, line);
     }
#else
     (void) string; (void)name; 
     (void)id; (void)function; (void)file; (void)line;
#endif
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 33 of file freebsd.c.

Definition at line 30 of file freebsd.c.

Initial value:
 {
  .get_dmem_info    = _papi_freebsd_get_dmem_info,
  .get_real_cycles  = _papi_freebsd_get_real_cycles,
  .get_real_usec    = _papi_freebsd_get_real_usec,
  .get_virt_usec    = _papi_freebsd_get_virt_usec,
  .update_shlib_info    = _papi_freebsd_update_shlib_info,
  .get_system_info  = _papi_freebsd_get_system_info,
}

Definition at line 976 of file freebsd.c.

Definition at line 65 of file freebsd.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines