LLVM  13.0.0git
Classes | Typedefs | Enumerations | Functions | Variables
llvm::omp Namespace Reference

Classes

struct  AssumptionClauseMappingInfo
 Helper to describe assume clauses. More...
 
struct  OMPContext
 The context for a source location is made up of active property traits, e.g., device={kind(host)}, and constructs traits which describe the nesting in OpenMP constructs at the location. More...
 
struct  OpenMPInModule
 Helper to remember if the module contains OpenMP (runtime calls), to be used foremost with containsOpenMP. More...
 
struct  VariantMatchInfo
 Variant match information describes the required traits and how they are scored (via the ScoresMap). More...
 

Typedefs

using Kernel = Function *
 Summary of a kernel (=entry point for target offloading). More...
 

Enumerations

enum  InternalControlVar { InternalControlVar::ICV_DATA_ENV }
 IDs for all Internal Control Variables (ICVs). More...
 
enum  ICVInitValue { ICVInitValue::ICV_INIT_VALUE }
 
enum  RuntimeFunction { RuntimeFunction::OMP_RTL }
 IDs for all omp runtime library (RTL) functions. More...
 
enum  DefaultKind { DefaultKind::OMP_DEFAULT_KIND }
 IDs for the different default kinds. More...
 
enum  IdentFlag { IdentFlag::OMP_IDENT_FLAG }
 IDs for all omp runtime library ident_t flag encodings (see their defintion in openmp/runtime/src/kmp.h). More...
 
enum  OMPScheduleType {
  OMPScheduleType::Static = 34, OMPScheduleType::DynamicChunked = 35, OMPScheduleType::GuidedChunked = 36, OMPScheduleType::Runtime = 37,
  OMPScheduleType::Auto = 38, OMPScheduleType::ModifierNonmonotonic
}
 
enum  TraitSet { TraitSet::OMP_TRAIT_SET }
 OpenMP Context related IDs and helpers. More...
 
enum  TraitSelector { TraitSelector::OMP_TRAIT_SELECTOR }
 IDs for all OpenMP context selector trait (device={kind/isa...}/...). More...
 
enum  TraitProperty { TraitProperty::OMP_TRAIT_PROPERTY, TraitProperty::OMP_LAST_TRAIT_PROPERTY }
 IDs for all OpenMP context trait properties (host/gpu/bsc/llvm/...) More...
 
enum  GVIDX {
  GV_Threads, GV_Slot_Size, GV_Warp_Size, GV_Warp_Size_32,
  GV_Warp_Size_Log2, GV_Warp_Slot_Size, GV_Max_Teams, GV_Mem_Align,
  GV_Warp_Size_Log2_Mask, GV_SimpleBufferSize, GV_Max_WG_Size, GV_Default_WG_Size,
  GV_Max_Warp_Number, GV_Warp_Size_Log2_MaskL
}
 Defines various target-specific GPU grid values that must be consistent between host RTL (plugin), device RTL, and clang. More...
 

Functions

 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE ()
 
std::string getAllAssumeClauseOptions ()
 
TraitSet getOpenMPContextTraitSetKind (StringRef Str)
 Parse Str and return the trait set it matches or TraitSet::invalid. More...
 
TraitSet getOpenMPContextTraitSetForSelector (TraitSelector Selector)
 Return the trait set for which Selector is a selector. More...
 
TraitSet getOpenMPContextTraitSetForProperty (TraitProperty Property)
 Return the trait set for which Property is a property. More...
 
StringRef getOpenMPContextTraitSetName (TraitSet Kind)
 Return a textual representation of the trait set Kind. More...
 
TraitSelector getOpenMPContextTraitSelectorKind (StringRef Str)
 Parse Str and return the trait set it matches or TraitSelector::invalid. More...
 
TraitSelector getOpenMPContextTraitSelectorForProperty (TraitProperty Property)
 Return the trait selector for which Property is a property. More...
 
StringRef getOpenMPContextTraitSelectorName (TraitSelector Kind)
 Return a textual representation of the trait selector Kind. More...
 
