clang 8.0.0

Classes | Enumerations | Functions
CGOpenMPRuntimeNVPTX.cpp File Reference
`#include "CGOpenMPRuntimeNVPTX.h"`
`#include "CodeGenFunction.h"`
`#include "clang/AST/DeclOpenMP.h"`
`#include "clang/AST/StmtOpenMP.h"`
`#include "clang/AST/StmtVisitor.h"`
`#include "clang/Basic/Cuda.h"`
`#include "llvm/ADT/SmallPtrSet.h"`
Include dependency graph for CGOpenMPRuntimeNVPTX.cpp:

Go to the source code of this file.

## Classes
struct | CopyOptionsTy

## Enumerations
enum | OpenMPRTLFunctionNVPTX
enum | MachineConfiguration : unsigned
| GPU Configuration: This information can be derived from cuda registers, however, providing compile time constants helps generate more efficient code. More...
enum | ModeFlagsTy : unsigned
| Enum for accesseing the reserved_2 field of the ident_t struct. More...
enum | CopyAction : unsigned

## Functions
static llvm::Value * | getNVPTXWarpSize (CodeGenFunction &CGF)
| Get the GPU warp size. More...
static llvm::Value * | getNVPTXThreadID (CodeGenFunction &CGF)
| Get the id of the current thread on the GPU. More...
static llvm::Value * | getNVPTXWarpID (CodeGenFunction &CGF)
| Get the id of the warp in the block. More...
static llvm::Value * | getNVPTXLaneID (CodeGenFunction &CGF)
| Get the id of the current lane in the Warp. More...
static llvm::Value * | getNVPTXNumThreads (CodeGenFunction &CGF)
| Get the maximum number of threads in a block of the GPU. More...
static llvm::Value * | getThreadLimit (CodeGenFunction &CGF, bool IsInSPMDExecutionMode=false)
| Get the value of the thread_limit clause in the teams directive. More...
static llvm::Value * | getMasterThreadID (CodeGenFunction &CGF)
| Get the thread id of the OMP master thread. More...
static CGOpenMPRuntimeNVPTX::DataSharingMode | getDataSharingMode (CodeGenModule &CGM)
static bool | isTrivial (ASTContext &Ctx, const Expr *E)
| Checks if the expression is constant or does not have non-trivial function calls. More...
static const Stmt * | getSingleCompoundChild (ASTContext &Ctx, const Stmt *Body)
| Checks if the `Body` is the CompoundStmt and returns its child statement iff there is only one that is not evaluatable at the compile time. More...
static bool | hasParallelIfNumThreadsClause (ASTContext &Ctx, const OMPExecutableDirective &D)
| Check if the parallel directive has an 'if' clause with non-constant or false condition. More...
static bool | hasNestedSPMDDirective (ASTContext &Ctx, const OMPExecutableDirective &D)
| Check for inner (nested) SPMD construct, if any. More...
static bool | supportsSPMDExecutionMode (ASTContext &Ctx, const OMPExecutableDirective &D)
static bool | hasStaticScheduling (const OMPExecutableDirective &D)
| Check if the directive is loops based and has schedule clause at all or has static scheduling. More...
static bool | hasNestedLightweightDirective (ASTContext &Ctx, const OMPExecutableDirective &D)
| Check for inner (nested) lightweight runtime construct, if any. More...
static bool | supportsLightweightRuntime (ASTContext &Ctx, const OMPExecutableDirective &D)
| Checks if the construct supports lightweight runtime. More...
static void | setPropertyExecutionMode (CodeGenModule &CGM, StringRef Name, bool Mode)
static void | getDistributeLastprivateVars (ASTContext &Ctx, const OMPExecutableDirective &D, llvm::SmallVectorImpl< const ValueDecl *> &Vars)
| Get list of lastprivate variables from the teams distribute ... More...
static void | getTeamsReductionVars (ASTContext &Ctx, const OMPExecutableDirective &D, llvm::SmallVectorImpl< const ValueDecl *> &Vars)
| Get list of reduction variables from the teams ... directives. More...
static llvm::Value * | castValueToType (CodeGenFunction &CGF, llvm::Value *Val, QualType ValTy, QualType CastTy, SourceLocation Loc)
| Cast value to the specified type. More...
static llvm::Value * | createRuntimeShuffleFunction (CodeGenFunction &CGF, llvm::Value *Elem, QualType ElemType, llvm::Value *Offset, SourceLocation Loc)
| This function creates calls to one of two shuffle functions to copy variables between lanes in a warp. More...
static void | shuffleAndStore (CodeGenFunction &CGF, Address SrcAddr, Address DestAddr, QualType ElemType, llvm::Value *Offset, SourceLocation Loc)
static void | emitReductionListCopy (CopyAction Action, CodeGenFunction &CGF, QualType ReductionArrayTy, ArrayRef< const Expr *> Privates, Address SrcBase, Address DestBase, CopyOptionsTy CopyOptions={nullptr, nullptr, nullptr})
| Emit instructions to copy a Reduce list, which contains partially aggregated values, in the specified direction. More...
static llvm::Value * | emitInterWarpCopyFunction (CodeGenModule &CGM, ArrayRef< const Expr *> Privates, QualType ReductionArrayTy, SourceLocation Loc)
| This function emits a helper that gathers Reduce lists from the first lane of every active warp to lanes in the first warp. More...
static llvm::Value * | emitShuffleAndReduceFunction (CodeGenModule &CGM, ArrayRef< const Expr *> Privates, QualType ReductionArrayTy, llvm::Value *ReduceFn, SourceLocation Loc)
| Emit a helper that reduces data across two OpenMP threads (lanes) in the same warp. More...
static CudaArch | getCudaArch (CodeGenModule &CGM)
static std::pair< unsigned, unsigned > | getSMsBlocksPerSM (CodeGenModule &CGM)
| Get number of SMs and number of blocks per SM. More...

