Commit 540bc760 authored by Bednárek David RNDr. Ph.D.'s avatar Bednárek David RNDr. Ph.D.
Browse files

alternate input during non-compared runs, to catch non-reset state in leven::compute

parent 6fb63b48
......@@ -1339,7 +1339,7 @@ namespace fmwkng {
private:
using self_ = index_iterator<index_t>;
public:
using iterator_category = std::input_iterator_tag;
using iterator_category = std::bidirectional_iterator_tag;
using value_type = index_t;
using difference_type = std::make_signed_t<index_t>;
using pointer = const index_t*;
......@@ -1358,6 +1358,15 @@ namespace fmwkng {
{
return self_(v_++);
}
self_& operator--()
{
--v_;
return *this;
}
self_ operator--(int)
{
return self_(v_--);
}
bool operator==(const self_& b) const
{
return v_ == b.v_;
......
......@@ -90,6 +90,68 @@ namespace levenasgn {
}
};
struct generator_4_alt {
auto begin1() const
{
return v1_.cbegin();
}
auto end1() const
{
return v1_.cend();
}
auto data1() const
{
return v1_.data();
}
auto size1() const
{
return v1_.size();
}
auto data2() const
{
return v2_.data();
}
auto size2() const
{
return v2_.size();
}
auto begin2() const
{
return v2_.cbegin();
}
auto end2() const
{
return v2_.cend();
}
template< typename GP>
generator_4_alt(GP&& p, std::size_t s1, std::size_t s2)
: s2_(s2),
s1_(s1),
v1_(s1),
v2_(s2)
{
auto gen = [&p]() -> data_element {
return p.get();
};
std::generate(v2_.begin(), v2_.end(), gen);
std::generate(v1_.begin(), v1_.end(), gen);
}
private:
std::size_t s1_, s2_;
std::vector< data_element> v1_, v2_;
};
struct policy_random {
static std::string name() { return "random"; }
......
......@@ -22,7 +22,11 @@ namespace levenmain {
levenasgn::policy_random(
std::mt19937_64::default_seed + ctx2.thread_index()
), get<a_size>(ctx4), get<b_size>(ctx4));
levenasgn::generator_4_alt mg_alt(
levenasgn::policy_random(
std::mt19937_64::default_seed + ctx2.thread_index() + 729
), get<a_size>(ctx4), get<b_size>(ctx4));
if constexpr ( std::is_constructible_v<levensol::levenstein<policy>, const levenasgn::data_element *, const levenasgn::data_element *, const levenasgn::data_element *, const levenasgn::data_element *> )
{
// old-style interface
......@@ -50,9 +54,14 @@ namespace levenmain {
for (auto&& ctx5 : auto_measurement<repeat_policy>(ctx4, 1024))
{
std::size_t h = 0;
for (auto i : for_index<repeats>(ctx5))
auto range = for_index<repeats>(ctx5);
auto back = *std::prev(range.end());
for (auto i : range)
{
auto rv = data.compute(mg.data1(), mg.data2());
auto alt = i != back;
auto rv = data.compute(
alt ? mg_alt.data1() : mg.data1(),
alt ? mg_alt.data2() : mg.data2());
h = rv;
}
if (stop_for_results(ctx5))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment