14#ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMEGPU_H
15#define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMEGPU_H
51 struct EntryFunctionState {
55 ExecutionMode getExecutionMode()
const;
57 DataSharingMode getDataSharingMode()
const;
60 void syncCTAThreads(CodeGenFunction &CGF);
64 EntryFunctionState &EST,
bool IsSPMD);
67 void emitKernelDeinit(CodeGenFunction &CGF, EntryFunctionState &EST,
71 void emitGenericVarsProlog(CodeGenFunction &CGF,
SourceLocation Loc);
74 void emitGenericVarsEpilog(CodeGenFunction &CGF);
90 llvm::Function *&OutlinedFn,
91 llvm::Constant *&OutlinedFnID,
bool IsOffloadEntry,
92 const RegionCodeGenTy &
CodeGen);
106 llvm::Function *&OutlinedFn,
107 llvm::Constant *&OutlinedFnID,
bool IsOffloadEntry,
108 const RegionCodeGenTy &
CodeGen);
120 StringRef ParentName,
121 llvm::Function *&OutlinedFn,
122 llvm::Constant *&OutlinedFnID,
124 const RegionCodeGenTy &
CodeGen)
override;
134 bool isGPU()
const override {
return true; };
142 const VarDecl *VD)
const override;
145 std::pair<llvm::Value *, llvm::Value *>
151 const std::pair<llvm::Value *, llvm::Value *> &AddrSizePair)
override;
162 llvm::omp::ProcBindKind ProcBind,
183 const Expr *Message =
nullptr,
254 llvm::Function *OutlinedFn,
256 const Expr *IfCond, llvm::Value *NumThreads,
260 const Expr *Message =
nullptr)
override;
272 bool ForceSimpleCall =
false)
override;
282 const Expr *Hint =
nullptr)
override;
302 ReductionOptionsTy Options)
override;
309 const VarDecl *NativeParam)
const override;
316 const VarDecl *TargetParam)
const override;
322 llvm::FunctionCallee OutlinedFn,
340 llvm::Value *&Chunk)
const override;
345 const Expr *&ChunkExpr)
const override;
366 ExecutionMode CurrentExecutionMode =
EM_Unknown;
374 bool IsInTTDRegion =
false;
377 llvm::DenseMap<llvm::Function *, llvm::Function *> WrapperFunctionsMap;
383 llvm::Function *createParallelDataSharingWrapper(
387 struct MappedVarData {
389 llvm::Value *GlobalizedVal =
nullptr;
394 using DeclToAddrMapTy = llvm::MapVector<const Decl *, MappedVarData>;
397 struct FunctionData {
398 DeclToAddrMapTy LocalVarData;
399 EscapedParamsTy EscapedParameters;
403 EscapedVariableLengthDeclsAddrs;
404 std::unique_ptr<CodeGenFunction::OMPMapVars> MappedParams;
408 llvm::SmallDenseMap<llvm::Function *, FunctionData> FunctionGlobalizedDecls;
413 llvm::SmallVector<const RecordDecl *, 4> TeamsReductions;
416 std::pair<const Decl *, llvm::SmallVector<const ValueDecl *, 4>>
This file defines OpenMP AST classes for executable directives and clauses.
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::Function * emitTeamsOutlinedFunction(CodeGenFunction &CGF, const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits inlined function for the specified OpenMP teams.
void emitProcBindClause(CodeGenFunction &CGF, llvm::omp::ProcBindKind ProcBind, SourceLocation Loc) override
Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32global_tid, int proc_bind) to generate...
void emitReduction(CodeGenFunction &CGF, SourceLocation Loc, ArrayRef< const Expr * > Privates, ArrayRef< const Expr * > LHSExprs, ArrayRef< const Expr * > RHSExprs, ArrayRef< const Expr * > ReductionOps, ReductionOptionsTy Options) override
Emit a code for reduction clause.
DataSharingMode
Target codegen is specialized based on two data-sharing modes: CUDA, in which the local variables are...
@ DS_CUDA
CUDA data sharing mode.
@ DS_Generic
Generic data-sharing mode.
void getDefaultDistScheduleAndChunk(CodeGenFunction &CGF, const OMPLoopDirective &S, OpenMPDistScheduleClauseKind &ScheduleKind, llvm::Value *&Chunk) const override
Choose a default value for the dist_schedule clause.
Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD) override
Gets the OpenMP-specific address of the local variable.
void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D) override
Emits OpenMP-specific function prolog.
bool isDefaultLocationConstant() const override
Check if the default location must be constant.
void getDefaultScheduleAndChunk(CodeGenFunction &CGF, const OMPLoopDirective &S, OpenMPScheduleClauseKind &ScheduleKind, const Expr *&ChunkExpr) const override
Choose a default value for the schedule clause.
void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams, const Expr *ThreadLimit, SourceLocation Loc) override
This function ought to emit, in the general case, a call to.
void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr) override
Emits a critical region.
void emitTeamsCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value * > CapturedVars) override
Emits code for teams call of the OutlinedFn with variables captured in a record which address is stor...
bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS) override
Checks if the variable has associated OMPAllocateDeclAttr attribute with the predefined allocator and...
void getKmpcFreeShared(CodeGenFunction &CGF, const std::pair< llvm::Value *, llvm::Value * > &AddrSizePair) override
Get call to __kmpc_free_shared.
CGOpenMPRuntimeGPU(CodeGenModule &CGM)
llvm::Function * emitParallelOutlinedFunction(CodeGenFunction &CGF, const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits inlined function for the specified OpenMP parallel.
void functionFinished(CodeGenFunction &CGF) override
Cleans up references to the objects in finished function.
llvm::Value * getGPUThreadID(CodeGenFunction &CGF)
Get the id of the current thread on the GPU.
void processRequiresDirective(const OMPRequiresDecl *D) override
Perform check on requires decl to ensure that target architecture supports unified addressing.
bool isDelayedVariableLengthDecl(CodeGenFunction &CGF, const VarDecl *VD) const override
Declare generalized virtual functions which need to be defined by all specializations of OpenMPGPURun...
void emitOutlinedFunctionCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::FunctionCallee OutlinedFn, ArrayRef< llvm::Value * > Args={}) const override
Emits call of the outlined function with the provided arguments, translating these arguments to corre...
Address getParameterAddress(CodeGenFunction &CGF, const VarDecl *NativeParam, const VarDecl *TargetParam) const override
Gets the address of the native argument basing on the address of the target-specific parameter.
ExecutionMode
Defines the execution mode.
@ EM_NonSPMD
Non-SPMD execution mode (1 master thread, others are workers).
@ EM_Unknown
Unknown execution mode (orphaned directive).
@ EM_SPMD
SPMD execution mode (all threads are worker threads).
void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false) override
Emit an implicit/explicit barrier for OpenMP threads.
llvm::Value * getGPUNumThreads(CodeGenFunction &CGF)
Get the maximum number of threads in a block of the GPU.
const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const override
Translates the native parameter of outlined function if this is required for target.
std::pair< llvm::Value *, llvm::Value * > getKmpcAllocShared(CodeGenFunction &CGF, const VarDecl *VD) override
Get call to __kmpc_alloc_shared.
bool isGPU() const override
Returns true if the current target is a GPU.
llvm::Value * emitSeverityClause(OpenMPSeverityClauseKind Severity, SourceLocation Loc) override
llvm::Value * emitMessageClause(CodeGenFunction &CGF, const Expr *Message, SourceLocation Loc) override
void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value * > CapturedVars, const Expr *IfCond, llvm::Value *NumThreads, OpenMPNumThreadsClauseModifier NumThreadsModifier=OMPC_NUMTHREADS_unknown, OpenMPSeverityClauseKind Severity=OMPC_SEVERITY_fatal, const Expr *Message=nullptr) override
Emits code for parallel or serial call of the OutlinedFn with variables captured in a record which ad...
void emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc, OpenMPNumThreadsClauseModifier Modifier=OMPC_NUMTHREADS_unknown, OpenMPSeverityClauseKind Severity=OMPC_SEVERITY_fatal, SourceLocation SeverityLoc=SourceLocation(), const Expr *Message=nullptr, SourceLocation MessageLoc=SourceLocation()) override
Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32global_tid, kmp_int32 num_threads) ...
void adjustTargetSpecificDataForLambdas(CodeGenFunction &CGF, const OMPExecutableDirective &D) const override
Adjust some parameters for the target-based directives, like addresses of the variables captured by r...
CGOpenMPRuntime(CodeGenModule &CGM)
virtual llvm::Value * emitMessageClause(CodeGenFunction &CGF, const Expr *Message, SourceLocation Loc)
virtual llvm::Value * emitSeverityClause(OpenMPSeverityClauseKind Severity, SourceLocation Loc)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a member of a struct/union/class.
This represents 'pragma omp requires...' directive.
Encodes a location in the source.
Represents a variable declaration or definition.
Top level wrappers for InstallAPI frontend operations.
Privates[]
This class represents the 'transparent' clause in the 'pragma omp task' directive.
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
LangAS
Defines the address space values used by the address space qualifier of QualType.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
OpenMPNumThreadsClauseModifier
@ OMPC_NUMTHREADS_unknown
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.