Halide
Halide::ExternalCode Class Reference

#include <ExternalCode.h>

Public Member Functions

bool is_for_cpu_target (const Target &host) const
 Return true if this container holds llvm bitcode linkable with code generated for the target argument. More...
 
bool is_for_device_api (DeviceAPI current_device) const
 True if this container holds code linkable with a code generated for a GPU. More...
 
bool is_c_plus_plus_source () const
 True if this container holds C++ source code for inclusion in generating C++ output. More...
 
const std::vector< uint8_t > & contents () const
 Retrieve the bytes of external code held by this container. More...
 
const std::string & name () const
 Retrieve the name of this container. More...
 

Static Public Member Functions

static ExternalCode bitcode_wrapper (const Target &cpu_type, const std::vector< uint8_t > &code, const std::string &name)
 Construct an ExternalCode container from llvm bitcode. More...
 
static ExternalCode device_code_wrapper (DeviceAPI device_api, const std::vector< uint8_t > &code, const std::string &name)
 Construct an ExternalCode container from GPU "source code." This container can be used to insert its code into the GPU code generated for a given DeviceAPI. More...
 
static ExternalCode c_plus_plus_code_wrapper (const std::vector< uint8_t > &code, const std::string &name)
 Construct an ExternalCode container from C++ source code. More...
 

Detailed Description

Definition at line 11 of file ExternalCode.h.

Member Function Documentation

◆ bitcode_wrapper()

static ExternalCode Halide::ExternalCode::bitcode_wrapper ( const Target cpu_type,
const std::vector< uint8_t > &  code,
const std::string &  name 
)
inlinestatic

Construct an ExternalCode container from llvm bitcode.

The result can be passed to Halide::Module::append to have the contained bitcode linked with that module. The Module's target must match the target argument here on architecture, bit width, and operating system. The name is used as a unique identifier for the external code and duplicates will be reduced to a single instance. Halide does not do anything other than to compare names for equality. To guarantee uniqueness in public code, we suggest using a Java style inverted domain name followed by organization specific naming. E.g.: com.initech.y2k.5d2ac80aaf522eec6cb4b40f39fb923f9902bc7e

Definition at line 44 of file ExternalCode.h.

References Halide::None.

◆ device_code_wrapper()

static ExternalCode Halide::ExternalCode::device_code_wrapper ( DeviceAPI  device_api,
const std::vector< uint8_t > &  code,
const std::string &  name 
)
inlinestatic

Construct an ExternalCode container from GPU "source code." This container can be used to insert its code into the GPU code generated for a given DeviceAPI.

The specific type of code depends on the device API used as follows: CUDA: llvm bitcode for PTX OpenCL: OpenCL source code GLSL: GLSL source code OpenGLCompute: GLSL source code Metal: Metal source code Hexagon: llvm bitcode for Hexagon

At present, this API is not fully working. See Issue: https://github.com/halide/Halide/issues/1971

The name is used as a unique identifier for the external code and duplicates will be reduced to a single instance. Halide does not do anything other than to compare names for equality. To guarantee uniqueness in public code, we suggest using a Java style inverted domain name followed by organization specific naming. E.g.: com.tyrell.nexus-6.53947db86ba97a9ca5ecd5e60052880945bfeb37

Definition at line 69 of file ExternalCode.h.

◆ c_plus_plus_code_wrapper()

static ExternalCode Halide::ExternalCode::c_plus_plus_code_wrapper ( const std::vector< uint8_t > &  code,
const std::string &  name 
)
inlinestatic

Construct an ExternalCode container from C++ source code.

This container can be used to insert its code into C++ output from Halide.

At present, this API is not fully working. See Issue: https://github.com/halide/Halide/issues/1971

The name is used as a unique identifier for the external code and duplicates will be reduced to a single instance. Halide does not do anything other than to compare names for equality. To guarantee uniqueness in public code, we suggest using a Java style inverted domain name followed by organization specific naming. E.g.: com.cyberdyne.skynet.78ad6c411d313f050f172cd3d440f23fdd797d0d

Definition at line 87 of file ExternalCode.h.

References Halide::None.

◆ is_for_cpu_target()

bool Halide::ExternalCode::is_for_cpu_target ( const Target host) const
inline

Return true if this container holds llvm bitcode linkable with code generated for the target argument.

The matching is done on the architecture, bit width, and operating system only. Features are ignored. If the container is for Target::ArchUnkonwn, it applies to all architectures – meaning it is generic llvm bitcode. If the OS is OSUnknown, it applies to all operationg systems. The bit width must match.

Ignoring feature flags isn't too important since generally ExternalCode will be constructed in a Generator which has access to the feature flags in effect and can select code appropriately.

Definition at line 103 of file ExternalCode.h.

References Halide::Target::arch, Halide::Target::ArchUnknown, Halide::Target::bits, Halide::Target::os, and Halide::Target::OSUnknown.

◆ is_for_device_api()

bool Halide::ExternalCode::is_for_device_api ( DeviceAPI  current_device) const
inline

True if this container holds code linkable with a code generated for a GPU.

Definition at line 111 of file ExternalCode.h.

◆ is_c_plus_plus_source()

bool Halide::ExternalCode::is_c_plus_plus_source ( ) const
inline

True if this container holds C++ source code for inclusion in generating C++ output.

Definition at line 117 of file ExternalCode.h.

◆ contents()

const std::vector<uint8_t>& Halide::ExternalCode::contents ( ) const
inline

Retrieve the bytes of external code held by this container.

Definition at line 120 of file ExternalCode.h.

◆ name()

const std::string& Halide::ExternalCode::name ( ) const
inline

Retrieve the name of this container.

Used to ensure the same piece of external code is only included once in linkage.

Definition at line 124 of file ExternalCode.h.


The documentation for this class was generated from the following file: