Skip to content

Commit 76df096

Browse files
Victorinjames-d-mitchell
authored andcommitted
17/07
1 parent 951e67b commit 76df096

File tree

3 files changed

+148
-75
lines changed

3 files changed

+148
-75
lines changed

include/hpcombi/bmat16.hpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,29 @@
3535
#include <vector> // for vector
3636

3737
#include "debug.hpp" // for HPCOMBI_ASSERT
38-
#include "epu8.hpp" // for epu8
39-
#include "perm16.hpp" // for Perm16
4038
#include "bmat8.hpp"
4139

4240
#include "simde/x86/avx2.h"
43-
// #include "simde/x86/avx512/popcnt.h"
4441

4542
namespace HPCombi {
4643
using xpu16 = uint16_t __attribute__((vector_size(32)));
4744
using xpu64 = uint64_t __attribute__((vector_size(32)));
4845

46+
//! Converting storage type from blocks to rows of a xpu64
47+
//! representing a 16x16 matrix (used in BMat16).
48+
//!
49+
//! Each 64 bit unsigned int represents 4 lines of the matrix.
4950
xpu64 to_line(xpu64 vect);
51+
52+
//! Converting storage type from rows to blocks of a xpu64
53+
//! representing a 16x16 matrix (used in BMat16).
54+
//!
55+
//! Each 64 bit unsigned int represents one of the four
56+
//! 8x8 matrix that make up a 16x16 when quartered.
5057
xpu64 to_block(xpu64 vect);
5158

59+
60+
5261
//! Class for fast boolean matrices of dimension up to 16 x 16
5362
//!
5463
//! The methods for these small matrices over the boolean semiring
@@ -60,8 +69,6 @@ xpu64 to_block(xpu64 vect);
6069
//! BMat16 is a trivial class.
6170
class BMat16 {
6271
public:
63-
xpu64 _data;
64-
6572
//! A default constructor.
6673
//!
6774
//! This constructor gives no guarantees on what the matrix will contain.
@@ -71,7 +78,7 @@ class BMat16 {
7178
//!
7279
//! This constructor initializes a matrix with a 256-bit register
7380
//! The rows are equal to the 16 chunks, of 16 bits each,
74-
//! of the binary representation of the matrix
81+
//! of the binary representation of the matrix.
7582
explicit BMat16(xpu64 mat) noexcept :
7683
_data{mat} {}
7784

@@ -242,9 +249,14 @@ class BMat16 {
242249

243250
void swap(BMat16 &that) noexcept { std::swap(this->_data, that._data); }
244251

245-
// ! Write \c this on \c os
252+
//! Write \c this on \c os
246253
// Not noexcept
247254
std::ostream &write(std::ostream &os) const;
255+
256+
257+
private:
258+
xpu64 _data;
259+
248260
};
249261

250262
} // namespace HPCombi

include/hpcombi/bmat16_impl.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ inline std::array<std::array<bool, 16>, 16> BMat16::to_array() const noexcept {
9595
uint64_t a = tmp[0], b = tmp[1], c = tmp[2], d = tmp[3];
9696
std::array<std::array<bool, 16>, 16> res;
9797
for (size_t i = 0; i < 64; ++i) {
98-
res[i/8][i%8] = a & 1; a >>= 1;
99-
res[i/8][8 + i%8] = b & 1; b >>= 1;
100-
res[8 + i/8][i%8] = c & 1; c >>= 1;
98+
res[i/8][i%8] = a & 1; a >>= 1;
99+
res[i/8][8 + i%8] = b & 1; b >>= 1;
100+
res[8 + i/8][i%8] = c & 1; c >>= 1;
101101
res[8 + i/8][8 + i%8] = d & 1; d >>= 1;
102102
}
103103
return res;
@@ -129,7 +129,6 @@ inline BMat16 BMat16::transpose() const noexcept {
129129
}
130130

131131
static constexpr xpu16 rot{0x302, 0x504, 0x706, 0x908, 0xb0a, 0xd0c, 0xf0e, 0x100, 0x302, 0x504, 0x706, 0x908, 0xb0a, 0xd0c, 0xf0e, 0x100};
132-
static constexpr xpu16 alt{0x200, 0x604, 0xa08, 0xe0c, 0x301, 0x705, 0xb09, 0xf0d, 0x200, 0x604, 0xa08, 0xe0c, 0x301, 0x705, 0xb09, 0xf0d};
133132

134133
inline BMat16 BMat16::mult_transpose(BMat16 const &that) const noexcept {
135134
xpu16 x = _data;
@@ -185,8 +184,8 @@ inline BMat16 BMat16::mult_naive_array(BMat16 const &that) const noexcept {
185184
for (int j = 7; j >= 0; --j) {
186185
a <<= 1; b <<= 1; c <<= 1; d <<= 1;
187186
for (size_t k = 0; k < 16; ++k) {
188-
a |= tab1[i][k] & tab2[k][j];
189-
b |= tab1[i][k] & tab2[k][j + 8];
187+
a |= tab1[i][k] & tab2[k][j];
188+
b |= tab1[i][k] & tab2[k][j + 8];
190189
c |= tab1[i + 8][k] & tab2[k][j];
191190
d |= tab1[i + 8][k] & tab2[k][j + 8];
192191
}
@@ -202,7 +201,7 @@ inline size_t BMat16::nr_rows() const noexcept{
202201
++res;
203202
return res;
204203

205-
//// Vectorized version that doesn't work due to the absence of popcnt in simde
204+
//// Vectorized version which doesn't work due to the absence of popcnt in simde
206205
// xpu16 tmp = _data, zero = simde_mm256_setzero_si256();
207206
// xpu16 x = (tmp != zero);
208207
// return simde_mm256_popcnt_epi16(x);
@@ -212,6 +211,8 @@ inline std::vector<uint16_t> BMat16::rows() const {
212211
std::vector<uint16_t> rows;
213212
for (size_t i = 0; i < 16; ++i) {
214213
uint16_t row_rev = (_data[i/4] << (16 * (3 - i%4)) >> 48);
214+
215+
// The row needs to be reversed
215216
uint16_t row = 0;
216217
for (size_t j = 0; j < 16; ++j) {
217218
row = (row << 1) | (row_rev & 1);
@@ -294,7 +295,7 @@ inline std::ostream &BMat16::write(std::ostream &os) const {
294295

295296
namespace std {
296297

297-
// Not noexcept because BMat8::write isn't
298+
// Not noexcept because BMat16::write isn't
298299
inline std::ostream &operator<<(std::ostream &os, HPCombi::BMat16 const &bm) {
299300
return bm.write(os);
300301
}

tests/test_bmat16.cpp

Lines changed: 120 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include <catch2/catch_test_macros.hpp> // for operator""_catch_sr, operator==
2929

3030
#include "hpcombi/bmat16.hpp" // for BMat16, operator<<
31-
#include "hpcombi/perm16.hpp" // for Perm16
32-
#include "hpcombi/vect16.hpp" // for Vect16
3331

3432
namespace HPCombi {
3533
namespace {
@@ -88,38 +86,38 @@ struct BMat16Fixture {
8886
{1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1},
8987
{0, 1, 1, 1, 0,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, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
115+
{1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1},
116+
{0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0},
117+
{1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0},
118+
{1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1},
119+
{1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0},
120+
{0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0}}),
123121
BMlist(
124122
{zero, one1, one2, ones, bm, bm1, bmm1, bm2, bm2t, bm3, bm3t}) {}
125123
};
@@ -128,7 +126,45 @@ struct BMat16Fixture {
128126
//****************************************************************************//
129127
//****************************************************************************//
130128

131-
TEST_CASE_METHOD(BMat16Fixture, "BMat16::transpose", "[BMat16][000]") {
129+
TEST_CASE_METHOD(BMat16Fixture, "BMat16::one", "[BMat16][000]") {
130+
CHECK(BMat16::one(0) == zero);
131+
CHECK(BMat16::one(2) == BMat16({{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
132+
{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
133+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
134+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
135+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
136+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
137+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
138+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
159+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
160+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
161+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
162+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}));
163+
CHECK(BMat16::one(16) == BMat16::one());
164+
}
165+
166+
167+
TEST_CASE_METHOD(BMat16Fixture, "BMat16::transpose", "[BMat16][001]") {
132168
CHECK(zero.transpose() == zero);
133169
CHECK(bm2.transpose() == bm2t);
134170
CHECK(bm3.transpose() == bm3t);
@@ -138,9 +174,9 @@ TEST_CASE_METHOD(BMat16Fixture, "BMat16::transpose", "[BMat16][000]") {
138174
}
139175
}
140176

141-
TEST_AGREES(BMat16Fixture, transpose, transpose_naive, BMlist, "[BMat16][001]");
177+
TEST_AGREES(BMat16Fixture, transpose, transpose_naive, BMlist, "[BMat16][002]");
142178

143-
TEST_CASE_METHOD(BMat16Fixture, "BMat16::operator*", "[BMat16][002]") {
179+
TEST_CASE_METHOD(BMat16Fixture, "BMat16::operator*", "[BMat16][003]") {
144180
BMat16 tmp = bm * bm1;
145181
CHECK(tmp == bmm1);
146182
CHECK(tmp == bm * bm1);
@@ -162,11 +198,11 @@ TEST_CASE_METHOD(BMat16Fixture, "BMat16::operator*", "[BMat16][002]") {
162198
}
163199
}
164200

165-
TEST_AGREES2(BMat16Fixture, BMat16::operator*, mult_4bmat8, BMlist, "[BMat16][003]");
166-
TEST_AGREES2(BMat16Fixture, BMat16::operator*, mult_naive, BMlist, "[BMat16][004]");
167-
TEST_AGREES2(BMat16Fixture, BMat16::operator*, mult_naive_array, BMlist, "[BMat16][005]");
201+
TEST_AGREES2(BMat16Fixture, BMat16::operator*, mult_4bmat8, BMlist, "[BMat16][004]");
202+
TEST_AGREES2(BMat16Fixture, BMat16::operator*, mult_naive, BMlist, "[BMat16][005]");
203+
TEST_AGREES2(BMat16Fixture, BMat16::operator*, mult_naive_array, BMlist, "[BMat16][006]");
168204

169-
TEST_CASE("BMat16::random", "[BMat16][006]") {
205+
TEST_CASE("BMat16::random", "[BMat16][007]") {
170206
for (size_t d = 1; d < 8; ++d) {
171207
BMat16 bm = BMat16::random(d);
172208
for (size_t i = d + 1; i < 16; ++i) {
@@ -178,7 +214,7 @@ TEST_CASE("BMat16::random", "[BMat16][006]") {
178214
}
179215
}
180216

181-
TEST_CASE("BMat16::operator()", "[BMat16][007]") {
217+
TEST_CASE("BMat16::operator()", "[BMat16][008]") {
182218
std::vector<std::vector<bool>> mat = {
183219
{0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0},
184220
{0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0},
@@ -203,32 +239,56 @@ TEST_CASE("BMat16::operator()", "[BMat16][007]") {
203239
}
204240
}
205241

206-
TEST_CASE_METHOD(BMat16Fixture, "BMat16::operator<<", "[BMat16][008]") {
242+
TEST_CASE_METHOD(BMat16Fixture, "BMat16::operator<<", "[BMat16][009]") {
207243
std::ostringstream oss;
208244
oss << bm3;
209-
CHECK(oss.str() == "0001010001011011\n"
210-
"0111011000110001\n"
211-
"1010001101100010\n"
212-
"0011010100001011\n"
213-
"1001001111001110\n"
214-
"1010100111101100\n"
215-
"0110111001100001\n"
216-
"0000010110111100\n"
217-
"1100110100000001\n"
218-
"1101000100001100\n"
219-
"1101111000101101\n"
220-
"1010000001000011\n"
221-
"0011101110111000\n"
222-
"0001001010011001\n"
223-
"0100100100011110\n"
224-
"0101011111110101\n");
245+
CHECK(oss.str() == "0001101000101110\n"
246+
"0100101100001001\n"
247+
"1010000101101111\n"
248+
"0101001010100010\n"
249+
"0010001000010001\n"
250+
"1100101101100100\n"
251+
"1011000000100100\n"
252+
"1010001010010010\n"
253+
"0100100100010010\n"
254+
"1000101010001001\n"
255+
"0000000010100001\n"
256+
"1101110010100010\n"
257+
"0100100000110101\n"
258+
"1101001010101110\n"
259+
"0100010100001001\n"
260+
"0100000110100100\n");
225261

226262
std::stringbuf buff;
227263
std::ostream os(&buff);
228264
os << BMat8::random(); // Also does not do anything visible
229265
}
230266

231-
TEST_CASE_METHOD(BMat16Fixture, "BMat16::nr_rows", "[BMat16][009]") {
267+
TEST_CASE_METHOD(BMat16Fixture, "BMat16::set", "[BMat16][010]") {
268+
BMat16 bs;
269+
bs = bm;
270+
bs.set(0, 0, 1);
271+
CHECK(bs != bm);
272+
bs = bm;
273+
bs.set(0, 0, 0);
274+
CHECK(bs == bm);
275+
bs = bm;
276+
bs.set(13, 6, 1);
277+
CHECK(bs != bm);
278+
CHECK(bs == bm3);
279+
280+
for (size_t i = 0; i < 16; ++i)
281+
for (size_t j = 0; j < 16; ++j)
282+
bs.set(i, j, true);
283+
CHECK(bs == ones);
284+
285+
for (size_t i = 0; i < 16; ++i)
286+
for (size_t j = 0; j < 16; ++j)
287+
bs.set(i, j, false);
288+
CHECK(bs == zero);
289+
}
290+
291+
TEST_CASE_METHOD(BMat16Fixture, "BMat16::nr_rows", "[BMat16][011]") {
232292
CHECK(zero.nr_rows() == 0);
233293
CHECK(one1.nr_rows() == 1);
234294
CHECK(one2.nr_rows() == 2);

0 commit comments

Comments
 (0)