From 694c597d9d3572331b7bb16b5ab354653b938792 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Sun, 17 Jun 2018 12:33:33 +0100 Subject: Refactoring: progress on SSE2 Clean up tests --- aligned.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 aligned.h (limited to 'aligned.h') diff --git a/aligned.h b/aligned.h new file mode 100644 index 0000000..44889d1 --- /dev/null +++ b/aligned.h @@ -0,0 +1,22 @@ +#pragma once + +// Define allocation like: +// free_ptr quantized(AlignedArray(rows * cols)); +// This is only used by tests. + +#include + +namespace intgemm { + +struct DeleteWithFree { + template void operator() (T *t) const { + std::free(const_cast* >(t)); + } +}; +template using free_ptr = std::unique_ptr; +// Return memory suitably aligned for SIMD. +template T* AlignedArray(std::size_t size) { + return static_cast(aligned_alloc(64, size * sizeof(T))); +} + +} // namespace intgemm -- cgit v1.2.3