Skip to content

Commit b2ff3e7

Browse files
authored
[OpenMP][Offload] Restore __kmpc_* function signatures (#156104)
Avoid altering existing function signatures of the kmpc interface to fix regressions in the runtime optimization (OpenMPOpt).
1 parent 65f60fd commit b2ff3e7

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

offload/DeviceRTL/src/Parallelism.cpp

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ uint32_t determineNumberOfThreads(int32_t NumThreadsClause,
103103

104104
extern "C" {
105105

106-
[[clang::always_inline]] void
107-
__kmpc_parallel_spmd(IdentTy *ident, int32_t num_threads, void *fn, void **args,
108-
const int64_t nargs, int32_t nt_strict = false,
109-
int32_t nt_severity = severity_fatal,
110-
const char *nt_message = nullptr) {
106+
[[clang::always_inline]] void __kmpc_parallel_spmd_impl(
107+
IdentTy *ident, int32_t num_threads, void *fn, void **args,
108+
const int64_t nargs, int32_t nt_strict = false,
109+
int32_t nt_severity = severity_fatal, const char *nt_message = nullptr) {
111110
uint32_t TId = mapping::getThreadIdInBlock();
112111
uint32_t NumThreads =
113112
determineNumberOfThreads(num_threads, nt_strict, nt_severity, nt_message);
@@ -163,7 +162,22 @@ __kmpc_parallel_spmd(IdentTy *ident, int32_t num_threads, void *fn, void **args,
163162
return;
164163
}
165164

166-
[[clang::always_inline]] void __kmpc_parallel_51(
165+
[[clang::always_inline]] void __kmpc_parallel_spmd(IdentTy *ident,
166+
int32_t num_threads,
167+
void *fn, void **args,
168+
const int64_t nargs) {
169+
return __kmpc_parallel_spmd_impl(ident, num_threads, fn, args, nargs);
170+
}
171+
172+
[[clang::always_inline]] void __kmpc_parallel_spmd_60(
173+
IdentTy *ident, int32_t num_threads, void *fn, void **args,
174+
const int64_t nargs, int32_t nt_strict = false,
175+
int32_t nt_severity = severity_fatal, const char *nt_message = nullptr) {
176+
return __kmpc_parallel_spmd_impl(ident, num_threads, fn, args, nargs,
177+
nt_strict, nt_severity, nt_message);
178+
}
179+
180+
[[clang::always_inline]] void __kmpc_parallel_impl(
167181
IdentTy *ident, int32_t, int32_t if_expr, int32_t num_threads,
168182
int proc_bind, void *fn, void *wrapper_fn, void **args, int64_t nargs,
169183
int32_t nt_strict = false, int32_t nt_severity = severity_fatal,
@@ -198,8 +212,11 @@ __kmpc_parallel_spmd(IdentTy *ident, int32_t num_threads, void *fn, void **args,
198212
// This was moved to its own routine so it could be called directly
199213
// in certain situations to avoid resource consumption of unused
200214
// logic in parallel_51.
201-
__kmpc_parallel_spmd(ident, num_threads, fn, args, nargs, nt_strict,
202-
nt_severity, nt_message);
215+
if (nt_strict)
216+
__kmpc_parallel_spmd(ident, num_threads, fn, args, nargs);
217+
else
218+
__kmpc_parallel_spmd_60(ident, num_threads, fn, args, nargs, nt_strict,
219+
nt_severity, nt_message);
203220

204221
return;
205222
}
@@ -308,14 +325,22 @@ __kmpc_parallel_spmd(IdentTy *ident, int32_t num_threads, void *fn, void **args,
308325
__kmpc_end_sharing_variables();
309326
}
310327

328+
[[clang::always_inline]] void
329+
__kmpc_parallel_51(IdentTy *ident, int32_t id, int32_t if_expr,
330+
int32_t num_threads, int proc_bind, void *fn,
331+
void *wrapper_fn, void **args, int64_t nargs) {
332+
return __kmpc_parallel_impl(ident, id, if_expr, num_threads, proc_bind, fn,
333+
wrapper_fn, args, nargs);
334+
}
335+
311336
[[clang::always_inline]] void __kmpc_parallel_60(
312337
IdentTy *ident, int32_t id, int32_t if_expr, int32_t num_threads,
313338
int proc_bind, void *fn, void *wrapper_fn, void **args, int64_t nargs,
314339
int32_t nt_strict = false, int32_t nt_severity = severity_fatal,
315340
const char *nt_message = nullptr) {
316-
return __kmpc_parallel_51(ident, id, if_expr, num_threads, proc_bind, fn,
317-
wrapper_fn, args, nargs, nt_strict, nt_severity,
318-
nt_message);
341+
return __kmpc_parallel_impl(ident, id, if_expr, num_threads, proc_bind, fn,
342+
wrapper_fn, args, nargs, nt_strict, nt_severity,
343+
nt_message);
319344
}
320345

321346
[[clang::noinline]] bool __kmpc_kernel_parallel(ParallelRegionFnTy *WorkFn) {

0 commit comments

Comments
 (0)