LLVM 22.0.0git
Namespaces | Classes | Typedefs | Enumerations | Functions
llvm::offloading Namespace Reference

Namespaces

namespace  amdgpu
 
namespace  intel
 

Classes

struct  EntryTy
 This is the record of an object that just be registered with the offloading runtime. More...
 

Typedefs

using EntryArrayTy = std::pair< GlobalVariable *, GlobalVariable * >
 
using ByteArray = SmallVector< unsigned char, 0 >
 
using PropertyValue = std::variant< uint32_t, ByteArray >
 
using PropertySet = std::map< std::string, PropertyValue >
 
using PropertySetRegistry = std::map< std::string, PropertySet >
 

Enumerations

enum  OffloadEntryKindFlag : uint32_t {
  OffloadGlobalEntry = 0x0 , OffloadGlobalManagedEntry = 0x1 , OffloadGlobalSurfaceEntry = 0x2 , OffloadGlobalTextureEntry = 0x3 ,
  OffloadGlobalExtern = 0x1 << 3 , OffloadGlobalConstant = 0x1 << 4 , OffloadGlobalNormalized = 0x1 << 5
}
 Offloading entry flags for CUDA / HIP. More...
 

Functions

LLVM_ABI llvm::Error wrapOpenMPBinaries (llvm::Module &M, llvm::ArrayRef< llvm::ArrayRef< char > > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool Relocatable=false)
 Wraps the input device images into the module M as global symbols and registers the images with the OpenMP Offloading runtime libomptarget.
 
LLVM_ABI llvm::Error wrapCudaBinary (llvm::Module &M, llvm::ArrayRef< char > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool EmitSurfacesAndTextures=true)
 Wraps the input fatbinary image into the module M as global symbols and registers the images with the CUDA runtime.
 
LLVM_ABI llvm::Error wrapHIPBinary (llvm::Module &M, llvm::ArrayRef< char > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool EmitSurfacesAndTextures=true)
 Wraps the input bundled image into the module M as global symbols and registers the images with the HIP runtime.
 
LLVM_ABI void writePropertiesToJSON (const PropertySetRegistry &P, raw_ostream &O)
 
LLVM_ABI Expected< PropertySetRegistryreadPropertiesFromJSON (MemoryBufferRef Buf)
 
LLVM_ABI StructTypegetEntryTy (Module &M)
 Returns the type of the offloading entry we use to store kernels and globals that will be registered with the offloading runtime.
 
LLVM_ABI void emitOffloadingEntry (Module &M, object::OffloadKind Kind, Constant *Addr, StringRef Name, uint64_t Size, uint32_t Flags, uint64_t Data, Constant *AuxAddr=nullptr, StringRef SectionName="llvm_offload_entries")
 Create an offloading section struct used to register this global at runtime.
 
LLVM_ABI std::pair< Constant *, GlobalVariable * > getOffloadingEntryInitializer (Module &M, object::OffloadKind Kind, Constant *Addr, StringRef Name, uint64_t Size, uint32_t Flags, uint64_t Data, Constant *AuxAddr)
 Create a constant struct initializer used to register this global at runtime.
 
LLVM_ABI std::pair< GlobalVariable *, GlobalVariable * > getOffloadEntryArray (Module &M, StringRef SectionName="llvm_offload_entries")
 Creates a pair of globals used to iterate the array of offloading entries by accessing the section variables provided by the linker.
 

Typedef Documentation

◆ ByteArray

Definition at line 25 of file PropertySet.h.

◆ EntryArrayTy

Definition at line 18 of file OffloadWrapper.h.

◆ PropertySet

using llvm::offloading::PropertySet = typedef std::map<std::string, PropertyValue>

Definition at line 27 of file PropertySet.h.

◆ PropertySetRegistry

using llvm::offloading::PropertySetRegistry = typedef std::map<std::string, PropertySet>

Definition at line 28 of file PropertySet.h.

◆ PropertyValue

using llvm::offloading::PropertyValue = typedef std::variant<uint32_t, ByteArray>

Definition at line 26 of file PropertySet.h.

Enumeration Type Documentation

◆ OffloadEntryKindFlag

Offloading entry flags for CUDA / HIP.

The first three bits indicate the type of entry while the others are a bit field for additional information.

Enumerator
OffloadGlobalEntry 

Mark the entry as a global entry.

This indicates the presense of a kernel if the size size field is zero and a variable otherwise.

OffloadGlobalManagedEntry 

Mark the entry as a managed global variable.

OffloadGlobalSurfaceEntry 

Mark the entry as a surface variable.

OffloadGlobalTextureEntry 

Mark the entry as a texture variable.

OffloadGlobalExtern 

Mark the entry as being extern.

OffloadGlobalConstant 

Mark the entry as being constant.

OffloadGlobalNormalized 

Mark the entry as being a normalized surface.

Definition at line 51 of file Utility.h.

Function Documentation

◆ emitOffloadingEntry()

