Polly 20.0.0git
|
This ParallelLoopGenerator subclass handles the generation of parallelized code, utilizing the LLVM OpenMP library. More...
#include <LoopGeneratorsKMP.h>
Public Member Functions | |
ParallelLoopGeneratorKMP (PollyIRBuilder &Builder, const DataLayout &DL) | |
Create a parallel loop generator for the current function. | |
void | createCallSpawnThreads (Value *SubFn, Value *SubFnParam, Value *LB, Value *UB, Value *Stride) |
Create a runtime library call to spawn the worker threads. | |
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. | |
Function * | prepareSubFnDefinition (Function *F) const override |
Prepare the definition of the parallel subfunction. | |
std::tuple< Value *, Function * > | createSubFn (Value *Stride, AllocaInst *Struct, SetVector< Value * > UsedValues, ValueMapT &VMap) override |
Create the parallel subfunction. | |
Value * | createCallGlobalThreadNum () |
Create a runtime library call to get the current global thread number. | |
void | createCallPushNumThreads (Value *GlobalThreadID, Value *NumThreads) |
Create a runtime library call to request a number of threads. | |
void | createCallDispatchInit (Value *GlobalThreadID, Value *LB, Value *UB, Value *Inc, Value *ChunkSize) |
Create a runtime library call to prepare the OpenMP runtime. | |
Value * | createCallDispatchNext (Value *GlobalThreadID, Value *IsLastPtr, Value *LBPtr, Value *UBPtr, Value *StridePtr) |
Create a runtime library call to retrieve the next (dynamically) allocated chunk of work for this thread. | |
void | createCallStaticInit (Value *GlobalThreadID, Value *IsLastPtr, Value *LBPtr, Value *UBPtr, Value *StridePtr, Value *ChunkSize) |
Create a runtime library call to prepare the OpenMP runtime. | |
void | createCallStaticFini (Value *GlobalThreadID) |
Create a runtime library call to mark the end of a statically scheduled loop. | |
GlobalVariable * | createSourceLocation () |
Create the current source location. | |
Public Member Functions inherited from polly::ParallelLoopGenerator | |
ParallelLoopGenerator (PollyIRBuilder &Builder, const DataLayout &DL) | |
Create a parallel loop generator for the current function. | |
virtual | ~ParallelLoopGenerator () |
Value * | createParallelLoop (Value *LB, Value *UB, Value *Stride, SetVector< Value * > &Values, ValueMapT &VMap, BasicBlock::iterator *LoopBody) |
Create a parallel loop. | |
DominatorTree * | getCalleeDominatorTree () const |
Returns the DominatorTree for the generated subfunction. | |
LoopInfo * | getCalleeLoopInfo () const |
Returns the LoopInfo for the generated subfunction. | |
AllocaInst * | storeValuesIntoStruct (SetVector< Value * > &Values) |
Create a struct for all Values and store them in there. | |
void | extractValuesFromStruct (SetVector< Value * > Values, Type *Ty, Value *Struct, ValueMapT &VMap) |
Extract all values from the Struct and construct the mapping. | |
Function * | createSubFnDefinition () |
Create the definition of the parallel subfunction. | |
virtual void | deployParallelExecution (Function *SubFn, Value *SubFnParam, Value *LB, Value *UB, Value *Stride)=0 |
Create the runtime library calls for spawn and join of the worker threads. | |
virtual Function * | prepareSubFnDefinition (Function *F) const =0 |
Prepare the definition of the parallel subfunction. | |
virtual std::tuple< Value *, Function * > | createSubFn (Value *Stride, AllocaInst *Struct, SetVector< Value * > UsedValues, ValueMapT &VMap)=0 |
Create the parallel subfunction. | |
Protected Member Functions | |
OMPGeneralSchedulingType | getSchedType (int ChunkSize, OMPGeneralSchedulingType Scheduling) const |
Convert the combination of given chunk size and scheduling type (which might have been set via the command line) into the corresponding scheduling type. | |
bool | is64BitArch () |
Returns True if 'LongType' is 64bit wide, otherwise: False. | |
Protected Attributes | |
GlobalValue * | SourceLocationInfo |
The source location struct of this loop. | |
Protected Attributes inherited from polly::ParallelLoopGenerator | |
PollyIRBuilder & | Builder |
The IR builder we use to create instructions. | |
std::unique_ptr< LoopInfo > | SubFnLI |
The loop info for the generated subfunction. | |
std::unique_ptr< DominatorTree > | SubFnDT |
The dominance tree for the generated subfunction. | |
Type * | LongType |
The type of a "long" on this hardware used for backend calls. | |
Module * | M |
The current module. | |
llvm::DebugLoc | DLGenerated |
Debug location for generated code without direct link to any specific line. | |
This ParallelLoopGenerator subclass handles the generation of parallelized code, utilizing the LLVM OpenMP library.
Definition at line 27 of file LoopGeneratorsKMP.h.
|
inline |
Create a parallel loop generator for the current function.
Definition at line 30 of file LoopGeneratorsKMP.h.
References createSourceLocation(), and SourceLocationInfo.
void ParallelLoopGeneratorKMP::createCallDispatchInit | ( | Value * | GlobalThreadID, |
Value * | LB, | ||
Value * | UB, | ||
Value * | Inc, | ||
Value * | ChunkSize | ||
) |
Create a runtime library call to prepare the OpenMP runtime.
For dynamically scheduled loops, saving the loop arguments.
GlobalThreadID | The global thread ID. |
LB | The loop's lower bound. |
UB | The loop's upper bound. |
Inc | The loop increment. |
ChunkSize | The chunk size of the parallel loop. |
Definition at line 428 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, polly::ParallelLoopGenerator::DLGenerated, Function, getSchedType(), is64BitArch(), polly::ParallelLoopGenerator::LongType, polly::ParallelLoopGenerator::M, polly::PollyChunkSize, polly::PollyScheduling, SourceLocationInfo, and polly::Value.
Referenced by createSubFn().
Value * ParallelLoopGeneratorKMP::createCallDispatchNext | ( | Value * | GlobalThreadID, |
Value * | IsLastPtr, | ||
Value * | LBPtr, | ||
Value * | UBPtr, | ||
Value * | StridePtr | ||
) |
Create a runtime library call to retrieve the next (dynamically) allocated chunk of work for this thread.
GlobalThreadID | The global thread ID. |
IsLastPtr | Pointer to a flag, which is set to 1 if this is the last chunk of work, or 0 otherwise. |
LBPtr | Pointer to the lower bound for the next chunk. |
UBPtr | Pointer to the upper bound for the next chunk. |
StridePtr | Pointer to the stride for the next chunk. |
Definition at line 469 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, polly::ParallelLoopGenerator::DLGenerated, Function, is64BitArch(), polly::ParallelLoopGenerator::LongType, polly::ParallelLoopGenerator::M, SourceLocationInfo, and polly::Value.
Referenced by createSubFn().
Value * ParallelLoopGeneratorKMP::createCallGlobalThreadNum | ( | ) |
Create a runtime library call to get the current global thread number.
Definition at line 317 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, polly::ParallelLoopGenerator::DLGenerated, Function, polly::ParallelLoopGenerator::M, SourceLocationInfo, and polly::Value.
Referenced by deployParallelExecution().
void ParallelLoopGeneratorKMP::createCallPushNumThreads | ( | Value * | GlobalThreadID, |
Value * | NumThreads | ||
) |
Create a runtime library call to request a number of threads.
Which will be used in the next OpenMP section (by the next fork).
GlobalThreadID | The global thread ID. |
NumThreads | The number of threads to use. |
Definition at line 338 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, polly::ParallelLoopGenerator::DLGenerated, Function, polly::ParallelLoopGenerator::M, SourceLocationInfo, and polly::Value.
Referenced by deployParallelExecution().
void ParallelLoopGeneratorKMP::createCallSpawnThreads | ( | Value * | SubFn, |
Value * | SubFnParam, | ||
Value * | LB, | ||
Value * | UB, | ||
Value * | Stride | ||
) |
Create a runtime library call to spawn the worker threads.
SubFn | The subfunction which holds the loop body. |
SubFnParam | The parameter for the subfunction (basically the struct filled with the outside values). |
LB | The lower bound for the loop we parallelize. |
UB | The upper bound for the loop we parallelize. |
Stride | The stride of the loop we parallelize. |
Definition at line 21 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, polly::ParallelLoopGenerator::DLGenerated, Function, polly::ParallelLoopGenerator::M, SourceLocationInfo, and polly::Value.
Referenced by deployParallelExecution().
void ParallelLoopGeneratorKMP::createCallStaticFini | ( | Value * | GlobalThreadID | ) |
Create a runtime library call to mark the end of a statically scheduled loop.
GlobalThreadID | The global thread ID. |
Definition at line 408 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, polly::ParallelLoopGenerator::DLGenerated, Function, polly::ParallelLoopGenerator::M, SourceLocationInfo, and polly::Value.
Referenced by createSubFn().
void ParallelLoopGeneratorKMP::createCallStaticInit | ( | Value * | GlobalThreadID, |
Value * | IsLastPtr, | ||
Value * | LBPtr, | ||
Value * | UBPtr, | ||
Value * | StridePtr, | ||
Value * | ChunkSize | ||
) |
Create a runtime library call to prepare the OpenMP runtime.
For statically scheduled loops, saving the loop arguments.
GlobalThreadID | The global thread ID. |
IsLastPtr | Pointer to a flag, which is set to 1 if this is the last chunk of work, or 0 otherwise. |
LBPtr | Pointer to the lower bound for the next chunk. |
UBPtr | Pointer to the upper bound for the next chunk. |
StridePtr | Pointer to the stride for the next chunk. |
ChunkSize | The chunk size of the parallel loop. |
Definition at line 362 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, polly::ParallelLoopGenerator::DLGenerated, Function, getSchedType(), is64BitArch(), polly::ParallelLoopGenerator::LongType, polly::ParallelLoopGenerator::M, polly::PollyChunkSize, polly::PollyScheduling, SourceLocationInfo, and polly::Value.
Referenced by createSubFn().
GlobalVariable * ParallelLoopGeneratorKMP::createSourceLocation | ( | ) |
Create the current source location.
TODO: Generates only(!) dummy values.
Definition at line 505 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, and polly::ParallelLoopGenerator::M.
Referenced by ParallelLoopGeneratorKMP().
|
overridevirtual |
Create the parallel subfunction.
Stride | The induction variable increment. |
Struct | A struct holding all values in Values . |
Values | A set of LLVM-IR Values that should be available in the new loop body. |
VMap | A map to allow outside access to the new versions of the values in Values . |
SubFn | The newly created subfunction is returned here. |
Implements polly::ParallelLoopGenerator.
Definition at line 133 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, createCallDispatchInit(), createCallDispatchNext(), createCallStaticFini(), createCallStaticInit(), polly::createLoop(), polly::ParallelLoopGenerator::createSubFnDefinition(), polly::Dynamic, polly::ParallelLoopGenerator::extractValuesFromStruct(), Function, getSchedType(), polly::Guided, is64BitArch(), polly::ParallelLoopGenerator::LongType, polly::PollyChunkSize, polly::PollyScheduling, polly::Runtime, polly::StaticChunked, polly::StaticNonChunked, polly::ParallelLoopGenerator::SubFnDT, polly::ParallelLoopGenerator::SubFnLI, and polly::Value.
|
overridevirtual |
Create the runtime library calls for spawn and join of the worker threads.
Additionally, places a call to the specified subfunction.
SubFn | The subfunction which holds the loop body. |
SubFnParam | The parameter for the subfunction (basically the struct filled with the outside values). |
LB | The lower bound for the loop we parallelize. |
UB | The upper bound for the loop we parallelize. |
Stride | The stride of the loop we parallelize. |
Implements polly::ParallelLoopGenerator.
Definition at line 65 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, createCallGlobalThreadNum(), createCallPushNumThreads(), createCallSpawnThreads(), polly::PollyNumThreads, and polly::Value.
|
protected |
Convert the combination of given chunk size and scheduling type (which might have been set via the command line) into the corresponding scheduling type.
This may result (e.g.) in a 'change' from "static chunked" scheduling to "static non-chunked" (regarding the provided and returned scheduling types).
ChunkSize | The chunk size, set via command line or its default. |
Scheduling | The scheduling, set via command line or its default. |
Definition at line 561 of file LoopGeneratorsKMP.cpp.
References polly::StaticChunked, and polly::StaticNonChunked.
Referenced by createCallDispatchInit(), createCallStaticInit(), and createSubFn().
|
protected |
Returns True if 'LongType' is 64bit wide, otherwise: False.
Definition at line 557 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::LongType.
Referenced by createCallDispatchInit(), createCallDispatchNext(), createCallStaticInit(), and createSubFn().
|
overridevirtual |
Prepare the definition of the parallel subfunction.
Creates the argument list and names them (as well as the subfunction).
F | A pointer to the (parallel) subfunction's parent function. |
Implements polly::ParallelLoopGenerator.
Definition at line 79 of file LoopGeneratorsKMP.cpp.
References polly::ParallelLoopGenerator::Builder, Function, polly::ParallelLoopGenerator::LongType, and polly::ParallelLoopGenerator::M.
|
protected |
The source location struct of this loop.
ident_t = type { i32, i32, i32, i32, i8* }
Definition at line 38 of file LoopGeneratorsKMP.h.
Referenced by createCallDispatchInit(), createCallDispatchNext(), createCallGlobalThreadNum(), createCallPushNumThreads(), createCallSpawnThreads(), createCallStaticFini(), createCallStaticInit(), and ParallelLoopGeneratorKMP().