mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-04 12:15:11 +08:00
use built in alloca with align if available
This commit is contained in:
parent
b9b1c8661e
commit
f78dfe36b0
@ -765,6 +765,9 @@ void swap(scoped_array<T>& a, scoped_array<T>& b) {
|
|||||||
// We always manually re-align the result of EIGEN_ALLOCA.
|
// We always manually re-align the result of EIGEN_ALLOCA.
|
||||||
// If alloca is already aligned, the compiler should be smart enough to optimize away the re-alignment.
|
// If alloca is already aligned, the compiler should be smart enough to optimize away the re-alignment.
|
||||||
|
|
||||||
|
#if (EIGEN_COMP_GNUC || EIGEN_COMP_CLANG)
|
||||||
|
#define EIGEN_ALIGNED_ALLOCA(SIZE) __builtin_alloca_with_align(SIZE, CHAR_BIT* EIGEN_DEFAULT_ALIGN_BYTES)
|
||||||
|
#else
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void* eigen_aligned_alloca_helper(void* ptr) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void* eigen_aligned_alloca_helper(void* ptr) {
|
||||||
constexpr std::uintptr_t mask = EIGEN_DEFAULT_ALIGN_BYTES - 1;
|
constexpr std::uintptr_t mask = EIGEN_DEFAULT_ALIGN_BYTES - 1;
|
||||||
std::uintptr_t ptr_int = std::uintptr_t(ptr);
|
std::uintptr_t ptr_int = std::uintptr_t(ptr);
|
||||||
@ -772,8 +775,9 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void* eigen_aligned_alloca_helper(void* pt
|
|||||||
std::uintptr_t offset = aligned_ptr_int - ptr_int;
|
std::uintptr_t offset = aligned_ptr_int - ptr_int;
|
||||||
return static_cast<void*>(static_cast<uint8_t*>(ptr) + offset);
|
return static_cast<void*>(static_cast<uint8_t*>(ptr) + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EIGEN_ALIGNED_ALLOCA(SIZE) eigen_aligned_alloca_helper(EIGEN_ALLOCA(SIZE + EIGEN_DEFAULT_ALIGN_BYTES - 1))
|
#define EIGEN_ALIGNED_ALLOCA(SIZE) eigen_aligned_alloca_helper(EIGEN_ALLOCA(SIZE + EIGEN_DEFAULT_ALIGN_BYTES - 1))
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define EIGEN_ALIGNED_ALLOCA(SIZE) EIGEN_ALLOCA(SIZE)
|
#define EIGEN_ALIGNED_ALLOCA(SIZE) EIGEN_ALLOCA(SIZE)
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user