[OpenMP] Introduce the keepAlive function into the old device RT
authorJohannes Doerfert <johannes@jdoerfert.de>
Wed, 3 Nov 2021 15:26:34 +0000 (10:26 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Thu, 4 Nov 2021 22:54:56 +0000 (17:54 -0500)
Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D113110

openmp/libomptarget/deviceRTLs/common/src/support.cu

index 6dd5913..b3bf550 100644 (file)
@@ -226,4 +226,14 @@ void __kmp_invoke_microtask(kmp_int32 global_tid, kmp_int32 bound_tid, void *fn,
   }
 }
 
+namespace _OMP {
+/// Helper to keep code alive without introducing a performance penalty.
+__attribute__((used, weak, optnone)) void keepAlive() {
+  __kmpc_get_hardware_thread_id_in_block();
+  __kmpc_get_hardware_num_threads_in_block();
+  __kmpc_barrier_simple_spmd(nullptr, 0);
+  __kmpc_barrier_simple_generic(nullptr, 0);
+}
+} // namespace _OMP
+
 #pragma omp end declare target