Skip to content

Commit 54f20d8

Browse files
Dong Jun WounDong Jun Woun
authored andcommitted
Cuda: Statistic Qualifier
1 parent 09fee01 commit 54f20d8

File tree

11 files changed

+481
-119
lines changed

11 files changed

+481
-119
lines changed

src/components/cuda/README_internal.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,44 @@ At current the Cuda component uses bits to create an Event identifier. The follo
55
# Event Identifier Encoding Format
66

77
## Unused bits
8-
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.
8+
9+
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.
10+
11+
## STAT
12+
13+
3 bits are allocated for the statistic qualifier. ([0 - 7 stats]).
914

1015
## Device
16+
1117
7 bits are allocated for the device which accounts for 128 total devices on a node (e.g. [0 - 127 devices]).
1218

1319
## Qlmask
14-
2 bits are allocated for the qualifier mask.
20+
21+
2 bits are allocated for the qualifier mask.
1522

1623
## Nameid
17-
21 bits are allocated for the nameid which will roughly account for greater than 2 million Cuda native events per device on a node.
24+
25+
18 bits are allocated for the nameid which will roughly account for greater than 260k Cuda native events per device on a node.
1826

1927
## Calculations for Bit Masks and Shifts
20-
| #DEFINE | Bits |
21-
| -------- | ------- |
22-
| EVENTS_WIDTH | `(sizeof(uint64_t) * 8)` |
23-
| DEVICE_WIDTH | `( 7)` |
24-
| QLMASK_WIDTH | `( 2)` |
25-
| NAMEID_WIDTH | `(21)` |
26-
| UNUSED_WIDTH | `(EVENTS_WIDTH - DEVICE_WIDTH - QLMASK_WIDTH - NAMEID_WIDTH)` |
27-
| DEVICE_SHIFT | `(EVENTS_WIDTH - UNUSED_WIDTH - DEVICE_WIDTH)` |
28-
| QLMASK_SHIFT | `(DEVICE_SHIFT - QLMASK_WIDTH)` |
29-
| NAMEID_SHIFT | `(QLMASK_SHIFT - NAMEID_WIDTH)` |
30-
| DEVICE_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - DEVICE_WIDTH)) << DEVICE_SHIFT)` |
31-
| QLMASK_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - QLMASK_WIDTH)) << QLMASK_SHIFT)` |
32-
| NAMEID_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - NAMEID_WIDTH)) << NAMEID_SHIFT)` |
33-
| DEVICE_FLAG | `DEVICE_FLAG (0x1)` |
3428

29+
| #DEFINE | Bits |
30+
| ------------ | -------------------------------------------------------------------------- |
31+
| EVENTS_WIDTH | `(sizeof(uint32_t) * 8)` |
32+
| STAT_WIDTH | `( 3)` |
33+
| DEVICE_WIDTH | `( 7)` |
34+
| QLMASK_WIDTH | `( 2)` |
35+
| NAMEID_WIDTH | `(18)` |
36+
| UNUSED_WIDTH | `(EVENTS_WIDTH - DEVICE_WIDTH - QLMASK_WIDTH - NAMEID_WIDTH - STAT_WIDTH)` |
37+
| STAT_SHIFT | `(EVENTS_WIDTH - UNUSED_WIDTH - STAT_WIDTH)` |
38+
| DEVICE_SHIFT | `(EVENTS_WIDTH - UNUSED_WIDTH - STAT_WIDTH - DEVICE_WIDTH)` |
39+
| QLMASK_SHIFT | `(DEVICE_SHIFT - QLMASK_WIDTH)` |
40+
| NAMEID_SHIFT | `(QLMASK_SHIFT - NAMEID_WIDTH)` |
41+
| STAT_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - STAT_WIDTH)) << STAT_SHIFT)` |
42+
| DEVICE_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - DEVICE_WIDTH)) << DEVICE_SHIFT)` |
43+
| QLMASK_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - QLMASK_WIDTH)) << QLMASK_SHIFT)` |
44+
| NAMEID_MASK | `((0xFFFFFFFFFFFFFFFF >> (EVENTS_WIDTH - NAMEID_WIDTH)) << NAMEID_SHIFT)` |
45+
| STAT_FLAG | `STAT_FLAG (0x2)` |
46+
| DEVICE_FLAG | `DEVICE_FLAG (0x1)` |
3547

