Target#
-
struct Target#
A struct representing a target machine and os to generate code for.
Public Types
-
enum OS#
The operating system used by the target.
Determines which system calls to generate. Corresponds to os_name_map in Target.cpp.
Values:
-
enumerator OSUnknown#
-
enumerator Linux#
-
enumerator Windows#
-
enumerator OSX#
-
enumerator Android#
-
enumerator IOS#
-
enumerator QuRT#
-
enumerator NoOS#
-
enumerator Fuchsia#
-
enumerator WebAssemblyRuntime#
-
enumerator OSUnknown#
-
enum Arch#
The architecture used by the target.
Determines the instruction set to use. Corresponds to arch_name_map in Target.cpp.
Values:
-
enumerator ArchUnknown#
-
enumerator X86#
-
enumerator ARM#
-
enumerator Hexagon#
-
enumerator POWERPC#
-
enumerator WebAssembly#
-
enumerator RISCV#
-
enumerator ArchUnknown#
-
enum Processor#
The specific processor to target or tune for.
Mirrors halide_target_processor_t in HalideRuntime.h and corresponds to processor_name_map in Target.cpp.
New entries should be added to the end.
Values:
-
enumerator ProcessorGeneric#
Do not tune for any specific CPU. In practice, this means that halide will decide the tune CPU based on the enabled features.
-
enumerator K8#
-
enumerator K8_SSE3#
-
enumerator AMDFam10#
-
enumerator BtVer1#
-
enumerator BdVer1#
-
enumerator BdVer2#
-
enumerator BdVer3#
-
enumerator BdVer4#
-
enumerator BtVer2#
-
enumerator ZnVer1#
-
enumerator ZnVer2#
-
enumerator ZnVer3#
-
enumerator ZnVer4#
-
enumerator ZnVer5#
-
enumerator ProcessorGeneric#
-
enum Feature#
Optional features a target can have.
Corresponds to feature_name_map in Target.cpp. See definitions in HalideRuntime.h for full information.
Values:
-
enumerator JIT#
-
enumerator Debug#
-
enumerator EnableBacktraces#
-
enumerator NoAsserts#
-
enumerator NoBoundsQuery#
-
enumerator SSE41#
-
enumerator AVX#
-
enumerator AVX2#
-
enumerator AVXVNNI#
-
enumerator FMA#
-
enumerator FMA4#
-
enumerator F16C#
-
enumerator ARMv7s#
-
enumerator NoNEON#
-
enumerator VSX#
-
enumerator POWER_ARCH_2_07#
-
enumerator CUDA#
-
enumerator CUDACapability30#
-
enumerator CUDACapability32#
-
enumerator CUDACapability35#
-
enumerator CUDACapability50#
-
enumerator CUDACapability61#
-
enumerator CUDACapability70#
-
enumerator CUDACapability75#
-
enumerator CUDACapability80#
-
enumerator CUDACapability86#
-
enumerator CUDACapability89#
-
enumerator CUDACapability90#
-
enumerator CUDACapability100#
-
enumerator CUDACapability120#
-
enumerator OpenCL#
-
enumerator CLDoubles#
-
enumerator CLHalf#
-
enumerator CLAtomics64#
-
enumerator EGL#
-
enumerator UserContext#
-
enumerator Profile#
-
enumerator NoRuntime#
-
enumerator Metal#
-
enumerator CPlusPlusMangling#
-
enumerator LargeBuffers#
-
enumerator HexagonDma#
-
enumerator HVX_128#
-
enumerator HVX#
-
enumerator HVX_v62#
-
enumerator HVX_v65#
-
enumerator HVX_v66#
-
enumerator HVX_v68#
-
enumerator FuzzFloatStores#
-
enumerator SoftFloatABI#
-
enumerator MSAN#
-
enumerator AVX512#
-
enumerator AVX512_KNL#
-
enumerator AVX512_Skylake#
-
enumerator AVX512_Cannonlake#
-
enumerator AVX512_SapphireRapids#
-
enumerator AVX512_Zen4#
-
enumerator AVX512_Zen5#
-
enumerator TraceLoads#
-
enumerator TraceStores#
-
enumerator TraceRealizations#
-
enumerator TracePipeline#
-
enumerator D3D12Compute#
-
enumerator StrictFloat#
-
enumerator TSAN#
-
enumerator ASAN#
-
enumerator CheckUnsafePromises#
-
enumerator EmbedBitcode#
-
enumerator EnableLLVMLoopOpt#
-
enumerator WasmMvpOnly#
-
enumerator WasmSimd128#
-
enumerator WasmThreads#
-
enumerator WasmBulkMemory#
-
enumerator WebGPU#
-
enumerator SVE#
-
enumerator SVE2#
-
enumerator SME2#
-
enumerator SME_SVL128#
-
enumerator SME_SVL256#
-
enumerator SME_SVL512#
-
enumerator SME_SVL1024#
-
enumerator SME_SVL2048#
-
enumerator ARMDotProd#
-
enumerator ARMFp16#
-
enumerator LLVMLargeCodeModel#
-
enumerator RVV#
-
enumerator ARMv8a#
-
enumerator ARMv81a#
-
enumerator ARMv82a#
-
enumerator ARMv83a#
-
enumerator ARMv84a#
-
enumerator ARMv85a#
-
enumerator ARMv86a#
-
enumerator ARMv87a#
-
enumerator ARMv88a#
-
enumerator ARMv89a#
-
enumerator SanitizerCoverage#
-
enumerator ProfileByTimer#
-
enumerator SPIRV#
-
enumerator Vulkan#
-
enumerator VulkanInt8#
-
enumerator VulkanInt16#
-
enumerator VulkanInt64#
-
enumerator VulkanFloat16#
-
enumerator VulkanFloat64#
-
enumerator VulkanV10#
-
enumerator VulkanV12#
-
enumerator VulkanV13#
-
enumerator Semihosting#
-
enumerator AVX10_1#
-
enumerator X86APX#
-
enumerator Simulator#
-
enumerator HLSL_SM60#
-
enumerator HLSL_SM61#
-
enumerator HLSL_SM62#
-
enumerator HLSL_SM63#
-
enumerator HLSL_SM64#
-
enumerator HLSL_SM65#
-
enumerator HLSL_SM66#
-
enumerator HLSL_SM67#
-
enumerator HLSL_SM68#
-
enumerator HLSL_SM69#
-
enumerator FeatureEnd#
-
enumerator JIT#
Public Functions
-
explicit Target(const std::string &s)#
Given a string of the form used in HL_TARGET (e.g.
“x86-64-avx”), construct the Target it specifies. Note that this always starts with the result of get_host_target(), replacing only the parts found in the target string, so if you omit (say) an OS specification, the host OS will be used instead. An empty string is exactly equivalent to get_host_target().
Invalid target strings will fail with a user_error.
-
bool has_unknowns() const#
Return true if any of the arch/bits/os fields are “unknown”/0; return false otherwise.
-
void set_implied_features()#
Set any feature flags that are implied by the flags currently set.
For example, setting AVX2 implies AVX, so calling this on a target with the AVX2 feature will also set the AVX feature. The set of implications is a DAG, so this reaches a fixed point in a single pass. Call this before inspecting a target’s features, so that (e.g.) a check for SSE41 succeeds on an AVX2 target.
-
void unset_implied_features()#
Unset any feature flags that are implied by other flags that remain set, producing the minimal set of feature flags that set_implied_features() would expand back to the same target.
For example, on a target with both AVX2 and AVX set, this unsets AVX (since AVX2 implies it), but on a target with only AVX set it leaves AVX alone. Call this before emitting a target as a string, to get a compact canonical form.
-
Target with_implied_features() const#
Return a copy of the target with set_implied_features() applied.
-
Target without_implied_features() const#
Return a copy of the target with unset_implied_features() applied.
-
Target with_feature(Feature f) const#
Return a copy of the target with the given feature set.
This is convenient when enabling certain features (e.g. NoBoundsQuery) in an initialization list, where the target to be mutated may be a const reference.
-
Target without_feature(Feature f) const#
Return a copy of the target with the given feature cleared.
This is convenient when disabling certain features (e.g. NoBoundsQuery) in an initialization list, where the target to be mutated may be a const reference.
-
bool has_gpu_feature() const#
Is a fully feature GPU compute runtime enabled?
I.e. is Func::gpu_tile and similar going to work? Currently includes CUDA, OpenCL, Metal and D3D12Compute.
-
bool supports_type(const Type &t) const#
Does this target allow using a certain type.
Generally all types except 64-bit float and int/uint should be supported by all backends.
It is likely better to call the version below which takes a DeviceAPI.
-
bool supports_type(const Type &t, DeviceAPI device) const#
Does this target allow using a certain type on a certain device.
This is the preferred version of this routine.
-
bool supports_device_api(DeviceAPI api) const#
Returns whether a particular device API can be used with this Target.
-
DeviceAPI get_required_device_api() const#
If this Target (including all Features) requires a specific DeviceAPI, return it.
If it doesn’t, return DeviceAPI::None. If the Target has features with multiple (different) DeviceAPI requirements, the result will be an arbitrary DeviceAPI.
-
bool get_runtime_compatible_target(const Target &other, Target &result)#
Create a “greatest common denominator” runtime target that is compatible with both this target and
other.Used by generators to conveniently select a suitable runtime when linking together multiple functions.
- Parameters:
other – The other target from which we compute the gcd target.
result – [out] The gcd target if we return true, otherwise unmodified. Can be the same as *this.
- Returns:
Whether it was possible to find a compatible target (true) or not.
-
std::string to_string() const#
Convert the Target into a string form that can be reconstituted by merge_string(), which will always be of the form.
arch-bits-os-processor-feature1-feature2…featureN.
Note that is guaranteed that Target(t1.to_string()) == t1, but not that Target(s).to_string() == s (since there can be multiple strings that parse to the same Target)… unless t1 contains ‘unknown’ fields (in which case you’ll get a string that can’t be parsed, which is intentional).
-
int natural_vector_size(const Halide::Type &t) const#
Given a data type, return an estimate of the “natural” vector size for that data type when compiling for this Target.
-
int sme_streaming_vector_bits() const#
Return the fixed SME streaming vector length in bits selected by this target, or 0 if no SME_SVL feature is set.
-
template<typename data_t>
inline int natural_vector_size() const# Given a data type, return an estimate of the “natural” vector size for that data type when compiling for this Target.
-
inline bool has_large_buffers() const#
Return true iff 64 bits and has_feature(LargeBuffers).
-
inline int64_t maximum_buffer_size() const#
Return the maximum buffer size in bytes supported on this Target.
This is 2^31 - 1 except on 64-bit targets when the LargeBuffers feature is enabled, which expands the maximum to 2^63 - 1.
-
int get_cuda_capability_lower_bound() const#
Get the minimum cuda capability found as an integer.
Returns 20 (our minimum supported cuda compute capability) if no cuda features are set.
-
int get_vulkan_capability_lower_bound() const#
Get the minimum Vulkan capability found as an integer.
Returns 10 (our minimum supported Vulkan compute capability) if no Vulkan features are set.
-
int get_d3d12compute_capability_lower_bound() const#
Get the minimum D3D12Compute Shader Model version as an integer (e.g.
60 for SM 6.0, 62 for SM 6.2). Returns 51 (SM 5.1, FXC path) if no SM 6.x features are set, or -1 if D3D12Compute is not enabled.
-
int get_arm_v8_lower_bound() const#
Get the minimum ARM v8.x capability found as an integer.
Returns -1 if no ARM v8.x features are set.
-
bool supported() const#
Was libHalide compiled with support for this target?
-
inline const std::bitset<FeatureEnd> &get_features_bitset() const#
Return a bitset of the Featuress set in this Target (set = 1).
Note that while this happens to be the current internal representation, that might not always be the case.
Public Members
-
int bits = 0#
The bit-width of the target machine.
Must be 0 for unknown, or 32 or 64.
-
int vector_bits = 0#
The bit-width of a vector register for targets where this is configurable and targeting a fixed size is desired.
The default of 0 indicates no assumption of fixed size is allowed.
Public Static Functions
-
static bool validate_target_string(const std::string &s)#
Check if a target string is valid.
-
static std::string feature_to_name(Target::Feature feature)#
Return the name corresponding to a given Feature, in the form used to construct Target strings (e.g., Feature::Debug is “debug” and not “Debug”).
-
static Target::Feature feature_from_name(const std::string &name)#
Return the feature corresponding to a given name, in the form used to construct Target strings (e.g., Feature::Debug is “debug” and not “Debug”).
If the string is not a known feature name, return FeatureEnd.
-
enum OS#