Skip to content

Commit a3d9d07

Browse files
committed
Add overload of aligned_malloc function with alignment set to NATIVE_SIMD_WIDTH by default
1 parent 43a471e commit a3d9d07

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/lib/tsimd/alloc.H

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#ifndef SIMDALLOC_H_
3131
#define SIMDALLOC_H_
3232

33+
#include "defs.H"
34+
3335
#include <cstddef>
3436
#include <utility>
3537

@@ -53,6 +55,8 @@ namespace simd {
5355
* @param alignment alignment of the memory block in bytes
5456
* @param size size of the memory block in bytes
5557
* @return pointer to the allocated memory block
58+
*
59+
* @sa aligned_malloc(size_t)
5660
*/
5761
inline void *aligned_malloc(size_t alignment, size_t size)
5862
{
@@ -65,6 +69,25 @@ inline void *aligned_malloc(size_t alignment, size_t size)
6569
#endif
6670
}
6771

72+
/**
73+
* @ingroup group_aligned_alloc
74+
* @brief Aligned memory allocation aligned to `NATIVE_SIMD_WIDTH`.
75+
*
76+
* This function allocates a block of memory of size bytes, aligned to
77+
* `NATIVE_SIMD_WIDTH`.
78+
*
79+
* The allocated memory must be freed with aligned_free().
80+
*
81+
* @param size size of the memory block in bytes
82+
* @return pointer to the allocated memory block
83+
*
84+
* @sa aligned_malloc(size_t, size_t)
85+
*/
86+
inline void *aligned_malloc(size_t size)
87+
{
88+
return aligned_malloc(NATIVE_SIMD_WIDTH, size);
89+
}
90+
6891
/**
6992
* @ingroup group_aligned_alloc
7093
* @brief Aligned memory deallocation.

0 commit comments

Comments
 (0)