Skip to content

Commit 91f5de3

Browse files
committed
[vecops] Increase size of long test RVec instances in RVec test
For the tests to make sense, some vectors need to be longer than the maximum small vector size. This maximum size is compiler and architecture dependent. For `RVec<int>` on ARM64 with gcc 14, the small vector capacity turns out to be 60, which is larger than the current test vector size of 18. Therefore, the test is refactored to easily adapt the vector size, which is increased to 72. A `static_assert` is also added, to make sure there is an early compilation error if the vectors are not long enough.
1 parent cc9e693 commit 91f5de3

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

math/vecops/test/vecops_rvec.cxx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,15 +1672,35 @@ TEST_P(VecOpsSwap, BothSmallVectors)
16721672

16731673
TEST_P(VecOpsSwap, BothRegularVectors)
16741674
{
1675-
RVec<int> fixed_vreg1{1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3};
1676-
RVec<int> fixed_vreg2{4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6};
1677-
RVec<int> fixed_vreg3{7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7};
1675+
constexpr std::size_t nElems = 72;
1676+
constexpr std::size_t smallVecSize = ROOT::Internal::VecOps::RVecInlineStorageSize<int>::value;
1677+
static_assert(nElems > smallVecSize,
1678+
"The RVec instances in this test should be larger than the maximum small vector size!");
1679+
constexpr int nCycle = 3;
1680+
1681+
RVec<int> fixed_vreg1(nElems);
1682+
RVec<int> fixed_vreg2(nElems);
1683+
RVec<int> fixed_vreg3(nElems + 1);
16781684
RVec<int> fixed_vmocksmall{0, 7};
16791685

1680-
RVec<int> vreg1{1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3};
1681-
RVec<int> vreg2{4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6, 4, 5, 6};
1682-
RVec<int> vreg3{7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7};
1683-
RVec<int> vmocksmall{0, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 7, 8, 9, 7, 8, 9};
1686+
RVec<int> vreg1(nElems);
1687+
RVec<int> vreg2(nElems);
1688+
RVec<int> vreg3(nElems + 1);
1689+
RVec<int> vmocksmall(nElems);
1690+
std::cout << vmocksmall[0] << std::endl;
1691+
1692+
for (std::size_t i = 0; i < nElems; ++i) {
1693+
vreg1[i] = (i % nCycle) + 1;
1694+
vreg2[i] = vreg1[i] + nCycle;
1695+
vreg3[i] = vreg2[i] + nCycle;
1696+
fixed_vreg1[i] = vreg1[i];
1697+
fixed_vreg2[i] = vreg2[i];
1698+
fixed_vreg3[i] = vreg3[i];
1699+
vmocksmall[i + 1] = vreg3[i];
1700+
}
1701+
fixed_vreg3[nElems] = fixed_vreg3[0];
1702+
vreg3[nElems] = vreg3[0];
1703+
16841704
vmocksmall.erase(vmocksmall.begin() + 2, vmocksmall.end());
16851705
// vmocksmall is a regular vector of size 2
16861706

0 commit comments

Comments
 (0)