PAPI_set_cmp_granularity(3)
β¨ PAPI_set_cmp_granularity β¨
Okay bestie, buckle up β this is the PAPI_set_cmp_granularity(3) page from the PAPI manual, and it's literally about setting the default counting granularity for eventsets that get bound to a component you pick. Yes, you pick the component. It's a whole thing. Let's go π
πΈ SYNOPSIS πΈ
π Detailed Description
C Prototype:
#include <papi.h>
int PAPI_set_cmp_granularity( int granularity, int cidx );
π Parameters
granularityβ one of these constants, all defined in thepapi.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
cidxβ an integer identifier for a component. By convention, component0is always the cpu component. iykyk π§
β Return values
PAPI_OKPAPI_EINVALβ one or more of the arguments is invalid. rude, but okay πPAPI_ENOCMPβ the argumentcidxis not a valid component.
π¦ DESCRIPTION π¦
So like, PAPI_set_cmp_granularity sets the default counting granularity for all new event sets, and it requires an explicit component argument β no sneaky defaults here, bestie. π
Event sets that already exist? Not affected. They're living their life, unbothered, main character energy. β¨
If you wanna change the granularity of an existing event set, go see PAPI_set_opt. And lowkey important: the granularity of an event set affects only the mode in which the counter continues to run. That's the vibe check. π
π 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_cmp_granularity(PAPI_GRN_PROC, 0);
if (ret != PAPI_OK) handle_error(ret);
ret = PAPI_create_eventset(&EventSet);
if (ret != PAPI_OK) handle_error(ret);
π See also
PAPI_set_granularityPAPI_set_domainPAPI_set_optPAPI_get_opt
π Author
Generated automatically by Doxygen for PAPI from the source code. (Not me. I could never. π )
Alright bestie, that's the whole page β go set that granularity and slay. π«Ά
Version 7.2.0.0 πΈ Wed Jun 25 2025 19:30:49 β catch you in the next manpage, mwah π
π¦ 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