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 the papi.h header file:
    • PAPI_GRN_THR β€” count each individual thread
    • PAPI_GRN_PROC β€” count each individual process
    • PAPI_GRN_PROCG β€” count each individual process group
    • PAPI_GRN_SYS β€” count the current CPU
    • PAPI_GRN_SYS_CPU β€” count all CPUs individually
    • PAPI_GRN_MIN β€” the finest available granularity
    • PAPI_GRN_MAX β€” the coarsest available granularity
  • cidx β€” an integer identifier for a component. By convention, component 0 is always the cpu component. iykyk 🧚

⭐ Return values

  • PAPI_OK
  • PAPI_EINVAL β€” one or more of the arguments is invalid. rude, but okay 😭
  • PAPI_ENOCMP β€” the argument cidx is 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_granularity
  • PAPI_set_domain
  • PAPI_set_opt
  • PAPI_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 πŸ’–