Download cpp_engine/include/core/cache_line.hpp from Ypeng12/quant-ai: direct link, hf CLI and curl.
- Browser
- Download file 970 Bytes
-
https://huggingface.co/spaces/Ypeng12/quant-ai/resolve/main/cpp_engine/include/core/cache_line.hpp
- Command line
-
hf download hf://spaces/Ypeng12/quant-ai/cpp_engine/include/core/cache_line.hpp
-
curl -L -o cache_line.hpp https://huggingface.co/spaces/Ypeng12/quant-ai/resolve/main/cpp_engine/include/core/cache_line.hpp
970 Bytes
| namespace quant::core { | |
| // Standard x86_64 / ARM64 cache line size (64 bytes) | |
| constexpr size_t CACHELINE_SIZE = 64; | |
| constexpr size_t HARDWARE_DESTRUCTIVE_INTERFERENCE_SIZE = std::hardware_destructive_interference_size; | |
| constexpr size_t HARDWARE_CONSTRUCTIVE_INTERFERENCE_SIZE = std::hardware_constructive_interference_size; | |
| constexpr size_t HARDWARE_DESTRUCTIVE_INTERFERENCE_SIZE = CACHELINE_SIZE; | |
| constexpr size_t HARDWARE_CONSTRUCTIVE_INTERFERENCE_SIZE = CACHELINE_SIZE; | |
| // Padding helper to prevent false sharing between concurrent thread variables | |
| template <size_t Size> | |
| struct CacheLinePad { | |
| static constexpr size_t pad_bytes = (CACHELINE_SIZE - (Size % CACHELINE_SIZE)) % CACHELINE_SIZE; | |
| char pad[pad_bytes == 0 ? CACHELINE_SIZE : pad_bytes]; | |
| }; | |
| } // namespace quant::core | |