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

corrected gold code generator

parent df92971d
...@@ -3,4 +3,4 @@ target_include_directories(${TARGET_MACRO} PUBLIC ".") ...@@ -3,4 +3,4 @@ target_include_directories(${TARGET_MACRO} PUBLIC ".")
target_include_directories(${TARGET_LEVEN} PUBLIC ".") target_include_directories(${TARGET_LEVEN} PUBLIC ".")
target_sources(${TARGET_MACRO} PUBLIC "fmwkng.hpp" "macroasgn.hpp" "macroasgn.cpp" "macromain.cpp" "macrogold.cpp") target_sources(${TARGET_MACRO} PUBLIC "fmwkng.hpp" "macroasgn.hpp" "macroasgn.cpp" "macromain.cpp" "macrogold.cpp")
target_sources(${TARGET_LEVEN} PUBLIC "fmwkng.hpp" "levenasgn.hpp" "levenmain.cpp") target_sources(${TARGET_LEVEN} PUBLIC "fmwkng.hpp" "levenasgn.hpp" "levenmain.cpp" "levengold.cpp")
...@@ -1870,9 +1870,9 @@ namespace fmwkng { ...@@ -1870,9 +1870,9 @@ namespace fmwkng {
std::ofstream os(code_fn_); std::ofstream os(code_fn_);
os << "#include \"fmwkng.hpp\"" << std::endl; os << "#include \"fmwkng.hpp\"" << std::endl;
os << "#include \"macroasgn.hpp\"" << std::endl; os << "#include \"" << config_t::code_header_name() << "\"" << std::endl;
os << "" << std::endl; os << "" << std::endl;
os << "namespace macromain {" << std::endl; os << "namespace " << config_t::code_namespace_name() << " {" << std::endl;
os << " const fmwkng::gold_data & gold_results()" << std::endl; os << " const fmwkng::gold_data & gold_results()" << std::endl;
os << " {" << std::endl; os << " {" << std::endl;
os << " static fmwkng::gold_data gd_{" << std::endl; os << " static fmwkng::gold_data gd_{" << std::endl;
......
...@@ -11,95 +11,233 @@ ...@@ -11,95 +11,233 @@
/////////////////////////////// ///////////////////////////////
typedef int data_element; namespace levenasgn {
using data_element = std::uint32_t;
using time_complexity = std::size_t; using time_complexity = std::size_t;
template< typename IT> template< typename IT>
inline std::uint64_t chksum(IT b, IT e) inline std::uint64_t chksum(IT b, IT e)
{
std::uint64_t s = 0;
for (; b != e; ++b)
{ {
auto x = *b; std::uint64_t s = 0;
s = s * 3 + (std::uint64_t)x;
}
return s;
}
struct generator_4 { for (; b != e; ++b)
{
auto x = *b;
time_complexity complexity() const s = s * 3 + (std::uint64_t)x;
{ }
return s1_ * s2_;
}
auto begin1() const
{
return v1_.cbegin();
}
auto end1() const return s;
{
return v1_.cend();
} }
auto begin2() const struct generator_4 {
{
return v2_.cbegin(); time_complexity complexity() const
} {
return s1_ * s2_;
}
auto begin1() const
{
return v1_.cbegin();
}
auto end1() const
{
return v1_.cend();
}
auto begin2() const
{
return v2_.cbegin();
}
auto end2() const
{
return v2_.cend();
}
template< typename GP>
generator_4(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(v1_.begin(), v1_.end(), gen);
std::generate(v2_.begin(), v2_.end(), gen);
}
private:
std::size_t s1_, s2_;
std::vector< data_element> v1_, v2_;
};
struct policy_random {
static std::string name() { return "random"; }
explicit policy_random(std::size_t seed)
: engine_(seed), ui_(0, 255)
{
}
void reset()
{
}
data_element get()
{
return ui_(engine_);
}
private:
typedef std::mt19937_64 M;
M engine_;
typedef std::uniform_int_distribution< data_element> D;
D ui_;
};
auto end2() const }
{
return v2_.cend();
}
template< typename GP> namespace levensol {
generator_4( 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(v1_.begin(), v1_.end(), gen);
std::generate(v2_.begin(), v2_.end(), gen);
}
private: struct policy_scalar;
std::size_t s1_, s2_; struct policy_sse;
std::vector< data_element> v1_, v2_; #ifdef USE_AVX
struct policy_avx;
#endif
#ifdef USE_AVX512
struct policy_avx512;
#endif
}; };
struct policy_random { namespace levenmain {
/*
static std::string name() { return "random"; } struct platform_scalar {
using tag_category = fmwkng::platform_tag_category;
explicit policy_random(std::size_t seed) static auto name() { return "scalar"; }
: engine_(seed), ui_(0, 255) static auto code_name() { return "levenmain::platform_scalar"; }
{ using policy = levensol::policy_scalar;
} };
*/
struct platform_sse {
using tag_category = fmwkng::platform_tag_category;
static auto name() { return "sse"; }
static auto code_name() { return "levenmain::platform_sse"; }
using policy = levensol::policy_sse;
};
#ifdef USE_AVX
struct platform_avx {
using tag_category = fmwkng::platform_tag_category;
static auto name() { return "avx"; }
static auto code_name() { return "levenmain::platform_avx"; }
using policy = levensol::policy_avx;
};
#endif
void reset() #ifdef USE_AVX512
{ struct platform_avx512 {
} using tag_category = fmwkng::platform_tag_category;
static auto name() { return "avx512"; }
static auto code_name() { return "levenmain::platform_avx512"; }
using policy = levensol::policy_avx512;
};
#endif
data_element get() struct a_size {
{ using tag_category = fmwkng::range_tag_category;
return ui_(engine_); static auto name() { return "a_size"; }
} static auto code_name() { return "levenmain::a_size"; }
static auto enumerator() {
return fmwkng::logarithmic(
0x40,
#ifdef NDEBUG
0x10000,
#else
0x1000,
#endif
0x20
);
}
};
struct b_size {
using tag_category = fmwkng::range_tag_category;
static auto name() { return "b_size"; }
static auto code_name() { return "levenmain::b_size"; }
static auto enumerator() {
return fmwkng::logarithmic(
0x40,
#ifdef NDEBUG
0x10000,
#else
0x1000,
#endif
0x20
);
}
};
struct repeats {
using tag_category = fmwkng::range_tag_category;
static auto name() { return "repeats"; }
static auto code_name() { return "levenmain::repeats"; }
static auto enumerator() {
return fmwkng::auto_repeat(
#ifdef NDEBUG
0x10000000
#else
0x100000
#endif
);
}
};
struct repeat_policy {
using ranges = fmwkng::ranges< repeats>;
static auto name() { return "time_per_cell"; }
static auto code_name() { return "levenmain::repeat_policy"; }
template< typename CTX>
static auto complexity(CTX&& ctx)
{
return (std::uint_fast64_t)fmwkng::get<a_size>(ctx) * fmwkng::get<b_size>(ctx);
}
static constexpr fmwkng::average_t minimum_count = 1000000000ULL;
};
struct output {
using tag_category = fmwkng::result_tag_category;
static auto name() { return "output"; }
static auto code_name() { return "levenmain::output"; }
using value_type = std::size_t;
};
struct root_config {
static auto code_name() { return "levenmain::root_config"; }
static auto code_header_name() { return "levenasgn.hpp"; }
static auto code_namespace_name() { return "levenmain"; }
using platforms = fmwkng::platforms<
//platform_scalar
//,
platform_sse
#ifdef USE_AVX
, platform_avx
#endif
#ifdef USE_AVX512
, platform_avx512
#endif
>;
using ranges = fmwkng::ranges<a_size, b_size, repeats>;
};
private: const fmwkng::gold_data& gold_results();
typedef std::mt19937_64 M; }
M engine_;
typedef std::uniform_int_distribution< data_element> D;
D ui_;
};
#endif #endif
This diff is collapsed.
...@@ -8,122 +8,6 @@ ...@@ -8,122 +8,6 @@
#include <sstream> #include <sstream>
namespace levenmain { namespace levenmain {
/*
struct platform_scalar {
using tag_category = fmwkng::platform_tag_category;
static auto name() { return "scalar"; }
static auto code_name() { return "levenmain::platform_scalar"; }
using policy = levensol::policy_scalar;
};
*/
struct platform_sse {
using tag_category = fmwkng::platform_tag_category;
static auto name() { return "sse"; }
static auto code_name() { return "levenmain::platform_sse"; }
using policy = levensol::policy_sse;
};
#ifdef USE_AVX
struct platform_avx {
using tag_category = fmwkng::platform_tag_category;
static auto name() { return "avx"; }
static auto code_name() { return "levenmain::platform_avx"; }
using policy = levensol::policy_avx;
};
#endif
#ifdef USE_AVX512
struct platform_avx512 {
using tag_category = fmwkng::platform_tag_category;
static auto name() { return "avx512"; }
static auto code_name() { return "levenmain::platform_avx512"; }
using policy = levensol::policy_avx512;
};
#endif
struct a_size {
using tag_category = fmwkng::range_tag_category;
static auto name() { return "a_size"; }
static auto code_name() { return "levenmain::a_size"; }
static auto enumerator() {
return fmwkng::logarithmic(
0x40,
#ifdef NDEBUG
0x10000,
#else
0x1000,
#endif
0x20
);
}
};
struct b_size {
using tag_category = fmwkng::range_tag_category;
static auto name() { return "b_size"; }
static auto code_name() { return "levenmain::b_size"; }
static auto enumerator() {
return fmwkng::logarithmic(
0x40,
#ifdef NDEBUG
0x10000,
#else
0x1000,
#endif
0x20
);
}
};
struct repeats {
using tag_category = fmwkng::range_tag_category;
static auto name() { return "repeats"; }
static auto code_name() { return "levenmain::repeats"; }
static auto enumerator() {
return fmwkng::auto_repeat(
#ifdef NDEBUG
0x10000000
#else
0x100000
#endif
);
}
};
struct repeat_policy {
using ranges = fmwkng::ranges< repeats>;
static auto name() { return "time_per_cell"; }
static auto code_name() { return "levenmain::repeat_policy"; }
template< typename CTX>
static auto complexity(CTX&& ctx)
{
return (std::uint_fast64_t)fmwkng::get<a_size>(ctx) * fmwkng::get<b_size>(ctx);
}
static constexpr fmwkng::average_t minimum_count = 1000000000ULL;
};
struct output {
using tag_category = fmwkng::result_tag_category;
static auto name() { return "output"; }
static auto code_name() { return "levenmain::output"; }
using value_type = std::size_t;
};
struct root_config {
static auto code_name() { return "levenmain::root_config"; }
using platforms = fmwkng::platforms<
//platform_scalar
//,
platform_sse
#ifdef USE_AVX
, platform_avx
#endif
#ifdef USE_AVX512
, platform_avx512
#endif
>;
using ranges = fmwkng::ranges<a_size, b_size, repeats>;
};
struct run_thread_ftor { struct run_thread_ftor {
template< typename CTX> template< typename CTX>
...@@ -135,8 +19,8 @@ namespace levenmain { ...@@ -135,8 +19,8 @@ namespace levenmain {
{ {
for (auto&& ctx4 : for_range<b_size>(ctx3)) for (auto&& ctx4 : for_range<b_size>(ctx3))
{ {
generator_4 mg( levenasgn::generator_4 mg(
policy_random( levenasgn::policy_random(
std::mt19937_64::default_seed + ctx2.thread_index() std::mt19937_64::default_seed + ctx2.thread_index()
), get<a_size>(ctx4), get<b_size>(ctx4)); ), get<a_size>(ctx4), get<b_size>(ctx4));
...@@ -177,7 +61,7 @@ namespace levenmain { ...@@ -177,7 +61,7 @@ namespace levenmain {
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
using namespace fmwkng; using namespace fmwkng;
root<levenmain::root_config> ctx1(argc, argv); root<levenmain::root_config> ctx1(argc, argv, levenmain::gold_results());
//std::cout << "Running..." << std::endl; //std::cout << "Running..." << std::endl;
for_platforms(ctx1, levenmain::run_platform_ftor()); for_platforms(ctx1, levenmain::run_platform_ftor());
//std::cout << "Done." << std::endl; //std::cout << "Done." << std::endl;
...@@ -188,25 +72,3 @@ int main(int argc, char** argv) ...@@ -188,25 +72,3 @@ int main(int argc, char** argv)
/////////////////////////////// ///////////////////////////////
/////////////////////////////// ///////////////////////////////
void o_main()
{
#ifdef _DEBUG
std::size_t min_inner = 64UL;
std::size_t step_inner = 4;
std::size_t max_inner = 2UL * 1024UL;
std::size_t min_outer = 64UL;
std::size_t step_outer = 4;
std::size_t max_outer = 2UL * 1024UL;
time_complexity target_complexity = 250000UL;
#else
std::size_t min_inner = 64UL;
std::size_t step_inner = 8;
std::size_t max_inner = 32UL * 1024UL;
std::size_t min_outer = 64UL;
std::size_t step_outer = 8;
std::size_t max_outer = 32UL * 1024UL;
time_complexity target_complexity = 10000000000UL;
#endif
}
///////////////////////////////
...@@ -165,6 +165,8 @@ namespace macromain { ...@@ -165,6 +165,8 @@ namespace macromain {
struct root_config { struct root_config {
static auto code_name() { return "macromain::root_config"; } static auto code_name() { return "macromain::root_config"; }
static auto code_header_name() { return "macroasgn.hpp"; }
static auto code_namespace_name() { return "macromain"; }
using platforms = fmwkng::platforms< using platforms = fmwkng::platforms<
platform_scalar platform_scalar
, ,
......
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