feature: optimize img2buf and buf2img builtins

Related-To: NEO-16652

Signed-off-by: Narendra Bagria <narendra.bagria@intel.com>
This commit is contained in:
Narendra Bagria
2025-11-14 12:10:22 +00:00
committed by Compute-Runtime-Automation
parent 4d4da44aff
commit f460980d14
17 changed files with 1678 additions and 172 deletions

View File

@@ -119,6 +119,13 @@ inline bool isAligned(T *ptr) {
// alignment requirement (returned by alignof) is always a power of 2
return (reinterpret_cast<uintptr_t>(ptr) & (alignof(T) - 1)) == 0;
}
// Variadic template to check if all values are aligned
template <size_t alignment, typename... Ts>
inline constexpr bool isAligned(Ts... vals) {
return (isAligned<alignment>(vals) && ...);
}
inline auto allocateAlignedMemory(size_t bytes, size_t alignment) {
return std::unique_ptr<void, std::function<decltype(alignedFree)>>(alignedMalloc(bytes, alignment), alignedFree);
}