Skip to content

Commit e423201

Browse files
author
Fikret Ardal
committed
fix aligned allocator
1 parent ccf6a9a commit e423201

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

c++/nda/mem/aligned_alloc.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ namespace nda::mem {
5252

5353
void *ptr = nullptr;
5454
if constexpr (AdrSp == Host) {
55+
if (alignment != 0) {
56+
size = next_multiple(size, alignment);
57+
}
5558
if (alignment >= 8UL) {
5659
ptr = std::aligned_alloc(alignment, size);
5760
} else {

test/c++/nda_basic_array_and_view.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -960,33 +960,6 @@ TEST_F(NDAArrayAndView, StrideOrderOfArrays) {
960960
*/
961961
TEST_F(NDAArrayAndView, ArrayAligned) {
962962
nda::array_aligned<int,2,nda::C_layout> M = {{1, 2}, {3, 4}, {5, 6}};
963-
// EXPECT_EQ(M.shape(), (shape_t<2>{3, 2}));
964-
// for (int i = 1; auto x : M) EXPECT_EQ(x, i++);
965-
// for (int i = 0 ; i < 2; ++i) {
966-
// for (int j = 0 ;j < 2; ++j) {
967-
// std::cout << M(i, j) << " ";
968-
// }
969-
// std::cout << std::endl;
970-
// }
971-
// nda::native_simd<int> x(&M(0,0), xsimd::aligned_mode());
972-
// nda::native_simd<int> y(&M(1,0), xsimd::aligned_mode());
973-
// nda::native_simd<int> z(&M(2,0), xsimd::aligned_mode());
974-
// alignas(x.alignment()) std::array<int,x.size()> test;
975-
// x.store(test.data());
976-
//
977-
// for (int i = 0 ; i < 8 ; ++i) {
978-
// std::cout << "x: " << test[i] << std::endl;
979-
// }
980-
// y.store(test.data());
981-
//
982-
// for (int i = 0 ; i < 8 ; ++i) {
983-
// std::cout << "y: " << test[i] << std::endl;
984-
// }
985-
// z.store(test.data());
986-
// for (int i = 0 ; i < 8 ; ++i) {
987-
// std::cout << "z: " << test[i] << std::endl;
988-
// }
989-
990963
}
991964

992965
#if defined(__has_feature)

0 commit comments

Comments
 (0)