3648
**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`.

src/components/cuda/cupti_dispatch.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ int cuptid_thread_info_destroy(cuptid_info_t *info)
9494
return cuptic_ctxarr_destroy((cuptic_info_t *) info);
9595
}
9696

97-
int cuptid_ctx_create(cuptid_info_t info, cuptip_control_t *pcupti_ctl, uint64_t *events_id, int num_events)
97+
int cuptid_ctx_create(cuptid_info_t info, cuptip_control_t *pcupti_ctl, uint32_t *events_id, int num_events)
9898
{
9999
if (cuptic_is_runtime_perfworks_api()) {
100100

@@ -200,7 +200,7 @@ int cuptid_ctx_destroy(cuptip_control_t *pcupti_ctl)
200200
return PAPI_ECMP;
201201
}
202202

203-
int cuptid_evt_enum(uint64_t *event_code, int modifier)
203+
int cuptid_evt_enum(uint32_t *event_code, int modifier)
204204
{
205205
if (cuptic_is_runtime_perfworks_api()) {
206206

@@ -218,7 +218,7 @@ int cuptid_evt_enum(uint64_t *event_code, int modifier)
218218
return PAPI_ECMP;
219219
}
220220

221-
int cuptid_evt_code_to_descr(uint64_t event_code, char *descr, int len)
221+
int cuptid_evt_code_to_descr(uint32_t event_code, char *descr, int len)
222222
{
223223
if (cuptic_is_runtime_perfworks_api()) {
224224

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

239-
int cuptid_evt_name_to_code(const char *name, uint64_t *event_code)
239+
int cuptid_evt_name_to_code(const char *name, uint32_t *event_code)
240240
{
241241
if (cuptic_is_runtime_perfworks_api()) {
242242

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

257-
int cuptid_evt_code_to_name(uint64_t event_code, char *name, int len)
257+
int cuptid_evt_code_to_name(uint32_t event_code, char *name, int len)
258258
{
259259
if (cuptic_is_runtime_perfworks_api()) {
260260

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

275-
int cuptid_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info)
275+
int cuptid_evt_code_to_info(uint32_t event_code, PAPI_event_info_t *info)
276276
{
277277
if (cuptic_is_runtime_perfworks_api()) {
278278

src/components/cuda/cupti_dispatch.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ int cuptid_init(void);
2323
int cuptid_shutdown(void);
2424

2525
/* native event interfaces */
26-
int cuptid_evt_enum(uint64_t *event_code, int modifier);
27-
int cuptid_evt_code_to_descr(uint64_t event_code, char *descr, int len);
28-
int cuptid_evt_name_to_code(const char *name, uint64_t *event_code);
29-
int cuptid_evt_code_to_name(uint64_t event_code, char *name, int len);
30-
int cuptid_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info);
26+
int cuptid_evt_enum(uint32_t *event_code, int modifier);
27+
int cuptid_evt_code_to_descr(uint32_t event_code, char *descr, int len);
28+
int cuptid_evt_name_to_code(const char *name, uint32_t *event_code);
29+
int cuptid_evt_code_to_name(uint32_t event_code, char *name, int len);
30+
int cuptid_evt_code_to_info(uint32_t event_code, PAPI_event_info_t *info);
3131

3232
/* profiling context handling interfaces */
33-
int cuptid_ctx_create(cuptid_info_t thread_info, cuptip_control_t *pcupti_ctl, uint64_t *events_id, int num_events);
33+
int cuptid_ctx_create(cuptid_info_t thread_info, cuptip_control_t *pcupti_ctl, uint32_t *events_id, int num_events);
3434
int cuptid_ctx_start(cuptip_control_t ctl);
3535
int cuptid_ctx_read(cuptip_control_t ctl, long long **counters);
3636
int cuptid_ctx_reset(cuptip_control_t ctl);

src/components/cuda/cupti_events.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,27 @@ int cuptie_ctx_destroy(cuptie_control_t *pctl)
5151
return PAPI_ENOIMPL;
5252
}
5353

54-
int cuptie_evt_enum(uint64_t *event_code, int modifier)
54+
int cuptie_evt_enum(uint32_t *event_code, int modifier)
5555
{
5656
return PAPI_ENOIMPL;
5757
}
5858

59-
int cuptie_evt_code_to_descr(uint64_t event_code, char *descr, int len)
59+
int cuptie_evt_code_to_descr(uint32_t event_code, char *descr, int len)
6060
{
6161
return PAPI_ENOIMPL;
6262
}
6363

64-
int cuptie_evt_name_to_code(const char *name, uint64_t *event_code)
64+
int cuptie_evt_name_to_code(const char *name, uint32_t *event_code)
6565
{
6666
return PAPI_ENOIMPL;
6767
}
6868

69-
int cuptie_evt_code_to_name(uint64_t event_code, char *name, int len)
69+
int cuptie_evt_code_to_name(uint32_t event_code, char *name, int len)
7070
{
7171
return PAPI_ENOIMPL;
7272
}
7373

74-
int cuptie_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info)
74+
int cuptie_evt_code_to_info(uint32_t event_code, PAPI_event_info_t *info)
7575
{
7676
return PAPI_ENOIMPL;
7777
}

src/components/cuda/cupti_events.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ int cuptie_init(void);
1919
int cuptie_shutdown(void);
2020

2121
/* native event interfaces */
22-
int cuptie_evt_enum(uint64_t *event_code, int modifier);
23-
int cuptie_evt_code_to_descr(uint64_t event_code, char *descr, int len);
24-
int cuptie_evt_name_to_code(const char *name, uint64_t *event_code);
25-
int cuptie_evt_code_to_name(uint64_t event_code, char *name, int len);
26-
int cuptie_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info);
22+
int cuptie_evt_enum(uint32_t *event_code, int modifier);
23+
int cuptie_evt_code_to_descr(uint32_t event_code, char *descr, int len);
24+
int cuptie_evt_name_to_code(const char *name, uint32_t *event_code);
25+
int cuptie_evt_code_to_name(uint32_t event_code, char *name, int len);
26+
int cuptie_evt_code_to_info(uint32_t event_code, PAPI_event_info_t *info);
2727

2828
/* profiling context handling interfaces */
2929
int cuptie_ctx_create(void *thr_info, cuptie_control_t *pctl);

0 commit comments

Comments
 (0)