TraitProperty getOpenMPContextTraitPropertyKind (TraitSet Set, TraitSelector Selector, StringRef Str)
 Parse Str and return the trait property it matches in the set Set and selector Selector or TraitProperty::invalid. More...
 
TraitProperty getOpenMPContextTraitPropertyForSelector (TraitSelector Selector)
 Return the trait property for a singleton selector Selector. More...
 
StringRef getOpenMPContextTraitPropertyName (TraitProperty Kind, StringRef RawString)
 Return a textual representation of the trait property Kind, which might be the raw string we parsed (RawString) if we do not translate the property into a (distinct) enum. More...
 
StringRef getOpenMPContextTraitPropertyFullName (TraitProperty Kind)
 Return a textual representation of the trait property Kind with selector and set name included. More...
 
std::string listOpenMPContextTraitSets ()
 Return a string listing all trait sets. More...
 
std::string listOpenMPContextTraitSelectors (TraitSet Set)
 Return a string listing all trait selectors for Set. More...
 
std::string listOpenMPContextTraitProperties (TraitSet Set, TraitSelector Selector)
 Return a string listing all trait properties for Set and Selector. More...
 
bool isValidTraitSelectorForTraitSet (TraitSelector Selector, TraitSet Set, bool &AllowsTraitScore, bool &RequiresProperty)
 } More...
 
bool isValidTraitPropertyForTraitSetAndSelector (TraitProperty Property, TraitSelector Selector, TraitSet Set)
 Return true if Property can be nested in Selector and Set. More...
 
bool isVariantApplicableInContext (const VariantMatchInfo &VMI, const OMPContext &Ctx, bool DeviceSetOnly=false)
 Return true if VMI is applicable in Ctx, that is, all traits required by VMI are available in the OpenMP context Ctx. More...
 
int getBestVariantMatchForContext (const SmallVectorImpl< VariantMatchInfo > &VMIs, const OMPContext &Ctx)
 Return the index (into VMIs) of the variant with the highest score from the ones applicble in Ctx. More...
 
bool containsOpenMP (Module &M, OpenMPInModule &OMPInModule)
 Helper to determine if M contains OpenMP (runtime calls). More...
 

Variables

static constexpr AssumptionClauseMappingInfo AssumptionClauseMappings []
 All known assume clauses. More...
 
static constexpr unsigned AMDGPUGpuGridValues []
 For AMDGPU GPUs. More...
 
static constexpr unsigned NVPTXGpuGridValues []
 For Nvidia GPUs. More...
 

Typedef Documentation

◆ Kernel

using llvm::omp::Kernel = typedef Function *

Summary of a kernel (=entry point for target offloading).

Definition at line 21 of file OpenMPOpt.h.

Enumeration Type Documentation

◆ DefaultKind

IDs for the different default kinds.

Enumerator
OMP_DEFAULT_KIND 

Definition at line 63 of file OMPConstants.h.

◆ GVIDX

Defines various target-specific GPU grid values that must be consistent between host RTL (plugin), device RTL, and clang.

We can change grid values for a "fat" binary so that different passes get the correct values when generating code for a multi-target binary. Both amdgcn and nvptx values are stored in this file. In the future, should there be differences between GPUs of the same architecture, then simply make a different array and use the new array name.

Example usage in clang: const unsigned slot_size = ctx.GetTargetInfo().getGridValue(llvm::omp::GVIDX::GV_Warp_Size);

Example usage in libomptarget/deviceRTLs: include "llvm/Frontend/OpenMP/OMPGridValues.h" #ifdef AMDGPU #define GRIDVAL AMDGPUGpuGridValues else #define GRIDVAL NVPTXGpuGridValues endif ... Then use this reference for GV_Warp_Size in the deviceRTL source. llvm::omp::GRIDVAL[llvm::omp::GVIDX::GV_Warp_Size]

Example usage in libomptarget hsa plugin: include "llvm/Frontend/OpenMP/OMPGridValues.h" #define GRIDVAL AMDGPUGpuGridValues ... Then use this reference to access GV_Warp_Size in the hsa plugin. llvm::omp::GRIDVAL[llvm::omp::GVIDX::GV_Warp_Size]

