Halide 21.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
cpu_features.h
Go to the documentation of this file.
1#ifndef HALIDE_CPU_FEATURES_H
2#define HALIDE_CPU_FEATURES_H
3
4#include "HalideRuntime.h"
5#include "runtime_internal.h"
6
7namespace Halide {
8namespace Runtime {
9namespace Internal {
10
11// Size of CPU feature mask large enough to cover all Halide target features
12static constexpr int cpu_feature_mask_size = (halide_target_feature_end + 63) / (sizeof(uint64_t) * 8);
13
14// Contains two masks:
15// One with all the CPU-specific features that might possible be available on this architecture ('known'),
16// and one with the subset that are actually present ('available').
18 uint64_t known[cpu_feature_mask_size] = {0}; // mask of the CPU features we know how to detect
19 uint64_t available[cpu_feature_mask_size] = {0}; // mask of the CPU features that are available
20 // (always a subset of 'known')
21};
22
24 features->known[i >> 6] |= ((uint64_t)1) << (i & 63);
25}
26
28 features->available[i >> 6] |= ((uint64_t)1) << (i & 63);
29}
30
32 return (features->known[i >> 6] & ((uint64_t)1) << (i & 63)) != 0;
33}
34
36 return (features->available[i >> 6] & ((uint64_t)1) << (i & 63)) != 0;
37}
38
39// NOTE: This method is not part of the public API, but we push it into extern "C" to
40// avoid name mangling mismatches between platforms. See: https://github.com/halide/Halide/issues/8565
41extern "C" WEAK int halide_get_cpu_features(CpuFeatures *features);
42
43} // namespace Internal
44} // namespace Runtime
45} // namespace Halide
46
47#endif // HALIDE_CPU_FEATURES_H
This file declares the routines used by Halide internally in its runtime.
@ halide_target_feature_end
A sentinel. Every target is considered to have this feature, and setting this feature does nothing.
ALWAYS_INLINE bool halide_test_known_cpu_feature(CpuFeatures *features, int i)
WEAK int halide_get_cpu_features(CpuFeatures *features)
ALWAYS_INLINE void halide_set_known_cpu_feature(CpuFeatures *features, int i)
ALWAYS_INLINE bool halide_test_available_cpu_feature(CpuFeatures *features, int i)
ALWAYS_INLINE void halide_set_available_cpu_feature(CpuFeatures *features, int i)
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
unsigned __INT64_TYPE__ uint64_t
#define ALWAYS_INLINE
#define WEAK
uint64_t known[cpu_feature_mask_size]
uint64_t available[cpu_feature_mask_size]