Skip to content

Commit

Permalink
Cuda: Statistic Qualifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Dong Jun Woun authored and Dong Jun Woun committed Feb 3, 2025
1 parent 09fee01 commit 3a40e1a
Show file tree
Hide file tree
Showing 11 changed files with 450 additions and 111 deletions.
44 changes: 28 additions & 16 deletions src/components/cuda/README_internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,44 @@ At current the Cuda component uses bits to create an Event identifier. The follo
# Event Identifier Encoding Format

## Unused bits
As of 09/16/24, there are a total of 34 unused bits. These bits can be used to create a new qualifier or can be used to extended the number of bits for an existing qualifier.

As of 02/02/25, there are a total of 2 unused bits. These bits can be used to create a new qualifier or can be used to extended the number of bits for an existing qualifier.

## STAT

3 bits are allocated for the statistic qualifier. ([0 - 8 stats]).

## Device

7 bits are allocated for the device which accounts for 128 total devices on a node (e.g. [0 - 127 devices]).

## Qlmask
2 bits are allocated for the qualifier mask.

2 bits are allocated for the qualifier mask.

## Nameid

21 bits are allocated for the nameid which will roughly account for greater than 2 million Cuda native events per device on a node.

## Calculations for Bit Masks and Shifts
| #DEFINE | Bits |
| -------- | ------- |
| EVENTS_WIDTH | `(sizeof(uint64_t) * 8)` |
| DEVICE_WIDTH | `( 7)` |
| QLMASK_WIDTH | `( 2)` |
| NAMEID_WIDTH | `(21)` |
| UNUSED_WIDTH | `(EVENTS_WIDTH - DEVICE_WIDTH - QLMASK_WIDTH - NAMEID_WIDTH)` |
| DEVICE_SHIFT | `(EVENTS_WIDTH - UNUSED_WIDTH - DEVICE_WIDTH)` |
| QLMASK_SHIFT | `(DEVICE_SHIFT - QLMASK_WIDTH)` |
| NAMEID_SHIFT | `(QLMASK_SHIFT - NAMEID_WIDTH)` |
| DEVICE_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - DEVICE_WIDTH)) << DEVICE_SHIFT)` |
| QLMASK_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - QLMASK_WIDTH)) << QLMASK_SHIFT)` |
| NAMEID_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - NAMEID_WIDTH)) << NAMEID_SHIFT)` |
| DEVICE_FLAG | `DEVICE_FLAG (0x1)` |

| #DEFINE | Bits |
| ------------ | -------------------------------------------------------------------------- |
| EVENTS_WIDTH | `(sizeof(uint64_t) * 8)` |
| STAT_WIDTH | `( 3)` |
| DEVICE_WIDTH | `( 7)` |
| QLMASK_WIDTH | `( 2)` |
| NAMEID_WIDTH | `(18)` |
| UNUSED_WIDTH | `(EVENTS_WIDTH - DEVICE_WIDTH - QLMASK_WIDTH - NAMEID_WIDTH - STAT_WIDTH)` |
| STAT_SHIFT | `(EVENTS_WIDTH - UNUSED_WIDTH - STAT_WIDTH)` |
| DEVICE_SHIFT | `(EVENTS_WIDTH - UNUSED_WIDTH - STAT_WIDTH - DEVICE_WIDTH)` |
| QLMASK_SHIFT | `(DEVICE_SHIFT - QLMASK_WIDTH)` |
| NAMEID_SHIFT | `(QLMASK_SHIFT - NAMEID_WIDTH)` |
| STAT_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - STAT_WIDTH)) << STAT_SHIFT)` |
| DEVICE_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - DEVICE_WIDTH)) << DEVICE_SHIFT)` |
| QLMASK_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - QLMASK_WIDTH)) << QLMASK_SHIFT)` |
| NAMEID_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - NAMEID_WIDTH)) << NAMEID_SHIFT)` |
| STAT_FLAG | `STAT_FLAG (0x2)` |
| DEVICE_FLAG | `DEVICE_FLAG (0x1)` |

**NOTE**: If adding a new qualifier, you must add it to the table found in the section titled [Calculations for Bit Masks and Shifts](#calculations-for-bit-masks-and-shifts) and account for this addition within `cupti_profiler.c`.
10 changes: 5 additions & 5 deletions src/components/cuda/cupti_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int cuptid_ctx_destroy(cuptip_control_t *pcupti_ctl)
return PAPI_ECMP;
}

int cuptid_evt_enum(uint64_t *event_code, int modifier)
int cuptid_evt_enum(uint32_t *event_code, int modifier)
{
if (cuptic_is_runtime_perfworks_api()) {

Expand All @@ -218,7 +218,7 @@ int cuptid_evt_enum(uint64_t *event_code, int modifier)
return PAPI_ECMP;
}

int cuptid_evt_code_to_descr(uint64_t event_code, char *descr, int len)
int cuptid_evt_code_to_descr(uint32_t event_code, char *descr, int len)
{
if (cuptic_is_runtime_perfworks_api()) {

Expand All @@ -236,7 +236,7 @@ int cuptid_evt_code_to_descr(uint64_t event_code, char *descr, int len)
return PAPI_ECMP;
}

int cuptid_evt_name_to_code(const char *name, uint64_t *event_code)
int cuptid_evt_name_to_code(const char *name, uint32_t *event_code)
{
if (cuptic_is_runtime_perfworks_api()) {

Expand All @@ -254,7 +254,7 @@ int cuptid_evt_name_to_code(const char *name, uint64_t *event_code)
return PAPI_ECMP;
}

int cuptid_evt_code_to_name(uint64_t event_code, char *name, int len)
int cuptid_evt_code_to_name(uint32_t event_code, char *name, int len)
{
if (cuptic_is_runtime_perfworks_api()) {

Expand All @@ -272,7 +272,7 @@ int cuptid_evt_code_to_name(uint64_t event_code, char *name, int len)
return PAPI_ECMP;
}

int cuptid_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info)
int cuptid_evt_code_to_info(uint32_t event_code, PAPI_event_info_t *info)
{
if (cuptic_is_runtime_perfworks_api()) {

Expand Down
12 changes: 6 additions & 6 deletions src/components/cuda/cupti_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ int cuptid_init(void);
int cuptid_shutdown(void);

/* native event interfaces */
int cuptid_evt_enum(uint64_t *event_code, int modifier);
int cuptid_evt_code_to_descr(uint64_t event_code, char *descr, int len);
int cuptid_evt_name_to_code(const char *name, uint64_t *event_code);
int cuptid_evt_code_to_name(uint64_t event_code, char *name, int len);
int cuptid_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info);
int cuptid_evt_enum(uint32_t *event_code, int modifier);
int cuptid_evt_code_to_descr(uint32_t event_code, char *descr, int len);
int cuptid_evt_name_to_code(const char *name, uint32_t *event_code);
int cuptid_evt_code_to_name(uint32_t event_code, char *name, int len);
int cuptid_evt_code_to_info(uint32_t event_code, PAPI_event_info_t *info);

/* profiling context handling interfaces */
int cuptid_ctx_create(cuptid_info_t thread_info, cuptip_control_t *pcupti_ctl, uint64_t *events_id, int num_events);
int cuptid_ctx_create(cuptid_info_t thread_info, cuptip_control_t *pcupti_ctl, uint64_t *papi, int num_events);
int cuptid_ctx_start(cuptip_control_t ctl);
int cuptid_ctx_read(cuptip_control_t ctl, long long **counters);
int cuptid_ctx_reset(cuptip_control_t ctl);
Expand Down
10 changes: 5 additions & 5 deletions src/components/cuda/cupti_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,27 @@ int cuptie_ctx_destroy(cuptie_control_t *pctl)
return PAPI_ENOIMPL;
}

int cuptie_evt_enum(uint64_t *event_code, int modifier)
int cuptie_evt_enum(uint32_t *event_code, int modifier)
{
return PAPI_ENOIMPL;
}

int cuptie_evt_code_to_descr(uint64_t event_code, char *descr, int len)
int cuptie_evt_code_to_descr(uint32_t event_code, char *descr, int len)
{
return PAPI_ENOIMPL;
}

int cuptie_evt_name_to_code(const char *name, uint64_t *event_code)
int cuptie_evt_name_to_code(const char *name, uint32_t *event_code)
{
return PAPI_ENOIMPL;
}

int cuptie_evt_code_to_name(uint64_t event_code, char *name, int len)
int cuptie_evt_code_to_name(uint32_t event_code, char *name, int len)
{
return PAPI_ENOIMPL;
}

int cuptie_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info)
int cuptie_evt_code_to_info(uint32_t event_code, PAPI_event_info_t *info)
{
return PAPI_ENOIMPL;
}
Expand Down
10 changes: 5 additions & 5 deletions src/components/cuda/cupti_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ int cuptie_init(void);
int cuptie_shutdown(void);

/* native event interfaces */
int cuptie_evt_enum(uint64_t *event_code, int modifier);
int cuptie_evt_code_to_descr(uint64_t event_code, char *descr, int len);
int cuptie_evt_name_to_code(const char *name, uint64_t *event_code);
int cuptie_evt_code_to_name(uint64_t event_code, char *name, int len);
int cuptie_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info);
int cuptie_evt_enum(uint32_t *event_code, int modifier);
int cuptie_evt_code_to_descr(uint32_t event_code, char *descr, int len);
int cuptie_evt_name_to_code(const char *name, uint32_t *event_code);
int cuptie_evt_code_to_name(uint32_t event_code, char *name, int len);
int cuptie_evt_code_to_info(uint32_t event_code, PAPI_event_info_t *info);

/* profiling context handling interfaces */
int cuptie_ctx_create(void *thr_info, cuptie_control_t *pctl);
Expand Down
Loading

0 comments on commit 3a40e1a

Please sign in to comment.