<commit_before>.\" $Id$
.TH PAPI_num_counters 3 "September, 2002" "PAPI Programmer's Reference" "PAPI"

.SH NAME
PAPI_num_counters \- PAPI High Level: get the number of hardware counters available on the system

.SH SYNOPSIS
.B C Interface
.nf
.B #include <papi.h>
.BI "int\ PAPI_num_counters(void);"
.fi
.B Fortran Interface
.nf
.B #include "fpapi.h"
.BI PAPIF_num_counters(C_INT\  number )
.fi

.SH DESCRIPTION
.LP
.B 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.
.B PAPI_num_counters()
initialises the library using
.B PAPI_library_init
if necessary.

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

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

.SH EXAMPLES

.nf
.if t .ft CW
  int Events[2] = { PAPI_TOT_CYC, PAPI_TOT_INS };
  int num_hwcntrs = 0;
	
  if ((num_hwcntrs = PAPI_num_counters()) != PAPI_OK)
    handle_error(1);

  if (num_hwcntrs > 2)
    num_hwcntrs = 2;

  /* Start counting events */<commit_msg>Documentation bug in the example code. PAPI_num_counters returns a non-negative number upon success. It only returns PAPI_OK on successful completion on a system with no counters...    :)<commit_after>.\" $Id$
.TH PAPI_num_counters 3 "September, 2002" "PAPI Programmer's Reference" "PAPI"

.SH NAME
PAPI_num_counters \- PAPI High Level: get the number of hardware counters available on the system

.SH SYNOPSIS
.B C Interface
.nf
.B #include <papi.h>
.BI "int\ PAPI_num_counters(void);"
.fi
.B Fortran Interface
.nf
.B #include "fpapi.h"
.BI PAPIF_num_counters(C_INT\  number )
.fi

.SH DESCRIPTION
.LP
.B 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.
.B PAPI_num_counters()
initialises the library using
.B PAPI_library_init
if necessary.

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

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

.SH EXAMPLES

.nf
.if t .ft CW
  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.\n");

  if (num_hwcntrs > 2)
    num_hwcntrs = 2;

  /* Start counting events */
{'fraction_non_alphanumeric': 0.0901948460087995, 'fraction_numerical': 0.0069138906348208675, 'mean_word_length': 3.8595419847328243, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7122220', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1105, 'n_words': 424}