[Openmp-commits] [openmp] [OpenMP][OMPT] Add ompt_set_frame_enter support to libomptarget (PR #201127)
Jan Patrick Lehr via Openmp-commits
openmp-commits at lists.llvm.org
Tue Jun 2 12:54:31 PDT 2026
https://github.com/jplehr updated https://github.com/llvm/llvm-project/pull/201127
>From 05ea3ab4a2fd4ca00ff1988cc08b2120dfc9af3d Mon Sep 17 00:00:00 2001
From: JP Lehr <JanPatrick.Lehr at amd.com>
Date: Mon, 13 Apr 2026 07:54:04 -0500
Subject: [PATCH] [OpenMP][OMPT] Add ompt_set_frame_enter support to
libomptarget
The first patch to upstream OMPT device traincg for OpenMP offloading.
Used to store the host task frame of the offloading context.
Port of the AMD downstream implementation.
AI assisted.
---
openmp/runtime/src/ompt-general.cpp | 5 +++++
openmp/runtime/src/ompt-internal.h | 6 ++++++
openmp/runtime/src/ompt-specific.cpp | 15 +++++++++++++++
openmp/runtime/src/ompt-specific.h | 2 ++
4 files changed, 28 insertions(+)
diff --git a/openmp/runtime/src/ompt-general.cpp b/openmp/runtime/src/ompt-general.cpp
index 959457d380d03..ab0944592bb92 100644
--- a/openmp/runtime/src/ompt-general.cpp
+++ b/openmp/runtime/src/ompt-general.cpp
@@ -892,6 +892,10 @@ static ompt_data_t *ompt_get_target_task_data() {
return __ompt_get_target_task_data();
}
+static int ompt_set_frame_enter(void *addr, int flags, int state) {
+ return __ompt_set_frame_enter_internal(addr, flags, state);
+}
+
/// Lookup function to query libomp callbacks registered by the tool
static ompt_interface_fn_t ompt_libomp_target_fn_lookup(const char *s) {
#define provide_fn(fn) \
@@ -901,6 +905,7 @@ static ompt_interface_fn_t ompt_libomp_target_fn_lookup(const char *s) {
provide_fn(ompt_get_callback);
provide_fn(ompt_get_task_data);
provide_fn(ompt_get_target_task_data);
+ provide_fn(ompt_set_frame_enter);
#undef provide_fn
#define ompt_interface_fn(fn, type, code) \
diff --git a/openmp/runtime/src/ompt-internal.h b/openmp/runtime/src/ompt-internal.h
index 36b45f7a91ea2..27c82622fb33e 100644
--- a/openmp/runtime/src/ompt-internal.h
+++ b/openmp/runtime/src/ompt-internal.h
@@ -24,6 +24,12 @@
((x == fork_context_gnu) ? ompt_parallel_invoker_program \
: ompt_parallel_invoker_runtime)
+#define OMPT_FRAME_SET(frame, which, ptr_value, flags) \
+ { \
+ frame->which##_frame.ptr = ptr_value; \
+ frame->which##_frame_flags = flags; \
+ }
+
#define ompt_callback(e) e##_callback
typedef struct ompt_callbacks_internal_s {
diff --git a/openmp/runtime/src/ompt-specific.cpp b/openmp/runtime/src/ompt-specific.cpp
index 94ae2e5293875..5e42401552f70 100644
--- a/openmp/runtime/src/ompt-specific.cpp
+++ b/openmp/runtime/src/ompt-specific.cpp
@@ -481,6 +481,21 @@ int __ompt_get_task_memory_internal(void **addr, size_t *size, int blocknum) {
return 0;
}
+//----------------------------------------------------------
+// target region support
+//----------------------------------------------------------
+
+int __ompt_set_frame_enter_internal(void *addr, int flags, int state) {
+ int gtid = __kmp_entry_gtid();
+ kmp_info_t *thr = __kmp_threads[gtid];
+
+ ompt_frame_t *ompt_frame = &OMPT_CUR_TASK_INFO(thr)->frame;
+ OMPT_FRAME_SET(ompt_frame, enter, addr, flags);
+ int old_state = thr->th.ompt_thread_info.state;
+ thr->th.ompt_thread_info.state = ompt_state_work_parallel;
+ return old_state;
+}
+
//----------------------------------------------------------
// team support
//----------------------------------------------------------
diff --git a/openmp/runtime/src/ompt-specific.h b/openmp/runtime/src/ompt-specific.h
index b7eb140458b40..4243acddde7b8 100644
--- a/openmp/runtime/src/ompt-specific.h
+++ b/openmp/runtime/src/ompt-specific.h
@@ -24,6 +24,8 @@
/// done already
void __ompt_force_initialization();
+int __ompt_set_frame_enter_internal(void *addr, int flags, int state);
+
void __ompt_team_assign_id(kmp_team_t *team, ompt_data_t ompt_pid);
void __ompt_thread_assign_wait_id(void *variable);
More information about the Openmp-commits
mailing list