From 4e32d5cedf19b639ff0cc7eea924dbe26b001de5 Mon Sep 17 00:00:00 2001 From: Guilherme Valarini Date: Tue, 20 Dec 2022 16:41:26 -0300 Subject: [PATCH] [OpenMP] Disable libomptarget integration on unsupported platforms Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D140419 --- openmp/runtime/src/kmp_config.h.cmake | 2 ++ openmp/runtime/src/kmp_tasking.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/openmp/runtime/src/kmp_config.h.cmake b/openmp/runtime/src/kmp_config.h.cmake index 40d2011..91bb8a8 100644 --- a/openmp/runtime/src/kmp_config.h.cmake +++ b/openmp/runtime/src/kmp_config.h.cmake @@ -94,6 +94,8 @@ #define KMP_HAVE_POSIX_MEMALIGN LIBOMP_HAVE_POSIX_MEMALIGN #cmakedefine01 LIBOMP_HAVE__ALIGNED_MALLOC #define KMP_HAVE__ALIGNED_MALLOC LIBOMP_HAVE__ALIGNED_MALLOC +#cmakedefine01 OPENMP_ENABLE_LIBOMPTARGET +#define ENABLE_LIBOMPTARGET OPENMP_ENABLE_LIBOMPTARGET // Configured cache line based on architecture #if KMP_ARCH_PPC64 diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp index 9fc02ea..e8c565c 100644 --- a/openmp/runtime/src/kmp_tasking.cpp +++ b/openmp/runtime/src/kmp_tasking.cpp @@ -21,8 +21,10 @@ #include "ompt-specific.h" #endif +#if ENABLE_LIBOMPTARGET // Declaration of synchronization function from libomptarget. extern "C" void __tgt_target_nowait_query(void **) KMP_WEAK_ATTRIBUTE_INTERNAL; +#endif /* forward declaration */ static void __kmp_enable_tasking(kmp_task_team_t *task_team, @@ -1798,12 +1800,15 @@ static void __kmp_invoke_task(kmp_int32 gtid, kmp_task_t *task, KMP_FSYNC_ACQUIRED(taskdata); // acquired self (new task) #endif +#if ENABLE_LIBOMPTARGET if (taskdata->td_target_data.async_handle != NULL) { // If we have a valid target async handle, that means that we have already // executed the task routine once. We must query for the handle completion // instead of re-executing the routine. __tgt_target_nowait_query(&taskdata->td_target_data.async_handle); - } else if (task->routine != NULL) { + } else +#endif + if (task->routine != NULL) { #ifdef KMP_GOMP_COMPAT if (taskdata->td_flags.native) { ((void (*)(void *))(*(task->routine)))(task->shareds); -- 2.7.4