Skip to content

Commit

Permalink
Add new params and rename other.
Browse files Browse the repository at this point in the history
- Add two params to enable and configure the monitor lazy reductions ('--mnt-red-lazy' and '--mnt-red-lazy-freq').
- Rename the '--sim-mpi-comm' argument in '--mnt-mpi-comm-freq'.
- Clean code.
  • Loading branch information
kouchy committed Jan 18, 2019
1 parent c8e7716 commit fcd41ff
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 135 deletions.
2 changes: 1 addition & 1 deletion ci/documentation-check.py
Expand Up @@ -138,7 +138,7 @@ def check_keys(keys_file, aff3ct_path, doc_path):

# manages special key exceptions
exceptions_not_in_doc_keys = ["factory::Frozenbits_generator::parameters::p+pb-path"]
exceptions_doc_keys = ["factory::Simulation::parameters::p+mpi-comm", "factory::Launcher::parameters::except-a2l"]
exceptions_doc_keys = ["factory::BFER::parameters::p+mpi-comm-freq", "factory::Launcher::parameters::except-a2l"]
for e in exceptions_not_in_doc_keys:
if e in not_in_doc_keys: not_in_doc_keys.remove(e)
for e in exceptions_doc_keys:
Expand Down
59 changes: 58 additions & 1 deletion doc/sphinx/source/user/simulation/parameters/monitor/monitor.rst
Expand Up @@ -70,4 +70,61 @@ display the histogram with the following command:
|factory::BFER::parameters::p+mutinfo|

.. note:: Only available on ``BFER`` simulation types (see the
:ref:`sim-sim-type` parameter for more details).
:ref:`sim-sim-type` parameter for more details).

.. _mnt-mnt-red-lazy:

``--mnt-red-lazy``
"""""""""""""""""""""""

|factory::BFER::parameters::p+red-lazy|

Using this parameter can significantly reduce the simulation time, especially
for short frame sizes when the monitor synchronizations happen very often.

.. note:: This parameter is not available if the code has been compiled with
|MPI|.

.. note:: By default, if the :ref:`mnt-mnt-red-lazy-freq` parameter is not
specified, the interval/frequency is set to the same value than the
:ref:`ter-ter-freq` parameter.

.. warning:: Be careful, this parameter is known to alter the behavior of the
:ref:`sim-sim-max-fra` parameter.

.. _mnt-mnt-red-lazy-freq:

``--mnt-red-lazy-freq``
"""""""""""""""""""""""""""

:Type: integer
:Default: 1000
:Examples: ``--mnt-red-lazy-freq 200``

|factory::BFER::parameters::p+red-lazy-freq|

.. note:: This parameter automatically enables the :ref:`mnt-mnt-red-lazy`
parameter.

.. note:: This parameter is not available if the code has been compiled with
|MPI|.

.. _mnt-mnt-mpi-comm-freq:

``--mnt-mpi-comm-freq``
"""""""""""""""""""""""

:Type: integer
:Default: 1000
:Examples: ``--mnt-mpi-comm-freq 1``

|factory::BFER::parameters::p+mpi-comm-freq|

.. note:: Available only when compiling with the |MPI| support
:ref:`compilation_cmake_options`.

.. note:: When this parameter is specified, the :ref:`ter-ter-freq` parameter
is automatically set to the same value except if the :ref:`ter-ter-freq` is
explicitly defined.

.. TODO: add link to MPI use
Expand Up @@ -748,22 +748,6 @@ For the above example, the dumped or read files will be:

|factory::BFER::parameters::p+err-trk-thold|

.. _sim-sim-mpi-comm:

``--sim-mpi-comm``
""""""""""""""""""

:Type: integer
:Default: 1000
:Examples: ``--sim-mpi-comm 1``

|factory::Simulation::parameters::p+mpi-comm|

.. note:: Available only when compiling with the |MPI| support
:ref:`compilation_cmake_options`.

.. TODO: add link to MPI use
References
""""""""""

Expand Down
Expand Up @@ -48,7 +48,7 @@ Description of the allowed values:
|factory::Terminal::parameters::p+freq|

.. note:: When |MPI| is enabled, this value is by default set to the same value
than the :ref:`sim-sim-mpi-comm` parameter.
than the :ref:`mnt-mnt-mpi-comm-freq` parameter.

.. _ter-ter-no:

