diff options
author | Kenneth Heafield <github@kheafield.com> | 2018-06-17 14:33:33 +0300 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2018-06-17 14:33:33 +0300 |
commit | 694c597d9d3572331b7bb16b5ab354653b938792 (patch) | |
tree | 3bccfe1e2e6fbfd00204a453a54de448cd4e8119 /aligned.h | |
parent | 6b48ad03d1fe89767bf150a12cdfd7e73be0078c (diff) |
Refactoring: progress on SSE2
Clean up tests
Diffstat (limited to 'aligned.h')
-rw-r--r-- | aligned.h | 22 |
1 files changed, 22 insertions, 0 deletions
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<Integer> quantized(AlignedArray<Integer>(rows * cols)); +// This is only used by tests. + +#include <memory> + +namespace intgemm { + +struct DeleteWithFree { + template <class T> void operator() (T *t) const { + std::free(const_cast<std::remove_const_t<T>* >(t)); + } +}; +template <class T> using free_ptr = std::unique_ptr<T, DeleteWithFree>; +// Return memory suitably aligned for SIMD. +template <class T> T* AlignedArray(std::size_t size) { + return static_cast<T*>(aligned_alloc(64, size * sizeof(T))); +} + +} // namespace intgemm |