Example usage in libomptarget cuda plugin: include "llvm/Frontend/OpenMP/OMPGridValues.h" #define GRIDVAL NVPTXGpuGridValues ... Then use this reference to access GV_Warp_Size in the cuda plugin. llvm::omp::GRIDVAL[llvm::omp::GVIDX::GV_Warp_Size]

Enumerator
GV_Threads 

The maximum number of workers in a kernel.

(THREAD_ABSOLUTE_LIMIT) - (GV_Warp_Size), might be issue for blockDim.z

GV_Slot_Size 

The size reserved for data in a shared memory slot.

GV_Warp_Size 

The default value of maximum number of threads in a worker warp.

GV_Warp_Size_32 

Alternate warp size for some AMDGCN architectures.

Same as GV_Warp_Size for NVPTX.

GV_Warp_Size_Log2 

The number of bits required to represent the max number of threads in warp.

GV_Warp_Slot_Size 

GV_Warp_Size * GV_Slot_Size,.

GV_Max_Teams 

the maximum number of teams.

GV_Mem_Align 

Global Memory Alignment.

GV_Warp_Size_Log2_Mask 

(~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))

GV_SimpleBufferSize 
GV_Max_WG_Size 
GV_Default_WG_Size 
GV_Max_Warp_Number 
GV_Warp_Size_Log2_MaskL 

The slot size that should be reserved for a working warp.

(~0u >> (GV_Warp_Size - GV_Warp_Size_Log2))

Definition at line 56 of file OMPGridValues.h.

◆ ICVInitValue

Enumerator
ICV_INIT_VALUE 

Definition at line 44 of file OMPConstants.h.

◆ IdentFlag

enum llvm::omp::IdentFlag
strong

IDs for all omp runtime library ident_t flag encodings (see their defintion in openmp/runtime/src/kmp.h).

Enumerator
OMP_IDENT_FLAG 

Definition at line 74 of file OMPConstants.h.

◆ InternalControlVar

IDs for all Internal Control Variables (ICVs).

Enumerator
ICV_DATA_ENV 

Definition at line 35 of file OMPConstants.h.

◆ OMPScheduleType

Note
This needs to be kept in sync with kmp.h enum sched_type. Todo: Update kmp.h to include this file, and remove the enums in kmp.h To complete this, more enum values will need to be moved here.
Enumerator
Static 
DynamicChunked 
GuidedChunked 
Runtime 
Auto 
ModifierNonmonotonic 

Set if the nonmonotonic schedule modifier was present.

Definition at line 113 of file OMPConstants.h.

◆ RuntimeFunction

IDs for all omp runtime library (RTL) functions.

Enumerator
OMP_RTL 

Definition at line 54 of file OMPConstants.h.

◆ TraitProperty

IDs for all OpenMP context trait properties (host/gpu/bsc/llvm/...)

Enumerator
OMP_TRAIT_PROPERTY 
OMP_LAST_TRAIT_PROPERTY 

Definition at line 45 of file OMPContext.h.

◆ TraitSelector

IDs for all OpenMP context selector trait (device={kind/isa...}/...).

Enumerator
OMP_TRAIT_SELECTOR 

Definition at line 39 of file OMPContext.h.

◆ TraitSet

enum llvm::omp::TraitSet
strong

OpenMP Context related IDs and helpers.

{ IDs for all OpenMP context selector trait sets (construct/device/...).

Enumerator
OMP_TRAIT_SET 

Definition at line 33 of file OMPContext.h.

Function Documentation

◆ containsOpenMP()

bool llvm::omp::containsOpenMP ( Module M,
OpenMPInModule OMPInModule 
)

Helper to determine if M contains OpenMP (runtime calls).

Definition at line 2661 of file OpenMPOpt.cpp.

References F, I, llvm::omp::OpenMPInModule::identifyKernels(), llvm::omp::OpenMPInModule::isKnown(), and M.

Referenced by llvm::OpenMPOptPass::run(), and llvm::OpenMPOptCGSCCPass::run().

◆ getAllAssumeClauseOptions()

std::string llvm::omp::getAllAssumeClauseOptions ( )
inline

Definition at line 103 of file OMPConstants.h.

References AssumptionClauseMappings, and S.

◆ getBestVariantMatchForContext()

int llvm::omp::getBestVariantMatchForContext ( const SmallVectorImpl< VariantMatchInfo > &  VMIs,
const OMPContext Ctx 
)

Return the index (into VMIs) of the variant with the highest score from the ones applicble in Ctx.

See llvm::isVariantApplicableInContext.

Definition at line 342 of file OMPContext.cpp.

References llvm::numbers::e, llvm::APInt::eq(), getVariantMatchScore(), isStrictSubset(), isVariantApplicableInContextHelper(), and llvm::APInt::ult().

◆ getOpenMPContextTraitPropertyForSelector()

TraitProperty llvm::omp::getOpenMPContextTraitPropertyForSelector ( TraitSelector  Selector)

Return the trait property for a singleton selector Selector.

Definition at line 456 of file OMPContext.cpp.

References llvm::StringSwitch< T, R >::Default(), and getOpenMPContextTraitSelectorName().

◆ getOpenMPContextTraitPropertyFullName()

StringRef llvm::omp::getOpenMPContextTraitPropertyFullName ( TraitProperty  Kind)

Return a textual representation of the trait property Kind with selector and set name included.

Definition at line 478 of file OMPContext.cpp.

References llvm_unreachable.

Referenced by llvm::omp::OMPContext::OMPContext().

◆ getOpenMPContextTraitPropertyKind()

TraitProperty llvm::omp::getOpenMPContextTraitPropertyKind ( TraitSet  Set,
TraitSelector  Selector,
StringRef  Str 
)

Parse Str and return the trait property it matches in the set Set and selector Selector or TraitProperty::invalid.

Definition at line 443 of file OMPContext.cpp.

◆ getOpenMPContextTraitPropertyName()

StringRef llvm::omp::getOpenMPContextTraitPropertyName ( TraitProperty  Kind,
StringRef  RawString 
)

Return a textual representation of the trait property Kind, which might be the raw string we parsed (RawString) if we do not translate the property into a (distinct) enum.

Definition at line 466 of file OMPContext.cpp.

References llvm_unreachable.

Referenced by isVariantApplicableInContextHelper().

◆ getOpenMPContextTraitSelectorForProperty()

TraitSelector llvm::omp::getOpenMPContextTraitSelectorForProperty ( TraitProperty  Property)

Return the trait selector for which Property is a property.

Definition at line 424 of file OMPContext.cpp.

References llvm_unreachable.

Referenced by getVariantMatchScore(), and isVariantApplicableInContextHelper().

◆ getOpenMPContextTraitSelectorKind()

TraitSelector llvm::omp::getOpenMPContextTraitSelectorKind ( StringRef  Str)

Parse Str and return the trait set it matches or TraitSelector::invalid.

Definition at line 416 of file OMPContext.cpp.

References llvm::StringSwitch< T, R >::Default(), and S.

◆ getOpenMPContextTraitSelectorName()

StringRef llvm::omp::getOpenMPContextTraitSelectorName ( TraitSelector  Kind)

Return a textual representation of the trait selector Kind.

Definition at line 433 of file OMPContext.cpp.

References llvm_unreachable.

Referenced by getOpenMPContextTraitPropertyForSelector().

◆ getOpenMPContextTraitSetForProperty()

TraitSet llvm::omp::getOpenMPContextTraitSetForProperty ( TraitProperty  Property)

Return the trait set for which Property is a property.

Definition at line 397 of file OMPContext.cpp.

References llvm_unreachable.

Referenced by llvm::omp::VariantMatchInfo::addTrait(), llvm::omp::OMPContext::addTrait(), getVariantMatchScore(), and isVariantApplicableInContextHelper().

◆ getOpenMPContextTraitSetForSelector()

TraitSet llvm::omp::getOpenMPContextTraitSetForSelector ( TraitSelector  Selector)

Return the trait set for which Selector is a selector.

Definition at line 387 of file OMPContext.cpp.

References llvm_unreachable.

◆ getOpenMPContextTraitSetKind()

TraitSet llvm::omp::getOpenMPContextTraitSetKind ( StringRef  Str)

Parse Str and return the trait set it matches or TraitSet::invalid.

Definition at line 379 of file OMPContext.cpp.

References llvm::StringSwitch< T, R >::Default(), and S.

◆ getOpenMPContextTraitSetName()

StringRef llvm::omp::getOpenMPContextTraitSetName ( TraitSet  Kind)

Return a textual representation of the trait set Kind.

Definition at line 406 of file OMPContext.cpp.

References llvm_unreachable.

◆ isValidTraitPropertyForTraitSetAndSelector()

bool llvm::omp::isValidTraitPropertyForTraitSetAndSelector ( TraitProperty  Property,
TraitSelector  Selector,
TraitSet  Set 
)

Return true if Property can be nested in Selector and Set.

Definition at line 503 of file OMPContext.cpp.

References llvm_unreachable.

◆ isValidTraitSelectorForTraitSet()

bool llvm::omp::isValidTraitSelectorForTraitSet ( TraitSelector  Selector,
TraitSet  Set,
bool &  AllowsTraitScore,
bool &  RequiresProperty 
)

}

