ralna / spral

Sparse Parallel Robust Algorithms Library
https://ralna.github.io/spral/
Other
106 stars 26 forks source link

Allow compilation of ldlt tests if targeting Windows #117

Closed mjacobse closed 1 year ago

mjacobse commented 1 year ago

Use Windows-specific _aligned_malloc and _aligned_free for implementing the AlignedAllocator in the ldlt tests on Windows.

I did consider making this completely platform-independent by upping the C-standard from C99 to C11 and just using aligned_alloc. Unfortunately, Microsoft does not support it (see https://learn.microsoft.com/en-us/cpp/standard-library/cstdlib?view=msvc-170#remarks-6) and so MinGW does not seem to provide it either. One could at least remove the posix-specific branch but that did not seem worth the standard change.

I believe another option would be to implement the aligning as in the SimpleAlignedAlloc: https://github.com/ralna/spral/blob/b1b7397f74f1ed91eb419f37a757a01918d64a30/src/ssids/cpu/SimpleAlignedAlloc.hxx#L37-L52 However, this was introduced in https://github.com/ralna/spral/commit/fea9ed81dedce4cc91a1c4746f87bc15b697f584 for "testing purposes" and does not seem to be used or tested anywhere at the moment. The only mention of it is commented out: https://github.com/ralna/spral/blob/b1b7397f74f1ed91eb419f37a757a01918d64a30/src/ssids/cpu/NumericSubtree.hxx#L35 So with those not entirely obvious reinterpret_casts for storing the original allocated pointer this did not seem like the best option to me either.