Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/intgemm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2020-04-13 16:00:25 +0300
committerKenneth Heafield <github@kheafield.com>2020-04-13 16:00:25 +0300
commitfb96b0851cf420ac49c13b361a503afffe386ada (patch)
treee9d0fd017c9f60b5293d8c6a995e84fffe456f03
parente1970fc7bcc8354aadd077844554c0462aa31c08 (diff)
Juse use posix_memalign everywhere
-rw-r--r--aligned.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/aligned.h b/aligned.h
index 6e72afb..6af3c31 100644
--- a/aligned.h
+++ b/aligned.h
@@ -1,5 +1,6 @@
#pragma once
#include <cstdlib>
+#include <new>
#include <stdlib.h>
// 64-byte aligned simple vector.
@@ -10,11 +11,9 @@ template <class T> class AlignedVector {
public:
explicit AlignedVector(std::size_t size)
: size_(size) {
- #ifdef __APPLE__
- posix_memalign(reinterpret_cast<void **>(&mem_), 64, size * sizeof(T));
- #else
- mem_ = reinterpret_cast<T*>(aligned_alloc(64, (size * sizeof(T) + 63) & ~63)); // pedantic requirements for memory size on aligned_alloc in case it's not just a call to posix_memalign
- #endif
+ if (posix_memalign(reinterpret_cast<void **>(&mem_), 64, size * sizeof(T))) {
+ throw std::bad_alloc();
+ }
}
AlignedVector(const AlignedVector&) = delete;