14#include "llvm/IR/Dominators.h"
15#include "llvm/IR/Module.h"
24 const std::string Name =
"GOMP_parallel_loop_runtime_start";
30 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
32 Type *Params[] = {PointerType::getUnqual(FunctionType::get(
40 FunctionType *Ty = FunctionType::get(
Builder.getVoidTy(), Params,
false);
41 F = Function::Create(Ty, Linkage, Name,
M);
47 CallInst *Call =
Builder.CreateCall(F, Args);
57 CallInst *Call =
Builder.CreateCall(SubFn, SubFnParam);
64 FunctionType::get(
Builder.getVoidTy(), {Builder.getPtrTy()},
false);
65 Function *SubFn = Function::Create(FT, Function::InternalLinkage,
66 F->getName() +
"_polly_subfn",
M);
68 SubFn->arg_begin()->setName(
"polly.par.userContext");
92std::tuple<Value *, Function *>
94 SetVector<Value *> Data,
98 errs() <<
"warning: Polly's GNU OpenMP backend solely "
99 "supports the scheduling type 'runtime'.\n";
104 errs() <<
"warning: Polly's GNU OpenMP backend solely "
105 "supports the default chunk size.\n";
109 LLVMContext &Context = SubFn->getContext();
112 BasicBlock *PrevBB =
Builder.GetInsertBlock();
115 BasicBlock *HeaderBB = BasicBlock::Create(Context,
"polly.par.setup", SubFn);
116 BasicBlock *ExitBB = BasicBlock::Create(Context,
"polly.par.exit", SubFn);
117 BasicBlock *CheckNextBB =
118 BasicBlock::Create(Context,
"polly.par.checkNext", SubFn);
119 BasicBlock *PreHeaderBB =
120 BasicBlock::Create(Context,
"polly.par.loadIVBounds", SubFn);
122 DT.addNewBlock(HeaderBB, PrevBB);
123 DT.addNewBlock(ExitBB, HeaderBB);
124 DT.addNewBlock(CheckNextBB, HeaderBB);
125 DT.addNewBlock(PreHeaderBB, HeaderBB);
128 Builder.SetInsertPoint(HeaderBB);
131 Value *UserContext = &*SubFn->arg_begin();
138 Builder.SetInsertPoint(CheckNextBB);
141 Next,
Builder.getInt1Ty(),
"polly.par.hasNextScheduleBlock");
142 Builder.CreateCondBr(HasNextSchedule, PreHeaderBB, ExitBB);
145 Builder.SetInsertPoint(PreHeaderBB);
152 "polly.par.UBAdjusted");
159 nullptr,
true,
false);
161 BasicBlock::iterator LoopBody =
Builder.GetInsertPoint();
164 Builder.SetInsertPoint(ExitBB);
168 Builder.SetInsertPoint(&*LoopBody);
170 return std::make_tuple(IV, SubFn);
175 const std::string Name =
"GOMP_loop_runtime_next";
181 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
183 FunctionType *Ty = FunctionType::get(
Builder.getInt8Ty(), Params,
false);
184 F = Function::Create(Ty, Linkage, Name,
M);
187 Value *Args[] = {LBPtr, UBPtr};
188 CallInst *Call =
Builder.CreateCall(F, Args);
196 const std::string Name =
"GOMP_parallel_end";
202 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
204 FunctionType *Ty = FunctionType::get(
Builder.getVoidTy(),
false);
205 F = Function::Create(Ty, Linkage, Name,
M);
208 CallInst *Call =
Builder.CreateCall(F, {});
213 const std::string Name =
"GOMP_loop_end_nowait";
219 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
221 FunctionType *Ty = FunctionType::get(
Builder.getVoidTy(),
false);
222 F = Function::Create(Ty, Linkage, Name,
M);
225 CallInst *Call =
Builder.CreateCall(F, {});
polly dump Polly Dump Function
void deployParallelExecution(Function *SubFn, Value *SubFnParam, Value *LB, Value *UB, Value *Stride) override
Create the runtime library calls for spawn and join of the worker threads.
Value * createCallGetWorkItem(Value *LBPtr, Value *UBPtr)
Create a runtime library call to get the next work item.
std::tuple< Value *, Function * > createSubFn(Value *Stride, AllocaInst *Struct, SetVector< Value * > UsedValues, ValueMapT &VMap) override
Create the parallel subfunction.
void createCallSpawnThreads(Value *SubFn, Value *SubFnParam, Value *LB, Value *UB, Value *Stride)
Create a runtime library call to spawn the worker threads.
void createCallJoinThreads()
Create a runtime library call to join the worker threads.
void createCallCleanupThread()
Create a runtime library call to allow cleanup of the thread.
Function * prepareSubFnDefinition(Function *F) const override
Prepare the definition of the parallel subfunction.
PollyIRBuilder & Builder
The IR builder we use to create instructions.
DominatorTree & DT
The dominance tree of the current function we need to update.
Function * createSubFnDefinition()
Create the definition of the parallel subfunction.
Module * M
The current module.
LoopInfo & LI
The loop info of the current function we need to update.
llvm::DebugLoc DLGenerated
Debug location for generated code without direct link to any specific line.
Type * LongType
The type of a "long" on this hardware used for backend calls.
void extractValuesFromStruct(SetVector< Value * > Values, Type *Ty, Value *Struct, ValueMapT &VMap)
Extract all values from the Struct and construct the mapping.
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
OMPGeneralSchedulingType PollyScheduling
@ Value
MemoryKind::Value: Models an llvm::Value.
Value * createLoop(Value *LowerBound, Value *UpperBound, Value *Stride, PollyIRBuilder &Builder, LoopInfo &LI, DominatorTree &DT, BasicBlock *&ExitBlock, ICmpInst::Predicate Predicate, ScopAnnotator *Annotator=nullptr, bool Parallel=false, bool UseGuard=true, bool LoopVectDisabled=false)
Create a scalar do/for-style loop.
llvm::DenseMap< llvm::AssertingVH< llvm::Value >, llvm::AssertingVH< llvm::Value > > ValueMapT
Type to remap values.