## Enumeration Type Documentation

## ◆ CopyAction

enum CopyAction : unsigned

Definition at line 2906 of file CGOpenMPRuntimeNVPTX.cpp.

## ◆ MachineConfiguration

enum MachineConfiguration : unsigned

GPU Configuration: This information can be derived from cuda registers, however, providing compile time constants helps generate more efficient code.

For all practical purposes this is fine because the configuration is the same for all known NVPTX architectures.

Definition at line 182 of file CGOpenMPRuntimeNVPTX.cpp.

## ◆ ModeFlagsTy

enum ModeFlagsTy : unsigned

Enum for accesseing the reserved_2 field of the ident_t struct.

Definition at line 1872 of file CGOpenMPRuntimeNVPTX.cpp.

## ◆ OpenMPRTLFunctionNVPTX

enum OpenMPRTLFunctionNVPTX

Definition at line 27 of file CGOpenMPRuntimeNVPTX.cpp.

## Function Documentation

## ◆ castValueToType()

static llvm::Value* castValueToType | ( | CodeGenFunction & | CGF,
|  | llvm::Value * | Val,
|  | QualType | ValTy,
|  | QualType | CastTy,
|  | SourceLocation | Loc
| ) |  |
| static

Cast value to the specified type.

Definition at line 2774 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::CodeGen::CGBuilderTy::CreateBitCast(), clang::CodeGen::CodeGenFunction::CreateMemTemp(), clang::CodeGen::CGBuilderTy::CreatePointerBitCastOrAddrSpaceCast(), clang::CodeGen::CodeGenFunction::EmitLoadOfScalar(), clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(), clang::CodeGen::Address::getAddressSpace(), clang::CodeGen::CodeGenFunction::getContext(), clang::CodeGen::Address::getType(), clang::ASTContext::getTypeSizeInChars(), clang::Type::hasSignedIntegerRepresentation(), clang::Type::isIntegerType(), clang::CharUnits::isZero(), and clang::CodeGen::Type.

Referenced by createRuntimeShuffleFunction(), and clang::CodeGen::CGOpenMPRuntimeNVPTX::emitOutlinedFunctionCall().

## ◆ createRuntimeShuffleFunction()

static llvm::Value* createRuntimeShuffleFunction | ( | CodeGenFunction & | CGF,
|  | llvm::Value * | Elem,
|  | QualType | ElemType,
|  | llvm::Value * | Offset,
|  | SourceLocation | Loc
| ) |  |
| static

