---
name: "PAPI_state"
section: "3"
platform: "linux"
package: "libpapi-dev"
version: "7.1.0-5+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/PAPI_state"
---

# PAPI\_state(3)

Return the counting state of an EventSet.

## NAME

PAPI\_state - Return the counting state of an EventSet.

## SYNOPSIS

## Detailed Description

**C Interface:**

\#include \<**papi.h**\> \
\
  int **PAPI\_state( int  EventSet, int \* status )**;

**Parameters**

*EventSet* -- an integer handle for a PAPI event set as created by **PAPI\_create\_eventset** \
 *status* -- an integer containing a boolean combination of one or more of the following nonzero constants as defined in the PAPI header file **papi.h**:

- •

  PAPI\_STOPPED -- EventSet is stopped

- •

  PAPI\_RUNNING -- EventSet is running

- •

  PAPI\_PAUSED -- EventSet temporarily disabled by the library

- •

  PAPI\_NOT\_INIT -- EventSet defined, but not initialized

- •

  PAPI\_OVERFLOWING -- EventSet has overflowing enabled

- •

  PAPI\_PROFILING -- EventSet has profiling enabled

- •

  PAPI\_MULTIPLEXING -- EventSet has multiplexing enabled

- •

  PAPI\_ACCUMULATING -- reserved for future use

- •

  PAPI\_HWPROFILING -- reserved for future use

**Return values**

*PAPI\_OK* \
 *PAPI\_EINVAL* One or more of the arguments is invalid. \
 *PAPI\_ENOEVST* The EventSet specified does not exist.

**PAPI\_state()** returns the counting state of the specified event set.

**Example:**

```
int EventSet = PAPI_NULL;
int status = 0;
int ret;
ret = PAPI_create_eventset(&EventSet);
if (ret != PAPI_OK) handle_error(ret);
// Add Total Instructions Executed to our EventSet
ret = PAPI_add_event(EventSet, PAPI_TOT_INS);
if (ret != PAPI_OK) handle_error(ret);
// Start counting
ret = PAPI_state(EventSet, &status);
if (ret != PAPI_OK) handle_error(ret);
printf("State is now %d\n",status);
ret = PAPI_start(EventSet);
if (ret != PAPI_OK) handle_error(ret);
ret = PAPI_state(EventSet, &status);
if (ret != PAPI_OK) handle_error(ret);
printf("State is now %d\n",status);
```

**See also**

**PAPI\_stop** **PAPI\_start**

## Author

Generated automatically by Doxygen for PAPI from the source code.
