-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[offload][ompt] Added lookup function for device callbacks #110007
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,14 +27,77 @@ | |
#undef DEBUG_PREFIX | ||
#define DEBUG_PREFIX "OMPT" | ||
|
||
using namespace llvm::omp::target::ompt; | ||
|
||
// Define OMPT callback functions (bound to actual callbacks later on) | ||
#define defineOmptCallback(Name, Type, Code) \ | ||
Name##_t llvm::omp::target::ompt::Name##_fn = nullptr; | ||
FOREACH_OMPT_NOEMI_EVENT(defineOmptCallback) | ||
FOREACH_OMPT_EMI_EVENT(defineOmptCallback) | ||
#undef defineOmptCallback | ||
|
||
using namespace llvm::omp::target::ompt; | ||
int ompt_get_device_num_procs(ompt_device_t *device) { return 0; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. format There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to clang-format this seems to be fine |
||
|
||
ompt_device_time_t ompt_get_device_time(ompt_device_t *device) { return 0; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use |
||
|
||
double ompt_translate_time(ompt_device_t *device, ompt_device_time_t time) { | ||
return 0; | ||
} | ||
|
||
ompt_set_result_t ompt_set_trace_ompt(ompt_device_t *device, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Downstream example (among others): |
||
unsigned int enable, unsigned int etype) { | ||
return ompt_set_error; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would not choose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
ompt_set_result_t ompt_set_trace_native(ompt_device_t *device, int enable, | ||
int flags) { | ||
return ompt_set_error; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as |
||
} | ||
|
||
int ompt_start_trace(ompt_device_t *device, | ||
ompt_callback_buffer_request_t request, | ||
ompt_callback_buffer_complete_t complete) { | ||
return 0; | ||
} | ||
|
||
int ompt_pause_trace(ompt_device_t *device, int begin_pause) { return 0; } | ||
|
||
int ompt_flush_trace(ompt_device_t *device) { return 0; } | ||
|
||
int ompt_stop_trace(ompt_device_t *device) { return 0; } | ||
|
||
int ompt_advance_buffer_cursor(ompt_device_t *device, ompt_buffer_t *buffer, | ||
size_t size, ompt_buffer_cursor_t current, | ||
ompt_buffer_cursor_t *next) { | ||
return 0; | ||
} | ||
|
||
ompt_record_t ompt_get_record_type(ompt_buffer_t *buffer, | ||
ompt_buffer_cursor_t current) { | ||
return ompt_record_ompt; | ||
} | ||
|
||
void *ompt_get_record_native(ompt_buffer_t *buffer, | ||
ompt_buffer_cursor_t current, | ||
ompt_id_t *host_op_id) { | ||
return NULL; | ||
} | ||
|
||
ompt_record_abstract_t *ompt_get_record_abstract(void *native_record) { | ||
return NULL; | ||
} | ||
|
||
ompt_interface_fn_t | ||
llvm::omp::target::ompt::ompt_device_fn_lookup(const char *s) { | ||
#define ompt_interface_fn(fn) \ | ||
if (strcmp(s, #fn) == 0) { \ | ||
fn##_t fn##_f = fn; \ | ||
return (ompt_interface_fn_t)fn##_f; \ | ||
} | ||
FOREACH_OMPT_DEVICE_INQUIRY_FN(ompt_interface_fn) | ||
#undef ompt_interface_fn | ||
return NULL; | ||
} | ||
|
||
/// Forward declaration | ||
class LibomptargetRtlFinalizer; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,23 @@ | |
macro(ompt_get_target_info) \ | ||
macro(ompt_get_num_devices) | ||
|
||
#define FOREACH_OMPT_DEVICE_INQUIRY_FN(macro) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. format There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, clang-format does not format this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can call it manually, but it might change a lot of unrelated stuff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can push a NFC first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Downstream examples (e.g. here I like this location way better): |
||
macro (ompt_get_device_num_procs) \ | ||
macro (ompt_get_device_time) \ | ||
macro (ompt_translate_time) \ | ||
macro (ompt_set_trace_ompt) \ | ||
macro (ompt_set_trace_native) \ | ||
/* macro (ompt_get_buffer_limits) */ \ | ||
macro (ompt_start_trace) \ | ||
macro (ompt_pause_trace) \ | ||
macro (ompt_flush_trace) \ | ||
macro (ompt_stop_trace) \ | ||
macro (ompt_advance_buffer_cursor) \ | ||
macro (ompt_get_record_type) \ | ||
/* macro (ompt_get_record_ompt) */ \ | ||
macro (ompt_get_record_native) \ | ||
macro (ompt_get_record_abstract) | ||
|
||
#define FOREACH_OMPT_STATE(macro) \ | ||
\ | ||
/* first available state */ \ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Downstream examples:
https://github.com/ROCm/llvm-project/blob/amd-staging/offload/plugins-nextgen/common/src/PluginInterface.cpp#L957
https://github.com/ROCm/llvm-project/blob/amd-staging/offload/plugins-nextgen/common/OMPT/OmptTracing.cpp#L298-L310