Expand Down
15 changes: 11 additions & 4 deletions doc/sphinx/strings.rst
Expand Up @@ -97,10 +97,6 @@
.. |factory::Simulation::parameters::p+seed,S| replace::
Set the |PRNG| seed used in the Monte Carlo simulation.

.. |factory::Simulation::parameters::p+mpi-comm| replace::
Set the time interval (in milliseconds) between the |MPI| communications.
Increase this interval will reduce the |MPI| communication overhead.

.. ---------------------------------------------------- factory BFER parameters
.. |factory::BFER::parameters::p+coset,c| replace::
Expand Down Expand Up @@ -129,6 +125,17 @@
.. |factory::BFER::parameters::p+mutinfo| replace::
Enable the computation of the mutual information (|MI|).

.. |factory::BFER::parameters::p+red-lazy| replace::
Enable the lazy synchronization between the various monitor threads.

.. |factory::BFER::parameters::p+red-lazy-freq| replace::
Set the time interval (in milliseconds) between the synchronizations of the
monitor threads.

.. |factory::BFER::parameters::p+mpi-comm-freq| replace::
Set the time interval (in milliseconds) between the |MPI| communications.
Increase this interval will reduce the |MPI| communications overhead.

.. ------------------------------------------------ factory BFER_ite parameters
.. |factory::BFER_ite::parameters::p+ite,I| replace::
Expand Down
115 changes: 75 additions & 40 deletions src/Factory/Simulation/BFER/BFER.cpp
Expand Up @@ -22,15 +22,15 @@ ::clone() const
{
return new BFER::parameters(*this);

// if (src != nullptr) { clone->src = src->clone(); }
// if (crc != nullptr) { clone->crc = crc->clone(); }
// if (cdc != nullptr) { clone->cdc = cdc->clone(); }
// if (mdm != nullptr) { clone->mdm = mdm->clone(); }
// if (chn != nullptr) { clone->chn = chn->clone(); }
// if (qnt != nullptr) { clone->qnt = qnt->clone(); }
// if (src != nullptr) { clone->src = src ->clone(); }
// if (crc != nullptr) { clone->crc = crc ->clone(); }
// if (cdc != nullptr) { clone->cdc = cdc ->clone(); }
// if (mdm != nullptr) { clone->mdm = mdm ->clone(); }
// if (chn != nullptr) { clone->chn = chn ->clone(); }
// if (qnt != nullptr) { clone->qnt = qnt ->clone(); }
// if (mnt_mi != nullptr) { clone->mnt_mi = mnt_mi->clone(); }
// if (mnt_er != nullptr) { clone->mnt_er = mnt_er->clone(); }
// if (ter != nullptr) { clone->ter = ter->clone(); }
// if (ter != nullptr) { clone->ter = ter ->clone(); }

// return clone;
}
Expand All @@ -39,47 +39,47 @@ std::vector<std::string> BFER::parameters
::get_names() const
{
auto n = Simulation::parameters::get_names();
if (src != nullptr) { auto nn = src->get_names(); for (auto &x : nn) n.push_back(x); }
if (crc != nullptr) { auto nn = crc->get_names(); for (auto &x : nn) n.push_back(x); }
if (cdc != nullptr) { auto nn = cdc->get_names(); for (auto &x : nn) n.push_back(x); }
if (mdm != nullptr) { auto nn = mdm->get_names(); for (auto &x : nn) n.push_back(x); }
if (chn != nullptr) { auto nn = chn->get_names(); for (auto &x : nn) n.push_back(x); }
if (qnt != nullptr) { auto nn = qnt->get_names(); for (auto &x : nn) n.push_back(x); }
if (src != nullptr) { auto nn = src ->get_names(); for (auto &x : nn) n.push_back(x); }
if (crc != nullptr) { auto nn = crc ->get_names(); for (auto &x : nn) n.push_back(x); }
if (cdc != nullptr) { auto nn = cdc ->get_names(); for (auto &x : nn) n.push_back(x); }
if (mdm != nullptr) { auto nn = mdm ->get_names(); for (auto &x : nn) n.push_back(x); }
if (chn != nullptr) { auto nn = chn ->get_names(); for (auto &x : nn) n.push_back(x); }
if (qnt != nullptr) { auto nn = qnt ->get_names(); for (auto &x : nn) n.push_back(x); }
if (mnt_mi != nullptr) { auto nn = mnt_mi->get_names(); for (auto &x : nn) n.push_back(x); }
if (mnt_er != nullptr) { auto nn = mnt_er->get_names(); for (auto &x : nn) n.push_back(x); }
if (ter != nullptr) { auto nn = ter->get_names(); for (auto &x : nn) n.push_back(x); }
if (ter != nullptr) { auto nn = ter ->get_names(); for (auto &x : nn) n.push_back(x); }
return n;
}

