[OpenMP] Introduce the keepAlive function into the old device RT

Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D113110
This commit is contained in:
Johannes Doerfert 2021-11-03 10:26:34 -05:00
parent 93bebdc78f
commit ab9f3f5d25
1 changed files with 10 additions and 0 deletions

View 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 #pragma omp end declare target