This function creates calls to one of two shuffle functions to copy variables between lanes in a warp.

Definition at line 2799 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::Builder, castValueToType(), clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CGOpenMPRuntimeNVPTX::createNVPTXRuntimeFunction(), clang::CodeGen::CodeGenFunction::EmitRuntimeCall(), clang::CodeGen::CodeGenFunction::getContext(), clang::ASTContext::getIntTypeForBitwidth(), getNVPTXWarpSize(), clang::CodeGen::CodeGenModule::getOpenMPRuntime(), clang::CharUnits::getQuantity(), clang::ASTContext::getTypeSizeInChars(), clang::CodeGen::CodeGenTypeCache::Int16Ty, and Offset.

Referenced by shuffleAndStore().

## ◆ emitInterWarpCopyFunction()

static llvm::Value* emitInterWarpCopyFunction | ( | CodeGenModule & | CGM,
|  | ArrayRef< const Expr *> | Privates,
|  | QualType | ReductionArrayTy,
|  | SourceLocation | Loc
| ) |  |
| static

This function emits a helper that gathers Reduce lists from the first lane of every active warp to lanes in the first warp.

void inter_warp_copy_func(void* reduce_data, num_warps) shared smem[warp_size]; For all data entries D in reduce_data: sync If (I am the first lane in each warp) Copy my local D to smem[warp_id] sync if (I am the first warp) Copy smem[thread_id] to my local D

Definition at line 3127 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenModule::addCompilerUsedGlobal(), clang::CodeGen::CodeGenTypes::arrangeBuiltinFunctionDeclaration(), clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::Create(), clang::CodeGen::CodeGenFunction::createBasicBlock(), clang::CodeGen::ApplyDebugLocation::CreateEmpty(), clang::CodeGen::CodeGenFunction::CreateMemTemp(), clang::CodeGen::CGBuilderTy::CreatePointerBitCastOrAddrSpaceCast(), clang::cuda_shared, clang::CodeGen::CodeGenFunction::EmitBlock(), clang::CodeGen::CodeGenFunction::EmitLoadOfScalar(), clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(), clang::CharUnits::fromQuantity(), clang::CodeGen::CodeGenFunction::GetAddrOfLocalVar(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenTypes::GetFunctionType(), clang::ASTContext::getIntTypeForBitwidth(), clang::CodeGen::CodeGenModule::getModule(), getNVPTXLaneID(), getNVPTXThreadID(), getNVPTXWarpID(), clang::CodeGen::CodeGenTypeCache::getPointerAlign(), clang::CharUnits::getQuantity(), clang::ASTContext::getTargetAddressSpace(), clang::ASTContext::getTypeAlignInChars(), clang::CodeGen::CodeGenModule::getTypes(), clang::ASTContext::getTypeSizeInChars(), clang::CodeGen::CodeGenTypeCache::Int32Ty, clang::InternalLinkage, clang::CodeGen::CodeGenTypeCache::IntTy, clang::ASTContext::IntTy, clang::CodeGen::Address::invalid(), clang::ImplicitParamDecl::Other, clang::CodeGen::CodeGenModule::SetInternalFunctionAttributes(), clang::CodeGen::CodeGenFunction::StartFunction(), clang::ASTContext::toBits(), clang::CodeGen::Type, clang::ASTContext::VoidPtrTy, and clang::ASTContext::VoidTy.

## ◆ emitReductionListCopy()

static void emitReductionListCopy | ( | CopyAction | Action,
|  | CodeGenFunction & | CGF,
|  | QualType | ReductionArrayTy,
|  | ArrayRef< const Expr *> | Privates,
|  | Address | SrcBase,
|  | Address | DestBase,
|  | CopyOptionsTy | CopyOptions = `{nullptr, nullptr, nullptr}`
| ) |  |
| static

Emit instructions to copy a Reduce list, which contains partially aggregated values, in the specified direction.

Definition at line 2928 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::CodeGen::CGBuilderTy::CreateConstArrayGEP(), clang::CodeGen::CGBuilderTy::CreateElementBitCast(), clang::CodeGen::CodeGenFunction::CreateMemTemp(), clang::CodeGen::CGBuilderTy::CreatePointerBitCastOrAddrSpaceCast(), clang::CodeGen::AggValueSlot::DoesNotOverlap, clang::CodeGen::CodeGenFunction::EmitAggregateCopy(), clang::CodeGen::CodeGenFunction::EmitLoadOfPointer(), clang::CodeGen::CodeGenFunction::EmitLoadOfScalar(), clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::Address::getElementType(), clang::CodeGen::Address::getPointer(), clang::CodeGen::CodeGenTypeCache::getPointerAlign(), clang::CodeGen::CodeGenTypeCache::getPointerSize(), clang::ASTContext::getPointerType(), clang::CodeGen::Address::getType(), clang::CodeGen::LValue::getType(), clang::ASTContext::getTypeAlignInChars(), clang::CodeGen::CodeGenFunction::getTypeSize(), clang::CodeGen::Address::invalid(), clang::CodeGen::CodeGenFunction::MakeAddrLValue(), shuffleAndStore(), clang::CodeGen::CodeGenTypeCache::SizeTy, clang::CodeGen::CodeGenTypeCache::VoidPtrTy, and clang::ASTContext::VoidPtrTy.

Referenced by emitShuffleAndReduceFunction().

## ◆ emitShuffleAndReduceFunction()

static llvm::Value* emitShuffleAndReduceFunction | ( | CodeGenModule & | CGM,
|  | ArrayRef< const Expr *> | Privates,
|  | QualType | ReductionArrayTy,
|  | llvm::Value * | ReduceFn,
|  | SourceLocation | Loc
| ) |  |
| static

Emit a helper that reduces data across two OpenMP threads (lanes) in the same warp.

It uses shuffle instructions to copy over data from a remote lane's stack. The reduction algorithm performed is specified by the fourth parameter.

Algorithm Versions. Full Warp Reduce (argument value 0): This algorithm assumes that all 32 lanes are active and gathers data from these 32 lanes, producing a single resultant value. Contiguous Partial Warp Reduce (argument value 1): This algorithm assumes that only a contiguous subset of lanes are active. This happens for the last warp in a parallel region when the user specified num_threads is not an integer multiple of

1. This contiguous subset always starts with the zeroth lane. Partial Warp Reduce (argument value 2): This algorithm gathers data from any number of lanes at any position. All reduced values are stored in the lowest possible lane. The set of problems every algorithm addresses is a super set of those addressable by algorithms with a lower version number. Overhead increases as algorithm version increases.

Terminology Reduce element: Reduce element refers to the individual data field with primitive data types to be combined and reduced across threads. Reduce list: Reduce list refers to a collection of local, thread-private reduce elements. Remote Reduce list: Remote Reduce list refers to a collection of remote (relative to the current thread) reduce elements.

We distinguish between three states of threads that are important to the implementation of this function. Alive threads: Threads in a warp executing the SIMT instruction, as distinguished from threads that are inactive due to divergent control flow. Active threads: The minimal set of threads that has to be alive upon entry to this function. The computation is correct iff active threads are alive. Some threads are alive but they are not active because they do not contribute to the computation in any useful manner. Turning them off may introduce control flow overheads without any tangible benefits. Effective threads: In order to comply with the argument requirements of the shuffle function, we must keep all lanes holding data alive. But at most half of them perform value aggregation; we refer to this half of threads as effective. The other half is simply handing off their data.

Procedure Value shuffle: In this step active threads transfer data from higher lane positions in the warp to lower lane positions, creating Remote Reduce list. Value aggregation: In this step, effective threads combine their thread local Reduce list with Remote Reduce list and store the result in the thread local Reduce list. Value copy: In this step, we deal with the assumption made by algorithm 2 (i.e. contiguity assumption). When we have an odd number of lanes active, say 2k+1, only k threads will be effective and therefore k new values will be produced. However, the Reduce list owned by the (2k+1)th thread is ignored in the value aggregation. Therefore we copy the Reduce list from the (2k+1)th lane to (k+1)th lane so that the contiguity assumption still holds.

Definition at line 3421 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenTypes::arrangeBuiltinFunctionDeclaration(), clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::Create(), clang::CodeGen::CodeGenFunction::createBasicBlock(), clang::CodeGen::CodeGenFunction::CreateMemTemp(), clang::CodeGen::CGBuilderTy::CreatePointerBitCastOrAddrSpaceCast(), clang::CodeGen::CodeGenFunction::EmitBlock(), clang::CodeGen::CodeGenFunction::EmitLoadOfScalar(), emitReductionListCopy(), clang::CodeGen::CodeGenFunction::FinishFunction(), clang::CodeGen::CodeGenFunction::GetAddrOfLocalVar(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenTypes::GetFunctionType(), clang::CodeGen::CodeGenModule::getModule(), clang::CodeGen::CodeGenModule::getOpenMPRuntime(), clang::CodeGen::Address::getPointer(), clang::CodeGen::CodeGenTypeCache::getPointerAlign(), clang::CodeGen::CodeGenModule::getTypes(), clang::InternalLinkage, clang::ImplicitParamDecl::Other, clang::CodeGen::CodeGenModule::SetInternalFunctionAttributes(), clang::ASTContext::ShortTy, clang::CodeGen::CodeGenFunction::StartFunction(), clang::CodeGen::CodeGenTypeCache::VoidPtrTy, clang::ASTContext::VoidPtrTy, and clang::ASTContext::VoidTy.

## ◆ getCudaArch()

static CudaArch getCudaArch | ( | CodeGenModule & | CGM | ) |
| static

Definition at line 4378 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::TargetOptions::CPU, clang::TargetOptions::Features, clang::CodeGen::CodeGenModule::getDiags(), clang::CodeGen::CodeGenModule::getTarget(), clang::TargetInfo::getTargetOpts(), clang::TargetInfo::hasFeature(), clang::TargetInfo::initFeatureMap(), clang::StringToCudaArch(), and clang::UNKNOWN.

Referenced by clang::CodeGen::CGOpenMPRuntimeNVPTX::checkArchForUnifiedAddressing(), and getSMsBlocksPerSM().

## ◆ getDataSharingMode()

static CGOpenMPRuntimeNVPTX::DataSharingMode getDataSharingMode | ( | CodeGenModule & | CGM | ) |
| static

Definition at line 703 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CGOpenMPRuntimeNVPTX::CUDA, clang::CodeGen::CGOpenMPRuntimeNVPTX::Generic, and clang::CodeGen::CodeGenModule::getLangOpts().

Referenced by clang::CodeGen::CGOpenMPRuntimeNVPTX::emitFunctionProlog(), clang::CodeGen::CGOpenMPRuntimeNVPTX::emitTeamsOutlinedFunction(), and clang::CodeGen::CGOpenMPRuntimeNVPTX::getAddressOfLocalVariable().

## ◆ getDistributeLastprivateVars()

static void getDistributeLastprivateVars | ( | ASTContext & | Ctx,
|  | const OMPExecutableDirective & | D,
|  | llvm::SmallVectorImpl< const ValueDecl *> & | Vars
| ) |  |
| static

Get list of lastprivate variables from the teams distribute ...

or teams {distribute ...} directives.

Definition at line 1973 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::OMPExecutableDirective::getDirectiveKind(), clang::isOpenMPDistributeDirective(), and clang::isOpenMPTeamsDirective().

Referenced by clang::CodeGen::CGOpenMPRuntimeNVPTX::emitTeamsOutlinedFunction().

## ◆ getMasterThreadID()

static llvm::Value* getMasterThreadID | ( | CodeGenFunction & | CGF | ) |
| static

Get the thread id of the OMP master thread.

The master thread id is the first thread (lane) of the last warp in the GPU block. Warp size is assumed to be some power of 2. Thread id is 0 indexed. E.g: If NumThreads is 33, master id is 32. If NumThreads is 64, master id is 32. If NumThreads is 1024, master id is 992.

Definition at line 668 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenTypes::arrangeNullaryFunction(), clang::CodeGen::CodeGenFunction::Builder, clang::Create(), clang::CodeGen::CodeGenTypes::GetFunctionType(), clang::CodeGen::CodeGenModule::getModule(), getNVPTXNumThreads(), getNVPTXWarpSize(), clang::CodeGen::CodeGenModule::getTypes(), clang::InternalLinkage, and clang::CodeGen::CodeGenModule::SetInternalFunctionAttributes().

Referenced by supportsLightweightRuntime().

## ◆ getNVPTXLaneID()

static llvm::Value* getNVPTXLaneID | ( | CodeGenFunction & | CGF | ) |
| static

Get the id of the current lane in the Warp.

We assume that the warp size is 32, which is always the case on the NVPTX device, to generate more efficient code.

Definition at line 633 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::Builder, and getNVPTXThreadID().

Referenced by emitInterWarpCopyFunction(), and clang::CodeGen::CGOpenMPRuntimeNVPTX::emitTeamsOutlinedFunction().

## ◆ getNVPTXNumThreads()

static llvm::Value* getNVPTXNumThreads | ( | CodeGenFunction & | CGF | ) |
| static

Get the maximum number of threads in a block of the GPU.

Definition at line 640 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::EmitRuntimeCall(), and clang::CodeGen::CodeGenModule::getModule().

Referenced by clang::CodeGen::CGOpenMPRuntimeNVPTX::emitCriticalRegion(), getMasterThreadID(), and getThreadLimit().

## ◆ getNVPTXThreadID()

static llvm::Value* getNVPTXThreadID | ( | CodeGenFunction & | CGF | ) |
| static

Get the id of the current thread on the GPU.

Definition at line 615 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::EmitRuntimeCall(), and clang::CodeGen::CodeGenModule::getModule().

Referenced by clang::CodeGen::CGOpenMPRuntimeNVPTX::emitCriticalRegion(), emitInterWarpCopyFunction(), getNVPTXLaneID(), getNVPTXWarpID(), and supportsLightweightRuntime().

## ◆ getNVPTXWarpID()

static llvm::Value* getNVPTXWarpID | ( | CodeGenFunction & | CGF | ) |
| static

Get the id of the warp in the block.

We assume that the warp size is 32, which is always the case on the NVPTX device, to generate more efficient code.

Definition at line 625 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::Builder, and getNVPTXThreadID().

Referenced by emitInterWarpCopyFunction().

## ◆ getNVPTXWarpSize()

static llvm::Value* getNVPTXWarpSize | ( | CodeGenFunction & | CGF | ) |
| static

Get the GPU warp size.

Definition at line 607 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::EmitRuntimeCall(), and clang::CodeGen::CodeGenModule::getModule().

Referenced by createRuntimeShuffleFunction(), getMasterThreadID(), and getThreadLimit().

## ◆ getSingleCompoundChild()

static const Stmt* getSingleCompoundChild | ( | ASTContext & | Ctx,
|  | const Stmt * | Body
| ) |  |
| static

Checks if the `Body` is the CompoundStmt and returns its child statement iff there is only one that is not evaluatable at the compile time.

Definition at line 720 of file CGOpenMPRuntimeNVPTX.cpp.

Referenced by hasNestedLightweightDirective(), and hasNestedSPMDDirective().

## ◆ getSMsBlocksPerSM()

static std::pair<unsigned, unsigned> getSMsBlocksPerSM | ( | CodeGenModule & | CGM | ) |
| static

Get number of SMs and number of blocks per SM.

Definition at line 4446 of file CGOpenMPRuntimeNVPTX.cpp.

References getCudaArch(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::GFX600, clang::GFX601, clang::GFX700, clang::GFX701, clang::GFX702, clang::GFX703, clang::GFX704, clang::GFX801, clang::GFX802, clang::GFX803, clang::GFX810, clang::GFX900, clang::GFX902, clang::GFX904, clang::GFX906, clang::GFX909, clang::LAST, clang::SM_20, clang::SM_21, clang::SM_30, clang::SM_32, clang::SM_35, clang::SM_37, clang::SM_50, clang::SM_52, clang::SM_53, clang::SM_60, clang::SM_61, clang::SM_62, clang::SM_70, clang::SM_72, clang::SM_75, and clang::UNKNOWN.

Referenced by clang::CodeGen::CGOpenMPRuntimeNVPTX::clear().

## ◆ getTeamsReductionVars()

static void getTeamsReductionVars | ( | ASTContext & | Ctx,
|  | const OMPExecutableDirective & | D,
|  | llvm::SmallVectorImpl< const ValueDecl *> & | Vars
| ) |  |
| static

Get list of reduction variables from the teams ... directives.

Definition at line 1998 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::OMPExecutableDirective::getClausesOfKind(), clang::OMPExecutableDirective::getDirectiveKind(), getPrivateItem(), and clang::isOpenMPTeamsDirective().

Referenced by clang::CodeGen::CGOpenMPRuntimeNVPTX::emitTeamsOutlinedFunction().

## ◆ getThreadLimit()

static llvm::Value* getThreadLimit | ( | CodeGenFunction & | CGF,
|  | bool | IsInSPMDExecutionMode = `false`
| ) |  |
| static

Get the value of the thread_limit clause in the teams directive.

For the 'generic' execution mode, the runtime encodes thread_limit in the launch parameters, always starting thread_limit+warpSize threads per CTA. The threads in the last warp are reserved for master execution. For the 'spmd' execution mode, all threads in a CTA are part of the team.

Definition at line 652 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::Builder, getNVPTXNumThreads(), and getNVPTXWarpSize().

Referenced by supportsLightweightRuntime().

## ◆ hasNestedLightweightDirective()

static bool hasNestedLightweightDirective | ( | ASTContext & | Ctx,
|  | const OMPExecutableDirective & | D
| ) |  |
| static

Check for inner (nested) lightweight runtime construct, if any.

Definition at line 955 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CapturedStmt::getCapturedStmt(), clang::OMPExecutableDirective::getDirectiveKind(), clang::OMPExecutableDirective::getInnermostCapturedStmt(), getSingleCompoundChild(), hasStaticScheduling(), clang::Stmt::IgnoreContainers(), clang::isOpenMPLoopDirective(), clang::isOpenMPParallelDirective(), clang::isOpenMPWorksharingDirective(), clang::OMPD_unknown, and supportsSPMDExecutionMode().

Referenced by supportsLightweightRuntime().

## ◆ hasNestedSPMDDirective()

static bool hasNestedSPMDDirective | ( | ASTContext & | Ctx,
|  | const OMPExecutableDirective & | D
| ) |  |
| static

Check for inner (nested) SPMD construct, if any.

Definition at line 783 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CapturedStmt::getCapturedStmt(), clang::OMPExecutableDirective::getDirectiveKind(), clang::OMPExecutableDirective::getInnermostCapturedStmt(), getSingleCompoundChild(), hasParallelIfNumThreadsClause(), clang::Stmt::IgnoreContainers(), clang::isOpenMPParallelDirective(), and clang::OMPD_unknown.

Referenced by supportsSPMDExecutionMode().

## ◆ hasParallelIfNumThreadsClause()

static bool hasParallelIfNumThreadsClause | ( | ASTContext & | Ctx,
|  | const OMPExecutableDirective & | D
| ) |  |
| static

Check if the parallel directive has an 'if' clause with non-constant or false condition.

Also, check if the number of threads is strictly specified and run those directives in non-SPMD mode.

Definition at line 766 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::Expr::EvaluateAsBooleanCondition(), clang::OMPExecutableDirective::getClausesOfKind(), clang::OMPExecutableDirective::hasClausesOfKind(), and clang::OMPD_unknown.

Referenced by hasNestedSPMDDirective(), and supportsSPMDExecutionMode().

## ◆ hasStaticScheduling()

static bool hasStaticScheduling | ( | const OMPExecutableDirective & | D | ) |
| static

Check if the directive is loops based and has schedule clause at all or has static scheduling.

Definition at line 942 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::OMPExecutableDirective::getClausesOfKind(), clang::OMPExecutableDirective::getDirectiveKind(), clang::OMPExecutableDirective::hasClausesOfKind(), clang::isOpenMPLoopDirective(), and clang::isOpenMPWorksharingDirective().

Referenced by hasNestedLightweightDirective(), and supportsLightweightRuntime().

## ◆ isTrivial()

static bool isTrivial | ( | ASTContext & | Ctx,
|  | const Expr * | E
| ) |  |
| static

Checks if the expression is constant or does not have non-trivial function calls.

Definition at line 710 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::Expr::hasNonTrivialCall(), clang::Expr::HasSideEffects(), clang::Expr::isEvaluatable(), and clang::Expr::SE_AllowUndefinedBehavior.

## ◆ setPropertyExecutionMode()

static void setPropertyExecutionMode | ( | CodeGenModule & | CGM,
|  | StringRef | Name,
|  | bool | Mode
| ) |  |
| static

Definition at line 1406 of file CGOpenMPRuntimeNVPTX.cpp.

Referenced by clang::CodeGen::CGOpenMPRuntimeNVPTX::createNVPTXRuntimeFunction().

## ◆ shuffleAndStore()

static void shuffleAndStore | ( | CodeGenFunction & | CGF,
|  | Address | SrcAddr,
|  | Address | DestAddr,
|  | QualType | ElemType,
|  | llvm::Value * | Offset,
|  | SourceLocation | Loc
| ) |  |
| static

Definition at line 2830 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::ConvertTypeForMem(), clang::CodeGen::CodeGenFunction::createBasicBlock(), clang::CodeGen::CGBuilderTy::CreateConstGEP(), clang::CodeGen::CGBuilderTy::CreatePointerBitCastOrAddrSpaceCast(), createRuntimeShuffleFunction(), clang::CodeGen::CodeGenFunction::EmitBlock(), clang::CodeGen::CodeGenFunction::EmitBranch(), clang::CodeGen::CodeGenFunction::EmitLoadOfScalar(), clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(), clang::CharUnits::fromQuantity(), clang::CodeGen::Address::getAlignment(), clang::CodeGen::CodeGenFunction::getContext(), clang::ASTContext::getIntTypeForBitwidth(), clang::CodeGen::Address::getPointer(), clang::CharUnits::getQuantity(), clang::CodeGen::Address::getType(), clang::ASTContext::getTypeSizeInChars(), Offset, clang::ASTContext::toBits(), clang::CodeGen::Type, and clang::CodeGen::CodeGenTypeCache::VoidPtrTy.

Referenced by emitReductionListCopy().

## ◆ supportsLightweightRuntime()

static bool supportsLightweightRuntime | ( | ASTContext & | Ctx,
|  | const OMPExecutableDirective & | D
| ) |  |
| static

Checks if the construct supports lightweight runtime.

It must be SPMD construct + inner loop-based construct with static scheduling.

Definition at line 1093 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CGOpenMPRuntime::clearLocThreadIdInsertPt(), clang::CodeGen::CodeGenFunction::createBasicBlock(), clang::cuda_shared, clang::CodeGen::CodeGenFunction::EmitBlock(), clang::CodeGen::CodeGenFunction::EmitBranch(), clang::CodeGen::CodeGenFunction::EmitRuntimeCall(), clang::OMPExecutableDirective::getBeginLoc(), clang::CodeGen::CodeGenModule::getContext(), clang::OMPExecutableDirective::getDirectiveKind(), clang::CodeGen::CodeGenModule::getLangOpts(), getMasterThreadID(), clang::CodeGen::CodeGenModule::getModule(), getNVPTXThreadID(), clang::CodeGen::CodeGenModule::getOpenMPRuntime(), clang::ASTContext::getTargetAddressSpace(), getThreadLimit(), hasNestedLightweightDirective(), hasStaticScheduling(), clang::CodeGen::CodeGenFunction::HaveInsertPoint(), clang::InternalLinkage, clang::OMPD_unknown, clang::CodeGen::RegionCodeGenTy::setAction(), clang::CodeGen::CGOpenMPRuntime::setLocThreadIdInsertPt(), supportsSPMDExecutionMode(), and clang::CodeGen::CodeGenTypeCache::VoidPtrTy.

## ◆ supportsSPMDExecutionMode()

static bool supportsSPMDExecutionMode | ( | ASTContext & | Ctx,
|  | const OMPExecutableDirective & | D
| ) |  |
| static

Definition at line 873 of file CGOpenMPRuntimeNVPTX.cpp.

References clang::OMPExecutableDirective::getDirectiveKind(), hasNestedSPMDDirective(), hasParallelIfNumThreadsClause(), and clang::OMPD_unknown.

Referenced by clang::CodeGen::CGOpenMPRuntimeNVPTX::createNVPTXRuntimeFunction(), hasNestedLightweightDirective(), and supportsLightweightRuntime().