std::vector<std::string> BFER::parameters
::get_short_names() const
{
auto sn = Factory::parameters::get_short_names();
if (src != nullptr) { auto nn = src->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (crc != nullptr) { auto nn = crc->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (cdc != nullptr) { auto nn = cdc->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (mdm != nullptr) { auto nn = mdm->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (chn != nullptr) { auto nn = chn->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (qnt != nullptr) { auto nn = qnt->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (src != nullptr) { auto nn = src ->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (crc != nullptr) { auto nn = crc ->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (cdc != nullptr) { auto nn = cdc ->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (mdm != nullptr) { auto nn = mdm ->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (chn != nullptr) { auto nn = chn ->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (qnt != nullptr) { auto nn = qnt ->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (mnt_mi != nullptr) { auto nn = mnt_mi->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (mnt_er != nullptr) { auto nn = mnt_er->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (ter != nullptr) { auto nn = ter->get_short_names(); for (auto &x : nn) sn.push_back(x); }
if (ter != nullptr) { auto nn = ter ->get_short_names(); for (auto &x : nn) sn.push_back(x); }
return sn;
}

std::vector<std::string> BFER::parameters
::get_prefixes() const
{
auto p = Factory::parameters::get_prefixes();
if (src != nullptr) { auto nn = src->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (crc != nullptr) { auto nn = crc->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (cdc != nullptr) { auto nn = cdc->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (mdm != nullptr) { auto nn = mdm->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (chn != nullptr) { auto nn = chn->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (qnt != nullptr) { auto nn = qnt->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (src != nullptr) { auto nn = src ->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (crc != nullptr) { auto nn = crc ->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (cdc != nullptr) { auto nn = cdc ->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (mdm != nullptr) { auto nn = mdm ->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (chn != nullptr) { auto nn = chn ->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (qnt != nullptr) { auto nn = qnt ->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (mnt_mi != nullptr) { auto nn = mnt_mi->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (mnt_er != nullptr) { auto nn = mnt_er->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (ter != nullptr) { auto nn = ter->get_prefixes(); for (auto &x : nn) p.push_back(x); }
if (ter != nullptr) { auto nn = ter ->get_prefixes(); for (auto &x : nn) p.push_back(x); }
return p;
}

Expand Down Expand Up @@ -113,15 +113,28 @@ ::get_description(tools::Argument_map_info &args) const
tools::add_arg(args, p, class_name+"p+coded",
tools::None());

auto pmon = mnt_er->get_prefix();
auto pmnt = mnt_er->get_prefix();

tools::add_arg(args, pmon, class_name+"p+mutinfo",
tools::add_arg(args, pmnt, class_name+"p+mutinfo",
tools::None());

#ifdef AFF3CT_MPI
tools::add_arg(args, pmnt, class_name+"p+mpi-comm-freq",
tools::Integer(tools::Positive(), tools::Non_zero()));
#else
tools::add_arg(args, pmnt, class_name+"p+red-lazy",
tools::None());

tools::add_arg(args, pmnt, class_name+"p+red-lazy-freq",
tools::Integer(tools::Positive(), tools::Non_zero()));
#endif
}

void BFER::parameters
::store(const tools::Argument_map_value &vals)
{
using namespace std::chrono;

#if !defined(AFF3CT_SYSTEMC_SIMU)
this->n_threads = std::thread::hardware_concurrency() ? std::thread::hardware_concurrency() : 1;
#endif
Expand All @@ -130,22 +143,33 @@ ::store(const tools::Argument_map_value &vals)

auto p = this->get_prefix();

if(vals.exist({p+"-err-trk-path" })) this->err_track_path = vals.at ({p+"-err-trk-path" });
if(vals.exist({p+"-err-trk-thold" })) this->err_track_threshold = vals.to_int({p+"-err-trk-thold" });
if(vals.exist({p+"-err-trk-rev" })) this->err_track_revert = true;
if(vals.exist({p+"-err-trk" })) this->err_track_enable = true;
if(vals.exist({p+"-coset", "c"})) this->coset = true;
if(vals.exist({p+"-coded", })) this->coded_monitoring = true;
if(vals.exist({p+"-err-trk-path" })) this->err_track_path = vals.at ({p+"-err-trk-path" });
if(vals.exist({p+"-err-trk-thold"})) this->err_track_threshold = vals.to_int({p+"-err-trk-thold" });
if(vals.exist({p+"-err-trk-rev" })) this->err_track_revert = true;
if(vals.exist({p+"-err-trk" })) this->err_track_enable = true;
if(vals.exist({p+"-coset", "c"})) this->coset = true;
if(vals.exist({p+"-coded", })) this->coded_monitoring = true;

if (this->err_track_revert)
{
this->err_track_enable = false;
this->n_threads = 1;
}

auto pmon = mnt_er->get_prefix();
auto pmnt = mnt_er->get_prefix();

if(vals.exist({pmnt+"-mutinfo"})) this->mnt_mutinfo = true;

if(vals.exist({pmon+"-mutinfo"})) this->mutinfo = true;
#ifdef AFF3CT_MPI
if(vals.exist({pmnt+"-mpi-comm-freq"})) this->mnt_mpi_comm_freq = milliseconds(vals.to_int({pmnt+"-mpi-comm-freq"}));
#else
if(vals.exist({pmnt+"-red-lazy"})) this->mnt_red_lazy = true;
if(vals.exist({pmnt+"-red-lazy-freq"}))
{
this->mnt_red_lazy = true;
this->mnt_red_lazy_freq = milliseconds(vals.to_int({pmnt+"-red-lazy-freq"}));
}
#endif
}

void BFER::parameters
Expand All @@ -155,6 +179,16 @@ ::get_headers(std::map<std::string,header_list>& headers, const bool full) const

auto p = this->get_prefix();

std::string pmnt = mnt_er->get_prefix();
#ifdef AFF3CT_MPI
headers[pmnt].push_back(std::make_pair("MPI comm. freq. (ms)", std::to_string(this->mnt_mpi_comm_freq.count())));
#else
headers[pmnt].push_back(std::make_pair("Lazy reduction", this->mnt_red_lazy ? "on" : "off"));
if (this->mnt_red_lazy)
headers[pmnt].push_back(std::make_pair("Lazy reduction freq. (ms)",
std::to_string(this->mnt_red_lazy_freq.count())));
#endif

headers[p].push_back(std::make_pair("Coset approach (c)", this->coset ? "yes" : "no"));
headers[p].push_back(std::make_pair("Coded monitoring", this->coded_monitoring ? "yes" : "no"));

Expand Down Expand Up @@ -196,8 +230,9 @@ ::get_headers(std::map<std::string,header_list>& headers, const bool full) const

if (this->mnt_er != nullptr) { this->mnt_er->get_headers(headers, full); }

headers[this->mnt_er->get_prefix()].push_back(std::make_pair("Compute mutual info", this->mutinfo ? "yes" : "no"));
if (this->mutinfo)
headers[this->mnt_er->get_prefix()].push_back(std::make_pair("Compute mutual info",
this->mnt_mutinfo ? "yes" : "no"));
if (this->mnt_mutinfo)
if (this->mnt_er != nullptr) { this->mnt_er->get_headers(headers, full); }

if (this->ter != nullptr) { this->ter->get_headers(headers, full); }
Expand Down
9 changes: 8 additions & 1 deletion src/Factory/Simulation/BFER/BFER.hpp
Expand Up @@ -34,7 +34,14 @@ struct BFER : Simulation
bool err_track_enable = false;
bool coset = false;
bool coded_monitoring = false;
bool mutinfo = false;
bool mnt_mutinfo = false;

#ifdef AFF3CT_MPI
std::chrono::milliseconds mnt_mpi_comm_freq = std::chrono::milliseconds(1000);
#else
std::chrono::milliseconds mnt_red_lazy_freq = std::chrono::milliseconds(0);
bool mnt_red_lazy = false;
#endif

// module parameters
tools::auto_cloned_unique_ptr<Source ::parameters> src;
Expand Down

0 comments on commit fcd41ff

Please sign in to comment.