Auto-sync: 2026-06-25 22:43:25 (part 26)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/util/thread_name.h +18 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/util/typeid.h +720 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/util/win32-headers.h +65 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/PeerToPeerAccess.h +23 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUCachingAllocator.h +142 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUDeviceProp.h +222 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUEvent.h +183 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUException.h +28 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUFunctions.h +50 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUGraphsC10Utils.h +47 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUMacros.h +38 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUStream.h +222 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/impl/XPUGuardImpl.h +258 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/test/impl/XPUTest.h +26 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/core/common.h +66 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/core/macros.h +77 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/core/timer.h +53 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/perfkernels/common.h +145 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/perfkernels/embedding_lookup_idx.h +62 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/crc_alt.h +1348 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/file_adapter.h +40 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/in_memory_adapter.h +35 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/inline_container.h +314 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/istream_adapter.h +31 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/read_adapter_interface.h +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/versions.h +137 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/fixed_divisor.h +137 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/proto_wrap.h +42 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/string_utils.h +56 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/ThreadPool.h +84 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/ThreadPoolCommon.h +25 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/WorkersPool.h +383 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/pthreadpool-cpp.h +60 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/pthreadpool.h +198 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/thread_pool_guard.h +28 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/clog.h +128 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/cpuinfo.h +2366 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl.h +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl.hpp +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_config.h +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_debug.h +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_ocl.h +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_ocl.hpp +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_sycl.h +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_sycl.hpp +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_sycl_types.h +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_threadpool.h +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_threadpool.hpp +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_threadpool_iface.hpp +27 -0
- outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_types.h +27 -0
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/util/thread_name.h
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <string>
|
| 5 |
+
|
| 6 |
+
#include <c10/macros/Export.h>
|
| 7 |
+
|
| 8 |
+
namespace c10 {
|
| 9 |
+
|
| 10 |
+
C10_API void setThreadName(std::string name);
|
| 11 |
+
|
| 12 |
+
C10_API std::string getThreadName();
|
| 13 |
+
|
| 14 |
+
} // namespace c10
|
| 15 |
+
|
| 16 |
+
#else
|
| 17 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 18 |
+
#endif //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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <array>
|
| 5 |
+
#include <atomic>
|
| 6 |
+
#include <cstddef>
|
| 7 |
+
#include <cstdint>
|
| 8 |
+
#include <memory>
|
| 9 |
+
#include <mutex>
|
| 10 |
+
#include <ostream>
|
| 11 |
+
#include <string>
|
| 12 |
+
#include <type_traits>
|
| 13 |
+
#include <vector>
|
| 14 |
+
|
| 15 |
+
#include <c10/macros/Export.h>
|
| 16 |
+
#include <c10/macros/Macros.h>
|
| 17 |
+
#include <c10/util/Exception.h>
|
| 18 |
+
#include <c10/util/Half.h>
|
| 19 |
+
#include <c10/util/IdWrapper.h>
|
| 20 |
+
#include <c10/util/TypeIndex.h>
|
| 21 |
+
#include <c10/util/TypeTraits.h>
|
| 22 |
+
#include <c10/util/irange.h>
|
| 23 |
+
|
| 24 |
+
#include <c10/core/ScalarType.h>
|
| 25 |
+
|
| 26 |
+
/*
|
| 27 |
+
* TypeIdentifier is a small type containing an id.
|
| 28 |
+
* Types must be registered using CAFFE_DECLARE_KNOWN_TYPE() (in their header)
|
| 29 |
+
* and CAFFE_DEFINE_KNOWN_TYPE() (in their .cpp file) for them to have a type
|
| 30 |
+
* id. If a type is registered, you can also create an object containing meta
|
| 31 |
+
* data like constructor, destructor, stringified name, ... about the type by
|
| 32 |
+
* calling TypeMeta::Make<T>. This returns a TypeMeta() object, which is
|
| 33 |
+
* basically just a pointer to the type information, so it's cheap to pass
|
| 34 |
+
* around.
|
| 35 |
+
*/
|
| 36 |
+
|
| 37 |
+
// TODO: This file is still in the caffe2 namespace, despite living
|
| 38 |
+
// in the ATen directory. This is because the macro
|
| 39 |
+
// CAFFE_KNOWN_TYPE (and CAFFE_DECLARE_KNOWN_TYPE) defines a template
|
| 40 |
+
// specialization, which relies
|
| 41 |
+
// on the namespace of TypeMeta matching the namespace where the macro is
|
| 42 |
+
// called. This requires us to fix all of the call-sites, which I want to do
|
| 43 |
+
// later. So the namespace is not fixed at the moment.
|
| 44 |
+
|
| 45 |
+
// Make at::Half a fundamental type.
|
| 46 |
+
|
| 47 |
+
namespace c10::guts {
|
| 48 |
+
template <>
|
| 49 |
+
struct is_fundamental<at::Half> : std::true_type {};
|
| 50 |
+
} // namespace c10::guts
|
| 51 |
+
|
| 52 |
+
namespace caffe2 {
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* A type id is a unique id for a given C++ type.
|
| 56 |
+
* You need to register your types using CAFFE_KNOWN_TYPE(MyType) to be able to
|
| 57 |
+
* use TypeIdentifier with custom types. This is for example used to store the
|
| 58 |
+
* dtype of tensors.
|
| 59 |
+
*/
|
| 60 |
+
class C10_API TypeIdentifier final
|
| 61 |
+
: public at::IdWrapper<TypeIdentifier, c10::util::type_index> {
|
| 62 |
+
public:
|
| 63 |
+
friend std::ostream& operator<<(std::ostream& stream, TypeIdentifier typeId);
|
| 64 |
+
friend constexpr bool operator<(TypeIdentifier lhs, TypeIdentifier rhs);
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Returns the unique id for the given type T. The id is unique for the type T
|
| 68 |
+
* in the sense that for any two different types, their ids are different; for
|
| 69 |
+
* the same type T, the id remains the same over different calls of the
|
| 70 |
+
* function. However, this is not guaranteed over different runs, as the id
|
| 71 |
+
* is generated during run-time. Do NOT serialize the id for storage.
|
| 72 |
+
*/
|
| 73 |
+
template <typename T>
|
| 74 |
+
static constexpr TypeIdentifier Get() noexcept {
|
| 75 |
+
return TypeIdentifier(c10::util::get_type_index<T>());
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
static constexpr TypeIdentifier uninitialized() {
|
| 79 |
+
return TypeIdentifier(c10::util::type_index{0});
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
private:
|
| 83 |
+
constexpr explicit TypeIdentifier(c10::util::type_index id) : IdWrapper(id) {}
|
| 84 |
+
};
|
| 85 |
+
|
| 86 |
+
// Allow usage in std::map / std::set
|
| 87 |
+
// TODO Disallow this and rather use std::unordered_map/set everywhere
|
| 88 |
+
inline constexpr bool operator<(TypeIdentifier lhs, TypeIdentifier rhs) {
|
| 89 |
+
return lhs.underlyingId() < rhs.underlyingId();
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
inline std::ostream& operator<<(
|
| 93 |
+
std::ostream& stream,
|
| 94 |
+
caffe2::TypeIdentifier typeId) {
|
| 95 |
+
return stream << typeId.underlyingId();
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
} // namespace caffe2
|
| 99 |
+
|
| 100 |
+
namespace at {
|
| 101 |
+
using DataType = caffe2::TypeIdentifier;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
C10_DEFINE_HASH_FOR_IDWRAPPER(caffe2::TypeIdentifier)
|
| 105 |
+
|
| 106 |
+
namespace caffe2 {
|
| 107 |
+
|
| 108 |
+
namespace detail {
|
| 109 |
+
|
| 110 |
+
// This struct holds the actual type information. There will be
|
| 111 |
+
// one allocated per type. TypeMeta objects will then point to the struct
|
| 112 |
+
// instance for the type they're configured for.
|
| 113 |
+
struct TypeMetaData final {
|
| 114 |
+
using New = void*();
|
| 115 |
+
using PlacementNew = void(void*, size_t);
|
| 116 |
+
using Copy = void(const void*, void*, size_t);
|
| 117 |
+
using PlacementDelete = void(void*, size_t);
|
| 118 |
+
using Delete = void(void*);
|
| 119 |
+
|
| 120 |
+
constexpr TypeMetaData() noexcept
|
| 121 |
+
: itemsize_(0),
|
| 122 |
+
new_(nullptr),
|
| 123 |
+
placementNew_(nullptr),
|
| 124 |
+
copy_(nullptr),
|
| 125 |
+
placementDelete_(nullptr),
|
| 126 |
+
delete_(nullptr),
|
| 127 |
+
id_(TypeIdentifier::uninitialized()),
|
| 128 |
+
name_("nullptr (uninitialized)") {}
|
| 129 |
+
|
| 130 |
+
constexpr TypeMetaData(
|
| 131 |
+
size_t itemsize,
|
| 132 |
+
New* newFn,
|
| 133 |
+
PlacementNew* placementNew,
|
| 134 |
+
Copy* copy,
|
| 135 |
+
PlacementDelete* placementDelete,
|
| 136 |
+
Delete* deleteFn,
|
| 137 |
+
TypeIdentifier id,
|
| 138 |
+
std::string_view name) noexcept
|
| 139 |
+
: itemsize_(itemsize),
|
| 140 |
+
new_(newFn),
|
| 141 |
+
placementNew_(placementNew),
|
| 142 |
+
copy_(copy),
|
| 143 |
+
placementDelete_(placementDelete),
|
| 144 |
+
delete_(deleteFn),
|
| 145 |
+
id_(id),
|
| 146 |
+
name_(name) {}
|
| 147 |
+
|
| 148 |
+
size_t itemsize_;
|
| 149 |
+
New* new_;
|
| 150 |
+
PlacementNew* placementNew_;
|
| 151 |
+
Copy* copy_;
|
| 152 |
+
PlacementDelete* placementDelete_;
|
| 153 |
+
Delete* delete_;
|
| 154 |
+
TypeIdentifier id_;
|
| 155 |
+
std::string_view name_;
|
| 156 |
+
};
|
| 157 |
+
|
| 158 |
+
// Mechanism for throwing errors which can't be prevented at compile time
|
| 159 |
+
// due to type erasure. E.g. somebody calling TypeMeta::copy() for
|
| 160 |
+
// non-copyable type. Right now just throws exception but is implemented
|
| 161 |
+
// in .cpp to manage dependencies
|
| 162 |
+
[[noreturn]] C10_API void _ThrowRuntimeTypeLogicError(const std::string& msg);
|
| 163 |
+
|
| 164 |
+
/**
|
| 165 |
+
* Placement new function for the type.
|
| 166 |
+
*/
|
| 167 |
+
template <typename T>
|
| 168 |
+
inline void _PlacementNew(void* ptr, size_t n) {
|
| 169 |
+
T* typed_ptr = static_cast<T*>(ptr);
|
| 170 |
+
for (const auto i : c10::irange(n)) {
|
| 171 |
+
new (typed_ptr + i) T;
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
template <typename T>
|
| 176 |
+
inline void _PlacementNewNotDefault(void* /*ptr*/, size_t /*n*/) {
|
| 177 |
+
_ThrowRuntimeTypeLogicError(
|
| 178 |
+
"Type " + std::string(c10::util::get_fully_qualified_type_name<T>()) +
|
| 179 |
+
" is not default-constructible.");
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
template <
|
| 183 |
+
typename T,
|
| 184 |
+
std::enable_if_t<std::is_default_constructible_v<T>>* = nullptr>
|
| 185 |
+
inline constexpr TypeMetaData::PlacementNew* _PickPlacementNew() {
|
| 186 |
+
return (c10::guts::is_fundamental<T>::value || std::is_pointer_v<T>)
|
| 187 |
+
? nullptr
|
| 188 |
+
: &_PlacementNew<T>;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
template <
|
| 192 |
+
typename T,
|
| 193 |
+
std::enable_if_t<!std::is_default_constructible_v<T>>* = nullptr>
|
| 194 |
+
inline constexpr TypeMetaData::PlacementNew* _PickPlacementNew() {
|
| 195 |
+
static_assert(
|
| 196 |
+
!c10::guts::is_fundamental<T>::value && !std::is_pointer_v<T>,
|
| 197 |
+
"this should have picked the other SFINAE case");
|
| 198 |
+
return &_PlacementNewNotDefault<T>;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
template <typename T>
|
| 202 |
+
inline void* _New() {
|
| 203 |
+
return new T;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
template <typename T>
|
| 207 |
+
inline void* _NewNotDefault() {
|
| 208 |
+
_ThrowRuntimeTypeLogicError(
|
| 209 |
+
"Type " + std::string(c10::util::get_fully_qualified_type_name<T>()) +
|
| 210 |
+
" is not default-constructible.");
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
template <
|
| 214 |
+
typename T,
|
| 215 |
+
std::enable_if_t<std::is_default_constructible_v<T>>* = nullptr>
|
| 216 |
+
inline constexpr TypeMetaData::New* _PickNew() {
|
| 217 |
+
return &_New<T>;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
template <
|
| 221 |
+
typename T,
|
| 222 |
+
std::enable_if_t<!std::is_default_constructible_v<T>>* = nullptr>
|
| 223 |
+
inline constexpr TypeMetaData::New* _PickNew() {
|
| 224 |
+
return &_NewNotDefault<T>;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
* Typed copy function for classes.
|
| 229 |
+
*/
|
| 230 |
+
template <typename T>
|
| 231 |
+
inline void _Copy(const void* src, void* dst, size_t n) {
|
| 232 |
+
const T* typed_src = static_cast<const T*>(src);
|
| 233 |
+
T* typed_dst = static_cast<T*>(dst);
|
| 234 |
+
for (const auto i : c10::irange(n)) {
|
| 235 |
+
typed_dst[i] = typed_src[i];
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
/**
|
| 240 |
+
* A placeholder function for types that do not allow assignment.
|
| 241 |
+
*/
|
| 242 |
+
template <typename T>
|
| 243 |
+
inline void _CopyNotAllowed(const void* /*src*/, void* /*dst*/, size_t /*n*/) {
|
| 244 |
+
_ThrowRuntimeTypeLogicError(
|
| 245 |
+
"Type " + std::string(c10::util::get_fully_qualified_type_name<T>()) +
|
| 246 |
+
" does not allow assignment.");
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
template <typename T, std::enable_if_t<std::is_copy_assignable_v<T>>* = nullptr>
|
| 250 |
+
inline constexpr TypeMetaData::Copy* _PickCopy() {
|
| 251 |
+
return (c10::guts::is_fundamental<T>::value || std::is_pointer_v<T>)
|
| 252 |
+
? nullptr
|
| 253 |
+
: &_Copy<T>;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
template <
|
| 257 |
+
typename T,
|
| 258 |
+
std::enable_if_t<!std::is_copy_assignable_v<T>>* = nullptr>
|
| 259 |
+
inline constexpr TypeMetaData::Copy* _PickCopy() {
|
| 260 |
+
static_assert(
|
| 261 |
+
!c10::guts::is_fundamental<T>::value && !std::is_pointer_v<T>,
|
| 262 |
+
"this should have picked the other SFINAE case");
|
| 263 |
+
return &_CopyNotAllowed<T>;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* Destructor for non-fundamental types.
|
| 268 |
+
*/
|
| 269 |
+
template <typename T>
|
| 270 |
+
inline void _PlacementDelete(void* ptr, size_t n) {
|
| 271 |
+
T* typed_ptr = static_cast<T*>(ptr);
|
| 272 |
+
for (const auto i : c10::irange(n)) {
|
| 273 |
+
typed_ptr[i].~T();
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
template <typename T>
|
| 278 |
+
inline constexpr TypeMetaData::PlacementDelete* _PickPlacementDelete() {
|
| 279 |
+
return (c10::guts::is_fundamental<T>::value || std::is_pointer_v<T>)
|
| 280 |
+
? nullptr
|
| 281 |
+
: &_PlacementDelete<T>;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
template <typename T>
|
| 285 |
+
inline void _Delete(void* ptr) {
|
| 286 |
+
T* typed_ptr = static_cast<T*>(ptr);
|
| 287 |
+
delete typed_ptr;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
template <class T>
|
| 291 |
+
inline constexpr TypeMetaData::Delete* _PickDelete() noexcept {
|
| 292 |
+
return &_Delete<T>;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
class _Uninitialized final {};
|
| 296 |
+
|
| 297 |
+
} // namespace detail
|
| 298 |
+
|
| 299 |
+
//
|
| 300 |
+
// note: this is outside TypeMeta bc gcc seems to have trouble
|
| 301 |
+
// with scalarTypeItemSizes as a constexpr static member used by
|
| 302 |
+
// a public inline instance method
|
| 303 |
+
//
|
| 304 |
+
|
| 305 |
+
// item sizes for TypeMeta::itemsize() fast path
|
| 306 |
+
static constexpr std::array<uint8_t, NumScalarTypes> scalarTypeItemSizes = {
|
| 307 |
+
#define SCALAR_TYPE_SIZE(T, name) sizeof(T),
|
| 308 |
+
AT_FORALL_SCALAR_TYPES_WITH_COMPLEX_AND_QINTS(SCALAR_TYPE_SIZE)
|
| 309 |
+
#undef SCALAR_TYPE_SIZE
|
| 310 |
+
0, // Undefined
|
| 311 |
+
};
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* TypeMeta is a thin class that allows us to store the type of a container such
|
| 315 |
+
* as a blob, or the data type of a tensor, with a unique run-time id. It also
|
| 316 |
+
* stores some additional data such as the item size and the name of the type
|
| 317 |
+
* for run-time inspection.
|
| 318 |
+
*/
|
| 319 |
+
class C10_API TypeMeta final {
|
| 320 |
+
public:
|
| 321 |
+
using New = detail::TypeMetaData::New;
|
| 322 |
+
using PlacementNew = detail::TypeMetaData::PlacementNew;
|
| 323 |
+
using Copy = detail::TypeMetaData::Copy;
|
| 324 |
+
using PlacementDelete = detail::TypeMetaData::PlacementDelete;
|
| 325 |
+
using Delete = detail::TypeMetaData::Delete;
|
| 326 |
+
|
| 327 |
+
/** Create a dummy TypeMeta object. To create a TypeMeta object for a specific
|
| 328 |
+
* type, use TypeMeta::Make<T>().
|
| 329 |
+
*/
|
| 330 |
+
TypeMeta() noexcept;
|
| 331 |
+
~TypeMeta() = default;
|
| 332 |
+
|
| 333 |
+
/**
|
| 334 |
+
* Copy constructor.
|
| 335 |
+
*/
|
| 336 |
+
TypeMeta(const TypeMeta& src) noexcept = default;
|
| 337 |
+
|
| 338 |
+
/**
|
| 339 |
+
* Assignment operators.
|
| 340 |
+
*/
|
| 341 |
+
TypeMeta& operator=(const TypeMeta& src) noexcept = default;
|
| 342 |
+
|
| 343 |
+
TypeMeta& operator=(TypeMeta&& src) noexcept = default;
|
| 344 |
+
TypeMeta(TypeMeta&& rhs) noexcept = default;
|
| 345 |
+
|
| 346 |
+
inline TypeMeta& operator=(ScalarType scalar_type) noexcept {
|
| 347 |
+
index_ = static_cast<uint16_t>(scalar_type);
|
| 348 |
+
return *this;
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
private:
|
| 352 |
+
// TypeMeta can only be created by Make, making sure that we do not
|
| 353 |
+
// create incorrectly mixed up TypeMeta objects.
|
| 354 |
+
explicit TypeMeta(const uint16_t index) noexcept : index_(index) {}
|
| 355 |
+
|
| 356 |
+
public:
|
| 357 |
+
/**
|
| 358 |
+
* Returns the type id.
|
| 359 |
+
*/
|
| 360 |
+
TypeIdentifier id() const noexcept {
|
| 361 |
+
return data().id_;
|
| 362 |
+
}
|
| 363 |
+
/**
|
| 364 |
+
* true if we represent some ScalarType type
|
| 365 |
+
*/
|
| 366 |
+
inline bool isScalarType() const noexcept {
|
| 367 |
+
return index_ < NumScalarTypes;
|
| 368 |
+
}
|
| 369 |
+
/**
|
| 370 |
+
* true if we represent ScalarType scalar_type
|
| 371 |
+
*/
|
| 372 |
+
inline bool isScalarType(ScalarType scalar_type) const noexcept {
|
| 373 |
+
return index_ == static_cast<uint16_t>(scalar_type);
|
| 374 |
+
}
|
| 375 |
+
/**
|
| 376 |
+
* Returns the size of the item.
|
| 377 |
+
*/
|
| 378 |
+
inline size_t itemsize() const noexcept {
|
| 379 |
+
if (C10_LIKELY(isScalarType())) {
|
| 380 |
+
return scalarTypeItemSizes[index_];
|
| 381 |
+
}
|
| 382 |
+
return data().itemsize_;
|
| 383 |
+
}
|
| 384 |
+
/**
|
| 385 |
+
* Returns the new function pointer for individual items.
|
| 386 |
+
*/
|
| 387 |
+
New* newFn() const noexcept {
|
| 388 |
+
return data().new_;
|
| 389 |
+
}
|
| 390 |
+
/**
|
| 391 |
+
* Returns the placement new function pointer for individual items.
|
| 392 |
+
*/
|
| 393 |
+
PlacementNew* placementNew() const noexcept {
|
| 394 |
+
return data().placementNew_;
|
| 395 |
+
}
|
| 396 |
+
/**
|
| 397 |
+
* Returns the typed copy function pointer for individual items.
|
| 398 |
+
*/
|
| 399 |
+
Copy* copy() const noexcept {
|
| 400 |
+
return data().copy_;
|
| 401 |
+
}
|
| 402 |
+
/**
|
| 403 |
+
* Returns the destructor function pointer for individual items.
|
| 404 |
+
*/
|
| 405 |
+
PlacementDelete* placementDelete() const noexcept {
|
| 406 |
+
return data().placementDelete_;
|
| 407 |
+
}
|
| 408 |
+
Delete* deleteFn() const noexcept {
|
| 409 |
+
return data().delete_;
|
| 410 |
+
}
|
| 411 |
+
/**
|
| 412 |
+
* Returns a printable name for the type.
|
| 413 |
+
*/
|
| 414 |
+
std::string_view name() const noexcept {
|
| 415 |
+
return data().name_;
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
friend bool operator==(const TypeMeta& lhs, const TypeMeta& rhs) noexcept;
|
| 419 |
+
|
| 420 |
+
template <typename T>
|
| 421 |
+
bool Match() const noexcept {
|
| 422 |
+
return (*this == Make<T>());
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
// Below are static functions that can be called by passing a specific type.
|
| 426 |
+
|
| 427 |
+
template <class T>
|
| 428 |
+
static constexpr TypeIdentifier Id() noexcept {
|
| 429 |
+
return TypeIdentifier::Get<T>();
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
template <class T>
|
| 433 |
+
static std::string_view TypeName() noexcept {
|
| 434 |
+
return c10::util::get_fully_qualified_type_name<T>();
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
template <class T>
|
| 438 |
+
static constexpr size_t ItemSize() noexcept {
|
| 439 |
+
return sizeof(T);
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
/**
|
| 443 |
+
* Returns a TypeMeta object that corresponds to the typename T.
|
| 444 |
+
*/
|
| 445 |
+
template <typename T>
|
| 446 |
+
static TypeMeta Make() {
|
| 447 |
+
// The instance pointed to is declared here, but defined in a .cpp file.
|
| 448 |
+
// We need to silence the compiler warning about using an undefined
|
| 449 |
+
// variable template. '-Wpragmas' and '-Wunknown-warning-option' has to be
|
| 450 |
+
// disabled for compilers that don't know '-Wundefined-var-template' and
|
| 451 |
+
// would error at our attempt to disable it.
|
| 452 |
+
#ifndef _MSC_VER
|
| 453 |
+
#pragma GCC diagnostic push
|
| 454 |
+
#pragma GCC diagnostic ignored "-Wpragmas"
|
| 455 |
+
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
|
| 456 |
+
#pragma GCC diagnostic ignored "-Wundefined-var-template"
|
| 457 |
+
#endif
|
| 458 |
+
return TypeMeta(_typeMetaData<T>());
|
| 459 |
+
#ifndef _MSC_VER
|
| 460 |
+
#pragma GCC diagnostic pop
|
| 461 |
+
#endif
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
/**
|
| 465 |
+
* convert ScalarType enum values to TypeMeta handles
|
| 466 |
+
*/
|
| 467 |
+
static inline caffe2::TypeMeta fromScalarType(ScalarType scalar_type) {
|
| 468 |
+
const auto index = static_cast<uint16_t>(scalar_type);
|
| 469 |
+
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(
|
| 470 |
+
index < NumScalarTypes,
|
| 471 |
+
"Unrecognized Scalartype ",
|
| 472 |
+
scalar_type,
|
| 473 |
+
" (please report this error)");
|
| 474 |
+
return TypeMeta(index);
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
/**
|
| 478 |
+
* convert TypeMeta handles to ScalarType enum values
|
| 479 |
+
*/
|
| 480 |
+
inline ScalarType toScalarType() const {
|
| 481 |
+
if (C10_LIKELY(isScalarType())) {
|
| 482 |
+
return static_cast<ScalarType>(index_);
|
| 483 |
+
}
|
| 484 |
+
error_unsupported_typemeta(*this);
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
private:
|
| 488 |
+
[[noreturn]] static void error_unsupported_typemeta(caffe2::TypeMeta dtype);
|
| 489 |
+
|
| 490 |
+
// hard limit number of registered types
|
| 491 |
+
// note: constexpr provokes Windows compilation error "member may not be
|
| 492 |
+
// initialized" static constexpr size_t MaxTypeIndex = 32;
|
| 493 |
+
//
|
| 494 |
+
#if defined C10_MOBILE
|
| 495 |
+
// The reason for this not to be UINT8_MAX is that the array
|
| 496 |
+
// initialization takes space which is proportional to the size of the array.
|
| 497 |
+
// The compiler seems to add code (or data padding) to initialize the array with
|
| 498 |
+
// empty elements. Please see
|
| 499 |
+
// https://github.com/pytorch/pytorch/pull/51881 for details.
|
| 500 |
+
//
|
| 501 |
+
#define MaxTypeIndex \
|
| 502 |
+
(NumScalarTypes + 15 /* number of CAFFE_DEFINE_KNOWN_TYPE in typeid.cpp */ + \
|
| 503 |
+
1 /* 1 more for caffe2 tensor */)
|
| 504 |
+
#else
|
| 505 |
+
#define MaxTypeIndex UINT8_MAX
|
| 506 |
+
#endif
|
| 507 |
+
|
| 508 |
+
// Protects type metadata allocation.
|
| 509 |
+
// NOLINTNEXTLINE(facebook-hte-NonPodStaticDeclaration)
|
| 510 |
+
static std::mutex& getTypeMetaDatasLock();
|
| 511 |
+
static uint16_t nextTypeIndex;
|
| 512 |
+
|
| 513 |
+
static detail::TypeMetaData* typeMetaDatas();
|
| 514 |
+
|
| 515 |
+
static uint16_t existingMetaDataIndexForType(TypeIdentifier identifier);
|
| 516 |
+
|
| 517 |
+
public:
|
| 518 |
+
#ifdef __CUDACC__
|
| 519 |
+
// NOTE [ TypeIdentifier::Get nvcc/clang discrepancy]
|
| 520 |
+
// nvcc and clang do not produce identical results for
|
| 521 |
+
// TypeIdentifier::Get, because TypeIdentifier::Get relies on
|
| 522 |
+
// __PRETTY_FUNCTION__ and they don't agree on the canonical names
|
| 523 |
+
// of types (e.g., nvcc normalizes to `short unsigned int`, but clang
|
| 524 |
+
// calls it `unsigned short`). Hide the implementation of this function
|
| 525 |
+
// from nvcc so that we always use clang (or whatever host C++ compiler)
|
| 526 |
+
// for TypeIdentifier::Get.
|
| 527 |
+
template <class T>
|
| 528 |
+
C10_EXPORT static uint16_t addTypeMetaData();
|
| 529 |
+
#else
|
| 530 |
+
template <class T>
|
| 531 |
+
C10_EXPORT static uint16_t addTypeMetaData() {
|
| 532 |
+
const auto identifier = TypeIdentifier::Get<T>();
|
| 533 |
+
// Need to hold this for the rest of the function, protecting:
|
| 534 |
+
// 1) existingMetaDataIndexForType()
|
| 535 |
+
// 2) nextTypeIndex++
|
| 536 |
+
// 3) the write into typeMetaDatas()
|
| 537 |
+
std::lock_guard<std::mutex> lock(getTypeMetaDatasLock());
|
| 538 |
+
// It may exist already if added in a different dynamic shared library.
|
| 539 |
+
const uint16_t existing_index = existingMetaDataIndexForType(identifier);
|
| 540 |
+
if (existing_index != MaxTypeIndex) {
|
| 541 |
+
return existing_index;
|
| 542 |
+
}
|
| 543 |
+
const uint16_t index = nextTypeIndex++;
|
| 544 |
+
TORCH_CHECK(
|
| 545 |
+
index <= MaxTypeIndex,
|
| 546 |
+
"Maximum number of CAFFE_KNOWN_TYPE declarations has been exceeded. ",
|
| 547 |
+
"Please report this issue.");
|
| 548 |
+
typeMetaDatas()[index] = detail::TypeMetaData{
|
| 549 |
+
sizeof(T),
|
| 550 |
+
detail::_PickNew<T>(),
|
| 551 |
+
detail::_PickPlacementNew<T>(),
|
| 552 |
+
detail::_PickCopy<T>(),
|
| 553 |
+
detail::_PickPlacementDelete<T>(),
|
| 554 |
+
detail::_PickDelete<T>(),
|
| 555 |
+
identifier,
|
| 556 |
+
c10::util::get_fully_qualified_type_name<T>()};
|
| 557 |
+
return index;
|
| 558 |
+
}
|
| 559 |
+
#endif
|
| 560 |
+
|
| 561 |
+
private:
|
| 562 |
+
// specializations return indexes into typeMetaDataInstances()
|
| 563 |
+
template <class T>
|
| 564 |
+
C10_API static uint16_t _typeMetaData() noexcept;
|
| 565 |
+
|
| 566 |
+
//
|
| 567 |
+
// TypeMeta just wraps this index
|
| 568 |
+
//
|
| 569 |
+
|
| 570 |
+
uint16_t index_;
|
| 571 |
+
|
| 572 |
+
inline const detail::TypeMetaData& data() const {
|
| 573 |
+
return typeMetaDatas()[index_];
|
| 574 |
+
}
|
| 575 |
+
};
|
| 576 |
+
|
| 577 |
+
// specializations of TypeMeta::_typeMetaData for ScalarType types
|
| 578 |
+
|
| 579 |
+
#define DEFINE_SCALAR_METADATA_INSTANCE(T, name) \
|
| 580 |
+
template <> \
|
| 581 |
+
constexpr uint16_t TypeMeta::_typeMetaData<T>() noexcept { \
|
| 582 |
+
return static_cast<uint16_t>(ScalarType::name); \
|
| 583 |
+
}
|
| 584 |
+
AT_FORALL_SCALAR_TYPES_WITH_COMPLEX_AND_QINTS(DEFINE_SCALAR_METADATA_INSTANCE)
|
| 585 |
+
#undef DEFINE_SCALAR_METADATA_INSTANCE
|
| 586 |
+
|
| 587 |
+
template <>
|
| 588 |
+
C10_EXPORT constexpr uint16_t TypeMeta::_typeMetaData<
|
| 589 |
+
detail::_Uninitialized>() noexcept {
|
| 590 |
+
return static_cast<uint16_t>(ScalarType::Undefined);
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
inline TypeMeta::TypeMeta() noexcept
|
| 594 |
+
: index_(_typeMetaData<detail::_Uninitialized>()) {}
|
| 595 |
+
|
| 596 |
+
inline bool operator==(const TypeMeta& lhs, const TypeMeta& rhs) noexcept {
|
| 597 |
+
return (lhs.index_ == rhs.index_);
|
| 598 |
+
}
|
| 599 |
+
inline bool operator!=(const TypeMeta& lhs, const TypeMeta& rhs) noexcept {
|
| 600 |
+
return !operator==(lhs, rhs);
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
inline std::ostream& operator<<(
|
| 604 |
+
std::ostream& stream,
|
| 605 |
+
caffe2::TypeMeta typeMeta) {
|
| 606 |
+
return stream << typeMeta.name();
|
| 607 |
+
}
|
| 608 |
+
|
| 609 |
+
/**
|
| 610 |
+
* Register unique id for a type so it can be used in TypeMeta context, e.g. be
|
| 611 |
+
* used as a type for Blob or for Tensor elements.
|
| 612 |
+
*
|
| 613 |
+
* CAFFE_KNOWN_TYPE is deprecated; prefer CAFFE_DECLARE_KNOWN_TYPE and
|
| 614 |
+
* CAFFE_DEFINE_KNOWN_TYPE.
|
| 615 |
+
*
|
| 616 |
+
* CAFFE_KNOWN_TYPE does explicit instantiation of TypeIdentifier::Get<T>
|
| 617 |
+
* template function and thus needs to be put in a single translation unit (.cpp
|
| 618 |
+
* file) for a given type T. Other translation units that use type T as a type
|
| 619 |
+
* of the caffe2::Blob or element type of caffe2::Tensor need to depend on the
|
| 620 |
+
* translation unit that contains CAFFE_KNOWN_TYPE declaration via regular
|
| 621 |
+
* linkage dependencies.
|
| 622 |
+
*
|
| 623 |
+
* NOTE: the macro needs to be invoked in ::caffe2 namespace
|
| 624 |
+
*/
|
| 625 |
+
// Implementation note: in MSVC, we will need to prepend the C10_API
|
| 626 |
+
// keyword in order to get things compiled properly. in Linux, gcc seems to
|
| 627 |
+
// create attribute ignored error for explicit template instantiations, see
|
| 628 |
+
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0537r0.html
|
| 629 |
+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51930
|
| 630 |
+
// and as a result, we define these two macros slightly differently.
|
| 631 |
+
#if defined(_MSC_VER) || defined(__clang__)
|
| 632 |
+
#define EXPORT_IF_NOT_GCC C10_EXPORT
|
| 633 |
+
#else
|
| 634 |
+
#define EXPORT_IF_NOT_GCC
|
| 635 |
+
#endif
|
| 636 |
+
|
| 637 |
+
// CAFFE_KNOWN_TYPE is deprecated! Use CAFFE_DECLARE_KNOWN_TYPE and
|
| 638 |
+
// CAFFE_DEFINE_KNOWN_TYPE instead.
|
| 639 |
+
#define CAFFE_KNOWN_TYPE(T) \
|
| 640 |
+
template uint16_t TypeMeta::addTypeMetaData<T>(); \
|
| 641 |
+
template <> \
|
| 642 |
+
EXPORT_IF_NOT_GCC uint16_t TypeMeta::_typeMetaData<T>() noexcept { \
|
| 643 |
+
static const uint16_t index = addTypeMetaData<T>(); \
|
| 644 |
+
return index; \
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
#define CAFFE_DEFINE_KNOWN_TYPE(T, ident) \
|
| 648 |
+
template uint16_t TypeMeta::addTypeMetaData<T>(); \
|
| 649 |
+
namespace detail { \
|
| 650 |
+
EXPORT_IF_NOT_GCC const uint16_t ident##_metadata_index = \
|
| 651 |
+
TypeMeta::addTypeMetaData<T>(); \
|
| 652 |
+
} // namespace detail
|
| 653 |
+
|
| 654 |
+
// Unlike CAFFE_KNOWN_TYPE, CAFFE_DECLARE_KNOWN_TYPE avoids a function
|
| 655 |
+
// call to access _typeMetaData in the common case.
|
| 656 |
+
#define CAFFE_DECLARE_KNOWN_TYPE(T, ident) \
|
| 657 |
+
extern template uint16_t TypeMeta::addTypeMetaData<T>(); \
|
| 658 |
+
namespace detail { \
|
| 659 |
+
extern C10_API const uint16_t ident##_metadata_index; \
|
| 660 |
+
} /* namespace detail */ \
|
| 661 |
+
template <> \
|
| 662 |
+
EXPORT_IF_NOT_GCC C10_ALWAYS_INLINE uint16_t \
|
| 663 |
+
TypeMeta::_typeMetaData<T>() noexcept { \
|
| 664 |
+
return detail::ident##_metadata_index; \
|
| 665 |
+
}
|
| 666 |
+
|
| 667 |
+
#define CAFFE_KNOWN_TYPE_NOEXPORT(T) \
|
| 668 |
+
template <> \
|
| 669 |
+
uint16_t TypeMeta::_typeMetaData<T>() noexcept { \
|
| 670 |
+
static const uint16_t index = addTypeMetaData<T>(); \
|
| 671 |
+
return index; \
|
| 672 |
+
}
|
| 673 |
+
|
| 674 |
+
CAFFE_DECLARE_KNOWN_TYPE(std::string, std_string)
|
| 675 |
+
CAFFE_DECLARE_KNOWN_TYPE(char, char)
|
| 676 |
+
CAFFE_DECLARE_KNOWN_TYPE(std::unique_ptr<std::mutex>, std_unique_ptr_std_mutex)
|
| 677 |
+
CAFFE_DECLARE_KNOWN_TYPE(
|
| 678 |
+
std::unique_ptr<std::atomic<bool>>,
|
| 679 |
+
std_unique_ptr_std_atomic_bool)
|
| 680 |
+
CAFFE_DECLARE_KNOWN_TYPE(std::vector<int32_t>, std_vector_int32_t)
|
| 681 |
+
CAFFE_DECLARE_KNOWN_TYPE(std::vector<int64_t>, std_vector_int64_t)
|
| 682 |
+
CAFFE_DECLARE_KNOWN_TYPE(std::vector<unsigned long>, std_vector_unsigned_long)
|
| 683 |
+
CAFFE_DECLARE_KNOWN_TYPE(bool*, bool_ptr)
|
| 684 |
+
CAFFE_DECLARE_KNOWN_TYPE(char*, char_ptr)
|
| 685 |
+
CAFFE_DECLARE_KNOWN_TYPE(int*, int_ptr)
|
| 686 |
+
|
| 687 |
+
// For some of the compilers, long is defined separately from int32_t and
|
| 688 |
+
// int64_t. As a result we will need to actually define them separately.
|
| 689 |
+
// It is recommended that one does NOT use long - use int32_t and int64_t
|
| 690 |
+
// explicitly. Explicit long type annotation may go away in the future.
|
| 691 |
+
// details: This hack works by defining a _guard_long_unique type, which is
|
| 692 |
+
// long iff the compiler has a separate long type and is a dummy type otherwise.
|
| 693 |
+
// we then allocate a type id to that _guard_long_unique. If the compiler has a
|
| 694 |
+
// separate long type, this allocates a type id for long. Otherwise, it
|
| 695 |
+
// allocates a type id for the dummy type, which doesn't matter.
|
| 696 |
+
namespace detail {
|
| 697 |
+
template <class T>
|
| 698 |
+
class _guard_long_unique_dummy final {};
|
| 699 |
+
template <class T>
|
| 700 |
+
using _guard_long_unique = std::conditional_t<
|
| 701 |
+
std::is_same_v<long, int32_t> || std::is_same_v<long, int64_t>,
|
| 702 |
+
_guard_long_unique_dummy<T>,
|
| 703 |
+
T>;
|
| 704 |
+
} // namespace detail
|
| 705 |
+
|
| 706 |
+
CAFFE_DECLARE_KNOWN_TYPE(
|
| 707 |
+
detail::_guard_long_unique<long>,
|
| 708 |
+
detail_guard_long_unique_long)
|
| 709 |
+
CAFFE_DECLARE_KNOWN_TYPE(
|
| 710 |
+
detail::_guard_long_unique<std::vector<long>>,
|
| 711 |
+
detail_guard_long_unique_std_vector_long)
|
| 712 |
+
|
| 713 |
+
CAFFE_DECLARE_KNOWN_TYPE(float*, float_ptr)
|
| 714 |
+
CAFFE_DECLARE_KNOWN_TYPE(at::Half*, at_Half)
|
| 715 |
+
|
| 716 |
+
} // namespace caffe2
|
| 717 |
+
|
| 718 |
+
#else
|
| 719 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 720 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/util/win32-headers.h
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#ifndef WIN32_LEAN_AND_MEAN
|
| 5 |
+
#define WIN32_LEAN_AND_MEAN
|
| 6 |
+
#endif
|
| 7 |
+
#ifndef NOMINMAX
|
| 8 |
+
#define NOMINMAX
|
| 9 |
+
#endif
|
| 10 |
+
#ifndef NOKERNEL
|
| 11 |
+
#define NOKERNEL
|
| 12 |
+
#endif
|
| 13 |
+
#ifndef NOUSER
|
| 14 |
+
#define NOUSER
|
| 15 |
+
#endif
|
| 16 |
+
#ifndef NOSERVICE
|
| 17 |
+
#define NOSERVICE
|
| 18 |
+
#endif
|
| 19 |
+
#ifndef NOSOUND
|
| 20 |
+
#define NOSOUND
|
| 21 |
+
#endif
|
| 22 |
+
#ifndef NOMCX
|
| 23 |
+
#define NOMCX
|
| 24 |
+
#endif
|
| 25 |
+
#ifndef NOGDI
|
| 26 |
+
#define NOGDI
|
| 27 |
+
#endif
|
| 28 |
+
#ifndef NOMSG
|
| 29 |
+
#define NOMSG
|
| 30 |
+
#endif
|
| 31 |
+
#ifndef NOMB
|
| 32 |
+
#define NOMB
|
| 33 |
+
#endif
|
| 34 |
+
#ifndef NOCLIPBOARD
|
| 35 |
+
#define NOCLIPBOARD
|
| 36 |
+
#endif
|
| 37 |
+
|
| 38 |
+
// dbghelp seems to require windows.h.
|
| 39 |
+
// clang-format off
|
| 40 |
+
#include <windows.h>
|
| 41 |
+
#include <dbghelp.h>
|
| 42 |
+
// clang-format on
|
| 43 |
+
|
| 44 |
+
#undef VOID
|
| 45 |
+
#undef DELETE
|
| 46 |
+
#undef IN
|
| 47 |
+
#undef THIS
|
| 48 |
+
#undef CONST
|
| 49 |
+
#undef NAN
|
| 50 |
+
#undef UNKNOWN
|
| 51 |
+
#undef NONE
|
| 52 |
+
#undef ANY
|
| 53 |
+
#undef IGNORE
|
| 54 |
+
#undef STRICT
|
| 55 |
+
#undef GetObject
|
| 56 |
+
#undef CreateSemaphore
|
| 57 |
+
#undef Yield
|
| 58 |
+
#undef RotateRight32
|
| 59 |
+
#undef RotateLeft32
|
| 60 |
+
#undef RotateRight64
|
| 61 |
+
#undef RotateLeft64
|
| 62 |
+
|
| 63 |
+
#else
|
| 64 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 65 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/PeerToPeerAccess.h
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/core/Device.h>
|
| 5 |
+
#include <c10/macros/Macros.h>
|
| 6 |
+
#include <c10/xpu/XPUMacros.h>
|
| 7 |
+
|
| 8 |
+
namespace c10::xpu {
|
| 9 |
+
namespace detail {
|
| 10 |
+
// Initialize the peer-to-peer access cache for XPU devices.
|
| 11 |
+
C10_XPU_API void init_p2p_access_cache(c10::DeviceIndex num_devices);
|
| 12 |
+
} // namespace detail
|
| 13 |
+
|
| 14 |
+
// Query if peer-to-peer access is available between two devices.
|
| 15 |
+
C10_XPU_API bool get_p2p_access(
|
| 16 |
+
c10::DeviceIndex dev,
|
| 17 |
+
c10::DeviceIndex dev_to_access);
|
| 18 |
+
|
| 19 |
+
} // namespace c10::xpu
|
| 20 |
+
|
| 21 |
+
#else
|
| 22 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 23 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUCachingAllocator.h
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/core/AllocatorConfig.h>
|
| 5 |
+
#include <c10/core/CachingDeviceAllocator.h>
|
| 6 |
+
#include <c10/xpu/XPUStream.h>
|
| 7 |
+
|
| 8 |
+
namespace c10::xpu::XPUCachingAllocator {
|
| 9 |
+
|
| 10 |
+
class XPUAllocator : public DeviceAllocator {
|
| 11 |
+
public:
|
| 12 |
+
virtual void init(c10::DeviceIndex device_count) = 0;
|
| 13 |
+
virtual void* raw_alloc(size_t size) = 0;
|
| 14 |
+
virtual void raw_delete(void* ptr) = 0;
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
C10_XPU_API extern std::atomic<XPUAllocator*> allocator;
|
| 18 |
+
|
| 19 |
+
struct AllocatorConfigInfo {
|
| 20 |
+
bool expandable_segments;
|
| 21 |
+
std::string last_allocator_settings;
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
struct SnapshotInfo {
|
| 25 |
+
std::vector<CachingDeviceAllocator::SegmentInfo> segments;
|
| 26 |
+
std::vector<std::vector<CachingDeviceAllocator::TraceEntry>> device_traces;
|
| 27 |
+
AllocatorConfigInfo config_metadata;
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
inline XPUAllocator* get() {
|
| 31 |
+
return allocator.load();
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
inline void init(c10::DeviceIndex device_count) {
|
| 35 |
+
get()->init(device_count);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
inline void emptyCache(MempoolId_t mempool_id = {0, 0}) {
|
| 39 |
+
get()->emptyCache(mempool_id);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
inline void resetPeakStats(DeviceIndex device) {
|
| 43 |
+
get()->resetPeakStats(device);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
inline void resetAccumulatedStats(DeviceIndex device) {
|
| 47 |
+
get()->resetAccumulatedStats(device);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
inline c10::CachingDeviceAllocator::DeviceStats getDeviceStats(
|
| 51 |
+
DeviceIndex device) {
|
| 52 |
+
return get()->getDeviceStats(device);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
inline void* raw_alloc(size_t size) {
|
| 56 |
+
return get()->raw_alloc(size);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
inline void raw_delete(void* ptr) {
|
| 60 |
+
get()->raw_delete(ptr);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
inline void recordStream(const DataPtr& dataPtr, XPUStream stream) {
|
| 64 |
+
get()->recordStream(dataPtr, stream);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
C10_XPU_API void enablePeerAccess(
|
| 68 |
+
c10::DeviceIndex dev,
|
| 69 |
+
c10::DeviceIndex dev_to_access);
|
| 70 |
+
|
| 71 |
+
C10_XPU_API double getMemoryFraction(DeviceIndex device);
|
| 72 |
+
|
| 73 |
+
C10_XPU_API void setMemoryFraction(double fraction, DeviceIndex device);
|
| 74 |
+
|
| 75 |
+
C10_XPU_API void recordHistory(
|
| 76 |
+
bool enabled,
|
| 77 |
+
CachingDeviceAllocator::CreateContextFn context_recorder,
|
| 78 |
+
size_t alloc_trace_max_entries,
|
| 79 |
+
CachingDeviceAllocator::RecordContext when,
|
| 80 |
+
bool clearHistory,
|
| 81 |
+
const std::vector<std::string>& skip_actions);
|
| 82 |
+
|
| 83 |
+
C10_XPU_API SnapshotInfo snapshot(MempoolId_t mempool_id = {0, 0});
|
| 84 |
+
|
| 85 |
+
C10_XPU_API void createOrIncrefPool(
|
| 86 |
+
c10::DeviceIndex device,
|
| 87 |
+
c10::MempoolId_t mempool_id,
|
| 88 |
+
XPUAllocator* allocator = nullptr);
|
| 89 |
+
|
| 90 |
+
C10_XPU_API void beginAllocateToPool(
|
| 91 |
+
c10::DeviceIndex device,
|
| 92 |
+
c10::MempoolId_t mempool_id,
|
| 93 |
+
std::function<bool(sycl::queue*)> filter);
|
| 94 |
+
|
| 95 |
+
C10_XPU_API void endAllocateToPool(
|
| 96 |
+
c10::DeviceIndex device,
|
| 97 |
+
c10::MempoolId_t mempool_id);
|
| 98 |
+
|
| 99 |
+
C10_XPU_API void releasePool(
|
| 100 |
+
c10::DeviceIndex device,
|
| 101 |
+
c10::MempoolId_t mempool_id);
|
| 102 |
+
|
| 103 |
+
C10_XPU_API int getPoolUseCount(
|
| 104 |
+
c10::DeviceIndex device,
|
| 105 |
+
c10::MempoolId_t mempool_id);
|
| 106 |
+
|
| 107 |
+
} // namespace c10::xpu::XPUCachingAllocator
|
| 108 |
+
|
| 109 |
+
namespace c10::xpu {
|
| 110 |
+
|
| 111 |
+
using c10::CaptureId_t;
|
| 112 |
+
using c10::MempoolId_t;
|
| 113 |
+
struct C10_XPU_API MemPool {
|
| 114 |
+
MemPool(
|
| 115 |
+
XPUCachingAllocator::XPUAllocator* allocator = nullptr,
|
| 116 |
+
bool is_user_created = true,
|
| 117 |
+
bool use_on_oom = false);
|
| 118 |
+
MemPool(const MemPool&) = delete;
|
| 119 |
+
MemPool(MemPool&&) = default;
|
| 120 |
+
MemPool& operator=(const MemPool&) = delete;
|
| 121 |
+
MemPool& operator=(MemPool&&) = default;
|
| 122 |
+
~MemPool();
|
| 123 |
+
|
| 124 |
+
MempoolId_t id();
|
| 125 |
+
XPUCachingAllocator::XPUAllocator* allocator();
|
| 126 |
+
int use_count();
|
| 127 |
+
c10::DeviceIndex device();
|
| 128 |
+
static MempoolId_t graph_pool_handle(bool is_user_created = true);
|
| 129 |
+
|
| 130 |
+
private:
|
| 131 |
+
static std::atomic<CaptureId_t> uid_;
|
| 132 |
+
static std::atomic<CaptureId_t> uuid_;
|
| 133 |
+
XPUCachingAllocator::XPUAllocator* allocator_;
|
| 134 |
+
bool is_user_created_;
|
| 135 |
+
MempoolId_t id_;
|
| 136 |
+
c10::DeviceIndex device_;
|
| 137 |
+
};
|
| 138 |
+
} // namespace c10::xpu
|
| 139 |
+
|
| 140 |
+
#else
|
| 141 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 142 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUDeviceProp.h
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/xpu/XPUMacros.h>
|
| 5 |
+
#include <sycl/sycl.hpp>
|
| 6 |
+
|
| 7 |
+
namespace c10::xpu {
|
| 8 |
+
|
| 9 |
+
#define AT_FORALL_XPU_DEVICE_PROPERTIES(_) \
|
| 10 |
+
/* the device name of this SYCL device. */ \
|
| 11 |
+
_(name) \
|
| 12 |
+
\
|
| 13 |
+
/* the device type associated with the device. */ \
|
| 14 |
+
_(device_type) \
|
| 15 |
+
\
|
| 16 |
+
/* the vendor of this SYCL device. */ \
|
| 17 |
+
_(vendor) \
|
| 18 |
+
\
|
| 19 |
+
/* a backend-defined driver version as a std::string. */ \
|
| 20 |
+
_(driver_version) \
|
| 21 |
+
\
|
| 22 |
+
/* the SYCL version as a std::string in the form <major>.<minor> */ \
|
| 23 |
+
_(version) \
|
| 24 |
+
\
|
| 25 |
+
/* true if the SYCL device is available. Otherwise, return false. */ \
|
| 26 |
+
_(is_available) \
|
| 27 |
+
\
|
| 28 |
+
/* the maximum size in bytes of the arguments that can be passed to a \
|
| 29 |
+
* kernel. */ \
|
| 30 |
+
_(max_parameter_size) \
|
| 31 |
+
\
|
| 32 |
+
/* the number of parallel compute units available to the device. */ \
|
| 33 |
+
_(max_compute_units) \
|
| 34 |
+
\
|
| 35 |
+
/* the maximum dimensions that specify the global and local work-item IDs \
|
| 36 |
+
* used by the data parallel execution model. */ \
|
| 37 |
+
_(max_work_item_dimensions) \
|
| 38 |
+
\
|
| 39 |
+
/* the maximum number of workitems that are permitted in a work-group \
|
| 40 |
+
* executing a kernel on a single compute unit. */ \
|
| 41 |
+
_(max_work_group_size) \
|
| 42 |
+
\
|
| 43 |
+
/* the maximum number of subgroups in a work-group for any kernel executed \
|
| 44 |
+
* on the device. */ \
|
| 45 |
+
_(max_num_sub_groups) \
|
| 46 |
+
\
|
| 47 |
+
/* a std::vector of size_t containing the set of sub-group sizes supported \
|
| 48 |
+
* by the device. */ \
|
| 49 |
+
_(sub_group_sizes) \
|
| 50 |
+
\
|
| 51 |
+
/* the maximum configured clock frequency of this SYCL device in MHz. */ \
|
| 52 |
+
_(max_clock_frequency) \
|
| 53 |
+
\
|
| 54 |
+
/* the default compute device address space size specified as an unsigned \
|
| 55 |
+
* integer value in bits. Must return either 32 or 64. */ \
|
| 56 |
+
_(address_bits) \
|
| 57 |
+
\
|
| 58 |
+
/* the maximum size of memory object allocation in bytes. */ \
|
| 59 |
+
_(max_mem_alloc_size) \
|
| 60 |
+
\
|
| 61 |
+
/* the minimum value in bits of the largest supported SYCL built-in data \
|
| 62 |
+
* type if this SYCL device is not of device type \
|
| 63 |
+
* sycl::info::device_type::custom. */ \
|
| 64 |
+
_(mem_base_addr_align) \
|
| 65 |
+
\
|
| 66 |
+
/* a std::vector of info::fp_config describing the half/single/double \
|
| 67 |
+
* precision floating-point capability of this SYCL device. */ \
|
| 68 |
+
_(half_fp_config) \
|
| 69 |
+
_(single_fp_config) \
|
| 70 |
+
_(double_fp_config) \
|
| 71 |
+
\
|
| 72 |
+
/* the size of global device memory in bytes. */ \
|
| 73 |
+
_(global_mem_size) \
|
| 74 |
+
\
|
| 75 |
+
/* the type of global memory cache supported. */ \
|
| 76 |
+
_(global_mem_cache_type) \
|
| 77 |
+
\
|
| 78 |
+
/* the size of global memory cache in bytes. */ \
|
| 79 |
+
_(global_mem_cache_size) \
|
| 80 |
+
\
|
| 81 |
+
/* the size of global memory cache line in bytes. */ \
|
| 82 |
+
_(global_mem_cache_line_size) \
|
| 83 |
+
\
|
| 84 |
+
/* the type of local memory supported. */ \
|
| 85 |
+
_(local_mem_type) \
|
| 86 |
+
\
|
| 87 |
+
/* the size of local memory arena in bytes. */ \
|
| 88 |
+
_(local_mem_size) \
|
| 89 |
+
\
|
| 90 |
+
/* the maximum number of sub-devices that can be created when this device is \
|
| 91 |
+
* partitioned. */ \
|
| 92 |
+
_(partition_max_sub_devices) \
|
| 93 |
+
\
|
| 94 |
+
/* the resolution of device timer in nanoseconds. */ \
|
| 95 |
+
_(profiling_timer_resolution) \
|
| 96 |
+
\
|
| 97 |
+
/* the preferred native vector width size for built-in scalar types that can \
|
| 98 |
+
* be put into vectors. */ \
|
| 99 |
+
_(preferred_vector_width_char) \
|
| 100 |
+
_(preferred_vector_width_short) \
|
| 101 |
+
_(preferred_vector_width_int) \
|
| 102 |
+
_(preferred_vector_width_long) \
|
| 103 |
+
_(preferred_vector_width_float) \
|
| 104 |
+
_(preferred_vector_width_double) \
|
| 105 |
+
_(preferred_vector_width_half) \
|
| 106 |
+
\
|
| 107 |
+
/* the native ISA vector width. The vector width is defined as the number of \
|
| 108 |
+
* scalar elements that can be stored in the vector. */ \
|
| 109 |
+
_(native_vector_width_char) \
|
| 110 |
+
_(native_vector_width_short) \
|
| 111 |
+
_(native_vector_width_int) \
|
| 112 |
+
_(native_vector_width_long) \
|
| 113 |
+
_(native_vector_width_float) \
|
| 114 |
+
_(native_vector_width_double) \
|
| 115 |
+
_(native_vector_width_half)
|
| 116 |
+
|
| 117 |
+
#define AT_FORALL_XPU_EXT_DEVICE_PROPERTIES(_) \
|
| 118 |
+
/* the number of EUs associated with the Intel GPU. */ \
|
| 119 |
+
_(gpu_eu_count, gpu_eu_count, 512) \
|
| 120 |
+
\
|
| 121 |
+
/* the number of EUs in a subslice. */ \
|
| 122 |
+
_(gpu_eu_count_per_subslice, gpu_eu_count_per_subslice, 8) \
|
| 123 |
+
\
|
| 124 |
+
/* the simd width of EU of GPU. */ \
|
| 125 |
+
_(gpu_eu_simd_width, gpu_eu_simd_width, 8) \
|
| 126 |
+
\
|
| 127 |
+
/* the number of hardware threads per EU of GPU. */ \
|
| 128 |
+
_(gpu_hw_threads_per_eu, gpu_hw_threads_per_eu, 8) \
|
| 129 |
+
\
|
| 130 |
+
/* the device identifier of the Intel GPU, also known as the product ID. */ \
|
| 131 |
+
_(device_id, device_id, 0) \
|
| 132 |
+
\
|
| 133 |
+
/* the device descriptor for device Universal Unique ID, 16 bytes. */ \
|
| 134 |
+
_(uuid, device_info_uuid, (std::array<unsigned char, 16>{})) \
|
| 135 |
+
\
|
| 136 |
+
/* the maximum clock rate of device's global memory in MHz. */ \
|
| 137 |
+
_(memory_clock_rate, memory_clock_rate, 0) \
|
| 138 |
+
\
|
| 139 |
+
/* the maximum bus width between device and memory in bits. */ \
|
| 140 |
+
_(memory_bus_width, memory_bus_width, 0)
|
| 141 |
+
|
| 142 |
+
#define AT_FORALL_XPU_DEVICE_ASPECT(_) \
|
| 143 |
+
/* sycl::half is supported on device. */ \
|
| 144 |
+
_(fp16) \
|
| 145 |
+
\
|
| 146 |
+
/* double is supported on device. */ \
|
| 147 |
+
_(fp64) \
|
| 148 |
+
\
|
| 149 |
+
/* 64-bit atomic operation is supported on device. */ \
|
| 150 |
+
_(atomic64)
|
| 151 |
+
|
| 152 |
+
#define AT_FORALL_XPU_EXP_CL_ASPECT(_) \
|
| 153 |
+
/* conversion between single-precision 32-bit floating-point values and \
|
| 154 |
+
* 16-bit bfloat16 values is supported on device. */ \
|
| 155 |
+
_(bfloat16_conversions) \
|
| 156 |
+
\
|
| 157 |
+
/* specialized hardware to compute MMA is supported on device. */ \
|
| 158 |
+
_(subgroup_matrix_multiply_accumulate) \
|
| 159 |
+
\
|
| 160 |
+
/* specialized hardware to compute MMA for 32-bit floating-point is \
|
| 161 |
+
* supported on device. */ \
|
| 162 |
+
_(subgroup_matrix_multiply_accumulate_tensor_float32) \
|
| 163 |
+
\
|
| 164 |
+
/* block read operations for efficient matrix multiplication is supported on \
|
| 165 |
+
* device. */ \
|
| 166 |
+
_(subgroup_2d_block_io)
|
| 167 |
+
|
| 168 |
+
#define AT_FORALL_XPU_EXP_DEVICE_PROPERTIES(_) \
|
| 169 |
+
/* the device architecture of this SYCL device. */ \
|
| 170 |
+
_(architecture)
|
| 171 |
+
|
| 172 |
+
#define _DEFINE_SYCL_PROP(ns, property, member) \
|
| 173 |
+
ns::property::return_type member;
|
| 174 |
+
|
| 175 |
+
#define DEFINE_DEVICE_PROP(property) \
|
| 176 |
+
_DEFINE_SYCL_PROP(sycl::info::device, property, property)
|
| 177 |
+
|
| 178 |
+
#define DEFINE_PLATFORM_PROP(property, member) \
|
| 179 |
+
_DEFINE_SYCL_PROP(sycl::info::platform, property, member)
|
| 180 |
+
|
| 181 |
+
#define DEFINE_EXT_DEVICE_PROP(property, ...) \
|
| 182 |
+
_DEFINE_SYCL_PROP(sycl::ext::intel::info::device, property, property)
|
| 183 |
+
|
| 184 |
+
#define DEFINE_DEVICE_ASPECT(member) bool has_##member;
|
| 185 |
+
|
| 186 |
+
#define DEFINE_EXP_DEVICE_PROP(property) \
|
| 187 |
+
_DEFINE_SYCL_PROP( \
|
| 188 |
+
sycl::ext::oneapi::experimental::info::device, property, property)
|
| 189 |
+
|
| 190 |
+
struct C10_XPU_API DeviceProp{
|
| 191 |
+
AT_FORALL_XPU_DEVICE_PROPERTIES(DEFINE_DEVICE_PROP)
|
| 192 |
+
|
| 193 |
+
// the platform name.
|
| 194 |
+
DEFINE_PLATFORM_PROP(name, platform_name)
|
| 195 |
+
|
| 196 |
+
// ext properties.
|
| 197 |
+
AT_FORALL_XPU_EXT_DEVICE_PROPERTIES(DEFINE_EXT_DEVICE_PROP)
|
| 198 |
+
|
| 199 |
+
// device aspects.
|
| 200 |
+
AT_FORALL_XPU_DEVICE_ASPECT(DEFINE_DEVICE_ASPECT)
|
| 201 |
+
|
| 202 |
+
// experimental device aspects.
|
| 203 |
+
AT_FORALL_XPU_EXP_CL_ASPECT(DEFINE_DEVICE_ASPECT)
|
| 204 |
+
|
| 205 |
+
#if SYCL_COMPILER_VERSION >= 20250000
|
| 206 |
+
// experimental device properties.
|
| 207 |
+
AT_FORALL_XPU_EXP_DEVICE_PROPERTIES(DEFINE_EXP_DEVICE_PROP)
|
| 208 |
+
#endif
|
| 209 |
+
};
|
| 210 |
+
|
| 211 |
+
#undef _DEFINE_SYCL_PROP
|
| 212 |
+
#undef DEFINE_DEVICE_PROP
|
| 213 |
+
#undef DEFINE_PLATFORM_PROP
|
| 214 |
+
#undef DEFINE_EXT_DEVICE_PROP
|
| 215 |
+
#undef DEFINE_DEVICE_ASPECT
|
| 216 |
+
#undef DEFINE_EXP_DEVICE_PROP
|
| 217 |
+
|
| 218 |
+
} // namespace c10::xpu
|
| 219 |
+
|
| 220 |
+
#else
|
| 221 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 222 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUEvent.h
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
#include <c10/xpu/XPUStream.h>
|
| 4 |
+
|
| 5 |
+
namespace c10::xpu {
|
| 6 |
+
|
| 7 |
+
/*
|
| 8 |
+
* XPUEvent are movable not copyable wrappers around SYCL event. XPUEvent are
|
| 9 |
+
* constructed lazily when first recorded. It has a device, and this device is
|
| 10 |
+
* acquired from the first recording stream. Later streams that record the event
|
| 11 |
+
* must match the same device.
|
| 12 |
+
*
|
| 13 |
+
* Currently, XPUEvent does NOT support to export an inter-process event from
|
| 14 |
+
* another process via inter-process communication(IPC). So it means that
|
| 15 |
+
* inter-process communication for event handles between different processes is
|
| 16 |
+
* not available. This could impact some applications that rely on cross-process
|
| 17 |
+
* synchronization and communication.
|
| 18 |
+
*/
|
| 19 |
+
struct XPUEvent {
|
| 20 |
+
// Constructors
|
| 21 |
+
XPUEvent(bool enable_timing = false) noexcept
|
| 22 |
+
: enable_timing_{enable_timing} {}
|
| 23 |
+
|
| 24 |
+
~XPUEvent() {
|
| 25 |
+
if (isCreated()) {
|
| 26 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 27 |
+
if (C10_UNLIKELY(interp)) {
|
| 28 |
+
(*interp)->trace_gpu_event_deletion(
|
| 29 |
+
c10::kXPU, reinterpret_cast<uintptr_t>(event_.get()));
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
C10_DISABLE_COPY_AND_ASSIGN(XPUEvent);
|
| 35 |
+
|
| 36 |
+
XPUEvent(XPUEvent&& other) = default;
|
| 37 |
+
XPUEvent& operator=(XPUEvent&& other) = default;
|
| 38 |
+
|
| 39 |
+
operator sycl::event&() const {
|
| 40 |
+
return event();
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
std::optional<c10::Device> device() const {
|
| 44 |
+
if (isCreated()) {
|
| 45 |
+
return c10::Device(c10::kXPU, device_index_);
|
| 46 |
+
} else {
|
| 47 |
+
return std::nullopt;
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
inline bool isCreated() const {
|
| 52 |
+
return (event_.get() != nullptr);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
DeviceIndex device_index() const {
|
| 56 |
+
return device_index_;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
sycl::event& event() const {
|
| 60 |
+
return *event_;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
bool query() const {
|
| 64 |
+
using namespace sycl::info;
|
| 65 |
+
if (!isCreated()) {
|
| 66 |
+
return true;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
return event().get_info<event::command_execution_status>() ==
|
| 70 |
+
event_command_status::complete;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
void record() {
|
| 74 |
+
record(getCurrentXPUStream());
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
void recordOnce(const XPUStream& stream) {
|
| 78 |
+
if (!isCreated()) {
|
| 79 |
+
record(stream);
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
void record(const XPUStream& stream) {
|
| 84 |
+
if (!isCreated()) {
|
| 85 |
+
device_index_ = stream.device_index();
|
| 86 |
+
assignEvent(stream.queue());
|
| 87 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 88 |
+
if (C10_UNLIKELY(interp)) {
|
| 89 |
+
(*interp)->trace_gpu_event_creation(
|
| 90 |
+
c10::kXPU, reinterpret_cast<uintptr_t>(event_.get()));
|
| 91 |
+
}
|
| 92 |
+
} else {
|
| 93 |
+
TORCH_CHECK(
|
| 94 |
+
device_index_ == stream.device_index(),
|
| 95 |
+
"Event device ",
|
| 96 |
+
device_index_,
|
| 97 |
+
" does not match recording stream's device ",
|
| 98 |
+
stream.device_index(),
|
| 99 |
+
".");
|
| 100 |
+
reassignEvent(stream.queue());
|
| 101 |
+
}
|
| 102 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 103 |
+
if (C10_UNLIKELY(interp)) {
|
| 104 |
+
(*interp)->trace_gpu_event_record(
|
| 105 |
+
c10::kXPU,
|
| 106 |
+
reinterpret_cast<uintptr_t>(event_.get()),
|
| 107 |
+
reinterpret_cast<uintptr_t>(&stream.queue()));
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
void block(const XPUStream& stream) {
|
| 112 |
+
if (isCreated()) {
|
| 113 |
+
std::vector<sycl::event> event_list{event()};
|
| 114 |
+
// Make this stream wait until event_ is completed.
|
| 115 |
+
stream.queue().ext_oneapi_submit_barrier(event_list);
|
| 116 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 117 |
+
if (C10_UNLIKELY(interp)) {
|
| 118 |
+
(*interp)->trace_gpu_event_wait(
|
| 119 |
+
c10::kXPU,
|
| 120 |
+
reinterpret_cast<uintptr_t>(event_.get()),
|
| 121 |
+
reinterpret_cast<uintptr_t>(&stream.queue()));
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
double elapsed_time(const XPUEvent& other) const {
|
| 127 |
+
TORCH_CHECK(
|
| 128 |
+
isCreated() && other.isCreated(),
|
| 129 |
+
"Both events must be recorded before calculating elapsed time.");
|
| 130 |
+
TORCH_CHECK(
|
| 131 |
+
query() && other.query(),
|
| 132 |
+
"Both events must be completed before calculating elapsed time.");
|
| 133 |
+
TORCH_CHECK(
|
| 134 |
+
enable_timing_ && other.enable_timing_,
|
| 135 |
+
"Both events must be created with argument 'enable_timing=True'.");
|
| 136 |
+
|
| 137 |
+
using namespace sycl::info::event_profiling;
|
| 138 |
+
// Block until both of the recorded events are completed.
|
| 139 |
+
uint64_t end_time_ns = other.event().get_profiling_info<command_end>();
|
| 140 |
+
uint64_t start_time_ns = event().get_profiling_info<command_end>();
|
| 141 |
+
// Return the eplased time in milliseconds.
|
| 142 |
+
return 1e-6 *
|
| 143 |
+
(static_cast<double>(end_time_ns) - static_cast<double>(start_time_ns));
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
void synchronize() const {
|
| 147 |
+
if (isCreated()) {
|
| 148 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 149 |
+
if (C10_UNLIKELY(interp)) {
|
| 150 |
+
(*interp)->trace_gpu_event_synchronization(
|
| 151 |
+
c10::kXPU, reinterpret_cast<uintptr_t>(event_.get()));
|
| 152 |
+
}
|
| 153 |
+
event().wait_and_throw();
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
private:
|
| 158 |
+
void assignEvent(sycl::queue& queue) {
|
| 159 |
+
if (enable_timing_) {
|
| 160 |
+
event_ = std::make_unique<sycl::event>(
|
| 161 |
+
sycl::ext::oneapi::experimental::submit_profiling_tag(queue));
|
| 162 |
+
} else {
|
| 163 |
+
event_ = std::make_unique<sycl::event>(queue.ext_oneapi_submit_barrier());
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
void reassignEvent(sycl::queue& queue) {
|
| 168 |
+
event_.reset();
|
| 169 |
+
assignEvent(queue);
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
bool enable_timing_ = false;
|
| 173 |
+
c10::DeviceIndex device_index_ = -1;
|
| 174 |
+
// Only need to track the last event, as events in an in-order queue are
|
| 175 |
+
// executed sequentially.
|
| 176 |
+
std::unique_ptr<sycl::event> event_;
|
| 177 |
+
};
|
| 178 |
+
|
| 179 |
+
} // namespace c10::xpu
|
| 180 |
+
|
| 181 |
+
#else
|
| 182 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 183 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUException.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/util/Exception.h>
|
| 5 |
+
#include <sycl/sycl.hpp>
|
| 6 |
+
|
| 7 |
+
namespace c10::xpu {
|
| 8 |
+
|
| 9 |
+
static inline sycl::async_handler asyncHandler =
|
| 10 |
+
[](const sycl::exception_list& el) {
|
| 11 |
+
if (el.size() == 0) {
|
| 12 |
+
return;
|
| 13 |
+
}
|
| 14 |
+
for (const auto& e : el) {
|
| 15 |
+
try {
|
| 16 |
+
std::rethrow_exception(e);
|
| 17 |
+
} catch (sycl::exception& e) {
|
| 18 |
+
TORCH_WARN("SYCL Exception: ", e.what());
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
throw;
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
} // namespace c10::xpu
|
| 25 |
+
|
| 26 |
+
#else
|
| 27 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 28 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUFunctions.h
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/core/Device.h>
|
| 5 |
+
#include <c10/xpu/XPUDeviceProp.h>
|
| 6 |
+
#include <c10/xpu/XPUMacros.h>
|
| 7 |
+
|
| 8 |
+
// The naming convention used here matches the naming convention of torch.xpu
|
| 9 |
+
|
| 10 |
+
namespace c10::xpu {
|
| 11 |
+
|
| 12 |
+
// Log a warning only once if no devices are detected.
|
| 13 |
+
C10_XPU_API DeviceIndex device_count();
|
| 14 |
+
|
| 15 |
+
// Throws an error if no devices are detected.
|
| 16 |
+
C10_XPU_API DeviceIndex device_count_ensure_non_zero();
|
| 17 |
+
|
| 18 |
+
C10_XPU_API DeviceIndex current_device();
|
| 19 |
+
|
| 20 |
+
C10_XPU_API void set_device(DeviceIndex device);
|
| 21 |
+
|
| 22 |
+
C10_XPU_API DeviceIndex exchange_device(DeviceIndex device);
|
| 23 |
+
|
| 24 |
+
C10_XPU_API DeviceIndex maybe_exchange_device(DeviceIndex to_device);
|
| 25 |
+
|
| 26 |
+
C10_XPU_API sycl::device& get_raw_device(DeviceIndex device);
|
| 27 |
+
|
| 28 |
+
C10_XPU_API sycl::context& get_device_context();
|
| 29 |
+
|
| 30 |
+
C10_XPU_API void get_device_properties(
|
| 31 |
+
DeviceProp* device_prop,
|
| 32 |
+
DeviceIndex device);
|
| 33 |
+
|
| 34 |
+
C10_XPU_API DeviceIndex get_device_idx_from_pointer(void* ptr);
|
| 35 |
+
|
| 36 |
+
static inline void check_device_index(DeviceIndex device_index) {
|
| 37 |
+
TORCH_CHECK(
|
| 38 |
+
device_index >= 0 && device_index < c10::xpu::device_count(),
|
| 39 |
+
"The device index is out of range. It must be in [0, ",
|
| 40 |
+
static_cast<int>(c10::xpu::device_count()),
|
| 41 |
+
"), but got ",
|
| 42 |
+
static_cast<int>(device_index),
|
| 43 |
+
".");
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
} // namespace c10::xpu
|
| 47 |
+
|
| 48 |
+
#else
|
| 49 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 50 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUGraphsC10Utils.h
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/xpu/XPUStream.h>
|
| 5 |
+
#include <iostream>
|
| 6 |
+
|
| 7 |
+
// XPU Graphs utils used by c10 and aten.
|
| 8 |
+
using namespace sycl::ext::oneapi::experimental;
|
| 9 |
+
namespace c10::xpu {
|
| 10 |
+
|
| 11 |
+
static_assert(
|
| 12 |
+
int8_t(queue_state::executing) == 0,
|
| 13 |
+
"unexpected int(queue_state::executing) value");
|
| 14 |
+
static_assert(
|
| 15 |
+
int8_t(queue_state::recording) == 1,
|
| 16 |
+
"unexpected int(queue_state::recording) value");
|
| 17 |
+
|
| 18 |
+
enum class CaptureStatus : int8_t {
|
| 19 |
+
Executing = int8_t(queue_state::executing),
|
| 20 |
+
Recording = int8_t(queue_state::recording)
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
inline std::ostream& operator<<(std::ostream& os, CaptureStatus status) {
|
| 24 |
+
switch (status) {
|
| 25 |
+
case CaptureStatus::Executing:
|
| 26 |
+
os << "Executing";
|
| 27 |
+
break;
|
| 28 |
+
case CaptureStatus::Recording:
|
| 29 |
+
os << "Recording";
|
| 30 |
+
break;
|
| 31 |
+
default:
|
| 32 |
+
TORCH_INTERNAL_ASSERT(
|
| 33 |
+
false, "Unknown XPU graph CaptureStatus", int(status));
|
| 34 |
+
}
|
| 35 |
+
return os;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
inline CaptureStatus currentStreamCaptureStatusMayInitCtx() {
|
| 39 |
+
auto state = c10::xpu::getCurrentXPUStream().queue().ext_oneapi_get_state();
|
| 40 |
+
return CaptureStatus(state);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
} // namespace c10::xpu
|
| 44 |
+
|
| 45 |
+
#else
|
| 46 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 47 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUMacros.h
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#ifndef C10_USING_CUSTOM_GENERATED_MACROS
|
| 5 |
+
#include <c10/xpu/impl/xpu_cmake_macros.h>
|
| 6 |
+
#endif
|
| 7 |
+
|
| 8 |
+
// See c10/macros/Export.h for a detailed explanation of what the function
|
| 9 |
+
// of these macros are. We need one set of macros for every separate library
|
| 10 |
+
// we build.
|
| 11 |
+
|
| 12 |
+
#ifdef _WIN32
|
| 13 |
+
#if defined(C10_XPU_BUILD_SHARED_LIBS)
|
| 14 |
+
#define C10_XPU_EXPORT __declspec(dllexport)
|
| 15 |
+
#define C10_XPU_IMPORT __declspec(dllimport)
|
| 16 |
+
#else
|
| 17 |
+
#define C10_XPU_EXPORT
|
| 18 |
+
#define C10_XPU_IMPORT
|
| 19 |
+
#endif
|
| 20 |
+
#else // _WIN32
|
| 21 |
+
#if defined(__GNUC__)
|
| 22 |
+
#define C10_XPU_EXPORT __attribute__((__visibility__("default")))
|
| 23 |
+
#else // defined(__GNUC__)
|
| 24 |
+
#define C10_XPU_EXPORT
|
| 25 |
+
#endif // defined(__GNUC__)
|
| 26 |
+
#define C10_XPU_IMPORT C10_XPU_EXPORT
|
| 27 |
+
#endif // _WIN32
|
| 28 |
+
|
| 29 |
+
// This one is being used by libc10_xpu.so
|
| 30 |
+
#ifdef C10_XPU_BUILD_MAIN_LIB
|
| 31 |
+
#define C10_XPU_API C10_XPU_EXPORT
|
| 32 |
+
#else
|
| 33 |
+
#define C10_XPU_API C10_XPU_IMPORT
|
| 34 |
+
#endif
|
| 35 |
+
|
| 36 |
+
#else
|
| 37 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 38 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/XPUStream.h
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
+
#include <c10/core/Stream.h>
|
| 5 |
+
#include <c10/core/impl/GPUTrace.h>
|
| 6 |
+
#include <c10/xpu/XPUFunctions.h>
|
| 7 |
+
|
| 8 |
+
namespace c10::xpu {
|
| 9 |
+
|
| 10 |
+
/*
|
| 11 |
+
* Note [Stream Management]
|
| 12 |
+
*
|
| 13 |
+
* An XPUStream is an abstraction of an actual SYCL queue in which SYCL kernel
|
| 14 |
+
* can execute. Currently, there are several pools per device to manage SYCL
|
| 15 |
+
* queue, and a device's pool is lazily created.
|
| 16 |
+
*
|
| 17 |
+
* There are two pools per device. The first pool contains "normal priority"
|
| 18 |
+
* queues. The second pool is the "high priority" queues. There are 32 queues in
|
| 19 |
+
* per pool per device, and when a queue is requested one of these queues is
|
| 20 |
+
* returned round-robin. That is, the first queue requested is at index 0, the
|
| 21 |
+
* second at index 1... to index 31, then index 0 again.
|
| 22 |
+
*
|
| 23 |
+
* This means that if 33 queues are requested, the first and last queues
|
| 24 |
+
* requested are actually the same queue (under the covers) and kernels enqueued
|
| 25 |
+
* on them cannot run concurrently.
|
| 26 |
+
*
|
| 27 |
+
* It is safe to enqueue a kernel on the same queue from two different
|
| 28 |
+
* threads as the SYCL specification described.
|
| 29 |
+
*/
|
| 30 |
+
|
| 31 |
+
static constexpr int max_compile_time_stream_priorities = 3;
|
| 32 |
+
|
| 33 |
+
/*
|
| 34 |
+
* This serves as a wrapper around c10::Stream and acts as a representation for
|
| 35 |
+
* a SYCL queue, which allows asynchronous execution of XPU tasks.
|
| 36 |
+
*/
|
| 37 |
+
class C10_XPU_API XPUStream {
|
| 38 |
+
public:
|
| 39 |
+
enum Unchecked { UNCHECKED };
|
| 40 |
+
|
| 41 |
+
/// Construct a XPUStream from a Stream. This construction is checked, and
|
| 42 |
+
/// will raise an error if the Stream is not, in fact, a XPU stream.
|
| 43 |
+
explicit XPUStream(Stream stream) : stream_(stream) {
|
| 44 |
+
TORCH_CHECK(stream_.device_type() == DeviceType::XPU);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/// Construct a XPUStream from a Stream with no error checking.
|
| 48 |
+
explicit XPUStream(Unchecked /*unused*/, Stream stream) : stream_(stream) {}
|
| 49 |
+
|
| 50 |
+
bool operator==(const XPUStream& other) const noexcept {
|
| 51 |
+
return unwrap() == other.unwrap();
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
bool operator!=(const XPUStream& other) const noexcept {
|
| 55 |
+
return unwrap() != other.unwrap();
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/// Implicit conversion to sycl::queue&.
|
| 59 |
+
operator sycl::queue&() const {
|
| 60 |
+
return queue();
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
/// Implicit conversion to sycl::queue*.
|
| 64 |
+
operator sycl::queue*() const {
|
| 65 |
+
return &queue();
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/// Implicit conversion to Stream (a.k.a., forget that the stream is a
|
| 69 |
+
/// XPU stream).
|
| 70 |
+
operator Stream() const {
|
| 71 |
+
return unwrap();
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/// Get the XPU device type that this stream is associated with.
|
| 75 |
+
DeviceType device_type() const {
|
| 76 |
+
return DeviceType::XPU;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/// Get the XPU device index that this stream is associated with.
|
| 80 |
+
DeviceIndex device_index() const {
|
| 81 |
+
return stream_.device_index();
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/// Get the full Device that this stream is associated with. The Device is
|
| 85 |
+
/// guaranteed to be a XPU device.
|
| 86 |
+
Device device() const {
|
| 87 |
+
return Device(DeviceType::XPU, device_index());
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/// Return the stream ID corresponding to this particular stream. StreamId is
|
| 91 |
+
/// a int64_t representation generated by its type and index.
|
| 92 |
+
StreamId id() const {
|
| 93 |
+
return stream_.id();
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/// Return true if all enqueued tasks in this stream have been completed,
|
| 97 |
+
/// otherwise return false.
|
| 98 |
+
bool query() const {
|
| 99 |
+
return queue().ext_oneapi_empty();
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/// Performs a blocking wait for the completion of all enqueued tasks in this
|
| 103 |
+
/// stream.
|
| 104 |
+
void synchronize() const {
|
| 105 |
+
queue().wait_and_throw();
|
| 106 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 107 |
+
if (C10_UNLIKELY(interp)) {
|
| 108 |
+
(*interp)->trace_gpu_stream_synchronization(
|
| 109 |
+
c10::kXPU, reinterpret_cast<uintptr_t>(&queue()));
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
bool is_capturing() const {
|
| 114 |
+
return queue().ext_oneapi_get_state() ==
|
| 115 |
+
sycl::ext::oneapi::experimental::queue_state::recording;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/// Return the priority that this stream is associated with. Lower numbers
|
| 119 |
+
/// represent higher priority.
|
| 120 |
+
int priority() const;
|
| 121 |
+
|
| 122 |
+
/// Explicit conversion to sycl::queue&.
|
| 123 |
+
sycl::queue& queue() const;
|
| 124 |
+
|
| 125 |
+
/// Explicit conversion to Stream.
|
| 126 |
+
Stream unwrap() const {
|
| 127 |
+
return stream_;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/// Reversibly pack a XPUStream into a struct representation. The XPUStream
|
| 131 |
+
/// can be unpacked using unpack3().
|
| 132 |
+
struct c10::StreamData3 pack3() const {
|
| 133 |
+
return stream_.pack3();
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/// Unpack a XPUStream from the 3 fields generated by pack3().
|
| 137 |
+
static XPUStream unpack3(
|
| 138 |
+
StreamId stream_id,
|
| 139 |
+
DeviceIndex device_index,
|
| 140 |
+
DeviceType device_type) {
|
| 141 |
+
return XPUStream(Stream::unpack3(stream_id, device_index, device_type));
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/// Return the range of priority **supported by PyTorch**.
|
| 145 |
+
static std::tuple<int, int> priority_range() {
|
| 146 |
+
// See Note [XPU Stream priorities]
|
| 147 |
+
return std::make_tuple(1, -max_compile_time_stream_priorities + 2);
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
private:
|
| 151 |
+
Stream stream_;
|
| 152 |
+
};
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* Get a stream from the pool in a round-robin fashion.
|
| 156 |
+
*
|
| 157 |
+
* You can request a stream from the highest priority pool by setting
|
| 158 |
+
* isHighPriority to true for a specific device.
|
| 159 |
+
*/
|
| 160 |
+
C10_XPU_API XPUStream
|
| 161 |
+
getStreamFromPool(const bool isHighPriority = false, DeviceIndex device = -1);
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* Get a stream from the pool in a round-robin fashion.
|
| 165 |
+
*
|
| 166 |
+
* You can request a stream by setting a priority value for a specific device.
|
| 167 |
+
* The priority number lower, the priority higher.
|
| 168 |
+
*/
|
| 169 |
+
C10_XPU_API XPUStream
|
| 170 |
+
getStreamFromPool(const int priority, DeviceIndex device = -1);
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Get an XPUStream from an external SYCL queue.
|
| 174 |
+
*
|
| 175 |
+
* This function allows interoperability with other libraries by enabling
|
| 176 |
+
* the use of an external SYCL queue that was not created by PyTorch. This
|
| 177 |
+
* can be useful for data exchange or other operations where integration
|
| 178 |
+
* with non-PyTorch queues is required.
|
| 179 |
+
*
|
| 180 |
+
* NOTE: It is the user's responsibility to ensure that the referenced SYCL
|
| 181 |
+
* queue remains alive while the corresponding XPUStream, or any c10::Stream
|
| 182 |
+
* derived from it, is in use. The different SYCL queue pointers will result in
|
| 183 |
+
* distinct XPUStream instances, even if the SYCL queues they dereference are
|
| 184 |
+
* equivalent.
|
| 185 |
+
*/
|
| 186 |
+
C10_XPU_API XPUStream
|
| 187 |
+
getStreamFromExternal(sycl::queue* ext_queue, DeviceIndex device_index);
|
| 188 |
+
|
| 189 |
+
/**
|
| 190 |
+
* Get the current XPU stream, for the passed XPU device, or for the current
|
| 191 |
+
* device if no device index is passed.
|
| 192 |
+
*/
|
| 193 |
+
C10_XPU_API XPUStream getCurrentXPUStream(DeviceIndex device = -1);
|
| 194 |
+
|
| 195 |
+
/**
|
| 196 |
+
* Set the current stream on the device of the passed in stream to be the passed
|
| 197 |
+
* in stream.
|
| 198 |
+
*/
|
| 199 |
+
C10_XPU_API void setCurrentXPUStream(XPUStream stream);
|
| 200 |
+
|
| 201 |
+
C10_XPU_API std::ostream& operator<<(std::ostream& stream, const XPUStream& s);
|
| 202 |
+
|
| 203 |
+
/**
|
| 204 |
+
* Block all reserved SYCL queues in the stream pools on the device, and wait
|
| 205 |
+
* for their synchronizations.
|
| 206 |
+
*/
|
| 207 |
+
C10_XPU_API void syncStreamsOnDevice(DeviceIndex device = -1);
|
| 208 |
+
|
| 209 |
+
} // namespace c10::xpu
|
| 210 |
+
|
| 211 |
+
namespace std {
|
| 212 |
+
template <>
|
| 213 |
+
struct hash<c10::xpu::XPUStream> {
|
| 214 |
+
size_t operator()(c10::xpu::XPUStream s) const noexcept {
|
| 215 |
+
return std::hash<c10::Stream>{}(s.unwrap());
|
| 216 |
+
}
|
| 217 |
+
};
|
| 218 |
+
} // namespace std
|
| 219 |
+
|
| 220 |
+
#else
|
| 221 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 222 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/impl/XPUGuardImpl.h
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/core/DeviceGuard.h>
|
| 5 |
+
#include <c10/core/impl/DeviceGuardImplInterface.h>
|
| 6 |
+
#include <c10/core/impl/GPUTrace.h>
|
| 7 |
+
#include <c10/xpu/XPUCachingAllocator.h>
|
| 8 |
+
#include <c10/xpu/XPUFunctions.h>
|
| 9 |
+
#include <c10/xpu/XPUStream.h>
|
| 10 |
+
|
| 11 |
+
#include <vector>
|
| 12 |
+
|
| 13 |
+
namespace c10::xpu::impl {
|
| 14 |
+
|
| 15 |
+
struct XPUGuardImpl final : public c10::impl::DeviceGuardImplInterface {
|
| 16 |
+
static constexpr DeviceType static_type = kXPU;
|
| 17 |
+
|
| 18 |
+
XPUGuardImpl() = default;
|
| 19 |
+
|
| 20 |
+
explicit XPUGuardImpl(DeviceType t) {
|
| 21 |
+
TORCH_CHECK(
|
| 22 |
+
t == kXPU, "XPUGuardImpl initialized with non-XPU DeviceType: ", t);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
DeviceType type() const override {
|
| 26 |
+
return kXPU;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
Device exchangeDevice(Device d) const override {
|
| 30 |
+
TORCH_CHECK(d.is_xpu(), "Expected a XPU device, but got ", d);
|
| 31 |
+
const auto old_device_index = c10::xpu::exchange_device(d.index());
|
| 32 |
+
return Device(kXPU, old_device_index);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
Device getDevice() const override {
|
| 36 |
+
const auto device = c10::xpu::current_device();
|
| 37 |
+
return Device(kXPU, device);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
void setDevice(Device d) const override {
|
| 41 |
+
TORCH_CHECK(d.is_xpu(), "Expected a XPU device, but got ", d);
|
| 42 |
+
c10::xpu::set_device(d.index());
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
void uncheckedSetDevice(Device d) const noexcept override {
|
| 46 |
+
c10::xpu::set_device(d.index());
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
DeviceCapability getDeviceCapability(Device d) const override {
|
| 50 |
+
DeviceCapability cap;
|
| 51 |
+
cap.capability_data.capability_bits = (1ULL << kIndex_Byte) |
|
| 52 |
+
(1ULL << kIndex_Char) | (1ULL << kIndex_Short) | (1ULL << kIndex_Int) |
|
| 53 |
+
(1ULL << kIndex_Long) | (1ULL << kIndex_Float) |
|
| 54 |
+
(1ULL << kIndex_ComplexFloat) | (1ULL << kIndex_Bool) |
|
| 55 |
+
(1ULL << kIndex_Float8_e5m2) | (1ULL << kIndex_Float8_e4m3fn) |
|
| 56 |
+
(1ULL << kIndex_Float8_e5m2fnuz) | (1ULL << kIndex_Float8_e4m3fnuz) |
|
| 57 |
+
(1ULL << kIndex_Float8_e8m0fnu) | (1ULL << kIndex_UInt16) |
|
| 58 |
+
(1ULL << kIndex_UInt32) | (1ULL << kIndex_UInt64);
|
| 59 |
+
// BFloat16 may be emulated. We always assume BFloat16 is available;
|
| 60 |
+
// users can call is_bf16_supported() to check for native hardware support.
|
| 61 |
+
cap.capability_data.capability_bits |= (1ULL << kIndex_BFloat16);
|
| 62 |
+
auto& device = c10::xpu::get_raw_device(d.index());
|
| 63 |
+
if (device.has(sycl::aspect::fp16)) {
|
| 64 |
+
cap.capability_data.capability_bits |= (1ULL << kIndex_Half);
|
| 65 |
+
cap.capability_data.capability_bits |= (1ULL << kIndex_ComplexHalf);
|
| 66 |
+
}
|
| 67 |
+
if (device.has(sycl::aspect::fp64)) {
|
| 68 |
+
cap.capability_data.capability_bits |= (1ULL << kIndex_Double);
|
| 69 |
+
cap.capability_data.capability_bits |= (1ULL << kIndex_ComplexDouble);
|
| 70 |
+
}
|
| 71 |
+
return cap;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
Stream getStream(Device d) const override {
|
| 75 |
+
return getCurrentXPUStream(d.index()).unwrap();
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
Stream getNewStream(Device d, int priority = 0) const override {
|
| 79 |
+
return getStreamFromPool(priority, d.index());
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
Stream getStreamFromGlobalPool(Device d, bool isHighPriority = false)
|
| 83 |
+
const override {
|
| 84 |
+
return getStreamFromPool(isHighPriority, d.index());
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// NB: These do NOT set the current device
|
| 88 |
+
Stream exchangeStream(Stream s) const override {
|
| 89 |
+
const XPUStream stream(s);
|
| 90 |
+
const auto old_stream = getCurrentXPUStream(s.device().index());
|
| 91 |
+
setCurrentXPUStream(stream);
|
| 92 |
+
return old_stream.unwrap();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
void* getStreamNativeHandle(const Stream s) const override {
|
| 96 |
+
const XPUStream stream{s};
|
| 97 |
+
return reinterpret_cast<void*>(&(stream.queue()));
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
DeviceIndex deviceCount() const noexcept override {
|
| 101 |
+
return c10::xpu::device_count();
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
// Event-related functions
|
| 105 |
+
void destroyEvent(void* event, const DeviceIndex device_index)
|
| 106 |
+
const noexcept override {
|
| 107 |
+
if (!event)
|
| 108 |
+
return;
|
| 109 |
+
|
| 110 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 111 |
+
if (C10_UNLIKELY(interp)) {
|
| 112 |
+
(*interp)->trace_gpu_event_deletion(
|
| 113 |
+
c10::kXPU, reinterpret_cast<uintptr_t>(event));
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
delete reinterpret_cast<sycl::event*>(event);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
void record(
|
| 120 |
+
void** event,
|
| 121 |
+
const Stream& stream,
|
| 122 |
+
const DeviceIndex device_index,
|
| 123 |
+
const EventFlag flag) const override {
|
| 124 |
+
TORCH_CHECK(
|
| 125 |
+
device_index == -1 || device_index == stream.device_index(),
|
| 126 |
+
"Event device index ",
|
| 127 |
+
device_index,
|
| 128 |
+
" does not match recording stream's device index ",
|
| 129 |
+
stream.device_index(),
|
| 130 |
+
".");
|
| 131 |
+
|
| 132 |
+
auto* xpu_event = reinterpret_cast<sycl::event*>(*event);
|
| 133 |
+
const XPUStream xpu_stream{stream};
|
| 134 |
+
|
| 135 |
+
// Delete the event previously recorded.
|
| 136 |
+
if (xpu_event)
|
| 137 |
+
delete xpu_event;
|
| 138 |
+
#if SYCL_COMPILER_VERSION >= 20250000
|
| 139 |
+
if (flag == EventFlag::BACKEND_DEFAULT) {
|
| 140 |
+
// Use the profiling tag to record the event to enable timing feature.
|
| 141 |
+
xpu_event =
|
| 142 |
+
new sycl::event(sycl::ext::oneapi::experimental::submit_profiling_tag(
|
| 143 |
+
xpu_stream.queue()));
|
| 144 |
+
} else {
|
| 145 |
+
xpu_event =
|
| 146 |
+
new sycl::event(xpu_stream.queue().ext_oneapi_submit_barrier());
|
| 147 |
+
}
|
| 148 |
+
#else
|
| 149 |
+
xpu_event = new sycl::event(xpu_stream.queue().ext_oneapi_submit_barrier());
|
| 150 |
+
#endif
|
| 151 |
+
*event = reinterpret_cast<void*>(xpu_event);
|
| 152 |
+
|
| 153 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 154 |
+
if (C10_UNLIKELY(interp)) {
|
| 155 |
+
(*interp)->trace_gpu_event_record(
|
| 156 |
+
c10::kXPU,
|
| 157 |
+
reinterpret_cast<uintptr_t>(xpu_event),
|
| 158 |
+
reinterpret_cast<uintptr_t>(&xpu_stream.queue()));
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
void block(void* event, const Stream& stream) const override {
|
| 163 |
+
if (!event)
|
| 164 |
+
return;
|
| 165 |
+
auto* xpu_event = reinterpret_cast<sycl::event*>(event);
|
| 166 |
+
std::vector<sycl::event> event_list{*xpu_event};
|
| 167 |
+
const XPUStream xpu_stream(stream);
|
| 168 |
+
xpu_stream.queue().ext_oneapi_submit_barrier(event_list);
|
| 169 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 170 |
+
if (C10_UNLIKELY(interp)) {
|
| 171 |
+
(*interp)->trace_gpu_event_wait(
|
| 172 |
+
c10::kXPU,
|
| 173 |
+
reinterpret_cast<uintptr_t>(xpu_event),
|
| 174 |
+
reinterpret_cast<uintptr_t>(&xpu_stream.queue()));
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
bool queryEvent(void* event) const override {
|
| 179 |
+
using namespace sycl::info;
|
| 180 |
+
if (!event)
|
| 181 |
+
return true;
|
| 182 |
+
auto* xpu_event = reinterpret_cast<sycl::event*>(event);
|
| 183 |
+
return xpu_event->get_info<event::command_execution_status>() ==
|
| 184 |
+
event_command_status::complete;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
double elapsedTime(
|
| 188 |
+
void* start_event,
|
| 189 |
+
void* end_event,
|
| 190 |
+
const DeviceIndex device_index) const override {
|
| 191 |
+
#if SYCL_COMPILER_VERSION < 20250000
|
| 192 |
+
TORCH_CHECK_NOT_IMPLEMENTED(
|
| 193 |
+
false,
|
| 194 |
+
"elapsedTime requires PyTorch to be built with SYCL compiler version 2025.0.0 or newer.");
|
| 195 |
+
#endif
|
| 196 |
+
TORCH_CHECK(
|
| 197 |
+
start_event && end_event,
|
| 198 |
+
"Both events must be recorded before calculating elapsed time.");
|
| 199 |
+
auto* xpu_start_event = reinterpret_cast<sycl::event*>(start_event);
|
| 200 |
+
auto* xpu_end_event = reinterpret_cast<sycl::event*>(end_event);
|
| 201 |
+
|
| 202 |
+
using namespace sycl::info::event_profiling;
|
| 203 |
+
// Block until both of the recorded events are completed.
|
| 204 |
+
uint64_t end_time_ns = xpu_end_event->get_profiling_info<command_end>();
|
| 205 |
+
uint64_t start_time_ns = xpu_start_event->get_profiling_info<command_end>();
|
| 206 |
+
// Return the eplased time in milliseconds.
|
| 207 |
+
return 1e-6 *
|
| 208 |
+
(static_cast<double>(end_time_ns) - static_cast<double>(start_time_ns));
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
// Stream-related functions
|
| 212 |
+
bool queryStream(const Stream& stream) const override {
|
| 213 |
+
const XPUStream xpu_stream{stream};
|
| 214 |
+
return xpu_stream.query();
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
void synchronizeStream(const Stream& stream) const override {
|
| 218 |
+
const XPUStream xpu_stream{stream};
|
| 219 |
+
xpu_stream.synchronize();
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
bool isStreamCapturing(const Stream& stream) const override {
|
| 223 |
+
const XPUStream xpu_stream{stream};
|
| 224 |
+
return xpu_stream.is_capturing();
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
void synchronizeEvent(void* event) const override {
|
| 228 |
+
if (!event)
|
| 229 |
+
return;
|
| 230 |
+
auto* xpu_event = reinterpret_cast<sycl::event*>(event);
|
| 231 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 232 |
+
if (C10_UNLIKELY(interp)) {
|
| 233 |
+
(*interp)->trace_gpu_event_synchronization(
|
| 234 |
+
c10::kXPU, reinterpret_cast<uintptr_t>(xpu_event));
|
| 235 |
+
}
|
| 236 |
+
xpu_event->wait_and_throw();
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
void synchronizeDevice(const c10::DeviceIndex device_index) const override {
|
| 240 |
+
const c10::impl::PyInterpreter* interp = c10::impl::GPUTrace::get_trace();
|
| 241 |
+
if (C10_UNLIKELY(interp)) {
|
| 242 |
+
(*interp)->trace_gpu_device_synchronization(c10::kXPU);
|
| 243 |
+
}
|
| 244 |
+
c10::xpu::syncStreamsOnDevice(device_index);
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
void recordDataPtrOnStream(const c10::DataPtr& data_ptr, const Stream& stream)
|
| 248 |
+
const override {
|
| 249 |
+
const XPUStream xpu_stream{stream};
|
| 250 |
+
XPUCachingAllocator::recordStream(data_ptr, xpu_stream);
|
| 251 |
+
}
|
| 252 |
+
};
|
| 253 |
+
|
| 254 |
+
} // namespace c10::xpu::impl
|
| 255 |
+
|
| 256 |
+
#else
|
| 257 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 258 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/c10/xpu/test/impl/XPUTest.h
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#include <gtest/gtest.h>
|
| 3 |
+
|
| 4 |
+
#include <c10/util/irange.h>
|
| 5 |
+
|
| 6 |
+
static inline void initHostData(int* hostData, int numel) {
|
| 7 |
+
for (const auto i : c10::irange(numel)) {
|
| 8 |
+
hostData[i] = i;
|
| 9 |
+
}
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
static inline void clearHostData(int* hostData, int numel) {
|
| 13 |
+
for (const auto i : c10::irange(numel)) {
|
| 14 |
+
hostData[i] = 0;
|
| 15 |
+
}
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
static inline void validateHostData(int* hostData, int numel) {
|
| 19 |
+
for (const auto i : c10::irange(numel)) {
|
| 20 |
+
EXPECT_EQ(hostData[i], i);
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
#else
|
| 25 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 26 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/core/common.h
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef CAFFE2_CORE_COMMON_H_
|
| 3 |
+
#define CAFFE2_CORE_COMMON_H_
|
| 4 |
+
|
| 5 |
+
#include <algorithm>
|
| 6 |
+
#include <cmath>
|
| 7 |
+
#include <map>
|
| 8 |
+
#include <memory>
|
| 9 |
+
#include <numeric>
|
| 10 |
+
#include <set>
|
| 11 |
+
#include <sstream>
|
| 12 |
+
#include <string>
|
| 13 |
+
#include <type_traits>
|
| 14 |
+
#include <vector>
|
| 15 |
+
|
| 16 |
+
#ifdef __APPLE__
|
| 17 |
+
#include <TargetConditionals.h>
|
| 18 |
+
#endif
|
| 19 |
+
|
| 20 |
+
#if defined(_MSC_VER)
|
| 21 |
+
#include <io.h>
|
| 22 |
+
#else
|
| 23 |
+
#include <unistd.h>
|
| 24 |
+
#endif
|
| 25 |
+
|
| 26 |
+
// Macros used during the build of this caffe2 instance. This header file
|
| 27 |
+
// is automatically generated by the cmake script during build.
|
| 28 |
+
#include "caffe2/core/macros.h"
|
| 29 |
+
|
| 30 |
+
#include <c10/macros/Macros.h>
|
| 31 |
+
|
| 32 |
+
namespace caffe2 {
|
| 33 |
+
|
| 34 |
+
// Using statements for common classes that we refer to in caffe2 very often.
|
| 35 |
+
// Note that we only place it inside caffe2 so the global namespace is not
|
| 36 |
+
// polluted.
|
| 37 |
+
/* using override */
|
| 38 |
+
using std::set;
|
| 39 |
+
using std::string;
|
| 40 |
+
using std::unique_ptr;
|
| 41 |
+
using std::vector;
|
| 42 |
+
|
| 43 |
+
// Define alignment macro that is cross platform
|
| 44 |
+
#if (defined _MSC_VER && !defined NOMINMAX)
|
| 45 |
+
#define NOMINMAX
|
| 46 |
+
#endif
|
| 47 |
+
|
| 48 |
+
using std::make_unique;
|
| 49 |
+
|
| 50 |
+
#if defined(__ANDROID__) && !defined(__NDK_MAJOR__)
|
| 51 |
+
using ::round;
|
| 52 |
+
#else
|
| 53 |
+
using std::round;
|
| 54 |
+
#endif // defined(__ANDROID__) && !defined(__NDK_MAJOR__)
|
| 55 |
+
|
| 56 |
+
// Returns which setting Caffe2 was configured and built with (exported from
|
| 57 |
+
// CMake)
|
| 58 |
+
TORCH_API const std::map<string, string>& GetBuildOptions();
|
| 59 |
+
|
| 60 |
+
} // namespace caffe2
|
| 61 |
+
|
| 62 |
+
#endif // CAFFE2_CORE_COMMON_H_
|
| 63 |
+
|
| 64 |
+
#else
|
| 65 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 66 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/core/macros.h
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
// Automatically generated header file for caffe2 macros. These
|
| 3 |
+
// macros are used to build the Caffe2 binary, and if you are
|
| 4 |
+
// building a dependent library, they will need to be set as well
|
| 5 |
+
// for your program to link correctly.
|
| 6 |
+
|
| 7 |
+
#pragma once
|
| 8 |
+
|
| 9 |
+
#define CAFFE2_BUILD_SHARED_LIBS
|
| 10 |
+
/* #undef CAFFE2_FORCE_FALLBACK_CUDA_MPI */
|
| 11 |
+
/* #undef CAFFE2_HAS_MKL_DNN */
|
| 12 |
+
/* #undef CAFFE2_HAS_MKL_SGEMM_PACK */
|
| 13 |
+
#define CAFFE2_PERF_WITH_AVX
|
| 14 |
+
#define CAFFE2_PERF_WITH_AVX2
|
| 15 |
+
/* #undef CAFFE2_THREADPOOL_MAIN_IMBALANCE */
|
| 16 |
+
/* #undef CAFFE2_THREADPOOL_STATS */
|
| 17 |
+
/* #undef CAFFE2_USE_ACCELERATE */
|
| 18 |
+
#define CAFFE2_USE_CUDNN
|
| 19 |
+
/* #undef CAFFE2_USE_EIGEN_FOR_BLAS */
|
| 20 |
+
/* #undef CAFFE2_USE_FBCODE */
|
| 21 |
+
/* #undef CAFFE2_USE_GOOGLE_GLOG */
|
| 22 |
+
/* #undef CAFFE2_USE_LITE_PROTO */
|
| 23 |
+
/* #undef CAFFE2_USE_MKL */
|
| 24 |
+
#define USE_MKLDNN
|
| 25 |
+
/* #undef CAFFE2_USE_NVTX */
|
| 26 |
+
/* #undef CAFFE2_USE_ITT */
|
| 27 |
+
|
| 28 |
+
#ifndef EIGEN_MPL2_ONLY
|
| 29 |
+
#define EIGEN_MPL2_ONLY
|
| 30 |
+
#endif
|
| 31 |
+
|
| 32 |
+
// Useful build settings that are recorded in the compiled binary
|
| 33 |
+
// torch.__config__.show()
|
| 34 |
+
#define CAFFE2_BUILD_STRINGS { \
|
| 35 |
+
{"TORCH_VERSION", "2.12.1"}, \
|
| 36 |
+
{"CXX_COMPILER", "/cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/x86_64-pc-linux-gnu/gcc-bin/12/c++"}, \
|
| 37 |
+
{"CXX_FLAGS", " -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DLIBKINETO_NOXPUPTI=ON -DUSE_FBGEMM -DUSE_MSLK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -DC10_NODEPRECATED -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=range-loop-construct -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-unused-parameter -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wsuggest-override -Wno-psabi -Wno-error=old-style-cast -faligned-new -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow"}, \
|
| 38 |
+
{"CUDA_FLAGS", " -DLIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_OPERATIONS -Xfatbin -compress-all -DONNX_NAMESPACE=onnx_torch -gencode arch=compute_80,code=sm_80 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_100,code=sm_100 -gencode arch=compute_100,code=compute_100 -Xcudafe --diag_suppress=cc_clobber_ignored,--diag_suppress=field_without_dll_interface,--diag_suppress=base_class_has_different_dll_interface,--diag_suppress=dll_interface_conflict_none_assumed,--diag_suppress=dll_interface_conflict_dllexport_assumed,--diag_suppress=bad_friend_decl --expt-relaxed-constexpr --expt-extended-lambda -Wno-deprecated-gpu-targets --expt-extended-lambda -DCUB_WRAPPED_NAMESPACE=at_cuda_detail -DDISABLE_CUSPARSE_DEPRECATED -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -DC10_NODEPRECATED"}, \
|
| 39 |
+
{"BUILD_TYPE", "Release"}, \
|
| 40 |
+
{"BLAS_INFO", "flexi"}, \
|
| 41 |
+
{"LAPACK_INFO", "flexi"}, \
|
| 42 |
+
{"USE_CUDA", "ON"}, \
|
| 43 |
+
{"USE_ROCM", "OFF"}, \
|
| 44 |
+
{"CUDA_VERSION", "13.2"}, \
|
| 45 |
+
{"ROCM_VERSION", ""}, \
|
| 46 |
+
{"USE_CUDNN", "ON"}, \
|
| 47 |
+
{"COMMIT_SHA", "7269437d655783a26cba32aa88195b741ff496aa"}, \
|
| 48 |
+
{"CUDNN_VERSION", "9.21.1"}, \
|
| 49 |
+
{"USE_NCCL", "ON"}, \
|
| 50 |
+
{"USE_MPI", "ON"}, \
|
| 51 |
+
{"USE_GFLAGS", "OFF"}, \
|
| 52 |
+
{"USE_GLOG", "OFF"}, \
|
| 53 |
+
{"USE_GLOO", "ON"}, \
|
| 54 |
+
{"USE_NNPACK", "ON"}, \
|
| 55 |
+
{"USE_OPENMP", "ON"}, \
|
| 56 |
+
{"FORCE_FALLBACK_CUDA_MPI", ""}, \
|
| 57 |
+
{"HAS_MKL_DNN", ""}, \
|
| 58 |
+
{"HAS_MKL_SGEMM_PACK", ""}, \
|
| 59 |
+
{"PERF_WITH_AVX", "1"}, \
|
| 60 |
+
{"PERF_WITH_AVX2", "1"}, \
|
| 61 |
+
{"USE_ACCELERATE", ""}, \
|
| 62 |
+
{"USE_EIGEN_FOR_BLAS", ""}, \
|
| 63 |
+
{"USE_LITE_PROTO", ""}, \
|
| 64 |
+
{"USE_MKL", ""}, \
|
| 65 |
+
{"USE_MKLDNN", "ON"}, \
|
| 66 |
+
{"USE_NVTX", ""}, \
|
| 67 |
+
{"USE_ITT", ""}, \
|
| 68 |
+
{"USE_ROCM_KERNEL_ASSERT", "OFF"}, \
|
| 69 |
+
{"USE_CUSPARSELT", "ON"}, \
|
| 70 |
+
{"USE_XPU", "OFF"}, \
|
| 71 |
+
{"USE_XCCL", "OFF"}, \
|
| 72 |
+
{"SYCL_COMPILER_VERSION", ""}, \
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
#else
|
| 76 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 77 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/core/timer.h
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef CAFFE2_CORE_TIMER_H_
|
| 3 |
+
#define CAFFE2_CORE_TIMER_H_
|
| 4 |
+
|
| 5 |
+
#include <chrono>
|
| 6 |
+
|
| 7 |
+
#include "caffe2/core/common.h"
|
| 8 |
+
|
| 9 |
+
namespace caffe2 {
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* @brief A simple timer object for measuring time.
|
| 13 |
+
*
|
| 14 |
+
* This is a minimal class around a std::chrono::high_resolution_clock that
|
| 15 |
+
* serves as a utility class for testing code.
|
| 16 |
+
*/
|
| 17 |
+
class Timer {
|
| 18 |
+
public:
|
| 19 |
+
typedef std::chrono::high_resolution_clock clock;
|
| 20 |
+
typedef std::chrono::nanoseconds ns;
|
| 21 |
+
Timer() { Start(); }
|
| 22 |
+
/**
|
| 23 |
+
* @brief Starts a timer.
|
| 24 |
+
*/
|
| 25 |
+
inline void Start() { start_time_ = clock::now(); }
|
| 26 |
+
inline float NanoSeconds() {
|
| 27 |
+
return static_cast<float>(
|
| 28 |
+
std::chrono::duration_cast<ns>(clock::now() - start_time_).count());
|
| 29 |
+
}
|
| 30 |
+
/**
|
| 31 |
+
* @brief Returns the elapsed time in milliseconds.
|
| 32 |
+
*/
|
| 33 |
+
inline float MilliSeconds() { return NanoSeconds() / 1000000.f; }
|
| 34 |
+
/**
|
| 35 |
+
* @brief Returns the elapsed time in microseconds.
|
| 36 |
+
*/
|
| 37 |
+
inline float MicroSeconds() { return NanoSeconds() / 1000.f; }
|
| 38 |
+
/**
|
| 39 |
+
* @brief Returns the elapsed time in seconds.
|
| 40 |
+
*/
|
| 41 |
+
inline float Seconds() { return NanoSeconds() / 1000000000.f; }
|
| 42 |
+
|
| 43 |
+
protected:
|
| 44 |
+
std::chrono::time_point<clock> start_time_;
|
| 45 |
+
C10_DISABLE_COPY_AND_ASSIGN(Timer);
|
| 46 |
+
};
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
#endif // CAFFE2_CORE_TIMER_H_
|
| 50 |
+
|
| 51 |
+
#else
|
| 52 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 53 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/perfkernels/common.h
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
// !!!! PLEASE READ !!!!
|
| 3 |
+
// Minimize (transitively) included headers from _avx*.cc because some of the
|
| 4 |
+
// functions defined in the headers compiled with platform dependent compiler
|
| 5 |
+
// options can be reused by other translation units generating illegal
|
| 6 |
+
// instruction run-time error.
|
| 7 |
+
|
| 8 |
+
// Common utilities for writing performance kernels and easy dispatching of
|
| 9 |
+
// different backends.
|
| 10 |
+
/*
|
| 11 |
+
The general workflow shall be as follows, say we want to
|
| 12 |
+
implement a functionality called void foo(int a, float b).
|
| 13 |
+
|
| 14 |
+
In foo.h, do:
|
| 15 |
+
void foo(int a, float b);
|
| 16 |
+
|
| 17 |
+
In foo_avx512.cc, do:
|
| 18 |
+
void foo__avx512(int a, float b) {
|
| 19 |
+
[actual avx512 implementation]
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
In foo_avx2.cc, do:
|
| 23 |
+
void foo__avx2(int a, float b) {
|
| 24 |
+
[actual avx2 implementation]
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
In foo_avx.cc, do:
|
| 28 |
+
void foo__avx(int a, float b) {
|
| 29 |
+
[actual avx implementation]
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
In foo.cc, do:
|
| 33 |
+
// The base implementation should *always* be provided.
|
| 34 |
+
void foo__base(int a, float b) {
|
| 35 |
+
[base, possibly slow implementation]
|
| 36 |
+
}
|
| 37 |
+
decltype(foo__base) foo__avx512;
|
| 38 |
+
decltype(foo__base) foo__avx2;
|
| 39 |
+
decltype(foo__base) foo__avx;
|
| 40 |
+
void foo(int a, float b) {
|
| 41 |
+
// You should always order things by their preference, faster
|
| 42 |
+
// implementations earlier in the function.
|
| 43 |
+
AVX512_DO(foo, a, b);
|
| 44 |
+
AVX2_DO(foo, a, b);
|
| 45 |
+
AVX_DO(foo, a, b);
|
| 46 |
+
BASE_DO(foo, a, b);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
*/
|
| 50 |
+
// Details: this functionality basically covers the cases for both build time
|
| 51 |
+
// and run time architecture support.
|
| 52 |
+
//
|
| 53 |
+
// During build time:
|
| 54 |
+
// The build system should provide flags CAFFE2_PERF_WITH_AVX512,
|
| 55 |
+
// CAFFE2_PERF_WITH_AVX2, and CAFFE2_PERF_WITH_AVX that corresponds to the
|
| 56 |
+
// __AVX512F__, __AVX512DQ__, __AVX512VL__, __AVX2__, and __AVX__ flags the
|
| 57 |
+
// compiler provides. Note that we do not use the compiler flags but rely on
|
| 58 |
+
// the build system flags, because the common files (like foo.cc above) will
|
| 59 |
+
// always be built without __AVX512F__, __AVX512DQ__, __AVX512VL__, __AVX2__
|
| 60 |
+
// and __AVX__.
|
| 61 |
+
// During run time:
|
| 62 |
+
// we use cpuinfo to identify cpu support and run the proper functions.
|
| 63 |
+
|
| 64 |
+
#pragma once
|
| 65 |
+
#if defined(CAFFE2_PERF_WITH_SVE) || defined(CAFFE2_PERF_WITH_AVX512) || \
|
| 66 |
+
defined(CAFFE2_PERF_WITH_AVX2) || defined(CAFFE2_PERF_WITH_AVX)
|
| 67 |
+
#include <cpuinfo.h>
|
| 68 |
+
#endif
|
| 69 |
+
|
| 70 |
+
// DO macros: these should be used in your entry function, similar to foo()
|
| 71 |
+
// above, that routes implementations based on CPU capability.
|
| 72 |
+
|
| 73 |
+
#define BASE_DO(funcname, ...) return funcname##__base(__VA_ARGS__);
|
| 74 |
+
|
| 75 |
+
#ifdef CAFFE2_PERF_WITH_SVE
|
| 76 |
+
#define SVE_DO(funcname, ...) \
|
| 77 |
+
{ \
|
| 78 |
+
static const bool isDo = cpuinfo_initialize() && cpuinfo_has_arm_sve(); \
|
| 79 |
+
if (isDo) { \
|
| 80 |
+
return funcname##__sve(__VA_ARGS__); \
|
| 81 |
+
} \
|
| 82 |
+
}
|
| 83 |
+
#else // CAFFE2_PERF_WITH_SVE
|
| 84 |
+
#define SVE_DO(funcname, ...)
|
| 85 |
+
#endif // CAFFE2_PERF_WITH_SVE
|
| 86 |
+
|
| 87 |
+
#ifdef CAFFE2_PERF_WITH_AVX512
|
| 88 |
+
#define AVX512_DO(funcname, ...) \
|
| 89 |
+
{ \
|
| 90 |
+
static const bool isDo = cpuinfo_initialize() && \
|
| 91 |
+
cpuinfo_has_x86_avx512f() && cpuinfo_has_x86_avx512dq() && \
|
| 92 |
+
cpuinfo_has_x86_avx512vl(); \
|
| 93 |
+
if (isDo) { \
|
| 94 |
+
return funcname##__avx512(__VA_ARGS__); \
|
| 95 |
+
} \
|
| 96 |
+
}
|
| 97 |
+
#else // CAFFE2_PERF_WITH_AVX512
|
| 98 |
+
#define AVX512_DO(funcname, ...)
|
| 99 |
+
#endif // CAFFE2_PERF_WITH_AVX512
|
| 100 |
+
|
| 101 |
+
#ifdef CAFFE2_PERF_WITH_AVX2
|
| 102 |
+
#define AVX2_DO(funcname, ...) \
|
| 103 |
+
{ \
|
| 104 |
+
static const bool isDo = cpuinfo_initialize() && cpuinfo_has_x86_avx2(); \
|
| 105 |
+
if (isDo) { \
|
| 106 |
+
return funcname##__avx2(__VA_ARGS__); \
|
| 107 |
+
} \
|
| 108 |
+
}
|
| 109 |
+
#define AVX2_FMA_DO(funcname, ...) \
|
| 110 |
+
{ \
|
| 111 |
+
static const bool isDo = cpuinfo_initialize() && cpuinfo_has_x86_avx2() && \
|
| 112 |
+
cpuinfo_has_x86_fma3(); \
|
| 113 |
+
if (isDo) { \
|
| 114 |
+
return funcname##__avx2_fma(__VA_ARGS__); \
|
| 115 |
+
} \
|
| 116 |
+
}
|
| 117 |
+
#else // CAFFE2_PERF_WITH_AVX2
|
| 118 |
+
#define AVX2_DO(funcname, ...)
|
| 119 |
+
#define AVX2_FMA_DO(funcname, ...)
|
| 120 |
+
#endif // CAFFE2_PERF_WITH_AVX2
|
| 121 |
+
|
| 122 |
+
#ifdef CAFFE2_PERF_WITH_AVX
|
| 123 |
+
#define AVX_DO(funcname, ...) \
|
| 124 |
+
{ \
|
| 125 |
+
static const bool isDo = cpuinfo_initialize() && cpuinfo_has_x86_avx(); \
|
| 126 |
+
if (isDo) { \
|
| 127 |
+
return funcname##__avx(__VA_ARGS__); \
|
| 128 |
+
} \
|
| 129 |
+
}
|
| 130 |
+
#define AVX_F16C_DO(funcname, ...) \
|
| 131 |
+
{ \
|
| 132 |
+
static const bool isDo = cpuinfo_initialize() && cpuinfo_has_x86_avx() && \
|
| 133 |
+
cpuinfo_has_x86_f16c(); \
|
| 134 |
+
if (isDo) { \
|
| 135 |
+
return funcname##__avx_f16c(__VA_ARGS__); \
|
| 136 |
+
} \
|
| 137 |
+
}
|
| 138 |
+
#else // CAFFE2_PERF_WITH_AVX
|
| 139 |
+
#define AVX_DO(funcname, ...)
|
| 140 |
+
#define AVX_F16C_DO(funcname, ...)
|
| 141 |
+
#endif // CAFFE2_PERF_WITH_AVX
|
| 142 |
+
|
| 143 |
+
#else
|
| 144 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 145 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/perfkernels/embedding_lookup_idx.h
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <cstdint>
|
| 5 |
+
|
| 6 |
+
namespace caffe2 {
|
| 7 |
+
|
| 8 |
+
// clang-format off
|
| 9 |
+
/**
|
| 10 |
+
* Embedding lookup with reduction.
|
| 11 |
+
*
|
| 12 |
+
* `input` of size data_size * block_size
|
| 13 |
+
* `indices` of size index_size
|
| 14 |
+
* `offsets` of size output_size
|
| 15 |
+
* `weights` nullptr or array of size index_size
|
| 16 |
+
* `out` of size output_size * block_size
|
| 17 |
+
*
|
| 18 |
+
* Behavior is roughly equivalent to pseudocode:
|
| 19 |
+
*
|
| 20 |
+
* pos = 0
|
| 21 |
+
* for (i = 0..output_size-1)
|
| 22 |
+
* for (k = 0..block_size-1)
|
| 23 |
+
* out[i*block_size + k] = 0
|
| 24 |
+
* start_offset = offsets[i]
|
| 25 |
+
* end_offset = offsets[i+1]
|
| 26 |
+
* length = end_offset - start_offset
|
| 27 |
+
* for (j = start_offset..end_offset-1)
|
| 28 |
+
* for (k = 0..block_size-1)
|
| 29 |
+
* out[i*block_size + k] += input[indices[pos]*block_size + k] *
|
| 30 |
+
* (weights ? weights[IS_WEIGHT_POSITIONAL ? j - start_offset : pos] : 1.0)
|
| 31 |
+
* pos += 1
|
| 32 |
+
* if (normalize_weights && length > 0)
|
| 33 |
+
* for (k = 0..block_size-1)
|
| 34 |
+
* out[i*block_size + k] /= length
|
| 35 |
+
*
|
| 36 |
+
* TODO: make this API also take "offsets" rather than "lengths" to match the
|
| 37 |
+
* API for PyTorch's EmbeddingBag
|
| 38 |
+
*/
|
| 39 |
+
// clang-format on
|
| 40 |
+
template <
|
| 41 |
+
typename IndexType,
|
| 42 |
+
typename InType,
|
| 43 |
+
typename OutType,
|
| 44 |
+
bool IS_WEIGHT_POSITIONAL = false>
|
| 45 |
+
void EmbeddingLookupIdx(
|
| 46 |
+
const std::int64_t block_size,
|
| 47 |
+
const std::int64_t output_size,
|
| 48 |
+
const std::int64_t index_size,
|
| 49 |
+
const std::int64_t data_size,
|
| 50 |
+
const InType* input,
|
| 51 |
+
const IndexType* indices,
|
| 52 |
+
const IndexType* offsets,
|
| 53 |
+
const float* weights, // optional, can be null for non-weighted sum
|
| 54 |
+
const float* scale_bias, // optional scale & bias params for uint8 input
|
| 55 |
+
bool normalize_by_lengths,
|
| 56 |
+
OutType* out);
|
| 57 |
+
|
| 58 |
+
} // namespace caffe2
|
| 59 |
+
|
| 60 |
+
#else
|
| 61 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 62 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/crc_alt.h
ADDED
|
@@ -0,0 +1,1348 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
// //////////////////////////////////////////////////////////
|
| 5 |
+
// Crc32.h
|
| 6 |
+
// Copyright (c) 2011-2019 Stephan Brumme. All rights reserved.
|
| 7 |
+
// Slicing-by-16 contributed by Bulat Ziganshin
|
| 8 |
+
// Tableless bytewise CRC contributed by Hagai Gold
|
| 9 |
+
// see http://create.stephan-brumme.com/disclaimer.html
|
| 10 |
+
//
|
| 11 |
+
|
| 12 |
+
// if running on an embedded system, you might consider shrinking the
|
| 13 |
+
// big Crc32Lookup table by undefining these lines:
|
| 14 |
+
#define CRC32_USE_LOOKUP_TABLE_BYTE
|
| 15 |
+
#define CRC32_USE_LOOKUP_TABLE_SLICING_BY_4
|
| 16 |
+
#define CRC32_USE_LOOKUP_TABLE_SLICING_BY_8
|
| 17 |
+
#define CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
|
| 18 |
+
// - crc32_bitwise doesn't need it at all
|
| 19 |
+
// - crc32_halfbyte has its own small lookup table
|
| 20 |
+
// - crc32_1byte_tableless and crc32_1byte_tableless2 don't need it at all
|
| 21 |
+
// - crc32_1byte needs only Crc32Lookup[0]
|
| 22 |
+
// - crc32_4bytes needs only Crc32Lookup[0..3]
|
| 23 |
+
// - crc32_8bytes needs only Crc32Lookup[0..7]
|
| 24 |
+
// - crc32_4x8bytes needs only Crc32Lookup[0..7]
|
| 25 |
+
// - crc32_16bytes needs all of Crc32Lookup
|
| 26 |
+
// using the aforementioned #defines the table is automatically fitted to your needs
|
| 27 |
+
|
| 28 |
+
// uint8_t, uint32_t, int32_t
|
| 29 |
+
#include <stdint.h>
|
| 30 |
+
// size_t
|
| 31 |
+
#include <cstddef>
|
| 32 |
+
|
| 33 |
+
// crc32_fast selects the fastest algorithm depending on flags (CRC32_USE_LOOKUP_...)
|
| 34 |
+
/// compute CRC32 using the fastest algorithm for large datasets on modern CPUs
|
| 35 |
+
uint32_t crc32_fast (const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 36 |
+
|
| 37 |
+
/// merge two CRC32 such that result = crc32(dataB, lengthB, crc32(dataA, lengthA))
|
| 38 |
+
uint32_t crc32_combine (uint32_t crcA, uint32_t crcB, size_t lengthB);
|
| 39 |
+
|
| 40 |
+
/// compute CRC32 (bitwise algorithm)
|
| 41 |
+
uint32_t crc32_bitwise (const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 42 |
+
/// compute CRC32 (half-byte algorithm)
|
| 43 |
+
uint32_t crc32_halfbyte(const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 44 |
+
|
| 45 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_BYTE
|
| 46 |
+
/// compute CRC32 (standard algorithm)
|
| 47 |
+
uint32_t crc32_1byte (const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 48 |
+
#endif
|
| 49 |
+
|
| 50 |
+
/// compute CRC32 (byte algorithm) without lookup tables
|
| 51 |
+
uint32_t crc32_1byte_tableless (const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 52 |
+
/// compute CRC32 (byte algorithm) without lookup tables
|
| 53 |
+
uint32_t crc32_1byte_tableless2(const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 54 |
+
|
| 55 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_4
|
| 56 |
+
/// compute CRC32 (Slicing-by-4 algorithm)
|
| 57 |
+
uint32_t crc32_4bytes (const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_8
|
| 61 |
+
/// compute CRC32 (Slicing-by-8 algorithm)
|
| 62 |
+
uint32_t crc32_8bytes (const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 63 |
+
/// compute CRC32 (Slicing-by-8 algorithm), unroll inner loop 4 times
|
| 64 |
+
uint32_t crc32_4x8bytes(const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 65 |
+
#endif
|
| 66 |
+
|
| 67 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
|
| 68 |
+
/// compute CRC32 (Slicing-by-16 algorithm)
|
| 69 |
+
uint32_t crc32_16bytes (const void* data, size_t length, uint32_t previousCrc32 = 0);
|
| 70 |
+
/// compute CRC32 (Slicing-by-16 algorithm, prefetch upcoming data blocks)
|
| 71 |
+
uint32_t crc32_16bytes_prefetch(const void* data, size_t length, uint32_t previousCrc32 = 0, size_t prefetchAhead = 256);
|
| 72 |
+
#endif
|
| 73 |
+
|
| 74 |
+
// //////////////////////////////////////////////////////////
|
| 75 |
+
// Crc32.cpp
|
| 76 |
+
// Copyright (c) 2011-2019 Stephan Brumme. All rights reserved.
|
| 77 |
+
// Slicing-by-16 contributed by Bulat Ziganshin
|
| 78 |
+
// Tableless bytewise CRC contributed by Hagai Gold
|
| 79 |
+
// see http://create.stephan-brumme.com/disclaimer.html
|
| 80 |
+
//
|
| 81 |
+
|
| 82 |
+
// if running on an embedded system, you might consider shrinking the
|
| 83 |
+
// big Crc32Lookup table:
|
| 84 |
+
// - crc32_bitwise doesn't need it at all
|
| 85 |
+
// - crc32_halfbyte has its own small lookup table
|
| 86 |
+
// - crc32_1byte needs only Crc32Lookup[0]
|
| 87 |
+
// - crc32_4bytes needs only Crc32Lookup[0..3]
|
| 88 |
+
// - crc32_8bytes needs only Crc32Lookup[0..7]
|
| 89 |
+
// - crc32_4x8bytes needs only Crc32Lookup[0..7]
|
| 90 |
+
// - crc32_16bytes needs all of Crc32Lookup
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
#ifndef __LITTLE_ENDIAN
|
| 94 |
+
#define __LITTLE_ENDIAN 1234
|
| 95 |
+
#endif
|
| 96 |
+
#ifndef __BIG_ENDIAN
|
| 97 |
+
#define __BIG_ENDIAN 4321
|
| 98 |
+
#endif
|
| 99 |
+
|
| 100 |
+
// define endianness and some integer data types
|
| 101 |
+
#if defined(_MSC_VER) || defined(__MINGW32__)
|
| 102 |
+
// Windows always little endian
|
| 103 |
+
#define __BYTE_ORDER __LITTLE_ENDIAN
|
| 104 |
+
|
| 105 |
+
// intrinsics / prefetching
|
| 106 |
+
#if defined(_M_ARM64)
|
| 107 |
+
#include <intrin.h>
|
| 108 |
+
#else
|
| 109 |
+
#include <xmmintrin.h>
|
| 110 |
+
#endif
|
| 111 |
+
|
| 112 |
+
#ifdef __MINGW32__
|
| 113 |
+
#define PREFETCH(location) __builtin_prefetch(location)
|
| 114 |
+
#else
|
| 115 |
+
#if defined(_M_ARM64)
|
| 116 |
+
#define PREFETCH(location) __prefetch(location)
|
| 117 |
+
#else
|
| 118 |
+
#define PREFETCH(location) _mm_prefetch(location, _MM_HINT_T0)
|
| 119 |
+
#endif
|
| 120 |
+
#endif
|
| 121 |
+
#elif defined(__APPLE__)
|
| 122 |
+
#include <TargetConditionals.h>
|
| 123 |
+
#if TARGET_IPHONE_SIMULATOR
|
| 124 |
+
#define __BYTE_ORDER __LITTLE_ENDIAN
|
| 125 |
+
#elif TARGET_OS_IPHONE
|
| 126 |
+
#define __BYTE_ORDER __LITTLE_ENDIAN
|
| 127 |
+
#elif TARGET_OS_MAC
|
| 128 |
+
#include <machine/endian.h>
|
| 129 |
+
#if defined(__BIG_ENDIAN__)
|
| 130 |
+
#define __BYTE_ORDER __BIG_ENDIAN
|
| 131 |
+
#endif
|
| 132 |
+
#if defined(__LITTLE_ENDIAN__)
|
| 133 |
+
#define __BYTE_ORDER __LITTLE_ENDIAN
|
| 134 |
+
#endif
|
| 135 |
+
#else
|
| 136 |
+
# error "Unknown Apple platform"
|
| 137 |
+
#endif
|
| 138 |
+
#elif defined(__ARMEB__)
|
| 139 |
+
#define __BYTE_ORDER __BIG_ENDIAN
|
| 140 |
+
#elif (defined(__BYTE_ORDER__) and !defined(__BYTE_ORDER))
|
| 141 |
+
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
| 142 |
+
#define __BYTE_ORDER __BIG_ENDIAN
|
| 143 |
+
#else
|
| 144 |
+
#define __BYTE_ORDER __LITTLE_ENDIAN
|
| 145 |
+
#endif
|
| 146 |
+
#else
|
| 147 |
+
// defines __BYTE_ORDER as __LITTLE_ENDIAN or __BIG_ENDIAN
|
| 148 |
+
#include <sys/param.h>
|
| 149 |
+
#endif
|
| 150 |
+
|
| 151 |
+
// intrinsics / prefetching
|
| 152 |
+
#ifdef __GNUC__
|
| 153 |
+
#define PREFETCH(location) __builtin_prefetch(location)
|
| 154 |
+
#else
|
| 155 |
+
#ifndef PREFETCH
|
| 156 |
+
// no prefetching
|
| 157 |
+
#define PREFETCH(location) ;
|
| 158 |
+
#endif
|
| 159 |
+
#endif
|
| 160 |
+
|
| 161 |
+
// abort if byte order is undefined
|
| 162 |
+
#ifndef __BYTE_ORDER
|
| 163 |
+
#error undefined byte order, compile with -D__BYTE_ORDER=1234 (if little endian) or -D__BYTE_ORDER=4321 (big endian)
|
| 164 |
+
#endif
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
namespace
|
| 168 |
+
{
|
| 169 |
+
/// zlib's CRC32 polynomial
|
| 170 |
+
const uint32_t Polynomial = 0xEDB88320;
|
| 171 |
+
|
| 172 |
+
/// swap endianness
|
| 173 |
+
static inline uint32_t swap(uint32_t x)
|
| 174 |
+
{
|
| 175 |
+
#if defined(__GNUC__) || defined(__clang__)
|
| 176 |
+
return __builtin_bswap32(x);
|
| 177 |
+
#else
|
| 178 |
+
return (x >> 24) |
|
| 179 |
+
((x >> 8) & 0x0000FF00) |
|
| 180 |
+
((x << 8) & 0x00FF0000) |
|
| 181 |
+
(x << 24);
|
| 182 |
+
#endif
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/// Slicing-By-16
|
| 186 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
|
| 187 |
+
const size_t MaxSlice = 16;
|
| 188 |
+
#elif defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8)
|
| 189 |
+
const size_t MaxSlice = 8;
|
| 190 |
+
#elif defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4)
|
| 191 |
+
const size_t MaxSlice = 4;
|
| 192 |
+
#elif defined(CRC32_USE_LOOKUP_TABLE_BYTE)
|
| 193 |
+
const size_t MaxSlice = 1;
|
| 194 |
+
#else
|
| 195 |
+
#define NO_LUT // don't need Crc32Lookup at all
|
| 196 |
+
#endif
|
| 197 |
+
|
| 198 |
+
} // anonymous namespace
|
| 199 |
+
|
| 200 |
+
#ifndef NO_LUT
|
| 201 |
+
/// forward declaration, table is at the end of this file
|
| 202 |
+
extern const uint32_t Crc32Lookup[MaxSlice][256]; // extern is needed to keep compiler happy
|
| 203 |
+
#endif
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
/// compute CRC32 (bitwise algorithm)
|
| 207 |
+
uint32_t crc32_bitwise(const void* data, size_t length, uint32_t previousCrc32)
|
| 208 |
+
{
|
| 209 |
+
uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF
|
| 210 |
+
const uint8_t* current = (const uint8_t*) data;
|
| 211 |
+
|
| 212 |
+
while (length-- != 0)
|
| 213 |
+
{
|
| 214 |
+
crc ^= *current++;
|
| 215 |
+
|
| 216 |
+
for (int j = 0; j < 8; j++)
|
| 217 |
+
{
|
| 218 |
+
// branch-free
|
| 219 |
+
crc = (crc >> 1) ^ (-int32_t(crc & 1) & Polynomial);
|
| 220 |
+
|
| 221 |
+
// branching, much slower:
|
| 222 |
+
//if (crc & 1)
|
| 223 |
+
// crc = (crc >> 1) ^ Polynomial;
|
| 224 |
+
//else
|
| 225 |
+
// crc = crc >> 1;
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
/// compute CRC32 (half-byte algorithm)
|
| 234 |
+
uint32_t crc32_halfbyte(const void* data, size_t length, uint32_t previousCrc32)
|
| 235 |
+
{
|
| 236 |
+
uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF
|
| 237 |
+
const uint8_t* current = (const uint8_t*) data;
|
| 238 |
+
|
| 239 |
+
/// look-up table for half-byte, same as crc32Lookup[0][16*i]
|
| 240 |
+
static const uint32_t Crc32Lookup16[16] =
|
| 241 |
+
{
|
| 242 |
+
0x00000000,0x1DB71064,0x3B6E20C8,0x26D930AC,0x76DC4190,0x6B6B51F4,0x4DB26158,0x5005713C,
|
| 243 |
+
0xEDB88320,0xF00F9344,0xD6D6A3E8,0xCB61B38C,0x9B64C2B0,0x86D3D2D4,0xA00AE278,0xBDBDF21C
|
| 244 |
+
};
|
| 245 |
+
|
| 246 |
+
while (length-- != 0)
|
| 247 |
+
{
|
| 248 |
+
crc = Crc32Lookup16[(crc ^ *current ) & 0x0F] ^ (crc >> 4);
|
| 249 |
+
crc = Crc32Lookup16[(crc ^ (*current >> 4)) & 0x0F] ^ (crc >> 4);
|
| 250 |
+
current++;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_BYTE
|
| 258 |
+
/// compute CRC32 (standard algorithm)
|
| 259 |
+
uint32_t crc32_1byte(const void* data, size_t length, uint32_t previousCrc32)
|
| 260 |
+
{
|
| 261 |
+
uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF
|
| 262 |
+
const uint8_t* current = (const uint8_t*) data;
|
| 263 |
+
|
| 264 |
+
while (length-- != 0)
|
| 265 |
+
crc = (crc >> 8) ^ Crc32Lookup[0][(crc & 0xFF) ^ *current++];
|
| 266 |
+
|
| 267 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 268 |
+
}
|
| 269 |
+
#endif
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
/// compute CRC32 (byte algorithm) without lookup tables
|
| 273 |
+
uint32_t crc32_1byte_tableless(const void* data, size_t length, uint32_t previousCrc32)
|
| 274 |
+
{
|
| 275 |
+
uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF
|
| 276 |
+
const uint8_t* current = (const uint8_t*) data;
|
| 277 |
+
|
| 278 |
+
while (length-- != 0)
|
| 279 |
+
{
|
| 280 |
+
uint8_t s = uint8_t(crc) ^ *current++;
|
| 281 |
+
|
| 282 |
+
// Hagai Gold made me aware of this table-less algorithm and send me code
|
| 283 |
+
|
| 284 |
+
// polynomial 0xEDB88320 can be written in binary as 11101101101110001000001100100000b
|
| 285 |
+
// reverse the bits (or just assume bit 0 is the first one)
|
| 286 |
+
// and we have bits set at position 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26
|
| 287 |
+
// => those are the shift offsets:
|
| 288 |
+
//crc = (crc >> 8) ^
|
| 289 |
+
// t ^
|
| 290 |
+
// (t >> 1) ^ (t >> 2) ^ (t >> 4) ^ (t >> 5) ^ // == y
|
| 291 |
+
// (t >> 7) ^ (t >> 8) ^ (t >> 10) ^ (t >> 11) ^ // == y >> 6
|
| 292 |
+
// (t >> 12) ^ (t >> 16) ^ // == z
|
| 293 |
+
// (t >> 22) ^ (t >> 26) ^ // == z >> 10
|
| 294 |
+
// (t >> 23);
|
| 295 |
+
|
| 296 |
+
// the fastest I can come up with:
|
| 297 |
+
uint32_t low = (s ^ (s << 6)) & 0xFF;
|
| 298 |
+
uint32_t a = (low * ((1 << 23) + (1 << 14) + (1 << 2)));
|
| 299 |
+
crc = (crc >> 8) ^
|
| 300 |
+
(low * ((1 << 24) + (1 << 16) + (1 << 8))) ^
|
| 301 |
+
a ^
|
| 302 |
+
(a >> 1) ^
|
| 303 |
+
(low * ((1 << 20) + (1 << 12) )) ^
|
| 304 |
+
(low << 19) ^
|
| 305 |
+
(low << 17) ^
|
| 306 |
+
(low >> 2);
|
| 307 |
+
|
| 308 |
+
// Hagai's code:
|
| 309 |
+
/*uint32_t t = (s ^ (s << 6)) << 24;
|
| 310 |
+
// some temporaries to optimize XOR
|
| 311 |
+
uint32_t x = (t >> 1) ^ (t >> 2);
|
| 312 |
+
uint32_t y = x ^ (x >> 3);
|
| 313 |
+
uint32_t z = (t >> 12) ^ (t >> 16);
|
| 314 |
+
crc = (crc >> 8) ^
|
| 315 |
+
t ^ (t >> 23) ^
|
| 316 |
+
y ^ (y >> 6) ^
|
| 317 |
+
z ^ (z >> 10);*/
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
/// compute CRC32 (byte algorithm) without lookup tables
|
| 325 |
+
uint32_t crc32_1byte_tableless2(const void* data, size_t length, uint32_t previousCrc32)
|
| 326 |
+
{
|
| 327 |
+
int32_t crc = ~previousCrc32; // note: signed integer, right shift distributes sign bit into lower bits
|
| 328 |
+
const uint8_t* current = (const uint8_t*) data;
|
| 329 |
+
|
| 330 |
+
while (length-- != 0)
|
| 331 |
+
{
|
| 332 |
+
crc = crc ^ *current++;
|
| 333 |
+
|
| 334 |
+
uint32_t c = (((crc << 31) >> 31) & ((Polynomial >> 7) ^ (Polynomial >> 1))) ^
|
| 335 |
+
(((crc << 30) >> 31) & ((Polynomial >> 6) ^ Polynomial)) ^
|
| 336 |
+
(((crc << 29) >> 31) & (Polynomial >> 5)) ^
|
| 337 |
+
(((crc << 28) >> 31) & (Polynomial >> 4)) ^
|
| 338 |
+
(((crc << 27) >> 31) & (Polynomial >> 3)) ^
|
| 339 |
+
(((crc << 26) >> 31) & (Polynomial >> 2)) ^
|
| 340 |
+
(((crc << 25) >> 31) & (Polynomial >> 1)) ^
|
| 341 |
+
(((crc << 24) >> 31) & Polynomial);
|
| 342 |
+
|
| 343 |
+
crc = ((uint32_t)crc >> 8) ^ c; // convert to unsigned integer before right shift
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_4
|
| 351 |
+
/// compute CRC32 (Slicing-by-4 algorithm)
|
| 352 |
+
uint32_t crc32_4bytes(const void* data, size_t length, uint32_t previousCrc32)
|
| 353 |
+
{
|
| 354 |
+
uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF
|
| 355 |
+
const uint32_t* current = (const uint32_t*) data;
|
| 356 |
+
|
| 357 |
+
// process four bytes at once (Slicing-by-4)
|
| 358 |
+
while (length >= 4)
|
| 359 |
+
{
|
| 360 |
+
#if __BYTE_ORDER == __BIG_ENDIAN
|
| 361 |
+
uint32_t one = *current++ ^ swap(crc);
|
| 362 |
+
crc = Crc32Lookup[0][ one & 0xFF] ^
|
| 363 |
+
Crc32Lookup[1][(one>> 8) & 0xFF] ^
|
| 364 |
+
Crc32Lookup[2][(one>>16) & 0xFF] ^
|
| 365 |
+
Crc32Lookup[3][(one>>24) & 0xFF];
|
| 366 |
+
#else
|
| 367 |
+
uint32_t one = *current++ ^ crc;
|
| 368 |
+
crc = Crc32Lookup[0][(one>>24) & 0xFF] ^
|
| 369 |
+
Crc32Lookup[1][(one>>16) & 0xFF] ^
|
| 370 |
+
Crc32Lookup[2][(one>> 8) & 0xFF] ^
|
| 371 |
+
Crc32Lookup[3][ one & 0xFF];
|
| 372 |
+
#endif
|
| 373 |
+
|
| 374 |
+
length -= 4;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
const uint8_t* currentChar = (const uint8_t*) current;
|
| 378 |
+
// remaining 1 to 3 bytes (standard algorithm)
|
| 379 |
+
while (length-- != 0)
|
| 380 |
+
crc = (crc >> 8) ^ Crc32Lookup[0][(crc & 0xFF) ^ *currentChar++];
|
| 381 |
+
|
| 382 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 383 |
+
}
|
| 384 |
+
#endif
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_8
|
| 388 |
+
/// compute CRC32 (Slicing-by-8 algorithm)
|
| 389 |
+
uint32_t crc32_8bytes(const void* data, size_t length, uint32_t previousCrc32)
|
| 390 |
+
{
|
| 391 |
+
uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF
|
| 392 |
+
const uint32_t* current = (const uint32_t*) data;
|
| 393 |
+
|
| 394 |
+
// process eight bytes at once (Slicing-by-8)
|
| 395 |
+
while (length >= 8)
|
| 396 |
+
{
|
| 397 |
+
#if __BYTE_ORDER == __BIG_ENDIAN
|
| 398 |
+
uint32_t one = *current++ ^ swap(crc);
|
| 399 |
+
uint32_t two = *current++;
|
| 400 |
+
crc = Crc32Lookup[0][ two & 0xFF] ^
|
| 401 |
+
Crc32Lookup[1][(two>> 8) & 0xFF] ^
|
| 402 |
+
Crc32Lookup[2][(two>>16) & 0xFF] ^
|
| 403 |
+
Crc32Lookup[3][(two>>24) & 0xFF] ^
|
| 404 |
+
Crc32Lookup[4][ one & 0xFF] ^
|
| 405 |
+
Crc32Lookup[5][(one>> 8) & 0xFF] ^
|
| 406 |
+
Crc32Lookup[6][(one>>16) & 0xFF] ^
|
| 407 |
+
Crc32Lookup[7][(one>>24) & 0xFF];
|
| 408 |
+
#else
|
| 409 |
+
uint32_t one = *current++ ^ crc;
|
| 410 |
+
uint32_t two = *current++;
|
| 411 |
+
crc = Crc32Lookup[0][(two>>24) & 0xFF] ^
|
| 412 |
+
Crc32Lookup[1][(two>>16) & 0xFF] ^
|
| 413 |
+
Crc32Lookup[2][(two>> 8) & 0xFF] ^
|
| 414 |
+
Crc32Lookup[3][ two & 0xFF] ^
|
| 415 |
+
Crc32Lookup[4][(one>>24) & 0xFF] ^
|
| 416 |
+
Crc32Lookup[5][(one>>16) & 0xFF] ^
|
| 417 |
+
Crc32Lookup[6][(one>> 8) & 0xFF] ^
|
| 418 |
+
Crc32Lookup[7][ one & 0xFF];
|
| 419 |
+
#endif
|
| 420 |
+
|
| 421 |
+
length -= 8;
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
const uint8_t* currentChar = (const uint8_t*) current;
|
| 425 |
+
// remaining 1 to 7 bytes (standard algorithm)
|
| 426 |
+
while (length-- != 0)
|
| 427 |
+
crc = (crc >> 8) ^ Crc32Lookup[0][(crc & 0xFF) ^ *currentChar++];
|
| 428 |
+
|
| 429 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
/// compute CRC32 (Slicing-by-8 algorithm), unroll inner loop 4 times
|
| 434 |
+
uint32_t crc32_4x8bytes(const void* data, size_t length, uint32_t previousCrc32)
|
| 435 |
+
{
|
| 436 |
+
uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF
|
| 437 |
+
const uint32_t* current = (const uint32_t*) data;
|
| 438 |
+
|
| 439 |
+
// enabling optimization (at least -O2) automatically unrolls the inner for-loop
|
| 440 |
+
const size_t Unroll = 4;
|
| 441 |
+
const size_t BytesAtOnce = 8 * Unroll;
|
| 442 |
+
|
| 443 |
+
// process 4x eight bytes at once (Slicing-by-8)
|
| 444 |
+
while (length >= BytesAtOnce)
|
| 445 |
+
{
|
| 446 |
+
for (size_t unrolling = 0; unrolling < Unroll; unrolling++)
|
| 447 |
+
{
|
| 448 |
+
#if __BYTE_ORDER == __BIG_ENDIAN
|
| 449 |
+
uint32_t one = *current++ ^ swap(crc);
|
| 450 |
+
uint32_t two = *current++;
|
| 451 |
+
crc = Crc32Lookup[0][ two & 0xFF] ^
|
| 452 |
+
Crc32Lookup[1][(two>> 8) & 0xFF] ^
|
| 453 |
+
Crc32Lookup[2][(two>>16) & 0xFF] ^
|
| 454 |
+
Crc32Lookup[3][(two>>24) & 0xFF] ^
|
| 455 |
+
Crc32Lookup[4][ one & 0xFF] ^
|
| 456 |
+
Crc32Lookup[5][(one>> 8) & 0xFF] ^
|
| 457 |
+
Crc32Lookup[6][(one>>16) & 0xFF] ^
|
| 458 |
+
Crc32Lookup[7][(one>>24) & 0xFF];
|
| 459 |
+
#else
|
| 460 |
+
uint32_t one = *current++ ^ crc;
|
| 461 |
+
uint32_t two = *current++;
|
| 462 |
+
crc = Crc32Lookup[0][(two>>24) & 0xFF] ^
|
| 463 |
+
Crc32Lookup[1][(two>>16) & 0xFF] ^
|
| 464 |
+
Crc32Lookup[2][(two>> 8) & 0xFF] ^
|
| 465 |
+
Crc32Lookup[3][ two & 0xFF] ^
|
| 466 |
+
Crc32Lookup[4][(one>>24) & 0xFF] ^
|
| 467 |
+
Crc32Lookup[5][(one>>16) & 0xFF] ^
|
| 468 |
+
Crc32Lookup[6][(one>> 8) & 0xFF] ^
|
| 469 |
+
Crc32Lookup[7][ one & 0xFF];
|
| 470 |
+
#endif
|
| 471 |
+
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
length -= BytesAtOnce;
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
const uint8_t* currentChar = (const uint8_t*) current;
|
| 478 |
+
// remaining 1 to 31 bytes (standard algorithm)
|
| 479 |
+
while (length-- != 0)
|
| 480 |
+
crc = (crc >> 8) ^ Crc32Lookup[0][(crc & 0xFF) ^ *currentChar++];
|
| 481 |
+
|
| 482 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 483 |
+
}
|
| 484 |
+
#endif // CRC32_USE_LOOKUP_TABLE_SLICING_BY_8
|
| 485 |
+
|
| 486 |
+
|
| 487 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
|
| 488 |
+
/// compute CRC32 (Slicing-by-16 algorithm)
|
| 489 |
+
uint32_t crc32_16bytes(const void* data, size_t length, uint32_t previousCrc32)
|
| 490 |
+
{
|
| 491 |
+
uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF
|
| 492 |
+
const uint32_t* current = (const uint32_t*) data;
|
| 493 |
+
|
| 494 |
+
// enabling optimization (at least -O2) automatically unrolls the inner for-loop
|
| 495 |
+
const size_t Unroll = 4;
|
| 496 |
+
const size_t BytesAtOnce = 16 * Unroll;
|
| 497 |
+
|
| 498 |
+
while (length >= BytesAtOnce)
|
| 499 |
+
{
|
| 500 |
+
for (size_t unrolling = 0; unrolling < Unroll; unrolling++)
|
| 501 |
+
{
|
| 502 |
+
#if __BYTE_ORDER == __BIG_ENDIAN
|
| 503 |
+
uint32_t one = *current++ ^ swap(crc);
|
| 504 |
+
uint32_t two = *current++;
|
| 505 |
+
uint32_t three = *current++;
|
| 506 |
+
uint32_t four = *current++;
|
| 507 |
+
crc = Crc32Lookup[ 0][ four & 0xFF] ^
|
| 508 |
+
Crc32Lookup[ 1][(four >> 8) & 0xFF] ^
|
| 509 |
+
Crc32Lookup[ 2][(four >> 16) & 0xFF] ^
|
| 510 |
+
Crc32Lookup[ 3][(four >> 24) & 0xFF] ^
|
| 511 |
+
Crc32Lookup[ 4][ three & 0xFF] ^
|
| 512 |
+
Crc32Lookup[ 5][(three >> 8) & 0xFF] ^
|
| 513 |
+
Crc32Lookup[ 6][(three >> 16) & 0xFF] ^
|
| 514 |
+
Crc32Lookup[ 7][(three >> 24) & 0xFF] ^
|
| 515 |
+
Crc32Lookup[ 8][ two & 0xFF] ^
|
| 516 |
+
Crc32Lookup[ 9][(two >> 8) & 0xFF] ^
|
| 517 |
+
Crc32Lookup[10][(two >> 16) & 0xFF] ^
|
| 518 |
+
Crc32Lookup[11][(two >> 24) & 0xFF] ^
|
| 519 |
+
Crc32Lookup[12][ one & 0xFF] ^
|
| 520 |
+
Crc32Lookup[13][(one >> 8) & 0xFF] ^
|
| 521 |
+
Crc32Lookup[14][(one >> 16) & 0xFF] ^
|
| 522 |
+
Crc32Lookup[15][(one >> 24) & 0xFF];
|
| 523 |
+
#else
|
| 524 |
+
uint32_t one = *current++ ^ crc;
|
| 525 |
+
uint32_t two = *current++;
|
| 526 |
+
uint32_t three = *current++;
|
| 527 |
+
uint32_t four = *current++;
|
| 528 |
+
crc = Crc32Lookup[ 0][(four >> 24) & 0xFF] ^
|
| 529 |
+
Crc32Lookup[ 1][(four >> 16) & 0xFF] ^
|
| 530 |
+
Crc32Lookup[ 2][(four >> 8) & 0xFF] ^
|
| 531 |
+
Crc32Lookup[ 3][ four & 0xFF] ^
|
| 532 |
+
Crc32Lookup[ 4][(three >> 24) & 0xFF] ^
|
| 533 |
+
Crc32Lookup[ 5][(three >> 16) & 0xFF] ^
|
| 534 |
+
Crc32Lookup[ 6][(three >> 8) & 0xFF] ^
|
| 535 |
+
Crc32Lookup[ 7][ three & 0xFF] ^
|
| 536 |
+
Crc32Lookup[ 8][(two >> 24) & 0xFF] ^
|
| 537 |
+
Crc32Lookup[ 9][(two >> 16) & 0xFF] ^
|
| 538 |
+
Crc32Lookup[10][(two >> 8) & 0xFF] ^
|
| 539 |
+
Crc32Lookup[11][ two & 0xFF] ^
|
| 540 |
+
Crc32Lookup[12][(one >> 24) & 0xFF] ^
|
| 541 |
+
Crc32Lookup[13][(one >> 16) & 0xFF] ^
|
| 542 |
+
Crc32Lookup[14][(one >> 8) & 0xFF] ^
|
| 543 |
+
Crc32Lookup[15][ one & 0xFF];
|
| 544 |
+
#endif
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
length -= BytesAtOnce;
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
const uint8_t* currentChar = (const uint8_t*) current;
|
| 551 |
+
// remaining 1 to 63 bytes (standard algorithm)
|
| 552 |
+
while (length-- != 0)
|
| 553 |
+
crc = (crc >> 8) ^ Crc32Lookup[0][(crc & 0xFF) ^ *currentChar++];
|
| 554 |
+
|
| 555 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
|
| 559 |
+
/// compute CRC32 (Slicing-by-16 algorithm, prefetch upcoming data blocks)
|
| 560 |
+
uint32_t crc32_16bytes_prefetch(const void* data, size_t length, uint32_t previousCrc32, size_t prefetchAhead)
|
| 561 |
+
{
|
| 562 |
+
// CRC code is identical to crc32_16bytes (including unrolling), only added prefetching
|
| 563 |
+
// 256 bytes look-ahead seems to be the sweet spot on Core i7 CPUs
|
| 564 |
+
|
| 565 |
+
uint32_t crc = ~previousCrc32; // same as previousCrc32 ^ 0xFFFFFFFF
|
| 566 |
+
const uint32_t* current = (const uint32_t*) data;
|
| 567 |
+
|
| 568 |
+
// enabling optimization (at least -O2) automatically unrolls the for-loop
|
| 569 |
+
const size_t Unroll = 4;
|
| 570 |
+
const size_t BytesAtOnce = 16 * Unroll;
|
| 571 |
+
|
| 572 |
+
while (length >= BytesAtOnce + prefetchAhead)
|
| 573 |
+
{
|
| 574 |
+
PREFETCH(((const char*) current) + prefetchAhead);
|
| 575 |
+
|
| 576 |
+
for (size_t unrolling = 0; unrolling < Unroll; unrolling++)
|
| 577 |
+
{
|
| 578 |
+
#if __BYTE_ORDER == __BIG_ENDIAN
|
| 579 |
+
uint32_t one = *current++ ^ swap(crc);
|
| 580 |
+
uint32_t two = *current++;
|
| 581 |
+
uint32_t three = *current++;
|
| 582 |
+
uint32_t four = *current++;
|
| 583 |
+
crc = Crc32Lookup[ 0][ four & 0xFF] ^
|
| 584 |
+
Crc32Lookup[ 1][(four >> 8) & 0xFF] ^
|
| 585 |
+
Crc32Lookup[ 2][(four >> 16) & 0xFF] ^
|
| 586 |
+
Crc32Lookup[ 3][(four >> 24) & 0xFF] ^
|
| 587 |
+
Crc32Lookup[ 4][ three & 0xFF] ^
|
| 588 |
+
Crc32Lookup[ 5][(three >> 8) & 0xFF] ^
|
| 589 |
+
Crc32Lookup[ 6][(three >> 16) & 0xFF] ^
|
| 590 |
+
Crc32Lookup[ 7][(three >> 24) & 0xFF] ^
|
| 591 |
+
Crc32Lookup[ 8][ two & 0xFF] ^
|
| 592 |
+
Crc32Lookup[ 9][(two >> 8) & 0xFF] ^
|
| 593 |
+
Crc32Lookup[10][(two >> 16) & 0xFF] ^
|
| 594 |
+
Crc32Lookup[11][(two >> 24) & 0xFF] ^
|
| 595 |
+
Crc32Lookup[12][ one & 0xFF] ^
|
| 596 |
+
Crc32Lookup[13][(one >> 8) & 0xFF] ^
|
| 597 |
+
Crc32Lookup[14][(one >> 16) & 0xFF] ^
|
| 598 |
+
Crc32Lookup[15][(one >> 24) & 0xFF];
|
| 599 |
+
#else
|
| 600 |
+
uint32_t one = *current++ ^ crc;
|
| 601 |
+
uint32_t two = *current++;
|
| 602 |
+
uint32_t three = *current++;
|
| 603 |
+
uint32_t four = *current++;
|
| 604 |
+
crc = Crc32Lookup[ 0][(four >> 24) & 0xFF] ^
|
| 605 |
+
Crc32Lookup[ 1][(four >> 16) & 0xFF] ^
|
| 606 |
+
Crc32Lookup[ 2][(four >> 8) & 0xFF] ^
|
| 607 |
+
Crc32Lookup[ 3][ four & 0xFF] ^
|
| 608 |
+
Crc32Lookup[ 4][(three >> 24) & 0xFF] ^
|
| 609 |
+
Crc32Lookup[ 5][(three >> 16) & 0xFF] ^
|
| 610 |
+
Crc32Lookup[ 6][(three >> 8) & 0xFF] ^
|
| 611 |
+
Crc32Lookup[ 7][ three & 0xFF] ^
|
| 612 |
+
Crc32Lookup[ 8][(two >> 24) & 0xFF] ^
|
| 613 |
+
Crc32Lookup[ 9][(two >> 16) & 0xFF] ^
|
| 614 |
+
Crc32Lookup[10][(two >> 8) & 0xFF] ^
|
| 615 |
+
Crc32Lookup[11][ two & 0xFF] ^
|
| 616 |
+
Crc32Lookup[12][(one >> 24) & 0xFF] ^
|
| 617 |
+
Crc32Lookup[13][(one >> 16) & 0xFF] ^
|
| 618 |
+
Crc32Lookup[14][(one >> 8) & 0xFF] ^
|
| 619 |
+
Crc32Lookup[15][ one & 0xFF];
|
| 620 |
+
#endif
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
length -= BytesAtOnce;
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
const uint8_t* currentChar = (const uint8_t*) current;
|
| 627 |
+
// remaining 1 to 63 bytes (standard algorithm)
|
| 628 |
+
while (length-- != 0)
|
| 629 |
+
crc = (crc >> 8) ^ Crc32Lookup[0][(crc & 0xFF) ^ *currentChar++];
|
| 630 |
+
|
| 631 |
+
return ~crc; // same as crc ^ 0xFFFFFFFF
|
| 632 |
+
}
|
| 633 |
+
#endif
|
| 634 |
+
|
| 635 |
+
|
| 636 |
+
/// compute CRC32 using the fastest algorithm for large datasets on modern CPUs
|
| 637 |
+
uint32_t crc32_fast(const void* data, size_t length, uint32_t previousCrc32)
|
| 638 |
+
{
|
| 639 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
|
| 640 |
+
return crc32_16bytes (data, length, previousCrc32);
|
| 641 |
+
#elif defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8)
|
| 642 |
+
return crc32_8bytes (data, length, previousCrc32);
|
| 643 |
+
#elif defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4)
|
| 644 |
+
return crc32_4bytes (data, length, previousCrc32);
|
| 645 |
+
#elif defined(CRC32_USE_LOOKUP_TABLE_BYTE)
|
| 646 |
+
return crc32_1byte (data, length, previousCrc32);
|
| 647 |
+
#else
|
| 648 |
+
return crc32_halfbyte(data, length, previousCrc32);
|
| 649 |
+
#endif
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
|
| 653 |
+
/// merge two CRC32 such that result = crc32(dataB, lengthB, crc32(dataA, lengthA))
|
| 654 |
+
uint32_t crc32_combine(uint32_t crcA, uint32_t crcB, size_t lengthB)
|
| 655 |
+
{
|
| 656 |
+
// based on Mark Adler's crc_combine from
|
| 657 |
+
// https://github.com/madler/pigz/blob/master/pigz.c
|
| 658 |
+
|
| 659 |
+
// main idea:
|
| 660 |
+
// - if you have two equally-sized blocks A and B,
|
| 661 |
+
// then you can create a block C = A ^ B
|
| 662 |
+
// which has the property crc(C) = crc(A) ^ crc(B)
|
| 663 |
+
// - if you append length(B) zeros to A and call it A' (think of it as AAAA000)
|
| 664 |
+
// and prepend length(A) zeros to B and call it B' (think of it as 0000BBB)
|
| 665 |
+
// then exists a C' = A' ^ B'
|
| 666 |
+
// - remember: if you XOR something with zero, it remains unchanged: X ^ 0 = X
|
| 667 |
+
// - that means C' = A concat B so that crc(A concat B) = crc(C') = crc(A') ^ crc(B')
|
| 668 |
+
// - the trick is to compute crc(A') based on crc(A)
|
| 669 |
+
// and crc(B') based on crc(B)
|
| 670 |
+
// - since B' starts with many zeros, the crc of those initial zeros is still zero
|
| 671 |
+
// - that means crc(B') = crc(B)
|
| 672 |
+
// - unfortunately the trailing zeros of A' change the crc, so usually crc(A') != crc(A)
|
| 673 |
+
// - the following code is a fast algorithm to compute crc(A')
|
| 674 |
+
// - starting with crc(A) and appending length(B) zeros, needing just log2(length(B)) iterations
|
| 675 |
+
// - the details are explained by the original author at
|
| 676 |
+
// https://stackoverflow.com/questions/23122312/crc-calculation-of-a-mostly-static-data-stream/23126768
|
| 677 |
+
//
|
| 678 |
+
// notes:
|
| 679 |
+
// - I squeezed everything into one function to keep global namespace clean (original code two helper functions)
|
| 680 |
+
// - most original comments are still in place, I added comments where these helper functions where made inline code
|
| 681 |
+
// - performance-wise there isn't any differenze to the original zlib/pigz code
|
| 682 |
+
|
| 683 |
+
// degenerated case
|
| 684 |
+
if (lengthB == 0)
|
| 685 |
+
return crcA;
|
| 686 |
+
|
| 687 |
+
/// CRC32 => 32 bits
|
| 688 |
+
const uint32_t CrcBits = 32;
|
| 689 |
+
|
| 690 |
+
uint32_t odd [CrcBits]; // odd-power-of-two zeros operator
|
| 691 |
+
uint32_t even[CrcBits]; // even-power-of-two zeros operator
|
| 692 |
+
|
| 693 |
+
// put operator for one zero bit in odd
|
| 694 |
+
odd[0] = Polynomial; // CRC-32 polynomial
|
| 695 |
+
for (uint32_t i = 1; i < CrcBits; i++)
|
| 696 |
+
odd[i] = 1 << (i - 1);
|
| 697 |
+
|
| 698 |
+
// put operator for two zero bits in even
|
| 699 |
+
// same as gf2_matrix_square(even, odd);
|
| 700 |
+
for (uint32_t i = 0; i < CrcBits; i++)
|
| 701 |
+
{
|
| 702 |
+
uint32_t vec = odd[i];
|
| 703 |
+
even[i] = 0;
|
| 704 |
+
for (int j = 0; vec != 0; j++, vec >>= 1)
|
| 705 |
+
if (vec & 1)
|
| 706 |
+
even[i] ^= odd[j];
|
| 707 |
+
}
|
| 708 |
+
// put operator for four zero bits in odd
|
| 709 |
+
// same as gf2_matrix_square(odd, even);
|
| 710 |
+
for (uint32_t i = 0; i < CrcBits; i++)
|
| 711 |
+
{
|
| 712 |
+
uint32_t vec = even[i];
|
| 713 |
+
odd[i] = 0;
|
| 714 |
+
for (int j = 0; vec != 0; j++, vec >>= 1)
|
| 715 |
+
if (vec & 1)
|
| 716 |
+
odd[i] ^= even[j];
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
// the following loop becomes much shorter if I keep swapping even and odd
|
| 720 |
+
uint32_t* a = even;
|
| 721 |
+
uint32_t* b = odd;
|
| 722 |
+
// apply secondLength zeros to firstCrc32
|
| 723 |
+
for (; lengthB > 0; lengthB >>= 1)
|
| 724 |
+
{
|
| 725 |
+
// same as gf2_matrix_square(a, b);
|
| 726 |
+
for (uint32_t i = 0; i < CrcBits; i++)
|
| 727 |
+
{
|
| 728 |
+
uint32_t vec = b[i];
|
| 729 |
+
a[i] = 0;
|
| 730 |
+
for (int j = 0; vec != 0; j++, vec >>= 1)
|
| 731 |
+
if (vec & 1)
|
| 732 |
+
a[i] ^= b[j];
|
| 733 |
+
}
|
| 734 |
+
|
| 735 |
+
// apply zeros operator for this bit
|
| 736 |
+
if (lengthB & 1)
|
| 737 |
+
{
|
| 738 |
+
// same as firstCrc32 = gf2_matrix_times(a, firstCrc32);
|
| 739 |
+
uint32_t sum = 0;
|
| 740 |
+
for (int i = 0; crcA != 0; i++, crcA >>= 1)
|
| 741 |
+
if (crcA & 1)
|
| 742 |
+
sum ^= a[i];
|
| 743 |
+
crcA = sum;
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
// switch even and odd
|
| 747 |
+
uint32_t* t = a; a = b; b = t;
|
| 748 |
+
}
|
| 749 |
+
|
| 750 |
+
// return combined crc
|
| 751 |
+
return crcA ^ crcB;
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
|
| 755 |
+
// //////////////////////////////////////////////////////////
|
| 756 |
+
// constants
|
| 757 |
+
|
| 758 |
+
|
| 759 |
+
#ifndef NO_LUT
|
| 760 |
+
/// look-up table, already declared above
|
| 761 |
+
const uint32_t Crc32Lookup[MaxSlice][256] =
|
| 762 |
+
{
|
| 763 |
+
//// same algorithm as crc32_bitwise
|
| 764 |
+
//for (int i = 0; i <= 0xFF; i++)
|
| 765 |
+
//{
|
| 766 |
+
// uint32_t crc = i;
|
| 767 |
+
// for (int j = 0; j < 8; j++)
|
| 768 |
+
// crc = (crc >> 1) ^ ((crc & 1) * Polynomial);
|
| 769 |
+
// Crc32Lookup[0][i] = crc;
|
| 770 |
+
//}
|
| 771 |
+
//// ... and the following slicing-by-8 algorithm (from Intel):
|
| 772 |
+
//// http://www.intel.com/technology/comms/perfnet/download/CRC_generators.pdf
|
| 773 |
+
//// http://sourceforge.net/projects/slicing-by-8/
|
| 774 |
+
//for (int slice = 1; slice < MaxSlice; slice++)
|
| 775 |
+
// Crc32Lookup[slice][i] = (Crc32Lookup[slice - 1][i] >> 8) ^ Crc32Lookup[0][Crc32Lookup[slice - 1][i] & 0xFF];
|
| 776 |
+
{
|
| 777 |
+
// note: the first number of every second row corresponds to the half-byte look-up table !
|
| 778 |
+
0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,
|
| 779 |
+
0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,
|
| 780 |
+
0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,
|
| 781 |
+
0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5,
|
| 782 |
+
0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,
|
| 783 |
+
0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59,
|
| 784 |
+
0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,
|
| 785 |
+
0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,
|
| 786 |
+
0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,
|
| 787 |
+
0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01,
|
| 788 |
+
0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,
|
| 789 |
+
0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65,
|
| 790 |
+
0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,
|
| 791 |
+
0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,
|
| 792 |
+
0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,
|
| 793 |
+
0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD,
|
| 794 |
+
0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,
|
| 795 |
+
0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1,
|
| 796 |
+
0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,
|
| 797 |
+
0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,
|
| 798 |
+
0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,
|
| 799 |
+
0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79,
|
| 800 |
+
0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,
|
| 801 |
+
0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D,
|
| 802 |
+
0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,
|
| 803 |
+
0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,
|
| 804 |
+
0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,
|
| 805 |
+
0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45,
|
| 806 |
+
0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,
|
| 807 |
+
0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9,
|
| 808 |
+
0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,
|
| 809 |
+
0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D,
|
| 810 |
+
}
|
| 811 |
+
|
| 812 |
+
#if defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4) || defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8) || defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_16)
|
| 813 |
+
// beyond this point only relevant for Slicing-by-4, Slicing-by-8 and Slicing-by-16
|
| 814 |
+
,{
|
| 815 |
+
0x00000000,0x191B3141,0x32366282,0x2B2D53C3,0x646CC504,0x7D77F445,0x565AA786,0x4F4196C7,
|
| 816 |
+
0xC8D98A08,0xD1C2BB49,0xFAEFE88A,0xE3F4D9CB,0xACB54F0C,0xB5AE7E4D,0x9E832D8E,0x87981CCF,
|
| 817 |
+
0x4AC21251,0x53D92310,0x78F470D3,0x61EF4192,0x2EAED755,0x37B5E614,0x1C98B5D7,0x05838496,
|
| 818 |
+
0x821B9859,0x9B00A918,0xB02DFADB,0xA936CB9A,0xE6775D5D,0xFF6C6C1C,0xD4413FDF,0xCD5A0E9E,
|
| 819 |
+
0x958424A2,0x8C9F15E3,0xA7B24620,0xBEA97761,0xF1E8E1A6,0xE8F3D0E7,0xC3DE8324,0xDAC5B265,
|
| 820 |
+
0x5D5DAEAA,0x44469FEB,0x6F6BCC28,0x7670FD69,0x39316BAE,0x202A5AEF,0x0B07092C,0x121C386D,
|
| 821 |
+
0xDF4636F3,0xC65D07B2,0xED705471,0xF46B6530,0xBB2AF3F7,0xA231C2B6,0x891C9175,0x9007A034,
|
| 822 |
+
0x179FBCFB,0x0E848DBA,0x25A9DE79,0x3CB2EF38,0x73F379FF,0x6AE848BE,0x41C51B7D,0x58DE2A3C,
|
| 823 |
+
0xF0794F05,0xE9627E44,0xC24F2D87,0xDB541CC6,0x94158A01,0x8D0EBB40,0xA623E883,0xBF38D9C2,
|
| 824 |
+
0x38A0C50D,0x21BBF44C,0x0A96A78F,0x138D96CE,0x5CCC0009,0x45D73148,0x6EFA628B,0x77E153CA,
|
| 825 |
+
0xBABB5D54,0xA3A06C15,0x888D3FD6,0x91960E97,0xDED79850,0xC7CCA911,0xECE1FAD2,0xF5FACB93,
|
| 826 |
+
0x7262D75C,0x6B79E61D,0x4054B5DE,0x594F849F,0x160E1258,0x0F152319,0x243870DA,0x3D23419B,
|
| 827 |
+
0x65FD6BA7,0x7CE65AE6,0x57CB0925,0x4ED03864,0x0191AEA3,0x188A9FE2,0x33A7CC21,0x2ABCFD60,
|
| 828 |
+
0xAD24E1AF,0xB43FD0EE,0x9F12832D,0x8609B26C,0xC94824AB,0xD05315EA,0xFB7E4629,0xE2657768,
|
| 829 |
+
0x2F3F79F6,0x362448B7,0x1D091B74,0x04122A35,0x4B53BCF2,0x52488DB3,0x7965DE70,0x607EEF31,
|
| 830 |
+
0xE7E6F3FE,0xFEFDC2BF,0xD5D0917C,0xCCCBA03D,0x838A36FA,0x9A9107BB,0xB1BC5478,0xA8A76539,
|
| 831 |
+
0x3B83984B,0x2298A90A,0x09B5FAC9,0x10AECB88,0x5FEF5D4F,0x46F46C0E,0x6DD93FCD,0x74C20E8C,
|
| 832 |
+
0xF35A1243,0xEA412302,0xC16C70C1,0xD8774180,0x9736D747,0x8E2DE606,0xA500B5C5,0xBC1B8484,
|
| 833 |
+
0x71418A1A,0x685ABB5B,0x4377E898,0x5A6CD9D9,0x152D4F1E,0x0C367E5F,0x271B2D9C,0x3E001CDD,
|
| 834 |
+
0xB9980012,0xA0833153,0x8BAE6290,0x92B553D1,0xDDF4C516,0xC4EFF457,0xEFC2A794,0xF6D996D5,
|
| 835 |
+
0xAE07BCE9,0xB71C8DA8,0x9C31DE6B,0x852AEF2A,0xCA6B79ED,0xD37048AC,0xF85D1B6F,0xE1462A2E,
|
| 836 |
+
0x66DE36E1,0x7FC507A0,0x54E85463,0x4DF36522,0x02B2F3E5,0x1BA9C2A4,0x30849167,0x299FA026,
|
| 837 |
+
0xE4C5AEB8,0xFDDE9FF9,0xD6F3CC3A,0xCFE8FD7B,0x80A96BBC,0x99B25AFD,0xB29F093E,0xAB84387F,
|
| 838 |
+
0x2C1C24B0,0x350715F1,0x1E2A4632,0x07317773,0x4870E1B4,0x516BD0F5,0x7A468336,0x635DB277,
|
| 839 |
+
0xCBFAD74E,0xD2E1E60F,0xF9CCB5CC,0xE0D7848D,0xAF96124A,0xB68D230B,0x9DA070C8,0x84BB4189,
|
| 840 |
+
0x03235D46,0x1A386C07,0x31153FC4,0x280E0E85,0x674F9842,0x7E54A903,0x5579FAC0,0x4C62CB81,
|
| 841 |
+
0x8138C51F,0x9823F45E,0xB30EA79D,0xAA1596DC,0xE554001B,0xFC4F315A,0xD7626299,0xCE7953D8,
|
| 842 |
+
0x49E14F17,0x50FA7E56,0x7BD72D95,0x62CC1CD4,0x2D8D8A13,0x3496BB52,0x1FBBE891,0x06A0D9D0,
|
| 843 |
+
0x5E7EF3EC,0x4765C2AD,0x6C48916E,0x7553A02F,0x3A1236E8,0x230907A9,0x0824546A,0x113F652B,
|
| 844 |
+
0x96A779E4,0x8FBC48A5,0xA4911B66,0xBD8A2A27,0xF2CBBCE0,0xEBD08DA1,0xC0FDDE62,0xD9E6EF23,
|
| 845 |
+
0x14BCE1BD,0x0DA7D0FC,0x268A833F,0x3F91B27E,0x70D024B9,0x69CB15F8,0x42E6463B,0x5BFD777A,
|
| 846 |
+
0xDC656BB5,0xC57E5AF4,0xEE530937,0xF7483876,0xB809AEB1,0xA1129FF0,0x8A3FCC33,0x9324FD72,
|
| 847 |
+
},
|
| 848 |
+
|
| 849 |
+
{
|
| 850 |
+
0x00000000,0x01C26A37,0x0384D46E,0x0246BE59,0x0709A8DC,0x06CBC2EB,0x048D7CB2,0x054F1685,
|
| 851 |
+
0x0E1351B8,0x0FD13B8F,0x0D9785D6,0x0C55EFE1,0x091AF964,0x08D89353,0x0A9E2D0A,0x0B5C473D,
|
| 852 |
+
0x1C26A370,0x1DE4C947,0x1FA2771E,0x1E601D29,0x1B2F0BAC,0x1AED619B,0x18ABDFC2,0x1969B5F5,
|
| 853 |
+
0x1235F2C8,0x13F798FF,0x11B126A6,0x10734C91,0x153C5A14,0x14FE3023,0x16B88E7A,0x177AE44D,
|
| 854 |
+
0x384D46E0,0x398F2CD7,0x3BC9928E,0x3A0BF8B9,0x3F44EE3C,0x3E86840B,0x3CC03A52,0x3D025065,
|
| 855 |
+
0x365E1758,0x379C7D6F,0x35DAC336,0x3418A901,0x3157BF84,0x3095D5B3,0x32D36BEA,0x331101DD,
|
| 856 |
+
0x246BE590,0x25A98FA7,0x27EF31FE,0x262D5BC9,0x23624D4C,0x22A0277B,0x20E69922,0x2124F315,
|
| 857 |
+
0x2A78B428,0x2BBADE1F,0x29FC6046,0x283E0A71,0x2D711CF4,0x2CB376C3,0x2EF5C89A,0x2F37A2AD,
|
| 858 |
+
0x709A8DC0,0x7158E7F7,0x731E59AE,0x72DC3399,0x7793251C,0x76514F2B,0x7417F172,0x75D59B45,
|
| 859 |
+
0x7E89DC78,0x7F4BB64F,0x7D0D0816,0x7CCF6221,0x798074A4,0x78421E93,0x7A04A0CA,0x7BC6CAFD,
|
| 860 |
+
0x6CBC2EB0,0x6D7E4487,0x6F38FADE,0x6EFA90E9,0x6BB5866C,0x6A77EC5B,0x68315202,0x69F33835,
|
| 861 |
+
0x62AF7F08,0x636D153F,0x612BAB66,0x60E9C151,0x65A6D7D4,0x6464BDE3,0x662203BA,0x67E0698D,
|
| 862 |
+
0x48D7CB20,0x4915A117,0x4B531F4E,0x4A917579,0x4FDE63FC,0x4E1C09CB,0x4C5AB792,0x4D98DDA5,
|
| 863 |
+
0x46C49A98,0x4706F0AF,0x45404EF6,0x448224C1,0x41CD3244,0x400F5873,0x4249E62A,0x438B8C1D,
|
| 864 |
+
0x54F16850,0x55330267,0x5775BC3E,0x56B7D609,0x53F8C08C,0x523AAABB,0x507C14E2,0x51BE7ED5,
|
| 865 |
+
0x5AE239E8,0x5B2053DF,0x5966ED86,0x58A487B1,0x5DEB9134,0x5C29FB03,0x5E6F455A,0x5FAD2F6D,
|
| 866 |
+
0xE1351B80,0xE0F771B7,0xE2B1CFEE,0xE373A5D9,0xE63CB35C,0xE7FED96B,0xE5B86732,0xE47A0D05,
|
| 867 |
+
0xEF264A38,0xEEE4200F,0xECA29E56,0xED60F461,0xE82FE2E4,0xE9ED88D3,0xEBAB368A,0xEA695CBD,
|
| 868 |
+
0xFD13B8F0,0xFCD1D2C7,0xFE976C9E,0xFF5506A9,0xFA1A102C,0xFBD87A1B,0xF99EC442,0xF85CAE75,
|
| 869 |
+
0xF300E948,0xF2C2837F,0xF0843D26,0xF1465711,0xF4094194,0xF5CB2BA3,0xF78D95FA,0xF64FFFCD,
|
| 870 |
+
0xD9785D60,0xD8BA3757,0xDAFC890E,0xDB3EE339,0xDE71F5BC,0xDFB39F8B,0xDDF521D2,0xDC374BE5,
|
| 871 |
+
0xD76B0CD8,0xD6A966EF,0xD4EFD8B6,0xD52DB281,0xD062A404,0xD1A0CE33,0xD3E6706A,0xD2241A5D,
|
| 872 |
+
0xC55EFE10,0xC49C9427,0xC6DA2A7E,0xC7184049,0xC25756CC,0xC3953CFB,0xC1D382A2,0xC011E895,
|
| 873 |
+
0xCB4DAFA8,0xCA8FC59F,0xC8C97BC6,0xC90B11F1,0xCC440774,0xCD866D43,0xCFC0D31A,0xCE02B92D,
|
| 874 |
+
0x91AF9640,0x906DFC77,0x922B422E,0x93E92819,0x96A63E9C,0x976454AB,0x9522EAF2,0x94E080C5,
|
| 875 |
+
0x9FBCC7F8,0x9E7EADCF,0x9C381396,0x9DFA79A1,0x98B56F24,0x99770513,0x9B31BB4A,0x9AF3D17D,
|
| 876 |
+
0x8D893530,0x8C4B5F07,0x8E0DE15E,0x8FCF8B69,0x8A809DEC,0x8B42F7DB,0x89044982,0x88C623B5,
|
| 877 |
+
0x839A6488,0x82580EBF,0x801EB0E6,0x81DCDAD1,0x8493CC54,0x8551A663,0x8717183A,0x86D5720D,
|
| 878 |
+
0xA9E2D0A0,0xA820BA97,0xAA6604CE,0xABA46EF9,0xAEEB787C,0xAF29124B,0xAD6FAC12,0xACADC625,
|
| 879 |
+
0xA7F18118,0xA633EB2F,0xA4755576,0xA5B73F41,0xA0F829C4,0xA13A43F3,0xA37CFDAA,0xA2BE979D,
|
| 880 |
+
0xB5C473D0,0xB40619E7,0xB640A7BE,0xB782CD89,0xB2CDDB0C,0xB30FB13B,0xB1490F62,0xB08B6555,
|
| 881 |
+
0xBBD72268,0xBA15485F,0xB853F606,0xB9919C31,0xBCDE8AB4,0xBD1CE083,0xBF5A5EDA,0xBE9834ED,
|
| 882 |
+
},
|
| 883 |
+
|
| 884 |
+
{
|
| 885 |
+
0x00000000,0xB8BC6765,0xAA09C88B,0x12B5AFEE,0x8F629757,0x37DEF032,0x256B5FDC,0x9DD738B9,
|
| 886 |
+
0xC5B428EF,0x7D084F8A,0x6FBDE064,0xD7018701,0x4AD6BFB8,0xF26AD8DD,0xE0DF7733,0x58631056,
|
| 887 |
+
0x5019579F,0xE8A530FA,0xFA109F14,0x42ACF871,0xDF7BC0C8,0x67C7A7AD,0x75720843,0xCDCE6F26,
|
| 888 |
+
0x95AD7F70,0x2D111815,0x3FA4B7FB,0x8718D09E,0x1ACFE827,0xA2738F42,0xB0C620AC,0x087A47C9,
|
| 889 |
+
0xA032AF3E,0x188EC85B,0x0A3B67B5,0xB28700D0,0x2F503869,0x97EC5F0C,0x8559F0E2,0x3DE59787,
|
| 890 |
+
0x658687D1,0xDD3AE0B4,0xCF8F4F5A,0x7733283F,0xEAE41086,0x525877E3,0x40EDD80D,0xF851BF68,
|
| 891 |
+
0xF02BF8A1,0x48979FC4,0x5A22302A,0xE29E574F,0x7F496FF6,0xC7F50893,0xD540A77D,0x6DFCC018,
|
| 892 |
+
0x359FD04E,0x8D23B72B,0x9F9618C5,0x272A7FA0,0xBAFD4719,0x0241207C,0x10F48F92,0xA848E8F7,
|
| 893 |
+
0x9B14583D,0x23A83F58,0x311D90B6,0x89A1F7D3,0x1476CF6A,0xACCAA80F,0xBE7F07E1,0x06C36084,
|
| 894 |
+
0x5EA070D2,0xE61C17B7,0xF4A9B859,0x4C15DF3C,0xD1C2E785,0x697E80E0,0x7BCB2F0E,0xC377486B,
|
| 895 |
+
0xCB0D0FA2,0x73B168C7,0x6104C729,0xD9B8A04C,0x446F98F5,0xFCD3FF90,0xEE66507E,0x56DA371B,
|
| 896 |
+
0x0EB9274D,0xB6054028,0xA4B0EFC6,0x1C0C88A3,0x81DBB01A,0x3967D77F,0x2BD27891,0x936E1FF4,
|
| 897 |
+
0x3B26F703,0x839A9066,0x912F3F88,0x299358ED,0xB4446054,0x0CF80731,0x1E4DA8DF,0xA6F1CFBA,
|
| 898 |
+
0xFE92DFEC,0x462EB889,0x549B1767,0xEC277002,0x71F048BB,0xC94C2FDE,0xDBF98030,0x6345E755,
|
| 899 |
+
0x6B3FA09C,0xD383C7F9,0xC1366817,0x798A0F72,0xE45D37CB,0x5CE150AE,0x4E54FF40,0xF6E89825,
|
| 900 |
+
0xAE8B8873,0x1637EF16,0x048240F8,0xBC3E279D,0x21E91F24,0x99557841,0x8BE0D7AF,0x335CB0CA,
|
| 901 |
+
0xED59B63B,0x55E5D15E,0x47507EB0,0xFFEC19D5,0x623B216C,0xDA874609,0xC832E9E7,0x708E8E82,
|
| 902 |
+
0x28ED9ED4,0x9051F9B1,0x82E4565F,0x3A58313A,0xA78F0983,0x1F336EE6,0x0D86C108,0xB53AA66D,
|
| 903 |
+
0xBD40E1A4,0x05FC86C1,0x1749292F,0xAFF54E4A,0x322276F3,0x8A9E1196,0x982BBE78,0x2097D91D,
|
| 904 |
+
0x78F4C94B,0xC048AE2E,0xD2FD01C0,0x6A4166A5,0xF7965E1C,0x4F2A3979,0x5D9F9697,0xE523F1F2,
|
| 905 |
+
0x4D6B1905,0xF5D77E60,0xE762D18E,0x5FDEB6EB,0xC2098E52,0x7AB5E937,0x680046D9,0xD0BC21BC,
|
| 906 |
+
0x88DF31EA,0x3063568F,0x22D6F961,0x9A6A9E04,0x07BDA6BD,0xBF01C1D8,0xADB46E36,0x15080953,
|
| 907 |
+
0x1D724E9A,0xA5CE29FF,0xB77B8611,0x0FC7E174,0x9210D9CD,0x2AACBEA8,0x38191146,0x80A57623,
|
| 908 |
+
0xD8C66675,0x607A0110,0x72CFAEFE,0xCA73C99B,0x57A4F122,0xEF189647,0xFDAD39A9,0x45115ECC,
|
| 909 |
+
0x764DEE06,0xCEF18963,0xDC44268D,0x64F841E8,0xF92F7951,0x41931E34,0x5326B1DA,0xEB9AD6BF,
|
| 910 |
+
0xB3F9C6E9,0x0B45A18C,0x19F00E62,0xA14C6907,0x3C9B51BE,0x842736DB,0x96929935,0x2E2EFE50,
|
| 911 |
+
0x2654B999,0x9EE8DEFC,0x8C5D7112,0x34E11677,0xA9362ECE,0x118A49AB,0x033FE645,0xBB838120,
|
| 912 |
+
0xE3E09176,0x5B5CF613,0x49E959FD,0xF1553E98,0x6C820621,0xD43E6144,0xC68BCEAA,0x7E37A9CF,
|
| 913 |
+
0xD67F4138,0x6EC3265D,0x7C7689B3,0xC4CAEED6,0x591DD66F,0xE1A1B10A,0xF3141EE4,0x4BA87981,
|
| 914 |
+
0x13CB69D7,0xAB770EB2,0xB9C2A15C,0x017EC639,0x9CA9FE80,0x241599E5,0x36A0360B,0x8E1C516E,
|
| 915 |
+
0x866616A7,0x3EDA71C2,0x2C6FDE2C,0x94D3B949,0x090481F0,0xB1B8E695,0xA30D497B,0x1BB12E1E,
|
| 916 |
+
0x43D23E48,0xFB6E592D,0xE9DBF6C3,0x516791A6,0xCCB0A91F,0x740CCE7A,0x66B96194,0xDE0506F1,
|
| 917 |
+
}
|
| 918 |
+
#endif // defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_4) || defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_8) || defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_16)
|
| 919 |
+
#if defined (CRC32_USE_LOOKUP_TABLE_SLICING_BY_8) || defined(CRC32_USE_LOOKUP_TABLE_SLICING_BY_16)
|
| 920 |
+
// beyond this point only relevant for Slicing-by-8 and Slicing-by-16
|
| 921 |
+
,{
|
| 922 |
+
0x00000000,0x3D6029B0,0x7AC05360,0x47A07AD0,0xF580A6C0,0xC8E08F70,0x8F40F5A0,0xB220DC10,
|
| 923 |
+
0x30704BC1,0x0D106271,0x4AB018A1,0x77D03111,0xC5F0ED01,0xF890C4B1,0xBF30BE61,0x825097D1,
|
| 924 |
+
0x60E09782,0x5D80BE32,0x1A20C4E2,0x2740ED52,0x95603142,0xA80018F2,0xEFA06222,0xD2C04B92,
|
| 925 |
+
0x5090DC43,0x6DF0F5F3,0x2A508F23,0x1730A693,0xA5107A83,0x98705333,0xDFD029E3,0xE2B00053,
|
| 926 |
+
0xC1C12F04,0xFCA106B4,0xBB017C64,0x866155D4,0x344189C4,0x0921A074,0x4E81DAA4,0x73E1F314,
|
| 927 |
+
0xF1B164C5,0xCCD14D75,0x8B7137A5,0xB6111E15,0x0431C205,0x3951EBB5,0x7EF19165,0x4391B8D5,
|
| 928 |
+
0xA121B886,0x9C419136,0xDBE1EBE6,0xE681C256,0x54A11E46,0x69C137F6,0x2E614D26,0x13016496,
|
| 929 |
+
0x9151F347,0xAC31DAF7,0xEB91A027,0xD6F18997,0x64D15587,0x59B17C37,0x1E1106E7,0x23712F57,
|
| 930 |
+
0x58F35849,0x659371F9,0x22330B29,0x1F532299,0xAD73FE89,0x9013D739,0xD7B3ADE9,0xEAD38459,
|
| 931 |
+
0x68831388,0x55E33A38,0x124340E8,0x2F236958,0x9D03B548,0xA0639CF8,0xE7C3E628,0xDAA3CF98,
|
| 932 |
+
0x3813CFCB,0x0573E67B,0x42D39CAB,0x7FB3B51B,0xCD93690B,0xF0F340BB,0xB7533A6B,0x8A3313DB,
|
| 933 |
+
0x0863840A,0x3503ADBA,0x72A3D76A,0x4FC3FEDA,0xFDE322CA,0xC0830B7A,0x872371AA,0xBA43581A,
|
| 934 |
+
0x9932774D,0xA4525EFD,0xE3F2242D,0xDE920D9D,0x6CB2D18D,0x51D2F83D,0x167282ED,0x2B12AB5D,
|
| 935 |
+
0xA9423C8C,0x9422153C,0xD3826FEC,0xEEE2465C,0x5CC29A4C,0x61A2B3FC,0x2602C92C,0x1B62E09C,
|
| 936 |
+
0xF9D2E0CF,0xC4B2C97F,0x8312B3AF,0xBE729A1F,0x0C52460F,0x31326FBF,0x7692156F,0x4BF23CDF,
|
| 937 |
+
0xC9A2AB0E,0xF4C282BE,0xB362F86E,0x8E02D1DE,0x3C220DCE,0x0142247E,0x46E25EAE,0x7B82771E,
|
| 938 |
+
0xB1E6B092,0x8C869922,0xCB26E3F2,0xF646CA42,0x44661652,0x79063FE2,0x3EA64532,0x03C66C82,
|
| 939 |
+
0x8196FB53,0xBCF6D2E3,0xFB56A833,0xC6368183,0x74165D93,0x49767423,0x0ED60EF3,0x33B62743,
|
| 940 |
+
0xD1062710,0xEC660EA0,0xABC67470,0x96A65DC0,0x248681D0,0x19E6A860,0x5E46D2B0,0x6326FB00,
|
| 941 |
+
0xE1766CD1,0xDC164561,0x9BB63FB1,0xA6D61601,0x14F6CA11,0x2996E3A1,0x6E369971,0x5356B0C1,
|
| 942 |
+
0x70279F96,0x4D47B626,0x0AE7CCF6,0x3787E546,0x85A73956,0xB8C710E6,0xFF676A36,0xC2074386,
|
| 943 |
+
0x4057D457,0x7D37FDE7,0x3A978737,0x07F7AE87,0xB5D77297,0x88B75B27,0xCF1721F7,0xF2770847,
|
| 944 |
+
0x10C70814,0x2DA721A4,0x6A075B74,0x576772C4,0xE547AED4,0xD8278764,0x9F87FDB4,0xA2E7D404,
|
| 945 |
+
0x20B743D5,0x1DD76A65,0x5A7710B5,0x67173905,0xD537E515,0xE857CCA5,0xAFF7B675,0x92979FC5,
|
| 946 |
+
0xE915E8DB,0xD475C16B,0x93D5BBBB,0xAEB5920B,0x1C954E1B,0x21F567AB,0x66551D7B,0x5B3534CB,
|
| 947 |
+
0xD965A31A,0xE4058AAA,0xA3A5F07A,0x9EC5D9CA,0x2CE505DA,0x11852C6A,0x562556BA,0x6B457F0A,
|
| 948 |
+
0x89F57F59,0xB49556E9,0xF3352C39,0xCE550589,0x7C75D999,0x4115F029,0x06B58AF9,0x3BD5A349,
|
| 949 |
+
0xB9853498,0x84E51D28,0xC34567F8,0xFE254E48,0x4C059258,0x7165BBE8,0x36C5C138,0x0BA5E888,
|
| 950 |
+
0x28D4C7DF,0x15B4EE6F,0x521494BF,0x6F74BD0F,0xDD54611F,0xE03448AF,0xA794327F,0x9AF41BCF,
|
| 951 |
+
0x18A48C1E,0x25C4A5AE,0x6264DF7E,0x5F04F6CE,0xED242ADE,0xD044036E,0x97E479BE,0xAA84500E,
|
| 952 |
+
0x4834505D,0x755479ED,0x32F4033D,0x0F942A8D,0xBDB4F69D,0x80D4DF2D,0xC774A5FD,0xFA148C4D,
|
| 953 |
+
0x78441B9C,0x4524322C,0x028448FC,0x3FE4614C,0x8DC4BD5C,0xB0A494EC,0xF704EE3C,0xCA64C78C,
|
| 954 |
+
},
|
| 955 |
+
|
| 956 |
+
{
|
| 957 |
+
0x00000000,0xCB5CD3A5,0x4DC8A10B,0x869472AE,0x9B914216,0x50CD91B3,0xD659E31D,0x1D0530B8,
|
| 958 |
+
0xEC53826D,0x270F51C8,0xA19B2366,0x6AC7F0C3,0x77C2C07B,0xBC9E13DE,0x3A0A6170,0xF156B2D5,
|
| 959 |
+
0x03D6029B,0xC88AD13E,0x4E1EA390,0x85427035,0x9847408D,0x531B9328,0xD58FE186,0x1ED33223,
|
| 960 |
+
0xEF8580F6,0x24D95353,0xA24D21FD,0x6911F258,0x7414C2E0,0xBF481145,0x39DC63EB,0xF280B04E,
|
| 961 |
+
0x07AC0536,0xCCF0D693,0x4A64A43D,0x81387798,0x9C3D4720,0x57619485,0xD1F5E62B,0x1AA9358E,
|
| 962 |
+
0xEBFF875B,0x20A354FE,0xA6372650,0x6D6BF5F5,0x706EC54D,0xBB3216E8,0x3DA66446,0xF6FAB7E3,
|
| 963 |
+
0x047A07AD,0xCF26D408,0x49B2A6A6,0x82EE7503,0x9FEB45BB,0x54B7961E,0xD223E4B0,0x197F3715,
|
| 964 |
+
0xE82985C0,0x23755665,0xA5E124CB,0x6EBDF76E,0x73B8C7D6,0xB8E41473,0x3E7066DD,0xF52CB578,
|
| 965 |
+
0x0F580A6C,0xC404D9C9,0x4290AB67,0x89CC78C2,0x94C9487A,0x5F959BDF,0xD901E971,0x125D3AD4,
|
| 966 |
+
0xE30B8801,0x28575BA4,0xAEC3290A,0x659FFAAF,0x789ACA17,0xB3C619B2,0x35526B1C,0xFE0EB8B9,
|
| 967 |
+
0x0C8E08F7,0xC7D2DB52,0x4146A9FC,0x8A1A7A59,0x971F4AE1,0x5C439944,0xDAD7EBEA,0x118B384F,
|
| 968 |
+
0xE0DD8A9A,0x2B81593F,0xAD152B91,0x6649F834,0x7B4CC88C,0xB0101B29,0x36846987,0xFDD8BA22,
|
| 969 |
+
0x08F40F5A,0xC3A8DCFF,0x453CAE51,0x8E607DF4,0x93654D4C,0x58399EE9,0xDEADEC47,0x15F13FE2,
|
| 970 |
+
0xE4A78D37,0x2FFB5E92,0xA96F2C3C,0x6233FF99,0x7F36CF21,0xB46A1C84,0x32FE6E2A,0xF9A2BD8F,
|
| 971 |
+
0x0B220DC1,0xC07EDE64,0x46EAACCA,0x8DB67F6F,0x90B34FD7,0x5BEF9C72,0xDD7BEEDC,0x16273D79,
|
| 972 |
+
0xE7718FAC,0x2C2D5C09,0xAAB92EA7,0x61E5FD02,0x7CE0CDBA,0xB7BC1E1F,0x31286CB1,0xFA74BF14,
|
| 973 |
+
0x1EB014D8,0xD5ECC77D,0x5378B5D3,0x98246676,0x852156CE,0x4E7D856B,0xC8E9F7C5,0x03B52460,
|
| 974 |
+
0xF2E396B5,0x39BF4510,0xBF2B37BE,0x7477E41B,0x6972D4A3,0xA22E0706,0x24BA75A8,0xEFE6A60D,
|
| 975 |
+
0x1D661643,0xD63AC5E6,0x50AEB748,0x9BF264ED,0x86F75455,0x4DAB87F0,0xCB3FF55E,0x006326FB,
|
| 976 |
+
0xF135942E,0x3A69478B,0xBCFD3525,0x77A1E680,0x6AA4D638,0xA1F8059D,0x276C7733,0xEC30A496,
|
| 977 |
+
0x191C11EE,0xD240C24B,0x54D4B0E5,0x9F886340,0x828D53F8,0x49D1805D,0xCF45F2F3,0x04192156,
|
| 978 |
+
0xF54F9383,0x3E134026,0xB8873288,0x73DBE12D,0x6EDED195,0xA5820230,0x2316709E,0xE84AA33B,
|
| 979 |
+
0x1ACA1375,0xD196C0D0,0x5702B27E,0x9C5E61DB,0x815B5163,0x4A0782C6,0xCC93F068,0x07CF23CD,
|
| 980 |
+
0xF6999118,0x3DC542BD,0xBB513013,0x700DE3B6,0x6D08D30E,0xA65400AB,0x20C07205,0xEB9CA1A0,
|
| 981 |
+
0x11E81EB4,0xDAB4CD11,0x5C20BFBF,0x977C6C1A,0x8A795CA2,0x41258F07,0xC7B1FDA9,0x0CED2E0C,
|
| 982 |
+
0xFDBB9CD9,0x36E74F7C,0xB0733DD2,0x7B2FEE77,0x662ADECF,0xAD760D6A,0x2BE27FC4,0xE0BEAC61,
|
| 983 |
+
0x123E1C2F,0xD962CF8A,0x5FF6BD24,0x94AA6E81,0x89AF5E39,0x42F38D9C,0xC467FF32,0x0F3B2C97,
|
| 984 |
+
0xFE6D9E42,0x35314DE7,0xB3A53F49,0x78F9ECEC,0x65FCDC54,0xAEA00FF1,0x28347D5F,0xE368AEFA,
|
| 985 |
+
0x16441B82,0xDD18C827,0x5B8CBA89,0x90D0692C,0x8DD55994,0x46898A31,0xC01DF89F,0x0B412B3A,
|
| 986 |
+
0xFA1799EF,0x314B4A4A,0xB7DF38E4,0x7C83EB41,0x6186DBF9,0xAADA085C,0x2C4E7AF2,0xE712A957,
|
| 987 |
+
0x15921919,0xDECECABC,0x585AB812,0x93066BB7,0x8E035B0F,0x455F88AA,0xC3CBFA04,0x089729A1,
|
| 988 |
+
0xF9C19B74,0x329D48D1,0xB4093A7F,0x7F55E9DA,0x6250D962,0xA90C0AC7,0x2F987869,0xE4C4ABCC,
|
| 989 |
+
},
|
| 990 |
+
|
| 991 |
+
{
|
| 992 |
+
0x00000000,0xA6770BB4,0x979F1129,0x31E81A9D,0xF44F2413,0x52382FA7,0x63D0353A,0xC5A73E8E,
|
| 993 |
+
0x33EF4E67,0x959845D3,0xA4705F4E,0x020754FA,0xC7A06A74,0x61D761C0,0x503F7B5D,0xF64870E9,
|
| 994 |
+
0x67DE9CCE,0xC1A9977A,0xF0418DE7,0x56368653,0x9391B8DD,0x35E6B369,0x040EA9F4,0xA279A240,
|
| 995 |
+
0x5431D2A9,0xF246D91D,0xC3AEC380,0x65D9C834,0xA07EF6BA,0x0609FD0E,0x37E1E793,0x9196EC27,
|
| 996 |
+
0xCFBD399C,0x69CA3228,0x582228B5,0xFE552301,0x3BF21D8F,0x9D85163B,0xAC6D0CA6,0x0A1A0712,
|
| 997 |
+
0xFC5277FB,0x5A257C4F,0x6BCD66D2,0xCDBA6D66,0x081D53E8,0xAE6A585C,0x9F8242C1,0x39F54975,
|
| 998 |
+
0xA863A552,0x0E14AEE6,0x3FFCB47B,0x998BBFCF,0x5C2C8141,0xFA5B8AF5,0xCBB39068,0x6DC49BDC,
|
| 999 |
+
0x9B8CEB35,0x3DFBE081,0x0C13FA1C,0xAA64F1A8,0x6FC3CF26,0xC9B4C492,0xF85CDE0F,0x5E2BD5BB,
|
| 1000 |
+
0x440B7579,0xE27C7ECD,0xD3946450,0x75E36FE4,0xB044516A,0x16335ADE,0x27DB4043,0x81AC4BF7,
|
| 1001 |
+
0x77E43B1E,0xD19330AA,0xE07B2A37,0x460C2183,0x83AB1F0D,0x25DC14B9,0x14340E24,0xB2430590,
|
| 1002 |
+
0x23D5E9B7,0x85A2E203,0xB44AF89E,0x123DF32A,0xD79ACDA4,0x71EDC610,0x4005DC8D,0xE672D739,
|
| 1003 |
+
0x103AA7D0,0xB64DAC64,0x87A5B6F9,0x21D2BD4D,0xE47583C3,0x42028877,0x73EA92EA,0xD59D995E,
|
| 1004 |
+
0x8BB64CE5,0x2DC14751,0x1C295DCC,0xBA5E5678,0x7FF968F6,0xD98E6342,0xE86679DF,0x4E11726B,
|
| 1005 |
+
0xB8590282,0x1E2E0936,0x2FC613AB,0x89B1181F,0x4C162691,0xEA612D25,0xDB8937B8,0x7DFE3C0C,
|
| 1006 |
+
0xEC68D02B,0x4A1FDB9F,0x7BF7C102,0xDD80CAB6,0x1827F438,0xBE50FF8C,0x8FB8E511,0x29CFEEA5,
|
| 1007 |
+
0xDF879E4C,0x79F095F8,0x48188F65,0xEE6F84D1,0x2BC8BA5F,0x8DBFB1EB,0xBC57AB76,0x1A20A0C2,
|
| 1008 |
+
0x8816EAF2,0x2E61E146,0x1F89FBDB,0xB9FEF06F,0x7C59CEE1,0xDA2EC555,0xEBC6DFC8,0x4DB1D47C,
|
| 1009 |
+
0xBBF9A495,0x1D8EAF21,0x2C66B5BC,0x8A11BE08,0x4FB68086,0xE9C18B32,0xD82991AF,0x7E5E9A1B,
|
| 1010 |
+
0xEFC8763C,0x49BF7D88,0x78576715,0xDE206CA1,0x1B87522F,0xBDF0599B,0x8C184306,0x2A6F48B2,
|
| 1011 |
+
0xDC27385B,0x7A5033EF,0x4BB82972,0xEDCF22C6,0x28681C48,0x8E1F17FC,0xBFF70D61,0x198006D5,
|
| 1012 |
+
0x47ABD36E,0xE1DCD8DA,0xD034C247,0x7643C9F3,0xB3E4F77D,0x1593FCC9,0x247BE654,0x820CEDE0,
|
| 1013 |
+
0x74449D09,0xD23396BD,0xE3DB8C20,0x45AC8794,0x800BB91A,0x267CB2AE,0x1794A833,0xB1E3A387,
|
| 1014 |
+
0x20754FA0,0x86024414,0xB7EA5E89,0x119D553D,0xD43A6BB3,0x724D6007,0x43A57A9A,0xE5D2712E,
|
| 1015 |
+
0x139A01C7,0xB5ED0A73,0x840510EE,0x22721B5A,0xE7D525D4,0x41A22E60,0x704A34FD,0xD63D3F49,
|
| 1016 |
+
0xCC1D9F8B,0x6A6A943F,0x5B828EA2,0xFDF58516,0x3852BB98,0x9E25B02C,0xAFCDAAB1,0x09BAA105,
|
| 1017 |
+
0xFFF2D1EC,0x5985DA58,0x686DC0C5,0xCE1ACB71,0x0BBDF5FF,0xADCAFE4B,0x9C22E4D6,0x3A55EF62,
|
| 1018 |
+
0xABC30345,0x0DB408F1,0x3C5C126C,0x9A2B19D8,0x5F8C2756,0xF9FB2CE2,0xC813367F,0x6E643DCB,
|
| 1019 |
+
0x982C4D22,0x3E5B4696,0x0FB35C0B,0xA9C457BF,0x6C636931,0xCA146285,0xFBFC7818,0x5D8B73AC,
|
| 1020 |
+
0x03A0A617,0xA5D7ADA3,0x943FB73E,0x3248BC8A,0xF7EF8204,0x519889B0,0x6070932D,0xC6079899,
|
| 1021 |
+
0x304FE870,0x9638E3C4,0xA7D0F959,0x01A7F2ED,0xC400CC63,0x6277C7D7,0x539FDD4A,0xF5E8D6FE,
|
| 1022 |
+
0x647E3AD9,0xC209316D,0xF3E12BF0,0x55962044,0x90311ECA,0x3646157E,0x07AE0FE3,0xA1D90457,
|
| 1023 |
+
0x579174BE,0xF1E67F0A,0xC00E6597,0x66796E23,0xA3DE50AD,0x05A95B19,0x34414184,0x92364A30,
|
| 1024 |
+
},
|
| 1025 |
+
|
| 1026 |
+
{
|
| 1027 |
+
0x00000000,0xCCAA009E,0x4225077D,0x8E8F07E3,0x844A0EFA,0x48E00E64,0xC66F0987,0x0AC50919,
|
| 1028 |
+
0xD3E51BB5,0x1F4F1B2B,0x91C01CC8,0x5D6A1C56,0x57AF154F,0x9B0515D1,0x158A1232,0xD92012AC,
|
| 1029 |
+
0x7CBB312B,0xB01131B5,0x3E9E3656,0xF23436C8,0xF8F13FD1,0x345B3F4F,0xBAD438AC,0x767E3832,
|
| 1030 |
+
0xAF5E2A9E,0x63F42A00,0xED7B2DE3,0x21D12D7D,0x2B142464,0xE7BE24FA,0x69312319,0xA59B2387,
|
| 1031 |
+
0xF9766256,0x35DC62C8,0xBB53652B,0x77F965B5,0x7D3C6CAC,0xB1966C32,0x3F196BD1,0xF3B36B4F,
|
| 1032 |
+
0x2A9379E3,0xE639797D,0x68B67E9E,0xA41C7E00,0xAED97719,0x62737787,0xECFC7064,0x205670FA,
|
| 1033 |
+
0x85CD537D,0x496753E3,0xC7E85400,0x0B42549E,0x01875D87,0xCD2D5D19,0x43A25AFA,0x8F085A64,
|
| 1034 |
+
0x562848C8,0x9A824856,0x140D4FB5,0xD8A74F2B,0xD2624632,0x1EC846AC,0x9047414F,0x5CED41D1,
|
| 1035 |
+
0x299DC2ED,0xE537C273,0x6BB8C590,0xA712C50E,0xADD7CC17,0x617DCC89,0xEFF2CB6A,0x2358CBF4,
|
| 1036 |
+
0xFA78D958,0x36D2D9C6,0xB85DDE25,0x74F7DEBB,0x7E32D7A2,0xB298D73C,0x3C17D0DF,0xF0BDD041,
|
| 1037 |
+
0x5526F3C6,0x998CF358,0x1703F4BB,0xDBA9F425,0xD16CFD3C,0x1DC6FDA2,0x9349FA41,0x5FE3FADF,
|
| 1038 |
+
0x86C3E873,0x4A69E8ED,0xC4E6EF0E,0x084CEF90,0x0289E689,0xCE23E617,0x40ACE1F4,0x8C06E16A,
|
| 1039 |
+
0xD0EBA0BB,0x1C41A025,0x92CEA7C6,0x5E64A758,0x54A1AE41,0x980BAEDF,0x1684A93C,0xDA2EA9A2,
|
| 1040 |
+
0x030EBB0E,0xCFA4BB90,0x412BBC73,0x8D81BCED,0x8744B5F4,0x4BEEB56A,0xC561B289,0x09CBB217,
|
| 1041 |
+
0xAC509190,0x60FA910E,0xEE7596ED,0x22DF9673,0x281A9F6A,0xE4B09FF4,0x6A3F9817,0xA6959889,
|
| 1042 |
+
0x7FB58A25,0xB31F8ABB,0x3D908D58,0xF13A8DC6,0xFBFF84DF,0x37558441,0xB9DA83A2,0x7570833C,
|
| 1043 |
+
0x533B85DA,0x9F918544,0x111E82A7,0xDDB48239,0xD7718B20,0x1BDB8BBE,0x95548C5D,0x59FE8CC3,
|
| 1044 |
+
0x80DE9E6F,0x4C749EF1,0xC2FB9912,0x0E51998C,0x04949095,0xC83E900B,0x46B197E8,0x8A1B9776,
|
| 1045 |
+
0x2F80B4F1,0xE32AB46F,0x6DA5B38C,0xA10FB312,0xABCABA0B,0x6760BA95,0xE9EFBD76,0x2545BDE8,
|
| 1046 |
+
0xFC65AF44,0x30CFAFDA,0xBE40A839,0x72EAA8A7,0x782FA1BE,0xB485A120,0x3A0AA6C3,0xF6A0A65D,
|
| 1047 |
+
0xAA4DE78C,0x66E7E712,0xE868E0F1,0x24C2E06F,0x2E07E976,0xE2ADE9E8,0x6C22EE0B,0xA088EE95,
|
| 1048 |
+
0x79A8FC39,0xB502FCA7,0x3B8DFB44,0xF727FBDA,0xFDE2F2C3,0x3148F25D,0xBFC7F5BE,0x736DF520,
|
| 1049 |
+
0xD6F6D6A7,0x1A5CD639,0x94D3D1DA,0x5879D144,0x52BCD85D,0x9E16D8C3,0x1099DF20,0xDC33DFBE,
|
| 1050 |
+
0x0513CD12,0xC9B9CD8C,0x4736CA6F,0x8B9CCAF1,0x8159C3E8,0x4DF3C376,0xC37CC495,0x0FD6C40B,
|
| 1051 |
+
0x7AA64737,0xB60C47A9,0x3883404A,0xF42940D4,0xFEEC49CD,0x32464953,0xBCC94EB0,0x70634E2E,
|
| 1052 |
+
0xA9435C82,0x65E95C1C,0xEB665BFF,0x27CC5B61,0x2D095278,0xE1A352E6,0x6F2C5505,0xA386559B,
|
| 1053 |
+
0x061D761C,0xCAB77682,0x44387161,0x889271FF,0x825778E6,0x4EFD7878,0xC0727F9B,0x0CD87F05,
|
| 1054 |
+
0xD5F86DA9,0x19526D37,0x97DD6AD4,0x5B776A4A,0x51B26353,0x9D1863CD,0x1397642E,0xDF3D64B0,
|
| 1055 |
+
0x83D02561,0x4F7A25FF,0xC1F5221C,0x0D5F2282,0x079A2B9B,0xCB302B05,0x45BF2CE6,0x89152C78,
|
| 1056 |
+
0x50353ED4,0x9C9F3E4A,0x121039A9,0xDEBA3937,0xD47F302E,0x18D530B0,0x965A3753,0x5AF037CD,
|
| 1057 |
+
0xFF6B144A,0x33C114D4,0xBD4E1337,0x71E413A9,0x7B211AB0,0xB78B1A2E,0x39041DCD,0xF5AE1D53,
|
| 1058 |
+
0x2C8E0FFF,0xE0240F61,0x6EAB0882,0xA201081C,0xA8C40105,0x646E019B,0xEAE10678,0x264B06E6,
|
| 1059 |
+
}
|
| 1060 |
+
#endif // CRC32_USE_LOOKUP_TABLE_SLICING_BY_8 || CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
|
| 1061 |
+
#ifdef CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
|
| 1062 |
+
// beyond this point only relevant for Slicing-by-16
|
| 1063 |
+
,{
|
| 1064 |
+
0x00000000,0x177B1443,0x2EF62886,0x398D3CC5,0x5DEC510C,0x4A97454F,0x731A798A,0x64616DC9,
|
| 1065 |
+
0xBBD8A218,0xACA3B65B,0x952E8A9E,0x82559EDD,0xE634F314,0xF14FE757,0xC8C2DB92,0xDFB9CFD1,
|
| 1066 |
+
0xACC04271,0xBBBB5632,0x82366AF7,0x954D7EB4,0xF12C137D,0xE657073E,0xDFDA3BFB,0xC8A12FB8,
|
| 1067 |
+
0x1718E069,0x0063F42A,0x39EEC8EF,0x2E95DCAC,0x4AF4B165,0x5D8FA526,0x640299E3,0x73798DA0,
|
| 1068 |
+
0x82F182A3,0x958A96E0,0xAC07AA25,0xBB7CBE66,0xDF1DD3AF,0xC866C7EC,0xF1EBFB29,0xE690EF6A,
|
| 1069 |
+
0x392920BB,0x2E5234F8,0x17DF083D,0x00A41C7E,0x64C571B7,0x73BE65F4,0x4A335931,0x5D484D72,
|
| 1070 |
+
0x2E31C0D2,0x394AD491,0x00C7E854,0x17BCFC17,0x73DD91DE,0x64A6859D,0x5D2BB958,0x4A50AD1B,
|
| 1071 |
+
0x95E962CA,0x82927689,0xBB1F4A4C,0xAC645E0F,0xC80533C6,0xDF7E2785,0xE6F31B40,0xF1880F03,
|
| 1072 |
+
0xDE920307,0xC9E91744,0xF0642B81,0xE71F3FC2,0x837E520B,0x94054648,0xAD887A8D,0xBAF36ECE,
|
| 1073 |
+
0x654AA11F,0x7231B55C,0x4BBC8999,0x5CC79DDA,0x38A6F013,0x2FDDE450,0x1650D895,0x012BCCD6,
|
| 1074 |
+
0x72524176,0x65295535,0x5CA469F0,0x4BDF7DB3,0x2FBE107A,0x38C50439,0x014838FC,0x16332CBF,
|
| 1075 |
+
0xC98AE36E,0xDEF1F72D,0xE77CCBE8,0xF007DFAB,0x9466B262,0x831DA621,0xBA909AE4,0xADEB8EA7,
|
| 1076 |
+
0x5C6381A4,0x4B1895E7,0x7295A922,0x65EEBD61,0x018FD0A8,0x16F4C4EB,0x2F79F82E,0x3802EC6D,
|
| 1077 |
+
0xE7BB23BC,0xF0C037FF,0xC94D0B3A,0xDE361F79,0xBA5772B0,0xAD2C66F3,0x94A15A36,0x83DA4E75,
|
| 1078 |
+
0xF0A3C3D5,0xE7D8D796,0xDE55EB53,0xC92EFF10,0xAD4F92D9,0xBA34869A,0x83B9BA5F,0x94C2AE1C,
|
| 1079 |
+
0x4B7B61CD,0x5C00758E,0x658D494B,0x72F65D08,0x169730C1,0x01EC2482,0x38611847,0x2F1A0C04,
|
| 1080 |
+
0x6655004F,0x712E140C,0x48A328C9,0x5FD83C8A,0x3BB95143,0x2CC24500,0x154F79C5,0x02346D86,
|
| 1081 |
+
0xDD8DA257,0xCAF6B614,0xF37B8AD1,0xE4009E92,0x8061F35B,0x971AE718,0xAE97DBDD,0xB9ECCF9E,
|
| 1082 |
+
0xCA95423E,0xDDEE567D,0xE4636AB8,0xF3187EFB,0x97791332,0x80020771,0xB98F3BB4,0xAEF42FF7,
|
| 1083 |
+
0x714DE026,0x6636F465,0x5FBBC8A0,0x48C0DCE3,0x2CA1B12A,0x3BDAA569,0x025799AC,0x152C8DEF,
|
| 1084 |
+
0xE4A482EC,0xF3DF96AF,0xCA52AA6A,0xDD29BE29,0xB948D3E0,0xAE33C7A3,0x97BEFB66,0x80C5EF25,
|
| 1085 |
+
0x5F7C20F4,0x480734B7,0x718A0872,0x66F11C31,0x029071F8,0x15EB65BB,0x2C66597E,0x3B1D4D3D,
|
| 1086 |
+
0x4864C09D,0x5F1FD4DE,0x6692E81B,0x71E9FC58,0x15889191,0x02F385D2,0x3B7EB917,0x2C05AD54,
|
| 1087 |
+
0xF3BC6285,0xE4C776C6,0xDD4A4A03,0xCA315E40,0xAE503389,0xB92B27CA,0x80A61B0F,0x97DD0F4C,
|
| 1088 |
+
0xB8C70348,0xAFBC170B,0x96312BCE,0x814A3F8D,0xE52B5244,0xF2504607,0xCBDD7AC2,0xDCA66E81,
|
| 1089 |
+
0x031FA150,0x1464B513,0x2DE989D6,0x3A929D95,0x5EF3F05C,0x4988E41F,0x7005D8DA,0x677ECC99,
|
| 1090 |
+
0x14074139,0x037C557A,0x3AF169BF,0x2D8A7DFC,0x49EB1035,0x5E900476,0x671D38B3,0x70662CF0,
|
| 1091 |
+
0xAFDFE321,0xB8A4F762,0x8129CBA7,0x9652DFE4,0xF233B22D,0xE548A66E,0xDCC59AAB,0xCBBE8EE8,
|
| 1092 |
+
0x3A3681EB,0x2D4D95A8,0x14C0A96D,0x03BBBD2E,0x67DAD0E7,0x70A1C4A4,0x492CF861,0x5E57EC22,
|
| 1093 |
+
0x81EE23F3,0x969537B0,0xAF180B75,0xB8631F36,0xDC0272FF,0xCB7966BC,0xF2F45A79,0xE58F4E3A,
|
| 1094 |
+
0x96F6C39A,0x818DD7D9,0xB800EB1C,0xAF7BFF5F,0xCB1A9296,0xDC6186D5,0xE5ECBA10,0xF297AE53,
|
| 1095 |
+
0x2D2E6182,0x3A5575C1,0x03D84904,0x14A35D47,0x70C2308E,0x67B924CD,0x5E341808,0x494F0C4B,
|
| 1096 |
+
},
|
| 1097 |
+
|
| 1098 |
+
{
|
| 1099 |
+
0x00000000,0xEFC26B3E,0x04F5D03D,0xEB37BB03,0x09EBA07A,0xE629CB44,0x0D1E7047,0xE2DC1B79,
|
| 1100 |
+
0x13D740F4,0xFC152BCA,0x172290C9,0xF8E0FBF7,0x1A3CE08E,0xF5FE8BB0,0x1EC930B3,0xF10B5B8D,
|
| 1101 |
+
0x27AE81E8,0xC86CEAD6,0x235B51D5,0xCC993AEB,0x2E452192,0xC1874AAC,0x2AB0F1AF,0xC5729A91,
|
| 1102 |
+
0x3479C11C,0xDBBBAA22,0x308C1121,0xDF4E7A1F,0x3D926166,0xD2500A58,0x3967B15B,0xD6A5DA65,
|
| 1103 |
+
0x4F5D03D0,0xA09F68EE,0x4BA8D3ED,0xA46AB8D3,0x46B6A3AA,0xA974C894,0x42437397,0xAD8118A9,
|
| 1104 |
+
0x5C8A4324,0xB348281A,0x587F9319,0xB7BDF827,0x5561E35E,0xBAA38860,0x51943363,0xBE56585D,
|
| 1105 |
+
0x68F38238,0x8731E906,0x6C065205,0x83C4393B,0x61182242,0x8EDA497C,0x65EDF27F,0x8A2F9941,
|
| 1106 |
+
0x7B24C2CC,0x94E6A9F2,0x7FD112F1,0x901379CF,0x72CF62B6,0x9D0D0988,0x763AB28B,0x99F8D9B5,
|
| 1107 |
+
0x9EBA07A0,0x71786C9E,0x9A4FD79D,0x758DBCA3,0x9751A7DA,0x7893CCE4,0x93A477E7,0x7C661CD9,
|
| 1108 |
+
0x8D6D4754,0x62AF2C6A,0x89989769,0x665AFC57,0x8486E72E,0x6B448C10,0x80733713,0x6FB15C2D,
|
| 1109 |
+
0xB9148648,0x56D6ED76,0xBDE15675,0x52233D4B,0xB0FF2632,0x5F3D4D0C,0xB40AF60F,0x5BC89D31,
|
| 1110 |
+
0xAAC3C6BC,0x4501AD82,0xAE361681,0x41F47DBF,0xA32866C6,0x4CEA0DF8,0xA7DDB6FB,0x481FDDC5,
|
| 1111 |
+
0xD1E70470,0x3E256F4E,0xD512D44D,0x3AD0BF73,0xD80CA40A,0x37CECF34,0xDCF97437,0x333B1F09,
|
| 1112 |
+
0xC2304484,0x2DF22FBA,0xC6C594B9,0x2907FF87,0xCBDBE4FE,0x24198FC0,0xCF2E34C3,0x20EC5FFD,
|
| 1113 |
+
0xF6498598,0x198BEEA6,0xF2BC55A5,0x1D7E3E9B,0xFFA225E2,0x10604EDC,0xFB57F5DF,0x14959EE1,
|
| 1114 |
+
0xE59EC56C,0x0A5CAE52,0xE16B1551,0x0EA97E6F,0xEC756516,0x03B70E28,0xE880B52B,0x0742DE15,
|
| 1115 |
+
0xE6050901,0x09C7623F,0xE2F0D93C,0x0D32B202,0xEFEEA97B,0x002CC245,0xEB1B7946,0x04D91278,
|
| 1116 |
+
0xF5D249F5,0x1A1022CB,0xF12799C8,0x1EE5F2F6,0xFC39E98F,0x13FB82B1,0xF8CC39B2,0x170E528C,
|
| 1117 |
+
0xC1AB88E9,0x2E69E3D7,0xC55E58D4,0x2A9C33EA,0xC8402893,0x278243AD,0xCCB5F8AE,0x23779390,
|
| 1118 |
+
0xD27CC81D,0x3DBEA323,0xD6891820,0x394B731E,0xDB976867,0x34550359,0xDF62B85A,0x30A0D364,
|
| 1119 |
+
0xA9580AD1,0x469A61EF,0xADADDAEC,0x426FB1D2,0xA0B3AAAB,0x4F71C195,0xA4467A96,0x4B8411A8,
|
| 1120 |
+
0xBA8F4A25,0x554D211B,0xBE7A9A18,0x51B8F126,0xB364EA5F,0x5CA68161,0xB7913A62,0x5853515C,
|
| 1121 |
+
0x8EF68B39,0x6134E007,0x8A035B04,0x65C1303A,0x871D2B43,0x68DF407D,0x83E8FB7E,0x6C2A9040,
|
| 1122 |
+
0x9D21CBCD,0x72E3A0F3,0x99D41BF0,0x761670CE,0x94CA6BB7,0x7B080089,0x903FBB8A,0x7FFDD0B4,
|
| 1123 |
+
0x78BF0EA1,0x977D659F,0x7C4ADE9C,0x9388B5A2,0x7154AEDB,0x9E96C5E5,0x75A17EE6,0x9A6315D8,
|
| 1124 |
+
0x6B684E55,0x84AA256B,0x6F9D9E68,0x805FF556,0x6283EE2F,0x8D418511,0x66763E12,0x89B4552C,
|
| 1125 |
+
0x5F118F49,0xB0D3E477,0x5BE45F74,0xB426344A,0x56FA2F33,0xB938440D,0x520FFF0E,0xBDCD9430,
|
| 1126 |
+
0x4CC6CFBD,0xA304A483,0x48331F80,0xA7F174BE,0x452D6FC7,0xAAEF04F9,0x41D8BFFA,0xAE1AD4C4,
|
| 1127 |
+
0x37E20D71,0xD820664F,0x3317DD4C,0xDCD5B672,0x3E09AD0B,0xD1CBC635,0x3AFC7D36,0xD53E1608,
|
| 1128 |
+
0x24354D85,0xCBF726BB,0x20C09DB8,0xCF02F686,0x2DDEEDFF,0xC21C86C1,0x292B3DC2,0xC6E956FC,
|
| 1129 |
+
0x104C8C99,0xFF8EE7A7,0x14B95CA4,0xFB7B379A,0x19A72CE3,0xF66547DD,0x1D52FCDE,0xF29097E0,
|
| 1130 |
+
0x039BCC6D,0xEC59A753,0x076E1C50,0xE8AC776E,0x0A706C17,0xE5B20729,0x0E85BC2A,0xE147D714,
|
| 1131 |
+
},
|
| 1132 |
+
|
| 1133 |
+
{
|
| 1134 |
+
0x00000000,0xC18EDFC0,0x586CB9C1,0x99E26601,0xB0D97382,0x7157AC42,0xE8B5CA43,0x293B1583,
|
| 1135 |
+
0xBAC3E145,0x7B4D3E85,0xE2AF5884,0x23218744,0x0A1A92C7,0xCB944D07,0x52762B06,0x93F8F4C6,
|
| 1136 |
+
0xAEF6C4CB,0x6F781B0B,0xF69A7D0A,0x3714A2CA,0x1E2FB749,0xDFA16889,0x46430E88,0x87CDD148,
|
| 1137 |
+
0x1435258E,0xD5BBFA4E,0x4C599C4F,0x8DD7438F,0xA4EC560C,0x656289CC,0xFC80EFCD,0x3D0E300D,
|
| 1138 |
+
0x869C8FD7,0x47125017,0xDEF03616,0x1F7EE9D6,0x3645FC55,0xF7CB2395,0x6E294594,0xAFA79A54,
|
| 1139 |
+
0x3C5F6E92,0xFDD1B152,0x6433D753,0xA5BD0893,0x8C861D10,0x4D08C2D0,0xD4EAA4D1,0x15647B11,
|
| 1140 |
+
0x286A4B1C,0xE9E494DC,0x7006F2DD,0xB1882D1D,0x98B3389E,0x593DE75E,0xC0DF815F,0x01515E9F,
|
| 1141 |
+
0x92A9AA59,0x53277599,0xCAC51398,0x0B4BCC58,0x2270D9DB,0xE3FE061B,0x7A1C601A,0xBB92BFDA,
|
| 1142 |
+
0xD64819EF,0x17C6C62F,0x8E24A02E,0x4FAA7FEE,0x66916A6D,0xA71FB5AD,0x3EFDD3AC,0xFF730C6C,
|
| 1143 |
+
0x6C8BF8AA,0xAD05276A,0x34E7416B,0xF5699EAB,0xDC528B28,0x1DDC54E8,0x843E32E9,0x45B0ED29,
|
| 1144 |
+
0x78BEDD24,0xB93002E4,0x20D264E5,0xE15CBB25,0xC867AEA6,0x09E97166,0x900B1767,0x5185C8A7,
|
| 1145 |
+
0xC27D3C61,0x03F3E3A1,0x9A1185A0,0x5B9F5A60,0x72A44FE3,0xB32A9023,0x2AC8F622,0xEB4629E2,
|
| 1146 |
+
0x50D49638,0x915A49F8,0x08B82FF9,0xC936F039,0xE00DE5BA,0x21833A7A,0xB8615C7B,0x79EF83BB,
|
| 1147 |
+
0xEA17777D,0x2B99A8BD,0xB27BCEBC,0x73F5117C,0x5ACE04FF,0x9B40DB3F,0x02A2BD3E,0xC32C62FE,
|
| 1148 |
+
0xFE2252F3,0x3FAC8D33,0xA64EEB32,0x67C034F2,0x4EFB2171,0x8F75FEB1,0x169798B0,0xD7194770,
|
| 1149 |
+
0x44E1B3B6,0x856F6C76,0x1C8D0A77,0xDD03D5B7,0xF438C034,0x35B61FF4,0xAC5479F5,0x6DDAA635,
|
| 1150 |
+
0x77E1359F,0xB66FEA5F,0x2F8D8C5E,0xEE03539E,0xC738461D,0x06B699DD,0x9F54FFDC,0x5EDA201C,
|
| 1151 |
+
0xCD22D4DA,0x0CAC0B1A,0x954E6D1B,0x54C0B2DB,0x7DFBA758,0xBC757898,0x25971E99,0xE419C159,
|
| 1152 |
+
0xD917F154,0x18992E94,0x817B4895,0x40F59755,0x69CE82D6,0xA8405D16,0x31A23B17,0xF02CE4D7,
|
| 1153 |
+
0x63D41011,0xA25ACFD1,0x3BB8A9D0,0xFA367610,0xD30D6393,0x1283BC53,0x8B61DA52,0x4AEF0592,
|
| 1154 |
+
0xF17DBA48,0x30F36588,0xA9110389,0x689FDC49,0x41A4C9CA,0x802A160A,0x19C8700B,0xD846AFCB,
|
| 1155 |
+
0x4BBE5B0D,0x8A3084CD,0x13D2E2CC,0xD25C3D0C,0xFB67288F,0x3AE9F74F,0xA30B914E,0x62854E8E,
|
| 1156 |
+
0x5F8B7E83,0x9E05A143,0x07E7C742,0xC6691882,0xEF520D01,0x2EDCD2C1,0xB73EB4C0,0x76B06B00,
|
| 1157 |
+
0xE5489FC6,0x24C64006,0xBD242607,0x7CAAF9C7,0x5591EC44,0x941F3384,0x0DFD5585,0xCC738A45,
|
| 1158 |
+
0xA1A92C70,0x6027F3B0,0xF9C595B1,0x384B4A71,0x11705FF2,0xD0FE8032,0x491CE633,0x889239F3,
|
| 1159 |
+
0x1B6ACD35,0xDAE412F5,0x430674F4,0x8288AB34,0xABB3BEB7,0x6A3D6177,0xF3DF0776,0x3251D8B6,
|
| 1160 |
+
0x0F5FE8BB,0xCED1377B,0x5733517A,0x96BD8EBA,0xBF869B39,0x7E0844F9,0xE7EA22F8,0x2664FD38,
|
| 1161 |
+
0xB59C09FE,0x7412D63E,0xEDF0B03F,0x2C7E6FFF,0x05457A7C,0xC4CBA5BC,0x5D29C3BD,0x9CA71C7D,
|
| 1162 |
+
0x2735A3A7,0xE6BB7C67,0x7F591A66,0xBED7C5A6,0x97ECD025,0x56620FE5,0xCF8069E4,0x0E0EB624,
|
| 1163 |
+
0x9DF642E2,0x5C789D22,0xC59AFB23,0x041424E3,0x2D2F3160,0xECA1EEA0,0x754388A1,0xB4CD5761,
|
| 1164 |
+
0x89C3676C,0x484DB8AC,0xD1AFDEAD,0x1021016D,0x391A14EE,0xF894CB2E,0x6176AD2F,0xA0F872EF,
|
| 1165 |
+
0x33008629,0xF28E59E9,0x6B6C3FE8,0xAAE2E028,0x83D9F5AB,0x42572A6B,0xDBB54C6A,0x1A3B93AA,
|
| 1166 |
+
},
|
| 1167 |
+
|
| 1168 |
+
{
|
| 1169 |
+
0x00000000,0x9BA54C6F,0xEC3B9E9F,0x779ED2F0,0x03063B7F,0x98A37710,0xEF3DA5E0,0x7498E98F,
|
| 1170 |
+
0x060C76FE,0x9DA93A91,0xEA37E861,0x7192A40E,0x050A4D81,0x9EAF01EE,0xE931D31E,0x72949F71,
|
| 1171 |
+
0x0C18EDFC,0x97BDA193,0xE0237363,0x7B863F0C,0x0F1ED683,0x94BB9AEC,0xE325481C,0x78800473,
|
| 1172 |
+
0x0A149B02,0x91B1D76D,0xE62F059D,0x7D8A49F2,0x0912A07D,0x92B7EC12,0xE5293EE2,0x7E8C728D,
|
| 1173 |
+
0x1831DBF8,0x83949797,0xF40A4567,0x6FAF0908,0x1B37E087,0x8092ACE8,0xF70C7E18,0x6CA93277,
|
| 1174 |
+
0x1E3DAD06,0x8598E169,0xF2063399,0x69A37FF6,0x1D3B9679,0x869EDA16,0xF10008E6,0x6AA54489,
|
| 1175 |
+
0x14293604,0x8F8C7A6B,0xF812A89B,0x63B7E4F4,0x172F0D7B,0x8C8A4114,0xFB1493E4,0x60B1DF8B,
|
| 1176 |
+
0x122540FA,0x89800C95,0xFE1EDE65,0x65BB920A,0x11237B85,0x8A8637EA,0xFD18E51A,0x66BDA975,
|
| 1177 |
+
0x3063B7F0,0xABC6FB9F,0xDC58296F,0x47FD6500,0x33658C8F,0xA8C0C0E0,0xDF5E1210,0x44FB5E7F,
|
| 1178 |
+
0x366FC10E,0xADCA8D61,0xDA545F91,0x41F113FE,0x3569FA71,0xAECCB61E,0xD95264EE,0x42F72881,
|
| 1179 |
+
0x3C7B5A0C,0xA7DE1663,0xD040C493,0x4BE588FC,0x3F7D6173,0xA4D82D1C,0xD346FFEC,0x48E3B383,
|
| 1180 |
+
0x3A772CF2,0xA1D2609D,0xD64CB26D,0x4DE9FE02,0x3971178D,0xA2D45BE2,0xD54A8912,0x4EEFC57D,
|
| 1181 |
+
0x28526C08,0xB3F72067,0xC469F297,0x5FCCBEF8,0x2B545777,0xB0F11B18,0xC76FC9E8,0x5CCA8587,
|
| 1182 |
+
0x2E5E1AF6,0xB5FB5699,0xC2658469,0x59C0C806,0x2D582189,0xB6FD6DE6,0xC163BF16,0x5AC6F379,
|
| 1183 |
+
0x244A81F4,0xBFEFCD9B,0xC8711F6B,0x53D45304,0x274CBA8B,0xBCE9F6E4,0xCB772414,0x50D2687B,
|
| 1184 |
+
0x2246F70A,0xB9E3BB65,0xCE7D6995,0x55D825FA,0x2140CC75,0xBAE5801A,0xCD7B52EA,0x56DE1E85,
|
| 1185 |
+
0x60C76FE0,0xFB62238F,0x8CFCF17F,0x1759BD10,0x63C1549F,0xF86418F0,0x8FFACA00,0x145F866F,
|
| 1186 |
+
0x66CB191E,0xFD6E5571,0x8AF08781,0x1155CBEE,0x65CD2261,0xFE686E0E,0x89F6BCFE,0x1253F091,
|
| 1187 |
+
0x6CDF821C,0xF77ACE73,0x80E41C83,0x1B4150EC,0x6FD9B963,0xF47CF50C,0x83E227FC,0x18476B93,
|
| 1188 |
+
0x6AD3F4E2,0xF176B88D,0x86E86A7D,0x1D4D2612,0x69D5CF9D,0xF27083F2,0x85EE5102,0x1E4B1D6D,
|
| 1189 |
+
0x78F6B418,0xE353F877,0x94CD2A87,0x0F6866E8,0x7BF08F67,0xE055C308,0x97CB11F8,0x0C6E5D97,
|
| 1190 |
+
0x7EFAC2E6,0xE55F8E89,0x92C15C79,0x09641016,0x7DFCF999,0xE659B5F6,0x91C76706,0x0A622B69,
|
| 1191 |
+
0x74EE59E4,0xEF4B158B,0x98D5C77B,0x03708B14,0x77E8629B,0xEC4D2EF4,0x9BD3FC04,0x0076B06B,
|
| 1192 |
+
0x72E22F1A,0xE9476375,0x9ED9B185,0x057CFDEA,0x71E41465,0xEA41580A,0x9DDF8AFA,0x067AC695,
|
| 1193 |
+
0x50A4D810,0xCB01947F,0xBC9F468F,0x273A0AE0,0x53A2E36F,0xC807AF00,0xBF997DF0,0x243C319F,
|
| 1194 |
+
0x56A8AEEE,0xCD0DE281,0xBA933071,0x21367C1E,0x55AE9591,0xCE0BD9FE,0xB9950B0E,0x22304761,
|
| 1195 |
+
0x5CBC35EC,0xC7197983,0xB087AB73,0x2B22E71C,0x5FBA0E93,0xC41F42FC,0xB381900C,0x2824DC63,
|
| 1196 |
+
0x5AB04312,0xC1150F7D,0xB68BDD8D,0x2D2E91E2,0x59B6786D,0xC2133402,0xB58DE6F2,0x2E28AA9D,
|
| 1197 |
+
0x489503E8,0xD3304F87,0xA4AE9D77,0x3F0BD118,0x4B933897,0xD03674F8,0xA7A8A608,0x3C0DEA67,
|
| 1198 |
+
0x4E997516,0xD53C3979,0xA2A2EB89,0x3907A7E6,0x4D9F4E69,0xD63A0206,0xA1A4D0F6,0x3A019C99,
|
| 1199 |
+
0x448DEE14,0xDF28A27B,0xA8B6708B,0x33133CE4,0x478BD56B,0xDC2E9904,0xABB04BF4,0x3015079B,
|
| 1200 |
+
0x428198EA,0xD924D485,0xAEBA0675,0x351F4A1A,0x4187A395,0xDA22EFFA,0xADBC3D0A,0x36197165,
|
| 1201 |
+
},
|
| 1202 |
+
|
| 1203 |
+
{
|
| 1204 |
+
0x00000000,0xDD96D985,0x605CB54B,0xBDCA6CCE,0xC0B96A96,0x1D2FB313,0xA0E5DFDD,0x7D730658,
|
| 1205 |
+
0x5A03D36D,0x87950AE8,0x3A5F6626,0xE7C9BFA3,0x9ABAB9FB,0x472C607E,0xFAE60CB0,0x2770D535,
|
| 1206 |
+
0xB407A6DA,0x69917F5F,0xD45B1391,0x09CDCA14,0x74BECC4C,0xA92815C9,0x14E27907,0xC974A082,
|
| 1207 |
+
0xEE0475B7,0x3392AC32,0x8E58C0FC,0x53CE1979,0x2EBD1F21,0xF32BC6A4,0x4EE1AA6A,0x937773EF,
|
| 1208 |
+
0xB37E4BF5,0x6EE89270,0xD322FEBE,0x0EB4273B,0x73C72163,0xAE51F8E6,0x139B9428,0xCE0D4DAD,
|
| 1209 |
+
0xE97D9898,0x34EB411D,0x89212DD3,0x54B7F456,0x29C4F20E,0xF4522B8B,0x49984745,0x940E9EC0,
|
| 1210 |
+
0x0779ED2F,0xDAEF34AA,0x67255864,0xBAB381E1,0xC7C087B9,0x1A565E3C,0xA79C32F2,0x7A0AEB77,
|
| 1211 |
+
0x5D7A3E42,0x80ECE7C7,0x3D268B09,0xE0B0528C,0x9DC354D4,0x40558D51,0xFD9FE19F,0x2009381A,
|
| 1212 |
+
0xBD8D91AB,0x601B482E,0xDDD124E0,0x0047FD65,0x7D34FB3D,0xA0A222B8,0x1D684E76,0xC0FE97F3,
|
| 1213 |
+
0xE78E42C6,0x3A189B43,0x87D2F78D,0x5A442E08,0x27372850,0xFAA1F1D5,0x476B9D1B,0x9AFD449E,
|
| 1214 |
+
0x098A3771,0xD41CEEF4,0x69D6823A,0xB4405BBF,0xC9335DE7,0x14A58462,0xA96FE8AC,0x74F93129,
|
| 1215 |
+
0x5389E41C,0x8E1F3D99,0x33D55157,0xEE4388D2,0x93308E8A,0x4EA6570F,0xF36C3BC1,0x2EFAE244,
|
| 1216 |
+
0x0EF3DA5E,0xD36503DB,0x6EAF6F15,0xB339B690,0xCE4AB0C8,0x13DC694D,0xAE160583,0x7380DC06,
|
| 1217 |
+
0x54F00933,0x8966D0B6,0x34ACBC78,0xE93A65FD,0x944963A5,0x49DFBA20,0xF415D6EE,0x29830F6B,
|
| 1218 |
+
0xBAF47C84,0x6762A501,0xDAA8C9CF,0x073E104A,0x7A4D1612,0xA7DBCF97,0x1A11A359,0xC7877ADC,
|
| 1219 |
+
0xE0F7AFE9,0x3D61766C,0x80AB1AA2,0x5D3DC327,0x204EC57F,0xFDD81CFA,0x40127034,0x9D84A9B1,
|
| 1220 |
+
0xA06A2517,0x7DFCFC92,0xC036905C,0x1DA049D9,0x60D34F81,0xBD459604,0x008FFACA,0xDD19234F,
|
| 1221 |
+
0xFA69F67A,0x27FF2FFF,0x9A354331,0x47A39AB4,0x3AD09CEC,0xE7464569,0x5A8C29A7,0x871AF022,
|
| 1222 |
+
0x146D83CD,0xC9FB5A48,0x74313686,0xA9A7EF03,0xD4D4E95B,0x094230DE,0xB4885C10,0x691E8595,
|
| 1223 |
+
0x4E6E50A0,0x93F88925,0x2E32E5EB,0xF3A43C6E,0x8ED73A36,0x5341E3B3,0xEE8B8F7D,0x331D56F8,
|
| 1224 |
+
0x13146EE2,0xCE82B767,0x7348DBA9,0xAEDE022C,0xD3AD0474,0x0E3BDDF1,0xB3F1B13F,0x6E6768BA,
|
| 1225 |
+
0x4917BD8F,0x9481640A,0x294B08C4,0xF4DDD141,0x89AED719,0x54380E9C,0xE9F26252,0x3464BBD7,
|
| 1226 |
+
0xA713C838,0x7A8511BD,0xC74F7D73,0x1AD9A4F6,0x67AAA2AE,0xBA3C7B2B,0x07F617E5,0xDA60CE60,
|
| 1227 |
+
0xFD101B55,0x2086C2D0,0x9D4CAE1E,0x40DA779B,0x3DA971C3,0xE03FA846,0x5DF5C488,0x80631D0D,
|
| 1228 |
+
0x1DE7B4BC,0xC0716D39,0x7DBB01F7,0xA02DD872,0xDD5EDE2A,0x00C807AF,0xBD026B61,0x6094B2E4,
|
| 1229 |
+
0x47E467D1,0x9A72BE54,0x27B8D29A,0xFA2E0B1F,0x875D0D47,0x5ACBD4C2,0xE701B80C,0x3A976189,
|
| 1230 |
+
0xA9E01266,0x7476CBE3,0xC9BCA72D,0x142A7EA8,0x695978F0,0xB4CFA175,0x0905CDBB,0xD493143E,
|
| 1231 |
+
0xF3E3C10B,0x2E75188E,0x93BF7440,0x4E29ADC5,0x335AAB9D,0xEECC7218,0x53061ED6,0x8E90C753,
|
| 1232 |
+
0xAE99FF49,0x730F26CC,0xCEC54A02,0x13539387,0x6E2095DF,0xB3B64C5A,0x0E7C2094,0xD3EAF911,
|
| 1233 |
+
0xF49A2C24,0x290CF5A1,0x94C6996F,0x495040EA,0x342346B2,0xE9B59F37,0x547FF3F9,0x89E92A7C,
|
| 1234 |
+
0x1A9E5993,0xC7088016,0x7AC2ECD8,0xA754355D,0xDA273305,0x07B1EA80,0xBA7B864E,0x67ED5FCB,
|
| 1235 |
+
0x409D8AFE,0x9D0B537B,0x20C13FB5,0xFD57E630,0x8024E068,0x5DB239ED,0xE0785523,0x3DEE8CA6,
|
| 1236 |
+
},
|
| 1237 |
+
|
| 1238 |
+
{
|
| 1239 |
+
0x00000000,0x9D0FE176,0xE16EC4AD,0x7C6125DB,0x19AC8F1B,0x84A36E6D,0xF8C24BB6,0x65CDAAC0,
|
| 1240 |
+
0x33591E36,0xAE56FF40,0xD237DA9B,0x4F383BED,0x2AF5912D,0xB7FA705B,0xCB9B5580,0x5694B4F6,
|
| 1241 |
+
0x66B23C6C,0xFBBDDD1A,0x87DCF8C1,0x1AD319B7,0x7F1EB377,0xE2115201,0x9E7077DA,0x037F96AC,
|
| 1242 |
+
0x55EB225A,0xC8E4C32C,0xB485E6F7,0x298A0781,0x4C47AD41,0xD1484C37,0xAD2969EC,0x3026889A,
|
| 1243 |
+
0xCD6478D8,0x506B99AE,0x2C0ABC75,0xB1055D03,0xD4C8F7C3,0x49C716B5,0x35A6336E,0xA8A9D218,
|
| 1244 |
+
0xFE3D66EE,0x63328798,0x1F53A243,0x825C4335,0xE791E9F5,0x7A9E0883,0x06FF2D58,0x9BF0CC2E,
|
| 1245 |
+
0xABD644B4,0x36D9A5C2,0x4AB88019,0xD7B7616F,0xB27ACBAF,0x2F752AD9,0x53140F02,0xCE1BEE74,
|
| 1246 |
+
0x988F5A82,0x0580BBF4,0x79E19E2F,0xE4EE7F59,0x8123D599,0x1C2C34EF,0x604D1134,0xFD42F042,
|
| 1247 |
+
0x41B9F7F1,0xDCB61687,0xA0D7335C,0x3DD8D22A,0x581578EA,0xC51A999C,0xB97BBC47,0x24745D31,
|
| 1248 |
+
0x72E0E9C7,0xEFEF08B1,0x938E2D6A,0x0E81CC1C,0x6B4C66DC,0xF64387AA,0x8A22A271,0x172D4307,
|
| 1249 |
+
0x270BCB9D,0xBA042AEB,0xC6650F30,0x5B6AEE46,0x3EA74486,0xA3A8A5F0,0xDFC9802B,0x42C6615D,
|
| 1250 |
+
0x1452D5AB,0x895D34DD,0xF53C1106,0x6833F070,0x0DFE5AB0,0x90F1BBC6,0xEC909E1D,0x719F7F6B,
|
| 1251 |
+
0x8CDD8F29,0x11D26E5F,0x6DB34B84,0xF0BCAAF2,0x95710032,0x087EE144,0x741FC49F,0xE91025E9,
|
| 1252 |
+
0xBF84911F,0x228B7069,0x5EEA55B2,0xC3E5B4C4,0xA6281E04,0x3B27FF72,0x4746DAA9,0xDA493BDF,
|
| 1253 |
+
0xEA6FB345,0x77605233,0x0B0177E8,0x960E969E,0xF3C33C5E,0x6ECCDD28,0x12ADF8F3,0x8FA21985,
|
| 1254 |
+
0xD936AD73,0x44394C05,0x385869DE,0xA55788A8,0xC09A2268,0x5D95C31E,0x21F4E6C5,0xBCFB07B3,
|
| 1255 |
+
0x8373EFE2,0x1E7C0E94,0x621D2B4F,0xFF12CA39,0x9ADF60F9,0x07D0818F,0x7BB1A454,0xE6BE4522,
|
| 1256 |
+
0xB02AF1D4,0x2D2510A2,0x51443579,0xCC4BD40F,0xA9867ECF,0x34899FB9,0x48E8BA62,0xD5E75B14,
|
| 1257 |
+
0xE5C1D38E,0x78CE32F8,0x04AF1723,0x99A0F655,0xFC6D5C95,0x6162BDE3,0x1D039838,0x800C794E,
|
| 1258 |
+
0xD698CDB8,0x4B972CCE,0x37F60915,0xAAF9E863,0xCF3442A3,0x523BA3D5,0x2E5A860E,0xB3556778,
|
| 1259 |
+
0x4E17973A,0xD318764C,0xAF795397,0x3276B2E1,0x57BB1821,0xCAB4F957,0xB6D5DC8C,0x2BDA3DFA,
|
| 1260 |
+
0x7D4E890C,0xE041687A,0x9C204DA1,0x012FACD7,0x64E20617,0xF9EDE761,0x858CC2BA,0x188323CC,
|
| 1261 |
+
0x28A5AB56,0xB5AA4A20,0xC9CB6FFB,0x54C48E8D,0x3109244D,0xAC06C53B,0xD067E0E0,0x4D680196,
|
| 1262 |
+
0x1BFCB560,0x86F35416,0xFA9271CD,0x679D90BB,0x02503A7B,0x9F5FDB0D,0xE33EFED6,0x7E311FA0,
|
| 1263 |
+
0xC2CA1813,0x5FC5F965,0x23A4DCBE,0xBEAB3DC8,0xDB669708,0x4669767E,0x3A0853A5,0xA707B2D3,
|
| 1264 |
+
0xF1930625,0x6C9CE753,0x10FDC288,0x8DF223FE,0xE83F893E,0x75306848,0x09514D93,0x945EACE5,
|
| 1265 |
+
0xA478247F,0x3977C509,0x4516E0D2,0xD81901A4,0xBDD4AB64,0x20DB4A12,0x5CBA6FC9,0xC1B58EBF,
|
| 1266 |
+
0x97213A49,0x0A2EDB3F,0x764FFEE4,0xEB401F92,0x8E8DB552,0x13825424,0x6FE371FF,0xF2EC9089,
|
| 1267 |
+
0x0FAE60CB,0x92A181BD,0xEEC0A466,0x73CF4510,0x1602EFD0,0x8B0D0EA6,0xF76C2B7D,0x6A63CA0B,
|
| 1268 |
+
0x3CF77EFD,0xA1F89F8B,0xDD99BA50,0x40965B26,0x255BF1E6,0xB8541090,0xC435354B,0x593AD43D,
|
| 1269 |
+
0x691C5CA7,0xF413BDD1,0x8872980A,0x157D797C,0x70B0D3BC,0xEDBF32CA,0x91DE1711,0x0CD1F667,
|
| 1270 |
+
0x5A454291,0xC74AA3E7,0xBB2B863C,0x2624674A,0x43E9CD8A,0xDEE62CFC,0xA2870927,0x3F88E851,
|
| 1271 |
+
},
|
| 1272 |
+
|
| 1273 |
+
{
|
| 1274 |
+
0x00000000,0xB9FBDBE8,0xA886B191,0x117D6A79,0x8A7C6563,0x3387BE8B,0x22FAD4F2,0x9B010F1A,
|
| 1275 |
+
0xCF89CC87,0x7672176F,0x670F7D16,0xDEF4A6FE,0x45F5A9E4,0xFC0E720C,0xED731875,0x5488C39D,
|
| 1276 |
+
0x44629F4F,0xFD9944A7,0xECE42EDE,0x551FF536,0xCE1EFA2C,0x77E521C4,0x66984BBD,0xDF639055,
|
| 1277 |
+
0x8BEB53C8,0x32108820,0x236DE259,0x9A9639B1,0x019736AB,0xB86CED43,0xA911873A,0x10EA5CD2,
|
| 1278 |
+
0x88C53E9E,0x313EE576,0x20438F0F,0x99B854E7,0x02B95BFD,0xBB428015,0xAA3FEA6C,0x13C43184,
|
| 1279 |
+
0x474CF219,0xFEB729F1,0xEFCA4388,0x56319860,0xCD30977A,0x74CB4C92,0x65B626EB,0xDC4DFD03,
|
| 1280 |
+
0xCCA7A1D1,0x755C7A39,0x64211040,0xDDDACBA8,0x46DBC4B2,0xFF201F5A,0xEE5D7523,0x57A6AECB,
|
| 1281 |
+
0x032E6D56,0xBAD5B6BE,0xABA8DCC7,0x1253072F,0x89520835,0x30A9D3DD,0x21D4B9A4,0x982F624C,
|
| 1282 |
+
0xCAFB7B7D,0x7300A095,0x627DCAEC,0xDB861104,0x40871E1E,0xF97CC5F6,0xE801AF8F,0x51FA7467,
|
| 1283 |
+
0x0572B7FA,0xBC896C12,0xADF4066B,0x140FDD83,0x8F0ED299,0x36F50971,0x27886308,0x9E73B8E0,
|
| 1284 |
+
0x8E99E432,0x37623FDA,0x261F55A3,0x9FE48E4B,0x04E58151,0xBD1E5AB9,0xAC6330C0,0x1598EB28,
|
| 1285 |
+
0x411028B5,0xF8EBF35D,0xE9969924,0x506D42CC,0xCB6C4DD6,0x7297963E,0x63EAFC47,0xDA1127AF,
|
| 1286 |
+
0x423E45E3,0xFBC59E0B,0xEAB8F472,0x53432F9A,0xC8422080,0x71B9FB68,0x60C49111,0xD93F4AF9,
|
| 1287 |
+
0x8DB78964,0x344C528C,0x253138F5,0x9CCAE31D,0x07CBEC07,0xBE3037EF,0xAF4D5D96,0x16B6867E,
|
| 1288 |
+
0x065CDAAC,0xBFA70144,0xAEDA6B3D,0x1721B0D5,0x8C20BFCF,0x35DB6427,0x24A60E5E,0x9D5DD5B6,
|
| 1289 |
+
0xC9D5162B,0x702ECDC3,0x6153A7BA,0xD8A87C52,0x43A97348,0xFA52A8A0,0xEB2FC2D9,0x52D41931,
|
| 1290 |
+
0x4E87F0BB,0xF77C2B53,0xE601412A,0x5FFA9AC2,0xC4FB95D8,0x7D004E30,0x6C7D2449,0xD586FFA1,
|
| 1291 |
+
0x810E3C3C,0x38F5E7D4,0x29888DAD,0x90735645,0x0B72595F,0xB28982B7,0xA3F4E8CE,0x1A0F3326,
|
| 1292 |
+
0x0AE56FF4,0xB31EB41C,0xA263DE65,0x1B98058D,0x80990A97,0x3962D17F,0x281FBB06,0x91E460EE,
|
| 1293 |
+
0xC56CA373,0x7C97789B,0x6DEA12E2,0xD411C90A,0x4F10C610,0xF6EB1DF8,0xE7967781,0x5E6DAC69,
|
| 1294 |
+
0xC642CE25,0x7FB915CD,0x6EC47FB4,0xD73FA45C,0x4C3EAB46,0xF5C570AE,0xE4B81AD7,0x5D43C13F,
|
| 1295 |
+
0x09CB02A2,0xB030D94A,0xA14DB333,0x18B668DB,0x83B767C1,0x3A4CBC29,0x2B31D650,0x92CA0DB8,
|
| 1296 |
+
0x8220516A,0x3BDB8A82,0x2AA6E0FB,0x935D3B13,0x085C3409,0xB1A7EFE1,0xA0DA8598,0x19215E70,
|
| 1297 |
+
0x4DA99DED,0xF4524605,0xE52F2C7C,0x5CD4F794,0xC7D5F88E,0x7E2E2366,0x6F53491F,0xD6A892F7,
|
| 1298 |
+
0x847C8BC6,0x3D87502E,0x2CFA3A57,0x9501E1BF,0x0E00EEA5,0xB7FB354D,0xA6865F34,0x1F7D84DC,
|
| 1299 |
+
0x4BF54741,0xF20E9CA9,0xE373F6D0,0x5A882D38,0xC1892222,0x7872F9CA,0x690F93B3,0xD0F4485B,
|
| 1300 |
+
0xC01E1489,0x79E5CF61,0x6898A518,0xD1637EF0,0x4A6271EA,0xF399AA02,0xE2E4C07B,0x5B1F1B93,
|
| 1301 |
+
0x0F97D80E,0xB66C03E6,0xA711699F,0x1EEAB277,0x85EBBD6D,0x3C106685,0x2D6D0CFC,0x9496D714,
|
| 1302 |
+
0x0CB9B558,0xB5426EB0,0xA43F04C9,0x1DC4DF21,0x86C5D03B,0x3F3E0BD3,0x2E4361AA,0x97B8BA42,
|
| 1303 |
+
0xC33079DF,0x7ACBA237,0x6BB6C84E,0xD24D13A6,0x494C1CBC,0xF0B7C754,0xE1CAAD2D,0x583176C5,
|
| 1304 |
+
0x48DB2A17,0xF120F1FF,0xE05D9B86,0x59A6406E,0xC2A74F74,0x7B5C949C,0x6A21FEE5,0xD3DA250D,
|
| 1305 |
+
0x8752E690,0x3EA93D78,0x2FD45701,0x962F8CE9,0x0D2E83F3,0xB4D5581B,0xA5A83262,0x1C53E98A,
|
| 1306 |
+
},
|
| 1307 |
+
|
| 1308 |
+
{
|
| 1309 |
+
0x00000000,0xAE689191,0x87A02563,0x29C8B4F2,0xD4314C87,0x7A59DD16,0x539169E4,0xFDF9F875,
|
| 1310 |
+
0x73139F4F,0xDD7B0EDE,0xF4B3BA2C,0x5ADB2BBD,0xA722D3C8,0x094A4259,0x2082F6AB,0x8EEA673A,
|
| 1311 |
+
0xE6273E9E,0x484FAF0F,0x61871BFD,0xCFEF8A6C,0x32167219,0x9C7EE388,0xB5B6577A,0x1BDEC6EB,
|
| 1312 |
+
0x9534A1D1,0x3B5C3040,0x129484B2,0xBCFC1523,0x4105ED56,0xEF6D7CC7,0xC6A5C835,0x68CD59A4,
|
| 1313 |
+
0x173F7B7D,0xB957EAEC,0x909F5E1E,0x3EF7CF8F,0xC30E37FA,0x6D66A66B,0x44AE1299,0xEAC68308,
|
| 1314 |
+
0x642CE432,0xCA4475A3,0xE38CC151,0x4DE450C0,0xB01DA8B5,0x1E753924,0x37BD8DD6,0x99D51C47,
|
| 1315 |
+
0xF11845E3,0x5F70D472,0x76B86080,0xD8D0F111,0x25290964,0x8B4198F5,0xA2892C07,0x0CE1BD96,
|
| 1316 |
+
0x820BDAAC,0x2C634B3D,0x05ABFFCF,0xABC36E5E,0x563A962B,0xF85207BA,0xD19AB348,0x7FF222D9,
|
| 1317 |
+
0x2E7EF6FA,0x8016676B,0xA9DED399,0x07B64208,0xFA4FBA7D,0x54272BEC,0x7DEF9F1E,0xD3870E8F,
|
| 1318 |
+
0x5D6D69B5,0xF305F824,0xDACD4CD6,0x74A5DD47,0x895C2532,0x2734B4A3,0x0EFC0051,0xA09491C0,
|
| 1319 |
+
0xC859C864,0x663159F5,0x4FF9ED07,0xE1917C96,0x1C6884E3,0xB2001572,0x9BC8A180,0x35A03011,
|
| 1320 |
+
0xBB4A572B,0x1522C6BA,0x3CEA7248,0x9282E3D9,0x6F7B1BAC,0xC1138A3D,0xE8DB3ECF,0x46B3AF5E,
|
| 1321 |
+
0x39418D87,0x97291C16,0xBEE1A8E4,0x10893975,0xED70C100,0x43185091,0x6AD0E463,0xC4B875F2,
|
| 1322 |
+
0x4A5212C8,0xE43A8359,0xCDF237AB,0x639AA63A,0x9E635E4F,0x300BCFDE,0x19C37B2C,0xB7ABEABD,
|
| 1323 |
+
0xDF66B319,0x710E2288,0x58C6967A,0xF6AE07EB,0x0B57FF9E,0xA53F6E0F,0x8CF7DAFD,0x229F4B6C,
|
| 1324 |
+
0xAC752C56,0x021DBDC7,0x2BD50935,0x85BD98A4,0x784460D1,0xD62CF140,0xFFE445B2,0x518CD423,
|
| 1325 |
+
0x5CFDEDF4,0xF2957C65,0xDB5DC897,0x75355906,0x88CCA173,0x26A430E2,0x0F6C8410,0xA1041581,
|
| 1326 |
+
0x2FEE72BB,0x8186E32A,0xA84E57D8,0x0626C649,0xFBDF3E3C,0x55B7AFAD,0x7C7F1B5F,0xD2178ACE,
|
| 1327 |
+
0xBADAD36A,0x14B242FB,0x3D7AF609,0x93126798,0x6EEB9FED,0xC0830E7C,0xE94BBA8E,0x47232B1F,
|
| 1328 |
+
0xC9C94C25,0x67A1DDB4,0x4E696946,0xE001F8D7,0x1DF800A2,0xB3909133,0x9A5825C1,0x3430B450,
|
| 1329 |
+
0x4BC29689,0xE5AA0718,0xCC62B3EA,0x620A227B,0x9FF3DA0E,0x319B4B9F,0x1853FF6D,0xB63B6EFC,
|
| 1330 |
+
0x38D109C6,0x96B99857,0xBF712CA5,0x1119BD34,0xECE04541,0x4288D4D0,0x6B406022,0xC528F1B3,
|
| 1331 |
+
0xADE5A817,0x038D3986,0x2A458D74,0x842D1CE5,0x79D4E490,0xD7BC7501,0xFE74C1F3,0x501C5062,
|
| 1332 |
+
0xDEF63758,0x709EA6C9,0x5956123B,0xF73E83AA,0x0AC77BDF,0xA4AFEA4E,0x8D675EBC,0x230FCF2D,
|
| 1333 |
+
0x72831B0E,0xDCEB8A9F,0xF5233E6D,0x5B4BAFFC,0xA6B25789,0x08DAC618,0x211272EA,0x8F7AE37B,
|
| 1334 |
+
0x01908441,0xAFF815D0,0x8630A122,0x285830B3,0xD5A1C8C6,0x7BC95957,0x5201EDA5,0xFC697C34,
|
| 1335 |
+
0x94A42590,0x3ACCB401,0x130400F3,0xBD6C9162,0x40956917,0xEEFDF886,0xC7354C74,0x695DDDE5,
|
| 1336 |
+
0xE7B7BADF,0x49DF2B4E,0x60179FBC,0xCE7F0E2D,0x3386F658,0x9DEE67C9,0xB426D33B,0x1A4E42AA,
|
| 1337 |
+
0x65BC6073,0xCBD4F1E2,0xE21C4510,0x4C74D481,0xB18D2CF4,0x1FE5BD65,0x362D0997,0x98459806,
|
| 1338 |
+
0x16AFFF3C,0xB8C76EAD,0x910FDA5F,0x3F674BCE,0xC29EB3BB,0x6CF6222A,0x453E96D8,0xEB560749,
|
| 1339 |
+
0x839B5EED,0x2DF3CF7C,0x043B7B8E,0xAA53EA1F,0x57AA126A,0xF9C283FB,0xD00A3709,0x7E62A698,
|
| 1340 |
+
0xF088C1A2,0x5EE05033,0x7728E4C1,0xD9407550,0x24B98D25,0x8AD11CB4,0xA319A846,0x0D7139D7,
|
| 1341 |
+
}
|
| 1342 |
+
#endif // CRC32_USE_LOOKUP_TABLE_SLICING_BY_16
|
| 1343 |
+
};
|
| 1344 |
+
#endif
|
| 1345 |
+
|
| 1346 |
+
#else
|
| 1347 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 1348 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/file_adapter.h
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/macros/Macros.h>
|
| 5 |
+
#include <fstream>
|
| 6 |
+
#include <memory>
|
| 7 |
+
|
| 8 |
+
#include "caffe2/serialize/istream_adapter.h"
|
| 9 |
+
#include "caffe2/serialize/read_adapter_interface.h"
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
namespace caffe2::serialize {
|
| 13 |
+
|
| 14 |
+
class TORCH_API FileAdapter final : public ReadAdapterInterface {
|
| 15 |
+
public:
|
| 16 |
+
C10_DISABLE_COPY_AND_ASSIGN(FileAdapter);
|
| 17 |
+
explicit FileAdapter(const std::string& file_name);
|
| 18 |
+
size_t size() const override;
|
| 19 |
+
size_t read(uint64_t pos, void* buf, size_t n, const char* what = "")
|
| 20 |
+
const override;
|
| 21 |
+
~FileAdapter() override;
|
| 22 |
+
|
| 23 |
+
private:
|
| 24 |
+
// An RAII Wrapper for a FILE pointer. Closes on destruction.
|
| 25 |
+
struct RAIIFile {
|
| 26 |
+
FILE* fp_;
|
| 27 |
+
explicit RAIIFile(const std::string& file_name);
|
| 28 |
+
~RAIIFile();
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
RAIIFile file_;
|
| 32 |
+
// The size of the opened file in bytes
|
| 33 |
+
uint64_t size_;
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
} // namespace caffe2::serialize
|
| 37 |
+
|
| 38 |
+
#else
|
| 39 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 40 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/in_memory_adapter.h
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
#include <caffe2/serialize/read_adapter_interface.h>
|
| 4 |
+
#include <cstring>
|
| 5 |
+
|
| 6 |
+
namespace caffe2 {
|
| 7 |
+
namespace serialize {
|
| 8 |
+
|
| 9 |
+
class MemoryReadAdapter final : public caffe2::serialize::ReadAdapterInterface {
|
| 10 |
+
public:
|
| 11 |
+
explicit MemoryReadAdapter(const void* data, off_t size)
|
| 12 |
+
: data_(data), size_(size) {}
|
| 13 |
+
|
| 14 |
+
size_t size() const override {
|
| 15 |
+
return size_;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
size_t read(uint64_t pos, void* buf, size_t n, const char* what = "")
|
| 19 |
+
const override {
|
| 20 |
+
(void)what;
|
| 21 |
+
memcpy(buf, (int8_t*)(data_) + pos, n);
|
| 22 |
+
return n;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
private:
|
| 26 |
+
const void* data_;
|
| 27 |
+
off_t size_;
|
| 28 |
+
};
|
| 29 |
+
|
| 30 |
+
} // namespace serialize
|
| 31 |
+
} // namespace caffe2
|
| 32 |
+
|
| 33 |
+
#else
|
| 34 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 35 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/inline_container.h
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <cerrno>
|
| 5 |
+
#include <cstdio>
|
| 6 |
+
#include <cstring>
|
| 7 |
+
#include <fstream>
|
| 8 |
+
#include <istream>
|
| 9 |
+
#include <mutex>
|
| 10 |
+
#include <ostream>
|
| 11 |
+
#include <unordered_set>
|
| 12 |
+
|
| 13 |
+
#include <c10/core/Allocator.h>
|
| 14 |
+
#include <c10/core/Backend.h>
|
| 15 |
+
|
| 16 |
+
#include "caffe2/serialize/istream_adapter.h"
|
| 17 |
+
#include "caffe2/serialize/read_adapter_interface.h"
|
| 18 |
+
#include "caffe2/serialize/versions.h"
|
| 19 |
+
|
| 20 |
+
extern "C" {
|
| 21 |
+
typedef struct mz_zip_archive mz_zip_archive;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
// PyTorch containers are a special zip archive with the following layout
|
| 25 |
+
// archive_name.zip contains:
|
| 26 |
+
// archive_name/
|
| 27 |
+
// version # a file with a single decimal number written in ascii,
|
| 28 |
+
// # used to establish the version of the archive format
|
| 29 |
+
// model.json # overall model description, this is a json output of
|
| 30 |
+
// # ModelDef from torch.proto
|
| 31 |
+
// # the following names are by convention only, model.json will
|
| 32 |
+
// # refer to these files by full names
|
| 33 |
+
// tensors/
|
| 34 |
+
// 0 # flat storage for tensor data, meta-data about shapes, etc. is
|
| 35 |
+
// # in model.json
|
| 36 |
+
// 1
|
| 37 |
+
// ...
|
| 38 |
+
// # code entries will only exist for modules that have methods attached
|
| 39 |
+
// code/
|
| 40 |
+
// archive_name.py # serialized torch script code (python syntax, using
|
| 41 |
+
// PythonPrint) archive_name_my_submodule.py # submodules have separate
|
| 42 |
+
// files
|
| 43 |
+
//
|
| 44 |
+
// The PyTorchStreamWriter also ensures additional useful properties for these
|
| 45 |
+
// files
|
| 46 |
+
// 1. All files are stored uncompressed.
|
| 47 |
+
// 2. All files in the archive are aligned to 64 byte boundaries such that
|
| 48 |
+
// it is possible to mmap the entire file and get an aligned pointer to
|
| 49 |
+
// tensor data.
|
| 50 |
+
// 3. We universally write in ZIP64 format for consistency.
|
| 51 |
+
|
| 52 |
+
// The PyTorchStreamReader also provides additional properties:
|
| 53 |
+
// 1. It can read zip files that are created with common
|
| 54 |
+
// zip tools. This means that even though our writer doesn't compress files,
|
| 55 |
+
// the reader can still read files that were compressed.
|
| 56 |
+
// 2. It provides a getRecordOffset function which returns the offset into the
|
| 57 |
+
// raw file where file data lives. If the file was written with
|
| 58 |
+
// PyTorchStreamWriter it is guaranteed to be 64 byte aligned.
|
| 59 |
+
|
| 60 |
+
// PyTorchReader/Writer handle checking the version number on the archive format
|
| 61 |
+
// and ensure that all files are written to a archive_name directory so they
|
| 62 |
+
// unzip cleanly.
|
| 63 |
+
|
| 64 |
+
// When developing this format we want to pay particular attention to the
|
| 65 |
+
// following use cases:
|
| 66 |
+
//
|
| 67 |
+
// -- Reading --
|
| 68 |
+
// 1) Reading with full random access
|
| 69 |
+
// a) Reading with file api's such as fread()
|
| 70 |
+
// b) mmaping the file and jumping around the mapped region
|
| 71 |
+
// 2) Reading with 1-pass sequential access
|
| 72 |
+
// -> A reader will need to build up a data structure of parsed structures
|
| 73 |
+
// as it reads
|
| 74 |
+
//
|
| 75 |
+
// -- Writing --
|
| 76 |
+
// 1) Writing with full random access
|
| 77 |
+
// 2) Writing with 1-pass sequential access
|
| 78 |
+
// -> We must take care not to require updating values that have already
|
| 79 |
+
// been written. We place the variable-length index at the end and do
|
| 80 |
+
// not put any index into the header to fulfill this constraint.
|
| 81 |
+
|
| 82 |
+
// The model.json, which contains all the metadata information,
|
| 83 |
+
// should be written as the last file. One reason is that the size of tensor
|
| 84 |
+
// data is usually stable. As long as the shape and type of the tensor do not
|
| 85 |
+
// change, the size of the data won't change. On the other sied, the size of the
|
| 86 |
+
// serialized model is likely to change, so we store it as the last record, and
|
| 87 |
+
// we don't need to move previous records when updating the model data.
|
| 88 |
+
|
| 89 |
+
// The zip format is sufficiently flexible to handle the above use-case.
|
| 90 |
+
// it puts its central directory at the end of the archive and we write
|
| 91 |
+
// model.json as the last file when writing after we have accumulated all
|
| 92 |
+
// other information.
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
namespace caffe2::serialize {
|
| 96 |
+
|
| 97 |
+
static constexpr const char* kSerializationIdRecordName =
|
| 98 |
+
".data/serialization_id";
|
| 99 |
+
|
| 100 |
+
struct MzZipReaderIterWrapper;
|
| 101 |
+
|
| 102 |
+
class TORCH_API ChunkRecordIterator {
|
| 103 |
+
public:
|
| 104 |
+
~ChunkRecordIterator();
|
| 105 |
+
|
| 106 |
+
// Read at most `chunkSize` into `buf`. Return the number of actual bytes
|
| 107 |
+
// read.
|
| 108 |
+
size_t next(void* buf);
|
| 109 |
+
size_t recordSize() const {
|
| 110 |
+
return recordSize_;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
private:
|
| 114 |
+
ChunkRecordIterator(
|
| 115 |
+
size_t recordSize,
|
| 116 |
+
size_t chunkSize,
|
| 117 |
+
std::unique_ptr<MzZipReaderIterWrapper> iter);
|
| 118 |
+
|
| 119 |
+
const size_t recordSize_;
|
| 120 |
+
const size_t chunkSize_;
|
| 121 |
+
size_t offset_;
|
| 122 |
+
std::unique_ptr<MzZipReaderIterWrapper> iter_;
|
| 123 |
+
|
| 124 |
+
friend class PyTorchStreamReader;
|
| 125 |
+
};
|
| 126 |
+
|
| 127 |
+
class TORCH_API PyTorchStreamReader final {
|
| 128 |
+
public:
|
| 129 |
+
explicit PyTorchStreamReader(const std::string& file_name);
|
| 130 |
+
explicit PyTorchStreamReader(std::istream* in);
|
| 131 |
+
explicit PyTorchStreamReader(std::shared_ptr<ReadAdapterInterface> in);
|
| 132 |
+
|
| 133 |
+
// return dataptr, size
|
| 134 |
+
// set allocator to override default cpu allocator
|
| 135 |
+
std::tuple<at::DataPtr, size_t> getRecord(
|
| 136 |
+
const std::string& name,
|
| 137 |
+
std::optional<at::Allocator*> allocator = std::nullopt);
|
| 138 |
+
// multi-thread getRecord
|
| 139 |
+
std::tuple<at::DataPtr, size_t> getRecord(
|
| 140 |
+
const std::string& name,
|
| 141 |
+
std::vector<std::shared_ptr<ReadAdapterInterface>>& additionalReaders,
|
| 142 |
+
std::optional<at::Allocator*> allocator = std::nullopt);
|
| 143 |
+
// inplace memory writing
|
| 144 |
+
size_t getRecord(const std::string& name, void* dst, size_t n);
|
| 145 |
+
// inplace memory writing, multi-threads.
|
| 146 |
+
// When additionalReaders is empty, the default behavior is call
|
| 147 |
+
// getRecord(name, dst, n) with default reader This approach can be used for
|
| 148 |
+
// reading large tensors.
|
| 149 |
+
size_t getRecord(
|
| 150 |
+
const std::string& name,
|
| 151 |
+
void* dst,
|
| 152 |
+
size_t n,
|
| 153 |
+
std::vector<std::shared_ptr<ReadAdapterInterface>>& additionalReaders);
|
| 154 |
+
size_t getRecord(
|
| 155 |
+
const std::string& name,
|
| 156 |
+
void* dst,
|
| 157 |
+
size_t n,
|
| 158 |
+
size_t chunk_size,
|
| 159 |
+
void* buf,
|
| 160 |
+
const std::function<void(void*, const void*, size_t)>& memcpy_func =
|
| 161 |
+
nullptr);
|
| 162 |
+
|
| 163 |
+
// Concurrent reading records with multiple readers.
|
| 164 |
+
// additionalReaders are additional clients to access the underlying record at
|
| 165 |
+
// different offsets and write to different trunks of buffers. If the overall
|
| 166 |
+
// size of the tensor is 10, and size of additionalReader is 2. The default
|
| 167 |
+
// thread will read [0,4), the additional reader will read [4,8). The default
|
| 168 |
+
// reader will read [8,10). The default reader will write to buffer[0,4), the
|
| 169 |
+
// additional reader will write to buffer[4,8), the additional reader will
|
| 170 |
+
// write to buffer[8,10). When additionalReaders is empty, the default
|
| 171 |
+
// behavior is call getRecord(name) with default reader This approach can be
|
| 172 |
+
// used for reading large tensors.
|
| 173 |
+
size_t getRecordMultiReaders(
|
| 174 |
+
const std::string& name,
|
| 175 |
+
std::vector<std::shared_ptr<ReadAdapterInterface>>& additionalReaders,
|
| 176 |
+
void* dst,
|
| 177 |
+
size_t n);
|
| 178 |
+
|
| 179 |
+
size_t getRecordSize(const std::string& name);
|
| 180 |
+
size_t getRecordHeaderOffset(const std::string& name);
|
| 181 |
+
size_t getRecordOffset(const std::string& name);
|
| 182 |
+
size_t getRecordOffsetNoRead(
|
| 183 |
+
size_t cursor,
|
| 184 |
+
std::string filename,
|
| 185 |
+
size_t size,
|
| 186 |
+
uint64_t alignment);
|
| 187 |
+
bool hasRecord(const std::string& name);
|
| 188 |
+
std::vector<std::string> getAllRecords();
|
| 189 |
+
|
| 190 |
+
ChunkRecordIterator createChunkReaderIter(
|
| 191 |
+
const std::string& name,
|
| 192 |
+
const size_t recordSize,
|
| 193 |
+
const size_t chunkSize);
|
| 194 |
+
|
| 195 |
+
~PyTorchStreamReader();
|
| 196 |
+
uint64_t version() const {
|
| 197 |
+
return version_;
|
| 198 |
+
}
|
| 199 |
+
const std::string& serializationId() {
|
| 200 |
+
return serialization_id_;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
void setShouldLoadDebugSymbol(bool should_load_debug_symbol) {
|
| 204 |
+
load_debug_symbol_ = should_load_debug_symbol;
|
| 205 |
+
}
|
| 206 |
+
void setAdditionalReaderSizeThreshold(const size_t& size) {
|
| 207 |
+
additional_reader_size_threshold_ = size;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
private:
|
| 211 |
+
void init();
|
| 212 |
+
size_t read(uint64_t pos, char* buf, size_t n);
|
| 213 |
+
void valid(const char* what, const char* info = "");
|
| 214 |
+
size_t getRecordID(const std::string& name);
|
| 215 |
+
|
| 216 |
+
friend size_t
|
| 217 |
+
istream_read_func(void* pOpaque, uint64_t file_ofs, void* pBuf, size_t n);
|
| 218 |
+
std::unique_ptr<mz_zip_archive> ar_;
|
| 219 |
+
std::string archive_name_;
|
| 220 |
+
std::string archive_name_plus_slash_;
|
| 221 |
+
std::shared_ptr<ReadAdapterInterface> in_;
|
| 222 |
+
int64_t version_;
|
| 223 |
+
std::mutex reader_lock_;
|
| 224 |
+
bool load_debug_symbol_ = true;
|
| 225 |
+
std::string serialization_id_;
|
| 226 |
+
size_t additional_reader_size_threshold_;
|
| 227 |
+
};
|
| 228 |
+
|
| 229 |
+
class TORCH_API PyTorchStreamWriter final {
|
| 230 |
+
public:
|
| 231 |
+
explicit PyTorchStreamWriter(
|
| 232 |
+
const std::string& archive_name,
|
| 233 |
+
bool compute_crc32 = true,
|
| 234 |
+
uint64_t alignment = 64);
|
| 235 |
+
explicit PyTorchStreamWriter(
|
| 236 |
+
const std::function<size_t(const void*, size_t)> writer_func,
|
| 237 |
+
bool compute_crc32 = true,
|
| 238 |
+
uint64_t alignment = 64);
|
| 239 |
+
|
| 240 |
+
void setMinVersion(const uint64_t version);
|
| 241 |
+
|
| 242 |
+
void writeRecord(
|
| 243 |
+
const std::string& name,
|
| 244 |
+
const void* data,
|
| 245 |
+
size_t size,
|
| 246 |
+
bool compress = false);
|
| 247 |
+
void writeEndOfFile();
|
| 248 |
+
|
| 249 |
+
const std::unordered_set<std::string>& getAllWrittenRecords();
|
| 250 |
+
|
| 251 |
+
bool finalized() const {
|
| 252 |
+
return finalized_;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
const std::string& archiveName() {
|
| 256 |
+
return archive_name_;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
const std::string& serializationId() {
|
| 260 |
+
return serialization_id_;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
~PyTorchStreamWriter();
|
| 264 |
+
|
| 265 |
+
private:
|
| 266 |
+
void setup(const std::string& file_name);
|
| 267 |
+
void valid(const char* what, const char* info = "");
|
| 268 |
+
void writeSerializationId();
|
| 269 |
+
size_t current_pos_ = 0;
|
| 270 |
+
std::unordered_set<std::string> files_written_;
|
| 271 |
+
std::unique_ptr<mz_zip_archive> ar_;
|
| 272 |
+
std::string archive_name_;
|
| 273 |
+
std::string archive_name_plus_slash_;
|
| 274 |
+
std::string padding_;
|
| 275 |
+
std::ofstream file_stream_;
|
| 276 |
+
std::function<size_t(const void*, size_t)> writer_func_;
|
| 277 |
+
uint64_t combined_uncomp_crc32_ = 0;
|
| 278 |
+
std::string serialization_id_;
|
| 279 |
+
bool compute_crc32_;
|
| 280 |
+
uint64_t alignment_;
|
| 281 |
+
|
| 282 |
+
// This number will be updated when the model has operators
|
| 283 |
+
// that have valid upgraders.
|
| 284 |
+
uint64_t version_ = kMinProducedFileFormatVersion;
|
| 285 |
+
bool finalized_ = false;
|
| 286 |
+
bool err_seen_ = false;
|
| 287 |
+
friend size_t ostream_write_func(
|
| 288 |
+
void* pOpaque,
|
| 289 |
+
uint64_t file_ofs,
|
| 290 |
+
const void* pBuf,
|
| 291 |
+
size_t n);
|
| 292 |
+
};
|
| 293 |
+
|
| 294 |
+
namespace detail {
|
| 295 |
+
|
| 296 |
+
// Returns a record to be appended to the local user extra data entry in order
|
| 297 |
+
// to make data beginning aligned at kFieldAlignment bytes boundary.
|
| 298 |
+
size_t getPadding(
|
| 299 |
+
size_t cursor,
|
| 300 |
+
size_t filename_size,
|
| 301 |
+
size_t size,
|
| 302 |
+
std::string& padding_buf,
|
| 303 |
+
uint64_t alignment);
|
| 304 |
+
|
| 305 |
+
std::tuple<size_t, size_t>
|
| 306 |
+
getOffset(size_t cursor, size_t filename_size, size_t size, uint64_t alignment);
|
| 307 |
+
|
| 308 |
+
} // namespace detail
|
| 309 |
+
|
| 310 |
+
} // namespace caffe2::serialize
|
| 311 |
+
|
| 312 |
+
#else
|
| 313 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 314 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/istream_adapter.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <istream>
|
| 5 |
+
|
| 6 |
+
#include "c10/macros/Macros.h"
|
| 7 |
+
#include "caffe2/serialize/read_adapter_interface.h"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
namespace caffe2::serialize {
|
| 11 |
+
|
| 12 |
+
// this is a reader implemented by std::istream
|
| 13 |
+
class TORCH_API IStreamAdapter final : public ReadAdapterInterface {
|
| 14 |
+
public:
|
| 15 |
+
C10_DISABLE_COPY_AND_ASSIGN(IStreamAdapter);
|
| 16 |
+
explicit IStreamAdapter(std::istream* istream);
|
| 17 |
+
size_t size() const override;
|
| 18 |
+
size_t read(uint64_t pos, void* buf, size_t n, const char* what = "")
|
| 19 |
+
const override;
|
| 20 |
+
~IStreamAdapter() override;
|
| 21 |
+
|
| 22 |
+
private:
|
| 23 |
+
std::istream* istream_;
|
| 24 |
+
void validate(const char* what) const;
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
} // namespace caffe2::serialize
|
| 28 |
+
|
| 29 |
+
#else
|
| 30 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 31 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/read_adapter_interface.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <cstddef>
|
| 5 |
+
#include <cstdint>
|
| 6 |
+
|
| 7 |
+
#include "c10/macros/Macros.h"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
namespace caffe2::serialize {
|
| 11 |
+
|
| 12 |
+
// this is the interface for the (file/stream/memory) reader in
|
| 13 |
+
// PyTorchStreamReader. with this interface, we can extend the support
|
| 14 |
+
// besides standard istream
|
| 15 |
+
class TORCH_API ReadAdapterInterface {
|
| 16 |
+
public:
|
| 17 |
+
virtual size_t size() const = 0;
|
| 18 |
+
virtual size_t read(uint64_t pos, void* buf, size_t n, const char* what = "")
|
| 19 |
+
const = 0;
|
| 20 |
+
virtual ~ReadAdapterInterface();
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
} // namespace caffe2::serialize
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/serialize/versions.h
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
#include <cstdint>
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
namespace caffe2::serialize {
|
| 7 |
+
|
| 8 |
+
constexpr uint64_t kMinSupportedFileFormatVersion = 0x1L;
|
| 9 |
+
|
| 10 |
+
constexpr uint64_t kMaxSupportedFileFormatVersion = 0xAL;
|
| 11 |
+
|
| 12 |
+
// Versions (i.e. why was the version number bumped?)
|
| 13 |
+
|
| 14 |
+
// Note [Dynamic Versions and torch.jit.save vs. torch.save]
|
| 15 |
+
//
|
| 16 |
+
// Our versioning scheme has a "produced file format version" which
|
| 17 |
+
// describes how an archive is to be read. The version written in an archive
|
| 18 |
+
// is at least this current produced file format version, but may be greater
|
| 19 |
+
// if it includes certain symbols. We refer to these conditional versions
|
| 20 |
+
// as "dynamic," since they are identified at runtime.
|
| 21 |
+
//
|
| 22 |
+
// Dynamic versioning is useful when an operator's semantics are updated.
|
| 23 |
+
// When using torch.jit.save we want those semantics to be preserved. If
|
| 24 |
+
// we bumped the produced file format version on every change, however,
|
| 25 |
+
// then older versions of PyTorch couldn't read even simple archives, like
|
| 26 |
+
// a single tensor, from newer versions of PyTorch. Instead, we
|
| 27 |
+
// assign dynamic versions to these changes that override the
|
| 28 |
+
// produced file format version as needed. That is, when the semantics
|
| 29 |
+
// of torch.div changed it was assigned dynamic version 4, and when
|
| 30 |
+
// torch.jit.saving modules that use torch.div those archives also have
|
| 31 |
+
// (at least) version 4. This prevents earlier versions of PyTorch
|
| 32 |
+
// from accidentally performing the wrong kind of division. Modules
|
| 33 |
+
// that don't use torch.div or other operators with dynamic versions
|
| 34 |
+
// can write the produced file format version, and these programs will
|
| 35 |
+
// run as expected on earlier versions of PyTorch.
|
| 36 |
+
//
|
| 37 |
+
// While torch.jit.save attempts to preserve operator semantics,
|
| 38 |
+
// torch.save does not. torch.save is analogous to pickling Python, so
|
| 39 |
+
// a function that uses torch.div will have different behavior if torch.saved
|
| 40 |
+
// and torch.loaded across PyTorch versions. From a technical perspective,
|
| 41 |
+
// torch.save ignores dynamic versioning.
|
| 42 |
+
|
| 43 |
+
// 1. Initial version
|
| 44 |
+
// 2. Removed op_version_set version numbers
|
| 45 |
+
// 3. Added type tags to pickle serialization of container types
|
| 46 |
+
// 4. (Dynamic) Stopped integer division using torch.div
|
| 47 |
+
// (a versioned symbol preserves the historic behavior of versions 1--3)
|
| 48 |
+
// 5. (Dynamic) Stops torch.full inferring a floating point dtype
|
| 49 |
+
// when given bool or integer fill values.
|
| 50 |
+
// 6. Write version string to `./data/version` instead of `version`.
|
| 51 |
+
|
| 52 |
+
// [12/15/2021]
|
| 53 |
+
// kProducedFileFormatVersion is set to 7 from 3 due to a different
|
| 54 |
+
// interpretation of what file format version is.
|
| 55 |
+
// Whenever there is new upgrader introduced,
|
| 56 |
+
// this number should be bumped.
|
| 57 |
+
// The reasons that version is bumped in the past:
|
| 58 |
+
// 1. aten::div is changed at version 4
|
| 59 |
+
// 2. aten::full is changed at version 5
|
| 60 |
+
// 3. torch.package uses version 6
|
| 61 |
+
// 4. Introduce new upgrader design and set the version number to 7
|
| 62 |
+
// mark this change
|
| 63 |
+
// --------------------------------------------------
|
| 64 |
+
// We describe new operator version bump reasons here:
|
| 65 |
+
// 1) [01/24/2022]
|
| 66 |
+
// We bump the version number to 8 to update aten::linspace
|
| 67 |
+
// and aten::linspace.out to error out when steps is not
|
| 68 |
+
// provided. (see: https://github.com/pytorch/pytorch/issues/55951)
|
| 69 |
+
// 2) [01/30/2022]
|
| 70 |
+
// Bump the version number to 9 to update aten::logspace and
|
| 71 |
+
// and aten::logspace.out to error out when steps is not
|
| 72 |
+
// provided. (see: https://github.com/pytorch/pytorch/issues/55951)
|
| 73 |
+
// 3) [02/11/2022]
|
| 74 |
+
// Bump the version number to 10 to update aten::gelu and
|
| 75 |
+
// and aten::gelu.out to support the new approximate kwarg.
|
| 76 |
+
// (see: https://github.com/pytorch/pytorch/pull/61439)
|
| 77 |
+
constexpr uint64_t kProducedFileFormatVersion = 0xAL;
|
| 78 |
+
|
| 79 |
+
// Absolute minimum version we will write packages. This
|
| 80 |
+
// means that every package from now on will always be
|
| 81 |
+
// greater than this number.
|
| 82 |
+
constexpr uint64_t kMinProducedFileFormatVersion = 0x3L;
|
| 83 |
+
|
| 84 |
+
// The version we write when the archive contains bytecode.
|
| 85 |
+
// It must be higher or eq to kProducedFileFormatVersion.
|
| 86 |
+
// Because torchscript changes is likely introduce bytecode change.
|
| 87 |
+
// If kProducedFileFormatVersion is increased, kProducedBytecodeVersion
|
| 88 |
+
// should be increased too. The relationship is:
|
| 89 |
+
// kMaxSupportedFileFormatVersion >= (most likely ==) kProducedBytecodeVersion
|
| 90 |
+
// >= kProducedFileFormatVersion
|
| 91 |
+
// If a format change is forward compatible (still readable by older
|
| 92 |
+
// executables), we will not increment the version number, to minimize the
|
| 93 |
+
// risk of breaking existing clients. TODO: A better way would be to allow
|
| 94 |
+
// the caller that creates a model to specify a maximum version that its
|
| 95 |
+
// clients can accept.
|
| 96 |
+
// Versions:
|
| 97 |
+
// 0x1L: Initial version
|
| 98 |
+
// 0x2L: (Comment missing)
|
| 99 |
+
// 0x3L: (Comment missing)
|
| 100 |
+
// 0x4L: (update) Added schema to function tuple. Forward-compatible change.
|
| 101 |
+
// 0x5L: (update) Update bytecode is sharing constant tensor files from
|
| 102 |
+
// torchscript, and only serialize extra tensors that are not in the
|
| 103 |
+
// torchscript constant table. Also update tensor storage schema adapting to
|
| 104 |
+
// the unify format, the root key of tensor storage is updated from {index} to
|
| 105 |
+
// {the_pointer_value_the_tensor.storage}, for example:
|
| 106 |
+
// `140245072983168.storage` Forward-compatibility change.
|
| 107 |
+
// 0x6L: Implicit opereator versioning using number of specified argument.
|
| 108 |
+
// Refer to the summary of https://github.com/pytorch/pytorch/pull/56845 for
|
| 109 |
+
// details.
|
| 110 |
+
// 0x7L: Enable support for operators with default arguments plus out
|
| 111 |
+
// arguments. Refer. See https://github.com/pytorch/pytorch/pull/63651 for
|
| 112 |
+
// details.
|
| 113 |
+
// 0x8L: Emit promoted operators as instructions. See
|
| 114 |
+
// https://github.com/pytorch/pytorch/pull/71662 for details.
|
| 115 |
+
// 0x9L: Change serialization format from pickle to format This version is to
|
| 116 |
+
// serve migration. v8 pickle and v9 flatbuffer are the same. Refer to the
|
| 117 |
+
// summary of https://github.com/pytorch/pytorch/pull/75201 for more details.
|
| 118 |
+
constexpr uint64_t kProducedBytecodeVersion = 0x8L;
|
| 119 |
+
|
| 120 |
+
// static_assert(
|
| 121 |
+
// kProducedBytecodeVersion >= kProducedFileFormatVersion,
|
| 122 |
+
// "kProducedBytecodeVersion must be higher or equal to
|
| 123 |
+
// kProducedFileFormatVersion.");
|
| 124 |
+
|
| 125 |
+
// Introduce kMinSupportedBytecodeVersion and kMaxSupportedBytecodeVersion
|
| 126 |
+
// for limited backward/forward compatibility support of bytecode. If
|
| 127 |
+
// kMinSupportedBytecodeVersion <= model_version <= kMaxSupportedBytecodeVersion
|
| 128 |
+
// (in loader), we should support this model_version. For example, we provide a
|
| 129 |
+
// wrapper to handle an updated operator.
|
| 130 |
+
constexpr uint64_t kMinSupportedBytecodeVersion = 0x4L;
|
| 131 |
+
constexpr uint64_t kMaxSupportedBytecodeVersion = 0x9L;
|
| 132 |
+
|
| 133 |
+
} // namespace caffe2::serialize
|
| 134 |
+
|
| 135 |
+
#else
|
| 136 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 137 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/fixed_divisor.h
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef CAFFE2_UTILS_FIXED_DIVISOR_H_
|
| 3 |
+
#define CAFFE2_UTILS_FIXED_DIVISOR_H_
|
| 4 |
+
|
| 5 |
+
#include <cstdint>
|
| 6 |
+
#include <cstdio>
|
| 7 |
+
#include <cstdlib>
|
| 8 |
+
|
| 9 |
+
// See Note [hip-clang differences to hcc]
|
| 10 |
+
|
| 11 |
+
#if defined(__CUDA_ARCH__) || defined(__HIP_ARCH__) || defined(__HIP__) || \
|
| 12 |
+
(defined(__clang__) && defined(__CUDA__))
|
| 13 |
+
#define FIXED_DIVISOR_DECL inline __host__ __device__
|
| 14 |
+
#else
|
| 15 |
+
#define FIXED_DIVISOR_DECL inline
|
| 16 |
+
#endif
|
| 17 |
+
|
| 18 |
+
namespace caffe2 {
|
| 19 |
+
|
| 20 |
+
// Utility class for quickly calculating quotients and remainders for
|
| 21 |
+
// a known integer divisor
|
| 22 |
+
template <typename T>
|
| 23 |
+
class FixedDivisor {};
|
| 24 |
+
|
| 25 |
+
// Works for any positive divisor, 1 to INT_MAX. One 64-bit
|
| 26 |
+
// multiplication and one 64-bit shift is used to calculate the
|
| 27 |
+
// result.
|
| 28 |
+
template <>
|
| 29 |
+
class FixedDivisor<std::int32_t> {
|
| 30 |
+
public:
|
| 31 |
+
FixedDivisor() = default;
|
| 32 |
+
|
| 33 |
+
explicit FixedDivisor(const std::int32_t d) : d_(d) {
|
| 34 |
+
#if !defined(USE_ROCM)
|
| 35 |
+
CalcSignedMagic();
|
| 36 |
+
#endif // USE_ROCM
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
FIXED_DIVISOR_DECL std::int32_t d() const {
|
| 40 |
+
return d_;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
#if !defined(USE_ROCM)
|
| 44 |
+
FIXED_DIVISOR_DECL std::uint64_t magic() const {
|
| 45 |
+
return magic_;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
FIXED_DIVISOR_DECL int shift() const {
|
| 49 |
+
return shift_;
|
| 50 |
+
}
|
| 51 |
+
#endif // USE_ROCM
|
| 52 |
+
|
| 53 |
+
/// Calculates `q = n / d`.
|
| 54 |
+
FIXED_DIVISOR_DECL std::int32_t Div(const std::int32_t n) const {
|
| 55 |
+
#if defined(USE_ROCM)
|
| 56 |
+
return n / d_;
|
| 57 |
+
#else // USE_ROCM
|
| 58 |
+
// In lieu of a mulhi instruction being available, perform the
|
| 59 |
+
// work in uint64
|
| 60 |
+
return (int32_t)((magic_ * (uint64_t)n) >> shift_);
|
| 61 |
+
#endif // USE_ROCM
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/// Calculates `r = n % d`.
|
| 65 |
+
FIXED_DIVISOR_DECL std::int32_t Mod(const std::int32_t n) const {
|
| 66 |
+
return n - d_ * Div(n);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/// Calculates `q = n / d` and `r = n % d` together.
|
| 70 |
+
FIXED_DIVISOR_DECL void
|
| 71 |
+
DivMod(const std::int32_t n, std::int32_t* q, int32_t* r) const {
|
| 72 |
+
*q = Div(n);
|
| 73 |
+
*r = n - d_ * *q;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
private:
|
| 77 |
+
#if !defined(USE_ROCM)
|
| 78 |
+
// Calculates magic multiplicative value and shift amount for calculating `q =
|
| 79 |
+
// n / d` for signed 32-bit integers.
|
| 80 |
+
// Implementation taken from Hacker's Delight section 10.
|
| 81 |
+
void CalcSignedMagic() {
|
| 82 |
+
if (d_ == 1) {
|
| 83 |
+
magic_ = UINT64_C(0x1) << 32;
|
| 84 |
+
shift_ = 32;
|
| 85 |
+
return;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
const std::uint32_t two31 = UINT32_C(0x80000000);
|
| 89 |
+
const std::uint32_t ad = std::abs(d_);
|
| 90 |
+
const std::uint32_t t = two31 + ((uint32_t)d_ >> 31);
|
| 91 |
+
const std::uint32_t anc = t - 1 - t % ad; // Absolute value of nc.
|
| 92 |
+
std::uint32_t p = 31; // Init. p.
|
| 93 |
+
std::uint32_t q1 = two31 / anc; // Init. q1 = 2**p/|nc|.
|
| 94 |
+
std::uint32_t r1 = two31 - q1 * anc; // Init. r1 = rem(2**p, |nc|).
|
| 95 |
+
std::uint32_t q2 = two31 / ad; // Init. q2 = 2**p/|d|.
|
| 96 |
+
std::uint32_t r2 = two31 - q2 * ad; // Init. r2 = rem(2**p, |d|).
|
| 97 |
+
std::uint32_t delta = 0;
|
| 98 |
+
do {
|
| 99 |
+
++p;
|
| 100 |
+
q1 <<= 1; // Update q1 = 2**p/|nc|.
|
| 101 |
+
r1 <<= 1; // Update r1 = rem(2**p, |nc|).
|
| 102 |
+
if (r1 >= anc) { // (Must be an unsigned
|
| 103 |
+
++q1; // comparison here).
|
| 104 |
+
r1 -= anc;
|
| 105 |
+
}
|
| 106 |
+
q2 <<= 1; // Update q2 = 2**p/|d|.
|
| 107 |
+
r2 <<= 1; // Update r2 = rem(2**p, |d|).
|
| 108 |
+
if (r2 >= ad) { // (Must be an unsigned
|
| 109 |
+
++q2; // comparison here).
|
| 110 |
+
r2 -= ad;
|
| 111 |
+
}
|
| 112 |
+
delta = ad - r2;
|
| 113 |
+
} while (q1 < delta || (q1 == delta && r1 == 0));
|
| 114 |
+
std::int32_t magic = q2 + 1;
|
| 115 |
+
if (d_ < 0) {
|
| 116 |
+
magic = -magic;
|
| 117 |
+
}
|
| 118 |
+
shift_ = p;
|
| 119 |
+
magic_ = (std::uint64_t)(std::uint32_t)magic;
|
| 120 |
+
}
|
| 121 |
+
#endif // USE_ROCM
|
| 122 |
+
|
| 123 |
+
std::int32_t d_ = 1;
|
| 124 |
+
|
| 125 |
+
#if !defined(USE_ROCM)
|
| 126 |
+
std::uint64_t magic_;
|
| 127 |
+
int shift_;
|
| 128 |
+
#endif // USE_ROCM
|
| 129 |
+
};
|
| 130 |
+
|
| 131 |
+
} // namespace caffe2
|
| 132 |
+
|
| 133 |
+
#endif // CAFFE2_UTILS_FIXED_DIVISOR_H_
|
| 134 |
+
|
| 135 |
+
#else
|
| 136 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 137 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/proto_wrap.h
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef CAFFE2_UTILS_PROTO_WRAP_H_
|
| 3 |
+
#define CAFFE2_UTILS_PROTO_WRAP_H_
|
| 4 |
+
|
| 5 |
+
#include <c10/util/Logging.h>
|
| 6 |
+
|
| 7 |
+
namespace caffe2 {
|
| 8 |
+
|
| 9 |
+
// A wrapper function to shut down protobuf library (this is needed in ASAN
|
| 10 |
+
// testing and valgrind cases to avoid protobuf appearing to "leak" memory).
|
| 11 |
+
TORCH_API void ShutdownProtobufLibrary();
|
| 12 |
+
|
| 13 |
+
// Caffe2 wrapper functions for protobuf's GetEmptyStringAlreadyInited()
|
| 14 |
+
// function used to avoid duplicated global variable in the case when protobuf
|
| 15 |
+
// is built with hidden visibility.
|
| 16 |
+
TORCH_API const ::std::string& GetEmptyStringAlreadyInited();
|
| 17 |
+
} // namespace caffe2
|
| 18 |
+
|
| 19 |
+
namespace ONNX_NAMESPACE {
|
| 20 |
+
|
| 21 |
+
// ONNX wrapper functions for protobuf's GetEmptyStringAlreadyInited() function
|
| 22 |
+
// used to avoid duplicated global variable in the case when protobuf
|
| 23 |
+
// is built with hidden visibility.
|
| 24 |
+
TORCH_API const ::std::string& GetEmptyStringAlreadyInited();
|
| 25 |
+
|
| 26 |
+
} // namespace ONNX_NAMESPACE
|
| 27 |
+
|
| 28 |
+
namespace torch {
|
| 29 |
+
|
| 30 |
+
// Caffe2 wrapper functions for protobuf's GetEmptyStringAlreadyInited()
|
| 31 |
+
// function used to avoid duplicated global variable in the case when protobuf
|
| 32 |
+
// is built with hidden visibility.
|
| 33 |
+
TORCH_API const ::std::string& GetEmptyStringAlreadyInited();
|
| 34 |
+
|
| 35 |
+
void ShutdownProtobufLibrary();
|
| 36 |
+
|
| 37 |
+
} // namespace torch
|
| 38 |
+
#endif // CAFFE2_UTILS_PROTO_WRAP_H_
|
| 39 |
+
|
| 40 |
+
#else
|
| 41 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 42 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/string_utils.h
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <algorithm>
|
| 5 |
+
#include <memory>
|
| 6 |
+
#include <string>
|
| 7 |
+
#include <vector>
|
| 8 |
+
|
| 9 |
+
#include <c10/macros/Export.h>
|
| 10 |
+
|
| 11 |
+
namespace caffe2 {
|
| 12 |
+
|
| 13 |
+
TORCH_API std::vector<std::string>
|
| 14 |
+
split(char separator, const std::string& string, bool ignore_empty = false);
|
| 15 |
+
|
| 16 |
+
TORCH_API std::string trim(const std::string& str);
|
| 17 |
+
|
| 18 |
+
TORCH_API size_t editDistance(
|
| 19 |
+
const std::string& s1,
|
| 20 |
+
const std::string& s2,
|
| 21 |
+
size_t max_distance = 0);
|
| 22 |
+
|
| 23 |
+
TORCH_API inline bool StartsWith(
|
| 24 |
+
const std::string& str,
|
| 25 |
+
const std::string& prefix) {
|
| 26 |
+
return str.length() >= prefix.length() &&
|
| 27 |
+
std::mismatch(prefix.begin(), prefix.end(), str.begin()).first ==
|
| 28 |
+
prefix.end();
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
TORCH_API inline bool EndsWith(
|
| 32 |
+
const std::string& full,
|
| 33 |
+
const std::string& ending) {
|
| 34 |
+
if (full.length() >= ending.length()) {
|
| 35 |
+
return (
|
| 36 |
+
0 ==
|
| 37 |
+
full.compare(full.length() - ending.length(), ending.length(), ending));
|
| 38 |
+
} else {
|
| 39 |
+
return false;
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
TORCH_API int32_t editDistanceHelper(
|
| 44 |
+
const char* s1,
|
| 45 |
+
size_t s1_len,
|
| 46 |
+
const char* s2,
|
| 47 |
+
size_t s2_len,
|
| 48 |
+
std::vector<size_t>& current,
|
| 49 |
+
std::vector<size_t>& previous,
|
| 50 |
+
std::vector<size_t>& previous1,
|
| 51 |
+
size_t max_distance);
|
| 52 |
+
} // namespace caffe2
|
| 53 |
+
|
| 54 |
+
#else
|
| 55 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 56 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/ThreadPool.h
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef CAFFE2_UTILS_THREADPOOL_H_
|
| 3 |
+
#define CAFFE2_UTILS_THREADPOOL_H_
|
| 4 |
+
|
| 5 |
+
#include "ThreadPoolCommon.h"
|
| 6 |
+
|
| 7 |
+
#include <atomic>
|
| 8 |
+
#include <functional>
|
| 9 |
+
#include <memory>
|
| 10 |
+
#include <mutex>
|
| 11 |
+
#include <vector>
|
| 12 |
+
|
| 13 |
+
#include "c10/util/Flags.h"
|
| 14 |
+
#include "caffe2/core/common.h"
|
| 15 |
+
|
| 16 |
+
//
|
| 17 |
+
// A work-stealing threadpool loosely based off of pthreadpool
|
| 18 |
+
//
|
| 19 |
+
|
| 20 |
+
namespace caffe2 {
|
| 21 |
+
|
| 22 |
+
struct Task;
|
| 23 |
+
class WorkersPool;
|
| 24 |
+
|
| 25 |
+
constexpr size_t kCacheLineSize = 64;
|
| 26 |
+
|
| 27 |
+
// A threadpool with the given number of threads.
|
| 28 |
+
// NOTE: the kCacheLineSize alignment is present only for cache
|
| 29 |
+
// performance, and is not strictly enforced (for example, when
|
| 30 |
+
// the object is created on the heap). Thus, in order to avoid
|
| 31 |
+
// misaligned intrinsics, no SSE instructions shall be involved in
|
| 32 |
+
// the ThreadPool implementation.
|
| 33 |
+
// Note: alignas is disabled because some compilers do not deal with
|
| 34 |
+
// TORCH_API and alignas annotations at the same time.
|
| 35 |
+
class TORCH_API /*alignas(kCacheLineSize)*/ ThreadPool {
|
| 36 |
+
public:
|
| 37 |
+
static ThreadPool* createThreadPool(int numThreads);
|
| 38 |
+
static std::unique_ptr<ThreadPool> defaultThreadPool();
|
| 39 |
+
virtual ~ThreadPool() = default;
|
| 40 |
+
// Returns the number of threads currently in use
|
| 41 |
+
virtual int getNumThreads() const = 0;
|
| 42 |
+
virtual void setNumThreads(size_t numThreads) = 0;
|
| 43 |
+
|
| 44 |
+
// Sets the minimum work size (range) for which to invoke the
|
| 45 |
+
// threadpool; work sizes smaller than this will just be run on the
|
| 46 |
+
// main (calling) thread
|
| 47 |
+
void setMinWorkSize(size_t size) {
|
| 48 |
+
std::lock_guard<std::mutex> guard(executionMutex_);
|
| 49 |
+
minWorkSize_ = size;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
size_t getMinWorkSize() const {
|
| 53 |
+
return minWorkSize_;
|
| 54 |
+
}
|
| 55 |
+
virtual void run(const std::function<void(int, size_t)>& fn, size_t range) = 0;
|
| 56 |
+
|
| 57 |
+
// Run an arbitrary function in a thread-safe manner accessing the Workers
|
| 58 |
+
// Pool
|
| 59 |
+
virtual void withPool(const std::function<void(WorkersPool*)>& fn) = 0;
|
| 60 |
+
|
| 61 |
+
protected:
|
| 62 |
+
static size_t defaultNumThreads_;
|
| 63 |
+
mutable std::mutex executionMutex_;
|
| 64 |
+
size_t minWorkSize_;
|
| 65 |
+
};
|
| 66 |
+
|
| 67 |
+
size_t getDefaultNumThreads();
|
| 68 |
+
} // namespace caffe2
|
| 69 |
+
|
| 70 |
+
C10_DECLARE_bool(caffe2_threadpool_force_inline);
|
| 71 |
+
|
| 72 |
+
// Whether or not threadpool caps apply to Android
|
| 73 |
+
C10_DECLARE_int(caffe2_threadpool_android_cap);
|
| 74 |
+
|
| 75 |
+
// Whether or not threadpool caps apply to iOS and MacOS
|
| 76 |
+
C10_DECLARE_int(caffe2_threadpool_ios_cap);
|
| 77 |
+
C10_DECLARE_int(caffe2_threadpool_macos_cap);
|
| 78 |
+
|
| 79 |
+
C10_DECLARE_int(pthreadpool_size);
|
| 80 |
+
#endif // CAFFE2_UTILS_THREADPOOL_H_
|
| 81 |
+
|
| 82 |
+
#else
|
| 83 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 84 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/ThreadPoolCommon.h
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#ifndef CAFFE2_UTILS_THREADPOOL_COMMON_H_
|
| 3 |
+
#define CAFFE2_UTILS_THREADPOOL_COMMON_H_
|
| 4 |
+
|
| 5 |
+
#ifdef __APPLE__
|
| 6 |
+
#include <TargetConditionals.h>
|
| 7 |
+
#endif
|
| 8 |
+
|
| 9 |
+
// caffe2 depends upon NNPACK, which depends upon this threadpool, so
|
| 10 |
+
// unfortunately we can't reference core/common.h here
|
| 11 |
+
|
| 12 |
+
// This is copied from core/common.h's definition of C10_MOBILE
|
| 13 |
+
// Define enabled when building for iOS or Android devices
|
| 14 |
+
#if defined(__ANDROID__)
|
| 15 |
+
#define C10_ANDROID 1
|
| 16 |
+
#elif (defined(__APPLE__) && \
|
| 17 |
+
(TARGET_IPHONE_SIMULATOR || TARGET_OS_SIMULATOR || TARGET_OS_IPHONE))
|
| 18 |
+
#define C10_IOS 1
|
| 19 |
+
#endif // ANDROID / IOS
|
| 20 |
+
|
| 21 |
+
#endif // CAFFE2_UTILS_THREADPOOL_COMMON_H_
|
| 22 |
+
|
| 23 |
+
#else
|
| 24 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 25 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/WorkersPool.h
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <atomic>
|
| 5 |
+
#include <condition_variable>
|
| 6 |
+
#include <thread>
|
| 7 |
+
#include "c10/util/thread_name.h"
|
| 8 |
+
#include <c10/util/irange.h>
|
| 9 |
+
#include <c10/util/Logging.h>
|
| 10 |
+
|
| 11 |
+
#if defined(_MSC_VER)
|
| 12 |
+
#include <intrin.h>
|
| 13 |
+
#endif
|
| 14 |
+
|
| 15 |
+
namespace caffe2 {
|
| 16 |
+
|
| 17 |
+
// Uses code derived from gemmlowp,
|
| 18 |
+
// https://github.com/google/gemmlowp/blob/6c91e1ed0c2eff1182d804310b92911fe9c18019/internal/multi_thread_gemm.h
|
| 19 |
+
// Changes:
|
| 20 |
+
// - allocation-free execute()
|
| 21 |
+
// - Use RAII where possible.
|
| 22 |
+
// - Run the first task on the main thread (since that is the largest task).
|
| 23 |
+
// - removed custom allocator.
|
| 24 |
+
// - Removed some ifdef's
|
| 25 |
+
// - cache-line align Worker.
|
| 26 |
+
// - use std::atomic instead of volatile and custom barriers.
|
| 27 |
+
// - use std::mutex/std::condition_variable instead of raw pthreads.
|
| 28 |
+
|
| 29 |
+
constexpr size_t kGEMMLOWPCacheLineSize = 64;
|
| 30 |
+
|
| 31 |
+
template <typename T>
|
| 32 |
+
struct AllocAligned {
|
| 33 |
+
// Allocate a T aligned at an `align` byte address
|
| 34 |
+
template <typename... Args>
|
| 35 |
+
static T* alloc(Args&&... args) {
|
| 36 |
+
void* p = nullptr;
|
| 37 |
+
|
| 38 |
+
#if defined(__ANDROID__)
|
| 39 |
+
p = memalign(kGEMMLOWPCacheLineSize, sizeof(T));
|
| 40 |
+
#elif defined(_MSC_VER)
|
| 41 |
+
p = _aligned_malloc(sizeof(T), kGEMMLOWPCacheLineSize);
|
| 42 |
+
#else
|
| 43 |
+
auto res = posix_memalign(&p, kGEMMLOWPCacheLineSize, sizeof(T));
|
| 44 |
+
(void)res;
|
| 45 |
+
#endif
|
| 46 |
+
|
| 47 |
+
if (p) {
|
| 48 |
+
return new (p) T(std::forward<Args>(args)...);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
return nullptr;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
// Free a T previously allocated via AllocAligned<T>::alloc()
|
| 55 |
+
static void release(T* p) {
|
| 56 |
+
if (p) {
|
| 57 |
+
p->~T();
|
| 58 |
+
#if defined(_MSC_VER)
|
| 59 |
+
_aligned_free((void*)p);
|
| 60 |
+
#else
|
| 61 |
+
free((void*)p);
|
| 62 |
+
#endif
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
};
|
| 66 |
+
|
| 67 |
+
// Deleter object for unique_ptr for an aligned object
|
| 68 |
+
template <typename T>
|
| 69 |
+
struct AlignedDeleter {
|
| 70 |
+
void operator()(T* p) const { AllocAligned<T>::release(p); }
|
| 71 |
+
};
|
| 72 |
+
|
| 73 |
+
// make_unique that guarantees alignment
|
| 74 |
+
template <typename T>
|
| 75 |
+
struct MakeAligned {
|
| 76 |
+
template <typename... Args>
|
| 77 |
+
static std::unique_ptr<T, AlignedDeleter<T>> make(Args&&... args) {
|
| 78 |
+
return std::unique_ptr<T, AlignedDeleter<T>>(
|
| 79 |
+
AllocAligned<T>::alloc(std::forward<Args>(args)...));
|
| 80 |
+
}
|
| 81 |
+
};
|
| 82 |
+
|
| 83 |
+
const int kMaxBusyWaitNOPs = 32 * 1000 * 1000;
|
| 84 |
+
|
| 85 |
+
#if defined(_MSC_VER)
|
| 86 |
+
#define GEMMLOWP_NOP __nop();
|
| 87 |
+
#else
|
| 88 |
+
#define GEMMLOWP_NOP "nop\n"
|
| 89 |
+
#endif
|
| 90 |
+
|
| 91 |
+
#define GEMMLOWP_STRING_CONCAT_4(X) X X X X
|
| 92 |
+
#define GEMMLOWP_NOP4 GEMMLOWP_STRING_CONCAT_4(GEMMLOWP_NOP)
|
| 93 |
+
#define GEMMLOWP_NOP16 GEMMLOWP_STRING_CONCAT_4(GEMMLOWP_NOP4)
|
| 94 |
+
#define GEMMLOWP_NOP64 GEMMLOWP_STRING_CONCAT_4(GEMMLOWP_NOP16)
|
| 95 |
+
|
| 96 |
+
inline int Do256NOPs() {
|
| 97 |
+
#if defined(_MSC_VER)
|
| 98 |
+
GEMMLOWP_NOP64;
|
| 99 |
+
#else
|
| 100 |
+
asm volatile(GEMMLOWP_NOP64);
|
| 101 |
+
#endif
|
| 102 |
+
return 64;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
#undef GEMMLOWP_STRING_CONCAT_4
|
| 106 |
+
#undef GEMMLOWP_NOP256
|
| 107 |
+
#undef GEMMLOWP_NOP64
|
| 108 |
+
#undef GEMMLOWP_NOP16
|
| 109 |
+
#undef GEMMLOWP_NOP4
|
| 110 |
+
#undef GEMMLOWP_NOP
|
| 111 |
+
|
| 112 |
+
// Waits until *var != initial_value.
|
| 113 |
+
//
|
| 114 |
+
// Returns the new value of *var. The guarantee here is that
|
| 115 |
+
// the return value is different from initial_value, and that that
|
| 116 |
+
// new value has been taken by *var at some point during the
|
| 117 |
+
// execution of this function. There is no guarantee that this is
|
| 118 |
+
// still the value of *var when this function returns, since *var is
|
| 119 |
+
// not assumed to be guarded by any lock.
|
| 120 |
+
//
|
| 121 |
+
// First does some busy-waiting for a fixed number of no-op cycles,
|
| 122 |
+
// then falls back to passive waiting for the given condvar, guarded
|
| 123 |
+
// by the given mutex.
|
| 124 |
+
//
|
| 125 |
+
// The idea of doing some initial busy-waiting is to help get
|
| 126 |
+
// better and more consistent multithreading benefits for small GEMM sizes.
|
| 127 |
+
// Busy-waiting help ensuring that if we need to wake up soon after having
|
| 128 |
+
// started waiting, then we can wake up quickly (as opposed to, say,
|
| 129 |
+
// having to wait to be scheduled again by the OS). On the other hand,
|
| 130 |
+
// we must still eventually revert to passive waiting for longer waits
|
| 131 |
+
// (e.g. worker threads having finished a GEMM and waiting until the next GEMM)
|
| 132 |
+
// so as to avoid permanently spinning.
|
| 133 |
+
//
|
| 134 |
+
template <typename T>
|
| 135 |
+
T WaitForVariableChange(std::atomic<T>* var,
|
| 136 |
+
T initial_value,
|
| 137 |
+
std::condition_variable* cond,
|
| 138 |
+
std::mutex* mutex) {
|
| 139 |
+
// If we are on a platform that supports it, spin for some time.
|
| 140 |
+
{
|
| 141 |
+
int nops = 0;
|
| 142 |
+
// First, trivial case where the variable already changed value.
|
| 143 |
+
T new_value = var->load(std::memory_order_relaxed);
|
| 144 |
+
if (new_value != initial_value) {
|
| 145 |
+
std::atomic_thread_fence(std::memory_order_acquire);
|
| 146 |
+
return new_value;
|
| 147 |
+
}
|
| 148 |
+
// Then try busy-waiting.
|
| 149 |
+
while (nops < kMaxBusyWaitNOPs) {
|
| 150 |
+
nops += Do256NOPs();
|
| 151 |
+
new_value = var->load(std::memory_order_relaxed);
|
| 152 |
+
if (new_value != initial_value) {
|
| 153 |
+
std::atomic_thread_fence(std::memory_order_acquire);
|
| 154 |
+
return new_value;
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
// Finally, do real passive waiting.
|
| 160 |
+
{
|
| 161 |
+
std::unique_lock<std::mutex> g(*mutex);
|
| 162 |
+
T new_value = var->load(std::memory_order_relaxed);
|
| 163 |
+
// Handle spurious wakeups.
|
| 164 |
+
cond->wait(g, [&]() {
|
| 165 |
+
new_value = var->load(std::memory_order_relaxed);
|
| 166 |
+
return new_value != initial_value;
|
| 167 |
+
});
|
| 168 |
+
TORCH_DCHECK_NE(static_cast<size_t>(new_value), static_cast<size_t>(initial_value));
|
| 169 |
+
return new_value;
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
// A BlockingCounter lets one thread to wait for N events to occur.
|
| 174 |
+
// This is how the master thread waits for all the worker threads
|
| 175 |
+
// to have finished working.
|
| 176 |
+
class BlockingCounter {
|
| 177 |
+
public:
|
| 178 |
+
// Sets/resets the counter; initial_count is the number of
|
| 179 |
+
// decrementing events that the Wait() call will be waiting for.
|
| 180 |
+
void Reset(std::size_t initial_count) {
|
| 181 |
+
std::lock_guard<std::mutex> g(mutex_);
|
| 182 |
+
TORCH_DCHECK_EQ(count_, 0);
|
| 183 |
+
count_ = initial_count;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
// Decrements the counter; if the counter hits zero, signals
|
| 187 |
+
// the thread that was waiting for that, and returns true.
|
| 188 |
+
// Otherwise (if the decremented count is still nonzero),
|
| 189 |
+
// returns false.
|
| 190 |
+
bool DecrementCount() {
|
| 191 |
+
const auto count_value = count_.fetch_sub(1, std::memory_order_relaxed) - 1;
|
| 192 |
+
if (count_value == 0) {
|
| 193 |
+
std::lock_guard<std::mutex> g(mutex_);
|
| 194 |
+
cond_.notify_one();
|
| 195 |
+
}
|
| 196 |
+
bool retval = count_value == 0;
|
| 197 |
+
return retval;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
// Waits for the N other threads (N having been set by Reset())
|
| 201 |
+
// to hit the BlockingCounter.
|
| 202 |
+
void Wait() {
|
| 203 |
+
while (size_t count_value = count_.load(std::memory_order_relaxed)) {
|
| 204 |
+
WaitForVariableChange(&count_, count_value, &cond_, &mutex_);
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
private:
|
| 209 |
+
std::condition_variable cond_;
|
| 210 |
+
std::mutex mutex_;
|
| 211 |
+
std::atomic<std::size_t> count_{0};
|
| 212 |
+
};
|
| 213 |
+
|
| 214 |
+
// A workload for a worker.
|
| 215 |
+
struct Task {
|
| 216 |
+
Task() = default;
|
| 217 |
+
virtual ~Task() = default;
|
| 218 |
+
virtual void Run() = 0;
|
| 219 |
+
};
|
| 220 |
+
|
| 221 |
+
// A worker thread.
|
| 222 |
+
class alignas(kGEMMLOWPCacheLineSize) Worker {
|
| 223 |
+
public:
|
| 224 |
+
enum class State : uint8_t {
|
| 225 |
+
ThreadStartup, // The initial state before the thread main loop runs.
|
| 226 |
+
Ready, // Is not working, has not yet received new work to do.
|
| 227 |
+
HasWork, // Has work to do.
|
| 228 |
+
ExitAsSoonAsPossible // Should exit at earliest convenience.
|
| 229 |
+
};
|
| 230 |
+
|
| 231 |
+
explicit Worker(BlockingCounter* counter_to_decrement_when_ready)
|
| 232 |
+
: task_(nullptr),
|
| 233 |
+
state_(State::ThreadStartup),
|
| 234 |
+
counter_to_decrement_when_ready_(counter_to_decrement_when_ready) {
|
| 235 |
+
thread_ = std::make_unique<std::thread>([this]() {
|
| 236 |
+
c10::setThreadName("pt_thread_pool");
|
| 237 |
+
this->ThreadFunc();
|
| 238 |
+
});
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
~Worker() {
|
| 242 |
+
ChangeState(State::ExitAsSoonAsPossible);
|
| 243 |
+
thread_->join();
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
// Changes State; may be called from either the worker thread
|
| 247 |
+
// or the master thread; however, not all state transitions are legal,
|
| 248 |
+
// which is guarded by assertions.
|
| 249 |
+
void ChangeState(State new_state) {
|
| 250 |
+
std::lock_guard<std::mutex> g(state_mutex_);
|
| 251 |
+
DCHECK(new_state != state_.load(std::memory_order_relaxed));
|
| 252 |
+
switch (state_.load(std::memory_order_relaxed)) {
|
| 253 |
+
case State::ThreadStartup:
|
| 254 |
+
DCHECK(new_state == State::Ready);
|
| 255 |
+
break;
|
| 256 |
+
case State::Ready:
|
| 257 |
+
DCHECK(new_state == State::HasWork || new_state == State::ExitAsSoonAsPossible);
|
| 258 |
+
break;
|
| 259 |
+
case State::HasWork:
|
| 260 |
+
DCHECK(new_state == State::Ready || new_state == State::ExitAsSoonAsPossible);
|
| 261 |
+
break;
|
| 262 |
+
case State::ExitAsSoonAsPossible:
|
| 263 |
+
default:
|
| 264 |
+
abort();
|
| 265 |
+
}
|
| 266 |
+
state_.store(new_state, std::memory_order_relaxed);
|
| 267 |
+
state_cond_.notify_one();
|
| 268 |
+
if (new_state == State::Ready) {
|
| 269 |
+
counter_to_decrement_when_ready_->DecrementCount();
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
// Thread entry point.
|
| 274 |
+
void ThreadFunc() {
|
| 275 |
+
c10::setThreadName("CaffeWorkersPool");
|
| 276 |
+
ChangeState(State::Ready);
|
| 277 |
+
|
| 278 |
+
// Thread main loop
|
| 279 |
+
while (true) {
|
| 280 |
+
// Get a state to act on
|
| 281 |
+
// In the 'Ready' state, we have nothing to do but to wait until
|
| 282 |
+
// we switch to another state.
|
| 283 |
+
State state_to_act_upon =
|
| 284 |
+
WaitForVariableChange(&state_, State::Ready, &state_cond_, &state_mutex_);
|
| 285 |
+
|
| 286 |
+
// We now have a state to act on, so act.
|
| 287 |
+
switch (state_to_act_upon) {
|
| 288 |
+
case State::HasWork:
|
| 289 |
+
// Got work to do! So do it, and then revert to 'Ready' state.
|
| 290 |
+
DCHECK(task_.load());
|
| 291 |
+
(*task_).Run();
|
| 292 |
+
task_ = nullptr;
|
| 293 |
+
ChangeState(State::Ready);
|
| 294 |
+
break;
|
| 295 |
+
case State::ExitAsSoonAsPossible:
|
| 296 |
+
return;
|
| 297 |
+
case State::Ready:
|
| 298 |
+
case State::ThreadStartup:
|
| 299 |
+
default:
|
| 300 |
+
abort();
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
static void* ThreadFunc(void* arg) {
|
| 306 |
+
static_cast<Worker*>(arg)->ThreadFunc();
|
| 307 |
+
return nullptr;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
// Called by the master thread to give this worker work to do.
|
| 311 |
+
// It is only legal to call this if the worker
|
| 312 |
+
void StartWork(Task* task) {
|
| 313 |
+
DCHECK(!task_.load());
|
| 314 |
+
task_ = task;
|
| 315 |
+
DCHECK(state_.load(std::memory_order_acquire) == State::Ready);
|
| 316 |
+
ChangeState(State::HasWork);
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
private:
|
| 320 |
+
// The underlying thread.
|
| 321 |
+
std::unique_ptr<std::thread> thread_;
|
| 322 |
+
|
| 323 |
+
// The task to be worked on.
|
| 324 |
+
std::atomic<Task*> task_;
|
| 325 |
+
|
| 326 |
+
// The condition variable and mutex guarding state changes.
|
| 327 |
+
std::condition_variable state_cond_;
|
| 328 |
+
std::mutex state_mutex_;
|
| 329 |
+
|
| 330 |
+
// The state enum tells if we're currently working, waiting for work, etc.
|
| 331 |
+
std::atomic<State> state_;
|
| 332 |
+
|
| 333 |
+
// pointer to the master's thread BlockingCounter object, to notify the
|
| 334 |
+
// master thread of when this worker switches to the 'Ready' state.
|
| 335 |
+
BlockingCounter* const counter_to_decrement_when_ready_;
|
| 336 |
+
};
|
| 337 |
+
|
| 338 |
+
class WorkersPool {
|
| 339 |
+
public:
|
| 340 |
+
WorkersPool() = default;
|
| 341 |
+
|
| 342 |
+
void Execute(const std::vector<std::shared_ptr<Task>>& tasks) {
|
| 343 |
+
CAFFE_ENFORCE_GE(tasks.size(), 1);
|
| 344 |
+
// One of the tasks will be run on the current thread.
|
| 345 |
+
int workers_count = tasks.size() - 1;
|
| 346 |
+
CreateWorkers(workers_count);
|
| 347 |
+
TORCH_DCHECK_LE(workers_count, (int)workers_.size());
|
| 348 |
+
counter_to_decrement_when_ready_.Reset(workers_count);
|
| 349 |
+
for (const auto task : c10::irange(1, tasks.size())) {
|
| 350 |
+
workers_[task - 1]->StartWork(tasks[task].get());
|
| 351 |
+
}
|
| 352 |
+
// Execute the remaining workload immediately on the current thread.
|
| 353 |
+
auto& task = tasks.front();
|
| 354 |
+
task->Run();
|
| 355 |
+
// Wait for the workers submitted above to finish.
|
| 356 |
+
counter_to_decrement_when_ready_.Wait();
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
private:
|
| 360 |
+
// Ensures that the pool has at least the given count of workers.
|
| 361 |
+
// If any new worker has to be created, this function waits for it to
|
| 362 |
+
// be ready.
|
| 363 |
+
void CreateWorkers(std::size_t workers_count) {
|
| 364 |
+
if (workers_.size() >= workers_count) {
|
| 365 |
+
return;
|
| 366 |
+
}
|
| 367 |
+
counter_to_decrement_when_ready_.Reset(workers_count - workers_.size());
|
| 368 |
+
while (workers_.size() < workers_count) {
|
| 369 |
+
workers_.push_back(MakeAligned<Worker>::make(&counter_to_decrement_when_ready_));
|
| 370 |
+
}
|
| 371 |
+
counter_to_decrement_when_ready_.Wait();
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
C10_DISABLE_COPY_AND_ASSIGN(WorkersPool);
|
| 375 |
+
std::vector<std::unique_ptr<Worker, AlignedDeleter<Worker>>> workers_;
|
| 376 |
+
// The BlockingCounter used to wait for the workers.
|
| 377 |
+
BlockingCounter counter_to_decrement_when_ready_;
|
| 378 |
+
};
|
| 379 |
+
} // namespace caffe2
|
| 380 |
+
|
| 381 |
+
#else
|
| 382 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 383 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/pthreadpool-cpp.h
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#ifdef USE_PTHREADPOOL
|
| 5 |
+
|
| 6 |
+
#ifdef USE_INTERNAL_PTHREADPOOL_IMPL
|
| 7 |
+
#include <caffe2/utils/threadpool/pthreadpool.h>
|
| 8 |
+
#else
|
| 9 |
+
#include <pthreadpool.h>
|
| 10 |
+
#endif
|
| 11 |
+
|
| 12 |
+
#include <functional>
|
| 13 |
+
#include <memory>
|
| 14 |
+
#include <mutex>
|
| 15 |
+
|
| 16 |
+
namespace caffe2 {
|
| 17 |
+
|
| 18 |
+
class PThreadPool final {
|
| 19 |
+
public:
|
| 20 |
+
explicit PThreadPool(size_t thread_count);
|
| 21 |
+
~PThreadPool() = default;
|
| 22 |
+
|
| 23 |
+
PThreadPool(const PThreadPool&) = delete;
|
| 24 |
+
PThreadPool& operator=(const PThreadPool&) = delete;
|
| 25 |
+
|
| 26 |
+
PThreadPool(PThreadPool&&) = delete;
|
| 27 |
+
PThreadPool& operator=(PThreadPool&&) = delete;
|
| 28 |
+
|
| 29 |
+
size_t get_thread_count() const;
|
| 30 |
+
void set_thread_count(size_t thread_count);
|
| 31 |
+
|
| 32 |
+
// Run, in parallel, function fn(task_id) over task_id in range [0, range).
|
| 33 |
+
// This function is blocking. All input is processed by the time it returns.
|
| 34 |
+
void run(const std::function<void(size_t)>& fn, size_t range);
|
| 35 |
+
|
| 36 |
+
private:
|
| 37 |
+
friend pthreadpool_t pthreadpool_();
|
| 38 |
+
|
| 39 |
+
private:
|
| 40 |
+
mutable std::mutex mutex_;
|
| 41 |
+
std::unique_ptr<pthreadpool, decltype(&pthreadpool_destroy)> threadpool_;
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
// Return a singleton instance of PThreadPool for ATen/TH multithreading.
|
| 45 |
+
PThreadPool* pthreadpool();
|
| 46 |
+
PThreadPool* pthreadpool(size_t thread_count);
|
| 47 |
+
|
| 48 |
+
// Exposes the underlying implementation of PThreadPool.
|
| 49 |
+
// Only for use in external libraries so as to unify threading across
|
| 50 |
+
// internal (i.e. ATen, etc.) and external (e.g. NNPACK, QNNPACK, XNNPACK)
|
| 51 |
+
// use cases.
|
| 52 |
+
pthreadpool_t pthreadpool_();
|
| 53 |
+
|
| 54 |
+
} // namespace caffe2
|
| 55 |
+
|
| 56 |
+
#endif /* USE_PTHREADPOOL */
|
| 57 |
+
|
| 58 |
+
#else
|
| 59 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 60 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/pthreadpool.h
ADDED
|
@@ -0,0 +1,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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
// pthreadpool header from https://github.com/Maratyszcza/pthreadpool
|
| 3 |
+
// for NNPACK
|
| 4 |
+
#ifndef CAFFE2_UTILS_PTHREADPOOL_H_
|
| 5 |
+
#define CAFFE2_UTILS_PTHREADPOOL_H_
|
| 6 |
+
|
| 7 |
+
#include "ThreadPoolCommon.h"
|
| 8 |
+
|
| 9 |
+
#include <stddef.h> // for size_t
|
| 10 |
+
#include <stdint.h> // for uint32_t
|
| 11 |
+
|
| 12 |
+
#if defined(USE_PTHREADPOOL)
|
| 13 |
+
// This is a hack.
|
| 14 |
+
// Mainly introduced here because
|
| 15 |
+
// 1. NNPACK can be compiled to use internal legacy threadpool implementation because much of C2 depends on that.
|
| 16 |
+
// 2. Then if we want to use NNPACK in PyTorch, which uses new pthreadpool, then we will supply new pthreadpool pointer
|
| 17 |
+
// to NNPACK. This will not work if NNPACK is compiled with internal legacy threadpool. Thus this guard
|
| 18 |
+
// along with changes in pthreadpool_impl.cc allows us to override that behavior.
|
| 19 |
+
// It enables us to use NNPACK from pytorch using `caffe2::pthreadpool_()`
|
| 20 |
+
namespace caffe2 {
|
| 21 |
+
class WithCastToNewThreadPool {
|
| 22 |
+
public:
|
| 23 |
+
explicit WithCastToNewThreadPool(bool use_new_threadpool);
|
| 24 |
+
~WithCastToNewThreadPool();
|
| 25 |
+
private:
|
| 26 |
+
bool use_new_threadpool_;
|
| 27 |
+
};
|
| 28 |
+
}
|
| 29 |
+
#endif
|
| 30 |
+
|
| 31 |
+
typedef struct pthreadpool* legacy_pthreadpool_t;
|
| 32 |
+
|
| 33 |
+
typedef void (*legacy_pthreadpool_function_1d_t)(void*, size_t);
|
| 34 |
+
typedef void (*legacy_pthreadpool_function_1d_tiled_t)(void*, size_t, size_t);
|
| 35 |
+
typedef void (*legacy_pthreadpool_function_2d_t)(void*, size_t, size_t);
|
| 36 |
+
typedef void (*legacy_pthreadpool_function_2d_tiled_t)(void*, size_t, size_t, size_t, size_t);
|
| 37 |
+
typedef void (*legacy_pthreadpool_function_3d_tiled_t)(
|
| 38 |
+
void*,
|
| 39 |
+
size_t,
|
| 40 |
+
size_t,
|
| 41 |
+
size_t,
|
| 42 |
+
size_t,
|
| 43 |
+
size_t,
|
| 44 |
+
size_t);
|
| 45 |
+
typedef void (*legacy_pthreadpool_function_4d_tiled_t)(
|
| 46 |
+
void*,
|
| 47 |
+
size_t,
|
| 48 |
+
size_t,
|
| 49 |
+
size_t,
|
| 50 |
+
size_t,
|
| 51 |
+
size_t,
|
| 52 |
+
size_t,
|
| 53 |
+
size_t,
|
| 54 |
+
size_t);
|
| 55 |
+
|
| 56 |
+
#ifdef __cplusplus
|
| 57 |
+
extern "C" {
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Creates a thread pool with the specified number of threads.
|
| 62 |
+
*
|
| 63 |
+
* @param[in] threads_count The number of threads in the thread pool.
|
| 64 |
+
* A value of 0 has special interpretation: it creates a thread for each
|
| 65 |
+
* processor core available in the system.
|
| 66 |
+
*
|
| 67 |
+
* @returns A pointer to an opaque thread pool object.
|
| 68 |
+
* On error the function returns NULL and sets errno accordingly.
|
| 69 |
+
*/
|
| 70 |
+
|
| 71 |
+
// Returns internal threadpool impl.
|
| 72 |
+
legacy_pthreadpool_t legacy_pthreadpool_create(size_t threads_count);
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* Queries the number of threads in a thread pool.
|
| 76 |
+
*
|
| 77 |
+
* @param[in] threadpool The thread pool to query.
|
| 78 |
+
*
|
| 79 |
+
* @returns The number of threads in the thread pool.
|
| 80 |
+
*/
|
| 81 |
+
size_t legacy_pthreadpool_get_threads_count(legacy_pthreadpool_t threadpool);
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Processes items in parallel using threads from a thread pool.
|
| 85 |
+
*
|
| 86 |
+
* When the call returns, all items have been processed and the thread pool is
|
| 87 |
+
* ready for a new task.
|
| 88 |
+
*
|
| 89 |
+
* @note If multiple threads call this function with the same thread pool, the
|
| 90 |
+
* calls are serialized.
|
| 91 |
+
*
|
| 92 |
+
* @param[in] threadpool The thread pool to use for parallelisation.
|
| 93 |
+
* @param[in] function The function to call for each item.
|
| 94 |
+
* @param[in] argument The first argument passed to the @a function.
|
| 95 |
+
* @param[in] items The number of items to process. The @a function
|
| 96 |
+
* will be called once for each item.
|
| 97 |
+
*/
|
| 98 |
+
void legacy_pthreadpool_compute_1d(
|
| 99 |
+
legacy_pthreadpool_t threadpool,
|
| 100 |
+
legacy_pthreadpool_function_1d_t function,
|
| 101 |
+
void* argument,
|
| 102 |
+
size_t range);
|
| 103 |
+
|
| 104 |
+
void legacy_pthreadpool_parallelize_1d(
|
| 105 |
+
legacy_pthreadpool_t threadpool,
|
| 106 |
+
legacy_pthreadpool_function_1d_t function,
|
| 107 |
+
void* argument,
|
| 108 |
+
size_t range,
|
| 109 |
+
uint32_t flags);
|
| 110 |
+
|
| 111 |
+
void legacy_pthreadpool_compute_1d_tiled(
|
| 112 |
+
legacy_pthreadpool_t threadpool,
|
| 113 |
+
legacy_pthreadpool_function_1d_tiled_t function,
|
| 114 |
+
void* argument,
|
| 115 |
+
size_t range,
|
| 116 |
+
size_t tile);
|
| 117 |
+
|
| 118 |
+
void legacy_pthreadpool_compute_2d(
|
| 119 |
+
legacy_pthreadpool_t threadpool,
|
| 120 |
+
legacy_pthreadpool_function_2d_t function,
|
| 121 |
+
void* argument,
|
| 122 |
+
size_t range_i,
|
| 123 |
+
size_t range_j);
|
| 124 |
+
|
| 125 |
+
void legacy_pthreadpool_compute_2d_tiled(
|
| 126 |
+
legacy_pthreadpool_t threadpool,
|
| 127 |
+
legacy_pthreadpool_function_2d_tiled_t function,
|
| 128 |
+
void* argument,
|
| 129 |
+
size_t range_i,
|
| 130 |
+
size_t range_j,
|
| 131 |
+
size_t tile_i,
|
| 132 |
+
size_t tile_j);
|
| 133 |
+
|
| 134 |
+
void legacy_pthreadpool_compute_3d_tiled(
|
| 135 |
+
legacy_pthreadpool_t threadpool,
|
| 136 |
+
legacy_pthreadpool_function_3d_tiled_t function,
|
| 137 |
+
void* argument,
|
| 138 |
+
size_t range_i,
|
| 139 |
+
size_t range_j,
|
| 140 |
+
size_t range_k,
|
| 141 |
+
size_t tile_i,
|
| 142 |
+
size_t tile_j,
|
| 143 |
+
size_t tile_k);
|
| 144 |
+
|
| 145 |
+
void legacy_pthreadpool_compute_4d_tiled(
|
| 146 |
+
legacy_pthreadpool_t threadpool,
|
| 147 |
+
legacy_pthreadpool_function_4d_tiled_t function,
|
| 148 |
+
void* argument,
|
| 149 |
+
size_t range_i,
|
| 150 |
+
size_t range_j,
|
| 151 |
+
size_t range_k,
|
| 152 |
+
size_t range_l,
|
| 153 |
+
size_t tile_i,
|
| 154 |
+
size_t tile_j,
|
| 155 |
+
size_t tile_k,
|
| 156 |
+
size_t tile_l);
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* Terminates threads in the thread pool and releases associated resources.
|
| 160 |
+
*
|
| 161 |
+
* @warning Accessing the thread pool after a call to this function constitutes
|
| 162 |
+
* undefined behaviour and may cause data corruption.
|
| 163 |
+
*
|
| 164 |
+
* @param[in,out] threadpool The thread pool to destroy.
|
| 165 |
+
*/
|
| 166 |
+
void legacy_pthreadpool_destroy(legacy_pthreadpool_t threadpool);
|
| 167 |
+
|
| 168 |
+
#ifdef USE_INTERNAL_PTHREADPOOL_IMPL
|
| 169 |
+
|
| 170 |
+
#define pthreadpool_t legacy_pthreadpool_t
|
| 171 |
+
#define pthreadpool_function_1d_t legacy_pthreadpool_function_1d_t
|
| 172 |
+
#define pthreadpool_function_1d_tiled_t legacy_pthreadpool_function_1d_tiled_t
|
| 173 |
+
#define pthreadpool_function_2d_t legacy_pthreadpool_function_2d_t
|
| 174 |
+
#define pthreadpool_function_2d_tiled_t legacy_pthreadpool_function_2d_tiled_t
|
| 175 |
+
#define pthreadpool_function_3d_tiled_t legacy_pthreadpool_function_3d_tiled_t
|
| 176 |
+
#define pthreadpool_function_4d_tiled_t legacy_pthreadpool_function_4d_tiled_t
|
| 177 |
+
#define pthreadpool_create legacy_pthreadpool_create
|
| 178 |
+
#define pthreadpool_destroy legacy_pthreadpool_destroy
|
| 179 |
+
#define pthreadpool_get_threads_count legacy_pthreadpool_get_threads_count
|
| 180 |
+
#define pthreadpool_compute_1d legacy_pthreadpool_compute_1d
|
| 181 |
+
#define pthreadpool_parallelize_1d legacy_pthreadpool_parallelize_1d
|
| 182 |
+
#define pthreadpool_compute_1d_tiled legacy_pthreadpool_compute_1d_tiled
|
| 183 |
+
#define pthreadpool_compute_2d legacy_pthreadpool_compute_2d
|
| 184 |
+
#define pthreadpool_compute_2d_tiled legacy_pthreadpool_compute_2d_tiled
|
| 185 |
+
#define pthreadpool_compute_3d_tiled legacy_pthreadpool_compute_3d_tiled
|
| 186 |
+
#define pthreadpool_compute_4d_tiled legacy_pthreadpool_compute_4d_tiled
|
| 187 |
+
|
| 188 |
+
#endif /* USE_INTERNAL_PTHREADPOOL_IMPL */
|
| 189 |
+
|
| 190 |
+
#ifdef __cplusplus
|
| 191 |
+
} /* extern "C" */
|
| 192 |
+
#endif
|
| 193 |
+
|
| 194 |
+
#endif // CAFFE2_UTILS_PTHREADPOOL_H_
|
| 195 |
+
|
| 196 |
+
#else
|
| 197 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 198 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/caffe2/utils/threadpool/thread_pool_guard.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
|
| 4 |
+
#include <c10/macros/Macros.h>
|
| 5 |
+
|
| 6 |
+
namespace caffe2 {
|
| 7 |
+
|
| 8 |
+
// A RAII, thread local (!) guard that enables or disables grad mode upon
|
| 9 |
+
// construction, and sets it back to the original value upon destruction.
|
| 10 |
+
struct TORCH_API _NoPThreadPoolGuard {
|
| 11 |
+
static bool is_enabled();
|
| 12 |
+
static void set_enabled(bool enabled);
|
| 13 |
+
|
| 14 |
+
_NoPThreadPoolGuard(): prev_mode_(_NoPThreadPoolGuard::is_enabled()) {
|
| 15 |
+
_NoPThreadPoolGuard::set_enabled(true);
|
| 16 |
+
}
|
| 17 |
+
~_NoPThreadPoolGuard() {
|
| 18 |
+
_NoPThreadPoolGuard::set_enabled(prev_mode_);
|
| 19 |
+
}
|
| 20 |
+
private:
|
| 21 |
+
bool prev_mode_;
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
#else
|
| 27 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 28 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/clog.h
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*
|
| 3 |
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
| 4 |
+
* All rights reserved.
|
| 5 |
+
*
|
| 6 |
+
* This source code is licensed under the BSD-style license found in the
|
| 7 |
+
* LICENSE file in the root directory of this source tree.
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#pragma once
|
| 11 |
+
|
| 12 |
+
#include <inttypes.h>
|
| 13 |
+
#include <stdarg.h>
|
| 14 |
+
#include <stdlib.h>
|
| 15 |
+
|
| 16 |
+
#define CLOG_NONE 0
|
| 17 |
+
#define CLOG_FATAL 1
|
| 18 |
+
#define CLOG_ERROR 2
|
| 19 |
+
#define CLOG_WARNING 3
|
| 20 |
+
#define CLOG_INFO 4
|
| 21 |
+
#define CLOG_DEBUG 5
|
| 22 |
+
|
| 23 |
+
#ifndef CLOG_VISIBILITY
|
| 24 |
+
#if defined(__ELF__)
|
| 25 |
+
#define CLOG_VISIBILITY __attribute__((__visibility__("internal")))
|
| 26 |
+
#elif defined(__MACH__)
|
| 27 |
+
#define CLOG_VISIBILITY __attribute__((__visibility__("hidden")))
|
| 28 |
+
#else
|
| 29 |
+
#define CLOG_VISIBILITY
|
| 30 |
+
#endif
|
| 31 |
+
#endif
|
| 32 |
+
|
| 33 |
+
#ifndef CLOG_ARGUMENTS_FORMAT
|
| 34 |
+
#if defined(__GNUC__)
|
| 35 |
+
#define CLOG_ARGUMENTS_FORMAT __attribute__((__format__(__printf__, 1, 2)))
|
| 36 |
+
#else
|
| 37 |
+
#define CLOG_ARGUMENTS_FORMAT
|
| 38 |
+
#endif
|
| 39 |
+
#endif
|
| 40 |
+
|
| 41 |
+
#ifdef __cplusplus
|
| 42 |
+
extern "C" {
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
CLOG_VISIBILITY void clog_vlog_debug(
|
| 46 |
+
const char* module,
|
| 47 |
+
const char* format,
|
| 48 |
+
va_list args);
|
| 49 |
+
CLOG_VISIBILITY void clog_vlog_info(
|
| 50 |
+
const char* module,
|
| 51 |
+
const char* format,
|
| 52 |
+
va_list args);
|
| 53 |
+
CLOG_VISIBILITY void clog_vlog_warning(
|
| 54 |
+
const char* module,
|
| 55 |
+
const char* format,
|
| 56 |
+
va_list args);
|
| 57 |
+
CLOG_VISIBILITY void clog_vlog_error(
|
| 58 |
+
const char* module,
|
| 59 |
+
const char* format,
|
| 60 |
+
va_list args);
|
| 61 |
+
CLOG_VISIBILITY void clog_vlog_fatal(
|
| 62 |
+
const char* module,
|
| 63 |
+
const char* format,
|
| 64 |
+
va_list args);
|
| 65 |
+
|
| 66 |
+
#define CLOG_DEFINE_LOG_DEBUG(log_debug_function_name, module, level) \
|
| 67 |
+
CLOG_ARGUMENTS_FORMAT \
|
| 68 |
+
inline static void log_debug_function_name(const char* format, ...) { \
|
| 69 |
+
if (level >= CLOG_DEBUG) { \
|
| 70 |
+
va_list args; \
|
| 71 |
+
va_start(args, format); \
|
| 72 |
+
clog_vlog_debug(module, format, args); \
|
| 73 |
+
va_end(args); \
|
| 74 |
+
} \
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
#define CLOG_DEFINE_LOG_INFO(log_info_function_name, module, level) \
|
| 78 |
+
CLOG_ARGUMENTS_FORMAT \
|
| 79 |
+
inline static void log_info_function_name(const char* format, ...) { \
|
| 80 |
+
if (level >= CLOG_INFO) { \
|
| 81 |
+
va_list args; \
|
| 82 |
+
va_start(args, format); \
|
| 83 |
+
clog_vlog_info(module, format, args); \
|
| 84 |
+
va_end(args); \
|
| 85 |
+
} \
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
#define CLOG_DEFINE_LOG_WARNING(log_warning_function_name, module, level) \
|
| 89 |
+
CLOG_ARGUMENTS_FORMAT \
|
| 90 |
+
inline static void log_warning_function_name(const char* format, ...) { \
|
| 91 |
+
if (level >= CLOG_WARNING) { \
|
| 92 |
+
va_list args; \
|
| 93 |
+
va_start(args, format); \
|
| 94 |
+
clog_vlog_warning(module, format, args); \
|
| 95 |
+
va_end(args); \
|
| 96 |
+
} \
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
#define CLOG_DEFINE_LOG_ERROR(log_error_function_name, module, level) \
|
| 100 |
+
CLOG_ARGUMENTS_FORMAT \
|
| 101 |
+
inline static void log_error_function_name(const char* format, ...) { \
|
| 102 |
+
if (level >= CLOG_ERROR) { \
|
| 103 |
+
va_list args; \
|
| 104 |
+
va_start(args, format); \
|
| 105 |
+
clog_vlog_error(module, format, args); \
|
| 106 |
+
va_end(args); \
|
| 107 |
+
} \
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
#define CLOG_DEFINE_LOG_FATAL(log_fatal_function_name, module, level) \
|
| 111 |
+
CLOG_ARGUMENTS_FORMAT \
|
| 112 |
+
inline static void log_fatal_function_name(const char* format, ...) { \
|
| 113 |
+
if (level >= CLOG_FATAL) { \
|
| 114 |
+
va_list args; \
|
| 115 |
+
va_start(args, format); \
|
| 116 |
+
clog_vlog_fatal(module, format, args); \
|
| 117 |
+
va_end(args); \
|
| 118 |
+
} \
|
| 119 |
+
abort(); \
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
#ifdef __cplusplus
|
| 123 |
+
} /* extern "C" */
|
| 124 |
+
#endif
|
| 125 |
+
|
| 126 |
+
#else
|
| 127 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 128 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/cpuinfo.h
ADDED
|
@@ -0,0 +1,2366 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
#pragma once
|
| 3 |
+
#ifndef CPUINFO_H
|
| 4 |
+
#define CPUINFO_H
|
| 5 |
+
|
| 6 |
+
#ifndef __cplusplus
|
| 7 |
+
#include <stdbool.h>
|
| 8 |
+
#endif
|
| 9 |
+
|
| 10 |
+
#ifdef __APPLE__
|
| 11 |
+
#include <TargetConditionals.h>
|
| 12 |
+
#endif
|
| 13 |
+
|
| 14 |
+
#include <stdint.h>
|
| 15 |
+
|
| 16 |
+
/* Identify architecture and define corresponding macro */
|
| 17 |
+
|
| 18 |
+
#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86)
|
| 19 |
+
#define CPUINFO_ARCH_X86 1
|
| 20 |
+
#endif
|
| 21 |
+
|
| 22 |
+
#if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
|
| 23 |
+
#define CPUINFO_ARCH_X86_64 1
|
| 24 |
+
#endif
|
| 25 |
+
|
| 26 |
+
#if defined(__arm__) || defined(_M_ARM)
|
| 27 |
+
#define CPUINFO_ARCH_ARM 1
|
| 28 |
+
#endif
|
| 29 |
+
|
| 30 |
+
#if defined(__aarch64__) || defined(_M_ARM64)
|
| 31 |
+
#define CPUINFO_ARCH_ARM64 1
|
| 32 |
+
#endif
|
| 33 |
+
|
| 34 |
+
#if defined(__PPC64__) || defined(__powerpc64__) || defined(_ARCH_PPC64)
|
| 35 |
+
#define CPUINFO_ARCH_PPC64 1
|
| 36 |
+
#endif
|
| 37 |
+
|
| 38 |
+
#if defined(__asmjs__)
|
| 39 |
+
#define CPUINFO_ARCH_ASMJS 1
|
| 40 |
+
#endif
|
| 41 |
+
|
| 42 |
+
#if defined(__wasm__)
|
| 43 |
+
#if defined(__wasm_simd128__)
|
| 44 |
+
#define CPUINFO_ARCH_WASMSIMD 1
|
| 45 |
+
#else
|
| 46 |
+
#define CPUINFO_ARCH_WASM 1
|
| 47 |
+
#endif
|
| 48 |
+
#endif
|
| 49 |
+
|
| 50 |
+
#if defined(__riscv)
|
| 51 |
+
#if (__riscv_xlen == 32)
|
| 52 |
+
#define CPUINFO_ARCH_RISCV32 1
|
| 53 |
+
#elif (__riscv_xlen == 64)
|
| 54 |
+
#define CPUINFO_ARCH_RISCV64 1
|
| 55 |
+
#endif
|
| 56 |
+
#endif
|
| 57 |
+
|
| 58 |
+
/* Define other architecture-specific macros as 0 */
|
| 59 |
+
|
| 60 |
+
#ifndef CPUINFO_ARCH_X86
|
| 61 |
+
#define CPUINFO_ARCH_X86 0
|
| 62 |
+
#endif
|
| 63 |
+
|
| 64 |
+
#ifndef CPUINFO_ARCH_X86_64
|
| 65 |
+
#define CPUINFO_ARCH_X86_64 0
|
| 66 |
+
#endif
|
| 67 |
+
|
| 68 |
+
#ifndef CPUINFO_ARCH_ARM
|
| 69 |
+
#define CPUINFO_ARCH_ARM 0
|
| 70 |
+
#endif
|
| 71 |
+
|
| 72 |
+
#ifndef CPUINFO_ARCH_ARM64
|
| 73 |
+
#define CPUINFO_ARCH_ARM64 0
|
| 74 |
+
#endif
|
| 75 |
+
|
| 76 |
+
#ifndef CPUINFO_ARCH_PPC64
|
| 77 |
+
#define CPUINFO_ARCH_PPC64 0
|
| 78 |
+
#endif
|
| 79 |
+
|
| 80 |
+
#ifndef CPUINFO_ARCH_ASMJS
|
| 81 |
+
#define CPUINFO_ARCH_ASMJS 0
|
| 82 |
+
#endif
|
| 83 |
+
|
| 84 |
+
#ifndef CPUINFO_ARCH_WASM
|
| 85 |
+
#define CPUINFO_ARCH_WASM 0
|
| 86 |
+
#endif
|
| 87 |
+
|
| 88 |
+
#ifndef CPUINFO_ARCH_WASMSIMD
|
| 89 |
+
#define CPUINFO_ARCH_WASMSIMD 0
|
| 90 |
+
#endif
|
| 91 |
+
|
| 92 |
+
#ifndef CPUINFO_ARCH_RISCV32
|
| 93 |
+
#define CPUINFO_ARCH_RISCV32 0
|
| 94 |
+
#endif
|
| 95 |
+
|
| 96 |
+
#ifndef CPUINFO_ARCH_RISCV64
|
| 97 |
+
#define CPUINFO_ARCH_RISCV64 0
|
| 98 |
+
#endif
|
| 99 |
+
|
| 100 |
+
#if CPUINFO_ARCH_X86 && defined(_MSC_VER)
|
| 101 |
+
#define CPUINFO_ABI __cdecl
|
| 102 |
+
#elif CPUINFO_ARCH_X86 && defined(__GNUC__)
|
| 103 |
+
#define CPUINFO_ABI __attribute__((__cdecl__))
|
| 104 |
+
#else
|
| 105 |
+
#define CPUINFO_ABI
|
| 106 |
+
#endif
|
| 107 |
+
|
| 108 |
+
#define CPUINFO_CACHE_UNIFIED 0x00000001
|
| 109 |
+
#define CPUINFO_CACHE_INCLUSIVE 0x00000002
|
| 110 |
+
#define CPUINFO_CACHE_COMPLEX_INDEXING 0x00000004
|
| 111 |
+
|
| 112 |
+
struct cpuinfo_cache {
|
| 113 |
+
/** Cache size in bytes */
|
| 114 |
+
uint32_t size;
|
| 115 |
+
/** Number of ways of associativity */
|
| 116 |
+
uint32_t associativity;
|
| 117 |
+
/** Number of sets */
|
| 118 |
+
uint32_t sets;
|
| 119 |
+
/** Number of partitions */
|
| 120 |
+
uint32_t partitions;
|
| 121 |
+
/** Line size in bytes */
|
| 122 |
+
uint32_t line_size;
|
| 123 |
+
/**
|
| 124 |
+
* Binary characteristics of the cache (unified cache, inclusive cache,
|
| 125 |
+
* cache with complex indexing).
|
| 126 |
+
*
|
| 127 |
+
* @see CPUINFO_CACHE_UNIFIED, CPUINFO_CACHE_INCLUSIVE,
|
| 128 |
+
* CPUINFO_CACHE_COMPLEX_INDEXING
|
| 129 |
+
*/
|
| 130 |
+
uint32_t flags;
|
| 131 |
+
/** Index of the first logical processor that shares this cache */
|
| 132 |
+
uint32_t processor_start;
|
| 133 |
+
/** Number of logical processors that share this cache */
|
| 134 |
+
uint32_t processor_count;
|
| 135 |
+
};
|
| 136 |
+
|
| 137 |
+
struct cpuinfo_trace_cache {
|
| 138 |
+
uint32_t uops;
|
| 139 |
+
uint32_t associativity;
|
| 140 |
+
};
|
| 141 |
+
|
| 142 |
+
#define CPUINFO_PAGE_SIZE_4KB 0x1000
|
| 143 |
+
#define CPUINFO_PAGE_SIZE_1MB 0x100000
|
| 144 |
+
#define CPUINFO_PAGE_SIZE_2MB 0x200000
|
| 145 |
+
#define CPUINFO_PAGE_SIZE_4MB 0x400000
|
| 146 |
+
#define CPUINFO_PAGE_SIZE_16MB 0x1000000
|
| 147 |
+
#define CPUINFO_PAGE_SIZE_1GB 0x40000000
|
| 148 |
+
|
| 149 |
+
struct cpuinfo_tlb {
|
| 150 |
+
uint32_t entries;
|
| 151 |
+
uint32_t associativity;
|
| 152 |
+
uint64_t pages;
|
| 153 |
+
};
|
| 154 |
+
|
| 155 |
+
/** Vendor of processor core design */
|
| 156 |
+
enum cpuinfo_vendor {
|
| 157 |
+
/** Processor vendor is not known to the library, or the library failed
|
| 158 |
+
to get vendor information from the OS. */
|
| 159 |
+
cpuinfo_vendor_unknown = 0,
|
| 160 |
+
|
| 161 |
+
/* Active vendors of modern CPUs */
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* Intel Corporation. Vendor of x86, x86-64, IA64, and ARM processor
|
| 165 |
+
* microarchitectures.
|
| 166 |
+
*
|
| 167 |
+
* Sold its ARM design subsidiary in 2006. The last ARM processor design
|
| 168 |
+
* was released in 2004.
|
| 169 |
+
*/
|
| 170 |
+
cpuinfo_vendor_intel = 1,
|
| 171 |
+
/** Advanced Micro Devices, Inc. Vendor of x86 and x86-64 processor
|
| 172 |
+
microarchitectures. */
|
| 173 |
+
cpuinfo_vendor_amd = 2,
|
| 174 |
+
/** ARM Holdings plc. Vendor of ARM and ARM64 processor
|
| 175 |
+
microarchitectures. */
|
| 176 |
+
cpuinfo_vendor_arm = 3,
|
| 177 |
+
/** Qualcomm Incorporated. Vendor of ARM and ARM64 processor
|
| 178 |
+
microarchitectures. */
|
| 179 |
+
cpuinfo_vendor_qualcomm = 4,
|
| 180 |
+
/** Apple Inc. Vendor of ARM and ARM64 processor microarchitectures. */
|
| 181 |
+
cpuinfo_vendor_apple = 5,
|
| 182 |
+
/** Samsung Electronics Co., Ltd. Vendir if ARM64 processor
|
| 183 |
+
microarchitectures. */
|
| 184 |
+
cpuinfo_vendor_samsung = 6,
|
| 185 |
+
/** Nvidia Corporation. Vendor of ARM64-compatible processor
|
| 186 |
+
microarchitectures. */
|
| 187 |
+
cpuinfo_vendor_nvidia = 7,
|
| 188 |
+
/** MIPS Technologies, Inc. Vendor of MIPS processor microarchitectures.
|
| 189 |
+
*/
|
| 190 |
+
cpuinfo_vendor_mips = 8,
|
| 191 |
+
/** International Business Machines Corporation. Vendor of PowerPC
|
| 192 |
+
processor microarchitectures. */
|
| 193 |
+
cpuinfo_vendor_ibm = 9,
|
| 194 |
+
/** Ingenic Semiconductor. Vendor of MIPS processor microarchitectures.
|
| 195 |
+
*/
|
| 196 |
+
cpuinfo_vendor_ingenic = 10,
|
| 197 |
+
/**
|
| 198 |
+
* VIA Technologies, Inc. Vendor of x86 and x86-64 processor
|
| 199 |
+
* microarchitectures.
|
| 200 |
+
*
|
| 201 |
+
* Processors are designed by Centaur Technology, a subsidiary of VIA
|
| 202 |
+
* Technologies.
|
| 203 |
+
*/
|
| 204 |
+
cpuinfo_vendor_via = 11,
|
| 205 |
+
/** Cavium, Inc. Vendor of ARM64 processor microarchitectures. */
|
| 206 |
+
cpuinfo_vendor_cavium = 12,
|
| 207 |
+
/** Broadcom, Inc. Vendor of ARM processor microarchitectures. */
|
| 208 |
+
cpuinfo_vendor_broadcom = 13,
|
| 209 |
+
/** Applied Micro Circuits Corporation (APM). Vendor of ARM64 processor
|
| 210 |
+
microarchitectures. */
|
| 211 |
+
cpuinfo_vendor_apm = 14,
|
| 212 |
+
/**
|
| 213 |
+
* Huawei Technologies Co., Ltd. Vendor of ARM64 processor
|
| 214 |
+
* microarchitectures.
|
| 215 |
+
*
|
| 216 |
+
* Processors are designed by HiSilicon, a subsidiary of Huawei.
|
| 217 |
+
*/
|
| 218 |
+
cpuinfo_vendor_huawei = 15,
|
| 219 |
+
/**
|
| 220 |
+
* Hygon (Chengdu Haiguang Integrated Circuit Design Co., Ltd), Vendor
|
| 221 |
+
* of x86-64 processor microarchitectures.
|
| 222 |
+
*
|
| 223 |
+
* Processors are variants of AMD cores.
|
| 224 |
+
*/
|
| 225 |
+
cpuinfo_vendor_hygon = 16,
|
| 226 |
+
/** SiFive, Inc. Vendor of RISC-V processor microarchitectures. */
|
| 227 |
+
cpuinfo_vendor_sifive = 17,
|
| 228 |
+
|
| 229 |
+
/* Active vendors of embedded CPUs */
|
| 230 |
+
|
| 231 |
+
/** Texas Instruments Inc. Vendor of ARM processor microarchitectures.
|
| 232 |
+
*/
|
| 233 |
+
cpuinfo_vendor_texas_instruments = 30,
|
| 234 |
+
/** Marvell Technology Group Ltd. Vendor of ARM processor
|
| 235 |
+
* microarchitectures.
|
| 236 |
+
*/
|
| 237 |
+
cpuinfo_vendor_marvell = 31,
|
| 238 |
+
/** RDC Semiconductor Co., Ltd. Vendor of x86 processor
|
| 239 |
+
microarchitectures. */
|
| 240 |
+
cpuinfo_vendor_rdc = 32,
|
| 241 |
+
/** DM&P Electronics Inc. Vendor of x86 processor microarchitectures. */
|
| 242 |
+
cpuinfo_vendor_dmp = 33,
|
| 243 |
+
/** Motorola, Inc. Vendor of PowerPC and ARM processor
|
| 244 |
+
microarchitectures. */
|
| 245 |
+
cpuinfo_vendor_motorola = 34,
|
| 246 |
+
|
| 247 |
+
/* Defunct CPU vendors */
|
| 248 |
+
|
| 249 |
+
/**
|
| 250 |
+
* Transmeta Corporation. Vendor of x86 processor microarchitectures.
|
| 251 |
+
*
|
| 252 |
+
* Now defunct. The last processor design was released in 2004.
|
| 253 |
+
* Transmeta processors implemented VLIW ISA and used binary translation
|
| 254 |
+
* to execute x86 code.
|
| 255 |
+
*/
|
| 256 |
+
cpuinfo_vendor_transmeta = 50,
|
| 257 |
+
/**
|
| 258 |
+
* Cyrix Corporation. Vendor of x86 processor microarchitectures.
|
| 259 |
+
*
|
| 260 |
+
* Now defunct. The last processor design was released in 1996.
|
| 261 |
+
*/
|
| 262 |
+
cpuinfo_vendor_cyrix = 51,
|
| 263 |
+
/**
|
| 264 |
+
* Rise Technology. Vendor of x86 processor microarchitectures.
|
| 265 |
+
*
|
| 266 |
+
* Now defunct. The last processor design was released in 1999.
|
| 267 |
+
*/
|
| 268 |
+
cpuinfo_vendor_rise = 52,
|
| 269 |
+
/**
|
| 270 |
+
* National Semiconductor. Vendor of x86 processor microarchitectures.
|
| 271 |
+
*
|
| 272 |
+
* Sold its x86 design subsidiary in 1999. The last processor design was
|
| 273 |
+
* released in 1998.
|
| 274 |
+
*/
|
| 275 |
+
cpuinfo_vendor_nsc = 53,
|
| 276 |
+
/**
|
| 277 |
+
* Silicon Integrated Systems. Vendor of x86 processor
|
| 278 |
+
* microarchitectures.
|
| 279 |
+
*
|
| 280 |
+
* Sold its x86 design subsidiary in 2001. The last processor design was
|
| 281 |
+
* released in 2001.
|
| 282 |
+
*/
|
| 283 |
+
cpuinfo_vendor_sis = 54,
|
| 284 |
+
/**
|
| 285 |
+
* NexGen. Vendor of x86 processor microarchitectures.
|
| 286 |
+
*
|
| 287 |
+
* Now defunct. The last processor design was released in 1994.
|
| 288 |
+
* NexGen designed the first x86 microarchitecture which decomposed x86
|
| 289 |
+
* instructions into simple microoperations.
|
| 290 |
+
*/
|
| 291 |
+
cpuinfo_vendor_nexgen = 55,
|
| 292 |
+
/**
|
| 293 |
+
* United Microelectronics Corporation. Vendor of x86 processor
|
| 294 |
+
* microarchitectures.
|
| 295 |
+
*
|
| 296 |
+
* Ceased x86 in the early 1990s. The last processor design was released
|
| 297 |
+
* in 1991. Designed U5C and U5D processors. Both are 486 level.
|
| 298 |
+
*/
|
| 299 |
+
cpuinfo_vendor_umc = 56,
|
| 300 |
+
/**
|
| 301 |
+
* Digital Equipment Corporation. Vendor of ARM processor
|
| 302 |
+
* microarchitecture.
|
| 303 |
+
*
|
| 304 |
+
* Sold its ARM designs in 1997. The last processor design was released
|
| 305 |
+
* in 1997.
|
| 306 |
+
*/
|
| 307 |
+
cpuinfo_vendor_dec = 57,
|
| 308 |
+
};
|
| 309 |
+
|
| 310 |
+
/**
|
| 311 |
+
* Processor microarchitecture
|
| 312 |
+
*
|
| 313 |
+
* Processors with different microarchitectures often have different instruction
|
| 314 |
+
* performance characteristics, and may have dramatically different pipeline
|
| 315 |
+
* organization.
|
| 316 |
+
*/
|
| 317 |
+
enum cpuinfo_uarch {
|
| 318 |
+
/** Microarchitecture is unknown, or the library failed to get
|
| 319 |
+
information about the microarchitecture from OS */
|
| 320 |
+
cpuinfo_uarch_unknown = 0,
|
| 321 |
+
|
| 322 |
+
/** Pentium and Pentium MMX microarchitecture. */
|
| 323 |
+
cpuinfo_uarch_p5 = 0x00100100,
|
| 324 |
+
/** Intel Quark microarchitecture. */
|
| 325 |
+
cpuinfo_uarch_quark = 0x00100101,
|
| 326 |
+
|
| 327 |
+
/** Pentium Pro, Pentium II, and Pentium III. */
|
| 328 |
+
cpuinfo_uarch_p6 = 0x00100200,
|
| 329 |
+
/** Pentium M. */
|
| 330 |
+
cpuinfo_uarch_dothan = 0x00100201,
|
| 331 |
+
/** Intel Core microarchitecture. */
|
| 332 |
+
cpuinfo_uarch_yonah = 0x00100202,
|
| 333 |
+
/** Intel Core 2 microarchitecture on 65 nm process. */
|
| 334 |
+
cpuinfo_uarch_conroe = 0x00100203,
|
| 335 |
+
/** Intel Core 2 microarchitecture on 45 nm process. */
|
| 336 |
+
cpuinfo_uarch_penryn = 0x00100204,
|
| 337 |
+
/** Intel Nehalem and Westmere microarchitectures (Core i3/i5/i7 1st
|
| 338 |
+
gen). */
|
| 339 |
+
cpuinfo_uarch_nehalem = 0x00100205,
|
| 340 |
+
/** Intel Sandy Bridge microarchitecture (Core i3/i5/i7 2nd gen). */
|
| 341 |
+
cpuinfo_uarch_sandy_bridge = 0x00100206,
|
| 342 |
+
/** Intel Ivy Bridge microarchitecture (Core i3/i5/i7 3rd gen). */
|
| 343 |
+
cpuinfo_uarch_ivy_bridge = 0x00100207,
|
| 344 |
+
/** Intel Haswell microarchitecture (Core i3/i5/i7 4th gen). */
|
| 345 |
+
cpuinfo_uarch_haswell = 0x00100208,
|
| 346 |
+
/** Intel Broadwell microarchitecture. */
|
| 347 |
+
cpuinfo_uarch_broadwell = 0x00100209,
|
| 348 |
+
/** Intel Sky Lake microarchitecture (14 nm, including
|
| 349 |
+
Kaby/Coffee/Whiskey/Amber/Comet/Cascade/Cooper Lake). */
|
| 350 |
+
cpuinfo_uarch_sky_lake = 0x0010020A,
|
| 351 |
+
/** DEPRECATED (Intel Kaby Lake microarchitecture). */
|
| 352 |
+
cpuinfo_uarch_kaby_lake = 0x0010020A,
|
| 353 |
+
/** Intel Palm Cove microarchitecture (10 nm, Cannon Lake). */
|
| 354 |
+
cpuinfo_uarch_palm_cove = 0x0010020B,
|
| 355 |
+
/** Intel Sunny Cove microarchitecture (10 nm, Ice Lake). */
|
| 356 |
+
cpuinfo_uarch_sunny_cove = 0x0010020C,
|
| 357 |
+
/** Intel Willow Cove microarchitecture (10 nm, Tiger Lake). */
|
| 358 |
+
cpuinfo_uarch_willow_cove = 0x0010020D,
|
| 359 |
+
|
| 360 |
+
/** Pentium 4 with Willamette, Northwood, or Foster cores. */
|
| 361 |
+
cpuinfo_uarch_willamette = 0x00100300,
|
| 362 |
+
/** Pentium 4 with Prescott and later cores. */
|
| 363 |
+
cpuinfo_uarch_prescott = 0x00100301,
|
| 364 |
+
|
| 365 |
+
/** Intel Atom on 45 nm process. */
|
| 366 |
+
cpuinfo_uarch_bonnell = 0x00100400,
|
| 367 |
+
/** Intel Atom on 32 nm process. */
|
| 368 |
+
cpuinfo_uarch_saltwell = 0x00100401,
|
| 369 |
+
/** Intel Silvermont microarchitecture (22 nm out-of-order Atom). */
|
| 370 |
+
cpuinfo_uarch_silvermont = 0x00100402,
|
| 371 |
+
/** Intel Airmont microarchitecture (14 nm out-of-order Atom). */
|
| 372 |
+
cpuinfo_uarch_airmont = 0x00100403,
|
| 373 |
+
/** Intel Goldmont microarchitecture (Denverton, Apollo Lake). */
|
| 374 |
+
cpuinfo_uarch_goldmont = 0x00100404,
|
| 375 |
+
/** Intel Goldmont Plus microarchitecture (Gemini Lake). */
|
| 376 |
+
cpuinfo_uarch_goldmont_plus = 0x00100405,
|
| 377 |
+
/** Intel Airmont microarchitecture (10 nm out-of-order Atom). */
|
| 378 |
+
cpuinfo_uarch_tremont = 0x00100406,
|
| 379 |
+
/** Intel Gracemont microarchitecture (AlderLake N). */
|
| 380 |
+
cpuinfo_uarch_gracemont = 0x00100407,
|
| 381 |
+
/** Intel Crestmont microarchitecture (Sierra Forest). */
|
| 382 |
+
cpuinfo_uarch_crestmont = 0x00100408,
|
| 383 |
+
/** Intel Darkmont microarchitecture (e-core used in Clearwater Forest). */
|
| 384 |
+
cpuinfo_uarch_darkmont = 0x00100409,
|
| 385 |
+
|
| 386 |
+
/** Intel Knights Ferry HPC boards. */
|
| 387 |
+
cpuinfo_uarch_knights_ferry = 0x00100500,
|
| 388 |
+
/** Intel Knights Corner HPC boards (aka Xeon Phi). */
|
| 389 |
+
cpuinfo_uarch_knights_corner = 0x00100501,
|
| 390 |
+
/** Intel Knights Landing microarchitecture (second-gen MIC). */
|
| 391 |
+
cpuinfo_uarch_knights_landing = 0x00100502,
|
| 392 |
+
/** Intel Knights Hill microarchitecture (third-gen MIC). */
|
| 393 |
+
cpuinfo_uarch_knights_hill = 0x00100503,
|
| 394 |
+
/** Intel Knights Mill Xeon Phi. */
|
| 395 |
+
cpuinfo_uarch_knights_mill = 0x00100504,
|
| 396 |
+
|
| 397 |
+
/** Intel/Marvell XScale series. */
|
| 398 |
+
cpuinfo_uarch_xscale = 0x00100600,
|
| 399 |
+
|
| 400 |
+
/** AMD K5. */
|
| 401 |
+
cpuinfo_uarch_k5 = 0x00200100,
|
| 402 |
+
/** AMD K6 and alike. */
|
| 403 |
+
cpuinfo_uarch_k6 = 0x00200101,
|
| 404 |
+
/** AMD Athlon and Duron. */
|
| 405 |
+
cpuinfo_uarch_k7 = 0x00200102,
|
| 406 |
+
/** AMD Athlon 64, Opteron 64. */
|
| 407 |
+
cpuinfo_uarch_k8 = 0x00200103,
|
| 408 |
+
/** AMD Family 10h (Barcelona, Istambul, Magny-Cours). */
|
| 409 |
+
cpuinfo_uarch_k10 = 0x00200104,
|
| 410 |
+
/**
|
| 411 |
+
* AMD Bulldozer microarchitecture
|
| 412 |
+
* Zambezi FX-series CPUs, Zurich, Valencia and Interlagos Opteron CPUs.
|
| 413 |
+
*/
|
| 414 |
+
cpuinfo_uarch_bulldozer = 0x00200105,
|
| 415 |
+
/**
|
| 416 |
+
* AMD Piledriver microarchitecture
|
| 417 |
+
* Vishera FX-series CPUs, Trinity and Richland APUs, Delhi, Seoul, Abu
|
| 418 |
+
* Dhabi Opteron CPUs.
|
| 419 |
+
*/
|
| 420 |
+
cpuinfo_uarch_piledriver = 0x00200106,
|
| 421 |
+
/** AMD Steamroller microarchitecture (Kaveri APUs). */
|
| 422 |
+
cpuinfo_uarch_steamroller = 0x00200107,
|
| 423 |
+
/** AMD Excavator microarchitecture (Carizzo APUs). */
|
| 424 |
+
cpuinfo_uarch_excavator = 0x00200108,
|
| 425 |
+
/** AMD Zen microarchitecture (12/14 nm Ryzen and EPYC CPUs). */
|
| 426 |
+
cpuinfo_uarch_zen = 0x00200109,
|
| 427 |
+
/** AMD Zen 2 microarchitecture (7 nm Ryzen and EPYC CPUs). */
|
| 428 |
+
cpuinfo_uarch_zen2 = 0x0020010A,
|
| 429 |
+
/** AMD Zen 3 microarchitecture. */
|
| 430 |
+
cpuinfo_uarch_zen3 = 0x0020010B,
|
| 431 |
+
/** AMD Zen 4 microarchitecture. */
|
| 432 |
+
cpuinfo_uarch_zen4 = 0x0020010C,
|
| 433 |
+
/** AMD Zen 5 microarchitecture. */
|
| 434 |
+
cpuinfo_uarch_zen5 = 0x0020010D,
|
| 435 |
+
|
| 436 |
+
/** NSC Geode and AMD Geode GX and LX. */
|
| 437 |
+
cpuinfo_uarch_geode = 0x00200200,
|
| 438 |
+
/** AMD Bobcat mobile microarchitecture. */
|
| 439 |
+
cpuinfo_uarch_bobcat = 0x00200201,
|
| 440 |
+
/** AMD Jaguar mobile microarchitecture. */
|
| 441 |
+
cpuinfo_uarch_jaguar = 0x00200202,
|
| 442 |
+
/** AMD Puma mobile microarchitecture. */
|
| 443 |
+
cpuinfo_uarch_puma = 0x00200203,
|
| 444 |
+
|
| 445 |
+
/** ARM7 series. */
|
| 446 |
+
cpuinfo_uarch_arm7 = 0x00300100,
|
| 447 |
+
/** ARM9 series. */
|
| 448 |
+
cpuinfo_uarch_arm9 = 0x00300101,
|
| 449 |
+
/** ARM 1136, ARM 1156, ARM 1176, or ARM 11MPCore. */
|
| 450 |
+
cpuinfo_uarch_arm11 = 0x00300102,
|
| 451 |
+
|
| 452 |
+
/** ARM Cortex-A5. */
|
| 453 |
+
cpuinfo_uarch_cortex_a5 = 0x00300205,
|
| 454 |
+
/** ARM Cortex-A7. */
|
| 455 |
+
cpuinfo_uarch_cortex_a7 = 0x00300207,
|
| 456 |
+
/** ARM Cortex-A8. */
|
| 457 |
+
cpuinfo_uarch_cortex_a8 = 0x00300208,
|
| 458 |
+
/** ARM Cortex-A9. */
|
| 459 |
+
cpuinfo_uarch_cortex_a9 = 0x00300209,
|
| 460 |
+
/** ARM Cortex-A12. */
|
| 461 |
+
cpuinfo_uarch_cortex_a12 = 0x00300212,
|
| 462 |
+
/** ARM Cortex-A15. */
|
| 463 |
+
cpuinfo_uarch_cortex_a15 = 0x00300215,
|
| 464 |
+
/** ARM Cortex-A17. */
|
| 465 |
+
cpuinfo_uarch_cortex_a17 = 0x00300217,
|
| 466 |
+
|
| 467 |
+
/** ARM Cortex-A32. */
|
| 468 |
+
cpuinfo_uarch_cortex_a32 = 0x00300332,
|
| 469 |
+
/** ARM Cortex-A35. */
|
| 470 |
+
cpuinfo_uarch_cortex_a35 = 0x00300335,
|
| 471 |
+
/** ARM Cortex-A53. */
|
| 472 |
+
cpuinfo_uarch_cortex_a53 = 0x00300353,
|
| 473 |
+
/** ARM Cortex-A55 revision 0 (restricted dual-issue capabilities
|
| 474 |
+
compared to revision 1+). */
|
| 475 |
+
cpuinfo_uarch_cortex_a55r0 = 0x00300354,
|
| 476 |
+
/** ARM Cortex-A55. */
|
| 477 |
+
cpuinfo_uarch_cortex_a55 = 0x00300355,
|
| 478 |
+
/** ARM Cortex-A57. */
|
| 479 |
+
cpuinfo_uarch_cortex_a57 = 0x00300357,
|
| 480 |
+
/** ARM Cortex-A65. */
|
| 481 |
+
cpuinfo_uarch_cortex_a65 = 0x00300365,
|
| 482 |
+
/** ARM Cortex-A72. */
|
| 483 |
+
cpuinfo_uarch_cortex_a72 = 0x00300372,
|
| 484 |
+
/** ARM Cortex-A73. */
|
| 485 |
+
cpuinfo_uarch_cortex_a73 = 0x00300373,
|
| 486 |
+
/** ARM Cortex-A75. */
|
| 487 |
+
cpuinfo_uarch_cortex_a75 = 0x00300375,
|
| 488 |
+
/** ARM Cortex-A76. */
|
| 489 |
+
cpuinfo_uarch_cortex_a76 = 0x00300376,
|
| 490 |
+
/** ARM Cortex-A77. */
|
| 491 |
+
cpuinfo_uarch_cortex_a77 = 0x00300377,
|
| 492 |
+
/** ARM Cortex-A78. */
|
| 493 |
+
cpuinfo_uarch_cortex_a78 = 0x00300378,
|
| 494 |
+
|
| 495 |
+
/** ARM Neoverse N1. */
|
| 496 |
+
cpuinfo_uarch_neoverse_n1 = 0x00300400,
|
| 497 |
+
/** ARM Neoverse E1. */
|
| 498 |
+
cpuinfo_uarch_neoverse_e1 = 0x00300401,
|
| 499 |
+
/** ARM Neoverse V1. */
|
| 500 |
+
cpuinfo_uarch_neoverse_v1 = 0x00300402,
|
| 501 |
+
/** ARM Neoverse N2. */
|
| 502 |
+
cpuinfo_uarch_neoverse_n2 = 0x00300403,
|
| 503 |
+
/** ARM Neoverse V2. */
|
| 504 |
+
cpuinfo_uarch_neoverse_v2 = 0x00300404,
|
| 505 |
+
|
| 506 |
+
/** ARM Cortex-X1. */
|
| 507 |
+
cpuinfo_uarch_cortex_x1 = 0x00300501,
|
| 508 |
+
/** ARM Cortex-X2. */
|
| 509 |
+
cpuinfo_uarch_cortex_x2 = 0x00300502,
|
| 510 |
+
/** ARM Cortex-X3. */
|
| 511 |
+
cpuinfo_uarch_cortex_x3 = 0x00300503,
|
| 512 |
+
/** ARM Cortex-X4. */
|
| 513 |
+
cpuinfo_uarch_cortex_x4 = 0x00300504,
|
| 514 |
+
/** ARM Cortex-X925. */
|
| 515 |
+
cpuinfo_uarch_cortex_x925 = 0x00300505,
|
| 516 |
+
|
| 517 |
+
/** ARM Cortex-A510. */
|
| 518 |
+
cpuinfo_uarch_cortex_a510 = 0x00300551,
|
| 519 |
+
/** ARM Cortex-A520. */
|
| 520 |
+
cpuinfo_uarch_cortex_a520 = 0x00300552,
|
| 521 |
+
/** ARM Cortex-A710. */
|
| 522 |
+
cpuinfo_uarch_cortex_a710 = 0x00300571,
|
| 523 |
+
/** ARM Cortex-A715. */
|
| 524 |
+
cpuinfo_uarch_cortex_a715 = 0x00300572,
|
| 525 |
+
/** ARM Cortex-A720. */
|
| 526 |
+
cpuinfo_uarch_cortex_a720 = 0x00300573,
|
| 527 |
+
/** ARM Cortex-A725. */
|
| 528 |
+
cpuinfo_uarch_cortex_a725 = 0x00300574,
|
| 529 |
+
|
| 530 |
+
/** Qualcomm Scorpion. */
|
| 531 |
+
cpuinfo_uarch_scorpion = 0x00400100,
|
| 532 |
+
/** Qualcomm Krait. */
|
| 533 |
+
cpuinfo_uarch_krait = 0x00400101,
|
| 534 |
+
/** Qualcomm Kryo. */
|
| 535 |
+
cpuinfo_uarch_kryo = 0x00400102,
|
| 536 |
+
/** Qualcomm Falkor. */
|
| 537 |
+
cpuinfo_uarch_falkor = 0x00400103,
|
| 538 |
+
/** Qualcomm Saphira. */
|
| 539 |
+
cpuinfo_uarch_saphira = 0x00400104,
|
| 540 |
+
/** Qualcomm Oryon. */
|
| 541 |
+
cpuinfo_uarch_oryon = 0x00400105,
|
| 542 |
+
|
| 543 |
+
/** Nvidia Denver. */
|
| 544 |
+
cpuinfo_uarch_denver = 0x00500100,
|
| 545 |
+
/** Nvidia Denver 2. */
|
| 546 |
+
cpuinfo_uarch_denver2 = 0x00500101,
|
| 547 |
+
/** Nvidia Carmel. */
|
| 548 |
+
cpuinfo_uarch_carmel = 0x00500102,
|
| 549 |
+
|
| 550 |
+
/** Samsung Exynos M1 (Exynos 8890 big cores). */
|
| 551 |
+
cpuinfo_uarch_exynos_m1 = 0x00600100,
|
| 552 |
+
/** Samsung Exynos M2 (Exynos 8895 big cores). */
|
| 553 |
+
cpuinfo_uarch_exynos_m2 = 0x00600101,
|
| 554 |
+
/** Samsung Exynos M3 (Exynos 9810 big cores). */
|
| 555 |
+
cpuinfo_uarch_exynos_m3 = 0x00600102,
|
| 556 |
+
/** Samsung Exynos M4 (Exynos 9820 big cores). */
|
| 557 |
+
cpuinfo_uarch_exynos_m4 = 0x00600103,
|
| 558 |
+
/** Samsung Exynos M5 (Exynos 9830 big cores). */
|
| 559 |
+
cpuinfo_uarch_exynos_m5 = 0x00600104,
|
| 560 |
+
|
| 561 |
+
/* Deprecated synonym for Cortex-A76 */
|
| 562 |
+
cpuinfo_uarch_cortex_a76ae = 0x00300376,
|
| 563 |
+
/* Deprecated names for Exynos. */
|
| 564 |
+
cpuinfo_uarch_mongoose_m1 = 0x00600100,
|
| 565 |
+
cpuinfo_uarch_mongoose_m2 = 0x00600101,
|
| 566 |
+
cpuinfo_uarch_meerkat_m3 = 0x00600102,
|
| 567 |
+
cpuinfo_uarch_meerkat_m4 = 0x00600103,
|
| 568 |
+
|
| 569 |
+
/** Apple A6 and A6X processors. */
|
| 570 |
+
cpuinfo_uarch_swift = 0x00700100,
|
| 571 |
+
/** Apple A7 processor. */
|
| 572 |
+
cpuinfo_uarch_cyclone = 0x00700101,
|
| 573 |
+
/** Apple A8 and A8X processor. */
|
| 574 |
+
cpuinfo_uarch_typhoon = 0x00700102,
|
| 575 |
+
/** Apple A9 and A9X processor. */
|
| 576 |
+
cpuinfo_uarch_twister = 0x00700103,
|
| 577 |
+
/** Apple A10 and A10X processor. */
|
| 578 |
+
cpuinfo_uarch_hurricane = 0x00700104,
|
| 579 |
+
/** Apple A11 processor (big cores). */
|
| 580 |
+
cpuinfo_uarch_monsoon = 0x00700105,
|
| 581 |
+
/** Apple A11 processor (little cores). */
|
| 582 |
+
cpuinfo_uarch_mistral = 0x00700106,
|
| 583 |
+
/** Apple A12 processor (big cores). */
|
| 584 |
+
cpuinfo_uarch_vortex = 0x00700107,
|
| 585 |
+
/** Apple A12 processor (little cores). */
|
| 586 |
+
cpuinfo_uarch_tempest = 0x00700108,
|
| 587 |
+
/** Apple A13 processor (big cores). */
|
| 588 |
+
cpuinfo_uarch_lightning = 0x00700109,
|
| 589 |
+
/** Apple A13 processor (little cores). */
|
| 590 |
+
cpuinfo_uarch_thunder = 0x0070010A,
|
| 591 |
+
/** Apple A14 / M1 processor (big cores). */
|
| 592 |
+
cpuinfo_uarch_firestorm = 0x0070010B,
|
| 593 |
+
/** Apple A14 / M1 processor (little cores). */
|
| 594 |
+
cpuinfo_uarch_icestorm = 0x0070010C,
|
| 595 |
+
/** Apple A15 / M2 processor (big cores). */
|
| 596 |
+
cpuinfo_uarch_avalanche = 0x0070010D,
|
| 597 |
+
/** Apple A15 / M2 processor (little cores). */
|
| 598 |
+
cpuinfo_uarch_blizzard = 0x0070010E,
|
| 599 |
+
/** Apple A16 processor (big cores). */
|
| 600 |
+
cpuinfo_uarch_everest = 0x00700200,
|
| 601 |
+
/** Apple A16 processor (little cores). */
|
| 602 |
+
cpuinfo_uarch_sawtooth = 0x00700201,
|
| 603 |
+
/** Apple A17 processor (big cores). */
|
| 604 |
+
cpuinfo_uarch_coll_everest = 0x00700202,
|
| 605 |
+
/** Apple A17 processor (little cores). */
|
| 606 |
+
cpuinfo_uarch_coll_sawtooth = 0x00700203,
|
| 607 |
+
/** Apple A18 processor (big cores). */
|
| 608 |
+
cpuinfo_uarch_tupai_everest = 0x00700204,
|
| 609 |
+
/** Apple A18 processor (little cores). */
|
| 610 |
+
cpuinfo_uarch_tupai_sawtooth = 0x00700205,
|
| 611 |
+
/** Apple A18 pro processor (big cores). */
|
| 612 |
+
cpuinfo_uarch_tahiti_everest = 0x00700206,
|
| 613 |
+
/** Apple A18 pro processor (little cores). */
|
| 614 |
+
cpuinfo_uarch_tahiti_sawtooth = 0x00700207,
|
| 615 |
+
|
| 616 |
+
/** Cavium ThunderX. */
|
| 617 |
+
cpuinfo_uarch_thunderx = 0x00800100,
|
| 618 |
+
/** Cavium ThunderX2 (originally Broadcom Vulkan). */
|
| 619 |
+
cpuinfo_uarch_thunderx2 = 0x00800200,
|
| 620 |
+
|
| 621 |
+
/** Marvell PJ4. */
|
| 622 |
+
cpuinfo_uarch_pj4 = 0x00900100,
|
| 623 |
+
|
| 624 |
+
/** Broadcom Brahma B15. */
|
| 625 |
+
cpuinfo_uarch_brahma_b15 = 0x00A00100,
|
| 626 |
+
/** Broadcom Brahma B53. */
|
| 627 |
+
cpuinfo_uarch_brahma_b53 = 0x00A00101,
|
| 628 |
+
|
| 629 |
+
/** Applied Micro X-Gene. */
|
| 630 |
+
cpuinfo_uarch_xgene = 0x00B00100,
|
| 631 |
+
|
| 632 |
+
/* Hygon Dhyana (a modification of AMD Zen for Chinese market). */
|
| 633 |
+
cpuinfo_uarch_dhyana = 0x01000100,
|
| 634 |
+
|
| 635 |
+
/** HiSilicon TaiShan v110 (Huawei Kunpeng 920 series processors). */
|
| 636 |
+
cpuinfo_uarch_taishan_v110 = 0x00C00100,
|
| 637 |
+
};
|
| 638 |
+
|
| 639 |
+
struct cpuinfo_processor {
|
| 640 |
+
/** SMT (hyperthread) ID within a core */
|
| 641 |
+
uint32_t smt_id;
|
| 642 |
+
/** Core containing this logical processor */
|
| 643 |
+
const struct cpuinfo_core* core;
|
| 644 |
+
/** Cluster of cores containing this logical processor */
|
| 645 |
+
const struct cpuinfo_cluster* cluster;
|
| 646 |
+
/** Physical package containing this logical processor */
|
| 647 |
+
const struct cpuinfo_package* package;
|
| 648 |
+
#if defined(__linux__)
|
| 649 |
+
/**
|
| 650 |
+
* Linux-specific ID for the logical processor:
|
| 651 |
+
* - Linux kernel exposes information about this logical processor in
|
| 652 |
+
* /sys/devices/system/cpu/cpu<linux_id>/
|
| 653 |
+
* - Bit <linux_id> in the cpu_set_t identifies this logical processor
|
| 654 |
+
*/
|
| 655 |
+
int linux_id;
|
| 656 |
+
#endif
|
| 657 |
+
#if defined(_WIN32) || defined(__CYGWIN__)
|
| 658 |
+
/** Windows-specific ID for the group containing the logical processor.
|
| 659 |
+
*/
|
| 660 |
+
uint16_t windows_group_id;
|
| 661 |
+
/**
|
| 662 |
+
* Windows-specific ID of the logical processor within its group:
|
| 663 |
+
* - Bit <windows_processor_id> in the KAFFINITY mask identifies this
|
| 664 |
+
* logical processor within its group.
|
| 665 |
+
*/
|
| 666 |
+
uint16_t windows_processor_id;
|
| 667 |
+
#endif
|
| 668 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 669 |
+
/** APIC ID (unique x86-specific ID of the logical processor) */
|
| 670 |
+
uint32_t apic_id;
|
| 671 |
+
#endif
|
| 672 |
+
struct {
|
| 673 |
+
/** Level 1 instruction cache */
|
| 674 |
+
const struct cpuinfo_cache* l1i;
|
| 675 |
+
/** Level 1 data cache */
|
| 676 |
+
const struct cpuinfo_cache* l1d;
|
| 677 |
+
/** Level 2 unified or data cache */
|
| 678 |
+
const struct cpuinfo_cache* l2;
|
| 679 |
+
/** Level 3 unified or data cache */
|
| 680 |
+
const struct cpuinfo_cache* l3;
|
| 681 |
+
/** Level 4 unified or data cache */
|
| 682 |
+
const struct cpuinfo_cache* l4;
|
| 683 |
+
} cache;
|
| 684 |
+
};
|
| 685 |
+
|
| 686 |
+
struct cpuinfo_core {
|
| 687 |
+
/** Index of the first logical processor on this core. */
|
| 688 |
+
uint32_t processor_start;
|
| 689 |
+
/** Number of logical processors on this core */
|
| 690 |
+
uint32_t processor_count;
|
| 691 |
+
/** Core ID within a package */
|
| 692 |
+
uint32_t core_id;
|
| 693 |
+
/** Cluster containing this core */
|
| 694 |
+
const struct cpuinfo_cluster* cluster;
|
| 695 |
+
/** Physical package containing this core. */
|
| 696 |
+
const struct cpuinfo_package* package;
|
| 697 |
+
/** Vendor of the CPU microarchitecture for this core */
|
| 698 |
+
enum cpuinfo_vendor vendor;
|
| 699 |
+
/** CPU microarchitecture for this core */
|
| 700 |
+
enum cpuinfo_uarch uarch;
|
| 701 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 702 |
+
/** Value of CPUID leaf 1 EAX register for this core */
|
| 703 |
+
uint32_t cpuid;
|
| 704 |
+
#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 705 |
+
/** Value of Main ID Register (MIDR) for this core */
|
| 706 |
+
uint32_t midr;
|
| 707 |
+
#endif
|
| 708 |
+
/** Clock rate (non-Turbo) of the core, in Hz */
|
| 709 |
+
uint64_t frequency;
|
| 710 |
+
};
|
| 711 |
+
|
| 712 |
+
struct cpuinfo_cluster {
|
| 713 |
+
/** Index of the first logical processor in the cluster */
|
| 714 |
+
uint32_t processor_start;
|
| 715 |
+
/** Number of logical processors in the cluster */
|
| 716 |
+
uint32_t processor_count;
|
| 717 |
+
/** Index of the first core in the cluster */
|
| 718 |
+
uint32_t core_start;
|
| 719 |
+
/** Number of cores on the cluster */
|
| 720 |
+
uint32_t core_count;
|
| 721 |
+
/** Cluster ID within a package */
|
| 722 |
+
uint32_t cluster_id;
|
| 723 |
+
/** Physical package containing the cluster */
|
| 724 |
+
const struct cpuinfo_package* package;
|
| 725 |
+
/** CPU microarchitecture vendor of the cores in the cluster */
|
| 726 |
+
enum cpuinfo_vendor vendor;
|
| 727 |
+
/** CPU microarchitecture of the cores in the cluster */
|
| 728 |
+
enum cpuinfo_uarch uarch;
|
| 729 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 730 |
+
/** Value of CPUID leaf 1 EAX register of the cores in the cluster */
|
| 731 |
+
uint32_t cpuid;
|
| 732 |
+
#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 733 |
+
/** Value of Main ID Register (MIDR) of the cores in the cluster */
|
| 734 |
+
uint32_t midr;
|
| 735 |
+
#endif
|
| 736 |
+
/** Clock rate (non-Turbo) of the cores in the cluster, in Hz */
|
| 737 |
+
uint64_t frequency;
|
| 738 |
+
};
|
| 739 |
+
|
| 740 |
+
#define CPUINFO_PACKAGE_NAME_MAX 64
|
| 741 |
+
|
| 742 |
+
struct cpuinfo_package {
|
| 743 |
+
/** SoC or processor chip model name */
|
| 744 |
+
char name[CPUINFO_PACKAGE_NAME_MAX];
|
| 745 |
+
/** Index of the first logical processor on this physical package */
|
| 746 |
+
uint32_t processor_start;
|
| 747 |
+
/** Number of logical processors on this physical package */
|
| 748 |
+
uint32_t processor_count;
|
| 749 |
+
/** Index of the first core on this physical package */
|
| 750 |
+
uint32_t core_start;
|
| 751 |
+
/** Number of cores on this physical package */
|
| 752 |
+
uint32_t core_count;
|
| 753 |
+
/** Index of the first cluster of cores on this physical package */
|
| 754 |
+
uint32_t cluster_start;
|
| 755 |
+
/** Number of clusters of cores on this physical package */
|
| 756 |
+
uint32_t cluster_count;
|
| 757 |
+
};
|
| 758 |
+
|
| 759 |
+
struct cpuinfo_uarch_info {
|
| 760 |
+
/** Type of CPU microarchitecture */
|
| 761 |
+
enum cpuinfo_uarch uarch;
|
| 762 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 763 |
+
/** Value of CPUID leaf 1 EAX register for the microarchitecture */
|
| 764 |
+
uint32_t cpuid;
|
| 765 |
+
#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 766 |
+
/** Value of Main ID Register (MIDR) for the microarchitecture */
|
| 767 |
+
uint32_t midr;
|
| 768 |
+
#endif
|
| 769 |
+
/** Number of logical processors with the microarchitecture */
|
| 770 |
+
uint32_t processor_count;
|
| 771 |
+
/** Number of cores with the microarchitecture */
|
| 772 |
+
uint32_t core_count;
|
| 773 |
+
};
|
| 774 |
+
|
| 775 |
+
#ifdef __cplusplus
|
| 776 |
+
extern "C" {
|
| 777 |
+
#endif
|
| 778 |
+
|
| 779 |
+
bool CPUINFO_ABI cpuinfo_initialize(void);
|
| 780 |
+
|
| 781 |
+
void CPUINFO_ABI cpuinfo_deinitialize(void);
|
| 782 |
+
|
| 783 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 784 |
+
/* This structure is not a part of stable API. Use cpuinfo_has_x86_* functions
|
| 785 |
+
* instead. */
|
| 786 |
+
struct cpuinfo_x86_isa {
|
| 787 |
+
#if CPUINFO_ARCH_X86
|
| 788 |
+
bool rdtsc;
|
| 789 |
+
#endif
|
| 790 |
+
bool rdtscp;
|
| 791 |
+
bool rdpid;
|
| 792 |
+
bool sysenter;
|
| 793 |
+
#if CPUINFO_ARCH_X86
|
| 794 |
+
bool syscall;
|
| 795 |
+
#endif
|
| 796 |
+
bool msr;
|
| 797 |
+
bool clzero;
|
| 798 |
+
bool clflush;
|
| 799 |
+
bool clflushopt;
|
| 800 |
+
bool mwait;
|
| 801 |
+
bool mwaitx;
|
| 802 |
+
#if CPUINFO_ARCH_X86
|
| 803 |
+
bool emmx;
|
| 804 |
+
#endif
|
| 805 |
+
bool fxsave;
|
| 806 |
+
bool xsave;
|
| 807 |
+
#if CPUINFO_ARCH_X86
|
| 808 |
+
bool fpu;
|
| 809 |
+
bool mmx;
|
| 810 |
+
bool mmx_plus;
|
| 811 |
+
#endif
|
| 812 |
+
bool three_d_now;
|
| 813 |
+
bool three_d_now_plus;
|
| 814 |
+
#if CPUINFO_ARCH_X86
|
| 815 |
+
bool three_d_now_geode;
|
| 816 |
+
#endif
|
| 817 |
+
bool prefetch;
|
| 818 |
+
bool prefetchw;
|
| 819 |
+
bool prefetchwt1;
|
| 820 |
+
#if CPUINFO_ARCH_X86
|
| 821 |
+
bool daz;
|
| 822 |
+
bool sse;
|
| 823 |
+
bool sse2;
|
| 824 |
+
#endif
|
| 825 |
+
bool sse3;
|
| 826 |
+
bool ssse3;
|
| 827 |
+
bool sse4_1;
|
| 828 |
+
bool sse4_2;
|
| 829 |
+
bool sse4a;
|
| 830 |
+
bool misaligned_sse;
|
| 831 |
+
bool avx;
|
| 832 |
+
bool avxvnni;
|
| 833 |
+
bool fma3;
|
| 834 |
+
bool fma4;
|
| 835 |
+
bool xop;
|
| 836 |
+
bool f16c;
|
| 837 |
+
bool avx2;
|
| 838 |
+
bool avx512f;
|
| 839 |
+
bool avx512pf;
|
| 840 |
+
bool avx512er;
|
| 841 |
+
bool avx512cd;
|
| 842 |
+
bool avx512dq;
|
| 843 |
+
bool avx512bw;
|
| 844 |
+
bool avx512vl;
|
| 845 |
+
bool avx512ifma;
|
| 846 |
+
bool avx512vbmi;
|
| 847 |
+
bool avx512vbmi2;
|
| 848 |
+
bool avx512bitalg;
|
| 849 |
+
bool avx512vpopcntdq;
|
| 850 |
+
bool avx512vnni;
|
| 851 |
+
bool avx512bf16;
|
| 852 |
+
bool avx512fp16;
|
| 853 |
+
bool avx512vp2intersect;
|
| 854 |
+
bool avx512_4vnniw;
|
| 855 |
+
bool avx512_4fmaps;
|
| 856 |
+
bool avx10_1;
|
| 857 |
+
bool avx10_2;
|
| 858 |
+
bool amx_bf16;
|
| 859 |
+
bool amx_tile;
|
| 860 |
+
bool amx_int8;
|
| 861 |
+
bool amx_fp16;
|
| 862 |
+
bool avx_vnni_int8;
|
| 863 |
+
bool avx_vnni_int16;
|
| 864 |
+
bool avx_ne_convert;
|
| 865 |
+
bool hle;
|
| 866 |
+
bool rtm;
|
| 867 |
+
bool xtest;
|
| 868 |
+
bool mpx;
|
| 869 |
+
#if CPUINFO_ARCH_X86
|
| 870 |
+
bool cmov;
|
| 871 |
+
bool cmpxchg8b;
|
| 872 |
+
#endif
|
| 873 |
+
bool cmpxchg16b;
|
| 874 |
+
bool clwb;
|
| 875 |
+
bool movbe;
|
| 876 |
+
#if CPUINFO_ARCH_X86_64
|
| 877 |
+
bool lahf_sahf;
|
| 878 |
+
#endif
|
| 879 |
+
bool fs_gs_base;
|
| 880 |
+
bool lzcnt;
|
| 881 |
+
bool popcnt;
|
| 882 |
+
bool tbm;
|
| 883 |
+
bool bmi;
|
| 884 |
+
bool bmi2;
|
| 885 |
+
bool adx;
|
| 886 |
+
bool aes;
|
| 887 |
+
bool vaes;
|
| 888 |
+
bool pclmulqdq;
|
| 889 |
+
bool vpclmulqdq;
|
| 890 |
+
bool gfni;
|
| 891 |
+
bool rdrand;
|
| 892 |
+
bool rdseed;
|
| 893 |
+
bool sha;
|
| 894 |
+
bool rng;
|
| 895 |
+
bool ace;
|
| 896 |
+
bool ace2;
|
| 897 |
+
bool phe;
|
| 898 |
+
bool pmm;
|
| 899 |
+
bool lwp;
|
| 900 |
+
};
|
| 901 |
+
|
| 902 |
+
extern struct cpuinfo_x86_isa cpuinfo_isa;
|
| 903 |
+
#endif
|
| 904 |
+
|
| 905 |
+
static inline bool cpuinfo_has_x86_rdtsc(void) {
|
| 906 |
+
#if CPUINFO_ARCH_X86_64
|
| 907 |
+
return true;
|
| 908 |
+
#elif CPUINFO_ARCH_X86
|
| 909 |
+
#if defined(__ANDROID__)
|
| 910 |
+
return true;
|
| 911 |
+
#else
|
| 912 |
+
return cpuinfo_isa.rdtsc;
|
| 913 |
+
#endif
|
| 914 |
+
#else
|
| 915 |
+
return false;
|
| 916 |
+
#endif
|
| 917 |
+
}
|
| 918 |
+
|
| 919 |
+
static inline bool cpuinfo_has_x86_rdtscp(void) {
|
| 920 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 921 |
+
return cpuinfo_isa.rdtscp;
|
| 922 |
+
#else
|
| 923 |
+
return false;
|
| 924 |
+
#endif
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
static inline bool cpuinfo_has_x86_rdpid(void) {
|
| 928 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 929 |
+
return cpuinfo_isa.rdpid;
|
| 930 |
+
#else
|
| 931 |
+
return false;
|
| 932 |
+
#endif
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
static inline bool cpuinfo_has_x86_clzero(void) {
|
| 936 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 937 |
+
return cpuinfo_isa.clzero;
|
| 938 |
+
#else
|
| 939 |
+
return false;
|
| 940 |
+
#endif
|
| 941 |
+
}
|
| 942 |
+
|
| 943 |
+
static inline bool cpuinfo_has_x86_mwait(void) {
|
| 944 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 945 |
+
return cpuinfo_isa.mwait;
|
| 946 |
+
#else
|
| 947 |
+
return false;
|
| 948 |
+
#endif
|
| 949 |
+
}
|
| 950 |
+
|
| 951 |
+
static inline bool cpuinfo_has_x86_mwaitx(void) {
|
| 952 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 953 |
+
return cpuinfo_isa.mwaitx;
|
| 954 |
+
#else
|
| 955 |
+
return false;
|
| 956 |
+
#endif
|
| 957 |
+
}
|
| 958 |
+
|
| 959 |
+
static inline bool cpuinfo_has_x86_fxsave(void) {
|
| 960 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 961 |
+
return cpuinfo_isa.fxsave;
|
| 962 |
+
#else
|
| 963 |
+
return false;
|
| 964 |
+
#endif
|
| 965 |
+
}
|
| 966 |
+
|
| 967 |
+
static inline bool cpuinfo_has_x86_xsave(void) {
|
| 968 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 969 |
+
return cpuinfo_isa.xsave;
|
| 970 |
+
#else
|
| 971 |
+
return false;
|
| 972 |
+
#endif
|
| 973 |
+
}
|
| 974 |
+
|
| 975 |
+
static inline bool cpuinfo_has_x86_fpu(void) {
|
| 976 |
+
#if CPUINFO_ARCH_X86_64
|
| 977 |
+
return true;
|
| 978 |
+
#elif CPUINFO_ARCH_X86
|
| 979 |
+
#if defined(__ANDROID__)
|
| 980 |
+
return true;
|
| 981 |
+
#else
|
| 982 |
+
return cpuinfo_isa.fpu;
|
| 983 |
+
#endif
|
| 984 |
+
#else
|
| 985 |
+
return false;
|
| 986 |
+
#endif
|
| 987 |
+
}
|
| 988 |
+
|
| 989 |
+
static inline bool cpuinfo_has_x86_mmx(void) {
|
| 990 |
+
#if CPUINFO_ARCH_X86_64
|
| 991 |
+
return true;
|
| 992 |
+
#elif CPUINFO_ARCH_X86
|
| 993 |
+
#if defined(__ANDROID__)
|
| 994 |
+
return true;
|
| 995 |
+
#else
|
| 996 |
+
return cpuinfo_isa.mmx;
|
| 997 |
+
#endif
|
| 998 |
+
#else
|
| 999 |
+
return false;
|
| 1000 |
+
#endif
|
| 1001 |
+
}
|
| 1002 |
+
|
| 1003 |
+
static inline bool cpuinfo_has_x86_mmx_plus(void) {
|
| 1004 |
+
#if CPUINFO_ARCH_X86_64
|
| 1005 |
+
return true;
|
| 1006 |
+
#elif CPUINFO_ARCH_X86
|
| 1007 |
+
#if defined(__ANDROID__)
|
| 1008 |
+
return true;
|
| 1009 |
+
#else
|
| 1010 |
+
return cpuinfo_isa.mmx_plus;
|
| 1011 |
+
#endif
|
| 1012 |
+
#else
|
| 1013 |
+
return false;
|
| 1014 |
+
#endif
|
| 1015 |
+
}
|
| 1016 |
+
|
| 1017 |
+
static inline bool cpuinfo_has_x86_3dnow(void) {
|
| 1018 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1019 |
+
return cpuinfo_isa.three_d_now;
|
| 1020 |
+
#else
|
| 1021 |
+
return false;
|
| 1022 |
+
#endif
|
| 1023 |
+
}
|
| 1024 |
+
|
| 1025 |
+
static inline bool cpuinfo_has_x86_3dnow_plus(void) {
|
| 1026 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1027 |
+
return cpuinfo_isa.three_d_now_plus;
|
| 1028 |
+
#else
|
| 1029 |
+
return false;
|
| 1030 |
+
#endif
|
| 1031 |
+
}
|
| 1032 |
+
|
| 1033 |
+
static inline bool cpuinfo_has_x86_3dnow_geode(void) {
|
| 1034 |
+
#if CPUINFO_ARCH_X86_64
|
| 1035 |
+
return false;
|
| 1036 |
+
#elif CPUINFO_ARCH_X86
|
| 1037 |
+
#if defined(__ANDROID__)
|
| 1038 |
+
return false;
|
| 1039 |
+
#else
|
| 1040 |
+
return cpuinfo_isa.three_d_now_geode;
|
| 1041 |
+
#endif
|
| 1042 |
+
#else
|
| 1043 |
+
return false;
|
| 1044 |
+
#endif
|
| 1045 |
+
}
|
| 1046 |
+
|
| 1047 |
+
static inline bool cpuinfo_has_x86_prefetch(void) {
|
| 1048 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1049 |
+
return cpuinfo_isa.prefetch;
|
| 1050 |
+
#else
|
| 1051 |
+
return false;
|
| 1052 |
+
#endif
|
| 1053 |
+
}
|
| 1054 |
+
|
| 1055 |
+
static inline bool cpuinfo_has_x86_prefetchw(void) {
|
| 1056 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1057 |
+
return cpuinfo_isa.prefetchw;
|
| 1058 |
+
#else
|
| 1059 |
+
return false;
|
| 1060 |
+
#endif
|
| 1061 |
+
}
|
| 1062 |
+
|
| 1063 |
+
static inline bool cpuinfo_has_x86_prefetchwt1(void) {
|
| 1064 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1065 |
+
return cpuinfo_isa.prefetchwt1;
|
| 1066 |
+
#else
|
| 1067 |
+
return false;
|
| 1068 |
+
#endif
|
| 1069 |
+
}
|
| 1070 |
+
|
| 1071 |
+
static inline bool cpuinfo_has_x86_daz(void) {
|
| 1072 |
+
#if CPUINFO_ARCH_X86_64
|
| 1073 |
+
return true;
|
| 1074 |
+
#elif CPUINFO_ARCH_X86
|
| 1075 |
+
#if defined(__ANDROID__)
|
| 1076 |
+
return true;
|
| 1077 |
+
#else
|
| 1078 |
+
return cpuinfo_isa.daz;
|
| 1079 |
+
#endif
|
| 1080 |
+
#else
|
| 1081 |
+
return false;
|
| 1082 |
+
#endif
|
| 1083 |
+
}
|
| 1084 |
+
|
| 1085 |
+
static inline bool cpuinfo_has_x86_sse(void) {
|
| 1086 |
+
#if CPUINFO_ARCH_X86_64
|
| 1087 |
+
return true;
|
| 1088 |
+
#elif CPUINFO_ARCH_X86
|
| 1089 |
+
#if defined(__ANDROID__)
|
| 1090 |
+
return true;
|
| 1091 |
+
#else
|
| 1092 |
+
return cpuinfo_isa.sse;
|
| 1093 |
+
#endif
|
| 1094 |
+
#else
|
| 1095 |
+
return false;
|
| 1096 |
+
#endif
|
| 1097 |
+
}
|
| 1098 |
+
|
| 1099 |
+
static inline bool cpuinfo_has_x86_sse2(void) {
|
| 1100 |
+
#if CPUINFO_ARCH_X86_64
|
| 1101 |
+
return true;
|
| 1102 |
+
#elif CPUINFO_ARCH_X86
|
| 1103 |
+
#if defined(__ANDROID__)
|
| 1104 |
+
return true;
|
| 1105 |
+
#else
|
| 1106 |
+
return cpuinfo_isa.sse2;
|
| 1107 |
+
#endif
|
| 1108 |
+
#else
|
| 1109 |
+
return false;
|
| 1110 |
+
#endif
|
| 1111 |
+
}
|
| 1112 |
+
|
| 1113 |
+
static inline bool cpuinfo_has_x86_sse3(void) {
|
| 1114 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1115 |
+
#if defined(__ANDROID__)
|
| 1116 |
+
return true;
|
| 1117 |
+
#else
|
| 1118 |
+
return cpuinfo_isa.sse3;
|
| 1119 |
+
#endif
|
| 1120 |
+
#else
|
| 1121 |
+
return false;
|
| 1122 |
+
#endif
|
| 1123 |
+
}
|
| 1124 |
+
|
| 1125 |
+
static inline bool cpuinfo_has_x86_ssse3(void) {
|
| 1126 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1127 |
+
#if defined(__ANDROID__)
|
| 1128 |
+
return true;
|
| 1129 |
+
#else
|
| 1130 |
+
return cpuinfo_isa.ssse3;
|
| 1131 |
+
#endif
|
| 1132 |
+
#else
|
| 1133 |
+
return false;
|
| 1134 |
+
#endif
|
| 1135 |
+
}
|
| 1136 |
+
|
| 1137 |
+
static inline bool cpuinfo_has_x86_sse4_1(void) {
|
| 1138 |
+
#if CPUINFO_ARCH_X86_64
|
| 1139 |
+
#if defined(__ANDROID__)
|
| 1140 |
+
return true;
|
| 1141 |
+
#else
|
| 1142 |
+
return cpuinfo_isa.sse4_1;
|
| 1143 |
+
#endif
|
| 1144 |
+
#elif CPUINFO_ARCH_X86
|
| 1145 |
+
return cpuinfo_isa.sse4_1;
|
| 1146 |
+
#else
|
| 1147 |
+
return false;
|
| 1148 |
+
#endif
|
| 1149 |
+
}
|
| 1150 |
+
|
| 1151 |
+
static inline bool cpuinfo_has_x86_sse4_2(void) {
|
| 1152 |
+
#if CPUINFO_ARCH_X86_64
|
| 1153 |
+
#if defined(__ANDROID__)
|
| 1154 |
+
return true;
|
| 1155 |
+
#else
|
| 1156 |
+
return cpuinfo_isa.sse4_2;
|
| 1157 |
+
#endif
|
| 1158 |
+
#elif CPUINFO_ARCH_X86
|
| 1159 |
+
return cpuinfo_isa.sse4_2;
|
| 1160 |
+
#else
|
| 1161 |
+
return false;
|
| 1162 |
+
#endif
|
| 1163 |
+
}
|
| 1164 |
+
|
| 1165 |
+
static inline bool cpuinfo_has_x86_sse4a(void) {
|
| 1166 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1167 |
+
return cpuinfo_isa.sse4a;
|
| 1168 |
+
#else
|
| 1169 |
+
return false;
|
| 1170 |
+
#endif
|
| 1171 |
+
}
|
| 1172 |
+
|
| 1173 |
+
static inline bool cpuinfo_has_x86_misaligned_sse(void) {
|
| 1174 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1175 |
+
return cpuinfo_isa.misaligned_sse;
|
| 1176 |
+
#else
|
| 1177 |
+
return false;
|
| 1178 |
+
#endif
|
| 1179 |
+
}
|
| 1180 |
+
|
| 1181 |
+
static inline bool cpuinfo_has_x86_avx(void) {
|
| 1182 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1183 |
+
return cpuinfo_isa.avx;
|
| 1184 |
+
#else
|
| 1185 |
+
return false;
|
| 1186 |
+
#endif
|
| 1187 |
+
}
|
| 1188 |
+
|
| 1189 |
+
static inline bool cpuinfo_has_x86_avxvnni(void) {
|
| 1190 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1191 |
+
return cpuinfo_isa.avxvnni;
|
| 1192 |
+
#else
|
| 1193 |
+
return false;
|
| 1194 |
+
#endif
|
| 1195 |
+
}
|
| 1196 |
+
|
| 1197 |
+
static inline bool cpuinfo_has_x86_fma3(void) {
|
| 1198 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1199 |
+
return cpuinfo_isa.fma3;
|
| 1200 |
+
#else
|
| 1201 |
+
return false;
|
| 1202 |
+
#endif
|
| 1203 |
+
}
|
| 1204 |
+
|
| 1205 |
+
static inline bool cpuinfo_has_x86_fma4(void) {
|
| 1206 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1207 |
+
return cpuinfo_isa.fma4;
|
| 1208 |
+
#else
|
| 1209 |
+
return false;
|
| 1210 |
+
#endif
|
| 1211 |
+
}
|
| 1212 |
+
|
| 1213 |
+
static inline bool cpuinfo_has_x86_xop(void) {
|
| 1214 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1215 |
+
return cpuinfo_isa.xop;
|
| 1216 |
+
#else
|
| 1217 |
+
return false;
|
| 1218 |
+
#endif
|
| 1219 |
+
}
|
| 1220 |
+
|
| 1221 |
+
static inline bool cpuinfo_has_x86_f16c(void) {
|
| 1222 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1223 |
+
return cpuinfo_isa.f16c;
|
| 1224 |
+
#else
|
| 1225 |
+
return false;
|
| 1226 |
+
#endif
|
| 1227 |
+
}
|
| 1228 |
+
|
| 1229 |
+
static inline bool cpuinfo_has_x86_avx2(void) {
|
| 1230 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1231 |
+
return cpuinfo_isa.avx2;
|
| 1232 |
+
#else
|
| 1233 |
+
return false;
|
| 1234 |
+
#endif
|
| 1235 |
+
}
|
| 1236 |
+
|
| 1237 |
+
static inline bool cpuinfo_has_x86_avx512f(void) {
|
| 1238 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1239 |
+
return cpuinfo_isa.avx512f;
|
| 1240 |
+
#else
|
| 1241 |
+
return false;
|
| 1242 |
+
#endif
|
| 1243 |
+
}
|
| 1244 |
+
|
| 1245 |
+
static inline bool cpuinfo_has_x86_avx512pf(void) {
|
| 1246 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1247 |
+
return cpuinfo_isa.avx512pf;
|
| 1248 |
+
#else
|
| 1249 |
+
return false;
|
| 1250 |
+
#endif
|
| 1251 |
+
}
|
| 1252 |
+
|
| 1253 |
+
static inline bool cpuinfo_has_x86_avx512er(void) {
|
| 1254 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1255 |
+
return cpuinfo_isa.avx512er;
|
| 1256 |
+
#else
|
| 1257 |
+
return false;
|
| 1258 |
+
#endif
|
| 1259 |
+
}
|
| 1260 |
+
|
| 1261 |
+
static inline bool cpuinfo_has_x86_avx512cd(void) {
|
| 1262 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1263 |
+
return cpuinfo_isa.avx512cd;
|
| 1264 |
+
#else
|
| 1265 |
+
return false;
|
| 1266 |
+
#endif
|
| 1267 |
+
}
|
| 1268 |
+
|
| 1269 |
+
static inline bool cpuinfo_has_x86_avx512dq(void) {
|
| 1270 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1271 |
+
return cpuinfo_isa.avx512dq;
|
| 1272 |
+
#else
|
| 1273 |
+
return false;
|
| 1274 |
+
#endif
|
| 1275 |
+
}
|
| 1276 |
+
|
| 1277 |
+
static inline bool cpuinfo_has_x86_avx512bw(void) {
|
| 1278 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1279 |
+
return cpuinfo_isa.avx512bw;
|
| 1280 |
+
#else
|
| 1281 |
+
return false;
|
| 1282 |
+
#endif
|
| 1283 |
+
}
|
| 1284 |
+
|
| 1285 |
+
static inline bool cpuinfo_has_x86_avx512vl(void) {
|
| 1286 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1287 |
+
return cpuinfo_isa.avx512vl;
|
| 1288 |
+
#else
|
| 1289 |
+
return false;
|
| 1290 |
+
#endif
|
| 1291 |
+
}
|
| 1292 |
+
|
| 1293 |
+
static inline bool cpuinfo_has_x86_avx512ifma(void) {
|
| 1294 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1295 |
+
return cpuinfo_isa.avx512ifma;
|
| 1296 |
+
#else
|
| 1297 |
+
return false;
|
| 1298 |
+
#endif
|
| 1299 |
+
}
|
| 1300 |
+
|
| 1301 |
+
static inline bool cpuinfo_has_x86_avx512vbmi(void) {
|
| 1302 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1303 |
+
return cpuinfo_isa.avx512vbmi;
|
| 1304 |
+
#else
|
| 1305 |
+
return false;
|
| 1306 |
+
#endif
|
| 1307 |
+
}
|
| 1308 |
+
|
| 1309 |
+
static inline bool cpuinfo_has_x86_avx512vbmi2(void) {
|
| 1310 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1311 |
+
return cpuinfo_isa.avx512vbmi2;
|
| 1312 |
+
#else
|
| 1313 |
+
return false;
|
| 1314 |
+
#endif
|
| 1315 |
+
}
|
| 1316 |
+
|
| 1317 |
+
static inline bool cpuinfo_has_x86_avx512bitalg(void) {
|
| 1318 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1319 |
+
return cpuinfo_isa.avx512bitalg;
|
| 1320 |
+
#else
|
| 1321 |
+
return false;
|
| 1322 |
+
#endif
|
| 1323 |
+
}
|
| 1324 |
+
|
| 1325 |
+
static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) {
|
| 1326 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1327 |
+
return cpuinfo_isa.avx512vpopcntdq;
|
| 1328 |
+
#else
|
| 1329 |
+
return false;
|
| 1330 |
+
#endif
|
| 1331 |
+
}
|
| 1332 |
+
|
| 1333 |
+
static inline bool cpuinfo_has_x86_avx512vnni(void) {
|
| 1334 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1335 |
+
return cpuinfo_isa.avx512vnni;
|
| 1336 |
+
#else
|
| 1337 |
+
return false;
|
| 1338 |
+
#endif
|
| 1339 |
+
}
|
| 1340 |
+
|
| 1341 |
+
static inline bool cpuinfo_has_x86_avx512bf16(void) {
|
| 1342 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1343 |
+
return cpuinfo_isa.avx512bf16;
|
| 1344 |
+
#else
|
| 1345 |
+
return false;
|
| 1346 |
+
#endif
|
| 1347 |
+
}
|
| 1348 |
+
|
| 1349 |
+
static inline bool cpuinfo_has_x86_avx512fp16(void) {
|
| 1350 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1351 |
+
return cpuinfo_isa.avx512fp16;
|
| 1352 |
+
#else
|
| 1353 |
+
return false;
|
| 1354 |
+
#endif
|
| 1355 |
+
}
|
| 1356 |
+
|
| 1357 |
+
static inline bool cpuinfo_has_x86_avx512vp2intersect(void) {
|
| 1358 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1359 |
+
return cpuinfo_isa.avx512vp2intersect;
|
| 1360 |
+
#else
|
| 1361 |
+
return false;
|
| 1362 |
+
#endif
|
| 1363 |
+
}
|
| 1364 |
+
|
| 1365 |
+
static inline bool cpuinfo_has_x86_avx512_4vnniw(void) {
|
| 1366 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1367 |
+
return cpuinfo_isa.avx512_4vnniw;
|
| 1368 |
+
#else
|
| 1369 |
+
return false;
|
| 1370 |
+
#endif
|
| 1371 |
+
}
|
| 1372 |
+
|
| 1373 |
+
static inline bool cpuinfo_has_x86_avx512_4fmaps(void) {
|
| 1374 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1375 |
+
return cpuinfo_isa.avx512_4fmaps;
|
| 1376 |
+
#else
|
| 1377 |
+
return false;
|
| 1378 |
+
#endif
|
| 1379 |
+
}
|
| 1380 |
+
|
| 1381 |
+
/* [NOTE] Intel Advanced Matrix Extensions (AMX) detection
|
| 1382 |
+
*
|
| 1383 |
+
* I. AMX is a new extensions to the x86 ISA to work on matrices, consists of
|
| 1384 |
+
* 1) 2-dimentional registers (tiles), hold sub-matrices from larger matrices in memory
|
| 1385 |
+
* 2) Accelerator called Tile Matrix Multiply (TMUL), contains instructions operating on tiles
|
| 1386 |
+
*
|
| 1387 |
+
* II. Platforms that supports AMX:
|
| 1388 |
+
* +-----------------+-----+----------+----------+----------+----------+
|
| 1389 |
+
* | Platforms | Gen | amx-bf16 | amx-tile | amx-int8 | amx-fp16 |
|
| 1390 |
+
* +-----------------+-----+----------+----------+----------+----------+
|
| 1391 |
+
* | Sapphire Rapids | 4th | YES | YES | YES | NO |
|
| 1392 |
+
* +-----------------+-----+----------+----------+----------+----------+
|
| 1393 |
+
* | Emerald Rapids | 5th | YES | YES | YES | NO |
|
| 1394 |
+
* +-----------------+-----+----------+----------+----------+----------+
|
| 1395 |
+
* | Granite Rapids | 6th | YES | YES | YES | YES |
|
| 1396 |
+
* +-----------------+-----+----------+----------+----------+----------+
|
| 1397 |
+
*
|
| 1398 |
+
* Reference: https://www.intel.com/content/www/us/en/products/docs
|
| 1399 |
+
* /accelerator-engines/advanced-matrix-extensions/overview.html
|
| 1400 |
+
*/
|
| 1401 |
+
static inline bool cpuinfo_has_x86_amx_bf16(void) {
|
| 1402 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1403 |
+
return cpuinfo_isa.amx_bf16;
|
| 1404 |
+
#else
|
| 1405 |
+
return false;
|
| 1406 |
+
#endif
|
| 1407 |
+
}
|
| 1408 |
+
|
| 1409 |
+
static inline bool cpuinfo_has_x86_amx_tile(void) {
|
| 1410 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1411 |
+
return cpuinfo_isa.amx_tile;
|
| 1412 |
+
#else
|
| 1413 |
+
return false;
|
| 1414 |
+
#endif
|
| 1415 |
+
}
|
| 1416 |
+
|
| 1417 |
+
static inline bool cpuinfo_has_x86_amx_int8(void) {
|
| 1418 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1419 |
+
return cpuinfo_isa.amx_int8;
|
| 1420 |
+
#else
|
| 1421 |
+
return false;
|
| 1422 |
+
#endif
|
| 1423 |
+
}
|
| 1424 |
+
|
| 1425 |
+
static inline bool cpuinfo_has_x86_amx_fp16(void) {
|
| 1426 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1427 |
+
return cpuinfo_isa.amx_fp16;
|
| 1428 |
+
#else
|
| 1429 |
+
return false;
|
| 1430 |
+
#endif
|
| 1431 |
+
}
|
| 1432 |
+
|
| 1433 |
+
/*
|
| 1434 |
+
* Intel AVX Vector Neural Network Instructions (VNNI) INT8
|
| 1435 |
+
* Supported Platfroms: Sierra Forest, Arrow Lake, Lunar Lake
|
| 1436 |
+
*/
|
| 1437 |
+
static inline bool cpuinfo_has_x86_avx_vnni_int8(void) {
|
| 1438 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1439 |
+
return cpuinfo_isa.avx_vnni_int8;
|
| 1440 |
+
#else
|
| 1441 |
+
return false;
|
| 1442 |
+
#endif
|
| 1443 |
+
}
|
| 1444 |
+
|
| 1445 |
+
/*
|
| 1446 |
+
* Intel AVX Vector Neural Network Instructions (VNNI) INT16
|
| 1447 |
+
* Supported Platfroms: Arrow Lake, Lunar Lake
|
| 1448 |
+
*/
|
| 1449 |
+
static inline bool cpuinfo_has_x86_avx_vnni_int16(void) {
|
| 1450 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1451 |
+
return cpuinfo_isa.avx_vnni_int16;
|
| 1452 |
+
#else
|
| 1453 |
+
return false;
|
| 1454 |
+
#endif
|
| 1455 |
+
}
|
| 1456 |
+
|
| 1457 |
+
/*
|
| 1458 |
+
* A new set of instructions, which can convert low precision floating point
|
| 1459 |
+
* like BF16/FP16 to high precision floating point FP32, as well as convert FP32
|
| 1460 |
+
* elements to BF16. This instruction allows the platform to have improved AI
|
| 1461 |
+
* capabilities and better compatibility.
|
| 1462 |
+
*
|
| 1463 |
+
* Supported Platforms: Sierra Forest, Arrow Lake, Lunar Lake
|
| 1464 |
+
*/
|
| 1465 |
+
static inline bool cpuinfo_has_x86_avx_ne_convert(void) {
|
| 1466 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1467 |
+
return cpuinfo_isa.avx_ne_convert;
|
| 1468 |
+
#else
|
| 1469 |
+
return false;
|
| 1470 |
+
#endif
|
| 1471 |
+
}
|
| 1472 |
+
|
| 1473 |
+
static inline bool cpuinfo_has_x86_avx10_1(void) {
|
| 1474 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1475 |
+
return cpuinfo_isa.avx10_1;
|
| 1476 |
+
#else
|
| 1477 |
+
return false;
|
| 1478 |
+
#endif
|
| 1479 |
+
}
|
| 1480 |
+
|
| 1481 |
+
static inline bool cpuinfo_has_x86_avx10_2(void) {
|
| 1482 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1483 |
+
return cpuinfo_isa.avx10_2;
|
| 1484 |
+
#else
|
| 1485 |
+
return false;
|
| 1486 |
+
#endif
|
| 1487 |
+
}
|
| 1488 |
+
|
| 1489 |
+
static inline bool cpuinfo_has_x86_hle(void) {
|
| 1490 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1491 |
+
return cpuinfo_isa.hle;
|
| 1492 |
+
#else
|
| 1493 |
+
return false;
|
| 1494 |
+
#endif
|
| 1495 |
+
}
|
| 1496 |
+
|
| 1497 |
+
static inline bool cpuinfo_has_x86_rtm(void) {
|
| 1498 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1499 |
+
return cpuinfo_isa.rtm;
|
| 1500 |
+
#else
|
| 1501 |
+
return false;
|
| 1502 |
+
#endif
|
| 1503 |
+
}
|
| 1504 |
+
|
| 1505 |
+
static inline bool cpuinfo_has_x86_xtest(void) {
|
| 1506 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1507 |
+
return cpuinfo_isa.xtest;
|
| 1508 |
+
#else
|
| 1509 |
+
return false;
|
| 1510 |
+
#endif
|
| 1511 |
+
}
|
| 1512 |
+
|
| 1513 |
+
static inline bool cpuinfo_has_x86_mpx(void) {
|
| 1514 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1515 |
+
return cpuinfo_isa.mpx;
|
| 1516 |
+
#else
|
| 1517 |
+
return false;
|
| 1518 |
+
#endif
|
| 1519 |
+
}
|
| 1520 |
+
|
| 1521 |
+
static inline bool cpuinfo_has_x86_cmov(void) {
|
| 1522 |
+
#if CPUINFO_ARCH_X86_64
|
| 1523 |
+
return true;
|
| 1524 |
+
#elif CPUINFO_ARCH_X86
|
| 1525 |
+
return cpuinfo_isa.cmov;
|
| 1526 |
+
#else
|
| 1527 |
+
return false;
|
| 1528 |
+
#endif
|
| 1529 |
+
}
|
| 1530 |
+
|
| 1531 |
+
static inline bool cpuinfo_has_x86_cmpxchg8b(void) {
|
| 1532 |
+
#if CPUINFO_ARCH_X86_64
|
| 1533 |
+
return true;
|
| 1534 |
+
#elif CPUINFO_ARCH_X86
|
| 1535 |
+
return cpuinfo_isa.cmpxchg8b;
|
| 1536 |
+
#else
|
| 1537 |
+
return false;
|
| 1538 |
+
#endif
|
| 1539 |
+
}
|
| 1540 |
+
|
| 1541 |
+
static inline bool cpuinfo_has_x86_cmpxchg16b(void) {
|
| 1542 |
+
#if CPUINFO_ARCH_X86_64
|
| 1543 |
+
return cpuinfo_isa.cmpxchg16b;
|
| 1544 |
+
#else
|
| 1545 |
+
return false;
|
| 1546 |
+
#endif
|
| 1547 |
+
}
|
| 1548 |
+
|
| 1549 |
+
static inline bool cpuinfo_has_x86_clwb(void) {
|
| 1550 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1551 |
+
return cpuinfo_isa.clwb;
|
| 1552 |
+
#else
|
| 1553 |
+
return false;
|
| 1554 |
+
#endif
|
| 1555 |
+
}
|
| 1556 |
+
|
| 1557 |
+
static inline bool cpuinfo_has_x86_movbe(void) {
|
| 1558 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1559 |
+
return cpuinfo_isa.movbe;
|
| 1560 |
+
#else
|
| 1561 |
+
return false;
|
| 1562 |
+
#endif
|
| 1563 |
+
}
|
| 1564 |
+
|
| 1565 |
+
static inline bool cpuinfo_has_x86_lahf_sahf(void) {
|
| 1566 |
+
#if CPUINFO_ARCH_X86
|
| 1567 |
+
return true;
|
| 1568 |
+
#elif CPUINFO_ARCH_X86_64
|
| 1569 |
+
return cpuinfo_isa.lahf_sahf;
|
| 1570 |
+
#else
|
| 1571 |
+
return false;
|
| 1572 |
+
#endif
|
| 1573 |
+
}
|
| 1574 |
+
|
| 1575 |
+
static inline bool cpuinfo_has_x86_lzcnt(void) {
|
| 1576 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1577 |
+
return cpuinfo_isa.lzcnt;
|
| 1578 |
+
#else
|
| 1579 |
+
return false;
|
| 1580 |
+
#endif
|
| 1581 |
+
}
|
| 1582 |
+
|
| 1583 |
+
static inline bool cpuinfo_has_x86_popcnt(void) {
|
| 1584 |
+
#if CPUINFO_ARCH_X86_64
|
| 1585 |
+
#if defined(__ANDROID__)
|
| 1586 |
+
return true;
|
| 1587 |
+
#else
|
| 1588 |
+
return cpuinfo_isa.popcnt;
|
| 1589 |
+
#endif
|
| 1590 |
+
#elif CPUINFO_ARCH_X86
|
| 1591 |
+
return cpuinfo_isa.popcnt;
|
| 1592 |
+
#else
|
| 1593 |
+
return false;
|
| 1594 |
+
#endif
|
| 1595 |
+
}
|
| 1596 |
+
|
| 1597 |
+
static inline bool cpuinfo_has_x86_tbm(void) {
|
| 1598 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1599 |
+
return cpuinfo_isa.tbm;
|
| 1600 |
+
#else
|
| 1601 |
+
return false;
|
| 1602 |
+
#endif
|
| 1603 |
+
}
|
| 1604 |
+
|
| 1605 |
+
static inline bool cpuinfo_has_x86_bmi(void) {
|
| 1606 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1607 |
+
return cpuinfo_isa.bmi;
|
| 1608 |
+
#else
|
| 1609 |
+
return false;
|
| 1610 |
+
#endif
|
| 1611 |
+
}
|
| 1612 |
+
|
| 1613 |
+
static inline bool cpuinfo_has_x86_bmi2(void) {
|
| 1614 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1615 |
+
return cpuinfo_isa.bmi2;
|
| 1616 |
+
#else
|
| 1617 |
+
return false;
|
| 1618 |
+
#endif
|
| 1619 |
+
}
|
| 1620 |
+
|
| 1621 |
+
static inline bool cpuinfo_has_x86_adx(void) {
|
| 1622 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1623 |
+
return cpuinfo_isa.adx;
|
| 1624 |
+
#else
|
| 1625 |
+
return false;
|
| 1626 |
+
#endif
|
| 1627 |
+
}
|
| 1628 |
+
|
| 1629 |
+
static inline bool cpuinfo_has_x86_aes(void) {
|
| 1630 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1631 |
+
return cpuinfo_isa.aes;
|
| 1632 |
+
#else
|
| 1633 |
+
return false;
|
| 1634 |
+
#endif
|
| 1635 |
+
}
|
| 1636 |
+
|
| 1637 |
+
static inline bool cpuinfo_has_x86_vaes(void) {
|
| 1638 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1639 |
+
return cpuinfo_isa.vaes;
|
| 1640 |
+
#else
|
| 1641 |
+
return false;
|
| 1642 |
+
#endif
|
| 1643 |
+
}
|
| 1644 |
+
|
| 1645 |
+
static inline bool cpuinfo_has_x86_pclmulqdq(void) {
|
| 1646 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1647 |
+
return cpuinfo_isa.pclmulqdq;
|
| 1648 |
+
#else
|
| 1649 |
+
return false;
|
| 1650 |
+
#endif
|
| 1651 |
+
}
|
| 1652 |
+
|
| 1653 |
+
static inline bool cpuinfo_has_x86_vpclmulqdq(void) {
|
| 1654 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1655 |
+
return cpuinfo_isa.vpclmulqdq;
|
| 1656 |
+
#else
|
| 1657 |
+
return false;
|
| 1658 |
+
#endif
|
| 1659 |
+
}
|
| 1660 |
+
|
| 1661 |
+
static inline bool cpuinfo_has_x86_gfni(void) {
|
| 1662 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1663 |
+
return cpuinfo_isa.gfni;
|
| 1664 |
+
#else
|
| 1665 |
+
return false;
|
| 1666 |
+
#endif
|
| 1667 |
+
}
|
| 1668 |
+
|
| 1669 |
+
static inline bool cpuinfo_has_x86_rdrand(void) {
|
| 1670 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1671 |
+
return cpuinfo_isa.rdrand;
|
| 1672 |
+
#else
|
| 1673 |
+
return false;
|
| 1674 |
+
#endif
|
| 1675 |
+
}
|
| 1676 |
+
|
| 1677 |
+
static inline bool cpuinfo_has_x86_rdseed(void) {
|
| 1678 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1679 |
+
return cpuinfo_isa.rdseed;
|
| 1680 |
+
#else
|
| 1681 |
+
return false;
|
| 1682 |
+
#endif
|
| 1683 |
+
}
|
| 1684 |
+
|
| 1685 |
+
static inline bool cpuinfo_has_x86_sha(void) {
|
| 1686 |
+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
|
| 1687 |
+
return cpuinfo_isa.sha;
|
| 1688 |
+
#else
|
| 1689 |
+
return false;
|
| 1690 |
+
#endif
|
| 1691 |
+
}
|
| 1692 |
+
|
| 1693 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 1694 |
+
/* This structure is not a part of stable API. Use cpuinfo_has_arm_* functions
|
| 1695 |
+
* instead. */
|
| 1696 |
+
struct cpuinfo_arm_isa {
|
| 1697 |
+
#if CPUINFO_ARCH_ARM
|
| 1698 |
+
bool thumb;
|
| 1699 |
+
bool thumb2;
|
| 1700 |
+
bool thumbee;
|
| 1701 |
+
bool jazelle;
|
| 1702 |
+
bool armv5e;
|
| 1703 |
+
bool armv6;
|
| 1704 |
+
bool armv6k;
|
| 1705 |
+
bool armv7;
|
| 1706 |
+
bool armv7mp;
|
| 1707 |
+
bool armv8;
|
| 1708 |
+
bool idiv;
|
| 1709 |
+
|
| 1710 |
+
bool vfpv2;
|
| 1711 |
+
bool vfpv3;
|
| 1712 |
+
bool d32;
|
| 1713 |
+
bool fp16;
|
| 1714 |
+
bool fma;
|
| 1715 |
+
|
| 1716 |
+
bool wmmx;
|
| 1717 |
+
bool wmmx2;
|
| 1718 |
+
bool neon;
|
| 1719 |
+
#endif
|
| 1720 |
+
#if CPUINFO_ARCH_ARM64
|
| 1721 |
+
bool atomics;
|
| 1722 |
+
bool bf16;
|
| 1723 |
+
bool sve;
|
| 1724 |
+
bool sve2;
|
| 1725 |
+
bool i8mm;
|
| 1726 |
+
bool sme;
|
| 1727 |
+
bool sme2;
|
| 1728 |
+
bool sme2p1;
|
| 1729 |
+
bool sme_i16i32;
|
| 1730 |
+
bool sme_bi32i32;
|
| 1731 |
+
bool sme_b16b16;
|
| 1732 |
+
bool sme_f16f16;
|
| 1733 |
+
uint32_t svelen;
|
| 1734 |
+
uint32_t smelen;
|
| 1735 |
+
#endif
|
| 1736 |
+
bool rdm;
|
| 1737 |
+
bool fp16arith;
|
| 1738 |
+
bool dot;
|
| 1739 |
+
bool jscvt;
|
| 1740 |
+
bool fcma;
|
| 1741 |
+
bool fhm;
|
| 1742 |
+
|
| 1743 |
+
bool aes;
|
| 1744 |
+
bool sha1;
|
| 1745 |
+
bool sha2;
|
| 1746 |
+
bool pmull;
|
| 1747 |
+
bool crc32;
|
| 1748 |
+
};
|
| 1749 |
+
|
| 1750 |
+
extern struct cpuinfo_arm_isa cpuinfo_isa;
|
| 1751 |
+
#endif
|
| 1752 |
+
|
| 1753 |
+
static inline bool cpuinfo_has_arm_thumb(void) {
|
| 1754 |
+
#if CPUINFO_ARCH_ARM
|
| 1755 |
+
return cpuinfo_isa.thumb;
|
| 1756 |
+
#else
|
| 1757 |
+
return false;
|
| 1758 |
+
#endif
|
| 1759 |
+
}
|
| 1760 |
+
|
| 1761 |
+
static inline bool cpuinfo_has_arm_thumb2(void) {
|
| 1762 |
+
#if CPUINFO_ARCH_ARM
|
| 1763 |
+
return cpuinfo_isa.thumb2;
|
| 1764 |
+
#else
|
| 1765 |
+
return false;
|
| 1766 |
+
#endif
|
| 1767 |
+
}
|
| 1768 |
+
|
| 1769 |
+
static inline bool cpuinfo_has_arm_v5e(void) {
|
| 1770 |
+
#if CPUINFO_ARCH_ARM
|
| 1771 |
+
return cpuinfo_isa.armv5e;
|
| 1772 |
+
#else
|
| 1773 |
+
return false;
|
| 1774 |
+
#endif
|
| 1775 |
+
}
|
| 1776 |
+
|
| 1777 |
+
static inline bool cpuinfo_has_arm_v6(void) {
|
| 1778 |
+
#if CPUINFO_ARCH_ARM
|
| 1779 |
+
return cpuinfo_isa.armv6;
|
| 1780 |
+
#else
|
| 1781 |
+
return false;
|
| 1782 |
+
#endif
|
| 1783 |
+
}
|
| 1784 |
+
|
| 1785 |
+
static inline bool cpuinfo_has_arm_v6k(void) {
|
| 1786 |
+
#if CPUINFO_ARCH_ARM
|
| 1787 |
+
return cpuinfo_isa.armv6k;
|
| 1788 |
+
#else
|
| 1789 |
+
return false;
|
| 1790 |
+
#endif
|
| 1791 |
+
}
|
| 1792 |
+
|
| 1793 |
+
static inline bool cpuinfo_has_arm_v7(void) {
|
| 1794 |
+
#if CPUINFO_ARCH_ARM
|
| 1795 |
+
return cpuinfo_isa.armv7;
|
| 1796 |
+
#else
|
| 1797 |
+
return false;
|
| 1798 |
+
#endif
|
| 1799 |
+
}
|
| 1800 |
+
|
| 1801 |
+
static inline bool cpuinfo_has_arm_v7mp(void) {
|
| 1802 |
+
#if CPUINFO_ARCH_ARM
|
| 1803 |
+
return cpuinfo_isa.armv7mp;
|
| 1804 |
+
#else
|
| 1805 |
+
return false;
|
| 1806 |
+
#endif
|
| 1807 |
+
}
|
| 1808 |
+
|
| 1809 |
+
static inline bool cpuinfo_has_arm_v8(void) {
|
| 1810 |
+
#if CPUINFO_ARCH_ARM64
|
| 1811 |
+
return true;
|
| 1812 |
+
#elif CPUINFO_ARCH_ARM
|
| 1813 |
+
return cpuinfo_isa.armv8;
|
| 1814 |
+
#else
|
| 1815 |
+
return false;
|
| 1816 |
+
#endif
|
| 1817 |
+
}
|
| 1818 |
+
|
| 1819 |
+
static inline bool cpuinfo_has_arm_idiv(void) {
|
| 1820 |
+
#if CPUINFO_ARCH_ARM64
|
| 1821 |
+
return true;
|
| 1822 |
+
#elif CPUINFO_ARCH_ARM
|
| 1823 |
+
return cpuinfo_isa.idiv;
|
| 1824 |
+
#else
|
| 1825 |
+
return false;
|
| 1826 |
+
#endif
|
| 1827 |
+
}
|
| 1828 |
+
|
| 1829 |
+
static inline bool cpuinfo_has_arm_vfpv2(void) {
|
| 1830 |
+
#if CPUINFO_ARCH_ARM
|
| 1831 |
+
return cpuinfo_isa.vfpv2;
|
| 1832 |
+
#else
|
| 1833 |
+
return false;
|
| 1834 |
+
#endif
|
| 1835 |
+
}
|
| 1836 |
+
|
| 1837 |
+
static inline bool cpuinfo_has_arm_vfpv3(void) {
|
| 1838 |
+
#if CPUINFO_ARCH_ARM64
|
| 1839 |
+
return true;
|
| 1840 |
+
#elif CPUINFO_ARCH_ARM
|
| 1841 |
+
return cpuinfo_isa.vfpv3;
|
| 1842 |
+
#else
|
| 1843 |
+
return false;
|
| 1844 |
+
#endif
|
| 1845 |
+
}
|
| 1846 |
+
|
| 1847 |
+
static inline bool cpuinfo_has_arm_vfpv3_d32(void) {
|
| 1848 |
+
#if CPUINFO_ARCH_ARM64
|
| 1849 |
+
return true;
|
| 1850 |
+
#elif CPUINFO_ARCH_ARM
|
| 1851 |
+
return cpuinfo_isa.vfpv3 && cpuinfo_isa.d32;
|
| 1852 |
+
#else
|
| 1853 |
+
return false;
|
| 1854 |
+
#endif
|
| 1855 |
+
}
|
| 1856 |
+
|
| 1857 |
+
static inline bool cpuinfo_has_arm_vfpv3_fp16(void) {
|
| 1858 |
+
#if CPUINFO_ARCH_ARM64
|
| 1859 |
+
return true;
|
| 1860 |
+
#elif CPUINFO_ARCH_ARM
|
| 1861 |
+
return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16;
|
| 1862 |
+
#else
|
| 1863 |
+
return false;
|
| 1864 |
+
#endif
|
| 1865 |
+
}
|
| 1866 |
+
|
| 1867 |
+
static inline bool cpuinfo_has_arm_vfpv3_fp16_d32(void) {
|
| 1868 |
+
#if CPUINFO_ARCH_ARM64
|
| 1869 |
+
return true;
|
| 1870 |
+
#elif CPUINFO_ARCH_ARM
|
| 1871 |
+
return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16 && cpuinfo_isa.d32;
|
| 1872 |
+
#else
|
| 1873 |
+
return false;
|
| 1874 |
+
#endif
|
| 1875 |
+
}
|
| 1876 |
+
|
| 1877 |
+
static inline bool cpuinfo_has_arm_vfpv4(void) {
|
| 1878 |
+
#if CPUINFO_ARCH_ARM64
|
| 1879 |
+
return true;
|
| 1880 |
+
#elif CPUINFO_ARCH_ARM
|
| 1881 |
+
return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma;
|
| 1882 |
+
#else
|
| 1883 |
+
return false;
|
| 1884 |
+
#endif
|
| 1885 |
+
}
|
| 1886 |
+
|
| 1887 |
+
static inline bool cpuinfo_has_arm_vfpv4_d32(void) {
|
| 1888 |
+
#if CPUINFO_ARCH_ARM64
|
| 1889 |
+
return true;
|
| 1890 |
+
#elif CPUINFO_ARCH_ARM
|
| 1891 |
+
return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma && cpuinfo_isa.d32;
|
| 1892 |
+
#else
|
| 1893 |
+
return false;
|
| 1894 |
+
#endif
|
| 1895 |
+
}
|
| 1896 |
+
|
| 1897 |
+
static inline bool cpuinfo_has_arm_fp16_arith(void) {
|
| 1898 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 1899 |
+
return cpuinfo_isa.fp16arith;
|
| 1900 |
+
#else
|
| 1901 |
+
return false;
|
| 1902 |
+
#endif
|
| 1903 |
+
}
|
| 1904 |
+
|
| 1905 |
+
static inline bool cpuinfo_has_arm_bf16(void) {
|
| 1906 |
+
#if CPUINFO_ARCH_ARM64
|
| 1907 |
+
return cpuinfo_isa.bf16;
|
| 1908 |
+
#else
|
| 1909 |
+
return false;
|
| 1910 |
+
#endif
|
| 1911 |
+
}
|
| 1912 |
+
|
| 1913 |
+
static inline bool cpuinfo_has_arm_wmmx(void) {
|
| 1914 |
+
#if CPUINFO_ARCH_ARM
|
| 1915 |
+
return cpuinfo_isa.wmmx;
|
| 1916 |
+
#else
|
| 1917 |
+
return false;
|
| 1918 |
+
#endif
|
| 1919 |
+
}
|
| 1920 |
+
|
| 1921 |
+
static inline bool cpuinfo_has_arm_wmmx2(void) {
|
| 1922 |
+
#if CPUINFO_ARCH_ARM
|
| 1923 |
+
return cpuinfo_isa.wmmx2;
|
| 1924 |
+
#else
|
| 1925 |
+
return false;
|
| 1926 |
+
#endif
|
| 1927 |
+
}
|
| 1928 |
+
|
| 1929 |
+
static inline bool cpuinfo_has_arm_neon(void) {
|
| 1930 |
+
#if CPUINFO_ARCH_ARM64
|
| 1931 |
+
return true;
|
| 1932 |
+
#elif CPUINFO_ARCH_ARM
|
| 1933 |
+
return cpuinfo_isa.neon;
|
| 1934 |
+
#else
|
| 1935 |
+
return false;
|
| 1936 |
+
#endif
|
| 1937 |
+
}
|
| 1938 |
+
|
| 1939 |
+
static inline bool cpuinfo_has_arm_neon_fp16(void) {
|
| 1940 |
+
#if CPUINFO_ARCH_ARM64
|
| 1941 |
+
return true;
|
| 1942 |
+
#elif CPUINFO_ARCH_ARM
|
| 1943 |
+
return cpuinfo_isa.neon && cpuinfo_isa.fp16;
|
| 1944 |
+
#else
|
| 1945 |
+
return false;
|
| 1946 |
+
#endif
|
| 1947 |
+
}
|
| 1948 |
+
|
| 1949 |
+
static inline bool cpuinfo_has_arm_neon_fma(void) {
|
| 1950 |
+
#if CPUINFO_ARCH_ARM64
|
| 1951 |
+
return true;
|
| 1952 |
+
#elif CPUINFO_ARCH_ARM
|
| 1953 |
+
return cpuinfo_isa.neon && cpuinfo_isa.fma;
|
| 1954 |
+
#else
|
| 1955 |
+
return false;
|
| 1956 |
+
#endif
|
| 1957 |
+
}
|
| 1958 |
+
|
| 1959 |
+
static inline bool cpuinfo_has_arm_neon_v8(void) {
|
| 1960 |
+
#if CPUINFO_ARCH_ARM64
|
| 1961 |
+
return true;
|
| 1962 |
+
#elif CPUINFO_ARCH_ARM
|
| 1963 |
+
return cpuinfo_isa.neon && cpuinfo_isa.armv8;
|
| 1964 |
+
#else
|
| 1965 |
+
return false;
|
| 1966 |
+
#endif
|
| 1967 |
+
}
|
| 1968 |
+
|
| 1969 |
+
static inline bool cpuinfo_has_arm_atomics(void) {
|
| 1970 |
+
#if CPUINFO_ARCH_ARM64
|
| 1971 |
+
return cpuinfo_isa.atomics;
|
| 1972 |
+
#else
|
| 1973 |
+
return false;
|
| 1974 |
+
#endif
|
| 1975 |
+
}
|
| 1976 |
+
|
| 1977 |
+
static inline bool cpuinfo_has_arm_neon_rdm(void) {
|
| 1978 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 1979 |
+
return cpuinfo_isa.rdm;
|
| 1980 |
+
#else
|
| 1981 |
+
return false;
|
| 1982 |
+
#endif
|
| 1983 |
+
}
|
| 1984 |
+
|
| 1985 |
+
static inline bool cpuinfo_has_arm_neon_fp16_arith(void) {
|
| 1986 |
+
#if CPUINFO_ARCH_ARM
|
| 1987 |
+
return cpuinfo_isa.neon && cpuinfo_isa.fp16arith;
|
| 1988 |
+
#elif CPUINFO_ARCH_ARM64
|
| 1989 |
+
return cpuinfo_isa.fp16arith;
|
| 1990 |
+
#else
|
| 1991 |
+
return false;
|
| 1992 |
+
#endif
|
| 1993 |
+
}
|
| 1994 |
+
|
| 1995 |
+
static inline bool cpuinfo_has_arm_fhm(void) {
|
| 1996 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 1997 |
+
return cpuinfo_isa.fhm;
|
| 1998 |
+
#else
|
| 1999 |
+
return false;
|
| 2000 |
+
#endif
|
| 2001 |
+
}
|
| 2002 |
+
|
| 2003 |
+
static inline bool cpuinfo_has_arm_neon_dot(void) {
|
| 2004 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 2005 |
+
return cpuinfo_isa.dot;
|
| 2006 |
+
#else
|
| 2007 |
+
return false;
|
| 2008 |
+
#endif
|
| 2009 |
+
}
|
| 2010 |
+
|
| 2011 |
+
static inline bool cpuinfo_has_arm_neon_bf16(void) {
|
| 2012 |
+
#if CPUINFO_ARCH_ARM64
|
| 2013 |
+
return cpuinfo_isa.bf16;
|
| 2014 |
+
#else
|
| 2015 |
+
return false;
|
| 2016 |
+
#endif
|
| 2017 |
+
}
|
| 2018 |
+
|
| 2019 |
+
static inline bool cpuinfo_has_arm_jscvt(void) {
|
| 2020 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 2021 |
+
return cpuinfo_isa.jscvt;
|
| 2022 |
+
#else
|
| 2023 |
+
return false;
|
| 2024 |
+
#endif
|
| 2025 |
+
}
|
| 2026 |
+
|
| 2027 |
+
static inline bool cpuinfo_has_arm_fcma(void) {
|
| 2028 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 2029 |
+
return cpuinfo_isa.fcma;
|
| 2030 |
+
#else
|
| 2031 |
+
return false;
|
| 2032 |
+
#endif
|
| 2033 |
+
}
|
| 2034 |
+
|
| 2035 |
+
static inline bool cpuinfo_has_arm_i8mm(void) {
|
| 2036 |
+
#if CPUINFO_ARCH_ARM64
|
| 2037 |
+
return cpuinfo_isa.i8mm;
|
| 2038 |
+
#else
|
| 2039 |
+
return false;
|
| 2040 |
+
#endif
|
| 2041 |
+
}
|
| 2042 |
+
|
| 2043 |
+
static inline bool cpuinfo_has_arm_aes(void) {
|
| 2044 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 2045 |
+
return cpuinfo_isa.aes;
|
| 2046 |
+
#else
|
| 2047 |
+
return false;
|
| 2048 |
+
#endif
|
| 2049 |
+
}
|
| 2050 |
+
|
| 2051 |
+
static inline bool cpuinfo_has_arm_sha1(void) {
|
| 2052 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 2053 |
+
return cpuinfo_isa.sha1;
|
| 2054 |
+
#else
|
| 2055 |
+
return false;
|
| 2056 |
+
#endif
|
| 2057 |
+
}
|
| 2058 |
+
|
| 2059 |
+
static inline bool cpuinfo_has_arm_sha2(void) {
|
| 2060 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 2061 |
+
return cpuinfo_isa.sha2;
|
| 2062 |
+
#else
|
| 2063 |
+
return false;
|
| 2064 |
+
#endif
|
| 2065 |
+
}
|
| 2066 |
+
|
| 2067 |
+
static inline bool cpuinfo_has_arm_pmull(void) {
|
| 2068 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 2069 |
+
return cpuinfo_isa.pmull;
|
| 2070 |
+
#else
|
| 2071 |
+
return false;
|
| 2072 |
+
#endif
|
| 2073 |
+
}
|
| 2074 |
+
|
| 2075 |
+
static inline bool cpuinfo_has_arm_crc32(void) {
|
| 2076 |
+
#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
|
| 2077 |
+
return cpuinfo_isa.crc32;
|
| 2078 |
+
#else
|
| 2079 |
+
return false;
|
| 2080 |
+
#endif
|
| 2081 |
+
}
|
| 2082 |
+
|
| 2083 |
+
static inline bool cpuinfo_has_arm_sve(void) {
|
| 2084 |
+
#if CPUINFO_ARCH_ARM64
|
| 2085 |
+
return cpuinfo_isa.sve;
|
| 2086 |
+
#else
|
| 2087 |
+
return false;
|
| 2088 |
+
#endif
|
| 2089 |
+
}
|
| 2090 |
+
|
| 2091 |
+
static inline bool cpuinfo_has_arm_sve_bf16(void) {
|
| 2092 |
+
#if CPUINFO_ARCH_ARM64
|
| 2093 |
+
return cpuinfo_isa.sve && cpuinfo_isa.bf16;
|
| 2094 |
+
#else
|
| 2095 |
+
return false;
|
| 2096 |
+
#endif
|
| 2097 |
+
}
|
| 2098 |
+
|
| 2099 |
+
static inline bool cpuinfo_has_arm_sve2(void) {
|
| 2100 |
+
#if CPUINFO_ARCH_ARM64
|
| 2101 |
+
return cpuinfo_isa.sve2;
|
| 2102 |
+
#else
|
| 2103 |
+
return false;
|
| 2104 |
+
#endif
|
| 2105 |
+
}
|
| 2106 |
+
|
| 2107 |
+
// Function to get the max SVE vector length on ARM CPU's which support SVE.
|
| 2108 |
+
static inline uint32_t cpuinfo_get_max_arm_sve_length(void) {
|
| 2109 |
+
#if CPUINFO_ARCH_ARM64
|
| 2110 |
+
return cpuinfo_isa.svelen * 8; // bytes * 8 = bit length(vector length)
|
| 2111 |
+
#else
|
| 2112 |
+
return 0;
|
| 2113 |
+
#endif
|
| 2114 |
+
}
|
| 2115 |
+
|
| 2116 |
+
// Function to get the max SME vector length on ARM CPU's which support SME.
|
| 2117 |
+
static inline uint32_t cpuinfo_get_max_arm_sme_length(void) {
|
| 2118 |
+
#if CPUINFO_ARCH_ARM64
|
| 2119 |
+
return cpuinfo_isa.smelen * 8; // bytes * 8 = bit length(vector length)
|
| 2120 |
+
#else
|
| 2121 |
+
return 0;
|
| 2122 |
+
#endif
|
| 2123 |
+
}
|
| 2124 |
+
|
| 2125 |
+
static inline bool cpuinfo_has_arm_sme(void) {
|
| 2126 |
+
#if CPUINFO_ARCH_ARM64
|
| 2127 |
+
return cpuinfo_isa.sme;
|
| 2128 |
+
#else
|
| 2129 |
+
return false;
|
| 2130 |
+
#endif
|
| 2131 |
+
}
|
| 2132 |
+
|
| 2133 |
+
static inline bool cpuinfo_has_arm_sme2(void) {
|
| 2134 |
+
#if CPUINFO_ARCH_ARM64
|
| 2135 |
+
return cpuinfo_isa.sme2;
|
| 2136 |
+
#else
|
| 2137 |
+
return false;
|
| 2138 |
+
#endif
|
| 2139 |
+
}
|
| 2140 |
+
|
| 2141 |
+
static inline bool cpuinfo_has_arm_sme2p1(void) {
|
| 2142 |
+
#if CPUINFO_ARCH_ARM64
|
| 2143 |
+
return cpuinfo_isa.sme2p1;
|
| 2144 |
+
#else
|
| 2145 |
+
return false;
|
| 2146 |
+
#endif
|
| 2147 |
+
}
|
| 2148 |
+
|
| 2149 |
+
static inline bool cpuinfo_has_arm_sme_i16i32(void) {
|
| 2150 |
+
#if CPUINFO_ARCH_ARM64
|
| 2151 |
+
return cpuinfo_isa.sme_i16i32;
|
| 2152 |
+
#else
|
| 2153 |
+
return false;
|
| 2154 |
+
#endif
|
| 2155 |
+
}
|
| 2156 |
+
|
| 2157 |
+
static inline bool cpuinfo_has_arm_sme_bi32i32(void) {
|
| 2158 |
+
#if CPUINFO_ARCH_ARM64
|
| 2159 |
+
return cpuinfo_isa.sme_bi32i32;
|
| 2160 |
+
#else
|
| 2161 |
+
return false;
|
| 2162 |
+
#endif
|
| 2163 |
+
}
|
| 2164 |
+
|
| 2165 |
+
static inline bool cpuinfo_has_arm_sme_b16b16(void) {
|
| 2166 |
+
#if CPUINFO_ARCH_ARM64
|
| 2167 |
+
return cpuinfo_isa.sme_b16b16;
|
| 2168 |
+
#else
|
| 2169 |
+
return false;
|
| 2170 |
+
#endif
|
| 2171 |
+
}
|
| 2172 |
+
|
| 2173 |
+
static inline bool cpuinfo_has_arm_sme_f16f16(void) {
|
| 2174 |
+
#if CPUINFO_ARCH_ARM64
|
| 2175 |
+
return cpuinfo_isa.sme_f16f16;
|
| 2176 |
+
#else
|
| 2177 |
+
return false;
|
| 2178 |
+
#endif
|
| 2179 |
+
}
|
| 2180 |
+
|
| 2181 |
+
#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
|
| 2182 |
+
/* This structure is not a part of stable API. Use cpuinfo_has_riscv_* functions
|
| 2183 |
+
* instead. */
|
| 2184 |
+
struct cpuinfo_riscv_isa {
|
| 2185 |
+
/**
|
| 2186 |
+
* Keep fields in line with the canonical order as defined by
|
| 2187 |
+
* Section 27.11 Subset Naming Convention.
|
| 2188 |
+
*/
|
| 2189 |
+
/* RV32I/64I/128I Base ISA. */
|
| 2190 |
+
bool i;
|
| 2191 |
+
#if CPUINFO_ARCH_RISCV32
|
| 2192 |
+
/* RV32E Base ISA. */
|
| 2193 |
+
bool e;
|
| 2194 |
+
#endif
|
| 2195 |
+
/* Integer Multiply/Divide Extension. */
|
| 2196 |
+
bool m;
|
| 2197 |
+
/* Atomic Extension. */
|
| 2198 |
+
bool a;
|
| 2199 |
+
/* Single-Precision Floating-Point Extension. */
|
| 2200 |
+
bool f;
|
| 2201 |
+
/* Double-Precision Floating-Point Extension. */
|
| 2202 |
+
bool d;
|
| 2203 |
+
/* Compressed Extension. */
|
| 2204 |
+
bool c;
|
| 2205 |
+
/* Vector Extension. */
|
| 2206 |
+
bool v;
|
| 2207 |
+
};
|
| 2208 |
+
|
| 2209 |
+
extern struct cpuinfo_riscv_isa cpuinfo_isa;
|
| 2210 |
+
#endif
|
| 2211 |
+
|
| 2212 |
+
static inline bool cpuinfo_has_riscv_i(void) {
|
| 2213 |
+
#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
|
| 2214 |
+
return cpuinfo_isa.i;
|
| 2215 |
+
#else
|
| 2216 |
+
return false;
|
| 2217 |
+
#endif
|
| 2218 |
+
}
|
| 2219 |
+
|
| 2220 |
+
static inline bool cpuinfo_has_riscv_e(void) {
|
| 2221 |
+
#if CPUINFO_ARCH_RISCV32
|
| 2222 |
+
return cpuinfo_isa.e;
|
| 2223 |
+
#else
|
| 2224 |
+
return false;
|
| 2225 |
+
#endif
|
| 2226 |
+
}
|
| 2227 |
+
|
| 2228 |
+
static inline bool cpuinfo_has_riscv_m(void) {
|
| 2229 |
+
#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
|
| 2230 |
+
return cpuinfo_isa.m;
|
| 2231 |
+
#else
|
| 2232 |
+
return false;
|
| 2233 |
+
#endif
|
| 2234 |
+
}
|
| 2235 |
+
|
| 2236 |
+
static inline bool cpuinfo_has_riscv_a(void) {
|
| 2237 |
+
#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
|
| 2238 |
+
return cpuinfo_isa.a;
|
| 2239 |
+
#else
|
| 2240 |
+
return false;
|
| 2241 |
+
#endif
|
| 2242 |
+
}
|
| 2243 |
+
|
| 2244 |
+
static inline bool cpuinfo_has_riscv_f(void) {
|
| 2245 |
+
#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
|
| 2246 |
+
return cpuinfo_isa.f;
|
| 2247 |
+
#else
|
| 2248 |
+
return false;
|
| 2249 |
+
#endif
|
| 2250 |
+
}
|
| 2251 |
+
|
| 2252 |
+
static inline bool cpuinfo_has_riscv_d(void) {
|
| 2253 |
+
#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
|
| 2254 |
+
return cpuinfo_isa.d;
|
| 2255 |
+
#else
|
| 2256 |
+
return false;
|
| 2257 |
+
#endif
|
| 2258 |
+
}
|
| 2259 |
+
|
| 2260 |
+
static inline bool cpuinfo_has_riscv_g(void) {
|
| 2261 |
+
// The 'G' extension is simply shorthand for 'IMAFD'.
|
| 2262 |
+
return cpuinfo_has_riscv_i() && cpuinfo_has_riscv_m() && cpuinfo_has_riscv_a() && cpuinfo_has_riscv_f() &&
|
| 2263 |
+
cpuinfo_has_riscv_d();
|
| 2264 |
+
}
|
| 2265 |
+
|
| 2266 |
+
static inline bool cpuinfo_has_riscv_c(void) {
|
| 2267 |
+
#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
|
| 2268 |
+
return cpuinfo_isa.c;
|
| 2269 |
+
#else
|
| 2270 |
+
return false;
|
| 2271 |
+
#endif
|
| 2272 |
+
}
|
| 2273 |
+
|
| 2274 |
+
static inline bool cpuinfo_has_riscv_v(void) {
|
| 2275 |
+
#if CPUINFO_ARCH_RISCV32 || CPUINFO_ARCH_RISCV64
|
| 2276 |
+
return cpuinfo_isa.v;
|
| 2277 |
+
#else
|
| 2278 |
+
return false;
|
| 2279 |
+
#endif
|
| 2280 |
+
}
|
| 2281 |
+
|
| 2282 |
+
const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processors(void);
|
| 2283 |
+
const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_cores(void);
|
| 2284 |
+
const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_clusters(void);
|
| 2285 |
+
const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_packages(void);
|
| 2286 |
+
const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarchs(void);
|
| 2287 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void);
|
| 2288 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void);
|
| 2289 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void);
|
| 2290 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void);
|
| 2291 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void);
|
| 2292 |
+
|
| 2293 |
+
const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_processor(uint32_t index);
|
| 2294 |
+
const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_core(uint32_t index);
|
| 2295 |
+
const struct cpuinfo_cluster* CPUINFO_ABI cpuinfo_get_cluster(uint32_t index);
|
| 2296 |
+
const struct cpuinfo_package* CPUINFO_ABI cpuinfo_get_package(uint32_t index);
|
| 2297 |
+
const struct cpuinfo_uarch_info* CPUINFO_ABI cpuinfo_get_uarch(uint32_t index);
|
| 2298 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index);
|
| 2299 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index);
|
| 2300 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index);
|
| 2301 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index);
|
| 2302 |
+
const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index);
|
| 2303 |
+
|
| 2304 |
+
uint32_t CPUINFO_ABI cpuinfo_get_processors_count(void);
|
| 2305 |
+
uint32_t CPUINFO_ABI cpuinfo_get_cores_count(void);
|
| 2306 |
+
uint32_t CPUINFO_ABI cpuinfo_get_clusters_count(void);
|
| 2307 |
+
uint32_t CPUINFO_ABI cpuinfo_get_packages_count(void);
|
| 2308 |
+
uint32_t CPUINFO_ABI cpuinfo_get_uarchs_count(void);
|
| 2309 |
+
uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void);
|
| 2310 |
+
uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void);
|
| 2311 |
+
uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void);
|
| 2312 |
+
uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void);
|
| 2313 |
+
uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void);
|
| 2314 |
+
|
| 2315 |
+
/**
|
| 2316 |
+
* Returns upper bound on cache size.
|
| 2317 |
+
*/
|
| 2318 |
+
uint32_t CPUINFO_ABI cpuinfo_get_max_cache_size(void);
|
| 2319 |
+
|
| 2320 |
+
/**
|
| 2321 |
+
* Identify the logical processor that executes the current thread.
|
| 2322 |
+
*
|
| 2323 |
+
* There is no guarantee that the thread will stay on the same logical processor
|
| 2324 |
+
* for any time. Callers should treat the result as only a hint, and be prepared
|
| 2325 |
+
* to handle NULL return value.
|
| 2326 |
+
*/
|
| 2327 |
+
const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void);
|
| 2328 |
+
|
| 2329 |
+
/**
|
| 2330 |
+
* Identify the core that executes the current thread.
|
| 2331 |
+
*
|
| 2332 |
+
* There is no guarantee that the thread will stay on the same core for any
|
| 2333 |
+
* time. Callers should treat the result as only a hint, and be prepared to
|
| 2334 |
+
* handle NULL return value.
|
| 2335 |
+
*/
|
| 2336 |
+
const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void);
|
| 2337 |
+
|
| 2338 |
+
/**
|
| 2339 |
+
* Identify the microarchitecture index of the core that executes the current
|
| 2340 |
+
* thread. If the system does not support such identification, the function
|
| 2341 |
+
* returns 0.
|
| 2342 |
+
*
|
| 2343 |
+
* There is no guarantee that the thread will stay on the same type of core for
|
| 2344 |
+
* any time. Callers should treat the result as only a hint.
|
| 2345 |
+
*/
|
| 2346 |
+
uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index(void);
|
| 2347 |
+
|
| 2348 |
+
/**
|
| 2349 |
+
* Identify the microarchitecture index of the core that executes the current
|
| 2350 |
+
* thread. If the system does not support such identification, the function
|
| 2351 |
+
* returns the user-specified default value.
|
| 2352 |
+
*
|
| 2353 |
+
* There is no guarantee that the thread will stay on the same type of core for
|
| 2354 |
+
* any time. Callers should treat the result as only a hint.
|
| 2355 |
+
*/
|
| 2356 |
+
uint32_t CPUINFO_ABI cpuinfo_get_current_uarch_index_with_default(uint32_t default_uarch_index);
|
| 2357 |
+
|
| 2358 |
+
#ifdef __cplusplus
|
| 2359 |
+
} /* extern "C" */
|
| 2360 |
+
#endif
|
| 2361 |
+
|
| 2362 |
+
#endif /* CPUINFO_H */
|
| 2363 |
+
|
| 2364 |
+
#else
|
| 2365 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 2366 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_H
|
| 19 |
+
#define DNNL_H
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl.h"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_H */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl.hpp
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_HPP
|
| 19 |
+
#define DNNL_HPP
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl.hpp"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_HPP */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_config.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_CONFIG_H
|
| 19 |
+
#define DNNL_CONFIG_H
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_config.h"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_CONFIG_H */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_debug.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_DEBUG_H
|
| 19 |
+
#define DNNL_DEBUG_H
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_debug.h"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_DEBUG_H */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_ocl.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_OCL_H
|
| 19 |
+
#define DNNL_OCL_H
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_ocl.h"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_OCL_H */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_ocl.hpp
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_OCL_HPP
|
| 19 |
+
#define DNNL_OCL_HPP
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_ocl.hpp"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_OCL_HPP */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_sycl.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_SYCL_H
|
| 19 |
+
#define DNNL_SYCL_H
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_sycl.h"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_SYCL_H */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_sycl.hpp
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_SYCL_HPP
|
| 19 |
+
#define DNNL_SYCL_HPP
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_sycl.hpp"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_SYCL_HPP */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_sycl_types.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_SYCL_TYPES_H
|
| 19 |
+
#define DNNL_SYCL_TYPES_H
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_sycl_types.h"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_SYCL_TYPES_H */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_threadpool.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_THREADPOOL_H
|
| 19 |
+
#define DNNL_THREADPOOL_H
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_threadpool.h"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_THREADPOOL_H */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_threadpool.hpp
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_THREADPOOL_HPP
|
| 19 |
+
#define DNNL_THREADPOOL_HPP
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_threadpool.hpp"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_THREADPOOL_HPP */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_threadpool_iface.hpp
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_THREADPOOL_IFACE_HPP
|
| 19 |
+
#define DNNL_THREADPOOL_IFACE_HPP
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_threadpool_iface.hpp"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_THREADPOOL_IFACE_HPP */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
outputs/audit_venv/lib/python3.11/site-packages/torch/include/dnnl_types.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|
| 2 |
+
/*******************************************************************************
|
| 3 |
+
* Copyright 2020 Intel Corporation
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 |
+
* you may not use this file except in compliance with the License.
|
| 7 |
+
* You may obtain a copy of the License at
|
| 8 |
+
*
|
| 9 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
*
|
| 11 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 |
+
* See the License for the specific language governing permissions and
|
| 15 |
+
* limitations under the License.
|
| 16 |
+
*******************************************************************************/
|
| 17 |
+
|
| 18 |
+
#ifndef DNNL_TYPES_H
|
| 19 |
+
#define DNNL_TYPES_H
|
| 20 |
+
|
| 21 |
+
#include "oneapi/dnnl/dnnl_types.h"
|
| 22 |
+
|
| 23 |
+
#endif /* DNNL_TYPES_H */
|
| 24 |
+
|
| 25 |
+
#else
|
| 26 |
+
#error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
|
| 27 |
+
#endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
|