Skip to content

Commit b2b0035

Browse files
committed
Try to use std::aligned_alloc for MacOS
1 parent 8bbb8b0 commit b2b0035

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

pennylane_lightning/src/util/Memory.hpp

+2-12
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,7 @@ namespace Pennylane::Util {
3434
* @return Pointer to the allocated memory
3535
*/
3636
inline auto alignedAlloc(uint32_t alignment, size_t bytes) -> void * {
37-
#if defined(__clang__) && defined(__APPLE__)
38-
/*
39-
* We use `posix_memalign` for MacOS as Mac does not support
40-
* `std::aligned_alloc` properly yet (even in MacOS 10.15).
41-
*/
42-
void *p;
43-
posix_memalign(&p, alignment, bytes);
44-
return p;
45-
#elif defined(_MSC_VER)
37+
#if defined(_MSC_VER)
4638
return _aligned_malloc(bytes, alignment);
4739
#else
4840
return std::aligned_alloc(alignment, bytes);
@@ -55,9 +47,7 @@ inline auto alignedAlloc(uint32_t alignment, size_t bytes) -> void * {
5547
* @param p Pointer to the memory location allocated by aligendAlloc
5648
*/
5749
inline void alignedFree(void *p) {
58-
#if defined(__clang__) && defined(__APPLE__)
59-
return ::free(p); // NOLINT(hicpp-no-malloc)
60-
#elif defined(_MSC_VER)
50+
#if defined(_MSC_VER)
6151
return _aligned_free(p);
6252
#else
6353
return std::free(p);

0 commit comments

Comments
 (0)