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

github.com/marian-nmt/intgemm/intgemm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolay Bogoychev <nheart@gmail.com>2020-01-22 20:18:33 +0300
committerNikolay Bogoychev <nheart@gmail.com>2020-01-22 20:18:33 +0300
commitc9b9fc1505ec98877cb673abc492bc9b8e8dfdb7 (patch)
treec8caca03cf4bb579f4a794da1bd368d1d4643b88
parent411dc06bcefba4588d57b5b39abc2221d753dfba (diff)
parent4eede3b46b07ff9a929c7c299408fc989055dc4f (diff)
Merge branch 'mac_support'
-rw-r--r--CMakeLists.txt6
-rw-r--r--aligned.h9
2 files changed, 8 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a9f3d1..31e5ff4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,11 +8,7 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
-if(APPLE)
- set(CMAKE_CXX_STANDARD 17) # aligned_alloc doesn't work otherwise
-else(APPLE)
- set(CMAKE_CXX_STANDARD 11)
-endif(APPLE)
+set(CMAKE_CXX_STANDARD 11)
# Check if compiler supports AVX512
try_compile(INTGEMM_COMPILER_SUPPORTS_AVX512
diff --git a/aligned.h b/aligned.h
index b5512ba..6e72afb 100644
--- a/aligned.h
+++ b/aligned.h
@@ -1,6 +1,6 @@
#pragma once
#include <cstdlib>
-#include <algorithm>
+#include <stdlib.h>
// 64-byte aligned simple vector.
@@ -9,7 +9,12 @@ namespace intgemm {
template <class T> class AlignedVector {
public:
explicit AlignedVector(std::size_t size)
- : mem_(static_cast<T*>(aligned_alloc(64, (size * sizeof(T) + 63) & ~63))), size_(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
}
AlignedVector(const AlignedVector&) = delete;