• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ska-sa / spead2 / 24443950125

15 Apr 2026 08:11AM UTC coverage: 78.747% (-0.01%) from 78.761%
24443950125

Pull #430

github

bmerry
Update pytest to 9.0.3

Addresses a dependabot alert. It's probably not that relevant to the
cases where we use the requirements files (CI environments where we
don't need to worry about other untrusted users in the same container).
Pull Request #430: Update pytest to 9.0.3

5569 of 7072 relevant lines covered (78.75%)

120104.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.45
/src/unittest_memcpy.cpp
1
/* Copyright 2016, 2021, 2023-2024 National Research Foundation (SARAO)
2
 *
3
 * This program is free software: you can redistribute it and/or modify it under
4
 * the terms of the GNU Lesser General Public License as published by the Free
5
 * Software Foundation, either version 3 of the License, or (at your option) any
6
 * later version.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
11
 * details.
12
 *
13
 * You should have received a copy of the GNU Lesser General Public License
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 */
16

17
/**
18
 * @file
19
 *
20
 * Unit tests for accelerated memcpy.
21
 */
22

23
#include <boost/test/unit_test.hpp>
24
#include <boost/test/data/test_case.hpp>
25
#include <utility>
26
#include <cstdint>
27
#include <ostream>
28
#include <spead2/common_memcpy.h>
29
#include <spead2/common_features.h>
30
#if SPEAD2_USE_SVE_STREAM
31
# include <sys/auxv.h>
32
#endif
33

34
/* Declare the implementations of the instruction-specific implementations, so
35
 * that we can test all of them (that the current CPU supports) rather than
36
 * just the one selected by the resolver.
37
 */
38
namespace spead2
39
{
40
#if SPEAD2_USE_SSE2_STREAM
41
void *memcpy_nontemporal_sse2(void * __restrict__ dest, const void * __restrict__ src, std::size_t n) noexcept;
42
#endif
43
#if SPEAD2_USE_AVX_STREAM
44
void *memcpy_nontemporal_avx(void * __restrict__ dest, const void * __restrict__ src, std::size_t n) noexcept;
45
#endif
46
#if SPEAD2_USE_AVX512_STREAM
47
void *memcpy_nontemporal_avx512(void * __restrict__ dest, const void * __restrict__ src, std::size_t n) noexcept;
48
#endif
49
#if SPEAD2_USE_SVE_STREAM
50
void *memcpy_nontemporal_sve(void * __restrict__ dest, const void * __restrict__ src, std::size_t n) noexcept;
51
#endif
52
} // namespace spead2
53

54
namespace spead2::unittest
55
{
56

57
BOOST_AUTO_TEST_SUITE(common)
58
BOOST_AUTO_TEST_SUITE(memcpy)
59

60
struct memcpy_function
61
{
62
    const char * name;
63
    void *(*func)(void * __restrict__, const void * __restrict__, std::size_t) noexcept;
64
    bool enabled;
65
};
66

67
std::ostream &operator<<(std::ostream &o, const memcpy_function &func)
4✔
68
{
69
    return o << func.name;
4✔
70
}
71

72
static const memcpy_function memcpy_functions[] =
73
{
74
    { "default", spead2::memcpy_nontemporal, true },
75
#if SPEAD2_USE_SSE2_STREAM
76
    { "sse2", spead2::memcpy_nontemporal_sse2, bool(__builtin_cpu_supports("sse2")) },
77
#endif
78
#if SPEAD2_USE_AVX_STREAM
79
    { "avx", spead2::memcpy_nontemporal_avx, bool(__builtin_cpu_supports("avx")) },
80
#endif
81
#if SPEAD2_USE_AVX512_STREAM
82
    { "avx512", spead2::memcpy_nontemporal_avx512, bool(__builtin_cpu_supports("avx512f")) },
83
#endif
84
#if SPEAD2_USE_SVE_STREAM
85
    { "sve", spead2::memcpy_nontemporal_sve, (getauxval(AT_HWCAP) & HWCAP_SVE) != 0 },
86
#endif
87
};
88

89
// Checks combinations of src and dest alignment relative to a page
90
BOOST_DATA_TEST_CASE(memcpy_nontemporal_alignments, boost::unit_test::data::make(memcpy_functions), sample)
12✔
91
{
92
    if (!sample.enabled)
4✔
93
        return;
×
94

95
    constexpr int head_pad = 64;
4✔
96
    constexpr int tail_pad = 64;
4✔
97
    constexpr int max_len = 1024;
4✔
98
    constexpr int align_range = 64;
4✔
99
    constexpr int buffer_size = head_pad + align_range + max_len + tail_pad;
4✔
100

101
    std::uint8_t src_buffer[buffer_size];
102
    std::uint8_t dest_buffer[buffer_size];
103
    std::uint8_t expected[buffer_size];
104
    for (int i = 0; i < align_range; i += 3)
92✔
105
        for (int j = 0; j < align_range; j += 3)
2,024✔
106
            // Step 1 at a time up to 128, then take larger steps to reduce test time
107
            for (int len = 0; len <= max_len; len = (len < 128) ? len + 1 : len + 37)
298,144✔
108
            {
109
                std::memset(dest_buffer, 255, sizeof(dest_buffer));
296,208✔
110
                for (int k = 0; k < buffer_size; k++)
360,485,136✔
111
                    src_buffer[k] = k % 255;
360,188,928✔
112
                void *ret = sample.func(dest_buffer + head_pad + i, src_buffer + head_pad + j, len);
296,208✔
113
                BOOST_TEST(ret == dest_buffer + head_pad + i);
296,208✔
114

115
                std::memset(expected, 255, sizeof(expected));
296,208✔
116
                for (int k = 0; k < len; k++)
43,716,816✔
117
                    expected[head_pad + i + k] = src_buffer[head_pad + j + k];
43,420,608✔
118
                BOOST_TEST(dest_buffer == expected);
296,208✔
119
            }
120
}
121

122
BOOST_AUTO_TEST_SUITE_END()  // memcpy
123
BOOST_AUTO_TEST_SUITE_END()  // common
124

125
} // namespace spead2::unittest
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc