Program Listing for File Spec.hpp

Return to documentation for file (include/sgpl/spec/Spec.hpp)

#pragma once
#ifndef SGPL_SPEC_SPEC_HPP_INCLUDE
#define SGPL_SPEC_SPEC_HPP_INCLUDE

#include <array>
#include <ratio>
#include <type_traits>

#include "../../../third-party/conduit/include/uit_emp/matching/matchbin_metrics.hpp"
#include "../../../third-party/conduit/include/uit_emp/matching/MatchDepository.hpp"
#include "../../../third-party/conduit/include/uit_emp/matching/regulators/PlusCountdownRegulator.hpp"
#include "../../../third-party/conduit/include/uit_emp/matching/selectors_static/RankedSelector.hpp"

#include "../library/prefab/CompleteOpLibrary.hpp"
#include "../utility/EmptyType.hpp"

namespace sgpl {

template<
  typename Library=sgpl::CompleteOpLibrary,
  typename Peripheral=sgpl::EmptyType
>
struct Spec {

  using library_t = Library;

  using peripheral_t = Peripheral;

  // make match cutoff threshold strict because there are many potential matches
  // among modules (each module is a potential match)
  using global_matching_t = uit_emp::MatchDepository<
    unsigned short, // program index type
    // matching metric
    uit_emp::OptimizedApproxDualStreakMetric<64>,
    // match selector
    uit_emp::statics::RankedSelector<
      std::ratio<1, 5> // match threshold
    >,
    // regulator
    uit_emp::PlusCountdownRegulator<
      std::deci, // Slope
      std::ratio<1,4>, // MaxUpreg
      std::deci, // ClampLeeway
      2 // CountdownStart
    >,
    true, // raw caching
    8 // regulated caching
  >;

  // make match cutoff threshold lax because there aren't very many potential
  // matches within a module
  using local_matching_t = uit_emp::MatchDepository<
    unsigned short, // program index type
    // matching metric
    uit_emp::OptimizedApproxDualStreakMetric<64>,
    // match selector
    uit_emp::statics::RankedSelector<
      std::ratio<1, 2> // match threshold
    >,
    // regulator
    uit_emp::PlusCountdownRegulator<
      std::deci, // Slope
      std::ratio<1,4>, // MaxUpreg
      std::deci, // ClampLeeway
      2 // CountdownStart
    >,
    false, // raw caching
    0 // regulated caching
  >;

  using tag_t = typename global_matching_t::tag_t;

  static_assert( std::is_same<
    typename global_matching_t::tag_t, typename local_matching_t::tag_t
  >::value );

  static constexpr inline size_t num_cores{ 16 };

  static constexpr inline size_t num_fork_requests{ 3 };

  // must be power of 2
  static constexpr inline size_t num_registers{ 8 };

  static constexpr inline size_t switch_steps{ 8 };

  static constexpr inline std::array<size_t, 2>
    global_jump_table_inclusion_mods{ 1, 2 };

  static constexpr inline size_t num_global_jump_tables
    = global_jump_table_inclusion_mods.size();

};

} // namespace sgpl

#endif // #ifndef SGPL_SPEC_SPEC_HPP_INCLUDE