Skip to content

Commit 449de1f

Browse files
committed
Tidy
rm unused multiply more tests
1 parent cb496ca commit 449de1f

File tree

2 files changed

+16
-34
lines changed

2 files changed

+16
-34
lines changed

inc/zoo/swar/associative_iteration.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -411,36 +411,6 @@ constexpr auto associativeOperatorIterated_regressive(
411411
return result;
412412
}
413413

414-
415-
// What I don't understand is why this doesn't work?
416-
template <typename T>
417-
constexpr auto multiply(T a , T b) {
418-
auto operation = [](auto left, auto right, auto count) {
419-
if (count) {
420-
return left + right;
421-
} else {
422-
return left;
423-
}
424-
};
425-
426-
auto updateCount = [](auto count) {
427-
return count << 1;
428-
};
429-
430-
constexpr auto numBits = sizeof(T) * 8;
431-
return associativeOperatorIterated_regressive(
432-
a, // base
433-
0, // neutral
434-
b, // count
435-
1, // forSquaring, pretty sure this is where i am not understanding
436-
operation, // operation
437-
numBits, // log2Count
438-
updateCount // halver
439-
);
440-
}
441-
442-
// static_assert(multiply(3, 4) == 12, "multiply failed");
443-
444414
template<int ActualBits, int NB, typename T>
445415
constexpr auto multiplication_OverflowUnsafe_SpecificBitCount(
446416
SWAR<NB, T> multiplicand, SWAR<NB, T> multiplier

test/swar/BasicOperations.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "catch2/catch.hpp"
44

5+
#include <initializer_list>
56
#include <type_traits>
67

78

@@ -59,7 +60,7 @@ static_assert(
5960

6061
static_assert(0b00000010000000110000010100000110 == 0x02'03'05'06);
6162

62-
TEST_CASE("Jamie's totally working exponentiation :D") {
63+
TEST_CASE("Expontiation with 8-bit lane width (overflow unsafe)") {
6364
using S = SWAR<8, u32>;
6465
constexpr auto base = S::fromLaneLiterals({2, 3, 5, 6});
6566
constexpr auto exponent = S::fromLaneLiterals({7, 4, 2, 3});
@@ -69,8 +70,19 @@ TEST_CASE("Jamie's totally working exponentiation :D") {
6970
CHECK(expected.value() == actual.value());
7071
}
7172

73+
TEST_CASE("Expontiation with 16-bit lane width (overflow unsafe)") {
74+
using S = SWAR<16, u64>; // Change to 16-bit lane width
75+
constexpr auto base = S::fromLaneLiterals({10, 2, 7, 3});
76+
constexpr auto exponent = S::fromLaneLiterals({3, 5, 1, 4});
77+
constexpr auto expected = S::fromLaneLiterals({1000, 32, 7, 81});
78+
constexpr auto actual = exponentiation_OverflowUnsafe(base, exponent);
79+
static_assert(expected.value() == actual.value());
80+
CHECK(expected.value() == actual.value());
7281
}
7382

83+
};
84+
85+
7486
#define HE(nbits, t, v0, v1) \
7587
static_assert(horizontalEquality<nbits, t>(\
7688
SWAR<nbits, t>(v0),\
@@ -358,7 +370,7 @@ TEST_CASE(
358370
"BooleanSWAR MSBtoLaneMask",
359371
"[swar]"
360372
) {
361-
// BooleanSWAR as a mask:
373+
// BooleanSWAR as a mask:
362374
auto bswar =BooleanSWAR<4, u32>(0x0808'0000);
363375
auto mask = S4_32(0x0F0F'0000);
364376
CHECK(bswar.MSBtoLaneMask().value() == mask.value());
@@ -385,6 +397,6 @@ TEST_CASE(
385397
CHECK(SWAR<4, u16>(0x0400).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0100), SWAR<4, u16>(0x0300)).value());
386398
CHECK(SWAR<4, u16>(0x0B00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0300)).value());
387399
CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0700)).value());
388-
CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0800)).value());
389-
CHECK(S4_32(0x0F0C'F000).value() == saturatingUnsignedAddition(S4_32(0x0804'F000), S4_32(0x0808'F000)).value());
400+
CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0800)).value());
401+
CHECK(S4_32(0x0F0C'F000).value() == saturatingUnsignedAddition(S4_32(0x0804'F000), S4_32(0x0808'F000)).value());
390402
}

0 commit comments

Comments
 (0)