Skip to content

Commit

Permalink
constexpr backward compat cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hivert committed Oct 28, 2023
1 parent ad6ac85 commit 137224a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 121 deletions.
2 changes: 1 addition & 1 deletion include/bmat8_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ inline size_t BMat8::nr_rows() const {
return __builtin_popcountll(simde_mm_movemask_epi8(x != epu8{}));
}

static HPCOMBI_CONSTEXPR epu8 rev8{7, 6, 5, 4, 3, 2, 1, 0,
static constexpr epu8 rev8{7, 6, 5, 4, 3, 2, 1, 0,
8, 9, 10, 11, 12, 13, 14, 15};
inline BMat8 BMat8::row_permuted(Perm16 p) const {
epu8 x = simde_mm_set_epi64x(0, _data);
Expand Down
14 changes: 1 addition & 13 deletions include/epu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,17 @@
#include <iomanip>
#include <ostream>
#include <type_traits>
#include <utility> // integer_sequences

#ifdef HPCOMBI_HAVE_CONFIG
#include "HPCombi-config.h"
#endif

#if __cplusplus <= 201103L
#include "fallback/seq.hpp"
#endif

#include "vect_generic.hpp"

#include "simde/x86/sse4.1.h"
#include "simde/x86/sse4.2.h"

#ifdef HPCOMBI_CONSTEXPR_FUN_ARGS
#define HPCOMBI_CONSTEXPR constexpr
#define HPCOMBI_CONSTEXPR_CONSTRUCTOR constexpr
#else
#pragma message "Using a constexpr broken compiler ! " \
"Performance may not be optimal"
#define HPCOMBI_CONSTEXPR const
#define HPCOMBI_CONSTEXPR_CONSTRUCTOR
#endif

namespace HPCombi {

Expand Down
85 changes: 0 additions & 85 deletions include/fallback/seq.hpp

This file was deleted.

32 changes: 16 additions & 16 deletions include/perm16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ struct alignas(16) PTransf16 : public Vect16 {
using array = decltype(Epu8)::array;

PTransf16() = default;
HPCOMBI_CONSTEXPR_CONSTRUCTOR PTransf16(const PTransf16 &v) = default;
HPCOMBI_CONSTEXPR_CONSTRUCTOR PTransf16(const vect v) : Vect16(v) {}
HPCOMBI_CONSTEXPR_CONSTRUCTOR PTransf16(const epu8 x) : Vect16(x) {}
constexpr PTransf16(const PTransf16 &v) = default;
constexpr PTransf16(const vect v) : Vect16(v) {}
constexpr PTransf16(const epu8 x) : Vect16(x) {}
PTransf16(std::vector<uint8_t> dom, std::vector<uint8_t> rng,
size_t = 0 /* unused */);
PTransf16(std::initializer_list<uint8_t> il);
Expand All @@ -65,7 +65,7 @@ struct alignas(16) PTransf16 : public Vect16 {
}

//! The identity partial transformation.
static HPCOMBI_CONSTEXPR PTransf16 one() { return epu8id; }
static constexpr PTransf16 one() { return epu8id; }
//! The product of two partial transformations.
PTransf16 operator*(const PTransf16 &p) const {
return HPCombi::permuted(v, p.v) | (p.v == Epu8(0xFF));
Expand Down Expand Up @@ -120,9 +120,9 @@ struct alignas(16) PTransf16 : public Vect16 {
*/
struct Transf16 : public PTransf16 {
Transf16() = default;
HPCOMBI_CONSTEXPR_CONSTRUCTOR Transf16(const Transf16 &v) = default;
HPCOMBI_CONSTEXPR_CONSTRUCTOR Transf16(const vect v) : PTransf16(v) {}
HPCOMBI_CONSTEXPR_CONSTRUCTOR Transf16(const epu8 x) : PTransf16(x) {}
constexpr Transf16(const Transf16 &v) = default;
constexpr Transf16(const vect v) : PTransf16(v) {}
constexpr Transf16(const epu8 x) : PTransf16(x) {}
Transf16(std::initializer_list<uint8_t> il) : PTransf16(il) {}
Transf16 &operator=(const Transf16 &) = default;

Expand All @@ -132,7 +132,7 @@ struct Transf16 : public PTransf16 {
}

//! The identity transformation.
static HPCOMBI_CONSTEXPR Transf16 one() { return epu8id; }
static constexpr Transf16 one() { return epu8id; }
//! The product of two transformations.
Transf16 operator*(const Transf16 &p) const {
return HPCombi::permuted(v, p.v);
Expand All @@ -149,9 +149,9 @@ struct Transf16 : public PTransf16 {
*/
struct PPerm16 : public PTransf16 {
PPerm16() = default;
HPCOMBI_CONSTEXPR_CONSTRUCTOR PPerm16(const PPerm16 &v) = default;
HPCOMBI_CONSTEXPR_CONSTRUCTOR PPerm16(const vect v) : PTransf16(v) {}
HPCOMBI_CONSTEXPR_CONSTRUCTOR PPerm16(const epu8 x) : PTransf16(x) {}
constexpr PPerm16(const PPerm16 &v) = default;
constexpr PPerm16(const vect v) : PTransf16(v) {}
constexpr PPerm16(const epu8 x) : PTransf16(x) {}
PPerm16(std::vector<uint8_t> dom, std::vector<uint8_t> rng,
size_t = 0 /* unused */)
: PTransf16(dom, rng) {}
Expand All @@ -164,7 +164,7 @@ struct PPerm16 : public PTransf16 {
}

//! The identity partial permutations.
static HPCOMBI_CONSTEXPR PPerm16 one() { return epu8id; }
static constexpr PPerm16 one() { return epu8id; }
//! The product of two partial perrmutations.
PPerm16 operator*(const PPerm16 &p) const {
return this->PTransf16::operator*(p);
Expand Down Expand Up @@ -208,9 +208,9 @@ struct PPerm16 : public PTransf16 {
*/
struct Perm16 : public Transf16 /* public PPerm : diamond problem */ {
Perm16() = default;
HPCOMBI_CONSTEXPR_CONSTRUCTOR Perm16(const Perm16 &) = default;
HPCOMBI_CONSTEXPR_CONSTRUCTOR Perm16(const vect v) : Transf16(v) {}
HPCOMBI_CONSTEXPR_CONSTRUCTOR Perm16(const epu8 x) : Transf16(x) {}
constexpr Perm16(const Perm16 &) = default;
constexpr Perm16(const vect v) : Transf16(v) {}
constexpr Perm16(const epu8 x) : Transf16(x) {}
Perm16 &operator=(const Perm16 &) = default;
Perm16(std::initializer_list<uint8_t> il) : Transf16(il) {}

Expand All @@ -221,7 +221,7 @@ struct Perm16 : public Transf16 /* public PPerm : diamond problem */ {
// being defined (see https://stackoverflow.com/questions/11928089/)
// therefore we chose to have functions.
//! The identity partial permutation.
static HPCOMBI_CONSTEXPR Perm16 one() { return epu8id; }
static constexpr Perm16 one() { return epu8id; }
//! The product of two permutations
Perm16 operator*(const Perm16 &p) const {
return HPCombi::permuted(v, p.v);
Expand Down
8 changes: 4 additions & 4 deletions include/perm16_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ inline uint8_t PTransf16::nb_fix_points() const {
return __builtin_popcountl(fix_points_bitset());
}

inline static HPCOMBI_CONSTEXPR uint8_t hilo_exchng_fun(uint8_t i) {
inline static constexpr uint8_t hilo_exchng_fun(uint8_t i) {
return i < 8 ? i + 8 : i - 8;
}
static HPCOMBI_CONSTEXPR epu8 hilo_exchng = Epu8(hilo_exchng_fun);
inline static HPCOMBI_CONSTEXPR uint8_t hilo_mask_fun(uint8_t i) {
static constexpr epu8 hilo_exchng = Epu8(hilo_exchng_fun);
inline static constexpr uint8_t hilo_mask_fun(uint8_t i) {
return i < 8 ? 0x0 : 0xFF;
}
static HPCOMBI_CONSTEXPR epu8 hilo_mask = Epu8(hilo_mask_fun);
static constexpr epu8 hilo_mask = Epu8(hilo_mask_fun);

inline Transf16::Transf16(uint64_t compressed) {
epu8 res = simde_mm_set_epi64x(compressed, compressed);
Expand Down
4 changes: 2 additions & 2 deletions include/vect16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ struct alignas(16) Vect16 {
epu8 v;

Vect16() = default;
HPCOMBI_CONSTEXPR_CONSTRUCTOR Vect16(epu8 x) : v(x) {}
constexpr Vect16(epu8 x) : v(x) {}
Vect16(std::initializer_list<uint8_t> il, uint8_t def = 0)
: v(Epu8(il, def)) {}
HPCOMBI_CONSTEXPR_CONSTRUCTOR operator epu8() const { return v; }
constexpr operator epu8() const { return v; }

Vect16 &operator=(const Vect16 &) = default;
Vect16 &operator=(const epu8 &vv) {
Expand Down

0 comments on commit 137224a

Please sign in to comment.