Polly 19.0.0git
LoopGeneratorsGOMP.h
Go to the documentation of this file.
1//===- LoopGeneratorsGOMP.h - IR helper to create loops ---------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains functions to create scalar and OpenMP parallel loops
10// as LLVM-IR.
11//
12//===----------------------------------------------------------------------===//
13#ifndef POLLY_LOOP_GENERATORS_GOMP_H
14#define POLLY_LOOP_GENERATORS_GOMP_H
15
19#include "llvm/ADT/SetVector.h"
20
21namespace polly {
22
23/// This ParallelLoopGenerator subclass handles the generation of parallelized
24/// code, utilizing the GNU OpenMP library.
26public:
27 /// Create a parallel loop generator for the current function.
29 DominatorTree &DT, const DataLayout &DL)
31
32 // The functions below may be used if one does not want to generate a
33 // specific OpenMP parallel loop, but generate individual parts of it
34 // (e.g. the subfunction definition).
35
36 /// Create a runtime library call to spawn the worker threads.
37 ///
38 /// @param SubFn The subfunction which holds the loop body.
39 /// @param SubFnParam The parameter for the subfunction (basically the struct
40 /// filled with the outside values).
41 /// @param LB The lower bound for the loop we parallelize.
42 /// @param UB The upper bound for the loop we parallelize.
43 /// @param Stride The stride of the loop we parallelize.
44 void createCallSpawnThreads(Value *SubFn, Value *SubFnParam, Value *LB,
45 Value *UB, Value *Stride);
46
47 void deployParallelExecution(Function *SubFn, Value *SubFnParam, Value *LB,
48 Value *UB, Value *Stride) override;
49
50 Function *prepareSubFnDefinition(Function *F) const override;
51
52 std::tuple<Value *, Function *> createSubFn(Value *Stride, AllocaInst *Struct,
53 SetVector<Value *> UsedValues,
54 ValueMapT &VMap) override;
55
56 /// Create a runtime library call to join the worker threads.
58
59 /// Create a runtime library call to get the next work item.
60 ///
61 /// @param LBPtr A pointer value to store the work item begin in.
62 /// @param UBPtr A pointer value to store the work item end in.
63 ///
64 /// @returns A true value if the work item is not empty.
65 Value *createCallGetWorkItem(Value *LBPtr, Value *UBPtr);
66
67 /// Create a runtime library call to allow cleanup of the thread.
68 ///
69 /// @note This function is called right before the thread will exit the
70 /// subfunction and only if the runtime system depends on it.
72};
73} // end namespace polly
74#endif
polly dump Polly Dump Function
This ParallelLoopGenerator subclass handles the generation of parallelized code, utilizing the GNU Op...
ParallelLoopGeneratorGOMP(PollyIRBuilder &Builder, LoopInfo &LI, DominatorTree &DT, const DataLayout &DL)
Create a parallel loop generator for the current 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.
The ParallelLoopGenerator allows to create parallelized loops.
PollyIRBuilder & Builder
The IR builder we use to create instructions.
DominatorTree & DT
The dominance tree of the current function we need to update.
LoopInfo & LI
The loop info of the current function we need to update.
@ Value
MemoryKind::Value: Models an llvm::Value.
llvm::IRBuilder< llvm::ConstantFolder, IRInserter > PollyIRBuilder
Definition: IRBuilder.h:141
llvm::DenseMap< llvm::AssertingVH< llvm::Value >, llvm::AssertingVH< llvm::Value > > ValueMapT
Type to remap values.
Definition: ScopHelper.h:103