Skip to content

Commit 2ed3b10

Browse files
authored
Merge pull request #2246 from JohanMabille/align
Testing alignment
2 parents 16b3783 + ba8c27c commit 2ed3b10

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

.azure-pipelines/azure-pipelines-linux-clang.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
llvm_version: '8'
1515
clang_9:
1616
llvm_version: '9'
17+
clang_10:
18+
llvm_version: '10'
19+
disable_xsimd: 1
1720
pool:
1821
vmImage: ubuntu-16.04
1922
variables:

docs/source/xsimd.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ Alignment of fixed-size members
1818

1919
If you define a structure having members of fixed-size xtensor types,
2020
you must ensure that the buffers properly aligned.
21-
For this you can use the macro ``XTENSOR_SELECT_ALIGN`` available in
21+
For this you can use the macro ``XTENSOR_FIXED_ALIGN`` available in
2222
``xtensor/xtensor_config.hpp``.
2323
Consider the following example:
2424

2525
.. code-block:: cpp
2626
2727
template <typename T>
28-
class alignas(XTENSOR_SELECT_ALIGN(T)) Foo
28+
class alignas(XTENSOR_FIXED_ALIGN) Foo
2929
{
3030
public:
3131
32-
using allocator_type = std::conditional_t<XTENSOR_SELECT_ALIGN(T) != 0,
33-
xt_simd::aligned_allocator<T, XTENSOR_SELECT_ALIGN(T)>,
32+
using allocator_type = std::conditional_t<XTENSOR_FIXED_ALIGN != 0,
33+
xt_simd::aligned_allocator<T, XTENSOR_FIXED_ALIGN>,
3434
std::allocator<T>>;
3535
3636
Foo(T fac) : m_fac(fac)

include/xtensor/xtensor_config.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
#define XTENSOR_SELECT_ALIGN(T) (XTENSOR_DEFAULT_ALIGNMENT != 0 ? XTENSOR_DEFAULT_ALIGNMENT : alignof(T))
115115
#endif
116116

117+
#ifndef XTENSOR_FIXED_ALIGN
118+
#define XTENSOR_FIXED_ALIGN XTENSOR_SELECT_ALIGN(void*)
119+
#endif
120+
117121
#ifdef IN_DOXYGEN
118122
namespace xtl
119123
{

test/test_xsimd.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
#include "xtensor/xtensor_config.hpp"
1616

1717
template <typename T>
18-
class alignas(XTENSOR_SELECT_ALIGN(T)) Foo
18+
class alignas(XTENSOR_FIXED_ALIGN) Foo
1919
{
2020
public:
2121

22-
using allocator_type = std::conditional_t<XTENSOR_SELECT_ALIGN(T) != 0,
23-
xt_simd::aligned_allocator<T, XTENSOR_SELECT_ALIGN(T)>,
22+
using allocator_type = std::conditional_t<XTENSOR_FIXED_ALIGN != 0,
23+
xt_simd::aligned_allocator<T, XTENSOR_FIXED_ALIGN>,
2424
std::allocator<T>>;
2525

2626
Foo(T fac) : m_fac(fac)
@@ -49,3 +49,4 @@ namespace xt
4949
EXPECT_TRUE(xt::sum(foo.get())() == fac * 10 * 10);
5050
}
5151
}
52+

0 commit comments

Comments
 (0)