void llvm::offloading::emitOffloadingEntry ( Module M,
object::OffloadKind  Kind,
Constant Addr,
StringRef  Name,
uint64_t  Size,
uint32_t  Flags,
uint64_t  Data,
Constant AuxAddr = nullptr,
StringRef  SectionName = "llvm_offload_entries" 
)

Create an offloading section struct used to register this global at runtime.

Parameters
MThe module to be used
AddrThe pointer to the global being registered.
KindThe offloading language expected to consume this.
NameThe symbol name associated with the global.
SizeThe size in bytes of the global (0 for functions).
FlagsFlags associated with the entry.
DataExtra data storage associated with the entry.
SectionNameThe section this entry will be placed at.
AuxAddrAn extra pointer if needed.

Definition at line 85 of file Utility.cpp.

References Addr, llvm::object::OffloadBinary::getAlignment(), getEntryTy(), getOffloadingEntryInitializer(), llvm::Triple::isNVPTX(), llvm::Triple::isOSBinFormatCOFF(), Name, llvm::GlobalValue::NotThreadLocal, Size, and llvm::GlobalValue::WeakAnyLinkage.

Referenced by llvm::OpenMPIRBuilder::createOffloadEntriesAndInfoMetadata(), and llvm::OpenMPIRBuilder::createOffloadEntry().

◆ getEntryTy()

StructType * llvm::offloading::getEntryTy ( Module M)

Returns the type of the offloading entry we use to store kernels and globals that will be registered with the offloading runtime.

Definition at line 26 of file Utility.cpp.

References llvm::CallingConv::C, llvm::StructType::create(), llvm::Type::getInt16Ty(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), and llvm::StructType::getTypeByName().

Referenced by emitOffloadingEntry(), getOffloadEntryArray(), and getOffloadingEntryInitializer().

◆ getOffloadEntryArray()

std::pair< GlobalVariable *, GlobalVariable * > llvm::offloading::getOffloadEntryArray ( Module M,
StringRef  SectionName = "llvm_offload_entries" 
)

◆ getOffloadingEntryInitializer()

std::pair< Constant *, GlobalVariable * > llvm::offloading::getOffloadingEntryInitializer ( Module M,
object::OffloadKind  Kind,
Constant Addr,
StringRef  Name,
uint64_t  Size,
uint32_t  Flags,
uint64_t  Data,
Constant AuxAddr 
)

◆ readPropertiesFromJSON()

Expected< PropertySetRegistry > llvm::offloading::readPropertiesFromJSON ( MemoryBufferRef  Buf)

◆ wrapCudaBinary()

Error llvm::offloading::wrapCudaBinary ( llvm::Module M,
llvm::ArrayRef< char Images,
EntryArrayTy  EntryArray,
llvm::StringRef  Suffix = "",
bool  EmitSurfacesAndTextures = true 
)

Wraps the input fatbinary image into the module M as global symbols and registers the images with the CUDA runtime.

Parameters
EntryArrayOptional pair pointing to the __start and __stop symbols holding the __tgt_offload_entry array.
SuffixAn optional suffix appended to the emitted symbols.
EmitSurfacesAndTexturesWhether to emit surface and textures registration code. It defaults to false.

Definition at line 637 of file OffloadWrapper.cpp.

References llvm::createStringError(), llvm::inconvertibleErrorCode(), and llvm::Error::success().

◆ wrapHIPBinary()

Error llvm::offloading::wrapHIPBinary ( llvm::Module M,
llvm::ArrayRef< char Images,
EntryArrayTy  EntryArray,
llvm::StringRef  Suffix = "",
bool  EmitSurfacesAndTextures = true 
)

Wraps the input bundled image into the module M as global symbols and registers the images with the HIP runtime.

Parameters
EntryArrayOptional pair pointing to the __start and __stop symbols holding the __tgt_offload_entry array.
SuffixAn optional suffix appended to the emitted symbols.
EmitSurfacesAndTexturesWhether to emit surface and textures registration code. It defaults to false.

Definition at line 651 of file OffloadWrapper.cpp.

References llvm::createStringError(), llvm::inconvertibleErrorCode(), and llvm::Error::success().

◆ wrapOpenMPBinaries()

Error llvm::offloading::wrapOpenMPBinaries ( llvm::Module M,
llvm::ArrayRef< llvm::ArrayRef< char > >  Images,
EntryArrayTy  EntryArray,
llvm::StringRef  Suffix = "",
bool  Relocatable = false 
)

Wraps the input device images into the module M as global symbols and registers the images with the OpenMP Offloading runtime libomptarget.

Parameters
EntryArrayOptional pair pointing to the __start and __stop symbols holding the __tgt_offload_entry array.
SuffixAn optional suffix appended to the emitted symbols.
RelocatableIndicate if we need to change the offloading section to create a relocatable object.

Definition at line 625 of file OffloadWrapper.cpp.

References llvm::createStringError(), llvm::inconvertibleErrorCode(), and llvm::Error::success().

◆ writePropertiesToJSON()

void llvm::offloading::writePropertiesToJSON ( const PropertySetRegistry P,
raw_ostream O 
)