Disable aligned allocation in non linux/macos#82
Conversation
…sable non-linux/macos aligned alloc
|
Following discussion is the motivation of introducing aligned allocation. Why I tried to use aligned allocation, but actually not that useful? Using aligned allocation is increasing (but seems not surely) increase the posibility to use However, in actual,
The above comment is mostly for electronic integrals and GTO-type orbital computation, but similar discussion may also applie here. I think that for most users that want to use tensors in scientific programming, is not very concern on how data is aligned. Concerning alignment when writing code is actually great burden to programmer, since correctly using alignment usually requires intrinsics/assembly-level optimization; this is too technical and is not what a scientist should think about. |
This PR will disable aligned allocation on non-linux/macos platforms (actually that's windows).
Current aligned allocation follows https://users.rust-lang.org/t/how-can-i-allocate-aligned-memory-in-rust/33293.
Aligned allocation may be UB, dependent on compiler. In linux/macos, which usually uses LLVM backend, it seems aligned allocation will be correctly freed; while in windows, the aligned pointer and freed pointer may have some wrong magic that will have some corruption, which reason I'm not very sure but will cause memory-related problems.
This is related to a problem found in rest_libcint: https://gitee.com/restgroup/rest_libcint/pulls/6, which is found and proposed by @jeanwsr.