icl-utk-edu / heffte

BSD 3-Clause "New" or "Revised" License
20 stars 15 forks source link

Fix AppleClang: Stock `aligned_alloc` #49

Closed ax3l closed 3 months ago

ax3l commented 3 months ago

Compiling heFFTe 2.4.0 with AppleClang 16.0.6 on macOS 13.4 raises:

include/stock_fft/heffte_stock_allocator.h:43:46: error: use of undeclared identifier 'aligned_alloc'
            return reinterpret_cast<pointer>(aligned_alloc(alignof(F), n*sizeof(F)));
                                             ^

This adds the missing include and uses the C variant of the function (the C++ variant from <cstdlib> requires C++17 but heFFTe only uses C++11 so far).

Also, macOS SDK 10.15 or newer is needed: https://stackoverflow.com/a/76984907/2719194

First seen in https://github.com/conda-forge/staged-recipes/pull/26633 for #48 .

mkstoyanov commented 3 months ago

@ax3l Thanks for contributing.

OLCF Summit did not support C++-17 and even the C++-14 support was limited to the core language and did not include STL, that's why heFFTe is kept back. I'ld like to move to 17 and do some cleanup but I have to know that's not going to break anyone's existing code.

ax3l commented 3 months ago

Thanks for the merge!

Ah yes, we use(d) an experimental NVCC on Summit to use C++17 early :D https://warpx.readthedocs.io/en/latest/install/hpc/summit.html