Skip to content

Commit

Permalink
Use different rank default on arm
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed Oct 31, 2023
1 parent 31d797d commit 4309f36
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
26 changes: 11 additions & 15 deletions benchmark/bench_perm16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "hpcombi/perm16.hpp"
#include "hpcombi/perm_generic.hpp"


using namespace std;
using HPCombi::epu8;
using HPCombi::Perm16;
Expand Down Expand Up @@ -66,18 +65,16 @@ std::vector<Transf16> make_Transf16(size_t n) {

class Fix_Perm16 {
public:
Fix_Perm16() :
sample_Perm16(make_Perm16(1000)),
sample_Transf16(make_Transf16(1000)),
sample_pair_Perm16(make_Pair_Perm16(40))
{}
Fix_Perm16()
: sample_Perm16(make_Perm16(1000)),
sample_Transf16(make_Transf16(1000)),
sample_pair_Perm16(make_Pair_Perm16(40)) {}
~Fix_Perm16() {}
const std::vector<Perm16> sample_Perm16;
const std::vector<Transf16> sample_Transf16;
const std::vector<std::pair<Perm16, Perm16>> sample_pair_Perm16;
};


TEST_CASE_METHOD(Fix_Perm16, "Inverse of 1000 Perm16", "[Perm16][000]") {
BENCHMARK_MEM_FN(inverse_ref, sample_Perm16);
BENCHMARK_MEM_FN(inverse_arr, sample_Perm16);
Expand All @@ -88,40 +85,39 @@ TEST_CASE_METHOD(Fix_Perm16, "Inverse of 1000 Perm16", "[Perm16][000]") {
BENCHMARK_MEM_FN(inverse, sample_Perm16);
}

TEST_CASE_METHOD(Fix_Perm16, "Lehmer code of 1000 Perm16", "[Perm16][000]") {
TEST_CASE_METHOD(Fix_Perm16, "Lehmer code of 1000 Perm16", "[Perm16][001]") {
BENCHMARK_MEM_FN(lehmer_ref, sample_Perm16);
BENCHMARK_MEM_FN(lehmer_arr, sample_Perm16);
BENCHMARK_MEM_FN(lehmer, sample_Perm16);
}

TEST_CASE_METHOD(Fix_Perm16, "Coxeter Length of 1000 Perm16", "[Perm16][000]") {
TEST_CASE_METHOD(Fix_Perm16, "Coxeter Length of 1000 Perm16", "[Perm16][002]") {
BENCHMARK_MEM_FN(length_ref, sample_Perm16);
BENCHMARK_MEM_FN(length_arr, sample_Perm16);
BENCHMARK_MEM_FN(length, sample_Perm16);
}

TEST_CASE_METHOD(Fix_Perm16, "Number of descents of 1000 Perm16",
"[Perm16][000]") {
"[Perm16][003]") {
BENCHMARK_MEM_FN(nb_descents_ref, sample_Perm16);
BENCHMARK_MEM_FN(nb_descents, sample_Perm16);
}

TEST_CASE_METHOD(Fix_Perm16, "Number of cycles of 1000 Perm16",
"[Perm16][000]") {
"[Perm16][004]") {
BENCHMARK_MEM_FN(nb_cycles_ref, sample_Perm16);
BENCHMARK_MEM_FN(nb_cycles, sample_Perm16);
}

TEST_CASE_METHOD(Fix_Perm16, "Weak order comparison of 1600 pairs of Perm16",
"[Perm16][000]") {
"[Perm16][005]") {
BENCHMARK_MEM_FN_PAIR(left_weak_leq_ref, sample_pair_Perm16);
BENCHMARK_MEM_FN_PAIR(left_weak_leq_length, sample_pair_Perm16);
BENCHMARK_MEM_FN_PAIR(left_weak_leq, sample_pair_Perm16);
}

TEST_CASE_METHOD(Fix_Perm16, "Rank of 1000 PTransf16",
"[PTransf16][000]") {
TEST_CASE_METHOD(Fix_Perm16, "Rank of 1000 PTransf16", "[PTransf16][006]") {
BENCHMARK_MEM_FN(rank_ref, sample_Transf16);
BENCHMARK_MEM_FN(rank_cmpestrm, sample_Transf16);
BENCHMARK_MEM_FN(rank, sample_Transf16);
}

2 changes: 2 additions & 0 deletions include/hpcombi/perm16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ struct alignas(16) PTransf16 : public Vect16 {
uint32_t rank_ref() const;
/** Returns the size of the image of \c *this */
uint32_t rank() const;
//! Returns the size of the image of \c *this
uint32_t rank_cmpestrm() const;

/** Returns a mask for the fix point of \c *this */
epu8 fix_points_mask(bool complement = false) const;
Expand Down
11 changes: 10 additions & 1 deletion include/hpcombi/perm16_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,19 @@ inline uint32_t PTransf16::rank_ref() const {
tmp[x] = 1;
return std::accumulate(tmp.begin(), tmp.end(), uint8_t(0));
}
inline uint32_t PTransf16::rank() const {

inline uint32_t PTransf16::rank_cmpestrm() const {
return __builtin_popcountl(image_bitset());
}

inline uint32_t PTransf16::rank() const {
#ifdef SIMDE_X86_SSE4_2_NATIVE
return rank_cmpestrm();
#else
return rank_ref();
#endif
}

inline epu8 PTransf16::fix_points_mask(bool complement) const {
return complement ? v != one().v : v == one().v;
}
Expand Down

0 comments on commit 4309f36

Please sign in to comment.