diff --git a/openmp/runtime/src/dllexports b/openmp/runtime/src/dllexports --- a/openmp/runtime/src/dllexports +++ b/openmp/runtime/src/dllexports @@ -391,6 +391,11 @@ __kmpc_omp_target_task_alloc 279 %endif +# New interface entry points, the OpenMP version number they have been +# introduced is the suffix. + + __kmpc_parallel_51 280 + # User API entry points that have both lower- and upper- case versions for Fortran. # Number for lowercase version is indicated. Number for uppercase is obtained by adding 1000. # User API entry points are entry points that start with 'kmp_' or 'omp_'. diff --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h --- a/openmp/runtime/src/kmp.h +++ b/openmp/runtime/src/kmp.h @@ -3681,6 +3681,28 @@ KMP_EXPORT void __kmpc_fork_call(ident_t *, kmp_int32 nargs, kmpc_micro microtask, ...); +/// The parallel region type. +/// +/// \param global_tid The global thread ID of the executing thread. +/// \param bound_tid TODO +/// \param payload The payload/closure determined at the invocation. +typedef void (*kmpc_parallel_region_ty)(kmp_int32 *global_tid, + kmp_int32 *bound_tid, void *payload); + +/// Entry point to start a new parallel region. +/// +/// \param ident The source identifier. +/// \param global_tid The global thread ID. +/// \param if_expr The if(expr), or 1 if none given. +/// \param num_threads The num_threads(expr), or -1 if none given. +/// \param proc_bind The proc_bind, or `proc_bind_default` if none given. +/// \param fn The outlined parallel region. +/// \param payload The payload passed to the outlined parallel region. +KMP_EXPORT void __kmpc_parallel_51(ident_t *ident, kmp_int32 global_tid, + kmp_int32 if_expr, kmp_int32 num_threads, + kmp_proc_bind_t proc_bind, + kmpc_parallel_region_ty fn, void *payload); + KMP_EXPORT void __kmpc_serialized_parallel(ident_t *, kmp_int32 global_tid); KMP_EXPORT void __kmpc_end_serialized_parallel(ident_t *, kmp_int32 global_tid); diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp --- a/openmp/runtime/src/kmp_csupport.cpp +++ b/openmp/runtime/src/kmp_csupport.cpp @@ -18,6 +18,7 @@ #include "kmp_itt.h" #include "kmp_lock.h" #include "kmp_stats.h" +#include "ompt-internal.h" #include "ompt-specific.h" #define MAX_MESSAGE 512 @@ -331,6 +332,33 @@ #endif // KMP_STATS_ENABLED } +void __kmpc_parallel_51(ident_t *ident, kmp_int32 global_tid, kmp_int32 if_expr, + kmp_int32 num_threads, kmp_proc_bind_t proc_bind, + kmpc_parallel_region_ty fn, void *payload) { + // TODO: For now we simply translate to the old way but we should avoid + // the varags call (via __kmpc_fork_call) all together in favor of + // a single closure argument. + + // Handle the serialized case first. + if (UNLIKELY(!if_expr)) { + __kmpc_serialized_parallel(ident, global_tid); + kmp_int32 bound_tid = 0; + fn(&global_tid, &bound_tid, payload); + __kmpc_end_serialized_parallel(ident, global_tid); + return; + } + + // Handle the num_threads clause. + if (num_threads != -1) + __kmpc_push_num_threads(ident, global_tid, num_threads); + + // Handle the proc_bind clause. + if (proc_bind != proc_bind_default) + __kmpc_push_proc_bind(ident, global_tid, proc_bind); + + __kmpc_fork_call(ident, 1, kmpc_micro(fn), payload); +} + /*! @ingroup PARALLEL @param loc source location information