Polly 20.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.
30
31 // The functions below may be used if one does not want to generate a
32 // specific OpenMP parallel loop, but generate individual parts of it
33 // (e.g. the subfunction definition).
34
35 /// Create a runtime library call to spawn the worker threads.
36 ///
37 /// @param SubFn The subfunction which holds the loop body.
38 /// @param SubFnParam The parameter for the subfunction (basically the struct
39 /// filled with the outside values).
40 /// @param LB The lower bound for the loop we parallelize.
41 /// @param UB The upper bound for the loop we parallelize.
42 /// @param Stride The stride of the loop we parallelize.
43 void createCallSpawnThreads(Value *SubFn, Value *SubFnParam, Value *LB,
44 Value *UB, Value *Stride);
45
46 void deployParallelExecution(Function *SubFn, Value *SubFnParam, Value *LB,
47 Value *UB, Value *Stride) override;
48
49 Function *prepareSubFnDefinition(Function *F) const override;
50
51 std::tuple<Value *, Function *> createSubFn(Value *Stride, AllocaInst *Struct,
52 SetVector<Value *> UsedValues,
53 ValueMapT &VMap) override;
54
55 /// Create a runtime library call to join the worker threads.
57
58 /// Create a runtime library call to get the next work item.
59 ///
60 /// @param LBPtr A pointer value to store the work item begin in.
61 /// @param UBPtr A pointer value to store the work item end in.
62 ///
63 /// @returns A true value if the work item is not empty.
64 Value *createCallGetWorkItem(Value *LBPtr, Value *UBPtr);
65
66 /// Create a runtime library call to allow cleanup of the thread.
67 ///
68 /// @note This function is called right before the thread will exit the
69 /// subfunction and only if the runtime system depends on it.
71};
72} // end namespace polly
73#endif
polly dump Polly Dump Function
This ParallelLoopGenerator subclass handles the generation of parallelized code, utilizing the GNU Op...
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.
ParallelLoopGeneratorGOMP(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 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.
@ Value
MemoryKind::Value: Models an llvm::Value.
llvm::IRBuilder< llvm::ConstantFolder, IRInserter > PollyIRBuilder
Definition: IRBuilder.h:140
llvm::DenseMap< llvm::AssertingVH< llvm::Value >, llvm::AssertingVH< llvm::Value > > ValueMapT
Type to remap values.
Definition: ScopHelper.h:106