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);
65 CodeGenFunction &CGF);
69 EntryFunctionState &EST,
bool IsSPMD);
72 void emitKernelDeinit(CodeGenFunction &CGF, EntryFunctionState &EST,
76 void emitGenericVarsProlog(CodeGenFunction &CGF,
SourceLocation Loc);
79 void emitGenericVarsEpilog(CodeGenFunction &CGF);
95 llvm::Function *&OutlinedFn,
96 llvm::Constant *&OutlinedFnID,
bool IsOffloadEntry,
97 const RegionCodeGenTy &
CodeGen);
111 llvm::Function *&OutlinedFn,
112 llvm::Constant *&OutlinedFnID,
bool IsOffloadEntry,
113 const RegionCodeGenTy &
CodeGen);
125 StringRef ParentName,
126 llvm::Function *&OutlinedFn,
127 llvm::Constant *&OutlinedFnID,
129 const RegionCodeGenTy &
CodeGen)
override;
139 bool isGPU()
const override {
return true; };
147 const VarDecl *VD)
const override;
150 std::pair<llvm::Value *, llvm::Value *>
156 const std::pair<llvm::Value *, llvm::Value *> &AddrSizePair)
override;
167 llvm::omp::ProcBindKind ProcBind,
188 const Expr *Message =
nullptr,
259 llvm::Function *OutlinedFn,
261 const Expr *IfCond, llvm::Value *NumThreads,
265 const Expr *Message =
nullptr)
override;
277 bool ForceSimpleCall =
false)
override;
287 const Expr *Hint =
nullptr)
override;
307 ReductionOptionsTy Options)
override;
314 const VarDecl *NativeParam)
const override;
321 const VarDecl *TargetParam)
const override;
327 llvm::FunctionCallee OutlinedFn,
345 llvm::Value *&Chunk)
const override;
350 const Expr *&ChunkExpr)
const override;
371 ExecutionMode CurrentExecutionMode =
EM_Unknown;
379 bool IsInTTDRegion =
false;
382 llvm::DenseMap<llvm::Function *, llvm::Function *> WrapperFunctionsMap;
388 llvm::Function *createParallelDataSharingWrapper(
392 struct MappedVarData {
394 llvm::Value *GlobalizedVal =
nullptr;
399 using DeclToAddrMapTy = llvm::MapVector<const Decl *, MappedVarData>;
402 struct FunctionData {
403 DeclToAddrMapTy LocalVarData;
404 EscapedParamsTy EscapedParameters;
408 EscapedVariableLengthDeclsAddrs;
409 std::unique_ptr<CodeGenFunction::OMPMapVars> MappedParams;
413 llvm::SmallDenseMap<llvm::Function *, FunctionData> FunctionGlobalizedDecls;
418 llvm::SmallVector<const RecordDecl *, 4> TeamsReductions;
421 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.