Project
Loading...
Searching...
No Matches
test_ransAlignedArray.cxx
Go to the documentation of this file.
1// Copyright 2019-2023 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#define BOOST_TEST_MODULE Utility test
17#define BOOST_TEST_MAIN
18#define BOOST_TEST_DYN_LINK
19
20#include <vector>
21#include <type_traits>
22#include <array>
23
24#include <boost/test/unit_test.hpp>
25#include <boost/mpl/list.hpp>
26
27#include <fairlogger/Logger.h>
28
30
31#ifdef RANS_SIMD
32
34
35BOOST_AUTO_TEST_CASE(test_AlignedArray)
36{
37 using namespace o2::rans::internal::simd;
38
40
41 const array_t a{1u, 2u, 3u, 4u};
42 const std::array<uint32_t, 4> reference{1u, 2u, 3u, 4u};
43 BOOST_CHECK_EQUAL(a.nElements(), 4);
44 BOOST_CHECK_EQUAL(a.size(), 1);
45 BOOST_CHECK_EQUAL(a.data(), &a(0));
46
47 BOOST_CHECK_EQUAL_COLLECTIONS(gsl::make_span(a).begin(), gsl::make_span(a).end(), reference.begin(), reference.end());
48 BOOST_CHECK_EQUAL_COLLECTIONS(gsl::make_span(a).rbegin(), gsl::make_span(a).rend(), reference.rbegin(), reference.rend());
49
50 BOOST_CHECK_EQUAL(a[0], gsl::make_span(a.data(), 4));
51
52 const array_t a2{1};
53 const std::array<uint32_t, 4> reference2{1u, 1u, 1u, 1u};
54 BOOST_CHECK_EQUAL(a2.size(), 1);
55 BOOST_CHECK_EQUAL(a2.nElements(), 4);
56 BOOST_CHECK_EQUAL(a2.data(), &a2(0));
57
58 BOOST_CHECK_EQUAL_COLLECTIONS(gsl::make_span(a2).begin(), gsl::make_span(a2).end(), reference2.begin(), reference2.end());
59 BOOST_CHECK_EQUAL_COLLECTIONS(gsl::make_span(a2).rbegin(), gsl::make_span(a2).rend(), reference2.rbegin(), reference2.rend());
60};
61
62#else /* !defined(RANS_SIMD) */
63
65{
66 BOOST_TEST_WARN("Tests were not Compiled for SIMD, cannot run all tests");
67}
68
69#endif
Memory aligned array used for SIMD operations.
preprocessor defines to enable features based on CPU architecture
GLuint GLuint end
Definition glcorearb.h:469
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
auto make_span(const o2::rans::internal::simd::AlignedArray< T, width_V, size_V > &array)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())
BOOST_AUTO_TEST_CASE(test_NoSIMD)