Skip to content

Commit 4ba8fef

Browse files
Clang format
1 parent fefbced commit 4ba8fef

16 files changed

+734
-734
lines changed

include/bmat8.hpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,10 @@ class BMat8 {
301301
//! This method returns the 8 x 8 BMat8 with 1s on the main diagonal.
302302
static BMat8 one(size_t dim = 8) {
303303
HPCOMBI_ASSERT(dim <= 8);
304-
static std::array<uint64_t, 9> const ones = {0x0000000000000000,
305-
0x8000000000000000,
306-
0x8040000000000000,
307-
0x8040200000000000,
308-
0x8040201000000000,
309-
0x8040201008000000,
310-
0x8040201008040000,
311-
0x8040201008040200,
312-
0x8040201008040201};
304+
static std::array<uint64_t, 9> const ones = {
305+
0x0000000000000000, 0x8000000000000000, 0x8040000000000000,
306+
0x8040200000000000, 0x8040201000000000, 0x8040201008000000,
307+
0x8040201008040000, 0x8040201008040200, 0x8040201008040201};
313308
return BMat8(ones[dim]);
314309
}
315310

@@ -328,7 +323,7 @@ class BMat8 {
328323
void swap(BMat8 &that) { std::swap(this->_data, that._data); }
329324

330325
//! Write \c this on \c os
331-
std::ostream & write(std::ostream &os) const;
326+
std::ostream &write(std::ostream &os) const;
332327

333328
#ifdef LIBSEMIGROUPS_DENSEHASHMAP
334329
// FIXME do this another way

include/bmat8_impl.hpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ inline BMat8 BMat8::transpose() const {
156156
return BMat8(x);
157157
}
158158

159-
160159
inline BMat8 BMat8::transpose_mask() const {
161160
epu8 x = _mm_set_epi64x(_data, _data << 1);
162161
uint64_t res = _mm_movemask_epi8(x);
@@ -177,35 +176,34 @@ inline BMat8 BMat8::transpose_maskd() const {
177176
return BMat8(res);
178177
}
179178

180-
181-
using epu64 = uint64_t __attribute__ ((__vector_size__ (16), __may_alias__));
179+
using epu64 = uint64_t __attribute__((__vector_size__(16), __may_alias__));
182180

183181
inline void BMat8::transpose2(BMat8 &a, BMat8 &b) {
184182
epu64 x = _mm_set_epi64x(a._data, b._data);
185-
epu64 y = (x ^ (x >> 7)) & (epu64 {0xAA00AA00AA00AA, 0xAA00AA00AA00AA});
183+
epu64 y = (x ^ (x >> 7)) & (epu64{0xAA00AA00AA00AA, 0xAA00AA00AA00AA});
186184
x = x ^ y ^ (y << 7);
187-
y = (x ^ (x >> 14)) & (epu64 {0xCCCC0000CCCC, 0xCCCC0000CCCC});
185+
y = (x ^ (x >> 14)) & (epu64{0xCCCC0000CCCC, 0xCCCC0000CCCC});
188186
x = x ^ y ^ (y << 14);
189-
y = (x ^ (x >> 28)) & (epu64 {0xF0F0F0F0, 0xF0F0F0F0});
187+
y = (x ^ (x >> 28)) & (epu64{0xF0F0F0F0, 0xF0F0F0F0});
190188
x = x ^ y ^ (y << 28);
191189
a._data = _mm_extract_epi64(x, 1);
192190
b._data = _mm_extract_epi64(x, 0);
193191
}
194192

195-
static constexpr epu8 rotlow { 7, 0, 1, 2, 3, 4, 5, 6};
196-
static constexpr epu8 rothigh
197-
{ 0, 1, 2, 3, 4, 5, 6, 7,15, 8, 9,10,11,12,13,14};
198-
static constexpr epu8 rotboth
199-
{ 7, 0, 1, 2, 3, 4, 5, 6,15, 8, 9,10,11,12,13,14};
200-
static constexpr epu8 rot2
201-
{ 6, 7, 0, 1, 2, 3, 4, 5,14,15, 8, 9,10,11,12,13};
193+
static constexpr epu8 rotlow{7, 0, 1, 2, 3, 4, 5, 6};
194+
static constexpr epu8 rothigh{0, 1, 2, 3, 4, 5, 6, 7,
195+
15, 8, 9, 10, 11, 12, 13, 14};
196+
static constexpr epu8 rotboth{7, 0, 1, 2, 3, 4, 5, 6,
197+
15, 8, 9, 10, 11, 12, 13, 14};
198+
static constexpr epu8 rot2{6, 7, 0, 1, 2, 3, 4, 5,
199+
14, 15, 8, 9, 10, 11, 12, 13};
202200

203201
inline BMat8 BMat8::mult_transpose(BMat8 const &that) const {
204202
epu8 x = _mm_set_epi64x(_data, _data);
205203
epu8 y = _mm_shuffle_epi8(_mm_set_epi64x(that._data, that._data), rothigh);
206-
epu8 data {};
207-
epu8 diag {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
208-
0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40};
204+
epu8 data{};
205+
epu8 diag{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
206+
0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40};
209207
for (int i = 0; i < 4; ++i) {
210208
data |= ((x & y) != epu8{}) & diag;
211209
y = _mm_shuffle_epi8(y, rot2);
@@ -218,7 +216,7 @@ inline epu8 BMat8::row_space_basis_internal() const {
218216
epu8 res = remove_dups(revsorted8(_mm_set_epi64x(0, _data)));
219217
epu8 rescy = res;
220218
// We now compute the union of all the included different rows
221-
epu8 orincl {};
219+
epu8 orincl{};
222220
for (int i = 0; i < 7; i++) {
223221
rescy = permuted(rescy, rotlow);
224222
orincl |= ((rescy | res) == res) & rescy;
@@ -236,8 +234,8 @@ inline BMat8 BMat8::row_space_basis() const {
236234
#endif /* FF */
237235
#define FF 0xff
238236

239-
constexpr std::array<epu8, 4> masks {{
240-
// clang-format off
237+
constexpr std::array<epu8, 4> masks{
238+
{// clang-format off
241239
{FF, 0,FF, 0,FF, 0,FF, 0,FF, 0,FF, 0,FF, 0,FF, 0},
242240
{FF,FF, 1, 1,FF,FF, 1, 1,FF,FF, 1, 1,FF,FF, 1, 1},
243241
{FF,FF,FF,FF, 2, 2, 2, 2,FF,FF,FF,FF, 2, 2, 2, 2},

include/epu.hpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#define HPCOMBI_CONSTEXPR_CONSTRUCTOR
4545
#endif
4646

47-
4847
namespace HPCombi {
4948

5049
/// Unsigned 8 bits int constant.
@@ -64,7 +63,6 @@ using xpu8 = uint8_t __attribute__((vector_size(32)));
6463
static_assert(alignof(xpu8) == 32,
6564
"xpu8 type is not properly aligned by the compiler !");
6665

67-
6866
namespace { // Implementation detail code
6967

7068
/// A handmade C++11 constexpr lambda
@@ -136,15 +134,12 @@ uint8_t right_dup_fun(uint8_t i) { return i == 0 ? 0 : i - 1; }
136134
HPCOMBI_CONSTEXPR
137135
uint8_t complement_fun(uint8_t i) { return 15 - i; }
138136
HPCOMBI_CONSTEXPR uint8_t popcount4_fun(uint8_t i) {
139-
return ((i & 1) != 0 ? 1 : 0)
140-
+ ((i & 2) != 0 ? 1 : 0)
141-
+ ((i & 4) != 0 ? 1 : 0)
142-
+ ((i & 8) != 0 ? 1 : 0);
137+
return ((i & 1) != 0 ? 1 : 0) + ((i & 2) != 0 ? 1 : 0) +
138+
((i & 4) != 0 ? 1 : 0) + ((i & 8) != 0 ? 1 : 0);
143139
}
144140

145141
} // Anonymous namespace
146142

147-
148143
/// Factory object for various SIMD constants in particular constexpr
149144
TPUBuild<epu8> Epu8;
150145

@@ -258,13 +253,12 @@ inline epu8 revsorted8(epu8 a);
258253
* @details
259254
* @par Algorithm: Uses a 9 stages sorting network #sorting_rounds8
260255
*/
261-
inline epu8 sort_perm(epu8 & a);
256+
inline epu8 sort_perm(epu8 &a);
262257
/** Sort \c this and return the sorting permutation
263258
* @details
264259
* @par Algorithm: Uses a 9 stages sorting network #sorting_rounds8
265260
*/
266-
inline epu8 sort8_perm(epu8 & a);
267-
261+
inline epu8 sort8_perm(epu8 &a);
268262

269263
/** Find if a vector is a permutation of one other
270264
* @details
@@ -358,7 +352,6 @@ inline epu8 partial_sums_round(epu8);
358352
/** @copydoc common_partial_sums */
359353
inline epu8 partial_sums(epu8 v) { return partial_sums_round(v); }
360354

361-
362355
/** @class common_horiz_max
363356
* @brief Horizontal sum of a #HPCombi::epu8
364357
* @details
@@ -422,7 +415,6 @@ inline epu8 partial_max_round(epu8);
422415
/** @copydoc common_partial_max */
423416
inline epu8 partial_max(epu8 v) { return partial_max_round(v); }
424417

425-
426418
/** @class common_horiz_min
427419
* @brief Horizontal sum of a #HPCombi::epu8
428420
* @details
@@ -486,7 +478,6 @@ inline epu8 partial_min_round(epu8);
486478
/** @copydoc common_partial_min */
487479
inline epu8 partial_min(epu8 v) { return partial_min_round(v); }
488480

489-
490481
/** @class common_eval16
491482
* @brief Evaluation of a #HPCombi::epu8
492483
* @details
@@ -710,7 +701,7 @@ inline std::ostream &operator<<(std::ostream &stream, HPCombi::epu8 const &a);
710701
* - std::hash<epu8>
711702
* - std::less<epu8>
712703
*/
713-
}
704+
} // namespace std
714705

715706
#include "epu_impl.hpp"
716707

include/epu_impl.hpp

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,17 @@ inline char less_partial(epu8 a, epu8 b, int k) {
9292
: static_cast<char>(a[diff]) - static_cast<char>(b[diff]);
9393
}
9494

95-
9695
inline uint64_t first_zero(epu8 v, int bnd) {
97-
return first_mask(v == epu8 {}, bnd);
96+
return first_mask(v == epu8{}, bnd);
9897
}
9998
inline uint64_t last_zero(epu8 v, int bnd) {
100-
return last_mask(v == epu8 {}, bnd);
99+
return last_mask(v == epu8{}, bnd);
101100
}
102101
inline uint64_t first_non_zero(epu8 v, int bnd) {
103-
return first_mask(v != epu8 {}, bnd);
102+
return first_mask(v != epu8{}, bnd);
104103
}
105104
inline uint64_t last_non_zero(epu8 v, int bnd) {
106-
return last_mask(v != epu8 {}, bnd);
105+
return last_mask(v != epu8{}, bnd);
107106
}
108107

109108
/// Apply a sorting network
@@ -180,15 +179,9 @@ constexpr std::array<epu8, 6> sorting_rounds8
180179
inline bool is_sorted(epu8 a) {
181180
return _mm_movemask_epi8(shifted_right(a) > a) == 0;
182181
}
183-
inline epu8 sorted(epu8 a) {
184-
return network_sort<true>(a, sorting_rounds);
185-
}
186-
inline epu8 sorted8(epu8 a) {
187-
return network_sort<true>(a, sorting_rounds8);
188-
}
189-
inline epu8 revsorted(epu8 a) {
190-
return network_sort<false>(a, sorting_rounds);
191-
}
182+
inline epu8 sorted(epu8 a) { return network_sort<true>(a, sorting_rounds); }
183+
inline epu8 sorted8(epu8 a) { return network_sort<true>(a, sorting_rounds8); }
184+
inline epu8 revsorted(epu8 a) { return network_sort<false>(a, sorting_rounds); }
192185
inline epu8 revsorted8(epu8 a) {
193186
return network_sort<false>(a, sorting_rounds8);
194187
}
@@ -200,7 +193,6 @@ inline epu8 sort8_perm(epu8 &a) {
200193
return network_sort_perm<true>(a, sorting_rounds8);
201194
}
202195

203-
204196
inline epu8 random_epu8(uint16_t bnd) {
205197
epu8 res;
206198
std::random_device rd;
@@ -219,7 +211,7 @@ inline epu8 remove_dups(epu8 v, uint8_t repl) {
219211
}
220212

221213
// Gather at the front numbers with (3-i)-th bit not set.
222-
constexpr std::array<epu8, 3> inverting_rounds {{
214+
constexpr std::array<epu8, 3> inverting_rounds{{
223215
// clang-format off
224216
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
225217
epu8 { 0, 1, 2, 3, 8, 9, 10, 11, 4, 5, 6, 7, 12, 13, 14, 15},
@@ -244,14 +236,13 @@ inline epu8 permutation_of(epu8 a, epu8 b) {
244236
return res;
245237
}
246238

247-
248239
#if defined(FF)
249240
#error FF is defined !
250241
#endif /* FF */
251242
#define FF 0xff
252243

253244
/// Permutation Round for partial and horizontal sums
254-
constexpr std::array<epu8, 4> summing_rounds {{
245+
constexpr std::array<epu8, 4> summing_rounds{{
255246
// clang-format off
256247
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
257248
epu8 { FF, 0, FF, 2, FF, 4, FF, 6, FF, 8, FF, 10, FF, 12, FF, 14},
@@ -261,7 +252,7 @@ constexpr std::array<epu8, 4> summing_rounds {{
261252
// clang-format on
262253
}};
263254

264-
constexpr std::array<epu8, 4> mining_rounds {{
255+
constexpr std::array<epu8, 4> mining_rounds{{
265256
// clang-format off
266257
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
267258
epu8 { 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14},
@@ -306,7 +297,6 @@ inline epu8 partial_sums_round(epu8 v) {
306297
return v;
307298
}
308299

309-
310300
inline uint8_t horiz_max_ref(epu8 v) {
311301
uint8_t res = 0;
312302
for (size_t i = 0; i < 16; i++)
@@ -340,7 +330,6 @@ inline epu8 partial_max_round(epu8 v) {
340330
return v;
341331
}
342332

343-
344333
inline uint8_t horiz_min_ref(epu8 v) {
345334
uint8_t res = 255;
346335
for (size_t i = 0; i < 16; i++)
@@ -361,7 +350,7 @@ inline epu8 partial_min_ref(epu8 v) {
361350
epu8 res;
362351
res[0] = v[0];
363352
for (size_t i = 1; i < 16; i++)
364-
res[i] = std::min(res[i - 1], v[i]) ;
353+
res[i] = std::min(res[i - 1], v[i]);
365354
return res;
366355
}
367356
inline epu8 partial_min_gen(epu8 v) {
@@ -374,7 +363,6 @@ inline epu8 partial_min_round(epu8 v) {
374363
return v;
375364
}
376365

377-
378366
inline epu8 eval16_ref(epu8 v) {
379367
epu8 res{};
380368
for (size_t i = 0; i < 16; i++)
@@ -409,44 +397,42 @@ inline epu8 eval16_popcount(epu8 v) {
409397
return res;
410398
}
411399

412-
413-
inline epu8 popcount16(epu8 v){
400+
inline epu8 popcount16(epu8 v) {
414401
return permuted(popcount4, (v & Epu8(0x0f))) + permuted(popcount4, v >> 4);
415402
}
416403

417-
418404
inline bool is_partial_transformation(epu8 v, const size_t k) {
419405
uint64_t diff = last_diff(v, epu8id, 16);
420406
// (forall x in v, x + 1 <= 16) and
421407
// (v = Perm16::one() or last diff index < 16)
422-
return (_mm_movemask_epi8(v + Epu8(1) <= Epu8(0x10)) == 0xffff)
423-
&& (diff == 16 || diff < k);
408+
return (_mm_movemask_epi8(v + Epu8(1) <= Epu8(0x10)) == 0xffff) &&
409+
(diff == 16 || diff < k);
424410
}
425411

426412
inline bool is_transformation(epu8 v, const size_t k) {
427413
uint64_t diff = last_diff(v, epu8id, 16);
428-
return (_mm_movemask_epi8(v < Epu8(0x10)) == 0xffff)
429-
&& (diff == 16 || diff < k);
414+
return (_mm_movemask_epi8(v < Epu8(0x10)) == 0xffff) &&
415+
(diff == 16 || diff < k);
430416
}
431417

432418
inline bool is_partial_permutation(epu8 v, const size_t k) {
433419
uint64_t diff = last_diff(v, epu8id, 16);
434420
// (forall x in v, x <= 15) and
435421
// (forall x < 15, multiplicity x v <= 1
436422
// (v = Perm16::one() or last diff index < 16)
437-
return (_mm_movemask_epi8(v + Epu8(1) <= Epu8(0x10)) == 0xffff)
438-
&& (_mm_movemask_epi8(eval16(v) <= Epu8(1)) == 0xffff)
439-
&& (diff == 16 || diff < k);
423+
return (_mm_movemask_epi8(v + Epu8(1) <= Epu8(0x10)) == 0xffff) &&
424+
(_mm_movemask_epi8(eval16(v) <= Epu8(1)) == 0xffff) &&
425+
(diff == 16 || diff < k);
440426
}
441427

442428
inline bool is_permutation(epu8 v, const size_t k) {
443429
uint64_t diff = last_diff(v, epu8id, 16);
444430
// (forall x in v, x in Perm16::one()) and
445431
// (forall x in Perm16::one(), x in v) and
446432
// (v = Perm16::one() or last diff index < 16)
447-
return _mm_cmpestri(epu8id, 16, v, 16, FIRST_NON_ZERO) == 16
448-
&& _mm_cmpestri(v, 16, epu8id, 16, FIRST_NON_ZERO) == 16
449-
&& (diff == 16 || diff < k);
433+
return _mm_cmpestri(epu8id, 16, v, 16, FIRST_NON_ZERO) == 16 &&
434+
_mm_cmpestri(v, 16, epu8id, 16, FIRST_NON_ZERO) == 16 &&
435+
(diff == 16 || diff < k);
450436
}
451437

452438
} // namespace HPCombi

include/hpcombi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#ifndef HPCOMBI_HPCOMBI_HPP_INCLUDED
1717
#define HPCOMBI_HPCOMBI_HPP_INCLUDED
1818

19+
#include "bmat8.hpp"
1920
#include "epu.hpp"
2021
#include "perm16.hpp"
21-
#include "bmat8.hpp"
2222

2323
#endif // HPCOMBI_HPCOMBI_HPP_INCLUDED

0 commit comments

Comments
 (0)