fetch_ml/native/dataset_hash/crypto/sha256_x86.cpp
Jeremie Fraeys 43d241c28d
feat: implement C++ native libraries for performance-critical operations
- Add arena allocator for zero-allocation hot paths
- Add thread pool for parallel operations
- Add mmap utilities for memory-mapped I/O
- Implement queue_index with heap-based priority queue
- Implement dataset_hash with SIMD support (SHA-NI, ARMv8)
- Add runtime SIMD detection for cross-platform correctness
- Add comprehensive tests and benchmarks
2026-02-16 20:38:04 -05:00

34 lines
991 B
C++

#include "sha256_base.h"
// Intel SHA-NI (SHA Extensions) implementation
#if defined(__x86_64__) || defined(_M_X64)
#include <cpuid.h>
#include <immintrin.h>
// TODO: Full SHA-NI implementation using:
// _mm_sha256msg1_epu32, _mm_sha256msg2_epu32 for message schedule
// _mm_sha256rnds2_epu32 for rounds
// For now, falls back to generic (implementation placeholder)
static void transform_sha_ni(uint32_t* state, const uint8_t* data) {
// Placeholder: full implementation would use SHA-NI intrinsics
// This requires message scheduling with sha256msg1/sha256msg2
// and rounds with sha256rnds2
transform_generic(state, data);
}
TransformFunc detect_x86_transform(void) {
unsigned int eax, ebx, ecx, edx;
if (__get_cpuid(7, &eax, &ebx, &ecx, &edx)) {
if (ebx & (1 << 29)) { // SHA bit
return transform_sha_ni;
}
}
return nullptr;
}
#else // No x86 support
TransformFunc detect_x86_transform(void) { return nullptr; }
#endif