PAPI_set_granularity(3)
π PAPI_set_granularity(3) π
okay bestie, welcome to the PAPI manual π
this page is for PAPI_set_granularity, and it is literally giving βset the default counting granularity for eventsets bound to the cpu component.β No cap. π
β¨ NAME β¨
PAPI_set_granularity β Set the default counting granularity for eventsets bound to the cpu component. π¦
β¨ SYNOPSIS β¨
Detailed Description
C Prototype:
#include <papi.h>
int PAPI_set_granularity( int granularity );
Parameters
- granularity β one of the following constants as defined in the
papi.hheader file:PAPI_GRN_THRβ Count each individual threadPAPI_GRN_PROCβ Count each individual processPAPI_GRN_PROCGβ Count each individual process groupPAPI_GRN_SYSβ Count the current CPUPAPI_GRN_SYS_CPUβ Count all CPUs individuallyPAPI_GRN_MINβ The finest available granularityPAPI_GRN_MAXβ The coarsest available granularity
Return values
PAPI_OKPAPI_EINVALβ One or more of the arguments is invalid.
So hereβs the tea β: PAPI_set_granularity sets the default counting granularity for all new event sets created by PAPI_create_eventset. This call implicitly sets the granularity for the cpu component (component 0), and itβs included to preserve backward compatibility. That part is important, bestie β donβt skip it. π
Example:
int ret;
// Initialize the library
ret = PAPI_library_init(PAPI_VER_CURRENT);
if (ret > 0 && ret != PAPI_VER_CURRENT) {
fprintf(stderr,"PAPI library version mismatch!\n");
exit(1);
}
if (ret < 0) handle_error(ret);
// Set the default granularity for the cpu component
ret = PAPI_set_granularity(PAPI_GRN_PROC);
if (ret != PAPI_OK) handle_error(ret);
ret = PAPI_create_eventset(&EventSet);
if (ret != PAPI_OK) handle_error(ret);
π See also π
the page says see also:
PAPI_set_cmp_granularityPAPI_set_domainPAPI_set_optPAPI_get_opt
π Author π
Author: Generated automatically by Doxygen for PAPI from the source code. π€β¨
okay thatβs the whole page, bestie β this footer is giving Version 7.2.0.0, dated Wed Jun 25 2025 19:30:49. bye π
π¦ where this page comes from
- nixos 26.05: papi 7.2.0
- nixpkgs unstable: papi 7.2.0
- opensuse-leap 16.0: papi-devel 7.2.0-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: papi-devel 7.2.0-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: papi-devel 7.2.0-160000.2.2 Β· BSD-3-Clause
- ubuntu resolute: libpapi-dev 7.2.0-2 Β· BSD-3-Clause
- ubuntu stonking: libpapi-dev 7.2.0-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms