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

Merge branch 'build_test' into 'master'

macro now contains platform-independent checks and parlab-specific time comparison

See merge request teaching/nprg054/asgn!5
parents 7ced1c58 e238abd6
......@@ -2,5 +2,5 @@
target_include_directories(${TARGET_MACRO} PUBLIC ".")
target_include_directories(${TARGET_LEVEN} PUBLIC ".")
target_sources(${TARGET_MACRO} PUBLIC "fmwkng.hpp" "macroasgn.hpp" "macroasgn.cpp" "macromain.cpp")
target_sources(${TARGET_LEVEN} PUBLIC "fmwkng.hpp" "levenasgn.hpp" "levenmain.cpp")
target_sources(${TARGET_MACRO} PUBLIC "fmwkng.hpp" "macroasgn.hpp" "macroasgn.cpp" "macromain.cpp" "macrogolddebug.cpp" "macrogold.cpp" "macrogoldbig.cpp" "macrogoldsmall.cpp" "macrogoldphi.cpp")
target_sources(${TARGET_LEVEN} PUBLIC "fmwkng.hpp" "levenasgn.hpp" "levenmain.cpp" "levengolddebug.cpp" "levengold.cpp" "levengoldbig.cpp")
This diff is collapsed.
......@@ -11,95 +11,239 @@
///////////////////////////////
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>
inline std::uint64_t chksum(IT b, IT e)
{
std::uint64_t s = 0;
for (; b != e; ++b)
template< typename IT>
inline std::uint64_t chksum(IT b, IT e)
{
auto x = *b;
s = s * 3 + (std::uint64_t)x;
}
return s;
}
std::uint64_t s = 0;
struct generator_4 {
for (; b != e; ++b)
{
auto x = *b;
time_complexity complexity() const
{
return s1_ * s2_;
}
s = s * 3 + (std::uint64_t)x;
}
auto begin1() const
{
return v1_.cbegin();
return s;
}
auto end1() const
{
return v1_.cend();
}
struct generator_4 {
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 begin2() const
{
return v2_.cbegin();
}
}
auto end2() const
{
return v2_.cend();
}
namespace levensol {
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_scalar;
struct policy_sse;
#ifdef USE_AVX
struct policy_avx;
#endif
#ifdef USE_AVX512
struct policy_avx512;
#endif
};
struct policy_random {
static std::string name() { return "random"; }
explicit policy_random(std::size_t seed)
: engine_(seed), ui_(0, 255)
{
}
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
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()
{
return ui_(engine_);
}
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(
0x80,
#ifdef NDEBUG
0x8000,
#else
0x800,
#endif
0x10
);
}
};
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(
0x80,
#ifdef NDEBUG
0x8000,
#else
0x800,
#endif
0x10
);
}
};
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 =
#ifdef NDEBUG
1000000000ULL
#else
100000000ULL
#endif
;
};
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:
typedef std::mt19937_64 M;
M engine_;
typedef std::uniform_int_distribution< data_element> D;
D ui_;
};
fmwkng::gold_holder& gold_master();
}
#endif
This diff is collapsed.
This diff is collapsed.
#include "fmwkng.hpp"
#include "levenasgn.hpp"
namespace levenmain {
static fmwkng::gold_data gold_results_()
{
return fmwkng::gold_data{
{
{
std::make_unique<fmwkng::impl::element_t<levenmain::a_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(128,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::element_t<levenmain::b_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(128,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::config_element<levenmain::repeats,fmwkng::impl::element_sense::OPEN>>(64),
},
{
std::make_unique<fmwkng::impl::element_t<levenmain::output,fmwkng::impl::element_sense::CLOSE>>(128U),
}
},
{
{
std::make_unique<fmwkng::impl::element_t<levenmain::a_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(128,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::element_t<levenmain::b_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(2048,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::config_element<levenmain::repeats,fmwkng::impl::element_sense::OPEN>>(4),
},
{
std::make_unique<fmwkng::impl::element_t<levenmain::output,fmwkng::impl::element_sense::CLOSE>>(1997U),
}
},
{
{
std::make_unique<fmwkng::impl::element_t<levenmain::a_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(2048,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::element_t<levenmain::b_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(128,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::config_element<levenmain::repeats,fmwkng::impl::element_sense::OPEN>>(4),
},
{
std::make_unique<fmwkng::impl::element_t<levenmain::output,fmwkng::impl::element_sense::CLOSE>>(1995U),
}
},
{
{
std::make_unique<fmwkng::impl::element_t<levenmain::a_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(2048,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::element_t<levenmain::b_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(2048,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::config_element<levenmain::repeats,fmwkng::impl::element_sense::OPEN>>(1),
},
{
std::make_unique<fmwkng::impl::element_t<levenmain::output,fmwkng::impl::element_sense::CLOSE>>(2024U),
}
},
{
{
std::make_unique<fmwkng::impl::element_t<levenmain::a_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(128,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::config_element<levenmain::b_size,fmwkng::impl::element_sense::OPEN>>(fmwkng::logarithmic(128,2048,16)),
std::make_unique<fmwkng::impl::config_element<levenmain::repeats,fmwkng::impl::element_sense::OPEN>>(64),
},
{
std::make_unique<fmwkng::impl::element_t<levenmain::output,fmwkng::impl::element_sense::CLOSE>>(128U),
}
},
{
{
std::make_unique<fmwkng::impl::element_t<levenmain::a_size,fmwkng::impl::element_sense::OPEN>>(std::make_pair(2048,fmwkng::logarithmic(128,2048,16))),
std::make_unique<fmwkng::impl::config_element<levenmain::b_size,fmwkng::impl::element_sense::OPEN>>(fmwkng::logarithmic(128,2048,16)),
std::make_unique<fmwkng::impl::config_element<levenmain::repeats,fmwkng::impl::element_sense::OPEN>>(4),
},
{
std::make_unique<fmwkng::impl::element_t<levenmain::output,fmwkng::impl::element_sense::CLOSE>>(1995U),
}
},
{
{
std::make_unique<fmwkng::impl::config_element<levenmain::a_size,fmwkng::impl::element_sense::OPEN>>(fmwkng::logarithmic(128,2048,16)),
std::make_unique<fmwkng::impl::config_element<levenmain::b_size,fmwkng::impl::element_sense::OPEN>>(fmwkng::logarithmic(128,2048,16)),
std::make_unique<fmwkng::impl::config_element<levenmain::repeats,fmwkng::impl::element_sense::OPEN>>(64),
},
{
std::make_unique<fmwkng::impl::element_t<levenmain::output,fmwkng::impl::element_sense::CLOSE>>(128U),
}
},
{
{
std::make_unique<fmwkng::impl::config_element<fmwkng::all_platforms_tag,fmwkng::impl::element_sense::OPEN>>(std::monostate()),
std::make_unique<fmwkng::impl::config_element<levenmain::a_size,fmwkng::impl::element_sense::OPEN>>(fmwkng::logarithmic(128,2048,16)),
std::make_unique<fmwkng::impl::config_element<levenmain::b_size,fmwkng::impl::element_sense::OPEN>>(fmwkng::logarithmic(128,2048,16)),
std::make_unique<fmwkng::impl::config_element<levenmain::repeats,fmwkng::impl::element_sense::OPEN>>(64),
},
{
std::make_unique<fmwkng::impl::element_t<levenmain::output,fmwkng::impl::element_sense::CLOSE>>(128U),
}
},
};
}
static fmwkng::gold_holder gh_(gold_master(), gold_results_);
}
......@@ -8,113 +8,6 @@
#include <sstream>
namespace levenmain {
/*
struct platform_scalar {
using tag_category = fmwkng::platform_tag_category;
static auto name() { return "scalar"; }
using policy = levensol::policy_scalar;
};
*/
struct platform_sse {
using tag_category = fmwkng::platform_tag_category;
static auto name() { return "sse"; }
using policy = levensol::policy_sse;
};
#ifdef USE_AVX
struct platform_avx {
using tag_category = fmwkng::platform_tag_category;
static auto name() { return "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"; }
using policy = levensol::policy_avx512;
};
#endif
struct a_size {
using tag_category = fmwkng::range_tag_category;
static auto name() { return "a_size"; }
static auto enumerator() {
return fmwkng::logarithmic(
0x40,
#ifdef NDEBUG
0x10000,
#else
0x1000,
#endif
0x4
);
}
};
struct b_size {
using tag_category = fmwkng::range_tag_category;
static auto name() { return "b_size"; }
static auto enumerator() {
return fmwkng::logarithmic(
0x40,
#ifdef NDEBUG
0x10000,
#else
0x1000,
#endif
0x4
);
}
};
struct repeats {
using tag_category = fmwkng::range_tag_category;
static auto name() { return "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"; }
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"; }
using value_type = std::size_t;
};
struct 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 {
template< typename CTX>
void operator()(CTX&& ctx2) const
......@@ -125,8 +18,8 @@ namespace levenmain {
{
for (auto&& ctx4 : for_range<b_size>(ctx3))
{
generator_4 mg(
policy_random(
levenasgn::generator_4 mg(
levenasgn::policy_random(
std::mt19937_64::default_seed + ctx2.thread_index()
), get<a_size>(ctx4), get<b_size>(ctx4));
......@@ -162,12 +55,18 @@ namespace levenmain {
#endif
}
};
fmwkng::gold_holder& gold_master()
{
static fmwkng::gold_holder the;
return the;
}
}
int main(int argc, char** argv)
{
using namespace fmwkng;
root<levenmain::root_config> ctx1(argc, argv);
root<levenmain::root_config> ctx1(argc, argv, levenmain::gold_master().collect());
//std::cout << "Running..." << std::endl;
for_platforms(ctx1, levenmain::run_platform_ftor());
//std::cout << "Done." << std::endl;
......@@ -178,25 +77,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
}
///////////////////////////////
......@@ -15,7 +15,7 @@ namespace macroasgn {
auto M = 26 * exp_length;
auto N = M + 26;
std::uniform_int_distribution<std::size_t> char_distro(0, N - 1);
fmwkng::well_defined_uniform char_distro(0, N - 1);
auto generate_name = [&char_distro, &engine, M, exp_length, level_count, nonlevel_weight]()
{
......@@ -53,11 +53,11 @@ namespace macroasgn {
}
}
std::uniform_int_distribution<std::size_t> space_distro(0, exp_spaces);
std::uniform_int_distribution<std::size_t> width_distro(0, exp_width);
std::uniform_int_distribution<std::size_t> level_distro(0, (level_count + nonlevel_weight) * (exp_width + 1) - 1);
std::uniform_int_distribution<std::size_t> macro_distro(0, level_count + nonmacro_weight - 1);
std::uniform_int_distribution<std::size_t> name_distro(0, name_count - 1);
fmwkng::well_defined_uniform space_distro(0, exp_spaces);
fmwkng::well_defined_uniform width_distro(0, exp_width);
fmwkng::well_defined_uniform level_distro(0, (level_count + nonlevel_weight) * (exp_width + 1) - 1);
fmwkng::well_defined_uniform</