Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cuda Component Refactor #165

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
46a9cde
Initial push for Cuda component refactor.
Feb 26, 2024
5177cb6
Renaming and utilization of snprintf to have included null terminatin…
Feb 26, 2024
bb63674
Creating get_num_devices function, to collect and format the total nu…
Feb 27, 2024
31e2512
Pushing to keep track of changes, some changes of notes: added functi…
Feb 29, 2024
0b37aeb
Remove reconstruct_name function.
Mar 3, 2024
e9b98d3
Updating cuptiu_get_qualifier_name to get_parsed_evt_name, and update…
Mar 4, 2024
2fa973b
Pushing up code updates for various cuda components files/functions.
Mar 9, 2024
2f50cd4
Adding linked list implementation to collect and parse qualifiers per…
Mar 12, 2024
1d2df02
Update for Cuda component refactor to mimic Rocm refactor.
Apr 9, 2024
412efdb
Update to fix the repeated names being output from event table.
Apr 9, 2024
7ccafcc
Bug fix for hanging output and cleanup of files.
Apr 17, 2024
e3bcead
Updating cuptip_evt_code_to_info to retrieve and add description to e…
Apr 17, 2024
3a4c149
Adding documentation to cupti_profiler.c and updating linux-cuda.c to…
Apr 17, 2024
e177d58
Update Cuda component with fix to output correct metadata for a speci…
Apr 18, 2024
2ce952d
Adding device map to collect GPUs and removing the collection of units.
Apr 19, 2024
f0dc4c9
Updating event identifier encoding format to correctly shift event id's.
Apr 22, 2024
5edd824
Adding doxygen documentation for functions, updating snprintf conditi…
Apr 23, 2024
d2e8d2f
Adding more documentation and removing leftover function declarations.
Apr 23, 2024
f743fb1
Updating cupti_profiler.c to output all events even with a Numpass > 1.
Apr 24, 2024
a307adf
Fix warning of nonzero offset when building and add dummy conditional…
Apr 25, 2024
0a8b25f
Functionality for the Cuda component to work with a single type of GP…
Apr 25, 2024
ca9cc20
Adding internal readme for cuda component to show event identifier en…
Apr 30, 2024
e560785
Adding function to correctly calculate events for papi_component_avai…
Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/components/cuda/README_internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Cuda Component Native Events in PAPI

At current the Cuda component uses bits to create an Event identifier. The following internal README will be used to breakdown the encoding format.


# Event Identifier Encoding Format

## Unused bits
As of 04/30/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.

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

## 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)` |
| DEVICE_WIDTH | `( 7)` |
| 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 (0x2)` |


**NOTE**: If adding a new qualifier, you must add it to the above [Calculations for Bit Masks and Shifts](#calculations-for-bit-masks-and-shifts) section and account for this addition within `cupti_profiler.c`.
27 changes: 27 additions & 0 deletions src/components/cuda/cupti_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,30 @@ int cuptic_device_release(cuptiu_event_table_t *evt_table)
_papi_hwi_unlock(_cuda_lock);
return PAPI_OK;
}

/** @class cuptiu_dev_set
* @brief For a Cuda native event, set the device ID.
*
* @param *bitmap
* Device map.
* @param i
* Device ID.
*/
int cuptiu_dev_set(cuptiu_bitmap_t *bitmap, int i)
{
*bitmap |= (1ULL << i);
return PAPI_OK;
}

/** @class cuptiu_dev_check
* @brief For a Cuda native event, check for a valid device ID.
*
* @param *bitmap
* Device map.
* @param i
* Device ID.
*/
int cuptiu_dev_check(cuptiu_bitmap_t bitmap, int i)
{
return (bitmap & (1ULL << i));
}
4 changes: 4 additions & 0 deletions src/components/cuda/cupti_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,8 @@ int cuptic_ctxarr_destroy(cuptic_info_t *pinfo);
int cuptic_device_acquire(cuptiu_event_table_t *evt_table);
int cuptic_device_release(cuptiu_event_table_t *evt_table);

/* functions to handle device qualifiers */
int cuptiu_dev_set(cuptiu_bitmap_t *bitmap, int i);
int cuptiu_dev_check(cuptiu_bitmap_t bitmap, int i);

#endif /* __CUPTI_COMMON_H__ */
39 changes: 28 additions & 11 deletions src/components/cuda/cupti_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,42 +201,59 @@ int cuptid_control_reset(cuptid_ctl_t cupti_ctl)
return PAPI_ECMP;
}

int cuptid_event_enum(cuptiu_event_table_t *all_evt_names)
int cuptid_evt_enum(uint64_t *event_code, int modifier)
{
if (cuptic_is_runtime_perfworks_api()) {

#if defined(API_PERFWORKS)
return cuptip_event_enum(all_evt_names);
return cuptip_evt_enum(event_code, modifier);
#endif

} else if (cuptic_is_runtime_events_api()) {

#if defined(API_EVENTS)
return cuptie_event_enum(all_evt_names);
return cuptie_evt_enum(event_code, modifier);
#endif

}
return PAPI_ECMP;
}

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

#if defined(API_PERFWORKS)
return cuptip_event_name_to_descr(evt_name, descr);
return cuptip_evt_code_to_descr(event_code, descr, len);
#endif

} else if (cuptic_is_runtime_events_api()) {

}
else if (cuptic_is_runtime_events_api()) {
#if defined(API_EVENTS)
return cuptie_event_name_to_descr(evt_name, descr);
return cuptie_event_code_to_descr(event_code, descr, len);
#endif

}
return PAPI_ECMP;
}

int cuptid_evt_code_to_info(uint64_t event_code, PAPI_event_info_t *info)
{
return cuptip_evt_code_to_info(event_code, info);
}

int cuptid_evt_code_to_name(uint64_t event_code, char *name, int len)
{
return cuptip_evt_code_to_name(event_code, name, len);
}

int cuptid_evt_name_to_code(const char *name, uint64_t *event_code)
{
return cuptip_evt_name_to_code(name, event_code);
}

int cuptid_get_num_qualified_evts(int *count, uint64_t event_code)
{
return cuptip_get_num_qualified_evts(count, event_code);
}

void cuptid_event_table_destroy(ntv_event_table_t *evt_table)
{
cuptiu_event_table_destroy(evt_table);
Expand Down
9 changes: 7 additions & 2 deletions src/components/cuda/cupti_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ int cuptid_control_start(cuptid_ctl_t ctl);
int cuptid_control_stop(cuptid_ctl_t ctl);
int cuptid_control_read(cuptid_ctl_t ctl, long long *values);
int cuptid_control_reset(cuptid_ctl_t ctl);
int cuptid_event_enum(ntv_event_table_t all_evt_names);
int cuptid_event_name_to_descr(char *evt_name, char *descr);

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_code_to_info(uint64_t event_code, PAPI_event_info_t *info);
int cuptid_evt_code_to_name(uint64_t event_code, char *name, int len);
int cuptid_evt_name_to_code(const char *name, uint64_t *event_code);

void cuptid_event_table_destroy(ntv_event_table_t *evt_table);
int cuptid_event_table_create(ntv_event_table_t *evt_table);
Expand All @@ -37,4 +41,5 @@ int cuptid_event_table_find_name(ntv_event_table_t evt_table, const char *evt_na
int cuptid_event_table_insert_record(ntv_event_table_t evt_table, const char *evt_name, unsigned int evt_code, int evt_pos);
int cuptid_event_table_get_item(ntv_event_table_t evt_table, unsigned int evt_idx, ntv_event_t *record);

int cuptid_get_num_qualified_evts(int *count, uint64_t event_code);
#endif /* __CUPTI_DISPATCH_H__ */
5 changes: 2 additions & 3 deletions src/components/cuda/cupti_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ int cuptie_control_reset(cuptie_control_t ctl)
return PAPI_ENOIMPL;
}

int cuptie_event_enum(cuptiu_event_table_t *all_evt_names)
int cuptie_evt_enum(uint64_t *event_code, int modifier)
{
return PAPI_ENOIMPL;
}

int cuptie_event_name_to_descr(const char *evt_name, char *description)
{
int cuptie_event_code_to_descr(uint64_t event_code, char *descr, int len) {
return PAPI_ENOIMPL;
}

Expand Down
6 changes: 4 additions & 2 deletions src/components/cuda/cupti_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "cupti_utils.h"

#include <stdint.h>

typedef void *cuptie_control_t;

int cuptie_init(void);
Expand All @@ -18,8 +20,8 @@ int cuptie_control_start(cuptie_control_t ctl);
int cuptie_control_stop(cuptie_control_t ctl);
int cuptie_control_read(cuptie_control_t ctl, long long *values);
int cuptie_control_reset(cuptie_control_t ctl);
int cuptie_event_enum(cuptiu_event_table_t *all_evt_names);
int cuptie_event_name_to_descr(const char *evt_name, char *description);
int cuptie_evt_enum(uint64_t *event_code, int modifier);
int cuptie_event_code_to_descr(uint64_t event_code, char *descr, int len);
int cuptie_shutdown(void);

#endif /* __CUPTI_EVENTS_H__ */
Loading