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.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

Return values

  • PAPI_OK
  • PAPI_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_granularity
  • PAPI_set_domain
  • PAPI_set_opt
  • PAPI_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 πŸ’–