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

result display support

parent ce4c1154
......@@ -446,8 +446,8 @@ namespace fmwkng {
using iterator_category = std::input_iterator_tag;
using value_type = context_t;
using difference_type = impl::enumerator_value_t<range_tag>;
using pointer = const context_t*;
using reference = const context_t&;
using pointer = context_t*;
using reference = context_t&;
explicit context_iterator(context_t* p)
: p_(p)
......@@ -802,6 +802,7 @@ namespace fmwkng {
struct range_tag_category {};
struct parallel_tag_category {};
struct measurement_tag_category {};
struct result_tag_category {};
#pragma endregion
namespace impl {
#pragma region utils2
......@@ -1443,8 +1444,32 @@ namespace fmwkng {
using type = measurement_data_holder;
};
#pragma endregion
}
namespace impl {
#pragma region result
template<typename result_tag>
struct element_traits< result_tag_category, result_tag, element_sense::OPEN>
{
static void metadata_marker(std::ostream& os)
{
os << result_tag::name() << "<";
}
using data_type = void;
};
template<typename result_tag>
struct element_traits< result_tag_category, result_tag, element_sense::CLOSE>
{
static void metadata_marker(std::ostream& os)
{
os << ">";
}
using data_type = typename result_tag::value_type;
static void data_text(std::ostream& os, const data_type& d)
{
os << d;
}
static constexpr bool useful = true;
};
#pragma endregion
#pragma region tag_list_utils2
template< typename T, typename ...L>
struct index_of/*
......@@ -1589,15 +1614,30 @@ namespace fmwkng {
enter_phase(dt);
}
template< typename dt_t>
bool stop_for_results(const dt_t& dt)
{
if (p_ == phase::TEST)
{
exit_phase(dt);
p_ = phase::RESULTS;
return true;
}
return false;
}
template< typename dt_t>
bool advance(const dt_t& dt)
{
exit_phase(dt);
if (p_ != phase::RESULTS)
{
exit_phase(dt);
}
if (p_ == phase::LEAD_IN)
{
p_ = phase::TEST;
}
else if (p_ == phase::TEST)
else if (p_ == phase::TEST || p_ == phase::RESULTS)
{
p_ = phase::LEAD_OUT;
}
......@@ -1627,7 +1667,7 @@ namespace fmwkng {
}
private:
enum class phase { LEAD_IN, TEST, LEAD_OUT };
enum class phase { LEAD_IN, TEST, RESULTS, LEAD_OUT };
phase p_;
using time_point = clock::time_point;
using time_delta = clock::duration;
......@@ -1916,6 +1956,11 @@ namespace fmwkng {
return impl::context_range< child_context, my_measurement_tag>(dt_.get_my_pointer(), dt_.get_parent_pointer_tuple(), v_last);
}
bool stop_for_results()
{
return dt_.get_my_pointer()->stop_for_results(dt_);
}
template< typename range_tag>
self_* advance()
{
......@@ -1935,6 +1980,14 @@ namespace fmwkng {
return my_config.count();
}
template< typename result_tag, typename T>
void store_result( T && v) const
{
auto tp = impl::thread_pointer(dt_);
tp->template push_element<result_tag, impl::element_sense::OPEN>();
tp->template push_element<result_tag, impl::element_sense::CLOSE>(std::forward<T>(v));
}
std::lock_guard<std::mutex> guard() const
{
return my_root_pointer()->guard();
......@@ -2148,6 +2201,19 @@ namespace fmwkng {
return ctx.template auto_measurement< range_tag>( v_last);
}
template< typename ... tags>
auto stop_for_results(tagged_context< tags ...>& ctx)
{
return ctx.stop_for_results();
}
template< typename result_tag, typename T, typename ... tags>
void store_result(const tagged_context< tags ...>& ctx, T && v)
{
ctx.template store_result< result_tag>(std::forward<T>(v));
}
template< typename ... tags>
std::lock_guard<std::mutex> guard(const tagged_context< tags ...>& ctx)
{
......
......@@ -51,6 +51,12 @@ namespace levenmain {
}
};
struct output {
using tag_category = fmwkng::result_tag_category;
static auto name() { return "output"; }
using value_type = std::size_t;
};
struct root_config {
using platforms = fmwkng::platforms<
//platform_scalar
......@@ -80,13 +86,17 @@ namespace levenmain {
levensol::levenstein<policy> data(mg.begin1(), mg.end1(), mg.begin2(), mg.end2());
std::size_t h = 0;
for (auto&& ctx5 : auto_measurement<repeats>(ctx2, 1024))
{
std::size_t h = 0;
for (auto i : for_index<repeats>(ctx5))
{
auto rv = data.compute();
h += rv;
h = rv;
}
if (stop_for_results(ctx5))
{
store_result<output>(ctx5, h);
}
}
}
......
......@@ -16,6 +16,12 @@ namespace macroasgn {
macrotext_generator(std::size_t seed, std::size_t level_count, std::size_t name_count, std::size_t line_count, std::size_t exp_length, std::size_t nonlevel_weight, std::size_t nonmacro_weight, std::size_t exp_width, std::size_t exp_spaces);
void rewind(std::size_t i = 0)
{
index = i;
limit = i;
}
void advance(std::size_t i)
{
limit += i;
......
......@@ -52,6 +52,12 @@ namespace macromain {
}
};
struct output_hash {
using tag_category = fmwkng::result_tag_category;
static auto name() { return "output_hash"; }
using value_type = std::size_t;
};
struct root_config {
using platforms = fmwkng::platforms<
platform_scalar
......@@ -98,11 +104,12 @@ namespace macromain {
}
}
}
std::size_t h = 0;
for (auto&& ctx5 : auto_measurement<lines>(ctx2, 1024))
{
macrosol::macroprocessor< macrosol::policy_scalar> mp;
mg.rewind();
mg.advance(count<lines>(ctx5));
std::size_t h = 0;
std::string output;
for (;;)
{
......@@ -114,6 +121,10 @@ namespace macromain {
if (rv2)
h += std::hash<std::string>()(output);
}
if (stop_for_results(ctx5))
{
store_result<output_hash>(ctx5, h);
}
}
}
}
......
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