forked from OSchip/llvm-project
[OpenMP] Lower taskwait using OpenMP IR Builder
The code generation is exactly the same as it was. But not that the special handling of untied tasks is still handled by emitUntiedSwitch in clang. Differential Revision: https://reviews.llvm.org/D69828
This commit is contained in:
parent
4e1c49cf4d
commit
a82f35e176
|
@ -6340,11 +6340,18 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction &CGF,
|
|||
SourceLocation Loc) {
|
||||
if (!CGF.HaveInsertPoint())
|
||||
return;
|
||||
// Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
|
||||
// global_tid);
|
||||
llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
|
||||
// Ignore return result until untied tasks are supported.
|
||||
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskwait), Args);
|
||||
|
||||
llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
|
||||
if (OMPBuilder) {
|
||||
OMPBuilder->CreateTaskwait(CGF.Builder);
|
||||
} else {
|
||||
// Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
|
||||
// global_tid);
|
||||
llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
|
||||
// Ignore return result until untied tasks are supported.
|
||||
CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskwait), Args);
|
||||
}
|
||||
|
||||
if (auto *Region = dyn_cast_or_null<CGOpenMPRegionInfo>(CGF.CapturedStmtInfo))
|
||||
Region->emitUntiedSwitch(CGF);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s
|
||||
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
|
||||
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
|
||||
//
|
||||
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -o - | FileCheck %s
|
||||
// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
|
||||
// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
|
||||
|
||||
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
|
||||
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s
|
||||
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
|
||||
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
|
||||
//
|
||||
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -o - | FileCheck %s
|
||||
// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
|
||||
// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
|
||||
|
||||
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
|
||||
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
|
||||
|
|
|
@ -176,6 +176,11 @@ public:
|
|||
/// \param Loc The location where the flush directive was encountered
|
||||
void CreateFlush(const LocationDescription &Loc);
|
||||
|
||||
/// Generator for '#omp taskwait'
|
||||
///
|
||||
/// \param Loc The location where the taskwait directive was encountered.
|
||||
void CreateTaskwait(const LocationDescription& Loc);
|
||||
|
||||
///}
|
||||
|
||||
|
||||
|
@ -241,6 +246,11 @@ private:
|
|||
FinalizationStack.back().DK == DK;
|
||||
}
|
||||
|
||||
/// Generate a taskwait runtime call.
|
||||
///
|
||||
/// \param Loc The location at which the request originated and is fulfilled.
|
||||
void emitTaskwaitImpl(const LocationDescription &Loc);
|
||||
|
||||
/// Return the current thread ID.
|
||||
///
|
||||
/// \param Ident The ident (ident_t*) describing the query origin.
|
||||
|
|
|
@ -169,6 +169,7 @@ __OMP_RTL(__kmpc_cancel_barrier, false, Int32, IdentPtr, Int32)
|
|||
__OMP_RTL(__kmpc_flush, false, Void, IdentPtr)
|
||||
__OMP_RTL(__kmpc_global_thread_num, false, Int32, IdentPtr)
|
||||
__OMP_RTL(__kmpc_fork_call, true, Void, IdentPtr, Int32, ParallelTaskPtr)
|
||||
__OMP_RTL(__kmpc_omp_taskwait, false, Int32, IdentPtr, Int32)
|
||||
__OMP_RTL(__kmpc_push_num_threads, false, Void, IdentPtr, Int32,
|
||||
/* Int */ Int32)
|
||||
__OMP_RTL(__kmpc_push_proc_bind, false, Void, IdentPtr, Int32, /* Int */ Int32)
|
||||
|
|
|
@ -691,3 +691,21 @@ void OpenMPIRBuilder::CreateFlush(const LocationDescription &Loc)
|
|||
return;
|
||||
emitFlush(Loc);
|
||||
}
|
||||
|
||||
void OpenMPIRBuilder::emitTaskwaitImpl(const LocationDescription &Loc) {
|
||||
// Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
|
||||
// global_tid);
|
||||
Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
|
||||
Value *Ident = getOrCreateIdent(SrcLocStr);
|
||||
Value *Args[] = {Ident, getOrCreateThreadID(Ident)};
|
||||
|
||||
// Ignore return result until untied tasks are supported.
|
||||
Builder.CreateCall(getOrCreateRuntimeFunction(OMPRTL___kmpc_omp_taskwait),
|
||||
Args);
|
||||
}
|
||||
|
||||
void OpenMPIRBuilder::CreateTaskwait(const LocationDescription &Loc) {
|
||||
if (!updateToLocation(Loc))
|
||||
return;
|
||||
emitTaskwaitImpl(Loc);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue