NAME

PAPI_num_counters - PAPI High Level: get the number of hardware counters available on the system

CONTENTS

Synopsis
Description
Return Values
Errors
Examples
Authors
Bugs
See Also

SYNOPSIS

C Interface

#include <papi.h> 

int PAPI_num_counters(void); 

Fortran Interface

#include fpapi.h 

PAPIF_num_counters(C_INT number) 

DESCRIPTION

PAPI_num_counters() returns the optimal length of the values array for the high level functions. This value corresponds to the number of hardware counters supported by the current substrate. PAPI_num_counters() initialises the library to PAPI_HIGH_LEVEL_INITED if necessary.

RETURN VALUES

On success, this function returns the number of hardware counters available.
On error, a negative error code is returned.

ERRORS

PAPI_EINVAL
  papi.h is different from the version used to compile the PAPI library.
PAPI_ENOMEM
  Insufficient memory to complete the operation.
PAPI_ESYS
  A system or C library call failed inside PAPI, see the errno variable.

EXAMPLES


  int Events[2] = { PAPI_TOT_CYC, PAPI_TOT_INS };
  int num_hwcntrs = 0;
        
  /*  The installation does not support PAPI */
  if ((num_hwcntrs = PAPI_num_counters()) < 0 )
    handle_error(1);

/* The installation supports PAPI, but has no counters */ if ((num_hwcntrs = PAPI_num_counters()) == 0 ) fprintf(stderr,"Info:: This machine does not provide hardware counters.0);

if (num_hwcntrs > 2) num_hwcntrs = 2;

/* Start counting events */

if (PAPI_start_counters(Events, num_hwcntrs) != PAPI_OK) handle_error(1);

AUTHORS

The PAPI Team. See them at the PAPI Web Site: http://icl.cs.utk.edu/projects/papi

BUGS

If you don’t call this function, your application could core dump.

SEE ALSO

PAPI_start_counters (3), PAPI_read_counters (3), PAPI_stop_counters (3), PAPI_init_library (3), PAPI_num_hwctrs (3), PAPI (3)


PAPI Programmer’s Reference PAPI_num_counters (3) November, 2003

  Innovative Computing Laboratory
2001 R&D Winner  
Contact PAPI: papi@cs.utk.edu Computer Science Department
  University of Tennessee