Return true if Selector can be nested in Set. Also sets AllowsTraitScore and RequiresProperty to true/false if the user can specify a score for properties in Selector and if the Selector requires at least one property.

Definition at line 488 of file OMPContext.cpp.

References llvm_unreachable.

◆ isVariantApplicableInContext()

bool llvm::omp::isVariantApplicableInContext ( const VariantMatchInfo VMI,
const OMPContext Ctx,
bool  DeviceSetOnly = false 
)

Return true if VMI is applicable in Ctx, that is, all traits required by VMI are available in the OpenMP context Ctx.

If DeviceSetOnly is true, only the device selector set, if present, are checked. Note that we still honor extension traits provided by the user.

Definition at line 265 of file OMPContext.cpp.

References isVariantApplicableInContextHelper().

◆ listOpenMPContextTraitProperties()

std::string llvm::omp::listOpenMPContextTraitProperties ( TraitSet  Set,
TraitSelector  Selector 
)

Return a string listing all trait properties for Set and Selector.

Definition at line 536 of file OMPContext.cpp.

References S.

◆ listOpenMPContextTraitSelectors()

std::string llvm::omp::listOpenMPContextTraitSelectors ( TraitSet  Set)

Return a string listing all trait selectors for Set.

Definition at line 525 of file OMPContext.cpp.

References S.

◆ listOpenMPContextTraitSets()

std::string llvm::omp::listOpenMPContextTraitSets ( )

Return a string listing all trait sets.

Definition at line 515 of file OMPContext.cpp.

References S.

◆ LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()

llvm::omp::LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE ( )

Variable Documentation

◆ AMDGPUGpuGridValues

constexpr unsigned llvm::omp::AMDGPUGpuGridValues[]
staticconstexpr
Initial value:
= {
448,
256,
64,
32,
6,
64 * 256,
128,
256,
63,
896,
1024,
256,
1024 / 64,
63
}

For AMDGPU GPUs.

Definition at line 93 of file OMPGridValues.h.

◆ AssumptionClauseMappings

constexpr AssumptionClauseMappingInfo llvm::omp::AssumptionClauseMappings[]
staticconstexpr
Initial value:
= {
#define OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, HasExpression)
}

All known assume clauses.

Definition at line 96 of file OMPConstants.h.

Referenced by getAllAssumeClauseOptions().

◆ NVPTXGpuGridValues

constexpr unsigned llvm::omp::NVPTXGpuGridValues[]
staticconstexpr
Initial value:
= {
992,
256,
32,
32,
5,
32 * 256,
1024,
256,
(~0u >> (32 - 5)),
896,
1024,
128,
1024 / 32,
31
}

For Nvidia GPUs.

Definition at line 111 of file OMPGridValues.h.