diff options
author | Gheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com> | 2018-03-22 17:33:27 +0000 |
---|---|---|
committer | Gheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com> | 2018-03-22 17:33:27 +0000 |
commit | 36cdfad06236e1f3f348ab68b7ba8083337c81b3 (patch) | |
tree | ca4d947a09e8030e12e6bdb564f2de1e1f0acb2c | |
parent | b3297ef05179e1fee616b97b1c65b58e4c7fef17 (diff) | |
download | bcm5719-llvm-36cdfad06236e1f3f348ab68b7ba8083337c81b3.tar.gz bcm5719-llvm-36cdfad06236e1f3f348ab68b7ba8083337c81b3.zip |
[OpenMP][Clang] Add call to global data sharing stack initialization on the workers side
Summary: The workers also need to initialize the global stack. The call to the initialization function needs to happen after the kernel_init() function is called by the master. This ensures that the per-team data structures of the runtime have been initialized.
Reviewers: ABataev, grokos, carlo.bertolli, caomhin
Reviewed By: ABataev
Subscribers: jholewinski, guansong, cfe-commits
Differential Revision: https://reviews.llvm.org/D44749
llvm-svn: 328219
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp | 5 | ||||
-rw-r--r-- | clang/test/OpenMP/nvptx_data_sharing.cpp | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp index 8ab890cb4c3..62131cd0243 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -801,6 +801,11 @@ void CGOpenMPRuntimeNVPTX::emitWorkerLoop(CodeGenFunction &CGF, // Wait for parallel work syncCTAThreads(CGF); + // For data sharing, we need to initialize the stack for workers. + CGF.EmitRuntimeCall( + createNVPTXRuntimeFunction( + OMPRTL_NVPTX__kmpc_data_sharing_init_stack)); + Address WorkFn = CGF.CreateDefaultAlignTempAlloca(CGF.Int8PtrTy, /*Name=*/"work_fn"); Address ExecStatus = diff --git a/clang/test/OpenMP/nvptx_data_sharing.cpp b/clang/test/OpenMP/nvptx_data_sharing.cpp index 26ab3c0201b..68245c9abae 100644 --- a/clang/test/OpenMP/nvptx_data_sharing.cpp +++ b/clang/test/OpenMP/nvptx_data_sharing.cpp @@ -27,6 +27,11 @@ void test_ds(){ } } +/// ========= In the worker function ========= /// +// CK1: {{.*}}define internal void @__omp_offloading{{.*}}test_ds{{.*}}_worker() +// CK1: call void @llvm.nvvm.barrier0() +// CK1: call void @__kmpc_data_sharing_init_stack + /// ========= In the kernel function ========= /// // CK1: {{.*}}define void @__omp_offloading{{.*}}test_ds{{.*}}() |