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

correctly aggregated results

parent c48698e3
......@@ -697,7 +697,7 @@ namespace fmwkng {
}
virtual void metadata_marker(std::ostream& os) const
{
my_traits::metadata_marker_close(os);
my_traits::metadata_marker_open(os);
}
virtual element_sense sense() const
{
......@@ -750,7 +750,7 @@ namespace fmwkng {
}
virtual void metadata_marker(std::ostream& os) const
{
my_traits::metadata_marker_open(os);
my_traits::metadata_marker_close(os);
}
virtual element_sense sense() const
{
......@@ -1300,6 +1300,10 @@ namespace fmwkng {
struct all_platforms_tag {
using tag_category = platform_tag_category;
};
struct all_threads_tag {
using tag_category = parallel_tag_category;
};
#pragma endregion
namespace impl {
#pragma region utils2
......@@ -1697,6 +1701,7 @@ namespace fmwkng {
static void aggregate(aggregator_data_type& r, const data_type& v)
{
assert(r == v.second); // AGGREGATING TO A RANGE VALUE IS NONSENSE
//r = v.second; // LET THE LAST CONFIG WIN IF THE EQUALITY IS FAKE
}
};
......@@ -1737,6 +1742,35 @@ namespace fmwkng {
}
static void aggregate(data_type& r, const data_type& v)
{
// nothing to do with monostate
}
};
template<>
struct config_element_traits< parallel_tag_category, all_threads_tag>
{
static void metadata_marker_open(std::ostream& os)
{
os << "threads:";
}
static void metadata_marker_close(std::ostream& os)
{
os << ".";
}
using data_type = std::monostate;
static void data_text(std::ostream& os, const data_type& d)
{
os << "all";
}
template< element_sense sense>
using aggregator = config_element< all_threads_tag, sense>;
static data_type aggregator_data(const data_type&)
{
return {};
}
static void aggregate(data_type& r, const data_type& v)
{
// nothing to do with monostate
}
};
......@@ -1765,6 +1799,7 @@ namespace fmwkng {
static void aggregate(data_type& r, const data_type& v)
{
assert( r == v);
//r = v; // LET THE LAST CONFIG WIN IF THE EQUALITY IS FAKE
}
};
......@@ -1864,10 +1899,15 @@ namespace fmwkng {
static constexpr bool useful = false;
static constexpr bool reducible = false;
template< element_sense sense>
using aggregator = config_element< parallel_tag, sense>;
static void aggregate(data_type& r, const data_type& v)
using aggregator = config_element< all_threads_tag, sense>;
using aggregate_data_type = std::monostate;
static aggregate_data_type aggregator_data(const data_type&)
{
r += v; // !!! NONSENSE
return {};
}
static void aggregate(aggregate_data_type&, const data_type&)
{
// NOTHING TO DO
}
};
......@@ -1880,6 +1920,8 @@ namespace fmwkng {
}
using data_type = void;
static constexpr bool reducible = false;
template< element_sense sense>
using aggregator = config_element< all_threads_tag, sense>;
};
class parallel_data_holder {
......@@ -2040,7 +2082,7 @@ namespace fmwkng {
using data_type = void;
static constexpr bool reducible = true;
template< element_sense sense>
using aggregator = config_element< measurement_tag, sense>;
using aggregator = result_element< measurement_tag, sense>;
};
template<>
......@@ -2059,15 +2101,16 @@ namespace fmwkng {
static constexpr bool reducible = true;
using aggregator_data_type = std::pair< clock::duration, std::size_t>;
template< element_sense sense>
using aggregator = config_element< measurement_tag, sense>;
using aggregator = result_element< measurement_tag, sense>;
static aggregator_data_type aggregator_data(const data_type& v)
{
return aggregator_data_type(v, 1);
}
static void aggregate(aggregator_data_type& r, const data_type& v)
{
r.first += v;
r.second += 1;
// THE LAST MEASUREMENT WINS
r.first = v;
r.second = 1;
}
};
......@@ -2088,13 +2131,14 @@ namespace fmwkng {
os << (d.first.count() / d.second);
}
template< element_sense sense>
using aggregator = config_element< measurement_tag, sense>;
using aggregator = result_element< measurement_tag, sense>;
static data_type aggregator_data(const data_type& v)
{
return v;
}
static void aggregate(data_type& r, const data_type& v)
{
// AVERAGE
r.first += v.first;
r.second += v.second;
}
......@@ -2177,9 +2221,9 @@ namespace fmwkng {
{
return v;
}
static void aggregate(data_type& r, const data_type& v)
static void aggregate(data_type&, const data_type&)
{
r += v; // !!! NONSENSE
// THE FIRST RESULT WINS
}
};
#pragma endregion
......@@ -2346,8 +2390,9 @@ namespace fmwkng {
}
static void aggregate(aggregator_data_type& r, const data_type& v)
{
r.first += v; // !!! WE WANT THE LAST MEASUREMENT, NOT THE AVERAGE
r.second += 1;
// THE LAST MEASUREMENT WINS, CONVERTED TO LOGARITHMIC SCALE
r.first = std::log(v);
r.second = 1;
}
};
......@@ -2356,16 +2401,16 @@ namespace fmwkng {
{
static void metadata_marker_open(std::ostream& os)
{
os << "<";
os << "[";
}
static void metadata_marker_close(std::ostream& os)
{
os << ">";
os << measurement_policy::name() << "[ns]]";
}
using data_type = std::pair< double, std::size_t>;
static void data_text(std::ostream& os, const data_type& d)
{
os << (d.first / d.second);
os << std::exp(d.first / d.second);
}
template< element_sense sense>
using aggregator = result_element< auto_measurement_tag< measurement_policy>, sense>;
......@@ -2375,6 +2420,7 @@ namespace fmwkng {
}
static void aggregate(data_type& r, const data_type& v)
{
// AVERAGE (IN LOGARITHMIC SCALE)
r.first += v.first;
r.second += v.second;
}
......
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