author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
8,490 |
30.11.2019 10:20:21
| -3,600 |
f825bc10900fea242ac6df4c8da6cef54bb05de5
|
Fix the frozen bits update in polar decoders.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Decoder/Polar/SC/Decoder_polar_SC_fast_sys.hpp",
"new_path": "include/Module/Decoder/Polar/SC/Decoder_polar_SC_fast_sys.hpp",
"diff": "#include \"Tools/Code/Polar/Pattern_polar_parser.hpp\"\n#include \"Tools/Code/Polar/API/API_polar_dynamic_seq.hpp\"\n#include \"Tools/Code/Polar/decoder_polar_functions.h\"\n-#include \"Tools/Interface/Interface_notify_noise_update.hpp\"\n+#include \"Tools/Interface/Interface_notify_frozenbits_update.hpp\"\n#include \"Module/Decoder/Decoder_SIHO.hpp\"\nnamespace aff3ct\n@@ -31,7 +31,7 @@ template <typename B = int, typename R = float,\ntools::g0_LLR< R>,\ntools::h_LLR <B,R>,\ntools::xo_STD<B >>>\n-class Decoder_polar_SC_fast_sys : public Decoder_SIHO<B,R>, public tools::Interface_notify_noise_update\n+class Decoder_polar_SC_fast_sys : public Decoder_SIHO<B,R>, public tools::Interface_notify_frozenbits_update\n{\n#ifndef DOXYGEN_SHOULD_SKIP_THIS\nfriend Decoder_polar_ASCL_fast_CA_sys <B,R,API_polar>;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Decoder/Polar/SC/Decoder_polar_SC_naive.hpp",
"new_path": "include/Module/Decoder/Polar/SC/Decoder_polar_SC_naive.hpp",
"diff": "#include \"Tools/Algo/Tree/Binary_node.hpp\"\n#include \"Tools/Algo/Tree/Binary_tree.hpp\"\n#include \"Tools/Code/Polar/decoder_polar_functions.h\"\n-#include \"Tools/Interface/Interface_notify_noise_update.hpp\"\n+#include \"Tools/Interface/Interface_notify_frozenbits_update.hpp\"\n#include \"Module/Decoder/Decoder_SIHO.hpp\"\nnamespace aff3ct\n@@ -32,7 +32,7 @@ public:\ntemplate <typename B = int, typename R = float, tools::proto_f< R> F = tools::f_LLR,\ntools::proto_g<B,R> G = tools::g_LLR,\ntools::proto_h<B,R> H = tools::h_LLR>\n-class Decoder_polar_SC_naive : public Decoder_SIHO<B,R>, public tools::Interface_notify_noise_update\n+class Decoder_polar_SC_naive : public Decoder_SIHO<B,R>, public tools::Interface_notify_frozenbits_update\n{\nprotected:\nconst int m; // graph depth\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Decoder/Polar/SCL/Decoder_polar_SCL_MEM_fast_sys.hpp",
"new_path": "include/Module/Decoder/Polar/SCL/Decoder_polar_SCL_MEM_fast_sys.hpp",
"diff": "#include \"Tools/Code/Polar/API/API_polar_dynamic_seq.hpp\"\n#include \"Tools/Algo/Sort/LC_sorter.hpp\"\n#include \"Tools/Code/Polar/decoder_polar_functions.h\"\n-#include \"Tools/Interface/Interface_notify_noise_update.hpp\"\n+#include \"Tools/Interface/Interface_notify_frozenbits_update.hpp\"\n#include \"Tools/Code/Polar/Pattern_polar_parser.hpp\"\n#include \"Tools/Code/Polar/Patterns/Pattern_polar_i.hpp\"\n@@ -27,7 +27,7 @@ template <typename B = int, typename R = float,\ntools::g0_LLR< R>,\ntools::h_LLR <B,R>,\ntools::xo_STD<B >>>\n-class Decoder_polar_SCL_MEM_fast_sys : public Decoder_SIHO<B,R>, public tools::Interface_notify_noise_update\n+class Decoder_polar_SCL_MEM_fast_sys : public Decoder_SIHO<B,R>, public tools::Interface_notify_frozenbits_update\n{\nprotected:\nconst int m; // graph depth\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Decoder/Polar/SCL/Decoder_polar_SCL_fast_sys.hpp",
"new_path": "include/Module/Decoder/Polar/SCL/Decoder_polar_SCL_fast_sys.hpp",
"diff": "#include \"Tools/Code/Polar/API/API_polar_dynamic_seq.hpp\"\n#include \"Tools/Algo/Sort/LC_sorter.hpp\"\n#include \"Tools/Code/Polar/decoder_polar_functions.h\"\n-#include \"Tools/Interface/Interface_notify_noise_update.hpp\"\n+#include \"Tools/Interface/Interface_notify_frozenbits_update.hpp\"\n#include \"Tools/Code/Polar/Pattern_polar_parser.hpp\"\n#include \"Tools/Code/Polar/Patterns/Pattern_polar_i.hpp\"\n@@ -27,7 +27,7 @@ template <typename B = int, typename R = float,\ntools::g0_LLR< R>,\ntools::h_LLR <B,R>,\ntools::xo_STD<B >>>\n-class Decoder_polar_SCL_fast_sys : public Decoder_SIHO<B,R>, public tools::Interface_notify_noise_update\n+class Decoder_polar_SCL_fast_sys : public Decoder_SIHO<B,R>, public tools::Interface_notify_frozenbits_update\n{\nprotected:\nconst int m; // graph depth\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Decoder/Polar/SCL/Decoder_polar_SCL_naive.hpp",
"new_path": "include/Module/Decoder/Polar/SCL/Decoder_polar_SCL_naive.hpp",
"diff": "#include \"Tools/Algo/Tree/Binary_node.hpp\"\n#include \"Tools/Algo/Tree/Binary_tree_metric.hpp\"\n#include \"Tools/Code/Polar/decoder_polar_functions.h\"\n-#include \"Tools/Interface/Interface_notify_noise_update.hpp\"\n+#include \"Tools/Interface/Interface_notify_frozenbits_update.hpp\"\n#include \"Module/Decoder/Decoder_SIHO.hpp\"\n@@ -32,7 +32,7 @@ public:\n};\ntemplate <typename B, typename R, tools::proto_f<R> F = tools::f_LLR, tools::proto_g<B,R> G = tools::g_LLR>\n-class Decoder_polar_SCL_naive : public Decoder_SIHO<B,R>, public tools::Interface_notify_noise_update\n+class Decoder_polar_SCL_naive : public Decoder_SIHO<B,R>, public tools::Interface_notify_frozenbits_update\n{\nprotected:\nconst int m; // graph depth\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the frozen bits update in polar decoders.
|
8,490 |
30.11.2019 11:46:46
| -3,600 |
3a5eeef30d086f853e8cc4560a41de14e84c5928
|
Fix MPI monitor.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction.hpp",
"new_path": "include/Tools/Monitor/Monitor_reduction.hpp",
"diff": "@@ -66,7 +66,7 @@ public:\n* \\brief check if this monitor has done\n* \\return true if has done\n*/\n- virtual bool is_done() = 0;\n+ virtual bool is_done();\n/*\n* \\brief do the reduction of this monitor\n@@ -78,6 +78,8 @@ protected:\nvirtual ~Monitor_reduction_static() = default;\n+ virtual bool _is_done() = 0;\n+\nprivate:\n/*\n* \\brief loop on a forced reduction until '_reduce' call return 'true' after having call 'set_stop_loop()'\n@@ -138,9 +140,10 @@ public:\nvirtual void reset();\n- virtual bool is_done();\n-\nvirtual void reduce(bool fully = true);\n+\n+protected:\n+ virtual bool _is_done();\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction.hxx",
"new_path": "include/Tools/Monitor/Monitor_reduction.hxx",
"diff": "@@ -84,7 +84,7 @@ void Monitor_reduction<M>\ntemplate <class M>\nbool Monitor_reduction<M>\n-::is_done()\n+::_is_done()\n{\n// only the master thread can do this\nif ((std::this_thread::get_id() == Monitor_reduction_static::master_thread_id &&\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction_MPI.hpp",
"new_path": "include/Tools/Monitor/Monitor_reduction_MPI.hpp",
"diff": "@@ -29,10 +29,15 @@ private:\npublic:\nexplicit Monitor_reduction_MPI(const std::vector<std::unique_ptr<M>> &monitors);\n- virtual ~Monitor_reduction_MPI() = default;\n+ virtual ~Monitor_reduction_MPI();\n+\n+ virtual bool is_done();\nvirtual void reduce(bool fully = false);\n+protected:\n+ virtual bool _is_done();\n+\nprivate:\nstatic void MPI_reduce_monitors(void *in, void *inout, int *len, MPI_Datatype *datatype);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction_MPI.hxx",
"new_path": "include/Tools/Monitor/Monitor_reduction_MPI.hxx",
"diff": "@@ -47,6 +47,30 @@ Monitor_reduction_MPI<M>\n}\n}\n+template <class M>\n+Monitor_reduction_MPI<M>\n+::~Monitor_reduction_MPI()\n+{\n+ MPI_Type_free(&MPI_monitor_vals);\n+ MPI_Op_free(&MPI_Op_reduce_monitors);\n+}\n+\n+template <class M>\n+bool Monitor_reduction_MPI<M>\n+::is_done()\n+{\n+ std::stringstream message;\n+ message << \"'is_done' method is not available in MPI, please use the static 'is_done_all' method instead.\";\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__, message.str());\n+}\n+\n+template <class M>\n+bool Monitor_reduction_MPI<M>\n+::_is_done()\n+{\n+ return M::is_done();\n+}\n+\ntemplate <class M>\nvoid Monitor_reduction_MPI<M>\n::reduce(bool fully)\n@@ -56,7 +80,12 @@ void Monitor_reduction_MPI<M>\nMonitor_reduction<M>::reduce(fully);\nAttributes mvals_send = M::get_attributes(), mvals_recv;\n- MPI_Allreduce(&mvals_send, &mvals_recv, 1, MPI_monitor_vals, MPI_Op_reduce_monitors, MPI_COMM_WORLD);\n+ if (auto ret = MPI_Allreduce(&mvals_send, &mvals_recv, 1, MPI_monitor_vals, MPI_Op_reduce_monitors, MPI_COMM_WORLD))\n+ {\n+ std::stringstream message;\n+ message << \"'MPI_Allreduce' returned '\" << ret << \"' error code.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nM::copy(mvals_recv);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -130,7 +130,12 @@ void Simulation\nint max_n_threads_global;\nint max_n_threads_local = this->n_threads;\n- MPI_Allreduce(&max_n_threads_local, &max_n_threads_global, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);\n+ if (auto ret = MPI_Allreduce(&max_n_threads_local, &max_n_threads_global, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD))\n+ {\n+ std::stringstream message;\n+ message << \"'MPI_Allreduce' returned '\" << ret << \"' error code.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nif (max_n_threads_global <= 0)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.cpp",
"new_path": "src/Tools/Display/Terminal/Terminal.cpp",
"diff": "#ifdef AFF3CT_MPI\n#include <mpi.h>\n+#include <sstream>\n+#include \"Tools/Exception/exception.hpp\"\n#endif\n#include <csignal>\n#include <cstdlib>\n@@ -115,7 +117,12 @@ bool Terminal\n#ifdef AFF3CT_MPI\nchar over_send = (char)Terminal::over, over_recv;\n- MPI_Allreduce(&over_send, &over_recv, 1, MPI_CHAR, MPI_LOR, MPI_COMM_WORLD);\n+ if (auto ret = MPI_Allreduce(&over_send, &over_recv, 1, MPI_CHAR, MPI_LOR, MPI_COMM_WORLD))\n+ {\n+ std::stringstream message;\n+ message << \"'MPI_Allreduce' returned '\" << ret << \"' error code.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nreturn (bool)over_recv;\n#else\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Monitor/Monitor_reduction.cpp",
"new_path": "src/Tools/Monitor/Monitor_reduction.cpp",
"diff": "@@ -38,6 +38,12 @@ void Monitor_reduction_static\nm->reset();\n}\n+bool Monitor_reduction_static\n+::is_done()\n+{\n+ return this->_is_done();\n+}\n+\nbool Monitor_reduction_static\n::is_done_all(bool fully, bool final)\n{\n@@ -49,7 +55,7 @@ bool Monitor_reduction_static\nbool is_done = false;\nfor(auto& m : Monitor_reduction_static::monitors)\n- is_done |= m->is_done();\n+ is_done |= m->_is_done();\nif (is_done)\nset_stop_loop();\n@@ -76,16 +82,31 @@ void Monitor_reduction_static\n{\n#ifdef AFF3CT_MPI\nint n_monitor_send = Monitor_reduction_static::monitors.size(), n_monitor_recv;\n- MPI_Allreduce(&n_monitor_send, &n_monitor_recv, 1, MPI_INT, MPI_PROD, MPI_COMM_WORLD);\n+ if (auto ret = MPI_Allreduce(&n_monitor_send, &n_monitor_recv, 1, MPI_INT, MPI_PROD, MPI_COMM_WORLD))\n+ {\n+ std::stringstream message;\n+ message << \"'MPI_Allreduce' returned '\" << ret << \"' error code.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nint np;\n- MPI_Comm_size(MPI_COMM_WORLD, &np);\n+ if (auto ret = MPI_Comm_size(MPI_COMM_WORLD, &np))\n+ {\n+ std::stringstream message;\n+ message << \"'MPI_Comm_size' returned '\" << ret << \"' error code.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nint pow_np = std::pow(n_monitor_send, np);\nif (n_monitor_recv != pow_np)\n{\nint mpi_rank;\n- MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);\n+ if (auto ret = MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank))\n+ {\n+ std::stringstream message;\n+ message << \"'MPI_Comm_rank' returned '\" << ret << \"' error code.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nstd::stringstream message;\nmessage << \"The number of monitors to reduce (\" << n_monitor_send << \" monitors) with MPI on the process \"\n@@ -101,13 +122,23 @@ bool Monitor_reduction_static\n{\n#ifdef AFF3CT_MPI\nint n_stop_recv, stop_send = Monitor_reduction_static::get_stop_loop() ? 1 : 0;\n- MPI_Allreduce(&stop_send, &n_stop_recv, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);\n+ if (auto ret = MPI_Allreduce(&stop_send, &n_stop_recv, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD))\n+ {\n+ std::stringstream message;\n+ message << \"'MPI_Allreduce' returned '\" << ret << \"' error code.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nif (n_stop_recv > 0)\nMonitor_reduction_static::set_stop_loop();\nint np;\n- MPI_Comm_size(MPI_COMM_WORLD, &np);\n+ if (auto ret = MPI_Comm_size(MPI_COMM_WORLD, &np))\n+ {\n+ std::stringstream message;\n+ message << \"'MPI_Comm_size' returned '\" << ret << \"' error code.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nreturn n_stop_recv == np;\n#else\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix MPI monitor.
|
8,490 |
30.11.2019 12:09:08
| -3,600 |
eed80d168475e98f488fc18be31bac253026825b
|
Add a virtual destructor to socket.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hpp",
"new_path": "include/Module/Socket.hpp",
"diff": "@@ -36,6 +36,7 @@ protected:\npublic:\ninline Socket(Task &task, const std::string &name, const std::type_index datatype, const size_t databytes,\nconst bool fast = false, void *dataptr = nullptr);\n+ virtual ~Socket() = default;\ninline const std::string& get_name () const;\ninline const std::type_index& get_datatype () const;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a virtual destructor to socket.
|
8,490 |
30.11.2019 13:17:12
| -3,600 |
c8359a1895572009b92b17933673b32a35af2b92
|
Simplify the static monitor reduction interface.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction.hpp",
"new_path": "include/Tools/Monitor/Monitor_reduction.hpp",
"diff": "@@ -36,13 +36,18 @@ public:\n* \\param fully call the reduction functions with this parameter\n* \\return 'get_stop_loop()' result\n*/\n- static bool is_done_all(bool fully = false, bool final = false);\n+ static bool is_done_all(bool fully = false);\n/*\n* \\brief call _reduce with 'fully' and 'force' arguments\n*/\nstatic void reduce_all(bool fully = false, bool force = false);\n+ /*\n+ * \\brief loop on a forced reduction until '_reduce' call return 'true' after having call 'set_stop_loop()'\n+ */\n+ static void last_reduce_all(bool fully = true);\n+\n/*\n* \\brief throw if all process do not have the same number of monitors to reduce\n*/\n@@ -81,11 +86,6 @@ protected:\nvirtual bool _is_done() = 0;\nprivate:\n- /*\n- * \\brief loop on a forced reduction until '_reduce' call return 'true' after having call 'set_stop_loop()'\n- */\n- static void last_reduce_all(bool fully = false);\n-\n/*\n* \\brief get if the current simulation loop must be stopped or not\n* \\return true if loop must be stopped\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -183,11 +183,11 @@ void BFER<B,R,Q>\ntry\n{\nthis->_launch();\n- tools::Monitor_reduction_static::is_done_all(true, true); // final reduction\n+ tools::Monitor_reduction_static::last_reduce_all(); // final reduction\n}\ncatch (std::exception const& e)\n{\n- tools::Monitor_reduction_static::is_done_all(true, true); // final reduction\n+ tools::Monitor_reduction_static::last_reduce_all(); // final reduction\nterminal->final_report(std::cout); // display final report to not lost last line overwritten by the error\n// messages\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Monitor/Monitor_reduction.cpp",
"new_path": "src/Tools/Monitor/Monitor_reduction.cpp",
"diff": "@@ -45,11 +45,8 @@ bool Monitor_reduction_static\n}\nbool Monitor_reduction_static\n-::is_done_all(bool fully, bool final)\n+::is_done_all(bool fully)\n{\n- if (final)\n- last_reduce_all(fully);\n- else\nreduce_all(fully, false);\nbool is_done = false;\n@@ -73,7 +70,6 @@ void Monitor_reduction_static\n::last_reduce_all(bool fully)\n{\nMonitor_reduction_static::set_stop_loop();\n-\nwhile(!_reduce(fully, true));\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simplify the static monitor reduction interface.
|
8,490 |
30.11.2019 15:55:55
| -3,600 |
6202855707b6f361475107beba013ff143bec151
|
Mv Chain from module to tools + create new module::Chain.
|
[
{
"change_type": "DELETE",
"old_path": "include/Module/Chain.hpp",
"new_path": null,
"diff": "-/*!\n- * \\file\n- * \\brief Class module::Chain.\n- */\n-#ifndef CHAIN_HPP_\n-#define CHAIN_HPP_\n-\n-#include <functional>\n-#include <memory>\n-#include <vector>\n-\n-namespace aff3ct\n-{\n-namespace module\n-{\n-class Task;\n-class Module;\n-\n-class Chain\n-{\n-protected:\n- size_t n_threads;\n- std::vector<const Task*> tasks_sequence;\n- std::vector<std::vector<Task*>> tasks_sequences;\n- std::vector<std::vector<std::shared_ptr<Module>>> modules;\n-\n-public:\n- Chain(const Task &first, const size_t n_threads = 1);\n- Chain(const Task &first, const Task &last, const size_t n_threads = 1);\n- virtual ~Chain() = default;\n-\n- void exec(std::function<bool(const std::vector<int>&)> stop_condition);\n- void exec(std::function<bool( )> stop_condition);\n- inline size_t get_n_threads() const;\n-\n- template <class C = Module>\n- std::vector<C*> get_modules() const;\n- std::vector<std::vector<const Module*>> get_modules_per_threads() const;\n- std::vector<std::vector<const Module*>> get_modules_per_types () const;\n-\n-protected:\n- void init_recursive(const Task& current_task, const Task *last = nullptr);\n- void _exec(std::function<bool(const std::vector<int>&)> &stop_condition,\n- std::vector<Task*> &tasks_sequence);\n- void _exec_without_statuses(std::function<bool()> &stop_condition,\n- std::vector<Task*> &tasks_sequence);\n- void duplicate();\n-\n-};\n-}\n-}\n-\n-#ifndef DOXYGEN_SHOULD_SKIP_THIS\n-#include \"Module/Chain.hxx\"\n-#endif\n-\n-#endif /* CHAIN_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Chain/Chain.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Chain.\n+ */\n+#ifndef MODULE_CHAIN_HPP_\n+#define MODULE_CHAIN_HPP_\n+\n+#include <memory>\n+\n+#include \"Tools/Chain/Chain.hpp\"\n+#include \"Module/Module.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+class Chain : public Module\n+{\n+ std::shared_ptr<tools::Chain> chain;\n+\n+public:\n+ explicit Chain(const tools::Chain &chain);\n+\n+ virtual ~Chain() = default;\n+\n+ virtual Chain* clone() const;\n+\n+protected:\n+ virtual void deep_copy(const Chain& m);\n+};\n+}\n+}\n+\n+#endif /* MODULE_CHAIN_HPP_ */\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Task.hpp",
"new_path": "include/Module/Task.hpp",
"diff": "#include \"Tools/Interface/Interface_clone.hpp\"\n#include \"Tools/Interface/Interface_reset.hpp\"\n-#include \"Module/Chain.hpp\"\nnamespace aff3ct\n{\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class tools::Chain.\n+ */\n+#ifndef TOOLS_CHAIN_HPP_\n+#define TOOLS_CHAIN_HPP_\n+\n+#include <functional>\n+#include <memory>\n+#include <vector>\n+\n+#include \"Tools/Interface/Interface_clone.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+class Task;\n+class Module;\n+class Chain;\n+}\n+namespace tools\n+{\n+\n+class Chain : Interface_clone\n+{\n+ friend module::Chain;\n+\n+protected:\n+ size_t n_threads;\n+ std::vector<std::vector<module::Task*>> tasks_sequences;\n+ std::vector<std::vector<std::shared_ptr<module::Module>>> modules;\n+\n+public:\n+ Chain(const module::Task &first, const size_t n_threads = 1);\n+ Chain(const module::Task &first, const module::Task &last, const size_t n_threads = 1);\n+ virtual ~Chain() = default;\n+ virtual Chain* clone() const;\n+\n+ void exec(std::function<bool(const std::vector<int>&)> stop_condition);\n+ void exec(std::function<bool( )> stop_condition);\n+ int exec(const int tid = 0 );\n+ inline size_t get_n_threads() const;\n+\n+ template <class C = module::Module>\n+ std::vector<C*> get_modules() const;\n+ std::vector<std::vector<const module::Module*>> get_modules_per_threads() const;\n+ std::vector<std::vector<const module::Module*>> get_modules_per_types () const;\n+\n+protected:\n+ static void init_recursive(std::vector<const module::Task*> &tasks_sequence,\n+ const module::Task& current_task,\n+ const module::Task *last = nullptr);\n+ void _exec(std::function<bool(const std::vector<int>&)> &stop_condition,\n+ std::vector<module::Task*> &tasks_sequence);\n+ void _exec_without_statuses(std::function<bool()> &stop_condition,\n+ std::vector<module::Task*> &tasks_sequence);\n+ void duplicate(const std::vector<const module::Task*> &tasks_sequence);\n+};\n+}\n+}\n+\n+#ifndef DOXYGEN_SHOULD_SKIP_THIS\n+#include \"Tools/Chain/Chain.hxx\"\n+#endif\n+\n+#endif /* TOOLS_CHAIN_HPP_ */\n"
},
{
"change_type": "RENAME",
"old_path": "include/Module/Chain.hxx",
"new_path": "include/Tools/Chain/Chain.hxx",
"diff": "-#include \"Module/Chain.hpp\"\n+#include \"Tools/Chain/Chain.hpp\"\nnamespace aff3ct\n{\n-namespace module\n+namespace tools\n{\nsize_t Chain\n::get_n_threads() const\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Chain/Chain.cpp",
"diff": "+#include <string>\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Module/Chain/Chain.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+Chain\n+::Chain(const tools::Chain &chain)\n+: Module(chain.tasks_sequences[0][0]->get_module().get_n_frames()),\n+ chain(chain.clone())\n+{\n+ const std::string name = \"Chain\";\n+ this->set_name(name);\n+ this->set_short_name(name);\n+\n+ if (chain.get_n_threads() != 1)\n+ {\n+ std::stringstream message;\n+ message << \"'chain.get_n_threads()' has to be equal to 1 ('chain.get_n_threads()' = \" << chain.get_n_threads()\n+ << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto &p = this->create_task(\"exec\");\n+\n+ auto &first = *this->chain->tasks_sequences[0][0];\n+ for (auto &s : first.sockets)\n+ {\n+ if (first.get_socket_type(*s) == socket_t::SIN)\n+ {\n+ if (s->get_datatype() == typeid(int8_t ))\n+ this->template create_socket_in<int8_t >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int16_t))\n+ this->template create_socket_in<int16_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int32_t))\n+ this->template create_socket_in<int32_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int64_t))\n+ this->template create_socket_in<int64_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(float ))\n+ this->template create_socket_in<float >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(double ))\n+ this->template create_socket_in<double >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ }\n+ if (first.get_socket_type(*s) == socket_t::SIN_SOUT)\n+ {\n+ if (s->get_datatype() == typeid(int8_t ))\n+ this->template create_socket_in_out<int8_t >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int16_t))\n+ this->template create_socket_in_out<int16_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int32_t))\n+ this->template create_socket_in_out<int32_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int64_t))\n+ this->template create_socket_in_out<int64_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(float ))\n+ this->template create_socket_in_out<float >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(double ))\n+ this->template create_socket_in_out<double >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ }\n+ }\n+ auto &last = *this->chain->tasks_sequences[0][this->chain->tasks_sequences.size()-1];\n+ for (auto &s : last.sockets)\n+ {\n+ if (last.get_socket_type(*s) == socket_t::SOUT)\n+ {\n+ if (s->get_datatype() == typeid(int8_t ))\n+ this->template create_socket_out<int8_t >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int16_t))\n+ this->template create_socket_out<int16_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int32_t))\n+ this->template create_socket_out<int32_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int64_t))\n+ this->template create_socket_out<int64_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(float ))\n+ this->template create_socket_out<float >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(double ))\n+ this->template create_socket_out<double >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ }\n+ if (last.get_socket_type(*s) == socket_t::SIN_SOUT)\n+ {\n+ if (s->get_datatype() == typeid(int8_t ))\n+ this->template create_socket_in_out<int8_t >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int16_t))\n+ this->template create_socket_in_out<int16_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int32_t))\n+ this->template create_socket_in_out<int32_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(int64_t))\n+ this->template create_socket_in_out<int64_t>(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(float ))\n+ this->template create_socket_in_out<float >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ else if (s->get_datatype() == typeid(double ))\n+ this->template create_socket_in_out<double >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n+ }\n+ }\n+\n+ this->create_codelet(p, [](Module &m, Task &t) -> int\n+ {\n+ auto &c = static_cast<Chain&>(m);\n+\n+ auto &first = *c.chain->tasks_sequences[0][0];\n+ size_t sid_in = 0;\n+ for (auto &s : first.sockets)\n+ {\n+ if (first.get_socket_type(*s) == socket_t::SIN || first.get_socket_type(*s) == socket_t::SIN_SOUT)\n+ s->bind(t.sockets[sid_in]->get_dataptr());\n+ sid_in++;\n+ }\n+\n+ auto ret = c.chain->exec();\n+\n+ auto &last = *c.chain->tasks_sequences[0][c.chain->tasks_sequences.size()-1];\n+ size_t sid_out = 0;\n+ for (auto &s : last.sockets)\n+ {\n+ if (last.get_socket_type(*s) == socket_t::SOUT || last.get_socket_type(*s) == socket_t::SIN_SOUT)\n+ t.sockets[sid_out]->bind(s->get_dataptr());\n+ sid_out++;\n+ }\n+\n+ return ret;\n+ });\n+}\n+\n+Chain* Chain\n+::clone() const\n+{\n+ auto m = new Chain(*this);\n+ m->deep_copy(*this);\n+ return m;\n+}\n+\n+void Chain\n+::deep_copy(const Chain& m)\n+{\n+ Module::deep_copy(m);\n+ if (m.chain != nullptr) this->chain.reset(m.chain->clone());\n+}\n"
},
{
"change_type": "RENAME",
"old_path": "src/Module/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "#include <thread>\n#include <utility>\n+#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Module.hpp\"\n#include \"Module/Task.hpp\"\n#include \"Module/Socket.hpp\"\n-#include \"Module/Chain.hpp\"\n+#include \"Tools/Chain/Chain.hpp\"\nusing namespace aff3ct;\n-using namespace aff3ct::module;\n+using namespace aff3ct::tools;\nChain\n-::Chain(const Task &first, const Task &last, const size_t n_threads)\n+::Chain(const module::Task &first, const module::Task &last, const size_t n_threads)\n: n_threads(n_threads), tasks_sequences(n_threads), modules(n_threads)\n{\nif (n_threads == 0)\n@@ -21,12 +22,13 @@ Chain\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- this->init_recursive(first, &last);\n- this->duplicate();\n+ std::vector<const module::Task*> tasks_sequence;\n+ this->init_recursive(tasks_sequence, first, &last);\n+ this->duplicate(tasks_sequence);\n}\nChain\n-::Chain(const Task &first, const size_t n_threads)\n+::Chain(const module::Task &first, const size_t n_threads)\n: n_threads(n_threads), tasks_sequences(n_threads), modules(n_threads)\n{\nif (n_threads == 0)\n@@ -36,14 +38,28 @@ Chain\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- this->init_recursive(first);\n- this->duplicate();\n+ std::vector<const module::Task*> tasks_sequence;\n+ this->init_recursive(tasks_sequence, first);\n+ this->duplicate(tasks_sequence);\n}\n-std::vector<std::vector<const Module*>> Chain\n+Chain* Chain\n+::clone() const\n+{\n+ auto c = new Chain(*this);\n+ c->tasks_sequences.clear();\n+ c->modules.clear();\n+ std::vector<const module::Task*> tasks_sequence;\n+ for (size_t t = 0; t < this->tasks_sequences[0].size(); t++)\n+ tasks_sequence.push_back(this->tasks_sequences[0][t]);\n+ c->duplicate(tasks_sequence);\n+ return c;\n+}\n+\n+std::vector<std::vector<const module::Module*>> Chain\n::get_modules_per_threads() const\n{\n- std::vector<std::vector<const Module*>> modules_per_threads(modules.size());\n+ std::vector<std::vector<const module::Module*>> modules_per_threads(modules.size());\nsize_t tid = 0;\nfor (auto &e : modules)\n{\n@@ -54,11 +70,11 @@ std::vector<std::vector<const Module*>> Chain\nreturn modules_per_threads;\n}\n-std::vector<std::vector<const Module*>> Chain\n+std::vector<std::vector<const module::Module*>> Chain\n::get_modules_per_types() const\n{\n- std::vector<std::vector<const Module*>> modules_per_types(modules[0].size());\n+ std::vector<std::vector<const module::Module*>> modules_per_types(modules[0].size());\nfor (auto &e : modules)\n{\nsize_t mid = 0;\n@@ -69,7 +85,9 @@ std::vector<std::vector<const Module*>> Chain\n}\nvoid Chain\n-::init_recursive(const Task& current_task, const Task *last)\n+::init_recursive(std::vector<const module::Task*> &tasks_sequence,\n+ const module::Task& current_task,\n+ const module::Task *last)\n{\nif (current_task.can_exec())\n{\n@@ -86,8 +104,8 @@ void Chain\n{\nfor (auto &s : current_task.sockets)\n{\n- if (current_task.get_socket_type(*s) == socket_t::SIN_SOUT ||\n- current_task.get_socket_type(*s) == socket_t::SOUT)\n+ if (current_task.get_socket_type(*s) == module::socket_t::SIN_SOUT ||\n+ current_task.get_socket_type(*s) == module::socket_t::SOUT)\n{\nauto bss = s->get_bound_sockets();\nfor (auto &bs : bss)\n@@ -96,11 +114,11 @@ void Chain\n{\nauto &t = bs->get_task();\nif (t.is_last_input_socket(*bs))\n- this->init_recursive(t, last);\n+ Chain::init_recursive(tasks_sequence, t, last);\n}\n}\n}\n- else if (current_task.get_socket_type(*s) == socket_t::SIN)\n+ else if (current_task.get_socket_type(*s) == module::socket_t::SIN)\n{\nif (s->get_bound_sockets().size() > 1)\n{\n@@ -120,7 +138,7 @@ void Chain\n}\nvoid Chain\n-::_exec(std::function<bool(const std::vector<int>&)> &stop_condition, std::vector<Task*> &tasks_sequence)\n+::_exec(std::function<bool(const std::vector<int>&)> &stop_condition, std::vector<module::Task*> &tasks_sequence)\n{\nstd::vector<int> statuses(tasks_sequence.size(), 0);\nwhile (!stop_condition(statuses))\n@@ -129,7 +147,7 @@ void Chain\n}\nvoid Chain\n-::_exec_without_statuses(std::function<bool()> &stop_condition, std::vector<Task*> &tasks_sequence)\n+::_exec_without_statuses(std::function<bool()> &stop_condition, std::vector<module::Task*> &tasks_sequence)\n{\nwhile (!stop_condition())\nfor (size_t ta = 0; ta < tasks_sequence.size(); ta++)\n@@ -163,14 +181,24 @@ void Chain\nthreads[tid].join();\n}\n+int Chain\n+::exec(const int tid)\n+{\n+ int ret = 0;\n+ for (size_t ta = 0; ta < this->tasks_sequences[tid].size(); ta++)\n+ ret += this->tasks_sequences[tid][ta]->exec();\n+ return ret;\n+}\n+\nvoid Chain\n-::duplicate()\n+::duplicate(const std::vector<const module::Task*> &tasks_sequence)\n{\n- std::vector<std::pair<const Module*, std::vector<const Task*>>> modules_to_tasks;\n- std::map<const Task*, size_t> task_to_module_id;\n+ std::vector<std::pair<const module::Module*, std::vector<const module::Task*>>> modules_to_tasks;\n+ std::map<const module::Task*, size_t> task_to_module_id;\n- auto exist_module = [](const std::vector<std::pair<const Module*, std::vector<const Task*>>> &modules_to_tasks,\n- const Module *m) -> int\n+ auto exist_module = [](const std::vector<std::pair<const module::Module*, std::vector<const module::Task*>>>\n+ &modules_to_tasks,\n+ const module::Module *m) -> int\n{\nfor (int i = 0; i < (int)modules_to_tasks.size(); i++)\nif (modules_to_tasks[i].first == m)\n@@ -178,13 +206,13 @@ void Chain\nreturn -1;\n};\n- for (auto &ta : this->tasks_sequence)\n+ for (auto &ta : tasks_sequence)\n{\nauto m = &ta->get_module();\nauto id = exist_module(modules_to_tasks, m);\nif (id == -1)\n{\n- std::vector<const Task*> vt = {ta};\n+ std::vector<const module::Task*> vt = {ta};\ntask_to_module_id[ta] = modules_to_tasks.size();\nmodules_to_tasks.push_back(std::make_pair(m, vt));\n}\n@@ -201,24 +229,26 @@ void Chain\nthis->modules[tid].resize(modules_to_tasks.size());\nsize_t m = 0;\nfor (auto &mtt : modules_to_tasks)\n- this->modules[tid][m++] = std::shared_ptr<Module>(mtt.first->clone());\n+ this->modules[tid][m++] = std::shared_ptr<module::Module>(mtt.first->clone());\n}\n- auto get_task_id = [this](const Task &ta) -> int {\n- for (size_t t = 0; t < this->tasks_sequence.size(); t++)\n- if (&ta == this->tasks_sequence[t])\n+ auto get_task_id = [this, &tasks_sequence](const module::Task &ta) -> int\n+ {\n+ for (size_t t = 0; t < tasks_sequence.size(); t++)\n+ if (&ta == tasks_sequence[t])\nreturn t;\nreturn -1;\n};\n- auto get_socket_id = [](const Task &ta, const Socket& so) -> int {\n+ auto get_socket_id = [](const module::Task &ta, const module::Socket& so) -> int\n+ {\nfor (size_t s = 0; s < ta.sockets.size(); s++)\nif (&so == ta.sockets[s].get())\nreturn (int)s;\nreturn -1;\n};\n- auto get_task_id_in_module = [](const Task* t) -> int\n+ auto get_task_id_in_module = [](const module::Task* t) -> int\n{\nauto &m = t->get_module();\n@@ -228,10 +258,11 @@ void Chain\nreturn -1;\n};\n- auto get_task_cpy = [this, &task_to_module_id, &get_task_id_in_module](const size_t tid, const size_t id) -> Task&\n+ auto get_task_cpy = [this, &task_to_module_id, &get_task_id_in_module, &tasks_sequence](const size_t tid,\n+ const size_t id) -> module::Task&\n{\n- const auto module_id = task_to_module_id[this->tasks_sequence[id]];\n- const auto task_id_in_module = get_task_id_in_module(this->tasks_sequence[id]);\n+ const auto module_id = task_to_module_id[tasks_sequence[id]];\n+ const auto task_id_in_module = get_task_id_in_module(tasks_sequence[id]);\nassert(task_id_in_module != -1);\nreturn *modules[tid][module_id]->tasks[task_id_in_module].get();\n};\n@@ -240,7 +271,7 @@ void Chain\nfor (size_t tid = 0; tid < this->n_threads; tid++)\n{\nauto &tasks_chain_cpy = this->tasks_sequences[tid];\n- for (size_t taid = 0; taid < this->tasks_sequence.size(); taid++)\n+ for (size_t taid = 0; taid < tasks_sequence.size(); taid++)\n{\nauto &task_cpy = get_task_cpy(tid, taid);\ntask_cpy.set_autoalloc(true);\n@@ -249,14 +280,14 @@ void Chain\n}\n// bind the tasks of the n sequences\n- for (size_t tout_id = 0; tout_id < this->tasks_sequence.size(); tout_id++)\n+ for (size_t tout_id = 0; tout_id < tasks_sequence.size(); tout_id++)\n{\n- auto &tout = this->tasks_sequence[tout_id];\n+ auto &tout = tasks_sequence[tout_id];\nfor (size_t sout_id = 0; sout_id < tout->sockets.size(); sout_id++)\n{\nauto &sout = tout->sockets[sout_id];\n- if (tout->get_socket_type(*sout) == socket_t::SIN_SOUT ||\n- tout->get_socket_type(*sout) == socket_t::SOUT)\n+ if (tout->get_socket_type(*sout) == module::socket_t::SIN_SOUT ||\n+ tout->get_socket_type(*sout) == module::socket_t::SOUT)\n{\nfor (auto &sin : sout->get_bound_sockets())\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Mv Chain from module to tools + create new module::Chain.
|
8,490 |
30.11.2019 18:45:24
| -3,600 |
f6c24da816ab34c11d99628e5e4de41b043904d6
|
Fix 'is_done' method in the 'Monitor_reduction'.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction.hpp",
"new_path": "include/Tools/Monitor/Monitor_reduction.hpp",
"diff": "@@ -142,6 +142,8 @@ public:\nvirtual void reduce(bool fully = true);\n+ virtual bool is_done();\n+\nprotected:\nvirtual bool _is_done();\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction.hxx",
"new_path": "include/Tools/Monitor/Monitor_reduction.hxx",
"diff": "@@ -82,6 +82,13 @@ void Monitor_reduction<M>\nm->reset();\n}\n+template <class M>\n+bool Monitor_reduction<M>\n+::is_done()\n+{\n+ return this->_is_done();\n+}\n+\ntemplate <class M>\nbool Monitor_reduction<M>\n::_is_done()\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix 'is_done' method in the 'Monitor_reduction'.
|
8,490 |
30.11.2019 23:29:36
| -3,600 |
88f3169b08d56ebca4223d7be4ccaa188c617f03
|
Implement a first working version of the 'module::Subchain'.
|
[
{
"change_type": "DELETE",
"old_path": "include/Module/Chain/Chain.hpp",
"new_path": null,
"diff": "-/*!\n- * \\file\n- * \\brief Class module::Chain.\n- */\n-#ifndef MODULE_CHAIN_HPP_\n-#define MODULE_CHAIN_HPP_\n-\n-#include <memory>\n-\n-#include \"Tools/Chain/Chain.hpp\"\n-#include \"Module/Module.hpp\"\n-\n-namespace aff3ct\n-{\n-namespace module\n-{\n-class Chain : public Module\n-{\n- std::shared_ptr<tools::Chain> chain;\n-\n-public:\n- explicit Chain(const tools::Chain &chain);\n-\n- virtual ~Chain() = default;\n-\n- virtual Chain* clone() const;\n-\n-protected:\n- virtual void deep_copy(const Chain& m);\n-};\n-}\n-}\n-\n-#endif /* MODULE_CHAIN_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Subchain/Subchain.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Subchain.\n+ */\n+#ifndef SUBCHAIN_HPP_\n+#define SUBCHAIN_HPP_\n+\n+#include <memory>\n+#include <cstddef>\n+\n+#include \"Tools/Chain/Chain.hpp\"\n+#include \"Module/Module.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+ namespace sch\n+ {\n+ enum class tsk : size_t { exec, SIZE };\n+ }\n+\n+class Subchain : public Module\n+{\n+ std::shared_ptr<tools::Chain> chain;\n+\n+public:\n+ inline Task& operator[](const sch::tsk t);\n+\n+ explicit Subchain(const tools::Chain &chain);\n+\n+ virtual ~Subchain() = default;\n+\n+ virtual Subchain* clone() const;\n+\n+ tools::Chain& get_chain();\n+\n+protected:\n+ virtual void deep_copy(const Subchain& m);\n+};\n+}\n+}\n+\n+#ifndef DOXYGEN_SHOULD_SKIP_THIS\n+#include \"Module/Subchain/Subchain.hxx\"\n+#endif\n+\n+#endif /* SUBCHAIN_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Subchain/Subchain.hxx",
"diff": "+#include \"Module/Subchain/Subchain.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+Task& Subchain\n+::operator[](const sch::tsk t)\n+{\n+ return Module::operator[]((size_t)t);\n+}\n+\n+}\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "* \\file\n* \\brief Class tools::Chain.\n*/\n-#ifndef TOOLS_CHAIN_HPP_\n-#define TOOLS_CHAIN_HPP_\n+#ifndef CHAIN_HPP_\n+#define CHAIN_HPP_\n#include <functional>\n#include <memory>\n@@ -17,14 +17,14 @@ namespace module\n{\nclass Task;\nclass Module;\n-class Chain;\n+class Subchain;\n}\nnamespace tools\n{\nclass Chain : Interface_clone\n{\n- friend module::Chain;\n+ friend module::Subchain;\nprotected:\nsize_t n_threads;\n@@ -49,6 +49,7 @@ public:\nprotected:\nstatic void init_recursive(std::vector<const module::Task*> &tasks_sequence,\n+ const module::Task& first,\nconst module::Task& current_task,\nconst module::Task *last = nullptr);\nvoid _exec(std::function<bool(const std::vector<int>&)> &stop_condition,\n@@ -64,4 +65,4 @@ protected:\n#include \"Tools/Chain/Chain.hxx\"\n#endif\n-#endif /* TOOLS_CHAIN_HPP_ */\n+#endif /* CHAIN_HPP_ */\n"
},
{
"change_type": "MODIFY",
"old_path": "include/aff3ct.hpp",
"new_path": "include/aff3ct.hpp",
"diff": "#ifndef FACTORY_NOISE_HPP\n#include <Factory/Tools/Noise/Noise.hpp>\n#endif\n-#ifndef MODULE_CHAIN_HPP_\n-#include <Module/Chain/Chain.hpp>\n-#endif\n#ifndef CHANNEL_AWGN_LLR_HPP_\n#include <Module/Channel/AWGN/Channel_AWGN_LLR.hpp>\n#endif\n#ifndef SOURCE_USER_HPP_\n#include <Module/Source/User/Source_user.hpp>\n#endif\n+#ifndef SUBCHAIN_HPP_\n+#include <Module/Subchain/Subchain.hpp>\n+#endif\n#ifndef TASK_HPP_\n#include <Module/Task.hpp>\n#endif\n#ifndef AUTO_CLONED_UNIQUE_PTR_HPP__\n#include <Tools/auto_cloned_unique_ptr.hpp>\n#endif\n-#ifndef TOOLS_CHAIN_HPP_\n+#ifndef CHAIN_HPP_\n#include <Tools/Chain/Chain.hpp>\n#endif\n#ifndef BCH_POLYNOMIAL_GENERATOR_HPP\n"
},
{
"change_type": "RENAME",
"old_path": "src/Module/Chain/Chain.cpp",
"new_path": "src/Module/Subchain/Subchain.cpp",
"diff": "#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Module/Chain/Chain.hpp\"\n+#include \"Module/Subchain/Subchain.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\n-Chain\n-::Chain(const tools::Chain &chain)\n+Subchain\n+::Subchain(const tools::Chain &chain)\n: Module(chain.tasks_sequences[0][0]->get_module().get_n_frames()),\nchain(chain.clone())\n{\n- const std::string name = \"Chain\";\n+ const std::string name = \"Subchain\";\nthis->set_name(name);\nthis->set_short_name(name);\n@@ -60,7 +60,7 @@ Chain\nthis->template create_socket_in_out<double >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n}\n}\n- auto &last = *this->chain->tasks_sequences[0][this->chain->tasks_sequences.size()-1];\n+ auto &last = *this->chain->tasks_sequences[0][this->chain->tasks_sequences[0].size()-1];\nfor (auto &s : last.sockets)\n{\nif (last.get_socket_type(*s) == socket_t::SOUT)\n@@ -95,45 +95,85 @@ Chain\n}\n}\n+ size_t sid = 0;\n+ for (auto &s : last.sockets)\n+ {\n+ if (last.get_socket_type(*s) == socket_t::SOUT)\n+ {\n+ while (p.get_socket_type(*p.sockets[sid]) != socket_t::SOUT) sid++;\n+ p.sockets[sid++]->bind(*s);\n+ }\n+ }\n+\n+ sid = 0;\n+ for (auto &s : last.sockets)\n+ {\n+ if (last.get_socket_type(*s) == socket_t::SIN_SOUT)\n+ {\n+ while (p.get_socket_type(*p.sockets[sid]) != socket_t::SIN_SOUT) sid++;\n+ p.sockets[sid++]->bind(*s);\n+ }\n+ }\n+\nthis->create_codelet(p, [](Module &m, Task &t) -> int\n{\n- auto &c = static_cast<Chain&>(m);\n+ auto &c = static_cast<Subchain&>(m);\nauto &first = *c.chain->tasks_sequences[0][0];\n- size_t sid_in = 0;\n+ size_t sid = 0;\nfor (auto &s : first.sockets)\n{\nif (first.get_socket_type(*s) == socket_t::SIN || first.get_socket_type(*s) == socket_t::SIN_SOUT)\n- s->bind(t.sockets[sid_in]->get_dataptr());\n- sid_in++;\n+ s->bind(t.sockets[sid]->get_dataptr());\n+ sid++;\n}\n- auto ret = c.chain->exec();\n-\n- auto &last = *c.chain->tasks_sequences[0][c.chain->tasks_sequences.size()-1];\n- size_t sid_out = 0;\n- for (auto &s : last.sockets)\n- {\n- if (last.get_socket_type(*s) == socket_t::SOUT || last.get_socket_type(*s) == socket_t::SIN_SOUT)\n- t.sockets[sid_out]->bind(s->get_dataptr());\n- sid_out++;\n+ return c.chain->exec();\n+ });\n}\n- return ret;\n- });\n+tools::Chain& Subchain\n+::get_chain()\n+{\n+ return *this->chain;\n}\n-Chain* Chain\n+Subchain* Subchain\n::clone() const\n{\n- auto m = new Chain(*this);\n+ auto m = new Subchain(*this);\nm->deep_copy(*this);\nreturn m;\n}\n-void Chain\n-::deep_copy(const Chain& m)\n+void Subchain\n+::deep_copy(const Subchain& m)\n{\nModule::deep_copy(m);\nif (m.chain != nullptr) this->chain.reset(m.chain->clone());\n+\n+ auto &last = *this->chain->tasks_sequences[0][this->chain->tasks_sequences[0].size()-1];\n+\n+ auto &p = (*this)[sch::tsk::exec];\n+\n+ size_t sid = 0;\n+ for (auto &s : last.sockets)\n+ {\n+ if (last.get_socket_type(*s) == socket_t::SOUT)\n+ {\n+ while (p.get_socket_type(*p.sockets[sid]) != socket_t::SOUT) sid++;\n+ p.sockets[sid++]->bind(*s);\n+ }\n+ }\n+\n+ sid = 0;\n+ for (auto &s : last.sockets)\n+ {\n+ if (last.get_socket_type(*s) == socket_t::SIN_SOUT)\n+ {\n+ while (p.get_socket_type(*p.sockets[sid]) != socket_t::SIN_SOUT) sid++;\n+ p.sockets[sid++]->bind(*s);\n+ }\n+ }\n+\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -23,7 +23,7 @@ Chain\n}\nstd::vector<const module::Task*> tasks_sequence;\n- this->init_recursive(tasks_sequence, first, &last);\n+ this->init_recursive(tasks_sequence, first, first, &last);\nthis->duplicate(tasks_sequence);\n}\n@@ -39,7 +39,7 @@ Chain\n}\nstd::vector<const module::Task*> tasks_sequence;\n- this->init_recursive(tasks_sequence, first);\n+ this->init_recursive(tasks_sequence, first, first);\nthis->duplicate(tasks_sequence);\n}\n@@ -47,8 +47,6 @@ Chain* Chain\n::clone() const\n{\nauto c = new Chain(*this);\n- c->tasks_sequences.clear();\n- c->modules.clear();\nstd::vector<const module::Task*> tasks_sequence;\nfor (size_t t = 0; t < this->tasks_sequences[0].size(); t++)\ntasks_sequence.push_back(this->tasks_sequences[0][t]);\n@@ -86,19 +84,43 @@ std::vector<std::vector<const module::Module*>> Chain\nvoid Chain\n::init_recursive(std::vector<const module::Task*> &tasks_sequence,\n+ const module::Task& first,\nconst module::Task& current_task,\nconst module::Task *last)\n{\n- if (current_task.can_exec())\n+ if (¤t_task == &first)\n{\n- tasks_sequence.push_back(¤t_task);\n+ for (auto &s : current_task.sockets)\n+ if ((current_task.get_socket_type(*s) == module::socket_t::SOUT ||\n+ current_task.get_socket_type(*s) == module::socket_t::SIN_SOUT) && s->get_dataptr() == nullptr)\n+ {\n+ std::stringstream message;\n+ message << \"Output sockets of the first task has to be filled.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ else if (¤t_task == last)\n+ {\n+ for (auto &s : current_task.sockets)\n+ if ((current_task.get_socket_type(*s) == module::socket_t::SIN ||\n+ current_task.get_socket_type(*s) == module::socket_t::SIN_SOUT) && s->get_dataptr() == nullptr)\n+ {\n+ std::stringstream message;\n+ message << \"Input sockets of the last task has to be filled.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n}\nelse\n+ {\n+ if (!current_task.can_exec())\n{\nstd::stringstream message;\nmessage << \"'this->can_exec()' has to be true.\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n+ }\n+\n+ tasks_sequence.push_back(¤t_task);\nif (¤t_task != last)\n{\n@@ -114,7 +136,7 @@ void Chain\n{\nauto &t = bs->get_task();\nif (t.is_last_input_socket(*bs))\n- Chain::init_recursive(tasks_sequence, t, last);\n+ Chain::init_recursive(tasks_sequence, first, t, last);\n}\n}\n}\n@@ -229,7 +251,7 @@ void Chain\nthis->modules[tid].resize(modules_to_tasks.size());\nsize_t m = 0;\nfor (auto &mtt : modules_to_tasks)\n- this->modules[tid][m++] = std::shared_ptr<module::Module>(mtt.first->clone());\n+ this->modules[tid][m++].reset(mtt.first->clone());\n}\nauto get_task_id = [this, &tasks_sequence](const module::Task &ta) -> int\n@@ -271,6 +293,7 @@ void Chain\nfor (size_t tid = 0; tid < this->n_threads; tid++)\n{\nauto &tasks_chain_cpy = this->tasks_sequences[tid];\n+ tasks_chain_cpy.clear();\nfor (size_t taid = 0; taid < tasks_sequence.size(); taid++)\n{\nauto &task_cpy = get_task_cpy(tid, taid);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Implement a first working version of the 'module::Subchain'.
|
8,490 |
01.12.2019 11:15:06
| -3,600 |
dfc86729cee8e8460d21fce1a357c02b11a9c224
|
Simplify chain and subchain implementations.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -17,15 +17,12 @@ namespace module\n{\nclass Task;\nclass Module;\n-class Subchain;\n}\nnamespace tools\n{\nclass Chain : Interface_clone\n{\n- friend module::Subchain;\n-\nprotected:\nsize_t n_threads;\nstd::vector<std::vector<module::Task*>> tasks_sequences;\n@@ -46,6 +43,8 @@ public:\nstd::vector<C*> get_modules() const;\nstd::vector<std::vector<const module::Module*>> get_modules_per_threads() const;\nstd::vector<std::vector<const module::Module*>> get_modules_per_types () const;\n+ inline const std::vector<std::vector<module::Task*>>& get_tasks_sequences() const;\n+ inline const std::vector<module::Task*>& get_tasks_sequence(const int tid = 0) const;\nprotected:\nstatic void init_recursive(std::vector<const module::Task*> &tasks_sequence,\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hxx",
"new_path": "include/Tools/Chain/Chain.hxx",
"diff": "@@ -26,5 +26,17 @@ std::vector<C*> Chain\nreturn ret;\n}\n+const std::vector<std::vector<module::Task*>>& Chain\n+::get_tasks_sequences() const\n+{\n+ return this->tasks_sequences;\n+}\n+\n+const std::vector<module::Task*>& Chain\n+::get_tasks_sequence(const int tid) const\n+{\n+ return this->tasks_sequences[tid];\n+}\n+\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Subchain/Subchain.cpp",
"new_path": "src/Module/Subchain/Subchain.cpp",
"diff": "@@ -9,7 +9,7 @@ using namespace aff3ct::module;\nSubchain\n::Subchain(const tools::Chain &chain)\n-: Module(chain.tasks_sequences[0][0]->get_module().get_n_frames()),\n+: Module(chain.get_tasks_sequence().front()->get_module().get_n_frames()),\nchain(chain.clone())\n{\nconst std::string name = \"Subchain\";\n@@ -26,7 +26,7 @@ Subchain\nauto &p = this->create_task(\"exec\");\n- auto &first = *this->chain->tasks_sequences[0][0];\n+ auto &first = *this->chain->get_tasks_sequence().front();\nfor (auto &s : first.sockets)\n{\nif (first.get_socket_type(*s) == socket_t::SIN)\n@@ -60,7 +60,7 @@ Subchain\nthis->template create_socket_in_out<double >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n}\n}\n- auto &last = *this->chain->tasks_sequences[0][this->chain->tasks_sequences[0].size()-1];\n+ auto &last = *this->chain->get_tasks_sequence().back();\nfor (auto &s : last.sockets)\n{\nif (last.get_socket_type(*s) == socket_t::SOUT)\n@@ -119,7 +119,7 @@ Subchain\n{\nauto &c = static_cast<Subchain&>(m);\n- auto &first = *c.chain->tasks_sequences[0][0];\n+ auto &first = *c.chain->get_tasks_sequence().front();\nsize_t sid = 0;\nfor (auto &s : first.sockets)\n{\n@@ -152,7 +152,7 @@ void Subchain\nModule::deep_copy(m);\nif (m.chain != nullptr) this->chain.reset(m.chain->clone());\n- auto &last = *this->chain->tasks_sequences[0][this->chain->tasks_sequences[0].size()-1];\n+ auto &last = *this->chain->get_tasks_sequence().back();\nauto &p = (*this)[sch::tsk::exec];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -24,6 +24,16 @@ Chain\nstd::vector<const module::Task*> tasks_sequence;\nthis->init_recursive(tasks_sequence, first, first, &last);\n+ if (tasks_sequence.back() != &last)\n+ {\n+ std::stringstream message;\n+ message << \"'tasks_sequence.back()' has to be equal to '&last' (\"\n+ << \"'tasks_sequence.back()'\" << \" = \" << +tasks_sequence.back() << \", \"\n+ << \"'&last'\" << \" = \" << +&last << \", \"\n+ << \"'tasks_sequence.back()->get_name()'\" << \" = \" << tasks_sequence.back()->get_name() << \", \"\n+ << \"'last.get_name()'\" << \" = \" << last.get_name() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nthis->duplicate(tasks_sequence);\n}\n@@ -88,38 +98,6 @@ void Chain\nconst module::Task& current_task,\nconst module::Task *last)\n{\n- if (¤t_task == &first)\n- {\n- for (auto &s : current_task.sockets)\n- if ((current_task.get_socket_type(*s) == module::socket_t::SOUT ||\n- current_task.get_socket_type(*s) == module::socket_t::SIN_SOUT) && s->get_dataptr() == nullptr)\n- {\n- std::stringstream message;\n- message << \"Output sockets of the first task has to be filled.\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n- }\n- else if (¤t_task == last)\n- {\n- for (auto &s : current_task.sockets)\n- if ((current_task.get_socket_type(*s) == module::socket_t::SIN ||\n- current_task.get_socket_type(*s) == module::socket_t::SIN_SOUT) && s->get_dataptr() == nullptr)\n- {\n- std::stringstream message;\n- message << \"Input sockets of the last task has to be filled.\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n- }\n- else\n- {\n- if (!current_task.can_exec())\n- {\n- std::stringstream message;\n- message << \"'this->can_exec()' has to be true.\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n- }\n-\ntasks_sequence.push_back(¤t_task);\nif (¤t_task != last)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simplify chain and subchain implementations.
|
8,490 |
02.12.2019 12:58:50
| -3,600 |
a193239b0e999c1d473cbfe7f6441c27423e5c8f
|
Add the first routers.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Router/CRC/Router_CRC.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Router_CRC.\n+ */\n+#ifndef ROUTER_CRC_HPP_\n+#define ROUTER_CRC_HPP_\n+\n+#include <memory>\n+\n+#include \"Module/CRC/CRC.hpp\"\n+#include \"Module/Router/Router.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename IN = int, typename OUT = int>\n+class Router_CRC : public Router<IN,OUT>\n+{\n+ std::shared_ptr<CRC<IN>> crc;\n+\n+public:\n+ Router_CRC(const CRC<IN> &crc, const size_t n_elmts_out);\n+ virtual ~Router_CRC() = default;\n+ virtual Router_CRC<IN,OUT>* clone() const;\n+\n+protected:\n+ virtual void deep_copy(const Router_CRC<IN,OUT> &m);\n+\n+ virtual size_t _route(const IN *in, const int frame_id);\n+\n+ virtual size_t select_route_inter(const size_t a, const size_t b);\n+};\n+}\n+}\n+\n+#ifndef DOXYGEN_SHOULD_SKIP_THIS\n+#include \"Module/Router/CRC/Router_CRC.hxx\"\n+#endif\n+\n+#endif /* ROUTER_CRC_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Router/CRC/Router_CRC.hxx",
"diff": "+#include <string>\n+#include <algorithm>\n+\n+#include \"Module/Router/CRC/Router_CRC.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+template <typename IN, typename OUT>\n+Router_CRC<IN,OUT>\n+::Router_CRC(const CRC<IN> &crc, const size_t n_elmts_out)\n+: Router<IN,OUT>(crc.get_size() + crc.get_K(), n_elmts_out, 2, crc.get_n_frames()),\n+: crc(crc.clone())\n+{\n+ const std::string name = \"Router_CRC\";\n+ this->set_name(name);\n+}\n+\n+template <typename IN, typename OUT>\n+Router_CRC<IN,OUT>* Router_CRC<IN,OUT>\n+::clone() const\n+{\n+ auto m = new Router_CRC(*this);\n+ m->deep_copy(*this);\n+ return m;\n+}\n+\n+template <typename IN, typename OUT>\n+void Router_CRC<IN,OUT>\n+::deep_copy(const Router_CRC<IN> &m)\n+{\n+ Module::deep_copy(m);\n+ if (m.crc != nullptr) this->crc.reset(dynamic_cast<CRC<IN>*>(m.crc->clone()));\n+}\n+\n+template <typename IN, typename OUT>\n+size_t Router_CRC<IN,OUT>\n+::_route(const IN *in, const int frame_id)\n+{\n+ return this->crc.check(in) ? 1 : 0;\n+}\n+\n+template <typename IN, typename OUT>\n+size_t Router_CRC<IN,OUT>\n+::select_route_inter(const size_t a, const size_t b)\n+{\n+ return std::min(a, b);\n+}\n+\n+}\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Router/Predicate/Router_predicate.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Router_predicate.\n+ */\n+#ifndef ROUTER_PREDICATE_HPP_\n+#define ROUTER_PREDICATE_HPP_\n+\n+#include <memory>\n+\n+#include \"Tools/Algo/Predicate.hpp\"\n+#include \"Module/Router/Router.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename OUT = float>\n+class Router_predicate : public Router<OUT,OUT>\n+{\n+ std::shared_ptr<tools::Predicate> predicate;\n+\n+public:\n+ Router_predicate(const tools::Predicate &predicate, const size_t n_elmts_out, const int n_frames = 1);\n+ virtual ~Router_predicate() = default;\n+ virtual Router_predicate<OUT>* clone() const;\n+\n+ tools::Predicate& get_predicate();\n+\n+protected:\n+ virtual void deep_copy(const Router_predicate<OUT> &m);\n+\n+ virtual size_t _route(const OUT *in, const int frame_id);\n+\n+ virtual size_t select_route_inter(const size_t a, const size_t b);\n+};\n+}\n+}\n+\n+#endif /* ROUTER_CRC_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Router/Router.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Router.\n+ */\n+#ifndef ROUTER_HPP_\n+#define ROUTER_HPP_\n+\n+#include <cstddef>\n+\n+#include \"Module/Task.hpp\"\n+#include \"Module/Socket.hpp\"\n+#include \"Module/Module.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+ namespace rtr\n+ {\n+ enum class tsk : size_t { route, SIZE };\n+\n+ namespace sck\n+ {\n+ enum class route : size_t { in, out, out1, out2, SIZE };\n+ }\n+ }\n+\n+template <typename IN, typename OUT>\n+class Router : public Module\n+{\n+public:\n+ inline Task& operator[](const rtr::tsk t);\n+ inline Socket& operator[](const rtr::sck::route s);\n+\n+protected:\n+ const size_t n_elmts_in;\n+ const size_t n_elmts_out;\n+ const size_t n_outputs;\n+\n+public:\n+ Router(const size_t n_elmts_in, const size_t n_elmts_out, const size_t n_outputs, const int n_frames = 1);\n+ virtual ~Router() = default;\n+\n+ size_t get_n_elmts_in() const;\n+\n+ size_t get_n_elmts_out() const;\n+\n+ size_t get_n_outputs() const;\n+\n+ template <class A = std::allocator<IN>>\n+ size_t route(const std::vector<IN,A>& in, const int frame_id = -1);\n+\n+ virtual size_t route(const IN *in, const int frame_id = -1);\n+\n+protected:\n+ virtual size_t _route(const IN *in, const int frame_id);\n+\n+ virtual size_t select_route_inter(const size_t a, const size_t b);\n+};\n+}\n+}\n+\n+#ifndef DOXYGEN_SHOULD_SKIP_THIS\n+#include \"Module/Router/Router.hxx\"\n+#endif\n+\n+#endif /* ROUTER_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Router/Router.hxx",
"diff": "+#include <string>\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Module/Router/Router.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+template <typename IN, typename OUT>\n+Task& Router<IN,OUT>\n+::operator[](const rtr::tsk t)\n+{\n+ return Module::operator[]((size_t)t);\n+}\n+\n+template <typename IN, typename OUT>\n+Socket& Router<IN,OUT>\n+::operator[](const rtr::sck::route s)\n+{\n+ return Module::operator[]((size_t)rtr::tsk::route)[(size_t)s];\n+}\n+\n+template <typename IN, typename OUT>\n+Router<IN,OUT>\n+::Router(const size_t n_elmts_in, const size_t n_elmts_out, const size_t n_outputs, const int n_frames)\n+: Module(n_frames),\n+ n_elmts_in(n_elmts_in),\n+ n_elmts_out(n_elmts_out),\n+ n_outputs(n_outputs)\n+{\n+ const std::string name = \"Router\";\n+ this->set_name(name);\n+ this->set_short_name(name);\n+\n+ if (n_elmts_in == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'n_elmts_in' has to be greater than 0 ('n_elmts_in' = \" << n_elmts_in << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (n_elmts_out == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'n_elmts_out' has to be greater than 0 ('n_elmts_out' = \" << n_elmts_out << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (n_outputs == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'n_outputs' has to be greater than 0 ('n_outputs' = \" << n_outputs << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto &p = this->create_task(\"route\");\n+ auto ps_in = this->template create_socket_in<IN>(p, \"in\", this->n_elmts_in);\n+ auto ps_out = this->template create_socket_in<OUT>(p, \"out\", this->n_elmts_out);\n+ for (size_t o = 0; o < n_outputs; o++)\n+ this->template create_socket_out<OUT>(p, \"out\" + std::to_string(o), this->n_elmts_out);\n+\n+ this->create_codelet(p, [ps_in, ps_out](Module &m, Task &t) -> int\n+ {\n+ auto sout_dataptr = t.sockets[ps_out]->get_dataptr();\n+ for (size_t sout = 2; sout < t.sockets.size(); sout++)\n+ t.sockets[sout]->bind(sout_dataptr);\n+\n+ return (int)static_cast<Router<IN,OUT>&>(m).route(static_cast<IN*>(t[ps_in].get_dataptr()));\n+ });\n+}\n+\n+template <typename IN, typename OUT>\n+size_t Router<IN,OUT>\n+::get_n_elmts_in() const\n+{\n+ return this->n_elmts_in;\n+}\n+\n+template <typename IN, typename OUT>\n+size_t Router<IN,OUT>\n+::get_n_elmts_out() const\n+{\n+ return this->n_elmts_out;\n+}\n+\n+template <typename IN, typename OUT>\n+size_t Router<IN,OUT>\n+::get_n_outputs() const\n+{\n+ return this->n_outputs;\n+}\n+\n+template <typename IN, typename OUT>\n+template <class A>\n+size_t Router<IN,OUT>\n+::route(const std::vector<IN,A>& in, const int frame_id)\n+{\n+ if (this->n_elmts_in * this->n_frames != (int)in.size())\n+ {\n+ std::stringstream message;\n+ message << \"'in.size()' has to be equal to 'n_elmts_in' * 'n_frames' ('in.size()' = \" << in.size()\n+ << \", 'n_elmts_in' = \" << this->n_elmts_in << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ this->route(in.data(), frame_id);\n+}\n+\n+template <typename IN, typename OUT>\n+size_t Router<IN,OUT>\n+::route(const IN *in, const int frame_id)\n+{\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\n+ auto ret_val = this->_route(in + f_start * this->n_elmts_in, f_start);\n+ for (auto f = f_start+1; f < f_stop; f++)\n+ ret_val = this->select_route_inter(ret_val, this->_route(in + f * this->n_elmts_in, f));\n+ return ret_val;\n+}\n+\n+template <typename IN, typename OUT>\n+size_t Router<IN,OUT>\n+::_route(const IN *in, const int frame_id)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+template <typename IN, typename OUT>\n+size_t Router<IN,OUT>\n+::select_route_inter(const size_t a, const size_t b)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+}\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Algo/Predicate.hpp",
"new_path": "include/Tools/Algo/Predicate.hpp",
"diff": "#define PREDICATE_HPP\n#include \"Tools/Interface/Interface_reset.hpp\"\n+#ifndef _MSC_VER\n+#include \"Tools/Interface/Interface_clone.hpp\"\n+#endif\nnamespace aff3ct\n{\n@@ -16,7 +19,11 @@ namespace tools\n*\n* \\brief A predicate.\n*/\n+#ifdef _MSC_VER\nclass Predicate : public Interface_reset\n+#else\n+class Predicate : public Interface_reset, Interface_clone\n+#endif\n{\npublic:\n/*!\n@@ -24,6 +31,8 @@ public:\n*/\nvirtual ~Predicate() = default;\n+ virtual Predicate* clone() const = 0;\n+\n/*!\n* \\brief Evaluates the predicate.\n*\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Algo/Predicate_ite.hpp",
"new_path": "include/Tools/Algo/Predicate_ite.hpp",
"diff": "@@ -25,6 +25,8 @@ private:\npublic:\ninline explicit Predicate_ite(const int n_ite);\n+ virtual Predicate_ite* clone() const;\n+\nvirtual ~Predicate_ite() = default;\ninline bool operator()();\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Algo/Predicate_ite.hxx",
"new_path": "include/Tools/Algo/Predicate_ite.hxx",
"diff": "@@ -18,6 +18,12 @@ Predicate_ite::Predicate_ite(const int n_ite)\n}\n}\n+Predicate_ite* Predicate_ite\n+::clone() const\n+{\n+ return new Predicate_ite(*this);\n+}\n+\nbool Predicate_ite::operator()()\n{\nconst bool predicate = cur_ite >= n_ite;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Router/Predicate/Router_predicate.cpp",
"diff": "+#include <string>\n+\n+#include \"Module/Router/Predicate/Router_predicate.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+template <typename OUT>\n+Router_predicate<OUT>\n+::Router_predicate(const tools::Predicate &predicate, const size_t n_elmts_out, const int n_frames)\n+: Router<OUT,OUT>(1, n_elmts_out, 2, n_frames),\n+ predicate(predicate.clone())\n+{\n+ const std::string name = \"Router_predicate\";\n+ this->set_name(name);\n+}\n+\n+template <typename OUT>\n+Router_predicate<OUT>* Router_predicate<OUT>\n+::clone() const\n+{\n+ auto m = new Router_predicate(*this);\n+ m->deep_copy(*this);\n+ return m;\n+}\n+\n+template <typename OUT>\n+void Router_predicate<OUT>\n+::deep_copy(const Router_predicate<OUT> &m)\n+{\n+ Module::deep_copy(m);\n+ if (m.predicate != nullptr) this->predicate.reset(dynamic_cast<tools::Predicate*>(m.predicate->clone()));\n+}\n+\n+template <typename OUT>\n+tools::Predicate& Router_predicate<OUT>\n+::get_predicate()\n+{\n+ return *this->predicate;\n+}\n+\n+template <typename OUT>\n+size_t Router_predicate<OUT>\n+::_route(const OUT *in, const int frame_id)\n+{\n+ return (*this->predicate)() ? 1 : 0;\n+}\n+\n+template <typename OUT>\n+size_t Router_predicate<OUT>\n+::select_route_inter(const size_t a, const size_t b)\n+{\n+ return a;\n+}\n+\n+}\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+template class aff3ct::module::Router_predicate<B_8>;\n+template class aff3ct::module::Router_predicate<B_16>;\n+template class aff3ct::module::Router_predicate<B_32>;\n+template class aff3ct::module::Router_predicate<B_64>;\n+template class aff3ct::module::Router_predicate<R_32>;\n+template class aff3ct::module::Router_predicate<R_64>;\n+// ==================================================================================== explicit template instantiation\n+\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the first routers.
|
8,490 |
02.12.2019 18:45:04
| -3,600 |
4f012a8a7dface92ba61e335966b2c5d5612c7aa
|
Add routers in the BFER_ite simulation.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/CRC/Router_CRC.hpp",
"new_path": "include/Module/Router/CRC/Router_CRC.hpp",
"diff": "@@ -20,7 +20,7 @@ class Router_CRC : public Router<IN,OUT>\nstd::shared_ptr<CRC<IN>> crc;\npublic:\n- Router_CRC(const CRC<IN> &crc, const size_t n_elmts_out);\n+ Router_CRC(const CRC<IN> &crc, const size_t n_elmts_in, const size_t n_elmts_out);\nvirtual ~Router_CRC() = default;\nvirtual Router_CRC<IN,OUT>* clone() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/CRC/Router_CRC.hxx",
"new_path": "include/Module/Router/CRC/Router_CRC.hxx",
"diff": "@@ -10,12 +10,21 @@ namespace module\ntemplate <typename IN, typename OUT>\nRouter_CRC<IN,OUT>\n-::Router_CRC(const CRC<IN> &crc, const size_t n_elmts_out)\n-: Router<IN,OUT>(crc.get_size() + crc.get_K(), n_elmts_out, 2, crc.get_n_frames()),\n-: crc(crc.clone())\n+::Router_CRC(const CRC<IN> &crc, const size_t n_elmts_in, const size_t n_elmts_out)\n+: Router<IN,OUT>(n_elmts_in, n_elmts_out, 2, crc.get_n_frames()),\n+ crc(crc.clone())\n{\nconst std::string name = \"Router_CRC\";\nthis->set_name(name);\n+\n+ if (this->crc->get_size() + this->crc->get_K() != (int)n_elmts_in)\n+ {\n+ std::stringstream message;\n+ message << \"'n_elmts_in' has to be equal to 'crc->get_size()' + 'crc->get_K()' ('n_elmts_in' = \" << n_elmts_in\n+ << \", 'crc->get_size()' = \" << this->crc->get_size() << \", 'crc->get_K()' = \"\n+ << this->crc->get_K() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n}\ntemplate <typename IN, typename OUT>\n@@ -29,7 +38,7 @@ Router_CRC<IN,OUT>* Router_CRC<IN,OUT>\ntemplate <typename IN, typename OUT>\nvoid Router_CRC<IN,OUT>\n-::deep_copy(const Router_CRC<IN> &m)\n+::deep_copy(const Router_CRC<IN,OUT> &m)\n{\nModule::deep_copy(m);\nif (m.crc != nullptr) this->crc.reset(dynamic_cast<CRC<IN>*>(m.crc->clone()));\n@@ -39,7 +48,7 @@ template <typename IN, typename OUT>\nsize_t Router_CRC<IN,OUT>\n::_route(const IN *in, const int frame_id)\n{\n- return this->crc.check(in) ? 1 : 0;\n+ return this->crc->check(in) ? 1 : 0;\n}\ntemplate <typename IN, typename OUT>\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/Predicate/Router_predicate.hpp",
"new_path": "include/Module/Router/Predicate/Router_predicate.hpp",
"diff": "#include <memory>\n+#include \"Tools/Interface/Interface_reset.hpp\"\n#include \"Tools/Algo/Predicate.hpp\"\n#include \"Module/Router/Router.hpp\"\n@@ -18,6 +19,7 @@ template <typename OUT = float>\nclass Router_predicate : public Router<OUT,OUT>\n{\nstd::shared_ptr<tools::Predicate> predicate;\n+ std::vector<OUT> hack;\npublic:\nRouter_predicate(const tools::Predicate &predicate, const size_t n_elmts_out, const int n_frames = 1);\n@@ -26,6 +28,8 @@ public:\ntools::Predicate& get_predicate();\n+ virtual void reset();\n+\nprotected:\nvirtual void deep_copy(const Router_predicate<OUT> &m);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/Router.hpp",
"new_path": "include/Module/Router/Router.hpp",
"diff": "#define ROUTER_HPP_\n#include <cstddef>\n+#include <memory>\n+#include \"Tools/Interface/Interface_reset.hpp\"\n#include \"Module/Task.hpp\"\n#include \"Module/Socket.hpp\"\n#include \"Module/Module.hpp\"\n@@ -21,12 +23,12 @@ namespace module\nnamespace sck\n{\n- enum class route : size_t { in, out, out1, out2, SIZE };\n+ enum class route : size_t { in, in_out1, in_out2, SIZE };\n}\n}\ntemplate <typename IN, typename OUT>\n-class Router : public Module\n+class Router : public Module, public tools::Interface_reset\n{\npublic:\ninline Task& operator[](const rtr::tsk t);\n@@ -52,6 +54,8 @@ public:\nvirtual size_t route(const IN *in, const int frame_id = -1);\n+ virtual void reset();\n+\nprotected:\nvirtual size_t _route(const IN *in, const int frame_id);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/Router.hxx",
"new_path": "include/Module/Router/Router.hxx",
"diff": "@@ -58,16 +58,11 @@ Router<IN,OUT>\nauto &p = this->create_task(\"route\");\nauto ps_in = this->template create_socket_in<IN>(p, \"in\", this->n_elmts_in);\n- auto ps_out = this->template create_socket_in<OUT>(p, \"out\", this->n_elmts_out);\nfor (size_t o = 0; o < n_outputs; o++)\n- this->template create_socket_out<OUT>(p, \"out\" + std::to_string(o), this->n_elmts_out);\n+ this->template create_socket_in_out<OUT>(p, \"in_out\" + std::to_string(o), this->n_elmts_out);\n- this->create_codelet(p, [ps_in, ps_out](Module &m, Task &t) -> int\n+ this->create_codelet(p, [ps_in](Module &m, Task &t) -> int\n{\n- auto sout_dataptr = t.sockets[ps_out]->get_dataptr();\n- for (size_t sout = 2; sout < t.sockets.size(); sout++)\n- t.sockets[sout]->bind(sout_dataptr);\n-\nreturn (int)static_cast<Router<IN,OUT>&>(m).route(static_cast<IN*>(t[ps_in].get_dataptr()));\n});\n}\n@@ -136,5 +131,11 @@ size_t Router<IN,OUT>\nthrow tools::unimplemented_error(__FILE__, __LINE__, __func__);\n}\n+template <typename IN, typename OUT>\n+void Router<IN,OUT>\n+::reset()\n+{\n+}\n+\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Algo/Predicate.hpp",
"new_path": "include/Tools/Algo/Predicate.hpp",
"diff": "@@ -22,7 +22,7 @@ namespace tools\n#ifdef _MSC_VER\nclass Predicate : public Interface_reset\n#else\n-class Predicate : public Interface_reset, Interface_clone\n+class Predicate : public Interface_reset, public Interface_clone\n#endif\n{\npublic:\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Algo/Predicate_ite.hxx",
"new_path": "include/Tools/Algo/Predicate_ite.hxx",
"diff": "@@ -10,7 +10,7 @@ namespace tools\nPredicate_ite::Predicate_ite(const int n_ite)\n: n_ite(n_ite), cur_ite(0)\n{\n- if (n_ite <= 0)\n+ if (n_ite < 0)\n{\nstd::stringstream message;\nmessage << \"'n_ite' has to be equal or greater than 0 ('n_ite' = \" << n_ite << \").\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Router/Predicate/Router_predicate.cpp",
"new_path": "src/Module/Router/Predicate/Router_predicate.cpp",
"diff": "@@ -11,10 +11,12 @@ template <typename OUT>\nRouter_predicate<OUT>\n::Router_predicate(const tools::Predicate &predicate, const size_t n_elmts_out, const int n_frames)\n: Router<OUT,OUT>(1, n_elmts_out, 2, n_frames),\n- predicate(predicate.clone())\n+ predicate(predicate.clone()),\n+ hack(1)\n{\nconst std::string name = \"Router_predicate\";\nthis->set_name(name);\n+ (*this)[rtr::tsk::route].sockets[0]->bind(hack.data());\n}\ntemplate <typename OUT>\n@@ -23,6 +25,7 @@ Router_predicate<OUT>* Router_predicate<OUT>\n{\nauto m = new Router_predicate(*this);\nm->deep_copy(*this);\n+ (*m)[rtr::tsk::route].sockets[0]->bind(m->hack.data());\nreturn m;\n}\n@@ -41,6 +44,13 @@ tools::Predicate& Router_predicate<OUT>\nreturn *this->predicate;\n}\n+template <typename OUT>\n+void Router_predicate<OUT>\n+::reset()\n+{\n+ this->get_predicate().reset();\n+}\n+\ntemplate <typename OUT>\nsize_t Router_predicate<OUT>\n::_route(const OUT *in, const int frame_id)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/BFER_ite.cpp",
"new_path": "src/Simulation/BFER/Iterative/BFER_ite.cpp",
"diff": "#include <iomanip>\n#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Algo/Predicate_ite.hpp\"\n#include \"Factory/Module/Coset/Coset.hpp\"\n#include \"Simulation/BFER/Iterative/BFER_ite.hpp\"\n@@ -25,6 +26,9 @@ BFER_ite<B,R,Q>\ninterleaver_core(params_BFER_ite.n_threads),\ninterleaver_bit (params_BFER_ite.n_threads),\ninterleaver_llr (params_BFER_ite.n_threads),\n+ router_ite (params_BFER_ite.n_threads),\n+ router_crc (params_BFER_ite.n_threads),\n+ router_ite_crc (params_BFER_ite.n_threads),\nrd_engine_seed(params_BFER_ite.n_threads)\n{\n@@ -44,6 +48,9 @@ BFER_ite<B,R,Q>\nthis->add_module(\"coset_bit\" , params_BFER_ite.n_threads);\nthis->add_module(\"interleaver_bit\", params_BFER_ite.n_threads);\nthis->add_module(\"interleaver_llr\", params_BFER_ite.n_threads);\n+ this->add_module(\"router_ite\" , params_BFER_ite.n_threads);\n+ this->add_module(\"router_crc\" , params_BFER_ite.n_threads);\n+ this->add_module(\"router_ite_crc\" , params_BFER_ite.n_threads);\n}\ntemplate <typename B, typename R, typename Q>\n@@ -62,6 +69,9 @@ void BFER_ite<B,R,Q>\ncoset_real [tid] = build_coset_real (tid);\ncoset_bit [tid] = build_coset_bit (tid);\ninterleaver_core[tid] = build_interleaver (tid);\n+ router_ite [tid] = build_router_ite (tid);\n+ router_crc [tid] = build_router_crc (tid);\n+ router_ite_crc [tid] = build_router_ite_crc(tid);\n}\nif (params_BFER_ite.alloc_clone)\n@@ -75,6 +85,9 @@ void BFER_ite<B,R,Q>\ncoset_real [tid].reset(coset_real [0]->clone());\ncoset_bit [tid].reset(coset_bit [0]->clone());\ninterleaver_core[tid].reset(interleaver_core[0]->clone());\n+ router_ite [tid].reset(router_ite [0]->clone());\n+ router_crc [tid].reset(router_crc [0]->clone());\n+ router_ite_crc [tid].reset(router_ite_crc [0]->clone());\n}\ninterleaver_bit[tid].reset(factory::Interleaver::build<B>(*interleaver_core[tid]));\n@@ -120,6 +133,9 @@ void BFER_ite<B,R,Q>\nthis->set_module(\"coset_bit\" , tid, *coset_bit [tid]);\nthis->set_module(\"interleaver_bit\", tid, *interleaver_bit[tid]);\nthis->set_module(\"interleaver_llr\", tid, *interleaver_llr[tid]);\n+ this->set_module(\"router_ite\" , tid, *router_ite [tid]);\n+ this->set_module(\"router_crc\" , tid, *router_crc [tid]);\n+ this->set_module(\"router_ite_crc\" , tid, *router_ite_crc [tid]);\nif (static_cast<module::Decoder*>(&codec[tid]->get_decoder_siso()) !=\nstatic_cast<module::Decoder*>(&codec[tid]->get_decoder_siho()))\n@@ -131,6 +147,8 @@ void BFER_ite<B,R,Q>\ncodec[tid]->get_decoder_siso().set_auto_reset(false);\nthis->monitor_er[tid]->record_callback_check([this, tid](){ this->codec[tid]->get_decoder_siso().reset(); });\n+ this->monitor_er[tid]->record_callback_check([this, tid](){ this->router_ite[tid]->reset(); });\n+ this->monitor_er[tid]->record_callback_check([this, tid](){ this->router_ite_crc[tid]->reset(); });\nif (interleaver_core[tid]->is_uniform())\nthis->monitor_er[tid]->record_callback_check(std::bind(&tools::Interleaver_core<>::refresh,\n@@ -271,6 +289,46 @@ std::unique_ptr<module::Coset<B,B>> BFER_ite<B,R,Q>\nreturn std::unique_ptr<module::Coset<B,B>>(cst_params.build_bit<B,B>());\n}\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Router_predicate<Q>> BFER_ite<B,R,Q>\n+::build_router_ite(const int tid)\n+{\n+ tools::Predicate_ite p(params_BFER_ite.n_ite);\n+ auto router_ite = std::unique_ptr<module::Router_predicate<Q>>(new module::Router_predicate<Q>(\n+ p,\n+ params_BFER_ite.cdc->N_cw,\n+ params_BFER_ite.src->n_frames));\n+ router_ite->set_custom_name(\"Router_ite\");\n+ return router_ite;\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Router_CRC<B,Q>> BFER_ite<B,R,Q>\n+::build_router_crc(const int tid)\n+{\n+ auto crc = params_BFER_ite.crc->build<B>();\n+ size_t K = (size_t)crc->get_size() + (size_t)crc->get_K();\n+ auto router_crc = std::unique_ptr<module::Router_CRC<B,Q>>(new module::Router_CRC<B,Q>(\n+ *crc,\n+ K,\n+ params_BFER_ite.cdc->N_cw));\n+ router_crc->set_custom_name(\"Router_CRC\");\n+ return router_crc;\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Router_predicate<Q>> BFER_ite<B,R,Q>\n+::build_router_ite_crc(const int tid)\n+{\n+ tools::Predicate_ite p(params_BFER_ite.crc_start);\n+ auto router_ite = std::unique_ptr<module::Router_predicate<Q>>(new module::Router_predicate<Q>(\n+ p,\n+ params_BFER_ite.cdc->N_cw,\n+ params_BFER_ite.src->n_frames));\n+ router_ite->set_custom_name(\"Router_iCRC\");\n+ return router_ite;\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef AFF3CT_MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/BFER_ite.hpp",
"new_path": "src/Simulation/BFER/Iterative/BFER_ite.hpp",
"diff": "#include \"Module/Quantizer/Quantizer.hpp\"\n#include \"Module/Coset/Coset.hpp\"\n#include \"Module/Interleaver/Interleaver.hpp\"\n+#include \"Module/Router/Predicate/Router_predicate.hpp\"\n+#include \"Module/Router/CRC/Router_CRC.hpp\"\n#include \"Factory/Simulation/BFER/BFER_ite.hpp\"\n#include \"Simulation/BFER/BFER.hpp\"\n@@ -39,6 +41,9 @@ protected:\nstd::vector<std::unique_ptr<tools ::Interleaver_core< >>> interleaver_core;\nstd::vector<std::unique_ptr<module::Interleaver <B >>> interleaver_bit;\nstd::vector<std::unique_ptr<module::Interleaver <Q >>> interleaver_llr;\n+ std::vector<std::shared_ptr<module::Router_predicate<Q >>> router_ite;\n+ std::vector<std::shared_ptr<module::Router_CRC <B,Q >>> router_crc;\n+ std::vector<std::shared_ptr<module::Router_predicate<Q >>> router_ite_crc;\n// a vector of random generator to generate the seeds\nstd::vector<std::mt19937> rd_engine_seed;\n@@ -59,6 +64,9 @@ protected:\nvirtual std::unique_ptr<module::Coset <B,Q >> build_coset_real (const int tid = 0);\nvirtual std::unique_ptr<module::Coset <B,B >> build_coset_bit (const int tid = 0);\nvirtual std::unique_ptr<tools ::Interleaver_core< >> build_interleaver (const int tid = 0);\n+ virtual std::unique_ptr<module::Router_predicate<Q >> build_router_ite (const int tid = 0);\n+ virtual std::unique_ptr<module::Router_CRC <B,Q >> build_router_crc (const int tid = 0);\n+ virtual std::unique_ptr<module::Router_predicate<Q >> build_router_ite_crc(const int tid = 0);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"new_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"diff": "@@ -92,6 +92,9 @@ void BFER_ite_threads<B,R,Q>\nauto &csr = *this->coset_real [tid];\nauto &csb = *this->coset_bit [tid];\nauto &mnt = *this->monitor_er [tid];\n+ auto &rti = *this->router_ite [tid];\n+ auto &rtc = *this->router_crc [tid];\n+ auto &rtic = *this->router_ite_crc [tid];\nauto &enc = cdc.get_encoder();\nauto &dcs = cdc.get_decoder_siso();\n@@ -189,6 +192,8 @@ void BFER_ite_threads<B,R,Q>\n}\nitl[itl::sck::deinterleave::itl ](mdm[mdm::sck::demodulate ::Y_N2]);\n+ rti[rtr::sck::route ::in_out1](itl[itl::sck::deinterleave::nat ]);\n+ rti[rtr::sck::route ::in_out2](itl[itl::sck::deinterleave::nat ]);\n// ----------------------------------------------------------------------------------------------------------------\n// ---------------------------------------------------------------------------------------- turbo demodulation loop\n@@ -197,22 +202,38 @@ void BFER_ite_threads<B,R,Q>\n// --------------------------------------------------------------------------------------------------- CRC checking\nif (this->params_BFER_ite.crc->type != \"NO\")\n{\n- ext[ext::sck::get_sys_bit::Y_N](itl[itl::sck::deinterleave::nat]);\n- crc[crc::sck::check ::V_K](ext[ext::sck::get_sys_bit ::V_K]);\n+ rtic[rtr::sck::route ::in_out1](rti [rtr::sck::route ::in_out1]);\n+ rtic[rtr::sck::route ::in_out2](rti [rtr::sck::route ::in_out1]);\n+ ext[ext::sck::get_sys_bit::Y_N ](rtic[rtr::sck::route ::in_out1]);\n+ rtc[rtr::sck::route ::in ](ext [ext::sck::get_sys_bit::V_K ]);\n+ rtc[rtr::sck::route ::in_out1](rtic[rtr::sck::route ::in_out2]);\n+ rtc[rtr::sck::route ::in_out2](rtic[rtr::sck::route ::in_out2]);\n}\n// ------------------------------------------------------------------------------------------------------- decoding\nif (this->params_BFER_ite.coset)\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n{\n// output socket binding (trick to avoid runtime re-binding)\n- dcs[dec::sck::decode_siso::Y_N2](itl[itl::sck::deinterleave::nat ]);\n- csr[cst::sck::apply ::in ](itl[itl::sck::deinterleave::nat ]);\n+ dcs[dec::sck::decode_siso::Y_N2](rtic[rtr::sck::route::in_out1]);\n+ csr[cst::sck::apply ::in ](rtic[rtr::sck::route::in_out1]);\n+ }\n+ else\n+ {\n+ // output socket binding (trick to avoid runtime re-binding)\n+ dcs[dec::sck::decode_siso::Y_N2](rti[rtr::sck::route::in_out1]);\n+ csr[cst::sck::apply ::in ](rti[rtr::sck::route::in_out1]);\n+ }\ndcs[dec::sck::decode_siso::Y_N1](csr[cst::sck::apply ::out ]);\ncsr[cst::sck::apply ::in ](dcs[dec::sck::decode_siso::Y_N2]);\n}\nelse\n{\n- dcs[dec::sck::decode_siso::Y_N1](itl[itl::sck::deinterleave::nat]);\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ dcs[dec::sck::decode_siso::Y_N1](rtic[rtr::sck::route::in_out1]);\n+ else\n+ dcs[dec::sck::decode_siso::Y_N1](rti [rtr::sck::route::in_out1]);\n}\n// --------------------------------------------------------------------------------------------------- interleaving\n@@ -256,7 +277,10 @@ void BFER_ite_threads<B,R,Q>\nif (this->params_BFER_ite.coset)\n{\n- csr[cst::sck::apply::in](itl[itl::sck::deinterleave::nat]);\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ csr[cst::sck::apply::in](rtc[rtr::sck::route::in_out2]);\n+ else\n+ csr[cst::sck::apply::in](rti[rtr::sck::route::in_out2]);\nif (this->params_BFER_ite.coded_monitoring)\n{\n@@ -277,15 +301,18 @@ void BFER_ite_threads<B,R,Q>\n{\nif (this->params_BFER_ite.coded_monitoring)\n{\n- dch[dec::sck::decode_siho_cw::Y_N](itl[itl::sck::deinterleave::nat]);\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ dch[dec::sck::decode_siho_cw::Y_N](rtc[rtr::sck::route::in_out2]);\n+ else\n+ dch[dec::sck::decode_siho_cw::Y_N](rti[rtr::sck::route::in_out2]);\n}\nelse\n{\n+ dch[dec::sck::decode_siho::Y_N ](rti[rtr::sck::route ::in_out2]);\n+ crc[crc::sck::extract ::V_K1](dch[dec::sck::decode_siho ::V_K ]);\n+\nif (this->params_BFER_ite.crc->type == \"NO\")\ncrc[crc::sck::extract::V_K2](dch[dec::sck::decode_siho::V_K]);\n-\n- dch[dec::sck::decode_siho::Y_N ](itl[itl::sck::deinterleave::nat]);\n- crc[crc::sck::extract ::V_K1](dch[dec::sck::decode_siho ::V_K]);\n}\n}\n@@ -317,6 +344,9 @@ void BFER_ite_threads<B,R,Q>\nauto &coset_real = *this->coset_real [tid];\nauto &coset_bit = *this->coset_bit [tid];\nauto &monitor = *this->monitor_er [tid];\n+ auto &router_ite = *this->router_ite [tid];\n+ auto &router_crc = *this->router_crc [tid];\n+ auto &router_ite_crc = *this->router_ite_crc [tid];\nauto &encoder = codec.get_encoder();\nauto &decoder_siso = codec.get_decoder_siso();\n@@ -379,13 +409,13 @@ void BFER_ite_threads<B,R,Q>\n// ------------------------------------------------------------------------------------------------------------\n// ------------------------------------------------------------------------------------ turbo demodulation loop\n// ------------------------------------------------------------------------------------------------------------\n- for (auto ite = 1; ite <= this->params_BFER_ite.n_ite; ite++)\n+ while (!router_ite[rtr::tsk::route].exec())\n{\n// ------------------------------------------------------------------------------------------- CRC checking\n- if (this->params_BFER_ite.crc->type != \"NO\" && ite >= this->params_BFER_ite.crc_start)\n+ if (this->params_BFER_ite.crc->type != \"NO\" && router_ite_crc[rtr::tsk::route].exec())\n{\nextractor[ext::tsk::get_sys_bit].exec();\n- if (crc[crc::tsk::check].exec())\n+ if (router_crc[rtr::tsk::route].exec())\nbreak;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add routers in the BFER_ite simulation.
|
8,490 |
03.12.2019 11:34:03
| -3,600 |
c78913816277d4af122f6fea3718836e57df5bb5
|
Simplify the routers.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/CRC/Router_CRC.hpp",
"new_path": "include/Module/Router/CRC/Router_CRC.hpp",
"diff": "#define ROUTER_CRC_HPP_\n#include <memory>\n+#include <cstdint>\n#include \"Module/CRC/CRC.hpp\"\n#include \"Module/Router/Router.hpp\"\n@@ -15,7 +16,7 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename I = int, typename O = int>\n-class Router_CRC : public Router<I,O>\n+class Router_CRC : public Router\n{\nstd::shared_ptr<CRC<I>> crc;\n@@ -27,7 +28,7 @@ public:\nprotected:\nvirtual void deep_copy(const Router_CRC<I,O> &m);\n- virtual size_t _route(const I *in, const int frame_id);\n+ virtual size_t _route(const int8_t *in, const int frame_id);\nvirtual size_t select_route_inter(const size_t a, const size_t b);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/CRC/Router_CRC.hxx",
"new_path": "include/Module/Router/CRC/Router_CRC.hxx",
"diff": "@@ -11,7 +11,7 @@ namespace module\ntemplate <typename I, typename O>\nRouter_CRC<I,O>\n::Router_CRC(const CRC<I> &crc, const size_t n_elmts_in, const size_t n_elmts_out)\n-: Router<I,O>(n_elmts_in, n_elmts_out, 2, crc.get_n_frames()),\n+: Router(n_elmts_in * sizeof(I), n_elmts_out * sizeof(O), 2, crc.get_n_frames()),\ncrc(crc.clone())\n{\nconst std::string name = \"Router_CRC\";\n@@ -46,9 +46,9 @@ void Router_CRC<I,O>\ntemplate <typename I, typename O>\nsize_t Router_CRC<I,O>\n-::_route(const I *in, const int frame_id)\n+::_route(const int8_t *in, const int frame_id)\n{\n- return this->crc->check(in) ? 1 : 0;\n+ return this->crc->check((const I*)in) ? 1 : 0;\n}\ntemplate <typename I, typename O>\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/Predicate/Router_predicate.hpp",
"new_path": "include/Module/Router/Predicate/Router_predicate.hpp",
"diff": "#define ROUTER_PREDICATE_HPP_\n#include <memory>\n+#include <cstdint>\n#include \"Tools/Interface/Interface_reset.hpp\"\n#include \"Tools/Algo/Predicate.hpp\"\n@@ -16,10 +17,10 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename O = float>\n-class Router_predicate : public Router<O,O>\n+class Router_predicate : public Router\n{\nstd::shared_ptr<tools::Predicate> predicate;\n- std::vector<O> hack;\n+ std::vector<int8_t> hack;\npublic:\nRouter_predicate(const tools::Predicate &predicate, const size_t n_elmts_out, const int n_frames = 1);\n@@ -33,7 +34,7 @@ public:\nprotected:\nvirtual void deep_copy(const Router_predicate<O> &m);\n- virtual size_t _route(const O *in, const int frame_id);\n+ virtual size_t _route(const int8_t *in, const int frame_id);\nvirtual size_t select_route_inter(const size_t a, const size_t b);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/Router.hpp",
"new_path": "include/Module/Router/Router.hpp",
"diff": "#define ROUTER_HPP_\n#include <cstddef>\n+#include <cstdint>\n#include <memory>\n#include \"Tools/Interface/Interface_reset.hpp\"\n@@ -27,7 +28,6 @@ namespace module\n}\n}\n-template <typename I, typename O>\nclass Router : public Module, public tools::Interface_reset\n{\npublic:\n@@ -35,29 +35,29 @@ public:\ninline Socket& operator[](const rtr::sck::route s);\nprotected:\n- const size_t n_elmts_in;\n- const size_t n_elmts_out;\n+ const size_t n_bytes_in;\n+ const size_t n_bytes_out;\nconst size_t n_outputs;\npublic:\n- Router(const size_t n_elmts_in, const size_t n_elmts_out, const size_t n_outputs, const int n_frames = 1);\n+ inline Router(const size_t n_bytes_in, const size_t n_bytes_out, const size_t n_outputs, const int n_frames = 1);\nvirtual ~Router() = default;\n- size_t get_n_elmts_in() const;\n+ inline size_t get_n_bytes_in() const;\n- size_t get_n_elmts_out() const;\n+ inline size_t get_n_bytes_out() const;\n- size_t get_n_outputs() const;\n+ inline size_t get_n_outputs() const;\n- template <class A = std::allocator<I>>\n- size_t route(const std::vector<I,A>& in, const int frame_id = -1);\n+ template <class A = std::allocator<int8_t>>\n+ size_t route(const std::vector<int8_t,A>& in, const int frame_id = -1);\n- virtual size_t route(const I *in, const int frame_id = -1);\n+ virtual size_t route(const int8_t *in, const int frame_id = -1);\nvirtual void reset();\nprotected:\n- virtual size_t _route(const I *in, const int frame_id);\n+ virtual size_t _route(const int8_t *in, const int frame_id);\nvirtual size_t select_route_inter(const size_t a, const size_t b);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/Router.hxx",
"new_path": "include/Module/Router/Router.hxx",
"diff": "@@ -9,43 +9,40 @@ namespace aff3ct\nnamespace module\n{\n-template <typename I, typename O>\n-Task& Router<I,O>\n+Task& Router\n::operator[](const rtr::tsk t)\n{\nreturn Module::operator[]((size_t)t);\n}\n-template <typename I, typename O>\n-Socket& Router<I,O>\n+Socket& Router\n::operator[](const rtr::sck::route s)\n{\nreturn Module::operator[]((size_t)rtr::tsk::route)[(size_t)s];\n}\n-template <typename I, typename O>\n-Router<I,O>\n-::Router(const size_t n_elmts_in, const size_t n_elmts_out, const size_t n_outputs, const int n_frames)\n+Router\n+::Router(const size_t n_bytes_in, const size_t n_bytes_out, const size_t n_outputs, const int n_frames)\n: Module(n_frames),\n- n_elmts_in(n_elmts_in),\n- n_elmts_out(n_elmts_out),\n+ n_bytes_in(n_bytes_in),\n+ n_bytes_out(n_bytes_out),\nn_outputs(n_outputs)\n{\nconst std::string name = \"Router\";\nthis->set_name(name);\nthis->set_short_name(name);\n- if (n_elmts_in == 0)\n+ if (n_bytes_in == 0)\n{\nstd::stringstream message;\n- message << \"'n_elmts_in' has to be greater than 0 ('n_elmts_in' = \" << n_elmts_in << \").\";\n+ message << \"'n_bytes_in' has to be greater than 0 ('n_bytes_in' = \" << n_bytes_in << \").\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (n_elmts_out == 0)\n+ if (n_bytes_out == 0)\n{\nstd::stringstream message;\n- message << \"'n_elmts_out' has to be greater than 0 ('n_elmts_out' = \" << n_elmts_out << \").\";\n+ message << \"'n_bytes_out' has to be greater than 0 ('n_bytes_out' = \" << n_bytes_out << \").\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n@@ -57,85 +54,48 @@ Router<I,O>\n}\nauto &p = this->create_task(\"route\");\n- auto ps_in = this->template create_socket_in<I>(p, \"in\", this->n_elmts_in);\n+ auto ps_in = this->template create_socket_in<int8_t>(p, \"in\", this->n_bytes_in);\nfor (size_t o = 0; o < n_outputs; o++)\n- this->template create_socket_in_out<O>(p, \"in_out\" + std::to_string(o), this->n_elmts_out);\n+ this->template create_socket_in_out<int8_t>(p, \"in_out\" + std::to_string(o), this->n_bytes_out);\nthis->create_codelet(p, [ps_in](Module &m, Task &t) -> int\n{\n- return (int)static_cast<Router<I,O>&>(m).route(static_cast<I*>(t[ps_in].get_dataptr()));\n+ return (int)static_cast<Router&>(m).route(static_cast<int8_t*>(t[ps_in].get_dataptr()));\n});\n}\n-template <typename I, typename O>\n-size_t Router<I,O>\n-::get_n_elmts_in() const\n+size_t Router\n+::get_n_bytes_in() const\n{\n- return this->n_elmts_in;\n+ return this->n_bytes_in;\n}\n-template <typename I, typename O>\n-size_t Router<I,O>\n-::get_n_elmts_out() const\n+size_t Router\n+::get_n_bytes_out() const\n{\n- return this->n_elmts_out;\n+ return this->n_bytes_out;\n}\n-template <typename I, typename O>\n-size_t Router<I,O>\n+size_t Router\n::get_n_outputs() const\n{\nreturn this->n_outputs;\n}\n-template <typename I, typename O>\ntemplate <class A>\n-size_t Router<I,O>\n-::route(const std::vector<I,A>& in, const int frame_id)\n+size_t Router\n+::route(const std::vector<int8_t,A>& in, const int frame_id)\n{\n- if (this->n_elmts_in * this->n_frames != (int)in.size())\n+ if (this->n_bytes_in * this->n_frames != (int)in.size())\n{\nstd::stringstream message;\n- message << \"'in.size()' has to be equal to 'n_elmts_in' * 'n_frames' ('in.size()' = \" << in.size()\n- << \", 'n_elmts_in' = \" << this->n_elmts_in << \", 'n_frames' = \" << this->n_frames << \").\";\n+ message << \"'in.size()' has to be equal to 'n_bytes_in' * 'n_frames' ('in.size()' = \" << in.size()\n+ << \", 'n_bytes_in' = \" << this->n_bytes_in << \", 'n_frames' = \" << this->n_frames << \").\";\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\nthis->route(in.data(), frame_id);\n}\n-template <typename I, typename O>\n-size_t Router<I,O>\n-::route(const I *in, const int frame_id)\n-{\n- const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n- const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n-\n- auto ret_val = this->_route(in + f_start * this->n_elmts_in, f_start);\n- for (auto f = f_start+1; f < f_stop; f++)\n- ret_val = this->select_route_inter(ret_val, this->_route(in + f * this->n_elmts_in, f));\n- return ret_val;\n-}\n-\n-template <typename I, typename O>\n-size_t Router<I,O>\n-::_route(const I *in, const int frame_id)\n-{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n-}\n-\n-template <typename I, typename O>\n-size_t Router<I,O>\n-::select_route_inter(const size_t a, const size_t b)\n-{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n-}\n-\n-template <typename I, typename O>\n-void Router<I,O>\n-::reset()\n-{\n-}\n-\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Router/Predicate/Router_predicate.cpp",
"new_path": "src/Module/Router/Predicate/Router_predicate.cpp",
"diff": "@@ -10,7 +10,7 @@ namespace module\ntemplate <typename O>\nRouter_predicate<O>\n::Router_predicate(const tools::Predicate &predicate, const size_t n_elmts_out, const int n_frames)\n-: Router<O,O>(1, n_elmts_out, 2, n_frames),\n+: Router(8, n_elmts_out * sizeof(O), 2, n_frames),\npredicate(predicate.clone()),\nhack(1)\n{\n@@ -53,7 +53,7 @@ void Router_predicate<O>\ntemplate <typename O>\nsize_t Router_predicate<O>\n-::_route(const O *in, const int frame_id)\n+::_route(const int8_t *in, const int frame_id)\n{\nreturn (*this->predicate)() ? 1 : 0;\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Router/Router.cpp",
"diff": "+#include \"Module/Router/Router.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+size_t Router\n+::route(const int8_t *in, const int frame_id)\n+{\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\n+ auto ret_val = this->_route(in + f_start * this->n_bytes_in, f_start);\n+ for (auto f = f_start+1; f < f_stop; f++)\n+ ret_val = this->select_route_inter(ret_val, this->_route(in + f * this->n_bytes_in, f));\n+ return ret_val;\n+}\n+\n+size_t Router\n+::_route(const int8_t *in, const int frame_id)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+size_t Router\n+::select_route_inter(const size_t a, const size_t b)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+void Router\n+::reset()\n+{\n+}\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simplify the routers.
|
8,490 |
05.12.2019 18:58:57
| -3,600 |
9bdbb729ece1a67f71a5345039e001a4276c06b0
|
Fix SystemC compilation errors.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.cpp",
"new_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.cpp",
"diff": "@@ -23,8 +23,6 @@ SC_BFER_ite<B,R,Q>\nif (params_BFER_ite.coded_monitoring)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"SystemC simulation does not support the coded \"\n\"monitoring.\");\n-\n- this->add_module(\"coset_real_i\", params_BFER_ite.n_threads);\n}\ntemplate <typename B, typename R, typename Q>\n@@ -33,10 +31,8 @@ void SC_BFER_ite<B,R,Q>\n{\nBFER_ite<B,R,Q>::__build_communication_chain(tid);\n- this->set_module(\"coset_real_i\", tid, *coset_real_i);\n-\n- this->interleaver_bit[tid]->set_custom_name(this->interleaver_llr[tid]->get_name() + \"_bit\");\n- this->interleaver_llr[tid]->set_custom_name(this->interleaver_llr[tid]->get_name() + \"_llr\");\n+ this->interleaver_bit [tid]->set_custom_name(this->interleaver_llr1[tid]->get_name() + \"_bit\");\n+ this->interleaver_llr1[tid]->set_custom_name(this->interleaver_llr1[tid]->get_name() + \"_llr\");\nthis->monitor_er[tid]->record_callback_check([&]() -> void\n{\n@@ -55,33 +51,33 @@ void SC_BFER_ite<B,R,Q>\n// create the sc_module inside the objects of the communication chain\nthis->source [tid] ->sc.create_module(+src::tsk::generate );\nthis->crc [tid] ->sc.create_module(+crc::tsk::build );\n- this->codec [tid]->get_encoder() .sc.create_module(+enc::tsk::encode );\n+ this->codec1 [tid]->get_encoder() .sc.create_module(+enc::tsk::encode );\nthis->interleaver_bit[tid] ->sc.create_module(+itl::tsk::interleave);\n- this->modem [tid] ->sc.create_module(+mdm::tsk::modulate );\n- this->modem [tid] ->sc.create_module(+mdm::tsk::filter );\n+ this->modem1 [tid] ->sc.create_module(+mdm::tsk::modulate );\n+ this->modem1 [tid] ->sc.create_module(+mdm::tsk::filter );\nif (this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos)\n{\nthis->channel[tid]->sc.create_module(+chn::tsk::add_noise_wg );\n- this->modem [tid]->sc.create_module(+mdm::tsk::demodulate_wg );\n- this->modem [tid]->sc.create_module(+mdm::tsk::tdemodulate_wg);\n+ this->modem1 [tid]->sc.create_module(+mdm::tsk::demodulate_wg );\n+ this->modem1 [tid]->sc.create_module(+mdm::tsk::tdemodulate_wg);\n}\nelse\n{\nthis->channel[tid]->sc.create_module(+chn::tsk::add_noise );\n- this->modem [tid]->sc.create_module(+mdm::tsk::demodulate );\n- this->modem [tid]->sc.create_module(+mdm::tsk::tdemodulate);\n+ this->modem1 [tid]->sc.create_module(+mdm::tsk::demodulate );\n+ this->modem1 [tid]->sc.create_module(+mdm::tsk::tdemodulate);\n}\n- this->interleaver_llr[tid] ->sc.create_module(+itl::tsk::interleave );\n+ this->interleaver_llr1[tid] ->sc.create_module(+itl::tsk::interleave );\nthis->quantizer [tid] ->sc.create_module(+qnt::tsk::process );\n- this->interleaver_llr[tid] ->sc.create_module(+itl::tsk::deinterleave);\n- this->codec [tid]->get_decoder_siho() .sc.create_module(+dec::tsk::decode_siho );\n- this->codec [tid]->get_decoder_siso() .sc.create_module(+dec::tsk::decode_siso );\n+ this->interleaver_llr1[tid] ->sc.create_module(+itl::tsk::deinterleave);\n+ this->codec1 [tid]->get_decoder_siho() .sc.create_module(+dec::tsk::decode_siho );\n+ this->codec1 [tid]->get_decoder_siso() .sc.create_module(+dec::tsk::decode_siso );\nthis->monitor_er [tid] ->sc.create_module(+mnt::tsk::check_errors);\nif (this->params_BFER_ite.coset)\n{\n- this->coset_real[tid]->sc.create_module(+cst::tsk::apply);\n- this->coset_real_i ->sc.create_module(+cst::tsk::apply);\n+ this->coset_real1[tid]->sc.create_module(+cst::tsk::apply);\n+ this->coset_real2[tid]->sc.create_module(+cst::tsk::apply);\nthis->coset_bit [tid]->sc.create_module(+cst::tsk::apply);\n}\nthis->crc[tid]->sc.create_module(+crc::tsk::extract);\n@@ -109,7 +105,6 @@ void SC_BFER_ite<B,R,Q>\nthis->duplicator[6].reset( new tools::SC_Duplicator(\"Duplicator6\"));\n}\n-\nthis->router .reset( new tools::SC_Router (p, \"Router\" ));\nthis->funnel .reset( new tools::SC_Funnel ( \"Funnel\" ));\nthis->predicate.reset( new tools::SC_Predicate(p, \"Predicate\"));\n@@ -140,16 +135,16 @@ void SC_BFER_ite<B,R,Q>\nauto &src = *this->source [0];\nauto &crc = *this->crc [0];\n- auto &enc = this->codec [0]->get_encoder();\n+ auto &enc = this->codec1 [0]->get_encoder();\nauto &itb = *this->interleaver_bit [0];\n- auto &itl = *this->interleaver_llr[0];\n- auto &mdm = *this->modem [0];\n+ auto &itl = *this->interleaver_llr1[0];\n+ auto &mdm = *this->modem1 [0];\nauto &chn = *this->channel [0];\nauto &qnt = *this->quantizer [0];\n- auto &csr = *this->coset_real [0];\n- auto &csi = *this->coset_real_i;\n- auto &dch = this->codec [0]->get_decoder_siho();\n- auto &dcs = this->codec [0]->get_decoder_siso();\n+ auto &csr = *this->coset_real1 [0];\n+ auto &csi = *this->coset_real2 [0];\n+ auto &dch = this->codec1 [0]->get_decoder_siho();\n+ auto &dcs = this->codec1 [0]->get_decoder_siso();\nauto &csb = *this->coset_bit [0];\nauto &mnt = *this->monitor_er [0];\n@@ -261,20 +256,6 @@ void SC_BFER_ite<B,R,Q>\n}\n}\n-template <typename B, typename R, typename Q>\n-std::unique_ptr<module::Coset<B,Q>> SC_BFER_ite<B,R,Q>\n-::build_coset_real(const int tid)\n-{\n- factory::Coset cst_params;\n- cst_params.size = this->params_BFER_ite.cdc->N_cw;\n- cst_params.n_frames = this->params_BFER_ite.src->n_frames;\n-\n- this->coset_real_i.reset(cst_params.template build_real<B,Q>());\n- this->coset_real_i->set_custom_name(\"Coset_real_i\");\n-\n- return std::unique_ptr<module::Coset<B,Q>>(cst_params.template build_real<B,Q>());\n-}\n-\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef AFF3CT_MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.hpp",
"new_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.hpp",
"diff": "@@ -24,7 +24,6 @@ class SC_BFER_ite : public BFER_ite<B,R,Q>\n{\nprotected:\nstd::vector<std::unique_ptr<tools::SC_Duplicator>> duplicator;\n- std::unique_ptr<module::Coset<B,Q>> coset_real_i;\nstd::unique_ptr<tools::SC_Router> router;\nstd::unique_ptr<tools::SC_Funnel> funnel;\nstd::unique_ptr<tools::SC_Predicate> predicate;\n@@ -39,8 +38,6 @@ protected:\nvirtual void __build_communication_chain(const int tid = 0);\nvirtual void _launch();\n- virtual std::unique_ptr<module::Coset<B,Q>> build_coset_real(const int tid = 0);\n-\nprivate:\nvoid bind_sockets ();\nvoid bind_sockets_debug();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix SystemC compilation errors.
|
8,496 |
22.11.2019 11:28:51
| 25,200 |
c79bdd7a39dec81739ff0882a46e2494934d6d5c
|
Fixing bug where the last two rows of Table B.9 from ETSI EN 302 307 V1.2.1 (2009-08) were not included
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Code/LDPC/Standard/DVBS2/DVBS2_constants_64800.hpp",
"new_path": "include/Tools/Code/LDPC/Standard/DVBS2/DVBS2_constants_64800.hpp",
"diff": "@@ -520,7 +520,9 @@ struct dvbs2_values_64800_10800 : dvbs2_values // r=5/6 & K = 54000\n3, 24, 6881, 3883,\n3, 25, 3895, 2171,\n3, 26, 4062, 6424,\n- 3, 27, 3755, 9536\n+ 3, 27, 3755, 9536,\n+ 3, 28, 4683, 2131,\n+ 3, 29, 7347, 8027\n});\nthis->N = 64800;\n@@ -528,7 +530,7 @@ struct dvbs2_values_64800_10800 : dvbs2_values // r=5/6 & K = 54000\nthis->NmK = 10800;\nthis->M = 360;\nthis->Q = 30;\n- this->N_LINES = 148;\n+ this->N_LINES = 150;\n}\n};\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fixing bug where the last two rows of Table B.9 from ETSI EN 302 307 V1.2.1 (2009-08) were not included
|
8,490 |
06.12.2019 14:13:02
| -3,600 |
85ba604d47a9e3b4cd69d10568cdf8678069f1b0
|
Avoid recompute info bits positions each time in the polar extractor.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Extractor/Polar/Extractor_polar.hpp",
"new_path": "include/Module/Extractor/Polar/Extractor_polar.hpp",
"diff": "#include <cstdint>\n#include <vector>\n+#include \"Tools/Interface/Interface_notify_frozenbits_update.hpp\"\n#include \"Module/Extractor/Extractor.hpp\"\nnamespace aff3ct\n@@ -15,7 +16,7 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename B = int, typename Q = float>\n-class Extractor_polar : public Extractor<B,Q>\n+class Extractor_polar : public Extractor<B,Q>, public tools::Interface_notify_frozenbits_update\n{\nprotected:\nconst std::vector<bool>& frozen_bits; // known bits (alias frozen bits) are set to true\n@@ -27,6 +28,8 @@ public:\nvirtual Extractor_polar<B,Q>* clone() const;\n+ virtual void notify_noise_update();\n+\nprotected:\nconst std::vector<uint32_t>& get_info_bits_pos();\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Codec/Polar/Codec_polar.hpp",
"new_path": "include/Tools/Codec/Polar/Codec_polar.hpp",
"diff": "@@ -35,6 +35,7 @@ protected:\nmodule::Puncturer_polar_shortlast<B,Q>* puncturer_shortlast;\nInterface_notify_frozenbits_update* fb_decoder;\nInterface_notify_frozenbits_update* fb_encoder;\n+ Interface_notify_frozenbits_update* fb_extractor;\npublic:\nCodec_polar(const factory::Frozenbits_generator &fb_par,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Extractor/Polar/Extractor_polar.cpp",
"new_path": "src/Module/Extractor/Polar/Extractor_polar.cpp",
"diff": "@@ -13,6 +13,8 @@ Extractor_polar<B,Q>\n{\nconst std::string name = \"Extractor_polar\";\nthis->set_name(name);\n+\n+ this->notify_noise_update();\n}\ntemplate <typename B, typename Q>\n@@ -25,14 +27,19 @@ Extractor_polar<B,Q>* Extractor_polar<B,Q>\n}\ntemplate <typename B, typename Q>\n-const std::vector<uint32_t>& Extractor_polar<B,Q>\n-::get_info_bits_pos()\n+void Extractor_polar<B,Q>\n+::notify_noise_update()\n{\nint j = 0;\nfor (auto i = 0; i < this->N; i++)\nif (!this->frozen_bits[i])\nthis->info_bits_pos[j++] = i;\n+}\n+template <typename B, typename Q>\n+const std::vector<uint32_t>& Extractor_polar<B,Q>\n+::get_info_bits_pos()\n+{\nreturn this->info_bits_pos;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Codec/Polar/Codec_polar.cpp",
"new_path": "src/Tools/Codec/Polar/Codec_polar.cpp",
"diff": "@@ -27,7 +27,8 @@ Codec_polar<B,Q>\ngenerated_decoder((dec_params.implem.find(\"_SNR\") != std::string::npos)),\npuncturer_shortlast(nullptr),\nfb_decoder(nullptr),\n- fb_encoder(nullptr)\n+ fb_encoder(nullptr),\n+ fb_extractor(nullptr)\n{\n// ----------------------------------------------------------------------------------------------------- exceptions\nif (enc_params.K != dec_params.K)\n@@ -125,6 +126,7 @@ Codec_polar<B,Q>\nenc_params.N_cw,\n*frozen_bits,\nenc_params.n_frames));\n+ fb_extractor = dynamic_cast<Interface_notify_frozenbits_update*>(&this->get_extractor());\n// ------------------------------------------------------------------------------------------------- frozen bit gen\nif (!generated_decoder)\n@@ -185,6 +187,8 @@ void Codec_polar<B,Q>\nthis->fb_encoder = dynamic_cast<Interface_notify_frozenbits_update*>(&this->get_encoder());\nif (t.fb_decoder != nullptr)\nthis->fb_decoder = dynamic_cast<Interface_notify_frozenbits_update*>(&this->get_decoder_siho());\n+ if (t.fb_extractor != nullptr)\n+ this->fb_extractor = dynamic_cast<Interface_notify_frozenbits_update*>(&this->get_extractor());\n}\ntemplate <typename B, typename Q>\n@@ -195,6 +199,8 @@ void Codec_polar<B,Q>\nthis->fb_decoder->notify_noise_update();\nif (this->fb_encoder)\nthis->fb_encoder->notify_noise_update();\n+ if (this->fb_extractor)\n+ this->fb_extractor->notify_noise_update();\n}\ntemplate <typename B, typename Q>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Avoid recompute info bits positions each time in the polar extractor.
|
8,490 |
06.12.2019 14:14:35
| -3,600 |
79bbb039ff0322fdd3f305d9ba3db1c6631cf5bc
|
Improve the sockets binding of the tasks: rm output sockets binding.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"new_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"diff": "@@ -249,6 +249,14 @@ void BFER_ite_threads<B,R,Q>\nif (mdm1.is_demodulator())\n{\n+ if (is_rayleigh)\n+ {\n+ if (this->params_BFER_ite.chn->type != \"NO\")\n+ mdm1[mdm::sck::demodulate_wg::H_N](chn[chn::sck::add_noise_wg::H_N]);\n+ else\n+ mdm1[mdm::sck::demodulate_wg::H_N]((uint8_t*)(chn[chn::sck::add_noise_wg::H_N].get_dataptr()));\n+ }\n+\nif (this->params_BFER_ite.qnt->type != \"NO\")\n{\nif (is_rayleigh)\n@@ -266,35 +274,37 @@ void BFER_ite_threads<B,R,Q>\nelse if (this->params_BFER_ite.chn->type != \"NO\")\n{\nif (is_rayleigh)\n- {\n- mdm1[mdm::sck::demodulate_wg::H_N ](chn[chn::sck::add_noise_wg::H_N]);\nmdm1[mdm::sck::demodulate_wg::Y_N1](chn[chn::sck::add_noise_wg::Y_N]);\n- }\nelse\nmdm1[mdm::sck::demodulate::Y_N1](chn[chn::sck::add_noise::Y_N]);\n}\nelse\n{\nif (is_rayleigh)\n- {\n- mdm1[mdm::sck::demodulate_wg::H_N ]((uint8_t*)(chn[chn::sck::add_noise_wg::H_N].get_dataptr()));\nmdm1[mdm::sck::demodulate_wg::Y_N1](mdm1[mdm::sck::modulate::X_N2]);\n- }\nelse\n- {\nmdm1[mdm::sck::demodulate::Y_N1](mdm1[mdm::sck::modulate::X_N2]);\n}\n}\n- }\nif (mdm1.is_demodulator())\n+ {\n+ if (is_rayleigh)\n+ itl1[itl::sck::deinterleave::itl](mdm1[mdm::sck::demodulate_wg::Y_N2]);\n+ else\nitl1[itl::sck::deinterleave::itl](mdm1[mdm::sck::demodulate::Y_N2]);\n+ }\nelse if (this->params_BFER_ite.qnt->type != \"NO\")\nitl1[itl::sck::deinterleave::itl](qnt[qnt::sck::process::Y_N2]);\nelse if (mdm1.is_filter())\nitl1[itl::sck::deinterleave::itl](mdm1[mdm::sck::filter::Y_N2]);\nelse if (this->params_BFER_ite.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\nitl1[itl::sck::deinterleave::itl](chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ itl1[itl::sck::deinterleave::itl](chn[chn::sck::add_noise::Y_N]);\n+ }\nelse\nitl1[itl::sck::deinterleave::itl](mdm1[mdm::sck::modulate::X_N2]);\n@@ -339,8 +349,13 @@ void BFER_ite_threads<B,R,Q>\n// --------------------------------------------------------------------------------------------------- demodulation\nif (mdm2.is_demodulator())\n{\n- if (this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos)\n+ if (is_rayleigh)\n{\n+ if (this->params_BFER_ite.chn->type != \"NO\")\n+ mdm2[mdm::sck::tdemodulate_wg::H_N](chn[chn::sck::add_noise_wg::H_N]);\n+ else\n+ mdm2[mdm::sck::tdemodulate_wg::H_N]((uint8_t*)(chn[chn::sck::add_noise_wg::H_N].get_dataptr()));\n+\nif (this->params_BFER_ite.qnt->type != \"NO\")\nmdm2[mdm::sck::tdemodulate_wg::Y_N1](qnt[qnt::sck::process::Y_N2]);\nelse if (mdm1.is_filter())\n@@ -350,11 +365,6 @@ void BFER_ite_threads<B,R,Q>\nelse\nmdm2[mdm::sck::tdemodulate_wg::Y_N1](mdm1[mdm::sck::modulate::X_N2]);\n- if (this->params_BFER_ite.chn->type != \"NO\")\n- mdm2[mdm::sck::tdemodulate_wg::H_N](chn[chn::sck::add_noise_wg::H_N]);\n- else\n- mdm2[mdm::sck::tdemodulate_wg::H_N]((uint8_t*)(chn[chn::sck::add_noise_wg::H_N].get_dataptr()));\n-\nmdm2[mdm::sck::tdemodulate_wg::Y_N2](itl2[itl::sck::interleave::itl]);\n}\nelse\n@@ -364,7 +374,7 @@ void BFER_ite_threads<B,R,Q>\nelse if (mdm1.is_filter())\nmdm2[mdm::sck::tdemodulate::Y_N1](mdm1[mdm::sck::filter::Y_N2]);\nelse if (this->params_BFER_ite.chn->type != \"NO\")\n- mdm2[mdm::sck::tdemodulate::Y_N1](chn[chn::sck::add_noise_wg::Y_N]);\n+ mdm2[mdm::sck::tdemodulate::Y_N1](chn[chn::sck::add_noise::Y_N]);\nelse\nmdm2[mdm::sck::tdemodulate::Y_N1](mdm1[mdm::sck::modulate::X_N2]);\n@@ -373,25 +383,34 @@ void BFER_ite_threads<B,R,Q>\n}\n// ------------------------------------------------------------------------------------------------- deinterleaving\n- if (!mdm2.is_demodulator())\n+ if (mdm2.is_demodulator())\n{\n- if (this->params_BFER_ite.qnt->type != \"NO\")\n+ if (is_rayleigh)\n+ itl2[itl::sck::deinterleave::itl](mdm2[mdm::sck::tdemodulate_wg::Y_N3]);\n+ else\n+ itl2[itl::sck::deinterleave::itl](mdm2[mdm::sck::tdemodulate::Y_N3]);\n+ }\n+ else if (this->params_BFER_ite.qnt->type != \"NO\")\nitl2[itl::sck::deinterleave::itl](qnt[qnt::sck::process::Y_N2]);\nelse if (mdm1.is_filter())\nitl2[itl::sck::deinterleave::itl](mdm1[mdm::sck::filter::Y_N2]);\nelse if (this->params_BFER_ite.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\nitl2[itl::sck::deinterleave::itl](chn[chn::sck::add_noise_wg::Y_N]);\nelse\n- itl2[itl::sck::deinterleave::itl](mdm1[mdm::sck::modulate::X_N2]);\n+ itl2[itl::sck::deinterleave::itl](chn[chn::sck::add_noise::Y_N]);\n}\n- else if (this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos)\n- itl2[itl::sck::deinterleave::itl](mdm2[mdm::sck::tdemodulate_wg::Y_N3]);\nelse\n- itl2[itl::sck::deinterleave::itl](mdm2[mdm::sck::tdemodulate::Y_N3]);\n+ itl2[itl::sck::deinterleave::itl](mdm1[mdm::sck::modulate::X_N2]);\nif (this->params_BFER_ite.crc->type != \"NO\")\n{\n+ if (this->params_BFER_ite.coset)\n+ ext2[ext::sck::get_sys_bit::Y_N](dcs[dec::sck::decode_siso::Y_N2]);\n+ else\next2[ext::sck::get_sys_bit::Y_N](itl2[itl::sck::deinterleave::nat]);\n+\nlcrc[lop::sck::stop::in2 ](ext2[ext::sck::get_sys_bit ::V_K]);\nlcrc[lop::sck::stop::in_out2](itl2[itl::sck::deinterleave::nat]);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"new_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"diff": "@@ -16,14 +16,11 @@ BFER_std_threads<B,R,Q>\n::BFER_std_threads(const factory::BFER_std ¶ms_BFER_std)\n: BFER_std<B,R,Q>(params_BFER_std)\n{\n- if (this->params_BFER_std.err_track_revert)\n- {\n- if (this->params_BFER_std.n_threads != 1)\n+ if (this->params_BFER_std.err_track_revert && this->params_BFER_std.n_threads != 1)\nstd::clog << rang::tag::warning << \"Multi-threading detected with error tracking revert feature! \"\n\"Each thread will play the same frames. Please run with one thread.\"\n<< std::endl;\n}\n-}\ntemplate <typename B, typename R, typename Q>\nvoid BFER_std_threads<B,R,Q>\n@@ -117,92 +114,212 @@ void BFER_std_threads<B,R,Q>\n}\nelse\n{\n- if (this->params_BFER_std.crc->type == \"NO\")\n- crc[crc::sck::build::U_K2](src[src::sck::generate::U_K]);\n- if (this->params_BFER_std.cdc->enc->type == \"NO\")\n- enc[enc::sck::encode::X_N](crc[crc::sck::build::U_K2]);\n- if (this->params_BFER_std.cdc->pct == nullptr || this->params_BFER_std.cdc->pct->type == \"NO\")\n- pct[pct::sck::puncture::X_N2](enc[enc::sck::encode::X_N]);\n-\n+ if (this->params_BFER_std.crc->type != \"NO\")\ncrc[crc::sck::build::U_K1](src[src::sck::generate::U_K ]);\n+\n+ if (this->params_BFER_std.cdc->enc->type != \"NO\")\n+ {\n+ if (this->params_BFER_std.crc->type != \"NO\")\nenc[enc::sck::encode::U_K](crc[crc::sck::build::U_K2]);\n+ else\n+ enc[enc::sck::encode::U_K](src[src::sck::generate::U_K]);\n+ }\n+\n+ if (this->params_BFER_std.cdc->pct != nullptr && this->params_BFER_std.cdc->pct->type != \"NO\")\n+ {\n+ if (this->params_BFER_std.cdc->enc->type != \"NO\")\npct[pct::sck::puncture::X_N1](enc[enc::sck::encode::X_N]);\n+ else if (this->params_BFER_std.crc->type != \"NO\")\n+ pct[pct::sck::puncture::X_N1](crc[crc::sck::build::U_K2]);\n+ else\n+ pct[pct::sck::puncture::X_N1](src[src::sck::generate::U_K]);\n+ }\n+\n+ if (this->params_BFER_std.cdc->pct != nullptr && this->params_BFER_std.cdc->pct->type != \"NO\")\nmdm[mdm::sck::modulate::X_N1](pct[pct::sck::puncture::X_N2]);\n+ else if (this->params_BFER_std.cdc->enc->type != \"NO\")\n+ mdm[mdm::sck::modulate::X_N1](enc[enc::sck::encode::X_N]);\n+ else if (this->params_BFER_std.crc->type != \"NO\")\n+ mdm[mdm::sck::modulate::X_N1](crc[crc::sck::build::U_K2]);\n+ else\n+ mdm[mdm::sck::modulate::X_N1](src[src::sck::generate::U_K]);\n}\n- if (this->params_BFER_std.chn->type.find(\"RAYLEIGH\") != std::string::npos)\n+ const auto is_rayleigh = this->params_BFER_std.chn->type.find(\"RAYLEIGH\") != std::string::npos;\n+ const auto is_optical = this->params_BFER_std.chn->type == \"OPTICAL\" && this->params_BFER_std.mdm->rop_est_bits > 0;\n+ if (is_rayleigh)\n{\nif (this->params_BFER_std.chn->type == \"NO\")\n{\n- chn[chn::sck::add_noise_wg::Y_N](mdm[mdm::sck::modulate::X_N2]);\nauto chn_data = (uint8_t*)(chn[chn::sck::add_noise_wg::H_N].get_dataptr());\nauto chn_bytes = chn[chn::sck::add_noise_wg::H_N].get_databytes();\nstd::fill(chn_data, chn_data + chn_bytes, 0);\n}\n- if (!mdm.is_filter())\n- mdm[mdm::sck::filter::Y_N2](chn[chn::sck::add_noise_wg::Y_N]);\n- if (!mdm.is_demodulator())\n- mdm[mdm::sck::demodulate_wg::Y_N2](mdm[mdm::sck::filter::Y_N2]);\n- if (this->params_BFER_std.qnt->type == \"NO\")\n- qnt[qnt::sck::process::Y_N2](mdm[mdm::sck::demodulate_wg::Y_N2]);\n+ if (this->params_BFER_std.chn->type != \"NO\")\n+ {\nchn[chn::sck::add_noise_wg::X_N](mdm[mdm::sck::modulate::X_N2]);\n- mdm[mdm::sck::demodulate_wg::H_N ](chn[chn::sck::add_noise_wg ::H_N ]);\n+ }\n+\n+ if (mdm.is_filter())\n+ {\n+ if (this->params_BFER_std.chn->type != \"NO\")\nmdm[mdm::sck::filter::Y_N1](chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ mdm[mdm::sck::filter::Y_N1](mdm[mdm::sck::modulate::X_N2]);\n+ }\n+\n+ if (mdm.is_demodulator())\n+ {\n+ if (this->params_BFER_std.chn->type != \"NO\")\n+ mdm[mdm::sck::demodulate_wg::H_N](chn[chn::sck::add_noise_wg::H_N]);\n+ else\n+ mdm[mdm::sck::demodulate_wg::H_N]((uint8_t*)(chn[chn::sck::add_noise_wg::H_N].get_dataptr()));\n+\n+ if (mdm.is_filter())\nmdm[mdm::sck::demodulate_wg::Y_N1](mdm[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_std.chn->type != \"NO\")\n+ mdm[mdm::sck::demodulate_wg::Y_N1](chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ mdm[mdm::sck::demodulate_wg::Y_N1](mdm[mdm::sck::modulate::X_N2]);\n+ }\n+\n+ if (this->params_BFER_std.qnt->type != \"NO\")\n+ {\n+ if (mdm.is_demodulator())\nqnt[qnt::sck::process::Y_N1](mdm[mdm::sck::demodulate_wg::Y_N2]);\n+ else if (mdm.is_filter())\n+ qnt[qnt::sck::process::Y_N1](mdm[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_std.chn->type != \"NO\")\n+ qnt[qnt::sck::process::Y_N1](chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ qnt[qnt::sck::process::Y_N1](mdm[mdm::sck::modulate::X_N2]);\n}\n- else if (this->params_BFER_std.chn->type == \"OPTICAL\" && this->params_BFER_std.mdm->rop_est_bits > 0)\n+ }\n+ else if (is_optical)\n{\nchn[chn::sck::add_noise ::X_N ](mdm[mdm::sck::modulate ::X_N2]);\nmdm[mdm::sck::demodulate_wg::H_N ](mdm[mdm::sck::modulate ::X_N2]);\nmdm[mdm::sck::demodulate_wg::Y_N1](chn[chn::sck::add_noise ::Y_N ]);\nqnt[qnt::sck::process ::Y_N1](mdm[mdm::sck::demodulate_wg::Y_N2]);\n-\n- if (this->params_BFER_std.qnt->type == \"NO\")\n- qnt[qnt::sck::process::Y_N2](qnt[qnt::sck::process::Y_N1]);\n}\nelse\n{\n- if (this->params_BFER_std.chn->type == \"NO\")\n- chn[chn::sck::add_noise::Y_N](mdm[mdm::sck::modulate::X_N2]);\n- if (!mdm.is_filter())\n- mdm[mdm::sck::filter::Y_N2](chn[chn::sck::add_noise::Y_N]);\n- if (!mdm.is_demodulator())\n- mdm[mdm::sck::demodulate::Y_N2](mdm[mdm::sck::filter::Y_N2]);\n- if (this->params_BFER_std.qnt->type == \"NO\")\n- qnt[qnt::sck::process::Y_N2](mdm[mdm::sck::demodulate::Y_N2]);\n-\n+ if (this->params_BFER_std.chn->type != \"NO\")\nchn[chn::sck::add_noise::X_N](mdm[mdm::sck::modulate::X_N2]);\n+\n+ if (mdm.is_filter())\n+ {\n+ if (this->params_BFER_std.chn->type != \"NO\")\nmdm[mdm::sck::filter::Y_N1](chn[chn::sck::add_noise::Y_N]);\n+ else\n+ mdm[mdm::sck::filter::Y_N1](mdm[mdm::sck::modulate::X_N2]);\n+ }\n+\n+ if (mdm.is_demodulator())\n+ {\n+ if (mdm.is_filter())\nmdm[mdm::sck::demodulate::Y_N1](mdm[mdm::sck::filter::Y_N2]);\n- qnt[qnt::sck::process ::Y_N1](mdm[mdm::sck::demodulate::Y_N2]);\n+ else if (this->params_BFER_std.chn->type != \"NO\")\n+ mdm[mdm::sck::demodulate::Y_N1](chn[chn::sck::add_noise::Y_N]);\n+ else\n+ mdm[mdm::sck::demodulate::Y_N1](mdm[mdm::sck::modulate::X_N2]);\n}\n- if (this->params_BFER_std.cdc->pct == nullptr || this->params_BFER_std.cdc->pct->type == \"NO\")\n- pct[pct::sck::depuncture::Y_N2](qnt[qnt::sck::process::Y_N2]);\n+ if (this->params_BFER_std.qnt->type != \"NO\")\n+ {\n+ if (mdm.is_demodulator())\n+ qnt[qnt::sck::process::Y_N1](mdm[mdm::sck::demodulate::Y_N2]);\n+ else if (mdm.is_filter())\n+ qnt[qnt::sck::process::Y_N1](mdm[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_std.chn->type != \"NO\")\n+ qnt[qnt::sck::process::Y_N1](chn[chn::sck::add_noise::Y_N]);\n+ else\n+ qnt[qnt::sck::process::Y_N1](mdm[mdm::sck::modulate::X_N2]);\n+ }\n+ }\n+ if (this->params_BFER_std.cdc->pct != nullptr && this->params_BFER_std.cdc->pct->type != \"NO\")\n+ {\n+ if (this->params_BFER_std.qnt->type != \"NO\")\npct[pct::sck::depuncture::Y_N1](qnt[qnt::sck::process::Y_N2]);\n+ else if (mdm.is_demodulator())\n+ {\n+ if (is_rayleigh || is_optical)\n+ pct[pct::sck::depuncture::Y_N1](mdm[mdm::sck::demodulate_wg::Y_N2]);\n+ else\n+ pct[pct::sck::depuncture::Y_N1](mdm[mdm::sck::demodulate::Y_N2]);\n+ }\n+ else if (mdm.is_filter())\n+ pct[pct::sck::depuncture::Y_N1](mdm[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_std.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ pct[pct::sck::depuncture::Y_N1](chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ pct[pct::sck::depuncture::Y_N1](chn[chn::sck::add_noise::Y_N]);\n+ }\n+ else\n+ pct[pct::sck::depuncture::Y_N1](mdm[mdm::sck::modulate::X_N2]);\n+ }\nif (this->params_BFER_std.coset)\n{\n+ if (this->params_BFER_std.cdc->enc->type != \"NO\")\ncsr[cst::sck::apply::ref](enc[enc::sck::encode::X_N]);\n+ else if (this->params_BFER_std.crc->type != \"NO\")\n+ csr[cst::sck::apply::ref](crc[crc::sck::build::U_K2]);\n+ else\n+ csr[cst::sck::apply::ref](src[src::sck::generate::U_K]);\n+\n+ if (this->params_BFER_std.cdc->pct != nullptr && this->params_BFER_std.cdc->pct->type != \"NO\")\ncsr[cst::sck::apply::in](pct[pct::sck::depuncture::Y_N2]);\n+ else if (this->params_BFER_std.qnt->type != \"NO\")\n+ csr[cst::sck::apply::in](qnt[qnt::sck::process::Y_N2]);\n+ else if (mdm.is_demodulator())\n+ {\n+ if (is_rayleigh || is_optical)\n+ csr[cst::sck::apply::in](mdm[mdm::sck::demodulate_wg::Y_N2]);\n+ else\n+ csr[cst::sck::apply::in](mdm[mdm::sck::demodulate::Y_N2]);\n+ }\n+ else if (mdm.is_filter())\n+ csr[cst::sck::apply::in](mdm[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_std.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ csr[cst::sck::apply::in](chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ csr[cst::sck::apply::in](chn[chn::sck::add_noise::Y_N]);\n+ }\n+ else\n+ csr[cst::sck::apply::in](mdm[mdm::sck::modulate::X_N2]);\nif (this->params_BFER_std.coded_monitoring)\n{\ndec[dec::sck::decode_siho_cw::Y_N](csr[cst::sck::apply::out]);\n+\n+ if (this->params_BFER_std.cdc->enc->type != \"NO\")\ncsb[cst::sck::apply::ref](enc[enc::sck::encode::X_N]);\n+ else if (this->params_BFER_std.crc->type != \"NO\")\n+ csb[cst::sck::apply::ref](crc[crc::sck::build::U_K2]);\n+ else\n+ csb[cst::sck::apply::ref](src[src::sck::generate::U_K]);\n+\ncsb[cst::sck::apply::in](dec[dec::sck::decode_siho_cw::V_N]);\n}\nelse\n{\n- if (this->params_BFER_std.crc->type == \"NO\")\n- crc[crc::sck::extract::V_K2](csb[cst::sck::apply::out]);\n-\ndec[dec::sck::decode_siho::Y_N](csr[cst::sck::apply::out]);\n+\n+ if (this->params_BFER_std.crc->type != \"NO\")\ncsb[cst::sck::apply::ref](crc[crc::sck::build::U_K2]);\n+ else\n+ csb[cst::sck::apply::ref](src[src::sck::generate::U_K]);\n+\ncsb[cst::sck::apply::in](dec[dec::sck::decode_siho::V_K]);\n+\n+ if (this->params_BFER_std.crc->type != \"NO\")\ncrc[crc::sck::extract::V_K1](csb[cst::sck::apply::out]);\n}\n}\n@@ -210,48 +327,110 @@ void BFER_std_threads<B,R,Q>\n{\nif (this->params_BFER_std.coded_monitoring)\n{\n+ if (this->params_BFER_std.cdc->pct != nullptr && this->params_BFER_std.cdc->pct->type != \"NO\")\ndec[dec::sck::decode_siho_cw::Y_N](pct[pct::sck::depuncture::Y_N2]);\n+ else if (this->params_BFER_std.qnt->type != \"NO\")\n+ dec[dec::sck::decode_siho_cw::Y_N](qnt[qnt::sck::process::Y_N2]);\n+ else if (mdm.is_demodulator())\n+ {\n+ if (is_rayleigh || is_optical)\n+ dec[dec::sck::decode_siho_cw::Y_N](mdm[mdm::sck::demodulate_wg::Y_N2]);\n+ else\n+ dec[dec::sck::decode_siho_cw::Y_N](mdm[mdm::sck::demodulate::Y_N2]);\n+ }\n+ else if (mdm.is_filter())\n+ dec[dec::sck::decode_siho_cw::Y_N](mdm[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_std.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ dec[dec::sck::decode_siho_cw::Y_N](chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ dec[dec::sck::decode_siho_cw::Y_N](chn[chn::sck::add_noise::Y_N]);\n+ }\n+ else\n+ dec[dec::sck::decode_siho_cw::Y_N](mdm[mdm::sck::modulate::X_N2]);\n}\nelse\n{\n- if (this->params_BFER_std.crc->type == \"NO\")\n- crc[crc::sck::extract::V_K2](dec[dec::sck::decode_siho::V_K]);\n-\n+ if (this->params_BFER_std.cdc->pct != nullptr && this->params_BFER_std.cdc->pct->type != \"NO\")\ndec[dec::sck::decode_siho::Y_N](pct[pct::sck::depuncture::Y_N2]);\n+ else if (this->params_BFER_std.qnt->type != \"NO\")\n+ dec[dec::sck::decode_siho::Y_N](qnt[qnt::sck::process::Y_N2]);\n+ else if (mdm.is_demodulator())\n+ {\n+ if (is_rayleigh || is_optical)\n+ dec[dec::sck::decode_siho::Y_N](mdm[mdm::sck::demodulate_wg::Y_N2]);\n+ else\n+ dec[dec::sck::decode_siho::Y_N](mdm[mdm::sck::demodulate::Y_N2]);\n+ }\n+ else if (mdm.is_filter())\n+ dec[dec::sck::decode_siho::Y_N](mdm[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_std.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ dec[dec::sck::decode_siho::Y_N](chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ dec[dec::sck::decode_siho::Y_N](chn[chn::sck::add_noise::Y_N]);\n+ }\n+ else\n+ dec[dec::sck::decode_siho::Y_N](mdm[mdm::sck::modulate::X_N2]);\n+\n+ if (this->params_BFER_std.crc->type != \"NO\")\ncrc[crc::sck::extract::V_K1](dec[dec::sck::decode_siho::V_K]);\n}\n}\nif (this->params_BFER_std.coded_monitoring)\n{\n+ if (this->params_BFER_std.cdc->enc->type != \"NO\")\nmnt[mnt::sck::check_errors::U](enc[enc::sck::encode::X_N]);\n+ else if (this->params_BFER_std.crc->type != \"NO\")\n+ mnt[mnt::sck::check_errors::U](crc[crc::sck::build::U_K2]);\n+ else\n+ mnt[mnt::sck::check_errors::U](src[src::sck::generate::U_K]);\nif (this->params_BFER_std.coset)\n- {\nmnt[mnt::sck::check_errors::V](csb[cst::sck::apply::out]);\n- }\nelse\n- {\nmnt[mnt::sck::check_errors::V](dec[dec::sck::decode_siho_cw::V_N]);\n}\n- }\nelse\n{\nmnt[mnt::sck::check_errors::U](src[src::sck::generate::U_K]);\n+ if (this->params_BFER_std.crc->type != \"NO\")\nmnt[mnt::sck::check_errors::V](crc[crc::sck::extract::V_K2]);\n+ else if (this->params_BFER_std.coset)\n+ mnt[mnt::sck::check_errors::V](csb[cst::sck::apply::out]);\n+ else\n+ mnt[mnt::sck::check_errors::V](dec[dec::sck::decode_siho::V_K]);\n}\n- if (this->params_BFER_std.mnt_mutinfo) // this->monitor_mi[tid] != nullptr\n+ if (this->params_BFER_std.mnt_mutinfo)\n{\nauto &mnt = *this->monitor_mi[tid];\n- mnt[mnt::sck::get_mutual_info::X](mdm[mdm::sck::modulate ::X_N1]);\n+ if (this->params_BFER_std.cdc->pct != nullptr && this->params_BFER_std.cdc->pct->type != \"NO\")\n+ mnt[mnt::sck::get_mutual_info::X](pct[pct::sck::puncture::X_N2]);\n+ else if (this->params_BFER_std.cdc->enc->type != \"NO\")\n+ mnt[mnt::sck::get_mutual_info::X](enc[enc::sck::encode::X_N]);\n+ else if (this->params_BFER_std.crc->type != \"NO\")\n+ mnt[mnt::sck::get_mutual_info::X](crc[crc::sck::build::U_K2]);\n+ else\n+ mnt[mnt::sck::get_mutual_info::X](src[src::sck::generate::U_K]);\n- if (this->params_BFER_std.chn->type.find(\"RAYLEIGH\") != std::string::npos)\n+ if (mdm.is_demodulator())\n+ {\n+ if (is_rayleigh || is_optical)\nmnt[mnt::sck::get_mutual_info::Y](mdm[mdm::sck::demodulate_wg::Y_N2]);\nelse\nmnt[mnt::sck::get_mutual_info::Y](mdm[mdm::sck::demodulate::Y_N2]);\n-\n+ }\n+ else if (mdm.is_filter())\n+ mnt[mnt::sck::get_mutual_info::Y](mdm[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_std.chn->type != \"NO\")\n+ mnt[mnt::sck::get_mutual_info::Y](chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ mnt[mnt::sck::get_mutual_info::Y](mdm[mdm::sck::modulate::X_N2]);\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve the sockets binding of the tasks: rm output sockets binding.
|
8,490 |
07.12.2019 13:12:06
| -3,600 |
e3384005c1cea1358e7f28c93be887367c87b055
|
Rm the monitor ptr in the destructor in static monitor reduction.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction.hpp",
"new_path": "include/Tools/Monitor/Monitor_reduction.hpp",
"diff": "@@ -81,7 +81,7 @@ public:\nprotected:\nMonitor_reduction_static();\n- virtual ~Monitor_reduction_static() = default;\n+ virtual ~Monitor_reduction_static();\nvirtual bool _is_done() = 0;\n@@ -102,6 +102,8 @@ private:\n*/\nstatic void add_monitor(Monitor_reduction_static*);\n+ static void remove_monitor(Monitor_reduction_static*);\n+\n/*\n* \\brief do a reduction of the number of process that are at the final reduce step\n* \\return true if all process are at the final reduce step (always true without MPI)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Monitor/Monitor_reduction.cpp",
"new_path": "src/Tools/Monitor/Monitor_reduction.cpp",
"diff": "@@ -22,12 +22,29 @@ Monitor_reduction_static\nMonitor_reduction_static::add_monitor(this);\n}\n+Monitor_reduction_static\n+::~Monitor_reduction_static()\n+{\n+ Monitor_reduction_static::remove_monitor(this);\n+}\n+\nvoid Monitor_reduction_static\n::add_monitor(Monitor_reduction_static* m)\n{\nMonitor_reduction_static::monitors.push_back(m);\n}\n+void Monitor_reduction_static\n+::remove_monitor(Monitor_reduction_static* m)\n+{\n+ for (size_t i = 0; i < Monitor_reduction_static::monitors.size(); i++)\n+ if (m == Monitor_reduction_static::monitors[i])\n+ {\n+ Monitor_reduction_static::monitors.erase(Monitor_reduction_static::monitors.begin() +i);\n+ break;\n+ }\n+}\n+\nvoid Monitor_reduction_static\n::reset_all()\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rm the monitor ptr in the destructor in static monitor reduction.
|
8,490 |
07.12.2019 13:23:49
| -3,600 |
c0fb02a99a52277ddec8deed510169a41b5a2cc1
|
Rm autoexec in the tasks + enable socket binding without dataptr cpy.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hpp",
"new_path": "include/Module/Socket.hpp",
"diff": "@@ -51,25 +51,25 @@ public:\ninline void set_fast(const bool fast);\n- inline int bind(Socket &s);\n+ inline void bind(Socket &s, const bool copy_dataptr = true);\n- inline int operator()(Socket &s);\n+ inline void operator()(Socket &s, const bool copy_dataptr = true);\ntemplate <typename T, class A = std::allocator<T>>\n- inline int bind(std::vector<T,A> &vector);\n+ inline void bind(std::vector<T,A> &vector);\ntemplate <typename T, class A = std::allocator<T>>\n- inline int operator()(std::vector<T,A> &vector);\n+ inline void operator()(std::vector<T,A> &vector);\ntemplate <typename T>\n- inline int bind(T *array);\n+ inline void bind(T *array);\ntemplate <typename T>\n- inline int operator()(T *array);\n+ inline void operator()(T *array);\n- inline int bind(void* dataptr);\n+ inline void bind(void* dataptr);\n- inline int operator()(void* dataptr);\n+ inline void operator()(void* dataptr);\ninline void reset();\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hxx",
"new_path": "include/Module/Socket.hxx",
"diff": "@@ -94,8 +94,8 @@ void Socket\nthis->fast = fast;\n}\n-int Socket\n-::bind(Socket &s)\n+void Socket\n+::bind(Socket &s, const bool copy_dataptr)\n{\nif (!is_fast())\n{\n@@ -132,7 +132,7 @@ int Socket\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if (s.dataptr == nullptr)\n+ if (copy_dataptr && s.dataptr == nullptr)\n{\nstd::stringstream message;\nmessage << \"'s.dataptr' can't be NULL.\";\n@@ -142,22 +142,18 @@ int Socket\nthis->bound_sockets.push_back(&s);\ns.bound_sockets.push_back(this);\n+ if (copy_dataptr)\nthis->dataptr = s.dataptr;\n-\n- if (this->task.is_autoexec() && this->task.is_last_input_socket(*this))\n- return this->task.exec();\n- else\n- return 0;\n}\n-int Socket\n-::operator()(Socket &s)\n+void Socket\n+::operator()(Socket &s, const bool copy_dataptr)\n{\n- return bind(s);\n+ bind(s, copy_dataptr);\n}\ntemplate <typename T, class A>\n-int Socket\n+void Socket\n::bind(std::vector<T,A> &vector)\n{\nif (is_fast())\n@@ -178,25 +174,22 @@ int Socket\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- return bind(vector.data());\n+ bind(vector.data());\n}\ntemplate <typename T, class A>\n-int Socket\n+void Socket\n::operator()(std::vector<T,A> &vector)\n{\n- return bind(vector);\n+ bind(vector);\n}\ntemplate <typename T>\n-int Socket\n+void Socket\n::bind(T *array)\n{\nif (is_fast())\n- {\nthis->dataptr = static_cast<void*>(array);\n- return 0;\n- }\nif (type_to_string[typeid(T)] != type_to_string[this->datatype])\n{\n@@ -210,17 +203,17 @@ int Socket\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- return bind(static_cast<void*>(array));\n+ bind(static_cast<void*>(array));\n}\ntemplate <typename T>\n-int Socket\n+void Socket\n::operator()(T *array)\n{\n- return bind(array);\n+ bind(array);\n}\n-int Socket\n+void Socket\n::bind(void* dataptr)\n{\nif (!is_fast())\n@@ -234,17 +227,15 @@ int Socket\n}\nthis->dataptr = dataptr;\n-\n- return 0;\n}\n-int Socket\n+void Socket\n::operator()(void* dataptr)\n{\n- return bind(dataptr);\n+ bind(dataptr);\n}\n-inline void Socket\n+void Socket\n::reset()\n{\nthis->dataptr = nullptr;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Task.hpp",
"new_path": "include/Module/Task.hpp",
"diff": "@@ -36,7 +36,6 @@ protected:\nModule *module;\nconst std::string name;\nbool autoalloc;\n- bool autoexec;\nbool stats;\nbool fast;\nbool debug;\n@@ -69,7 +68,6 @@ public:\nTask( Module &module,\nconst std::string &name,\nconst bool autoalloc = false,\n- const bool autoexec = false,\nconst bool stats = false,\nconst bool fast = false,\nconst bool debug = false);\n@@ -79,7 +77,6 @@ public:\nvoid reset();\nvoid set_autoalloc (const bool autoalloc);\n- void set_autoexec (const bool autoexec );\nvoid set_stats (const bool stats );\nvoid set_fast (const bool fast );\nvoid set_debug (const bool debug );\n@@ -89,7 +86,6 @@ public:\nvoid set_debug_frame_max(const uint32_t limit );\ninline bool is_autoalloc ( ) const;\n- inline bool is_autoexec ( ) const;\ninline bool is_stats ( ) const;\ninline bool is_fast ( ) const;\ninline bool is_debug ( ) const;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Task.hxx",
"new_path": "include/Module/Task.hxx",
"diff": "@@ -14,12 +14,6 @@ bool Task\nreturn this->autoalloc;\n}\n-bool Task\n-::is_autoexec() const\n-{\n- return this->autoexec;\n-}\n-\nbool Task\n::is_stats() const\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Module.cpp",
"new_path": "src/Module/Module.cpp",
"diff": "@@ -106,8 +106,8 @@ void Module\nTask& Module\n::create_task(const std::string &name, const int id)\n{\n- bool autoalloc = false, autoexec = false, stats = false, fast = false, debug = false;\n- auto t = std::make_shared<Task>(*this, name, autoalloc, autoexec, stats, fast, debug);\n+ bool autoalloc = false, stats = false, fast = false, debug = false;\n+ auto t = std::make_shared<Task>(*this, name, autoalloc, stats, fast, debug);\nif (id < 0)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "@@ -15,12 +15,11 @@ using namespace aff3ct;\nusing namespace aff3ct::module;\nTask\n-::Task(Module &module, const std::string &name, const bool autoalloc, const bool autoexec,\n- const bool stats, const bool fast, const bool debug)\n+::Task(Module &module, const std::string &name, const bool autoalloc, const bool stats, const bool fast,\n+ const bool debug)\n: module(&module),\nname(name),\nautoalloc(autoalloc),\n- autoexec(autoexec),\nstats(stats),\nfast(fast),\ndebug(debug),\n@@ -63,12 +62,6 @@ void Task\n}\n}\n-void Task\n-::set_autoexec(const bool autoexec)\n-{\n- this->autoexec = autoexec;\n-}\n-\nvoid Task\n::set_stats(const bool stats)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rm autoexec in the tasks + enable socket binding without dataptr cpy.
|
8,490 |
07.12.2019 13:26:37
| -3,600 |
76dec5af2f02259fe497076fc90e04268d0d3c65
|
Improve the 'get_modules' method by adding subchain recursive parsing.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Subchain/Subchain.hpp",
"new_path": "include/Module/Subchain/Subchain.hpp",
"diff": "#include <memory>\n#include <cstddef>\n-#include \"Tools/Chain/Chain.hpp\"\n#include \"Module/Module.hpp\"\nnamespace aff3ct\n{\n+namespace tools\n+{\n+class Chain;\n+}\nnamespace module\n{\nnamespace sch\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -40,7 +40,7 @@ public:\ninline size_t get_n_threads() const;\ntemplate <class C = module::Module>\n- std::vector<C*> get_modules() const;\n+ std::vector<C*> get_modules(const bool subchain_modules = true) const;\nstd::vector<std::vector<const module::Module*>> get_modules_per_threads() const;\nstd::vector<std::vector<const module::Module*>> get_modules_per_types () const;\ninline const std::vector<std::vector<module::Task*>>& get_tasks_sequences() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hxx",
"new_path": "include/Tools/Chain/Chain.hxx",
"diff": "+#include \"Module/Subchain/Subchain.hpp\"\n#include \"Tools/Chain/Chain.hpp\"\nnamespace aff3ct\n@@ -12,12 +13,22 @@ size_t Chain\ntemplate <class C>\nstd::vector<C*> Chain\n-::get_modules() const\n+::get_modules(const bool subchain_modules) const\n{\nstd::vector<C*> ret;\nfor (auto &mm : this->modules)\nfor (auto &m : mm)\n{\n+ if (subchain_modules)\n+ {\n+ auto c = dynamic_cast<module::Subchain*>(m.get());\n+ if (c != nullptr)\n+ {\n+ auto subret = c->get_chain().get_modules<C>(subchain_modules);\n+ ret.insert(ret.end(), subret.begin(), subret.end());\n+ }\n+ }\n+\nauto c = dynamic_cast<C*>(m.get());\nif (c != nullptr)\nret.push_back(c);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Subchain/Subchain.cpp",
"new_path": "src/Module/Subchain/Subchain.cpp",
"diff": "#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Chain/Chain.hpp\"\n#include \"Module/Subchain/Subchain.hpp\"\nusing namespace aff3ct;\n@@ -25,6 +26,7 @@ Subchain\n}\nauto &p = this->create_task(\"exec\");\n+ p.set_autoalloc(true);\nauto &first = *this->chain->get_tasks_sequence().front();\nfor (auto &s : first.sockets)\n@@ -105,6 +107,7 @@ Subchain\n}\n}\n+ // /!\\ there is probably a bug with SIN_OUT sockets here\nsid = 0;\nfor (auto &s : last.sockets)\n{\n@@ -123,9 +126,21 @@ Subchain\nsize_t sid = 0;\nfor (auto &s : first.sockets)\n{\n- if (first.get_socket_type(*s) == socket_t::SIN || first.get_socket_type(*s) == socket_t::SIN_SOUT)\n- s->bind(t.sockets[sid]->get_dataptr());\n- sid++;\n+ if (first.get_socket_type(*s) == socket_t::SIN)\n+ {\n+ while (t.get_socket_type(*t.sockets[sid]) != socket_t::SIN) sid++;\n+ s->bind(t.sockets[sid++]->get_dataptr());\n+ }\n+ }\n+\n+ sid = 0;\n+ for (auto &s : first.sockets)\n+ {\n+ if (first.get_socket_type(*s) == socket_t::SIN_SOUT)\n+ {\n+ while (t.get_socket_type(*t.sockets[sid]) != socket_t::SIN_SOUT) sid++;\n+ s->bind(t.sockets[sid++]->get_dataptr());\n+ }\n}\nreturn c.chain->exec();\n@@ -166,6 +181,7 @@ void Subchain\n}\n}\n+ // /!\\ there is probably a bug with SIN_OUT sockets here\nsid = 0;\nfor (auto &s : last.sockets)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve the 'get_modules' method by adding subchain recursive parsing.
|
8,490 |
08.12.2019 21:38:02
| -3,600 |
a4a60b59a23205442da2a5f0c15a45b3acb8f4ad
|
Add exceptions management in the Chain.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "#include <functional>\n#include <memory>\n#include <vector>\n+#include <string>\n+#include <mutex>\n#include \"Tools/Interface/Interface_clone.hpp\"\n@@ -28,6 +30,10 @@ protected:\nstd::vector<std::vector<module::Task*>> tasks_sequences;\nstd::vector<std::vector<std::shared_ptr<module::Module>>> modules;\n+ std::shared_ptr<std::mutex> mtx_exception;\n+ std::vector<std::string> prev_exception_messages;\n+ std::vector<std::string> prev_exception_messages_to_display;\n+\npublic:\nChain(const module::Task &first, const size_t n_threads = 1);\nChain(const module::Task &first, const module::Task &last, const size_t n_threads = 1);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "#include <thread>\n#include <utility>\n#include <sstream>\n+#include <cstring>\n+#include <exception>\n+#include \"Tools/Display/Terminal/Terminal.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Module.hpp\"\n#include \"Module/Task.hpp\"\n@@ -13,7 +16,7 @@ using namespace aff3ct::tools;\nChain\n::Chain(const module::Task &first, const module::Task &last, const size_t n_threads)\n-: n_threads(n_threads), tasks_sequences(n_threads), modules(n_threads)\n+: n_threads(n_threads), tasks_sequences(n_threads), modules(n_threads), mtx_exception(new std::mutex())\n{\nif (n_threads == 0)\n{\n@@ -39,7 +42,7 @@ Chain\nChain\n::Chain(const module::Task &first, const size_t n_threads)\n-: n_threads(n_threads), tasks_sequences(n_threads), modules(n_threads)\n+: n_threads(n_threads), tasks_sequences(n_threads), modules(n_threads), mtx_exception(new std::mutex())\n{\nif (n_threads == 0)\n{\n@@ -61,6 +64,7 @@ Chain* Chain\nfor (size_t t = 0; t < this->tasks_sequences[0].size(); t++)\ntasks_sequence.push_back(this->tasks_sequences[0][t]);\nc->duplicate(tasks_sequence);\n+ c->mtx_exception.reset(new std::mutex());\nreturn c;\n}\n@@ -139,20 +143,70 @@ void Chain\nvoid Chain\n::_exec(std::function<bool(const std::vector<int>&)> &stop_condition, std::vector<module::Task*> &tasks_sequence)\n+{\n+ try\n{\nstd::vector<int> statuses(tasks_sequence.size(), 0);\nwhile (!stop_condition(statuses))\nfor (size_t ta = 0; ta < tasks_sequence.size(); ta++)\nstatuses[ta] = tasks_sequence[ta]->exec();\n}\n+ catch (std::exception const& e)\n+ {\n+ tools::Terminal::stop();\n+\n+ this->mtx_exception->lock();\n+\n+ auto save = tools::exception::no_backtrace;\n+ tools::exception::no_backtrace = true;\n+ std::string msg = e.what(); // get only the function signature\n+ tools::exception::no_backtrace = save;\n+\n+ if (std::find(this->prev_exception_messages.begin(), this->prev_exception_messages.end(), msg) ==\n+ this->prev_exception_messages.end())\n+ {\n+ this->prev_exception_messages.push_back(msg); // save only the function signature\n+ this->prev_exception_messages_to_display.push_back(e.what()); // with backtrace if debug mode\n+ }\n+ else if (std::strlen(e.what()) > this->prev_exception_messages_to_display.back().size())\n+ this->prev_exception_messages_to_display[prev_exception_messages_to_display.size() -1] = e.what();\n+\n+ this->mtx_exception->unlock();\n+ }\n+}\nvoid Chain\n::_exec_without_statuses(std::function<bool()> &stop_condition, std::vector<module::Task*> &tasks_sequence)\n+{\n+ try\n{\nwhile (!stop_condition())\nfor (size_t ta = 0; ta < tasks_sequence.size(); ta++)\ntasks_sequence[ta]->exec();\n}\n+ catch (std::exception const& e)\n+ {\n+ tools::Terminal::stop();\n+\n+ this->mtx_exception->lock();\n+\n+ auto save = tools::exception::no_backtrace;\n+ tools::exception::no_backtrace = true;\n+ std::string msg = e.what(); // get only the function signature\n+ tools::exception::no_backtrace = save;\n+\n+ if (std::find(this->prev_exception_messages.begin(), this->prev_exception_messages.end(), msg) ==\n+ this->prev_exception_messages.end())\n+ {\n+ this->prev_exception_messages.push_back(msg); // save only the function signature\n+ this->prev_exception_messages_to_display.push_back(e.what()); // with backtrace if debug mode\n+ }\n+ else if (std::strlen(e.what()) > this->prev_exception_messages_to_display.back().size())\n+ this->prev_exception_messages_to_display[prev_exception_messages_to_display.size() -1] = e.what();\n+\n+ this->mtx_exception->unlock();\n+ }\n+}\nvoid Chain\n::exec(std::function<bool(const std::vector<int>&)> stop_condition)\n@@ -165,6 +219,9 @@ void Chain\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n+\n+ if (!this->prev_exception_messages_to_display.empty())\n+ throw std::runtime_error(this->prev_exception_messages_to_display.back());\n}\nvoid Chain\n@@ -179,6 +236,9 @@ void Chain\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n+\n+ if (!this->prev_exception_messages_to_display.empty())\n+ throw std::runtime_error(this->prev_exception_messages_to_display.back());\n}\nint Chain\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add exceptions management in the Chain.
|
8,490 |
08.12.2019 22:08:28
| -3,600 |
2e9f2cc73f9584ea9f07c2300439514e0f1c7557
|
Improve exceptions management in the Chain.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "#include <memory>\n#include <vector>\n#include <string>\n+#include <atomic>\n#include <mutex>\n#include \"Tools/Interface/Interface_clone.hpp\"\n@@ -33,6 +34,7 @@ protected:\nstd::shared_ptr<std::mutex> mtx_exception;\nstd::vector<std::string> prev_exception_messages;\nstd::vector<std::string> prev_exception_messages_to_display;\n+ std::shared_ptr<std::atomic<bool>> force_exit_loop;\npublic:\nChain(const module::Task &first, const size_t n_threads = 1);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "#include <cstring>\n#include <exception>\n-#include \"Tools/Display/Terminal/Terminal.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Module.hpp\"\n#include \"Module/Task.hpp\"\n@@ -16,7 +15,11 @@ using namespace aff3ct::tools;\nChain\n::Chain(const module::Task &first, const module::Task &last, const size_t n_threads)\n-: n_threads(n_threads), tasks_sequences(n_threads), modules(n_threads), mtx_exception(new std::mutex())\n+: n_threads(n_threads),\n+ tasks_sequences(n_threads),\n+ modules(n_threads),\n+ mtx_exception(new std::mutex()),\n+ force_exit_loop(new std::atomic<bool>(false))\n{\nif (n_threads == 0)\n{\n@@ -42,7 +45,11 @@ Chain\nChain\n::Chain(const module::Task &first, const size_t n_threads)\n-: n_threads(n_threads), tasks_sequences(n_threads), modules(n_threads), mtx_exception(new std::mutex())\n+: n_threads(n_threads),\n+ tasks_sequences(n_threads),\n+ modules(n_threads),\n+ mtx_exception(new std::mutex()),\n+ force_exit_loop(new std::atomic<bool>(false))\n{\nif (n_threads == 0)\n{\n@@ -65,6 +72,7 @@ Chain* Chain\ntasks_sequence.push_back(this->tasks_sequences[0][t]);\nc->duplicate(tasks_sequence);\nc->mtx_exception.reset(new std::mutex());\n+ c->force_exit_loop.reset(new std::atomic<bool>(false));\nreturn c;\n}\n@@ -147,13 +155,13 @@ void Chain\ntry\n{\nstd::vector<int> statuses(tasks_sequence.size(), 0);\n- while (!stop_condition(statuses))\n+ while (!*force_exit_loop && !stop_condition(statuses))\nfor (size_t ta = 0; ta < tasks_sequence.size(); ta++)\nstatuses[ta] = tasks_sequence[ta]->exec();\n}\ncatch (std::exception const& e)\n{\n- tools::Terminal::stop();\n+ *force_exit_loop = true;\nthis->mtx_exception->lock();\n@@ -180,13 +188,13 @@ void Chain\n{\ntry\n{\n- while (!stop_condition())\n+ while (!*force_exit_loop && !stop_condition())\nfor (size_t ta = 0; ta < tasks_sequence.size(); ta++)\ntasks_sequence[ta]->exec();\n}\ncatch (std::exception const& e)\n{\n- tools::Terminal::stop();\n+ *force_exit_loop = true;\nthis->mtx_exception->lock();\n@@ -221,8 +229,11 @@ void Chain\nthreads[tid].join();\nif (!this->prev_exception_messages_to_display.empty())\n+ {\n+ *force_exit_loop = false;\nthrow std::runtime_error(this->prev_exception_messages_to_display.back());\n}\n+}\nvoid Chain\n::exec(std::function<bool()> stop_condition)\n@@ -238,8 +249,11 @@ void Chain\nthreads[tid].join();\nif (!this->prev_exception_messages_to_display.empty())\n+ {\n+ *force_exit_loop = false;\nthrow std::runtime_error(this->prev_exception_messages_to_display.back());\n}\n+}\nint Chain\n::exec(const int tid)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve exceptions management in the Chain.
|
8,490 |
08.12.2019 22:16:30
| -3,600 |
d56b249c0e1fd95ee171fd9ab282eb05a7a36e2c
|
Fix compilation error + cosmetics.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hxx",
"new_path": "include/Module/Socket.hxx",
"diff": "@@ -157,10 +157,7 @@ void Socket\n::bind(std::vector<T,A> &vector)\n{\nif (is_fast())\n- {\nthis->dataptr = static_cast<void*>(vector.data());\n- return 0;\n- }\nif (vector.size() != this->get_n_elmts())\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction_MPI.hpp",
"new_path": "include/Tools/Monitor/Monitor_reduction_MPI.hpp",
"diff": "@@ -28,7 +28,9 @@ private:\nMPI_Op MPI_Op_reduce_monitors;\npublic:\n+ explicit Monitor_reduction_MPI(const std::vector<M*> &monitors);\nexplicit Monitor_reduction_MPI(const std::vector<std::unique_ptr<M>> &monitors);\n+ explicit Monitor_reduction_MPI(const std::vector<std::shared_ptr<M>> &monitors);\nvirtual ~Monitor_reduction_MPI();\nvirtual bool is_done();\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction_MPI.hxx",
"new_path": "include/Tools/Monitor/Monitor_reduction_MPI.hxx",
"diff": "@@ -15,7 +15,7 @@ namespace tools\ntemplate <class M>\nMonitor_reduction_MPI<M>\n-::Monitor_reduction_MPI(const std::vector<std::unique_ptr<M>> &monitors)\n+::Monitor_reduction_MPI(const std::vector<M*> &monitors)\n: Monitor_reduction<M>(monitors)\n{\nconst std::string name = \"Monitor_reduction_MPI<\" + monitors[0]->get_name() + \">\";\n@@ -47,6 +47,20 @@ Monitor_reduction_MPI<M>\n}\n}\n+template <class M>\n+Monitor_reduction_MPI<M>\n+::Monitor_reduction_MPI(const std::vector<std::unique_ptr<M>> &monitors)\n+: Monitor_reduction_MPI(convert_to_ptr<M>(monitors))\n+{\n+}\n+\n+template <class M>\n+Monitor_reduction_MPI<M>\n+::Monitor_reduction_MPI(const std::vector<std::shared_ptr<M>> &monitors)\n+: Monitor_reduction_MPI(convert_to_ptr<M>(monitors))\n+{\n+}\n+\ntemplate <class M>\nMonitor_reduction_MPI<M>\n::~Monitor_reduction_MPI()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/SC_Module.cpp",
"new_path": "src/Module/SC_Module.cpp",
"diff": "@@ -19,7 +19,6 @@ SC_Module\ns_in (sockets_in, task, indirect_sockets_in),\ns_out(sockets_out, task, indirect_sockets_out)\n{\n- task.set_autoexec (false);\ntask.set_autoalloc(true);\nauto is_inputs = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Chain/Simulation_chain_BFER_std.hpp",
"new_path": "src/Simulation/Chain/Simulation_chain_BFER_std.hpp",
"diff": "#include \"Module/Source/Source.hpp\"\n#include \"Module/CRC/CRC.hpp\"\n-#include \"Tools/Codec/Codec_SIHO.hpp\"\n#include \"Module/Modem/Modem.hpp\"\n#include \"Module/Channel/Channel.hpp\"\n#include \"Module/Quantizer/Quantizer.hpp\"\n#include \"Module/Coset/Coset.hpp\"\n#include \"Module/Monitor/MI/Monitor_MI.hpp\"\n#include \"Module/Monitor/BFER/Monitor_BFER.hpp\"\n+#include \"Tools/Codec/Codec_SIHO.hpp\"\n#include \"Tools/Chain/Chain.hpp\"\n#include \"Tools/Constellation/Constellation.hpp\"\n#include \"Tools/Display/Reporter/Reporter.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Chain/Simulation_chain_BFER_std.hxx",
"new_path": "src/Simulation/Chain/Simulation_chain_BFER_std.hxx",
"diff": "@@ -707,7 +707,6 @@ template <typename B, typename R, typename Q>\nvoid Simulation_chain_BFER_std<B,R,Q>\n::create_monitors_reduction()\n{\n- // create and configure the monitors reduction --------------------------------------------------------------------\nauto monitors_bfer = chain->get_modules<module::Monitor_BFER<B>>();\n#ifdef AFF3CT_MPI\nthis->monitor_er_red.reset(new tools::Monitor_reduction_MPI<module::Monitor_BFER<B>>(monitors_bfer));\n@@ -764,7 +763,6 @@ void Simulation_chain_BFER_std<B,R,Q>\nreturn;\n}\n- // SNR loop -------------------------------------------------------------------------------------------------------\nint noise_begin = 0;\nint noise_end = (int)params_BFER.noise->range.size();\nint noise_step = 1;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix compilation error + cosmetics.
|
8,490 |
09.12.2019 16:33:04
| -3,600 |
6146579931499fbadeca7cdfb213c5b7aaad7766
|
Add the possibility to dump the simulated chain in Graphviz format.
|
[
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/simulation/simulation.rst",
"new_path": "doc/source/user/simulation/parameters/simulation/simulation.rst",
"diff": "@@ -647,6 +647,18 @@ parameter is enabled, it becomes the codeword size (:math:`N`).\n|factory::BFER::p+chain|\n+.. _sim-sim-chain-path:\n+\n+``--sim-chain-path`` |image_advanced_argument|\n+\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n+\n+ :Type: file\n+ :Rights: write\n+ :Default: :file:`chain.dot`\n+ :Examples: ``--sim-chain-path chain.dot``\n+\n+|factory::BFER::p+chain-path|\n+\n.. _sim-sim-clone:\n``--sim-clone`` |image_advanced_argument|\n"
},
{
"change_type": "MODIFY",
"old_path": "doc/strings.rst",
"new_path": "doc/strings.rst",
"diff": "Enable the new simulator engine based on a chain (should be faster than the\nlegacy simulator engine).\n+.. |factory::BFER::p+chain-path| replace::\n+ Enable the new simulator engine based on a chain and export the simulated\n+ chain in Graphviz format at the given path.\n+\n.. |factory::BFER::p+clone| replace::\nEnable the *clone* method to allocate the module objects.\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "#define CHAIN_HPP_\n#include <functional>\n+#include <iostream>\n#include <memory>\n#include <vector>\n#include <string>\n@@ -44,7 +45,7 @@ public:\nvoid exec(std::function<bool(const std::vector<int>&)> stop_condition);\nvoid exec(std::function<bool( )> stop_condition);\n- int exec(const int tid = 0 );\n+ int exec(const size_t tid = 0 );\ninline size_t get_n_threads() const;\ntemplate <class C = module::Module>\n@@ -54,7 +55,13 @@ public:\ninline const std::vector<std::vector<module::Task*>>& get_tasks_sequences() const;\ninline const std::vector<module::Task*>& get_tasks_sequence(const int tid = 0) const;\n+ void export_dot(std::ostream &stream = std::cout) const;\n+\nprotected:\n+ void export_dot_subsequence(const std::vector<module::Task*> &subseq,\n+ const std::string &subseq_name,\n+ const std::string &tab,\n+ std::ostream &stream) const;\nstatic void init_recursive(std::vector<const module::Task*> &tasks_sequence,\nconst module::Task& first,\nconst module::Task& current_task,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/BFER/BFER.cpp",
"new_path": "src/Factory/Simulation/BFER/BFER.cpp",
"diff": "@@ -142,6 +142,10 @@ void BFER\ntools::add_arg(args, p, class_name+\"p+chain\",\ncli::None(),\ncli::arg_rank::ADV);\n+\n+ tools::add_arg(args, p, class_name+\"p+chain-path\",\n+ cli::File(cli::openmode::write),\n+ cli::arg_rank::ADV);\n}\nvoid BFER\n@@ -166,6 +170,12 @@ void BFER\nif(vals.exist({p+\"-clone\", })) this->alloc_clone = true;\nif(vals.exist({p+\"-chain\", })) this->chain_threads = true;\n+ if (vals.exist({p+\"-chain-path\"}))\n+ {\n+ this->chain_threads = true;\n+ this->chain_path = vals.at({p+\"-chain-path\"});\n+ }\n+\nif (this->chain_threads)\nthis->alloc_clone = true;\n@@ -233,6 +243,9 @@ void BFER\nstd::string enable_chain_threads = (this->chain_threads) ? \"on\" : \"off\";\nheaders[p].push_back(std::make_pair(\"Chain multithreading\", enable_chain_threads));\n+ if (!this->chain_path.empty())\n+ headers[p].push_back(std::make_pair(\"Path export chain (dot)\", this->chain_path));\n+\nif (this->err_track_threshold)\nheaders[p].push_back(std::make_pair(\"Bad frames threshold\", std::to_string(this->err_track_threshold)));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/BFER/BFER.hpp",
"new_path": "src/Factory/Simulation/BFER/BFER.hpp",
"diff": "@@ -31,6 +31,7 @@ public:\n// ----------------------------------------------------------------------------------------------------- PARAMETERS\n// optional parameters\nstd::string err_track_path = \"error_tracker\";\n+ std::string chain_path = \"\";\nint err_track_threshold = 0;\nbool err_track_revert = false;\nbool err_track_enable = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Chain/BFER/Simulation_chain_BFER.cpp",
"new_path": "src/Simulation/Chain/BFER/Simulation_chain_BFER.cpp",
"diff": "@@ -109,6 +109,7 @@ void Simulation_chain_BFER<B,R>\n::create_modules()\n{\nthis->monitor_er = this->build_monitor_er();\n+ if (params_BFER.mnt_mi != nullptr)\nthis->monitor_mi = this->build_monitor_mi();\n}\n@@ -116,6 +117,12 @@ template <typename B, typename R>\nvoid Simulation_chain_BFER<B,R>\n::configure_chain_tasks()\n{\n+ if (!params_BFER.chain_path.empty())\n+ {\n+ std::ofstream dot_file(params_BFER.chain_path);\n+ this->chain->export_dot(dot_file);\n+ }\n+\nfor (auto &mod : chain->get_modules<module::Module>())\nfor (auto &tsk : mod->tasks)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Chain/BFER/Standard/Simulation_chain_BFER_std.cpp",
"new_path": "src/Simulation/Chain/BFER/Standard/Simulation_chain_BFER_std.cpp",
"diff": "@@ -138,7 +138,7 @@ void Simulation_chain_BFER_std<B,R,Q>\nauto &mnt = *this->monitor_er;\nauto &mni = *this->monitor_mi;\n- std::vector<module::Module*> modules = {&src, &crc, &enc, &pct, &mdm, &chn, &qnt, &csr, &dec, &csb, &mnt, &mni};\n+ std::vector<Module*> modules = {&src, &crc, &enc, &pct, &mdm, &chn, &qnt, &csr, &dec, &csb, &mnt, &mni};\nfor (auto& mod : modules)\nfor (auto& tsk : mod->tasks)\ntsk->set_autoalloc(true);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -76,6 +76,80 @@ Chain* Chain\nreturn c;\n}\n+void Chain\n+::export_dot_subsequence(const std::vector<module::Task*> &subseq,\n+ const std::string &subseq_name,\n+ const std::string &tab,\n+ std::ostream &stream) const\n+{\n+ if (!subseq_name.empty())\n+ {\n+ stream << tab << \"subgraph \\\"cluster_\" << subseq_name << \"\\\" {\" << std::endl;\n+ stream << tab << tab << \"node [style=filled];\" << std::endl;\n+ }\n+ for (auto &t : subseq)\n+ {\n+ stream << tab << tab << \"subgraph \\\"cluster_\" << +&t->get_module() << \"_\" << +&t << \"\\\" {\" << std::endl;\n+ stream << tab << tab << tab << \"node [style=filled];\" << std::endl;\n+ stream << tab << tab << tab << \"subgraph \\\"cluster_\" << +&t << \"\\\" {\" << std::endl;\n+ stream << tab << tab << tab << tab << \"node [style=filled];\" << std::endl;\n+ for (auto &s : t->sockets)\n+ {\n+ std::string stype;\n+ switch (t->get_socket_type(*s))\n+ {\n+ case module::socket_t::SIN: stype = \"in\"; break;\n+ case module::socket_t::SOUT: stype = \"out\"; break;\n+ case module::socket_t::SIN_SOUT: stype = \"in_out\"; break;\n+ default: stype = \"unkn\"; break;\n+ }\n+ stream << tab << tab << tab << tab << \"\\\"\" << +s.get() << \"\\\"\"\n+ << \"[label=\\\"\" << stype << \":\" << s->get_name() << \"\\\"];\" << std::endl;\n+ }\n+ stream << tab << tab << tab << tab << \"label=\\\"\" << t->get_name() << \"\\\";\" << std::endl;\n+ stream << tab << tab << tab << tab << \"color=blue;\" << std::endl;\n+ stream << tab << tab << tab << \"}\" << std::endl;\n+ stream << tab << tab << tab << \"label=\\\"\" << t->get_module().get_name() << \"\\n\" << +&t->get_module() << \"\\\";\"\n+ << std::endl;\n+ stream << tab << tab << tab << \"color=blue;\" << std::endl;\n+ stream << tab << tab << \"}\" << std::endl;\n+ }\n+ if (!subseq_name.empty())\n+ {\n+ stream << tab << tab << \"label=\\\"\" << subseq_name << \"\\\";\" << std::endl;\n+ stream << tab << tab << \"color=blue;\" << std::endl;\n+ stream << tab << \"}\" << std::endl;\n+ }\n+}\n+\n+void Chain\n+::export_dot(std::ostream &stream) const\n+{\n+ std::string tab = \"\\t\";\n+ stream << \"digraph Chain {\" << std::endl;\n+\n+ std::string subseq_name = \"\"; // \"Sub-sequence1\"\n+ this->export_dot_subsequence(this->tasks_sequences[0], subseq_name, tab, stream);\n+\n+ auto &tasks_sequence = this->tasks_sequences[0];\n+ for (auto &t : tasks_sequence)\n+ {\n+ for (auto &s : t->sockets)\n+ {\n+ if (t->get_socket_type(*s) == module::socket_t::SOUT ||\n+ t->get_socket_type(*s) == module::socket_t::SIN_SOUT)\n+ {\n+ for (auto &bs : s->get_bound_sockets())\n+ {\n+ stream << tab << \"\\\"\" << +s.get() << \"\\\" -> \\\"\" << +bs << \"\\\"\" << std::endl;\n+ }\n+ }\n+ }\n+ }\n+\n+ stream << \"}\" << std::endl;\n+}\n+\nstd::vector<std::vector<const module::Module*>> Chain\n::get_modules_per_threads() const\n{\n@@ -125,6 +199,8 @@ void Chain\nif (bs != nullptr)\n{\nauto &t = bs->get_task();\n+ std::cout << \"[in]: sname = \" << s->get_name() << \", tname = \" << s->get_task().get_name() << \" - \";\n+ std::cout << \"[out]: sname = \" << bs->get_name() << \", tname = \" << t.get_name() << std::endl;;\nif (t.is_last_input_socket(*bs))\nChain::init_recursive(tasks_sequence, first, t, last);\n}\n@@ -256,8 +332,16 @@ void Chain\n}\nint Chain\n-::exec(const int tid)\n+::exec(const size_t tid)\n+{\n+ if (tid >= this->tasks_sequences.size())\n{\n+ std::stringstream message;\n+ message << \"'tid' has to be smaller than 'tasks_sequences.size()' ('tid' = \" << tid\n+ << \", 'tasks_sequences.size()' = \" << this->tasks_sequences.size() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nint ret = 0;\nfor (size_t ta = 0; ta < this->tasks_sequences[tid].size(); ta++)\nret += this->tasks_sequences[tid][ta]->exec();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the possibility to dump the simulated chain in Graphviz format.
|
8,490 |
09.12.2019 16:34:58
| -3,600 |
eb3c1e414a3da225c9b97c2041bc5e67c0b6fb9f
|
Build polar decoders even if the decoder do not take advantage of CRC.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/Polar/Decoder_polar.cpp",
"new_path": "src/Factory/Module/Decoder/Polar/Decoder_polar.cpp",
"diff": "@@ -175,38 +175,34 @@ module::Decoder_SIHO<B,Q>* Decoder_polar\n{\nif (this->implem == \"NAIVE\")\n{\n- if (crc == nullptr || std::unique_ptr<module::CRC<B>>(crc->clone())->get_size() == 0)\n- {\n- if (this->type == \"SC\" ) return new module::Decoder_polar_SC_naive <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, frozen_bits, this->n_frames);\n- if (this->type == \"SCAN\") return new module::Decoder_polar_SCAN_naive <B,Q,tools::f_LLR<Q>,tools::v_LLR< Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, this->n_ite, frozen_bits, this->n_frames);\n- if (this->type == \"SCL\" ) return new module::Decoder_polar_SCL_naive <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q> >(this->K, this->N_cw, this->L, frozen_bits, this->n_frames);\n- }\n- else\n+ if (crc != nullptr && std::unique_ptr<module::CRC<B>>(crc->clone())->get_size() > 0)\n{\nif (this->type == \"SCF\" ) return new module::Decoder_polar_SCF_naive <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, frozen_bits, *crc, this->flips, this->n_frames);\nif (this->type == \"SCL\" ) return new module::Decoder_polar_SCL_naive_CA <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q> >(this->K, this->N_cw, this->L, frozen_bits, *crc, this->n_frames);\n}\n+\n+ if (this->type == \"SC\" ) return new module::Decoder_polar_SC_naive <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, frozen_bits, this->n_frames);\n+ if (this->type == \"SCAN\") return new module::Decoder_polar_SCAN_naive <B,Q,tools::f_LLR<Q>,tools::v_LLR< Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, this->n_ite, frozen_bits, this->n_frames);\n+ if (this->type == \"SCL\" ) return new module::Decoder_polar_SCL_naive <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q> >(this->K, this->N_cw, this->L, frozen_bits, this->n_frames);\n+\n}\n}\nelse // systematic encoding\n{\nif (this->implem == \"NAIVE\")\n{\n- if (crc == nullptr || std::unique_ptr<module::CRC<B>>(crc->clone())->get_size() == 0)\n- {\n- if (this->type == \"SC\" ) return new module::Decoder_polar_SC_naive_sys <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, frozen_bits, this->n_frames);\n- if (this->type == \"SCAN\") return new module::Decoder_polar_SCAN_naive_sys <B,Q,tools::f_LLR<Q>,tools::v_LLR< Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, this->n_ite, frozen_bits, this->n_frames);\n- if (this->type == \"SCL\" ) return new module::Decoder_polar_SCL_naive_sys <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q> >(this->K, this->N_cw, this->L, frozen_bits, this->n_frames);\n- }\n- else\n+ if (crc != nullptr && std::unique_ptr<module::CRC<B>>(crc->clone())->get_size() > 0)\n{\nif (this->type == \"SCF\" ) return new module::Decoder_polar_SCF_naive_sys <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, frozen_bits, *crc, this->flips, this->n_frames);\nif (this->type == \"SCL\" ) return new module::Decoder_polar_SCL_naive_CA_sys<B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q> >(this->K, this->N_cw, this->L, frozen_bits, *crc, this->n_frames);\n}\n+\n+ if (this->type == \"SC\" ) return new module::Decoder_polar_SC_naive_sys <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, frozen_bits, this->n_frames);\n+ if (this->type == \"SCAN\") return new module::Decoder_polar_SCAN_naive_sys <B,Q,tools::f_LLR<Q>,tools::v_LLR< Q>,tools::h_LLR<B,Q>>(this->K, this->N_cw, this->n_ite, frozen_bits, this->n_frames);\n+ if (this->type == \"SCL\" ) return new module::Decoder_polar_SCL_naive_sys <B,Q,tools::f_LLR<Q>,tools::g_LLR<B,Q> >(this->K, this->N_cw, this->L, frozen_bits, this->n_frames);\n+\n}\nelse if (this->implem == \"FAST\")\n- {\n- if (crc == nullptr || std::unique_ptr<module::CRC<B>>(crc->clone())->get_size() == 0)\n{\nint idx_r0, idx_r1;\nauto polar_patterns = tools::Nodes_parser<>::parse_ptr(this->polar_nodes, idx_r0, idx_r1);\n@@ -219,7 +215,6 @@ module::Decoder_SIHO<B,Q>* Decoder_polar\nreturn decoder;\n}\n}\n- }\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Build polar decoders even if the decoder do not take advantage of CRC.
|
8,490 |
09.12.2019 16:37:23
| -3,600 |
37885645bbee2015bd3d009e414c08414be78533
|
Add the BFER iterative simulation with chain (not working).
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/BFER/BFER_ite.cpp",
"new_path": "src/Factory/Simulation/BFER/BFER_ite.cpp",
"diff": "#include \"Tools/Documentation/documentation.h\"\n#include \"Simulation/Legacy/BFER/Iterative/SystemC/SC_BFER_ite.hpp\"\n#include \"Simulation/Legacy/BFER/Iterative/Threads/BFER_ite_threads.hpp\"\n+#include \"Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.hpp\"\n#include \"Factory/Simulation/BFER/BFER_ite.hpp\"\nusing namespace aff3ct;\n@@ -154,6 +155,9 @@ simulation::Simulation* BFER_ite\n#if defined(AFF3CT_SYSTEMC_SIMU)\nreturn new simulation::SC_BFER_ite<B,R,Q>(*this);\n#else\n+ if (this->chain_threads)\n+ return new simulation::Simulation_chain_BFER_ite<B,R,Q>(*this);\n+ else\nreturn new simulation::BFER_ite_threads<B,R,Q>(*this);\n#endif\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.cpp",
"diff": "+#include <functional>\n+#include <algorithm>\n+#include <iostream>\n+#include <vector>\n+#include <random>\n+#include <string>\n+\n+#include \"Tools/Algo/Predicate_ite.hpp\"\n+#include \"Tools/Chain/Chain.hpp\"\n+#include \"Tools/Display/rang_format/rang_format.h\"\n+#include \"Tools/Interface/Interface_set_seed.hpp\"\n+#include \"Tools/Interface/Interface_get_set_noise.hpp\"\n+#include \"Tools/Interface/Interface_notify_noise_update.hpp\"\n+#include \"Tools/Display/Dumper/Dumper.hpp\"\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Factory/Module/Coset/Coset.hpp\"\n+#include \"Factory/Tools/Codec/Codec.hpp\"\n+#include \"Factory/Tools/Codec/Codec_SIHO.hpp\"\n+#include \"Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::simulation;\n+\n+template <typename B, typename R, typename Q>\n+Simulation_chain_BFER_ite<B,R,Q>\n+::Simulation_chain_BFER_ite(const factory::BFER_ite ¶ms_BFER_ite)\n+: Simulation_chain_BFER<B,R>(params_BFER_ite),\n+ params_BFER_ite(params_BFER_ite)\n+{\n+ if (this->params_BFER_ite.err_track_revert && this->params_BFER_ite.n_threads != 1)\n+ std::clog << rang::tag::warning << \"Multi-threading detected with error tracking revert feature! \"\n+ \"Each thread will play the same frames. Please run with one thread.\"\n+ << std::endl;\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Source<B>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_source()\n+{\n+ return std::unique_ptr<module::Source<B>>(params_BFER_ite.src->build<B>());\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::CRC<B>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_crc()\n+{\n+ return std::unique_ptr<module::CRC<B>>(params_BFER_ite.crc->build<B>());\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<tools::Codec_SISO<B,Q>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_codec(const module::CRC<B> *crc)\n+{\n+ auto crc_ptr = this->params_BFER_ite.crc->type == \"NO\" ? nullptr : crc;\n+ std::unique_ptr<factory::Codec> params_cdc(params_BFER_ite.cdc->clone());\n+ auto param_siso_siho = dynamic_cast<factory::Codec_SISO*>(params_cdc.get());\n+ return std::unique_ptr<tools::Codec_SISO<B,Q>>(param_siso_siho->template build<B,Q>(crc_ptr));\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<tools ::Interleaver_core<>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_interleaver()\n+{\n+ std::unique_ptr<factory::Interleaver> params_itl(params_BFER_ite.itl->clone());\n+ return std::unique_ptr<tools::Interleaver_core<>>(params_itl->core->build<>());\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Modem<B,R,Q>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_modem(const tools::Distributions<R> *distributions, const tools::Constellation<R> *constellation)\n+{\n+ if (distributions != nullptr)\n+ return std::unique_ptr<module::Modem<B,R,Q>>(params_BFER_ite.mdm->build<B,R,Q>(*distributions));\n+ else\n+ return std::unique_ptr<module::Modem<B,R,Q>>(params_BFER_ite.mdm->build<B,R,Q>(constellation));\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Channel<R>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_channel(const tools::Distributions<R> *distributions)\n+{\n+ if (distributions != nullptr)\n+ return std::unique_ptr<module::Channel<R>>(params_BFER_ite.chn->build<R>(*distributions));\n+ else\n+ {\n+ auto c = std::unique_ptr<module::Channel<R>>(params_BFER_ite.chn->build<R>());\n+ return c;\n+ }\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Quantizer<R,Q>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_quantizer()\n+{\n+ return std::unique_ptr<module::Quantizer<R,Q>>(params_BFER_ite.qnt->build<R,Q>());\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Coset<B,Q>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_coset_real()\n+{\n+ factory::Coset cst_params;\n+ cst_params.size = params_BFER_ite.cdc->N_cw;\n+ cst_params.n_frames = params_BFER_ite.src->n_frames;\n+ return std::unique_ptr<module::Coset<B,Q>>(cst_params.build_real<B,Q>());\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Coset<B,B>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_coset_bit()\n+{\n+ factory::Coset cst_params;\n+ cst_params.size = params_BFER_ite.coded_monitoring ? params_BFER_ite.cdc->N_cw : params_BFER_ite.cdc->K;\n+ cst_params.n_frames = params_BFER_ite.src->n_frames;\n+ return std::unique_ptr<module::Coset<B,B>>(cst_params.build_bit<B,B>());\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Loop_predicate<Q>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_loop_ite()\n+{\n+ tools::Predicate_ite p(params_BFER_ite.n_ite);\n+ auto loop_ite = std::unique_ptr<module::Loop_predicate<Q>>(new module::Loop_predicate<Q>(\n+ p,\n+ params_BFER_ite.cdc->N_cw,\n+ params_BFER_ite.src->n_frames));\n+ return loop_ite;\n+}\n+\n+template <typename B, typename R, typename Q>\n+std::unique_ptr<module::Loop_CRC<B,Q>> Simulation_chain_BFER_ite<B,R,Q>\n+::build_loop_crc()\n+{\n+ tools::Predicate_ite p(params_BFER_ite.n_ite);\n+ auto crc = params_BFER_ite.crc->build<B>();\n+ auto loop_crc = std::unique_ptr<module::Loop_CRC<B,Q>>(new module::Loop_CRC<B,Q>(\n+ p,\n+ *crc,\n+ (size_t)crc->get_size() + (size_t)crc->get_K(),\n+ params_BFER_ite.cdc->N_cw,\n+ params_BFER_ite.crc_start));\n+ return loop_crc;\n+}\n+\n+template <typename B, typename R, typename Q>\n+void Simulation_chain_BFER_ite<B,R,Q>\n+::create_modules()\n+{\n+ Simulation_chain_BFER<B,R>::create_modules();\n+\n+ this->source = build_source ( );\n+ this->crc = build_crc ( );\n+ this->codec1 = build_codec (this->crc.get() );\n+ this->codec2 = build_codec (this->crc.get() );\n+ this->modem1 = build_modem (this->distributions.get(), this->constellation.get());\n+ this->modem2 = build_modem (this->distributions.get(), this->constellation.get());\n+ this->channel = build_channel (this->distributions.get() );\n+ this->quantizer = build_quantizer ( );\n+ this->coset_real1 = build_coset_real ( );\n+ this->coset_real2 = build_coset_real ( );\n+ this->coset_real3 = build_coset_real ( );\n+ this->coset_bit = build_coset_bit ( );\n+ this->interleaver_core = build_interleaver( );\n+ this->loop_ite = build_loop_ite ( );\n+ this->loop_crc = build_loop_crc ( );\n+\n+ this->interleaver_bit .reset(factory::Interleaver::build<B>(*this->interleaver_core));\n+ this->interleaver_llr1.reset(factory::Interleaver::build<Q>(*this->interleaver_core));\n+ this->interleaver_llr2.reset(factory::Interleaver::build<Q>(*this->interleaver_core));\n+}\n+\n+template <typename B, typename R, typename Q>\n+void Simulation_chain_BFER_ite<B,R,Q>\n+::bind_sockets()\n+{\n+ using namespace module;\n+\n+ auto &src = *this->source;\n+ auto &crc = *this->crc;\n+ auto &itb = *this->interleaver_bit;\n+ auto &mdm1 = *this->modem1;\n+ auto &mdm2 = *this->modem2;\n+ auto &chn = *this->channel;\n+ auto &qnt = *this->quantizer;\n+ auto &itl1 = *this->interleaver_llr1;\n+ auto &itl2 = *this->interleaver_llr2;\n+ auto &csr1 = *this->coset_real1;\n+ auto &csr2 = *this->coset_real2;\n+ auto &csr3 = *this->coset_real3;\n+ auto &csb = *this->coset_bit;\n+ auto &mnt = *this->monitor_er;\n+ auto &lite = *this->loop_ite;\n+ auto &lcrc = *this->loop_crc;\n+ auto &enc = this->codec1->get_encoder();\n+ auto &dcs = this->codec1->get_decoder_siso();\n+ auto &dch = this->codec1->get_decoder_siho();\n+ auto &ext1 = this->codec1->get_extractor();\n+ auto &ext2 = this->codec2->get_extractor();\n+\n+ std::vector<Module*> modules = { &src, &crc, &itb, &mdm1, &mdm2, &chn, &qnt, &itl1, &itl2, &csr1, &csr2, &csr3,\n+ &csb, &mnt, &lite, &lcrc, &enc, &dcs, &dch, &ext1, &ext2 };\n+ for (auto& mod : modules)\n+ for (auto& tsk : mod->tasks)\n+ tsk->set_autoalloc(true);\n+\n+ if (this->params_BFER_ite.src->type == \"AZCW\")\n+ {\n+ auto src_data = (uint8_t*)(src[src::sck::generate ::U_K ].get_dataptr());\n+ auto crc_data = (uint8_t*)(crc[crc::sck::build ::U_K2].get_dataptr());\n+ auto enc_data = (uint8_t*)(enc[enc::sck::encode ::X_N ].get_dataptr());\n+ auto itl_data = (uint8_t*)(itb[itl::sck::interleave::itl ].get_dataptr());\n+\n+ auto src_bytes = src[src::sck::generate ::U_K ].get_databytes();\n+ auto crc_bytes = crc[crc::sck::build ::U_K2].get_databytes();\n+ auto enc_bytes = enc[enc::sck::encode ::X_N ].get_databytes();\n+ auto itl_bytes = itb[itl::sck::interleave::itl ].get_databytes();\n+\n+ std::fill(src_data, src_data + src_bytes, 0);\n+ std::fill(crc_data, crc_data + crc_bytes, 0);\n+ std::fill(enc_data, enc_data + enc_bytes, 0);\n+ std::fill(itl_data, itl_data + itl_bytes, 0);\n+\n+ mdm1[mdm::sck::modulate::X_N1].bind(itb[itl::sck::interleave::itl]);\n+ mdm1[mdm::tsk::modulate].exec();\n+ mdm1[mdm::tsk::modulate].reset();\n+ }\n+ else\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ crc[crc::sck::build::U_K1].bind(src[src::sck::generate::U_K]);\n+\n+ if (this->params_BFER_ite.cdc->enc->type != \"NO\")\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ enc[enc::sck::encode::U_K].bind(crc[crc::sck::build::U_K2]);\n+ else\n+ enc[enc::sck::encode::U_K].bind(src[src::sck::generate::U_K]);\n+ }\n+\n+ if (this->params_BFER_ite.cdc->enc->type != \"NO\")\n+ itb[itl::sck::interleave::nat].bind(enc[enc::sck::encode::X_N]);\n+ else if (this->params_BFER_ite.crc->type != \"NO\")\n+ itb[itl::sck::interleave::nat].bind(crc[crc::sck::build::U_K2]);\n+ else\n+ itb[itl::sck::interleave::nat].bind(src[src::sck::generate::U_K]);\n+\n+ mdm1[mdm::sck::modulate::X_N1].bind(itb[itl::sck::interleave::itl]);\n+ }\n+\n+ if (this->params_BFER_ite.coset)\n+ {\n+ if (this->params_BFER_ite.coded_monitoring)\n+ {\n+ if (this->params_BFER_ite.cdc->enc->type != \"NO\")\n+ csb[cst::sck::apply::ref].bind(enc[enc::sck::encode::X_N]);\n+ else if (this->params_BFER_ite.crc->type != \"NO\")\n+ csb[cst::sck::apply::ref].bind(crc[crc::sck::build::U_K2]);\n+ else\n+ csb[cst::sck::apply::ref].bind(src[src::sck::generate::U_K]);\n+ }\n+ else\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ csb[cst::sck::apply::ref].bind(crc[crc::sck::build::U_K2]);\n+ else\n+ csb[cst::sck::apply::ref].bind(src[src::sck::generate::U_K]);\n+ }\n+\n+ if (this->params_BFER_ite.cdc->enc->type != \"NO\")\n+ {\n+ csr1[cst::sck::apply::ref].bind(enc[enc::sck::encode::X_N]);\n+ csr2[cst::sck::apply::ref].bind(enc[enc::sck::encode::X_N]);\n+ csr3[cst::sck::apply::ref].bind(enc[enc::sck::encode::X_N]);\n+ }\n+ else if (this->params_BFER_ite.crc->type != \"NO\")\n+ {\n+ csr1[cst::sck::apply::ref].bind(crc[crc::sck::build::U_K2]);\n+ csr2[cst::sck::apply::ref].bind(crc[crc::sck::build::U_K2]);\n+ csr3[cst::sck::apply::ref].bind(crc[crc::sck::build::U_K2]);\n+ }\n+ else\n+ {\n+ csr1[cst::sck::apply::ref].bind(src[src::sck::generate::U_K]);\n+ csr2[cst::sck::apply::ref].bind(src[src::sck::generate::U_K]);\n+ csr3[cst::sck::apply::ref].bind(src[src::sck::generate::U_K]);\n+ }\n+ }\n+\n+ if (this->params_BFER_ite.coded_monitoring)\n+ {\n+ if (this->params_BFER_ite.cdc->enc->type != \"NO\")\n+ mnt[mnt::sck::check_errors::U].bind(enc[enc::sck::encode::X_N]);\n+ else if (this->params_BFER_ite.crc->type != \"NO\")\n+ mnt[mnt::sck::check_errors::U].bind(crc[crc::sck::build::U_K2]);\n+ else\n+ mnt[mnt::sck::check_errors::U].bind(src[src::sck::generate::U_K]);\n+ }\n+ else\n+ mnt[mnt::sck::check_errors::U].bind(src[src::sck::generate::U_K]);\n+\n+ const auto is_rayleigh = this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos;\n+ if (is_rayleigh && this->params_BFER_ite.chn->type == \"NO\")\n+ {\n+ auto chn_data = (uint8_t*)(chn[chn::sck::add_noise_wg::H_N].get_dataptr());\n+ auto chn_bytes = chn[chn::sck::add_noise_wg::H_N].get_databytes();\n+ std::fill(chn_data, chn_data + chn_bytes, 0);\n+ }\n+\n+ if (this->params_BFER_ite.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ chn[chn::sck::add_noise_wg::X_N].bind(mdm1[mdm::sck::modulate::X_N2]);\n+ else\n+ chn[chn::sck::add_noise::X_N].bind(mdm1[mdm::sck::modulate::X_N2]);\n+ }\n+\n+ if (mdm1.is_filter())\n+ {\n+ if (this->params_BFER_ite.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ mdm1[mdm::sck::filter::Y_N1].bind(chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ mdm1[mdm::sck::filter::Y_N1].bind(chn[chn::sck::add_noise::Y_N]);\n+ }\n+ else\n+ mdm1[mdm::sck::filter::Y_N1].bind(mdm1[mdm::sck::modulate::X_N2]);\n+ }\n+\n+ if (this->params_BFER_ite.qnt->type != \"NO\")\n+ {\n+ if (mdm1.is_filter())\n+ qnt[qnt::sck::process::Y_N1].bind(mdm1[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_ite.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ qnt[qnt::sck::process::Y_N1].bind(chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ qnt[qnt::sck::process::Y_N1].bind(chn[chn::sck::add_noise::Y_N]);\n+ }\n+ else\n+ qnt[qnt::sck::process::Y_N1].bind(mdm1[mdm::sck::modulate::X_N2]);\n+ }\n+\n+ if (mdm1.is_demodulator())\n+ {\n+ if (is_rayleigh)\n+ {\n+ if (this->params_BFER_ite.chn->type != \"NO\")\n+ mdm1[mdm::sck::demodulate_wg::H_N].bind(chn[chn::sck::add_noise_wg::H_N]);\n+ else\n+ mdm1[mdm::sck::demodulate_wg::H_N].bind((uint8_t*)(chn[chn::sck::add_noise_wg::H_N].get_dataptr()));\n+ }\n+\n+ if (this->params_BFER_ite.qnt->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ mdm1[mdm::sck::demodulate_wg::Y_N1].bind(qnt[qnt::sck::process::Y_N2]);\n+ else\n+ mdm1[mdm::sck::demodulate::Y_N1].bind(qnt[qnt::sck::process::Y_N2]);\n+ }\n+ else if (mdm1.is_filter())\n+ {\n+ if (is_rayleigh)\n+ mdm1[mdm::sck::demodulate_wg::Y_N1].bind(mdm1[mdm::sck::filter::Y_N2]);\n+ else\n+ mdm1[mdm::sck::demodulate::Y_N1].bind(mdm1[mdm::sck::filter::Y_N2]);\n+ }\n+ else if (this->params_BFER_ite.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ mdm1[mdm::sck::demodulate_wg::Y_N1].bind(chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ mdm1[mdm::sck::demodulate::Y_N1].bind(chn[chn::sck::add_noise::Y_N]);\n+ }\n+ else\n+ {\n+ if (is_rayleigh)\n+ mdm1[mdm::sck::demodulate_wg::Y_N1].bind(mdm1[mdm::sck::modulate::X_N2]);\n+ else\n+ mdm1[mdm::sck::demodulate::Y_N1].bind(mdm1[mdm::sck::modulate::X_N2]);\n+ }\n+ }\n+\n+ if (mdm1.is_demodulator())\n+ {\n+ if (is_rayleigh)\n+ itl1[itl::sck::deinterleave::itl].bind(mdm1[mdm::sck::demodulate_wg::Y_N2]);\n+ else\n+ itl1[itl::sck::deinterleave::itl].bind(mdm1[mdm::sck::demodulate::Y_N2]);\n+ }\n+ else if (this->params_BFER_ite.qnt->type != \"NO\")\n+ itl1[itl::sck::deinterleave::itl].bind(qnt[qnt::sck::process::Y_N2]);\n+ else if (mdm1.is_filter())\n+ itl1[itl::sck::deinterleave::itl].bind(mdm1[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_ite.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ itl1[itl::sck::deinterleave::itl].bind(chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ itl1[itl::sck::deinterleave::itl].bind(chn[chn::sck::add_noise::Y_N]);\n+ }\n+ else\n+ itl1[itl::sck::deinterleave::itl].bind(mdm1[mdm::sck::modulate::X_N2]);\n+\n+ // ----------------------------------------------------------------------------------------------------------------\n+ // ---------------------------------------------------------------------------------------- turbo demodulation loop\n+ // ----------------------------------------------------------------------------------------------------------------\n+\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ {\n+ ext1[ext::sck::get_sys_bit::Y_N ].bind(itl1[itl::sck::deinterleave::nat]);\n+ lcrc[lop::sck::stop ::in1 ].bind(ext1[ext::sck::get_sys_bit ::V_K]);\n+ lcrc[lop::sck::stop ::in_out1].bind(itl1[itl::sck::deinterleave::nat]);\n+ }\n+ else\n+ lite[lop::sck::stop::in_out1].bind(itl1[itl::sck::deinterleave::nat]);\n+\n+ // ------------------------------------------------------------------------------------------------------- decoding\n+ if (this->params_BFER_ite.coset)\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ csr1[cst::sck::apply::in].bind(lcrc[lop::sck::stop::in_out1]);\n+ else\n+ csr1[cst::sck::apply::in].bind(lite[lop::sck::stop::in_out1]);\n+\n+ dcs [dec::sck::decode_siso::Y_N1].bind(csr1[cst::sck::apply ::out ]);\n+ csr2[cst::sck::apply ::in ].bind(dcs [dec::sck::decode_siso::Y_N2]);\n+ }\n+ else\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ dcs[dec::sck::decode_siso::Y_N1].bind(lcrc[lop::sck::stop::in_out1]);\n+ else\n+ dcs[dec::sck::decode_siso::Y_N1].bind(lite[lop::sck::stop::in_out1]);\n+ }\n+\n+ // --------------------------------------------------------------------------------------------------- interleaving\n+ if (this->params_BFER_ite.coset)\n+ itl2[itl::sck::interleave::nat].bind(csr2[cst::sck::apply::out]);\n+ else\n+ itl2[itl::sck::interleave::nat].bind(dcs[dec::sck::decode_siso::Y_N2]);\n+\n+ // --------------------------------------------------------------------------------------------------- demodulation\n+ if (mdm2.is_demodulator())\n+ {\n+ if (is_rayleigh)\n+ {\n+ if (this->params_BFER_ite.chn->type != \"NO\")\n+ mdm2[mdm::sck::tdemodulate_wg::H_N].bind(chn[chn::sck::add_noise_wg::H_N]);\n+ else\n+ mdm2[mdm::sck::tdemodulate_wg::H_N].bind((uint8_t*)(chn[chn::sck::add_noise_wg::H_N].get_dataptr()));\n+\n+ if (this->params_BFER_ite.qnt->type != \"NO\")\n+ mdm2[mdm::sck::tdemodulate_wg::Y_N1].bind(qnt[qnt::sck::process::Y_N2]);\n+ else if (mdm1.is_filter())\n+ mdm2[mdm::sck::tdemodulate_wg::Y_N1].bind(mdm1[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_ite.chn->type != \"NO\")\n+ mdm2[mdm::sck::tdemodulate_wg::Y_N1].bind(chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ mdm2[mdm::sck::tdemodulate_wg::Y_N1].bind(mdm1[mdm::sck::modulate::X_N2]);\n+\n+ mdm2[mdm::sck::tdemodulate_wg::Y_N2].bind(itl2[itl::sck::interleave::itl]);\n+ }\n+ else\n+ {\n+ if (this->params_BFER_ite.qnt->type != \"NO\")\n+ mdm2[mdm::sck::tdemodulate::Y_N1].bind(qnt[qnt::sck::process::Y_N2]);\n+ else if (mdm1.is_filter())\n+ mdm2[mdm::sck::tdemodulate::Y_N1].bind(mdm1[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_ite.chn->type != \"NO\")\n+ mdm2[mdm::sck::tdemodulate::Y_N1].bind(chn[chn::sck::add_noise::Y_N]);\n+ else\n+ mdm2[mdm::sck::tdemodulate::Y_N1].bind(mdm1[mdm::sck::modulate::X_N2]);\n+\n+ mdm2[mdm::sck::tdemodulate::Y_N2].bind(itl2[itl::sck::interleave::itl ]);\n+ }\n+ }\n+\n+ // ------------------------------------------------------------------------------------------------- deinterleaving\n+ if (mdm2.is_demodulator())\n+ {\n+ if (is_rayleigh)\n+ itl2[itl::sck::deinterleave::itl].bind(mdm2[mdm::sck::tdemodulate_wg::Y_N3]);\n+ else\n+ itl2[itl::sck::deinterleave::itl].bind(mdm2[mdm::sck::tdemodulate::Y_N3]);\n+ }\n+ else if (this->params_BFER_ite.qnt->type != \"NO\")\n+ itl2[itl::sck::deinterleave::itl].bind(qnt[qnt::sck::process::Y_N2]);\n+ else if (mdm1.is_filter())\n+ itl2[itl::sck::deinterleave::itl].bind(mdm1[mdm::sck::filter::Y_N2]);\n+ else if (this->params_BFER_ite.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ itl2[itl::sck::deinterleave::itl].bind(chn[chn::sck::add_noise_wg::Y_N]);\n+ else\n+ itl2[itl::sck::deinterleave::itl].bind(chn[chn::sck::add_noise::Y_N]);\n+ }\n+ else\n+ itl2[itl::sck::deinterleave::itl].bind(mdm1[mdm::sck::modulate::X_N2]);\n+\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ {\n+ if (this->params_BFER_ite.coset)\n+ ext2[ext::sck::get_sys_bit::Y_N].bind(dcs[dec::sck::decode_siso::Y_N2]);\n+ else\n+ ext2[ext::sck::get_sys_bit::Y_N].bind(itl2[itl::sck::deinterleave::nat]);\n+\n+ lcrc[lop::sck::stop::in2 ].bind(ext2[ext::sck::get_sys_bit ::V_K]);\n+ lcrc[lop::sck::stop::in_out2].bind(itl2[itl::sck::deinterleave::nat]);\n+ }\n+ else\n+ lite[lop::sck::stop::in_out2].bind(itl2[itl::sck::deinterleave::nat]);\n+\n+ // ----------------------------------------------------------------------------------------------------------------\n+ // --------------------------------------------------------------------------------- end of turbo demodulation loop\n+ // ----------------------------------------------------------------------------------------------------------------\n+\n+ if (this->params_BFER_ite.coset)\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ csr3[cst::sck::apply::in].bind(lcrc[lop::sck::stop::in_out2]);\n+ else\n+ csr3[cst::sck::apply::in].bind(lite[lop::sck::stop::in_out2]);\n+\n+ if (this->params_BFER_ite.coded_monitoring)\n+ {\n+ dch[dec::sck::decode_siho_cw::Y_N].bind(csr3[cst::sck::apply ::out]);\n+ csb[cst::sck::apply ::in ].bind(dch [dec::sck::decode_siho_cw::V_N]);\n+ }\n+ else\n+ {\n+ dch[dec::sck::decode_siho::Y_N ].bind(csr3[cst::sck::apply ::out]);\n+ csb[cst::sck::apply ::in ].bind(dch [dec::sck::decode_siho::V_K]);\n+ crc[crc::sck::extract ::V_K1].bind(csb [cst::sck::apply ::out]);\n+ }\n+ }\n+ else\n+ {\n+ if (this->params_BFER_ite.coded_monitoring)\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ dch[dec::sck::decode_siho_cw::Y_N].bind(lcrc[lop::sck::stop::in_out2]);\n+ else\n+ dch[dec::sck::decode_siho_cw::Y_N].bind(lite[lop::sck::stop::in_out2]);\n+ }\n+ else\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ dch[dec::sck::decode_siho::Y_N].bind(lcrc[lop::sck::stop::in_out2]);\n+ else\n+ dch[dec::sck::decode_siho::Y_N].bind(lite[lop::sck::stop::in_out2]);\n+\n+ crc[crc::sck::extract::V_K1].bind(dch[dec::sck::decode_siho::V_K]);\n+ }\n+ }\n+\n+ if (this->params_BFER_ite.coded_monitoring)\n+ {\n+ if (this->params_BFER_ite.coset)\n+ mnt[mnt::sck::check_errors::V].bind(csb[cst::sck::apply::out]);\n+ else\n+ mnt[mnt::sck::check_errors::V].bind(dch[dec::sck::decode_siho_cw::V_N]);\n+ }\n+ else\n+ {\n+ if (this->params_BFER_ite.crc->type != \"NO\")\n+ mnt[mnt::sck::check_errors::V].bind(crc[crc::sck::extract::V_K2]);\n+ else\n+ {\n+ if (this->params_BFER_ite.coset)\n+ mnt[mnt::sck::check_errors::V].bind(csb[cst::sck::apply::out]);\n+ else\n+ mnt[mnt::sck::check_errors::V].bind(dch[dec::sck::decode_siho::V_K]);\n+ }\n+ }\n+}\n+\n+template <typename B, typename R, typename Q>\n+void Simulation_chain_BFER_ite<B,R,Q>\n+::create_chain()\n+{\n+ const auto is_rayleigh = this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos;\n+ const auto t = this->params_BFER.n_threads;\n+ if (this->params_BFER_ite.src->type != \"AZCW\")\n+ this->chain.reset(new tools::Chain((*this->source)[module::src::tsk::generate], t));\n+ else if (this->params_BFER_ite.chn->type != \"NO\")\n+ {\n+ if (is_rayleigh)\n+ this->chain.reset(new tools::Chain((*this->channel)[module::chn::tsk::add_noise_wg], t));\n+ else\n+ this->chain.reset(new tools::Chain((*this->channel)[module::chn::tsk::add_noise], t));\n+ }\n+ else if (this->modem1->is_filter())\n+ this->chain.reset(new tools::Chain((*this->modem1)[module::mdm::tsk::filter], t));\n+ else if (this->params_BFER_ite.qnt->type != \"NO\")\n+ this->chain.reset(new tools::Chain((*this->quantizer)[module::qnt::tsk::process], t));\n+ else if (this->modem1->is_demodulator())\n+ {\n+ if (is_rayleigh)\n+ this->chain.reset(new tools::Chain((*this->modem1)[module::mdm::tsk::demodulate_wg], t));\n+ else\n+ this->chain.reset(new tools::Chain((*this->modem1)[module::mdm::tsk::demodulate], t));\n+ }\n+ else\n+ this->chain.reset(new tools::Chain((*this->interleaver_llr1)[module::itl::tsk::deinterleave], t));\n+\n+ // set the noise\n+ this->codec1->set_noise(*this->noise);\n+ this->codec2->set_noise(*this->noise);\n+ for (auto &m : this->chain->template get_modules<tools::Interface_get_set_noise>())\n+ m->set_noise(*this->noise);\n+\n+ // registering to noise updates\n+ this->noise->record_callback_update([this](){ this->codec1->notify_noise_update(); });\n+ this->noise->record_callback_update([this](){ this->codec2->notify_noise_update(); });\n+ for (auto &m : this->chain->template get_modules<tools::Interface_notify_noise_update>())\n+ this->noise->record_callback_update([m](){ m->notify_noise_update(); });\n+\n+ // set different seeds in the modules that uses PRNG\n+ std::mt19937 prng(params_BFER_ite.local_seed);\n+ for (auto &m : this->chain->template get_modules<tools::Interface_set_seed>())\n+ m->set_seed(prng());\n+\n+ this->interleaver_core->set_seed(params_BFER_ite.itl->core->seed);\n+ if (this->interleaver_core->is_uniform())\n+ {\n+ std::stringstream message;\n+ message << \"Please use the legacy simulator engine for uniform interleaving (remove the '--sim-chain' \"\n+ << \"argument from the command line).\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto monitors_er = this->chain->template get_modules<module::Monitor_BFER <B >>();\n+ auto decoders_siso = this->chain->template get_modules<module::Decoder_SISO <B,Q>>();\n+ auto loops_ite = this->chain->template get_modules<module::Loop_predicate<Q >>();\n+ auto loops_crc = this->chain->template get_modules<module::Loop_CRC <B,Q>>();\n+ for (size_t m = 0; m < monitors_er.size(); m++)\n+ {\n+ auto cur_monitor_er = monitors_er[m];\n+\n+ if (m < decoders_siso.size())\n+ {\n+ auto cur_decoder_siso = decoders_siso[m];\n+ cur_decoder_siso->set_auto_reset(false);\n+ cur_monitor_er->record_callback_check([cur_decoder_siso](){ cur_decoder_siso->reset(); });\n+ }\n+\n+ if (m < loops_ite.size())\n+ {\n+ auto cur_loop_ite = loops_ite[m];\n+ cur_monitor_er->record_callback_check([cur_loop_ite](){ cur_loop_ite->reset(); });\n+ }\n+\n+ if (m < loops_crc.size())\n+ {\n+ auto cur_loop_crc = loops_crc[m];\n+ cur_monitor_er->record_callback_check([cur_loop_crc](){ cur_loop_crc->reset(); });\n+ }\n+ }\n+\n+ if (this->params_BFER_ite.err_track_enable)\n+ {\n+ auto sources = this->chain->template get_modules<module::Source<B>>();\n+ for (size_t tid = 0; tid < (size_t)this->params_BFER.n_threads; tid++)\n+ {\n+ auto &source = sources.size() ? *sources[tid] : *this->source;\n+ auto src_data = (B*)(source[module::src::sck::generate::U_K].get_dataptr());\n+ auto src_bytes = source[module::src::sck::generate::U_K].get_databytes();\n+ auto src_size = (src_bytes / sizeof(B)) / this->params_BFER_ite.src->n_frames;\n+ this->dumper[tid]->register_data(src_data,\n+ (unsigned int)src_size,\n+ this->params_BFER_ite.err_track_threshold,\n+ \"src\",\n+ false,\n+ this->params_BFER_ite.src->n_frames,\n+ {});\n+ }\n+\n+ auto encoders = this->chain->template get_modules<module::Encoder<B>>();\n+ for (size_t tid = 0; tid < (size_t)this->params_BFER.n_threads; tid++)\n+ {\n+ auto &encoder = encoders.size() ? *encoders[tid] : this->codec1->get_encoder();\n+ auto enc_data = (B*)(encoder[module::enc::sck::encode::X_N].get_dataptr());\n+ auto enc_bytes = encoder[module::enc::sck::encode::X_N].get_databytes();\n+ auto enc_size = (enc_bytes / sizeof(B)) / this->params_BFER_ite.src->n_frames;\n+ this->dumper[tid]->register_data(enc_data,\n+ (unsigned int)enc_size,\n+ this->params_BFER_ite.err_track_threshold,\n+ \"enc\",\n+ false,\n+ this->params_BFER_ite.src->n_frames,\n+ {(unsigned)this->params_BFER_ite.cdc->enc->K});\n+ }\n+\n+ auto channels = this->chain->template get_modules<module::Channel<R>>();\n+ for (size_t tid = 0; tid < (size_t)this->params_BFER.n_threads; tid++)\n+ {\n+ auto &channel = channels.size() ? *channels[tid] : *this->channel;\n+ this->dumper[tid]->register_data(channel.get_noised_data(),\n+ this->params_BFER_ite.err_track_threshold,\n+ \"chn\",\n+ true,\n+ this->params_BFER_ite.src->n_frames,\n+ {});\n+ }\n+\n+ for (size_t tid = 0; tid < (size_t)this->params_BFER.n_threads; tid++)\n+ {\n+ monitors_er[tid]->record_callback_fe(std::bind(&tools::Dumper::add,\n+ this->dumper[tid].get(),\n+ std::placeholders::_1,\n+ std::placeholders::_2));\n+ }\n+ }\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef AFF3CT_MULTI_PREC\n+template class aff3ct::simulation::Simulation_chain_BFER_ite<B_8,R_8,Q_8>;\n+template class aff3ct::simulation::Simulation_chain_BFER_ite<B_16,R_16,Q_16>;\n+template class aff3ct::simulation::Simulation_chain_BFER_ite<B_32,R_32,Q_32>;\n+template class aff3ct::simulation::Simulation_chain_BFER_ite<B_64,R_64,Q_64>;\n+#else\n+template class aff3ct::simulation::Simulation_chain_BFER_ite<B,R,Q>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.hpp",
"diff": "+#ifndef SIMULATION_CHAIN_BFER_ITE_HPP_\n+#define SIMULATION_CHAIN_BFER_ITE_HPP_\n+\n+#include <memory>\n+\n+#include \"Module/Source/Source.hpp\"\n+#include \"Module/CRC/CRC.hpp\"\n+#include \"Module/Modem/Modem.hpp\"\n+#include \"Module/Channel/Channel.hpp\"\n+#include \"Module/Quantizer/Quantizer.hpp\"\n+#include \"Module/Coset/Coset.hpp\"\n+#include \"Module/Interleaver/Interleaver.hpp\"\n+#include \"Module/Loop/Predicate/Loop_predicate.hpp\"\n+#include \"Module/Loop/CRC/Loop_CRC.hpp\"\n+#include \"Tools/Interleaver/Interleaver_core.hpp\"\n+#include \"Tools/Codec/Codec_SISO.hpp\"\n+#include \"Tools/Constellation/Constellation.hpp\"\n+#include \"Tools/Math/Distribution/Distributions.hpp\"\n+#include \"Factory/Simulation/BFER/BFER_ite.hpp\"\n+#include \"Simulation/Chain/BFER/Simulation_chain_BFER.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace simulation\n+{\n+\n+template <typename B = int, typename R = float, typename Q = R>\n+class Simulation_chain_BFER_ite : public Simulation_chain_BFER<B,R>\n+{\n+protected:\n+ const factory::BFER_ite ¶ms_BFER_ite;\n+\n+ // communication chain\n+ std::unique_ptr<module::Source <B >> source;\n+ std::unique_ptr<module::CRC <B >> crc;\n+ std::unique_ptr<tools ::Codec_SISO <B, Q>> codec1;\n+ std::unique_ptr<tools ::Codec_SISO <B, Q>> codec2;\n+ std::unique_ptr<module::Modem <B,R,Q>> modem1;\n+ std::unique_ptr<module::Modem <B,R,Q>> modem2;\n+ std::unique_ptr<module::Channel <R >> channel;\n+ std::unique_ptr<module::Quantizer <R,Q >> quantizer;\n+ std::unique_ptr<module::Coset <B,Q >> coset_real1;\n+ std::unique_ptr<module::Coset <B,Q >> coset_real2;\n+ std::unique_ptr<module::Coset <B,Q >> coset_real3;\n+ std::unique_ptr<module::Coset <B,B >> coset_bit;\n+ std::unique_ptr<tools ::Interleaver_core< >> interleaver_core;\n+ std::unique_ptr<module::Interleaver <B >> interleaver_bit;\n+ std::unique_ptr<module::Interleaver <Q >> interleaver_llr1;\n+ std::unique_ptr<module::Interleaver <Q >> interleaver_llr2;\n+ std::shared_ptr<module::Loop_predicate <Q >> loop_ite;\n+ std::shared_ptr<module::Loop_CRC <B,Q >> loop_crc;\n+\n+public:\n+ explicit Simulation_chain_BFER_ite(const factory::BFER_ite ¶ms_BFER_ite);\n+ virtual ~Simulation_chain_BFER_ite() = default;\n+\n+protected:\n+ std::unique_ptr<module::Source <B >> build_source ( );\n+ std::unique_ptr<module::CRC <B >> build_crc ( );\n+ std::unique_ptr<tools ::Codec_SISO <B,Q >> build_codec (const module::CRC <B> *crc );\n+ std::unique_ptr<module::Modem <B,R,Q>> build_modem (const tools::Distributions<R> *distributions,\n+ const tools::Constellation<R> *constellation);\n+ std::unique_ptr<module::Channel <R >> build_channel (const tools::Distributions<R> *distributions);\n+ std::unique_ptr<module::Quantizer <R,Q >> build_quantizer ( );\n+ std::unique_ptr<module::Coset <B,Q >> build_coset_real ( );\n+ std::unique_ptr<module::Coset <B,B >> build_coset_bit ( );\n+ std::unique_ptr<tools ::Interleaver_core< >> build_interleaver( );\n+ std::unique_ptr<module::Loop_predicate <Q >> build_loop_ite ( );\n+ std::unique_ptr<module::Loop_CRC <B,Q >> build_loop_crc ( );\n+\n+ virtual void create_modules();\n+ virtual void bind_sockets();\n+ virtual void create_chain();\n+};\n+\n+}\n+}\n+\n+#endif /* SIMULATION_CHAIN_BFER_ITE_HPP_ */\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -199,8 +199,6 @@ void Chain\nif (bs != nullptr)\n{\nauto &t = bs->get_task();\n- std::cout << \"[in]: sname = \" << s->get_name() << \", tname = \" << s->get_task().get_name() << \" - \";\n- std::cout << \"[out]: sname = \" << bs->get_name() << \", tname = \" << t.get_name() << std::endl;;\nif (t.is_last_input_socket(*bs))\nChain::init_recursive(tasks_sequence, first, t, last);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the BFER iterative simulation with chain (not working).
|
8,490 |
10.12.2019 10:33:00
| -3,600 |
9d0ac40896482e797f04b0b9e1e435af2835e207
|
Add the first loop support to the chain.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hxx",
"new_path": "include/Module/Socket.hxx",
"diff": "@@ -140,7 +140,7 @@ void Socket\n}\n}\n- this->bound_sockets.push_back(&s);\n+ // this->bound_sockets.push_back(&s);\ns.bound_sockets.push_back(this);\nif (copy_dataptr)\nthis->dataptr = s.dataptr;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -25,18 +25,24 @@ class Module;\nnamespace tools\n{\n+enum class subseq_t : size_t { STD, LOOP, ROUTER };\n+\nclass Chain : Interface_clone\n{\nprotected:\nsize_t n_threads;\n- std::vector<std::vector<module::Task*>> tasks_sequences;\n+ std::vector<std::vector<std::vector<module::Task*>>> tasks_sequences;\nstd::vector<std::vector<std::shared_ptr<module::Module>>> modules;\n+ std::vector<subseq_t> subseq_types;\nstd::shared_ptr<std::mutex> mtx_exception;\nstd::vector<std::string> prev_exception_messages;\nstd::vector<std::string> prev_exception_messages_to_display;\nstd::shared_ptr<std::atomic<bool>> force_exit_loop;\n+ size_t n_tasks;\n+ std::vector<std::vector<size_t>> task_id;\n+\npublic:\nChain(const module::Task &first, const size_t n_threads = 1);\nChain(const module::Task &first, const module::Task &last, const size_t n_threads = 1);\n@@ -52,25 +58,29 @@ public:\nstd::vector<C*> get_modules(const bool subchain_modules = true) const;\nstd::vector<std::vector<const module::Module*>> get_modules_per_threads() const;\nstd::vector<std::vector<const module::Module*>> get_modules_per_types () const;\n- inline const std::vector<std::vector<module::Task*>>& get_tasks_sequences() const;\n- inline const std::vector<module::Task*>& get_tasks_sequence(const int tid = 0) const;\n+ inline const std::vector<std::vector<std::vector<module::Task*>>>& get_tasks_sequences() const;\n+ inline const std::vector<std::vector<module::Task*>>& get_tasks_sequence(const int tid = 0) const;\nvoid export_dot(std::ostream &stream = std::cout) const;\nprotected:\nvoid export_dot_subsequence(const std::vector<module::Task*> &subseq,\n+ const subseq_t &subseq_type,\nconst std::string &subseq_name,\nconst std::string &tab,\nstd::ostream &stream) const;\n- static void init_recursive(std::vector<const module::Task*> &tasks_sequence,\n+ static void init_recursive(std::vector<std::vector<const module::Task*>> &tasks_sequence,\n+ const size_t ssid,\n+ std::vector<subseq_t> &subseq_type,\n+ std::vector<const module::Task*> &loops,\nconst module::Task& first,\nconst module::Task& current_task,\nconst module::Task *last = nullptr);\nvoid _exec(std::function<bool(const std::vector<int>&)> &stop_condition,\n- std::vector<module::Task*> &tasks_sequence);\n+ std::vector<std::vector<module::Task*>> &tasks_sequence);\nvoid _exec_without_statuses(std::function<bool()> &stop_condition,\n- std::vector<module::Task*> &tasks_sequence);\n- void duplicate(const std::vector<const module::Task*> &tasks_sequence);\n+ std::vector<std::vector<module::Task*>> &tasks_sequence);\n+ void duplicate(const std::vector<std::vector<const module::Task*>> &tasks_sequence);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hxx",
"new_path": "include/Tools/Chain/Chain.hxx",
"diff": "@@ -37,13 +37,13 @@ std::vector<C*> Chain\nreturn ret;\n}\n-const std::vector<std::vector<module::Task*>>& Chain\n+const std::vector<std::vector<std::vector<module::Task*>>>& Chain\n::get_tasks_sequences() const\n{\nreturn this->tasks_sequences;\n}\n-const std::vector<module::Task*>& Chain\n+const std::vector<std::vector<module::Task*>>& Chain\n::get_tasks_sequence(const int tid) const\n{\nreturn this->tasks_sequences[tid];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Subchain/Subchain.cpp",
"new_path": "src/Module/Subchain/Subchain.cpp",
"diff": "@@ -10,7 +10,7 @@ using namespace aff3ct::module;\nSubchain\n::Subchain(const tools::Chain &chain)\n-: Module(chain.get_tasks_sequence().front()->get_module().get_n_frames()),\n+: Module(chain.get_tasks_sequence().front().front()->get_module().get_n_frames()),\nchain(chain.clone())\n{\nconst std::string name = \"Subchain\";\n@@ -28,7 +28,7 @@ Subchain\nauto &p = this->create_task(\"exec\");\np.set_autoalloc(true);\n- auto &first = *this->chain->get_tasks_sequence().front();\n+ auto &first = *this->chain->get_tasks_sequence().front().front();\nfor (auto &s : first.sockets)\n{\nif (first.get_socket_type(*s) == socket_t::SIN)\n@@ -62,7 +62,7 @@ Subchain\nthis->template create_socket_in_out<double >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n}\n}\n- auto &last = *this->chain->get_tasks_sequence().back();\n+ auto &last = *this->chain->get_tasks_sequence().back().back();\nfor (auto &s : last.sockets)\n{\nif (last.get_socket_type(*s) == socket_t::SOUT)\n@@ -122,7 +122,7 @@ Subchain\n{\nauto &c = static_cast<Subchain&>(m);\n- auto &first = *c.chain->get_tasks_sequence().front();\n+ auto &first = *c.chain->get_tasks_sequence().front().front();\nsize_t sid = 0;\nfor (auto &s : first.sockets)\n{\n@@ -167,7 +167,7 @@ void Subchain\nModule::deep_copy(m);\nif (m.chain != nullptr) this->chain.reset(m.chain->clone());\n- auto &last = *this->chain->get_tasks_sequence().back();\n+ auto &last = *this->chain->get_tasks_sequence().back().back();\nauto &p = (*this)[sch::tsk::exec];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.cpp",
"new_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.cpp",
"diff": "@@ -532,6 +532,7 @@ void Simulation_chain_BFER_ite<B,R,Q>\n{\ndch[dec::sck::decode_siho::Y_N].bind(csr3[cst::sck::apply ::out]);\ncsb[cst::sck::apply ::in ].bind(dch [dec::sck::decode_siho::V_K]);\n+ if (this->params_BFER_ite.crc->type != \"NO\")\ncrc[crc::sck::extract::V_K1].bind(csb[cst::sck::apply::out]);\n}\n}\n@@ -551,6 +552,7 @@ void Simulation_chain_BFER_ite<B,R,Q>\nelse\ndch[dec::sck::decode_siho::Y_N].bind(lite[lop::sck::stop::in_out2]);\n+ if (this->params_BFER_ite.crc->type != \"NO\")\ncrc[crc::sck::extract::V_K1].bind(dch[dec::sck::decode_siho::V_K]);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "#include <sstream>\n#include <cstring>\n#include <exception>\n+#include <algorithm>\n#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Module.hpp\"\n#include \"Module/Task.hpp\"\n#include \"Module/Socket.hpp\"\n+#include \"Module/Loop/Loop.hpp\"\n+#include \"Module/Router/Router.hpp\"\n#include \"Tools/Chain/Chain.hpp\"\nusing namespace aff3ct;\n@@ -28,19 +31,40 @@ Chain\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- std::vector<const module::Task*> tasks_sequence;\n- this->init_recursive(tasks_sequence, first, first, &last);\n- if (tasks_sequence.back() != &last)\n+ std::vector<std::vector<const module::Task*>> tasks_sequence;\n+ tasks_sequence.push_back(std::vector<const module::Task*>());\n+ std::vector<const module::Task*> loops;\n+ this->init_recursive(tasks_sequence, 0, this->subseq_types, loops, first, first, &last);\n+ if (tasks_sequence.back().back() != &last)\n{\nstd::stringstream message;\n- message << \"'tasks_sequence.back()' has to be equal to '&last' (\"\n- << \"'tasks_sequence.back()'\" << \" = \" << +tasks_sequence.back() << \", \"\n+ message << \"'tasks_sequence.back().back()' has to be equal to '&last' (\"\n+ << \"'tasks_sequence.back().back()'\" << \" = \" << +tasks_sequence.back().back() << \", \"\n<< \"'&last'\" << \" = \" << +&last << \", \"\n- << \"'tasks_sequence.back()->get_name()'\" << \" = \" << tasks_sequence.back()->get_name() << \", \"\n+ << \"'tasks_sequence.back().back()->get_name()'\" << \" = \" << tasks_sequence.back().back()->get_name() << \", \"\n<< \"'last.get_name()'\" << \" = \" << last.get_name() << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\nthis->duplicate(tasks_sequence);\n+ for (auto &ts : this->tasks_sequences)\n+ for (size_t ss = 0; ss < ts.size(); ss++)\n+ if (this->subseq_types[ss] == subseq_t::LOOP)\n+ {\n+ auto loop = ts[ss].back();\n+ ts[ss].pop_back();\n+ ts[ss].insert(ts[ss].begin(), loop);\n+ }\n+\n+ this->n_tasks = 0;\n+ this->task_id.resize(tasks_sequence.size());\n+ size_t id = 0;\n+ for (size_t ss = 0; ss < tasks_sequence.size(); ss++)\n+ {\n+ this->n_tasks += tasks_sequence[ss].size();\n+ this->task_id[ss].resize(tasks_sequence[ss].size());\n+ for (size_t ta = 0; ta < tasks_sequence[ss].size(); ta++)\n+ this->task_id[ss][ta] = id++;\n+ }\n}\nChain\n@@ -58,18 +82,43 @@ Chain\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- std::vector<const module::Task*> tasks_sequence;\n- this->init_recursive(tasks_sequence, first, first);\n+ std::vector<std::vector<const module::Task*>> tasks_sequence;\n+ tasks_sequence.push_back(std::vector<const module::Task*>());\n+ std::vector<const module::Task*> loops;\n+ this->init_recursive(tasks_sequence, 0, this->subseq_types, loops, first, first);\nthis->duplicate(tasks_sequence);\n+ for (auto &ts : this->tasks_sequences)\n+ for (size_t ss = 0; ss < ts.size(); ss++)\n+ if (this->subseq_types[ss] == subseq_t::LOOP)\n+ {\n+ auto loop = ts[ss].back();\n+ ts[ss].pop_back();\n+ ts[ss].insert(ts[ss].begin(), loop);\n+ }\n+\n+ this->n_tasks = 0;\n+ this->task_id.resize(tasks_sequence.size());\n+ size_t id = 0;\n+ for (size_t ss = 0; ss < tasks_sequence.size(); ss++)\n+ {\n+ this->n_tasks += tasks_sequence[ss].size();\n+ this->task_id[ss].resize(tasks_sequence[ss].size());\n+ for (size_t ta = 0; ta < tasks_sequence[ss].size(); ta++)\n+ this->task_id[ss][ta] = id++;\n+ }\n}\nChain* Chain\n::clone() const\n{\nauto c = new Chain(*this);\n- std::vector<const module::Task*> tasks_sequence;\n- for (size_t t = 0; t < this->tasks_sequences[0].size(); t++)\n- tasks_sequence.push_back(this->tasks_sequences[0][t]);\n+ std::vector<std::vector<const module::Task*>> tasks_sequence;\n+ for (size_t ss = 0; ss < this->tasks_sequences[0].size(); ss++)\n+ {\n+ tasks_sequence.push_back(std::vector<const module::Task*>());\n+ for (size_t t = 0; t < this->tasks_sequences[0][ss].size(); t++)\n+ tasks_sequence[ss].push_back(this->tasks_sequences[0][ss][t]);\n+ }\nc->duplicate(tasks_sequence);\nc->mtx_exception.reset(new std::mutex());\nc->force_exit_loop.reset(new std::atomic<bool>(false));\n@@ -78,6 +127,7 @@ Chain* Chain\nvoid Chain\n::export_dot_subsequence(const std::vector<module::Task*> &subseq,\n+ const subseq_t &subseq_type,\nconst std::string &subseq_name,\nconst std::string &tab,\nstd::ostream &stream) const\n@@ -87,6 +137,7 @@ void Chain\nstream << tab << \"subgraph \\\"cluster_\" << subseq_name << \"\\\" {\" << std::endl;\nstream << tab << tab << \"node [style=filled];\" << std::endl;\n}\n+ size_t exec_order = 0;\nfor (auto &t : subseq)\n{\nstream << tab << tab << \"subgraph \\\"cluster_\" << +&t->get_module() << \"_\" << +&t << \"\\\" {\" << std::endl;\n@@ -109,15 +160,17 @@ void Chain\nstream << tab << tab << tab << tab << \"label=\\\"\" << t->get_name() << \"\\\";\" << std::endl;\nstream << tab << tab << tab << tab << \"color=blue;\" << std::endl;\nstream << tab << tab << tab << \"}\" << std::endl;\n- stream << tab << tab << tab << \"label=\\\"\" << t->get_module().get_name() << \"\\n\" << +&t->get_module() << \"\\\";\"\n- << std::endl;\n+ stream << tab << tab << tab << \"label=\\\"\" << t->get_module().get_name() << \"\\n\"\n+ << \"exec order: [\" << exec_order++ << \"]\\n\"\n+ << \"addr: \" << +&t->get_module() << \"\\\";\" << std::endl;\nstream << tab << tab << tab << \"color=blue;\" << std::endl;\nstream << tab << tab << \"}\" << std::endl;\n}\nif (!subseq_name.empty())\n{\nstream << tab << tab << \"label=\\\"\" << subseq_name << \"\\\";\" << std::endl;\n- stream << tab << tab << \"color=blue;\" << std::endl;\n+ std::string color = subseq_type == subseq_t::LOOP ? \"red\" : \"blue\";\n+ stream << tab << tab << \"color=\" << color << \";\" << std::endl;\nstream << tab << \"}\" << std::endl;\n}\n}\n@@ -128,10 +181,15 @@ void Chain\nstd::string tab = \"\\t\";\nstream << \"digraph Chain {\" << std::endl;\n- std::string subseq_name = \"\"; // \"Sub-sequence1\"\n- this->export_dot_subsequence(this->tasks_sequences[0], subseq_name, tab, stream);\n+ for (size_t ss = 0; ss < this->tasks_sequences[0].size(); ss++)\n+ {\n+ std::string subseq_name = this->tasks_sequences[0].size() == 1 ? \"\" : \"Sub-sequence\"+std::to_string(ss);\n+ this->export_dot_subsequence(this->tasks_sequences[0][ss], this->subseq_types[ss], subseq_name, tab, stream);\n+ }\n- auto &tasks_sequence = this->tasks_sequences[0];\n+ for (size_t ss = 0; ss < this->tasks_sequences[0].size(); ss++)\n+ {\n+ auto &tasks_sequence = this->tasks_sequences[0][ss];\nfor (auto &t : tasks_sequence)\n{\nfor (auto &s : t->sockets)\n@@ -146,6 +204,7 @@ void Chain\n}\n}\n}\n+ }\nstream << \"}\" << std::endl;\n}\n@@ -167,7 +226,6 @@ std::vector<std::vector<const module::Module*>> Chain\nstd::vector<std::vector<const module::Module*>> Chain\n::get_modules_per_types() const\n{\n-\nstd::vector<std::vector<const module::Module*>> modules_per_types(modules[0].size());\nfor (auto &e : modules)\n{\n@@ -179,59 +237,27 @@ std::vector<std::vector<const module::Module*>> Chain\n}\nvoid Chain\n-::init_recursive(std::vector<const module::Task*> &tasks_sequence,\n- const module::Task& first,\n- const module::Task& current_task,\n- const module::Task *last)\n-{\n- tasks_sequence.push_back(¤t_task);\n-\n- if (¤t_task != last)\n+::_exec(std::function<bool(const std::vector<int>&)> &stop_condition, std::vector<std::vector<module::Task*>> &tasks_sequence)\n{\n- for (auto &s : current_task.sockets)\n- {\n- if (current_task.get_socket_type(*s) == module::socket_t::SIN_SOUT ||\n- current_task.get_socket_type(*s) == module::socket_t::SOUT)\n+ try\n{\n- auto bss = s->get_bound_sockets();\n- for (auto &bs : bss)\n+ std::vector<int> statuses(this->n_tasks, 0);\n+ do\n{\n- if (bs != nullptr)\n+ for (size_t ss = 0; ss < tasks_sequence.size(); ss++)\n+ if (this->subseq_types[ss] == subseq_t::LOOP)\n{\n- auto &t = bs->get_task();\n- if (t.is_last_input_socket(*bs))\n- Chain::init_recursive(tasks_sequence, first, t, last);\n+ while (!(statuses[this->task_id[ss][0]] = tasks_sequence[ss][0]->exec()))\n+ for (size_t ta = 1; ta < tasks_sequence[ss].size(); ta++)\n+ statuses[this->task_id[ss][ta]] = tasks_sequence[ss][ta]->exec();\n}\n- }\n- }\n- else if (current_task.get_socket_type(*s) == module::socket_t::SIN)\n- {\n- if (s->get_bound_sockets().size() > 1)\n+ else\n{\n- std::stringstream message;\n- message << \"'s->get_bound_sockets().size()' has to be smaller or equal to 1 (\"\n- << \"'s->get_bound_sockets().size()'\" << \" = \" << s->get_bound_sockets().size() << \", \"\n- << \"'get_socket_type(*s)'\" << \" = \" << \"socket_t::SIN\" << \", \"\n- << \"'s->get_name()'\" << \" = \" << s->get_name() << \", \"\n- << \"'s->get_task().get_name()'\" << \" = \" << s->get_task().get_name() << \", \"\n- << \"'s->get_task().get_module().get_name()'\" << \" = \" << s->get_task().get_module().get_name()\n- << \").\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n- }\n- }\n+ for (size_t ta = 0; ta < tasks_sequence[ss].size(); ta++)\n+ statuses[this->task_id[ss][ta]] = tasks_sequence[ss][ta]->exec();\n}\n}\n-\n-void Chain\n-::_exec(std::function<bool(const std::vector<int>&)> &stop_condition, std::vector<module::Task*> &tasks_sequence)\n-{\n- try\n- {\n- std::vector<int> statuses(tasks_sequence.size(), 0);\n- while (!*force_exit_loop && !stop_condition(statuses))\n- for (size_t ta = 0; ta < tasks_sequence.size(); ta++)\n- statuses[ta] = tasks_sequence[ta]->exec();\n+ while (!*force_exit_loop && !stop_condition(statuses));\n}\ncatch (std::exception const& e)\n{\n@@ -258,13 +284,26 @@ void Chain\n}\nvoid Chain\n-::_exec_without_statuses(std::function<bool()> &stop_condition, std::vector<module::Task*> &tasks_sequence)\n+::_exec_without_statuses(std::function<bool()> &stop_condition, std::vector<std::vector<module::Task*>> &tasks_sequence)\n{\ntry\n{\n- while (!*force_exit_loop && !stop_condition())\n- for (size_t ta = 0; ta < tasks_sequence.size(); ta++)\n- tasks_sequence[ta]->exec();\n+ do\n+ {\n+ for (size_t ss = 0; ss < tasks_sequence.size(); ss++)\n+ if (this->subseq_types[ss] == subseq_t::LOOP)\n+ {\n+ while (!tasks_sequence[ss][0]->exec())\n+ for (size_t ta = 1; ta < tasks_sequence[ss].size(); ta++)\n+ tasks_sequence[ss][ta]->exec();\n+ }\n+ else\n+ {\n+ for (size_t ta = 0; ta < tasks_sequence[ss].size(); ta++)\n+ tasks_sequence[ss][ta]->exec();\n+ }\n+ }\n+ while (!*force_exit_loop && !stop_condition());\n}\ncatch (std::exception const& e)\n{\n@@ -341,13 +380,123 @@ int Chain\n}\nint ret = 0;\n- for (size_t ta = 0; ta < this->tasks_sequences[tid].size(); ta++)\n- ret += this->tasks_sequences[tid][ta]->exec();\n+ for (size_t ss = 0; ss < this->tasks_sequences[tid].size(); ss++)\n+ {\n+ if (this->subseq_types[ss] == subseq_t::LOOP)\n+ {\n+ while (!this->tasks_sequences[tid][ss][0]->exec())\n+ for (size_t ta = 1; ta < this->tasks_sequences[tid][ss].size(); ta++)\n+ ret += this->tasks_sequences[tid][ss][ta]->exec();\n+ ret++;\n+ }\n+ else\n+ {\n+ for (size_t ta = 0; ta < this->tasks_sequences[tid][ss].size(); ta++)\n+ ret += this->tasks_sequences[tid][ss][ta]->exec();\n+ }\n+ }\nreturn ret;\n}\nvoid Chain\n-::duplicate(const std::vector<const module::Task*> &tasks_sequence)\n+::init_recursive(std::vector<std::vector<const module::Task*>> &tasks_sequence,\n+ const size_t ssid,\n+ std::vector<subseq_t> &subseq_types,\n+ std::vector<const module::Task*> &loops,\n+ const module::Task& first,\n+ const module::Task& current_task,\n+ const module::Task *last)\n+{\n+ if (auto loop = dynamic_cast<const module::Loop*>(¤t_task.get_module()))\n+ {\n+ if (std::find(loops.begin(), loops.end(), ¤t_task) == loops.end())\n+ {\n+ loops.push_back(¤t_task);\n+ if (¤t_task != &first)\n+ tasks_sequence.push_back(std::vector<const module::Task*>());\n+ tasks_sequence.push_back(std::vector<const module::Task*>());\n+\n+ const auto ssid1 = tasks_sequence.size() -2;\n+ const auto ssid2 = tasks_sequence.size() -1;\n+\n+ if (loop->tasks[0]->sockets[2]->get_bound_sockets().size() == 1)\n+ {\n+ subseq_types.push_back(subseq_t::LOOP);\n+ auto &t1 = loop->tasks[0]->sockets[2]->get_bound_sockets()[0]->get_task();\n+ Chain::init_recursive(tasks_sequence, ssid1, subseq_types, loops, first, t1, last);\n+ tasks_sequence[ssid1].push_back(¤t_task);\n+ }\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"'loop->tasks[0]->sockets[2]->get_bound_sockets().size()' has to be equal to 1 (\"\n+ << \"'loop->tasks[0]->sockets[2]->get_bound_sockets().size()' = \"\n+ << loop->tasks[0]->sockets[2]->get_bound_sockets().size() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (loop->tasks[0]->sockets[3]->get_bound_sockets().size() == 1)\n+ {\n+ auto &t2 = loop->tasks[0]->sockets[3]->get_bound_sockets()[0]->get_task();\n+ Chain::init_recursive(tasks_sequence, ssid2, subseq_types, loops, first, t2, last);\n+ }\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"'loop->tasks[0]->sockets[3]->get_bound_sockets().size()' has to be equal to 1 (\"\n+ << \"'loop->tasks[0]->sockets[3]->get_bound_sockets().size()' = \"\n+ << loop->tasks[0]->sockets[3]->get_bound_sockets().size() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ }\n+ else\n+ {\n+ if (subseq_types.size() < tasks_sequence.size())\n+ subseq_types.push_back(subseq_t::STD);\n+\n+ tasks_sequence[ssid].push_back(¤t_task);\n+\n+ if (¤t_task != last)\n+ {\n+ for (auto &s : current_task.sockets)\n+ {\n+ if (current_task.get_socket_type(*s) == module::socket_t::SIN_SOUT ||\n+ current_task.get_socket_type(*s) == module::socket_t::SOUT)\n+ {\n+ auto bss = s->get_bound_sockets();\n+ for (auto &bs : bss)\n+ {\n+ if (bs != nullptr)\n+ {\n+ auto &t = bs->get_task();\n+ if (t.is_last_input_socket(*bs) || dynamic_cast<const module::Loop*>(&t.get_module()))\n+ Chain::init_recursive(tasks_sequence, ssid, subseq_types, loops, first, t, last);\n+ }\n+ }\n+ }\n+ else if (current_task.get_socket_type(*s) == module::socket_t::SIN)\n+ {\n+ if (s->get_bound_sockets().size() > 1)\n+ {\n+ std::stringstream message;\n+ message << \"'s->get_bound_sockets().size()' has to be smaller or equal to 1 (\"\n+ << \"'s->get_bound_sockets().size()'\" << \" = \" << s->get_bound_sockets().size() << \", \"\n+ << \"'get_socket_type(*s)'\" << \" = \" << \"socket_t::SIN\" << \", \"\n+ << \"'s->get_name()'\" << \" = \" << s->get_name() << \", \"\n+ << \"'s->get_task().get_name()'\" << \" = \" << s->get_task().get_name() << \", \"\n+ << \"'s->get_task().get_module().get_name()'\" << \" = \" << s->get_task().get_module().get_name()\n+ << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ }\n+ }\n+ }\n+}\n+\n+void Chain\n+::duplicate(const std::vector<std::vector<const module::Task*>> &tasks_sequence)\n{\nstd::vector<std::pair<const module::Module*, std::vector<const module::Task*>>> modules_to_tasks;\nstd::map<const module::Task*, size_t> task_to_module_id;\n@@ -362,7 +511,9 @@ void Chain\nreturn -1;\n};\n- for (auto &ta : tasks_sequence)\n+ for (auto &subsec : tasks_sequence)\n+ {\n+ for (auto &ta : subsec)\n{\nauto m = &ta->get_module();\nauto id = exist_module(modules_to_tasks, m);\n@@ -378,6 +529,7 @@ void Chain\ntask_to_module_id[ta] = id;\n}\n}\n+ }\n// clone the modules\nfor (size_t tid = 0; tid < this->n_threads; tid++)\n@@ -388,12 +540,13 @@ void Chain\nthis->modules[tid][m++].reset(mtt.first->clone());\n}\n- auto get_task_id = [&tasks_sequence](const module::Task &ta) -> int\n+ auto get_task_id = [&tasks_sequence](const module::Task &ta) -> std::pair<int,int>\n{\n- for (size_t t = 0; t < tasks_sequence.size(); t++)\n- if (&ta == tasks_sequence[t])\n- return t;\n- return -1;\n+ for (size_t ss = 0; ss < tasks_sequence.size(); ss++)\n+ for (size_t t = 0; t < tasks_sequence[ss].size(); t++)\n+ if (&ta == tasks_sequence[ss][t])\n+ return std::make_pair(ss, t);\n+ return std::make_pair(-1, -1);\n};\nauto get_socket_id = [](const module::Task &ta, const module::Socket& so) -> int\n@@ -415,10 +568,10 @@ void Chain\n};\nauto get_task_cpy = [this, &task_to_module_id, &get_task_id_in_module, &tasks_sequence](const size_t tid,\n- const size_t id) -> module::Task&\n+ const size_t ssid, const size_t taid) -> module::Task&\n{\n- const auto module_id = task_to_module_id[tasks_sequence[id]];\n- const auto task_id_in_module = get_task_id_in_module(tasks_sequence[id]);\n+ const auto module_id = task_to_module_id[tasks_sequence[ssid][taid]];\n+ const auto task_id_in_module = get_task_id_in_module(tasks_sequence[ssid][taid]);\nassert(task_id_in_module != -1);\nreturn *modules[tid][module_id]->tasks[task_id_in_module].get();\n};\n@@ -426,20 +579,26 @@ void Chain\n// create the n tasks sequences\nfor (size_t tid = 0; tid < this->n_threads; tid++)\n{\n- auto &tasks_chain_cpy = this->tasks_sequences[tid];\n- tasks_chain_cpy.clear();\n- for (size_t taid = 0; taid < tasks_sequence.size(); taid++)\n+ auto &tasks_ss_chain_cpy = this->tasks_sequences[tid];\n+ tasks_ss_chain_cpy.clear();\n+ for (size_t ss = 0; ss < tasks_sequence.size(); ss++)\n+ {\n+ tasks_ss_chain_cpy.push_back(std::vector<module::Task*>());\n+ for (size_t taid = 0; taid < tasks_sequence[ss].size(); taid++)\n{\n- auto &task_cpy = get_task_cpy(tid, taid);\n+ auto &task_cpy = get_task_cpy(tid, ss, taid);\ntask_cpy.set_autoalloc(true);\n- tasks_chain_cpy.push_back(&task_cpy);\n+ tasks_ss_chain_cpy[ss].push_back(&task_cpy);\n+ }\n}\n}\n// bind the tasks of the n sequences\n- for (size_t tout_id = 0; tout_id < tasks_sequence.size(); tout_id++)\n+ for (size_t ssout_id = 0; ssout_id < tasks_sequence.size(); ssout_id++)\n+ {\n+ for (size_t tout_id = 0; tout_id < tasks_sequence[ssout_id].size(); tout_id++)\n{\n- auto &tout = tasks_sequence[tout_id];\n+ auto &tout = tasks_sequence[ssout_id][tout_id];\nfor (size_t sout_id = 0; sout_id < tout->sockets.size(); sout_id++)\n{\nauto &sout = tout->sockets[sout_id];\n@@ -451,9 +610,12 @@ void Chain\nif (sin != nullptr)\n{\nauto &tin = sin->get_task();\n- auto tin_id = get_task_id(tin);\n+ auto tin_id_pair = get_task_id(tin);\n- if (tin_id != -1)\n+ auto ssin_id = tin_id_pair.first;\n+ auto tin_id = tin_id_pair.second;\n+\n+ if (tin_id != -1 && ssin_id != -1)\n{\nauto sin_id = get_socket_id(tin, *sin);\nassert(sin_id != -1);\n@@ -461,7 +623,8 @@ void Chain\nfor (size_t tid = 0; tid < this->n_threads; tid++)\n{\nauto &tasks_chain_cpy = this->tasks_sequences[tid];\n- (*tasks_chain_cpy[tin_id])[sin_id].bind((*tasks_chain_cpy[tout_id])[sout_id]);\n+ (*tasks_chain_cpy[ssin_id][tin_id])[sin_id].bind((*tasks_chain_cpy[ssout_id][tout_id])[sout_id]);\n+ }\n}\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the first loop support to the chain.
|
8,490 |
10.12.2019 10:33:40
| -3,600 |
b7b2bbbe9268ba7852e5d428d3b0d440e32b372b
|
CI: enable chain simulator engine for the regression tests.
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-build-coverage-regression.sh",
"new_path": "ci/test-build-coverage-regression.sh",
"diff": "@@ -33,7 +33,7 @@ function gen_coverage_info\nci=$(awk -F \"=\" '/ci/ {print $2}' $path)\nif [ \"$ci\" != \"off\" ]; then\ncd $build\n- eval \"${cmd} --sim-threads 1 --sim-max-fra 1 --sim-crit-nostop --ter-freq 0 --sim-clone\"\n+ eval \"${cmd} --sim-threads 1 --sim-max-fra 1 --sim-crit-nostop --ter-freq 0 --sim-chain\"\nrc=$?; if [[ $rc != 0 ]]; then exit $rc; fi\ncd ..\nelse\n"
},
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -370,7 +370,7 @@ for fn in fileNames:\nargsAFFECT = argsAFFECTcommand[:] # hard copy\nargsAFFECT += simuRef.getSplitCommand()\nargsAFFECT[len(argsAFFECTcommand)] = args.binaryPath;\n- argsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-meta\", simuRef.getMetadata(\"title\"), \"--sim-clone\"]\n+ argsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-meta\", simuRef.getMetadata(\"title\"), \"--sim-chain\"]\nif args.maxFE:\nargsAFFECT += [\"-e\", str(args.maxFE)]\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
CI: enable chain simulator engine for the regression tests.
|
8,490 |
10.12.2019 19:07:35
| -3,600 |
13a22408fa0e17085619b5a789b71f6ab084e630
|
Fix loops for 'inter frames > 1' simulations.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Loop/CRC/Loop_CRC.hpp",
"new_path": "include/Module/Loop/CRC/Loop_CRC.hpp",
"diff": "@@ -26,10 +26,13 @@ public:\nconst CRC<I> &crc,\nconst size_t n_elmts_in,\nconst size_t n_elmts_out,\n- const size_t crc_ite_start = 0);\n+ const size_t crc_ite_start = 0,\n+ const int n_frames = 1);\nvirtual ~Loop_CRC() = default;\nvirtual Loop_CRC<I,O>* clone() const;\n+ virtual bool stop(const int8_t *in, const int frame_id = -1);\n+\nprotected:\nvirtual void deep_copy(const Loop_CRC<I,O> &m);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Loop/CRC/Loop_CRC.hxx",
"new_path": "include/Module/Loop/CRC/Loop_CRC.hxx",
"diff": "@@ -15,8 +15,9 @@ Loop_CRC<I,O>\nconst CRC<I> &crc,\nconst size_t n_elmts_in,\nconst size_t n_elmts_out,\n- const size_t crc_ite_start)\n-: Loop_predicate<O>(predicate, n_elmts_in, typeid(I), n_elmts_out, crc.get_n_frames()),\n+ const size_t crc_ite_start,\n+ const int n_frames)\n+: Loop_predicate<O>(predicate, n_elmts_in, typeid(I), n_elmts_out, n_frames),\ncrc(crc.clone()),\ncrc_ite_start(crc_ite_start)\n{\n@@ -52,11 +53,32 @@ void Loop_CRC<I,O>\ntemplate <typename I, typename O>\nbool Loop_CRC<I,O>\n-::_stop(const int8_t *in, const int frame_id)\n+::stop(const int8_t *in, const int frame_id)\n{\n- if (Loop_predicate<O>::_stop(in, frame_id))\n+ // this->n_calls++; // is performed into 'Loop_predicate<O>::stop' function\n+ if (Loop_predicate<O>::stop(in, frame_id))\nreturn true;\n- return (Loop::get_n_calls() > crc_ite_start) ? this->crc->check((const I*)in) ? true : false : false;\n+\n+ if (Loop::get_n_calls() > crc_ite_start)\n+ {\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\n+ auto ret_val = this->_stop(in + f_start * this->n_bytes_in, f_start);\n+ for (auto f = f_start+1; f < f_stop; f++)\n+ ret_val &= this->_stop(in + f * this->n_bytes_in, f);\n+\n+ return ret_val;\n+ }\n+ else\n+ return false;\n+}\n+\n+template <typename I, typename O>\n+bool Loop_CRC<I,O>\n+::_stop(const int8_t *in, const int frame_id)\n+{\n+ return this->crc->check((const I*)in, 1, 0) ? true : false;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Loop/Loop.hxx",
"new_path": "include/Module/Loop/Loop.hxx",
"diff": "@@ -100,12 +100,13 @@ Loop\n// I have to find a trick to avoid those copies\nif (stop && n_calls == 0)\nstd::copy((int8_t*)t[2].get_dataptr(),\n- (int8_t*)t[2].get_dataptr() + l.get_n_bytes_out(),\n+ (int8_t*)t[2].get_dataptr() + t[2].get_databytes(),\n(int8_t*)t[3].get_dataptr());\nif (!stop && n_calls > 0)\nstd::copy((int8_t*)t[3].get_dataptr(),\n- (int8_t*)t[3].get_dataptr() + l.get_n_bytes_out(),\n+ (int8_t*)t[3].get_dataptr() + t[3].get_databytes(),\n(int8_t*)t[2].get_dataptr());\n+\nreturn stop;\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Loop/Predicate/Loop_predicate.hpp",
"new_path": "include/Module/Loop/Predicate/Loop_predicate.hpp",
"diff": "@@ -31,6 +31,8 @@ public:\nvirtual void reset();\n+ virtual bool stop(const int8_t *in, const int frame_id = -1);\n+\nprotected:\nLoop_predicate(const tools::Predicate &predicate,\nconst size_t n_elmts_in,\n@@ -39,8 +41,6 @@ protected:\nconst int n_frames = 1);\nvirtual void deep_copy(const Loop_predicate<O> &m);\n-\n- virtual bool _stop(const int8_t *in, const int frame_id);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/CRC/Router_CRC.hpp",
"new_path": "include/Module/Router/CRC/Router_CRC.hpp",
"diff": "@@ -21,7 +21,7 @@ class Router_CRC : public Router\nstd::shared_ptr<CRC<I>> crc;\npublic:\n- Router_CRC(const CRC<I> &crc, const size_t n_elmts_in, const size_t n_elmts_out);\n+ Router_CRC(const CRC<I> &crc, const size_t n_elmts_in, const size_t n_elmts_out, const int n_frames = 1);\nvirtual ~Router_CRC() = default;\nvirtual Router_CRC<I,O>* clone() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Router/CRC/Router_CRC.hxx",
"new_path": "include/Module/Router/CRC/Router_CRC.hxx",
"diff": "@@ -11,8 +11,8 @@ namespace module\ntemplate <typename I, typename O>\nRouter_CRC<I,O>\n-::Router_CRC(const CRC<I> &crc, const size_t n_elmts_in, const size_t n_elmts_out)\n-: Router(n_elmts_in, typeid(I), n_elmts_out, typeid(O), 2, crc.get_n_frames()),\n+::Router_CRC(const CRC<I> &crc, const size_t n_elmts_in, const size_t n_elmts_out, const int n_frames)\n+: Router(n_elmts_in, typeid(I), n_elmts_out, typeid(O), 2, n_frames),\ncrc(crc.clone())\n{\nconst std::string name = \"Router_CRC\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Loop/Predicate/Loop_predicate.cpp",
"new_path": "src/Module/Loop/Predicate/Loop_predicate.cpp",
"diff": "@@ -76,8 +76,9 @@ void Loop_predicate<O>\ntemplate <typename O>\nbool Loop_predicate<O>\n-::_stop(const int8_t *in, const int frame_id)\n+::stop(const int8_t *in, const int frame_id)\n{\n+ this->n_calls++;\nreturn (*this->predicate)();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.cpp",
"new_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.cpp",
"diff": "@@ -138,7 +138,8 @@ std::unique_ptr<module::Loop_CRC<B,Q>> Simulation_chain_BFER_ite<B,R,Q>\n*crc,\n(size_t)crc->get_size() + (size_t)crc->get_K(),\nparams_BFER_ite.cdc->N_cw,\n- params_BFER_ite.crc_start));\n+ params_BFER_ite.crc_start,\n+ params_BFER_ite.src->n_frames));\nreturn loop_crc;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Legacy/BFER/Iterative/BFER_ite.cpp",
"new_path": "src/Simulation/Legacy/BFER/Iterative/BFER_ite.cpp",
"diff": "@@ -353,7 +353,8 @@ std::unique_ptr<module::Loop_CRC<B,Q>> BFER_ite<B,R,Q>\n*crc,\n(size_t)crc->get_size() + (size_t)crc->get_K(),\nparams_BFER_ite.cdc->N_cw,\n- params_BFER_ite.crc_start));\n+ params_BFER_ite.crc_start,\n+ params_BFER_ite.src->n_frames));\nreturn loop_crc;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix loops for 'inter frames > 1' simulations.
|
8,490 |
14.12.2019 11:08:01
| -3,600 |
bb60bdea46c71fc301caa5e174bf3616c5e25c75
|
Doc: add supported polar kernels.
|
[
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/codec/polar_mk/decoder.rst",
"new_path": "doc/source/user/simulation/parameters/codec/polar_mk/decoder.rst",
"diff": "@@ -33,6 +33,76 @@ Description of the allowed values:\n| ``ML`` | See the common :ref:`dec-common-dec-type` parameter. |\n+--------------+---------------------------------------------------------------+\n+At this time, the ``SC``, ``SCL`` and ``ASCL`` decoders support only a subset of\n+polar kernels listed below.\n+\n+.. math::\n+\n+ T2_{Arikan} =\n+ \\begin{bmatrix}\n+ 1 & 0 \\\\\n+ 1 & 1\n+ \\end{bmatrix}.\n+\n+:math:`T2_{Arikan}` is the original :math:`2 \\times 2` kernel proposed by Arikan\n+:cite:`Arikan2009`. This matrix is invertible and can be used for systematic\n+encoding/decoding schemes.\n+\n+.. math::\n+\n+ T3_{Huawei1} =\n+ \\begin{bmatrix}\n+ 1 & 1 & 1 \\\\\n+ 1 & 0 & 1 \\\\\n+ 0 & 1 & 1\n+ \\end{bmatrix}.\n+\n+:math:`T3_{Huawei1}` is a :math:`3 \\times 3` kernel proposed in\n+:cite:`Gabry2017`. This matrix is **not** invertible and **cannot** be used for\n+systematic encoding/decoding schemes.\n+\n+.. math::\n+\n+ T3_{Huawei2} =\n+ \\begin{bmatrix}\n+ 1 & 0 & 0 \\\\\n+ 1 & 1 & 0 \\\\\n+ 1 & 0 & 1\n+ \\end{bmatrix}.\n+\n+:math:`T3_{Huawei2}` is a :math:`3 \\times 3` kernel proposed in\n+:cite:`Bioglio2018c`. This matrix is invertible and can be used for systematic\n+encoding/decoding schemes.\n+\n+.. math::\n+\n+ T4_{Huawei} =\n+ \\begin{bmatrix}\n+ 1 & 0 & 0 & 0 \\\\\n+ 1 & 1 & 0 & 0 \\\\\n+ 1 & 0 & 1 & 0 \\\\\n+ 1 & 1 & 1 & 1\n+ \\end{bmatrix}.\n+\n+:math:`T4_{Huawei}` is a :math:`4 \\times 4` kernel proposed in\n+:cite:`Bioglio2018c`. This matrix is invertible and can be used for systematic\n+encoding/decoding schemes.\n+\n+.. math::\n+\n+ T5_{Huawei} =\n+ \\begin{bmatrix}\n+ 1 & 0 & 0 & 0 & 0 \\\\\n+ 1 & 1 & 0 & 0 & 0 \\\\\n+ 1 & 0 & 1 & 0 & 0 \\\\\n+ 1 & 0 & 0 & 1 & 0 \\\\\n+ 1 & 1 & 1 & 0 & 1\n+ \\end{bmatrix}.\n+\n+:math:`T5_{Huawei}` is a :math:`5 \\times 5` kernel proposed in\n+:cite:`Bioglio2018c`. This matrix is invertible and can be used for systematic\n+encoding/decoding schemes.\n+\n.. _dec-polar_mk-dec-implem:\n``--dec-implem``\n"
},
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/codec/polar_mk/references_dec.bib",
"new_path": "doc/source/user/simulation/parameters/codec/polar_mk/references_dec.bib",
"diff": "groups = {Polar Codes},\nkeywords = {adaptive codes, cyclic redundancy check codes, decoding, CRC code, FER, adaptive SC list decoder, adaptive successive cancellation list decoder, cyclic redundancy check codes, frame error rate, information theoretic limit, polar codes, word length 24 bit, Complexity theory, Cyclic redundancy check, Error analysis, Iterative decoding, Maximum likelihood decoding, Signal to noise ratio, Polar codes, list decoder},\n}\n+\n+@InProceedings{Gabry2017,\n+ author = {F. Gabry and V. Bioglio and I. Land and J. Belfiore},\n+ title = {Multi-Kernel Construction of Polar Codes},\n+ booktitle = {International Conference on Communications (ICC)},\n+ year = {2017},\n+ pages = {761--765},\n+ month = may,\n+ publisher = {IEEE},\n+ abstract = {We propose a generalized construction for binary polar codes based on mixing multiple kernels of different sizes in order to construct polar codes of block lengths that are not only powers of integers. This results in a multi-kernel polar code with very good performance while the encoding complexity remains low and the decoding follows the same general structure as for the original Arikan polar codes. The construction provides numerous practical advantages as more code lengths can be achieved without puncturing or shortening. We observe numerically that the error-rate performance of our construction outperforms state-of-the-art constructions using puncturing methods.},\n+ doi = {10.1109/ICCW.2017.7962750},\n+ file = {:pdf/Gabry2017 - Multi-Kernel Construction of Polar Codes.pdf:PDF},\n+ groups = {Polar Codes},\n+ issn = {2474-9133},\n+ keywords = {binary codes, block codes, multikernel construction, binary polar codes, block lengths, multikernel polar code, Arikan polar codes, Kernel, Decoding, Encoding, Nickel, 5G mobile communication, Complexity theory, Reliability, Polar Codes, Multiple Kernels, Successive Cancellation Decoding, multi kernel, multi-kernel},\n+}\n+\n+@InProceedings{Bioglio2018c,\n+ author = {V. Bioglio and I. Land},\n+ title = {On the Marginalization of Polarizing Kernels},\n+ booktitle = {International Symposium on Turbo Codes and Iterative Information Processing (ISTC)},\n+ year = {2018},\n+ pages = {1-5},\n+ month = dec,\n+ abstract = {In this paper, we analyze the decoding complexity of polarizing kernels of size larger than p = 2, proposing a general procedure which can be used to marginalize kernels of any size. We use this method to evaluate the decoding equations for optimal binary kernels up to size p = 8. Finally, we experimentally show that, even if T_2 and T_8 share the same polarization exponent, their performance may vary under list decoding, making large kernels of interest for long polar codes.},\n+ doi = {10.1109/ISTC.2018.8625378},\n+ file = {:pdf/Bioglio2018c - On the Marginalization of Polarizing Kernels.pdf:PDF},\n+ groups = {Polar Codes},\n+ issn = {2165-4719},\n+ keywords = {decoding, optimisation, polar codes, multi kernel, multi-kernel},\n+}\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Doc: add supported polar kernels.
|
8,490 |
14.12.2019 12:12:10
| -3,600 |
91ec9aaf095350346feecb7c1f16c14a67668230
|
Doc: update the library examples.
|
[
{
"change_type": "MODIFY",
"old_path": "doc/source/user/library/examples.rst",
"new_path": "doc/source/user/library/examples.rst",
"diff": "@@ -71,7 +71,7 @@ is a module (green boxes in :numref:`fig_simple_chain_code`).\nconst auto esn0 = tools::ebn0_to_esn0 (ebn0, p.R);\nconst auto sigma = tools::esn0_to_sigma(esn0 );\n- u.noise->set_noise(sigma, ebn0, esn0);\n+ u.noise->set_values(sigma, ebn0, esn0);\n// update the sigma of the modem and the channel\nm.modem ->set_noise(*u.noise);\n@@ -325,7 +325,7 @@ objects.\nconst auto esn0 = tools::ebn0_to_esn0 (ebn0, p.R);\nconst auto sigma = tools::esn0_to_sigma(esn0 );\n- u.noise->set_noise(sigma, ebn0, esn0);\n+ u.noise->set_values(sigma, ebn0, esn0);\n// update the sigma of the modem and the channel\nm.modem ->set_noise(*u.noise);\n@@ -382,7 +382,7 @@ for more informations about the statistics output).\n:linenos:\n:caption: Tasks: modules\n:name: lst_tasks_modules\n- :emphasize-lines: 10-24\n+ :emphasize-lines: 10-23\nvoid init_modules2(const params1 &p, modules1 &m)\n{\n@@ -399,7 +399,6 @@ for more informations about the statistics output).\nfor (auto& tsk : mod->tasks)\n{\ntsk->set_autoalloc (true ); // enable the automatic allocation of data buffers in the tasks\n- tsk->set_autoexec (false); // disable the auto execution mode of the tasks\ntsk->set_debug (false); // disable the debug mode\ntsk->set_debug_limit(16 ); // display only the 16 first bits if the debug mode is enabled\ntsk->set_stats (true ); // enable statistics collection\n@@ -412,7 +411,7 @@ for more informations about the statistics output).\nThe beginning of the ``init_modules2`` function (:numref:`lst_tasks_modules`) is\nthe same as the ``init_module1`` function (:numref:`lst_bootstrap_modules`). At\n-lines ``10-24``, each ``Module`` is parsed to get its tasks, each ``Task`` is\n+lines ``10-23``, each ``Module`` is parsed to get its tasks, each ``Task`` is\nconfigured to automatically allocate its outputs ``Socket`` memory (line ``15``)\nand collect statistics on the ``Task`` execution (line ``19``). It is also\npossible to print debug information by toggling boolean to ``true`` at line\n@@ -462,7 +461,7 @@ to use standard TLM interfaces.\nconst auto esn0 = tools::ebn0_to_esn0 (ebn0, p.R);\nconst auto sigma = tools::esn0_to_sigma(esn0 );\n- u.noise->set_noise(sigma, ebn0, esn0);\n+ u.noise->set_values(sigma, ebn0, esn0);\n// update the sigma of the modem and the channel\nm.modem ->set_noise(*u.noise);\n@@ -628,7 +627,7 @@ and line ``19`` by ``polar`` to work with polar code.\nstruct modules3\n{\nstd::unique_ptr<module::Source<>> source;\n- std::unique_ptr<module::Codec_SIHO<>> codec;\n+ std::unique_ptr<tools ::Codec_SIHO<>> codec;\nstd::unique_ptr<module::Modem<>> modem;\nstd::unique_ptr<module::Channel<>> channel;\nstd::unique_ptr<module::Monitor_BFER<>> monitor;\n@@ -639,7 +638,7 @@ and line ``19`` by ``polar`` to work with polar code.\nvoid init_modules3(const params3 &p, modules3 &m)\n{\nm.source = std::unique_ptr<module::Source <>>(p.source ->build());\n- m.codec = std::unique_ptr<module::Codec_SIHO <>>(p.codec ->build());\n+ m.codec = std::unique_ptr<tools ::Codec_SIHO <>>(p.codec ->build());\nm.modem = std::unique_ptr<module::Modem <>>(p.modem ->build());\nm.channel = std::unique_ptr<module::Channel <>>(p.channel->build());\nm.monitor = std::unique_ptr<module::Monitor_BFER<>>(p.monitor->build());\n@@ -652,7 +651,6 @@ and line ``19`` by ``polar`` to work with polar code.\nfor (auto& tsk : mod->tasks)\n{\ntsk->set_autoalloc (true ); // enable the automatic allocation of the data in the tasks\n- tsk->set_autoexec (false); // disable the auto execution mode of the tasks\ntsk->set_debug (false); // disable the debug mode\ntsk->set_debug_limit(16 ); // display only the 16 first bits if the debug mode is enabled\ntsk->set_stats (true ); // enable the statistics\n@@ -707,7 +705,7 @@ parameters list can be seen using ``-h`` as shown in\n:numref:`lst_factory_binary_help`.\n.. code-block:: bash\n- :caption: Factory: execute the binary\n+ :caption: Factory: display the command line parameters\n:name: lst_factory_binary_help\n./bin/my_project -h\n@@ -779,7 +777,7 @@ multi-threaded architectures using `pragma` directives of the well-known\nconst auto sigma = tools::esn0_to_sigma(esn0 );\n#pragma omp single\n- u.noise->set_noise(sigma, ebn0, esn0);\n+ u.noise->set_values(sigma, ebn0, esn0);\n// update the sigma of the modem and the channel\nm.modem ->set_noise(*u.noise);\n@@ -790,7 +788,7 @@ multi-threaded architectures using `pragma` directives of the well-known\nu.terminal->start_temp_report();\n// run the simulation chain\n- while (!u.monitor_red->is_done_all())\n+ while (!u.monitor_red->is_done())\n{\n(*m.source )[src::tsk::generate ].exec();\n(*m.encoder)[enc::tsk::encode ].exec();\n@@ -806,13 +804,13 @@ multi-threaded architectures using `pragma` directives of the well-known\n#pragma omp single\n{\n// final reduction\n- u.monitor_red->is_done_all(true, true);\n+ u.monitor_red->reduce();\n// display the performance (BER and FER) in the terminal\nu.terminal->final_report();\n// reset the monitor and the terminal for the next SNR\n- u.monitor_red->reset_all();\n+ u.monitor_red->reset();\nu.terminal->reset();\n}\n}\n@@ -844,13 +842,13 @@ each threads gets its own local ``m``.\n.. code-block:: cpp\n:caption: OpenMP: modules and utils\n:name: lst_openmp_modules_utils\n- :emphasize-lines: 7,17-20,25-30,36-37,57\n+ :emphasize-lines: 7,17-20,25-30,36-37,56\n:linenos:\nstruct modules4\n{\nstd::unique_ptr<module::Source<>> source;\n- std::unique_ptr<module::Codec_SIHO<>> codec;\n+ std::unique_ptr<tools ::Codec_SIHO<>> codec;\nstd::unique_ptr<module::Modem<>> modem;\nstd::unique_ptr<module::Channel<>> channel;\nmodule::Monitor_BFER<>* monitor;\n@@ -879,7 +877,7 @@ each threads gets its own local ``m``.\np.channel->seed += tid;\nm.source = std::unique_ptr<module::Source <>>(p.source ->build());\n- m.codec = std::unique_ptr<module::Codec_SIHO <>>(p.codec ->build());\n+ m.codec = std::unique_ptr<tools ::Codec_SIHO <>>(p.codec ->build());\nm.modem = std::unique_ptr<module::Modem <>>(p.modem ->build());\nm.channel = std::unique_ptr<module::Channel <>>(p.channel->build());\nu.monitors[tid] = std::unique_ptr<module::Monitor_BFER<>>(p.monitor->build());\n@@ -893,7 +891,6 @@ each threads gets its own local ``m``.\nfor (auto& tsk : mod->tasks)\n{\ntsk->set_autoalloc (true ); // enable the automatic allocation of the data in the tasks\n- tsk->set_autoexec (false); // disable the auto execution mode of the tasks\ntsk->set_debug (false); // disable the debug mode\ntsk->set_debug_limit(16 ); // display only the 16 first bits if the debug mode is enabled\ntsk->set_stats (true ); // enable the statistics\n@@ -924,7 +921,7 @@ seed to each thread. If the seed is the same for all threads, they all simulate\nthe same frame contents and apply the same noise over it.\nLines ``36-37``, the ``monitors`` are allocated in ``u`` and the resulting\n-pointer is assigned to ``m``. At line ``57`` a list of the modules is stored in\n+pointer is assigned to ``m``. At line ``56`` a list of the modules is stored in\n``u``.\n.. code-block:: cpp\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Doc: update the library examples.
|
8,490 |
14.12.2019 13:49:57
| -3,600 |
e0122b167c56a15970b859306c5bc16e9366039e
|
Doc: add the POLAR_MK type of code in the '--sim-cde-type' parameter.
|
[
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/simulation/references.bib",
"new_path": "doc/source/user/simulation/parameters/simulation/references.bib",
"diff": "@@ -113,3 +113,18 @@ are also included to test and enhance learning, making this an essential resourc\ngroups = {Polar Codes},\nkeywords = {binary codes, channel capacity, channel coding, decoding, memoryless systems, probability, channel capacity, channel coding, channel polarization, code sequence, polar codes, probability, successive cancellation decoding algorithm, symmetric binary-input memoryless channel, Capacity planning, Channel capacity, Channel coding, Codes, Councils, Decoding, Information theory, Memoryless systems, Noise cancellation, Polarization, Capacity-achieving codes, Plotkin construction, Reed-- Muller (RM) codes, channel capacity, channel polarization, polar codes, successive cancellation decoding},\n}\n+\n+@InProceedings{Benammar2017,\n+ author = {M. Benammar and V. Bioglio and F. Gabry and I. Land},\n+ title = {Multi-Kernel Polar Codes: Proof of Polarization and Error Exponents},\n+ booktitle = {Information Theory Workshop (ITW)},\n+ year = {2017},\n+ pages = {101--105},\n+ month = nov,\n+ publisher = {IEEE},\n+ abstract = {In this paper, we investigate a novel family of polar codes based on multi-kernel constructions, proving that this construction actually polarizes. To this end, we derive a new and more general proof of polarization, which gives sufficient conditions for kernels to polarize. Finally, we derive the convergence rate of the multi-kernel construction and relate it to the convergence rate of each of the constituent kernels.},\n+ doi = {10.1109/ITW.2017.8277949},\n+ file = {:pdf/Benammar2017 - Multi-Kernel Polar Codes\\: Proof of Polarization and Error Exponents.pdf:PDF},\n+ groups = {Polar Codes},\n+ keywords = {convergence, theorem proving, proof of polarization, constituent kernels, convergence rate, multikernel construction, error exponents, multikernel polar codes, Kernel, Convergence, Reliability, Random variables, Decoding, Conferences, multi kernel, multi-kernel},\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/simulation/simulation.rst",
"new_path": "doc/source/user/simulation/parameters/simulation/simulation.rst",
"diff": "@@ -58,8 +58,9 @@ Description of the allowed values:\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n:Type: text\n- :Allowed values: ``BCH`` ``LDPC`` ``POLAR`` ``RA`` ``REP`` ``RS`` ``RSC``\n- ``RSC_DB`` ``TURBO`` ``TURBO_DB`` ``TURBO_PROD`` ``UNCODED``\n+ :Allowed values: ``BCH`` ``LDPC`` ``POLAR`` ``POLAR_MK`` ``RA`` ``REP``\n+ ``RS`` ``RSC`` ``RSC_DB`` ``TURBO`` ``TURBO_DB``\n+ ``TURBO_PROD`` ``UNCODED``\n:Examples: ``-C BCH``\n|factory::Launcher::p+cde-type,C|\n@@ -86,6 +87,8 @@ Description of the allowed values:\n+----------------+-------------------------------------------------------------+\n| ``POLAR`` | The `Polar`_ codes :cite:`Arikan2009`. |\n+----------------+-------------------------------------------------------------+\n+| ``POLAR_MK`` | The Polar mono- or multi-kernel codes :cite:`Benammar2017`. |\n++----------------+-------------------------------------------------------------+\n| ``RA`` | The `Repeat Accumulate`_ codes :cite:`Divsalar1998`. |\n+----------------+-------------------------------------------------------------+\n| ``REP`` | The `Repetition`_ codes :cite:`Ryan2009`. |\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Doc: add the POLAR_MK type of code in the '--sim-cde-type' parameter.
|
8,490 |
15.12.2019 10:20:45
| -3,600 |
941f0ba70769101b2a253627a8e258ce7e179429
|
Fix dead link to the library doc.
|
[
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -73,7 +73,7 @@ of possible applications for the library:\n3. enable various modules to be used in SDR contexts.\nIf you seek for using **AFF3CT** as a library, please refer to the\n-[dedicated documentation page](https://aff3ct.readthedocs.io/en/latest/user/library/library.html).\n+[dedicated documentation page](https://aff3ct.readthedocs.io/en/latest/user/library/examples.html).\n## Installation\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix dead link to the library doc.
|
8,490 |
16.12.2019 13:15:36
| -3,600 |
8bc72b5921c003847a20da354c4439876610340d
|
Simplify the code to work with the MATLAB wrapper.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Monitor/BFER/Monitor_BFER.hpp",
"new_path": "include/Module/Monitor/BFER/Monitor_BFER.hpp",
"diff": "@@ -56,9 +56,6 @@ private:\npublic:\nMonitor_BFER(const int K, const unsigned max_fe, const unsigned max_n_frames = 0, const bool count_unknown_values = false, const int n_frames = 1);\n- Monitor_BFER(const Monitor_BFER<B>& m, const int n_frames = -1); // construct with the same parameters than \"m\"\n- // if n_frames != -1 then set it has \"n_frames\" value\n- Monitor_BFER(); // construct with null and default parameters.\nvirtual ~Monitor_BFER() = default;\n@@ -83,7 +80,6 @@ public:\nbool frame_limit_achieved() const;\nvirtual bool is_done() const;\n- const Attributes& get_attributes () const;\nint get_K () const;\nbool get_count_unknown_values() const;\nunsigned get_max_fe () const;\n@@ -94,7 +90,7 @@ public:\nfloat get_fer () const;\nfloat get_ber () const;\n- tools::Histogram<int> get_err_hist () const;\n+ const tools::Histogram<int>& get_err_hist () const;\nvoid activate_err_histogram(bool val);\nvirtual uint32_t record_callback_fe (std::function<void(unsigned, int)> callback);\n@@ -121,8 +117,9 @@ public:\nMonitor_BFER<B>& operator=(const Monitor_BFER<B>& m); // not full \"copy\" call\nprotected:\n- virtual int _check_errors(const B *U, const B *Y, const int frame_id);\n+ const Attributes& get_attributes() const;\n+ virtual int _check_errors(const B *U, const B *Y, const int frame_id);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Monitor/EXIT/Monitor_EXIT.hpp",
"new_path": "include/Module/Monitor/EXIT/Monitor_EXIT.hpp",
"diff": "@@ -50,9 +50,6 @@ private:\npublic:\nMonitor_EXIT(const int size, const unsigned max_n_trials, const int n_frames = 1);\n- Monitor_EXIT(const Monitor_EXIT<B,R>& m, const int n_frames = -1); // construct with the same parameters than \"m\"\n- // if n_frames != -1 then set it has \"n_frames\" value\n- Monitor_EXIT(); // construct with null and default parameters.\nvirtual ~Monitor_EXIT() = default;\n@@ -76,7 +73,6 @@ public:\nvirtual bool is_done() const;\nbool n_trials_achieved() const;\n- const Attributes& get_attributes () const;\nint get_N () const;\nunsigned get_max_n_trials() const;\nunsigned long long get_n_trials () const;\n@@ -102,6 +98,8 @@ public:\nMonitor_EXIT<B,R>& operator=(const Monitor_EXIT<B,R>& m); // not full \"copy\" call\nprotected:\n+ const Attributes& get_attributes() const;\n+\nvirtual void _check_mutual_info_avg (const B *bits, const R *llrs_a, const int frame_id);\nvirtual R _check_mutual_info_histo() const;\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Monitor/MI/Monitor_MI.hpp",
"new_path": "include/Module/Monitor/MI/Monitor_MI.hpp",
"diff": "@@ -57,9 +57,6 @@ public:\n* 'max_n_cf' is the max number of frames to checked after what the simulation shall stop\n*/\nMonitor_MI(const int N, const unsigned max_n_trials, const int n_frames = 1);\n- Monitor_MI(const Monitor_MI<B,R>& m, const int n_frames = -1); // construct with the same parameters than \"m\"\n- // if n_frames != -1 then set it has \"n_frames\" value\n- Monitor_MI(); // construct with null and default parameters.\nvirtual ~Monitor_MI() = default;\n@@ -75,8 +72,6 @@ public:\nbool n_trials_limit_achieved() const;\nvirtual bool is_done() const;\n-\n- const Attributes& get_attributes () const;\nint get_N () const;\nunsigned get_max_n_trials() const;\nunsigned long long get_n_trials () const;\n@@ -110,6 +105,8 @@ public:\nMonitor_MI<B,R>& operator=(const Monitor_MI<B,R>& m); // \"copy\" call with fully = false\nprotected:\n+ const Attributes& get_attributes() const;\n+\nvirtual R _get_mutual_info(const B *X, const R *Y, const int frame_id);\nvoid add_MI_value(const R mi);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Monitor/Monitor.hpp",
"new_path": "include/Module/Monitor/Monitor.hpp",
"diff": "@@ -54,6 +54,8 @@ public:\nvirtual void reset();\n+ virtual void clear_callbacks();\n+\n/*\n* \\brief return true if enough data have been processed and respect check conditions\n*/\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Monitor/Monitor_reduction.hxx",
"new_path": "include/Tools/Monitor/Monitor_reduction.hxx",
"diff": "@@ -11,22 +11,26 @@ namespace tools\n{\ntemplate <class M>\n-Monitor_reduction<M>\n-::Monitor_reduction(const std::vector<M*>& _monitors)\n-: Monitor_reduction_static(),\n- M((_monitors.size() && _monitors.front()) ? *_monitors.front() : M(),\n- std::accumulate(_monitors.begin(), _monitors.end(), 0,\n- [](int tot, const M *m) { return tot + m->get_n_frames(); })),\n- monitors(_monitors),\n- collecter(*this)\n+M& get_monitor_from_vector(const std::vector<M*> &monitors)\n{\n- if (this->monitors.size() == 0)\n+ if (monitors.size() == 0)\n{\nstd::stringstream message;\nmessage << \"'monitors.size()' has to be greater than 0 ('monitors.size()' = \" << monitors.size() << \").\";\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n+ return *monitors.front();\n+}\n+\n+template <class M>\n+Monitor_reduction<M>\n+::Monitor_reduction(const std::vector<M*>& _monitors)\n+: Monitor_reduction_static(),\n+ M(get_monitor_from_vector<M>(_monitors)),\n+ monitors(_monitors),\n+ collecter(*this)\n+{\nconst std::string name = \"Monitor_reduction<\" + monitors[0]->get_name() + \">\";\nthis->set_name(name);\n@@ -57,6 +61,9 @@ Monitor_reduction<M>\n}\n}\n+\n+ M::clear_callbacks();\n+ this->reduce();\n}\ntemplate <class M>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -38,21 +38,6 @@ Monitor_BFER<B>\nreset();\n}\n-template <typename B>\n-Monitor_BFER<B>\n-::Monitor_BFER(const Monitor_BFER<B>& mon, const int n_frames)\n-: Monitor_BFER<B>(mon.get_K(), mon.get_max_fe(), mon.get_max_n_frames(), mon.get_count_unknown_values(),\n- n_frames == -1 ? mon.get_n_frames() : n_frames)\n-{\n-}\n-\n-template <typename B>\n-Monitor_BFER<B>\n-::Monitor_BFER()\n-: Monitor_BFER<B>(1, 0)\n-{\n-}\n-\ntemplate <typename B>\nMonitor_BFER<B>* Monitor_BFER<B>\n::clone() const\n@@ -287,7 +272,7 @@ bool Monitor_BFER<B>\n}\ntemplate<typename B>\n-tools::Histogram<int> Monitor_BFER<B>::get_err_hist() const\n+const tools::Histogram<int>& Monitor_BFER<B>::get_err_hist() const\n{\nreturn err_hist;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp",
"new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp",
"diff": "@@ -34,20 +34,6 @@ Monitor_EXIT<B,R>\nreset();\n}\n-template <typename B, typename R>\n-Monitor_EXIT<B,R>\n-::Monitor_EXIT(const Monitor_EXIT<B,R>& mon, const int n_frames)\n-: Monitor_EXIT<B,R>(mon.get_N(), mon.get_max_n_trials(), n_frames == -1 ? mon.n_frames : n_frames)\n-{\n-}\n-\n-template <typename B, typename R>\n-Monitor_EXIT<B,R>\n-::Monitor_EXIT()\n-: Monitor_EXIT<B,R>(1, 0)\n-{\n-}\n-\ntemplate <typename B, typename R>\nMonitor_EXIT<B,R>* Monitor_EXIT<B,R>\n::clone() const\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/MI/Monitor_MI.cpp",
"new_path": "src/Module/Monitor/MI/Monitor_MI.cpp",
"diff": "@@ -37,20 +37,6 @@ Monitor_MI<B,R>\nreset();\n}\n-template <typename B, typename R>\n-Monitor_MI<B,R>\n-::Monitor_MI(const Monitor_MI<B,R>& mon, const int n_frames)\n-: Monitor_MI<B,R>(mon.get_N(), mon.get_max_n_trials(), n_frames == -1 ? mon.get_n_frames() : n_frames)\n-{\n-}\n-\n-template <typename B, typename R>\n-Monitor_MI<B,R>\n-::Monitor_MI()\n-: Monitor_MI<B,R>(1, 0)\n-{\n-}\n-\ntemplate <typename B, typename R>\nMonitor_MI<B,R>* Monitor_MI<B,R>\n::clone() const\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/Monitor.cpp",
"new_path": "src/Module/Monitor/Monitor.cpp",
"diff": "@@ -26,3 +26,8 @@ void Monitor\n::reset()\n{\n}\n+\n+void Monitor\n+::clear_callbacks()\n+{\n+}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simplify the code to work with the MATLAB wrapper.
|
8,490 |
17.12.2019 15:27:18
| -3,600 |
bce7ee55fc635dfad73301ec02d08e969eb7141a
|
CI: fix the number of threads in the regression tests script.
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -371,6 +371,7 @@ for fn in fileNames:\nargsAFFECT += simuRef.getSplitCommand()\nargsAFFECT[len(argsAFFECTcommand)] = args.binaryPath;\n+ refsNThreads = args.nThreads;\n# overrides nThreads if the ref specifies an inferior number\nif \"-t\" in argsAFFECT and argsAFFECT.index(\"-t\") +1 < len(argsAFFECT):\ntry:\n@@ -378,10 +379,10 @@ for fn in fileNames:\nexcept (ValueError, TypeError):\nrefsNThreads = args.nThreads\n- if args.nThreads == 0 or refsNThreads < args.nThreads:\n- args.nThreads = refsNThreads\n+ if refsNThreads == 0 or refsNThreads > args.nThreads:\n+ refsNThreads = args.nThreads\n- argsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-meta\", simuRef.getMetadata(\"title\"), \"--sim-chain\"]\n+ argsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(refsNThreads), \"--sim-meta\", simuRef.getMetadata(\"title\"), \"--sim-chain\"]\nif args.maxFE:\nargsAFFECT += [\"-e\", str(args.maxFE)]\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
CI: fix the number of threads in the regression tests script.
|
8,490 |
17.12.2019 15:39:21
| -3,600 |
c7fe5a4dd22986450076bc93fbba0184abfce87c
|
CI: fix the case when 'args.nThreads == 0'.
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -29,7 +29,7 @@ parser.add_argument('--build-path', action='store', dest='buildPath', ty\nparser.add_argument('--binary-path', action='store', dest='binaryPath', type=str, default=\"bin/aff3ct\", help='Path to the AFF3CT binary.')\nparser.add_argument('--start-id', action='store', dest='startId', type=int, default=1, help='Starting id to avoid computing results one again.') # choices=xrange(1, +inf)\nparser.add_argument('--sensibility', action='store', dest='sensibility', type=float, default=1.0, help='Sensibility on the difference between new vs ref to verify a noise point.') # choices=xrange(1.0, +inf)\n-parser.add_argument('--n-threads', action='store', dest='nThreads', type=int, default=0, help='Max number of threads to use in the simulation (0 = all available).') # choices=xrange(0, +ing)\n+parser.add_argument('--n-threads', action='store', dest='nThreads', type=int, default=0, help='Maximum number of threads to use in the simulation (0 = all available).') # choices=xrange(0, +ing)\nparser.add_argument('--recursive-scan', action='store', dest='recursiveScan', type=bool, default=True, help='If enabled, scan the path of refs recursively.')\nparser.add_argument('--max-fe', action='store', dest='maxFE', type=int, default=100, help='Maximum number of frames errors to simulate per noise point.') # choices=xrange(0, +inf)\nparser.add_argument('--min-fe', action='store', dest='minFE', type=int, default=50, help='Minimum number of frames errors to take into account the simulated noise point.') # choices=xrange(0, +inf)\n@@ -379,7 +379,7 @@ for fn in fileNames:\nexcept (ValueError, TypeError):\nrefsNThreads = args.nThreads\n- if refsNThreads == 0 or refsNThreads > args.nThreads:\n+ if refsNThreads == 0 or (refsNThreads > args.nThreads && args.nThreads != 0):\nrefsNThreads = args.nThreads\nargsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(refsNThreads), \"--sim-meta\", simuRef.getMetadata(\"title\"), \"--sim-chain\"]\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
CI: fix the case when 'args.nThreads == 0'.
|
8,490 |
17.12.2019 17:23:37
| -3,600 |
9b3f96892e6f2a3767811d68ec2f4b87e0d5f70d
|
CI: replace '&&' by 'and'...
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -379,7 +379,7 @@ for fn in fileNames:\nexcept (ValueError, TypeError):\nrefsNThreads = args.nThreads\n- if refsNThreads == 0 or (refsNThreads > args.nThreads && args.nThreads != 0):\n+ if refsNThreads == 0 or (refsNThreads > args.nThreads and args.nThreads != 0):\nrefsNThreads = args.nThreads\nargsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(refsNThreads), \"--sim-meta\", simuRef.getMetadata(\"title\"), \"--sim-chain\"]\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
CI: replace '&&' by 'and'...
|
8,490 |
17.12.2019 17:47:58
| -3,600 |
f1be3c354c61ee6cf97d5eace526e70cb33d9d8d
|
Doc: improve the doc of the multi-kernel polar codes.
|
[
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/codec/polar_mk/codec.rst",
"new_path": "doc/source/user/simulation/parameters/codec/polar_mk/codec.rst",
"diff": "-.. _codec-polar:\n+.. _codec-polar_mk:\nCodec Polar |MK|\n****************\n"
},
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/codec/polar_mk/encoder.rst",
"new_path": "doc/source/user/simulation/parameters/codec/polar_mk/encoder.rst",
"diff": "@@ -59,6 +59,8 @@ The Kronecker powers of the kernel matrix :math:`T_s` defines the :math:`G`\ngenerator matrix. The frame size :math:`N` can only be a power of the matrix\nsize :math:`s`. For traditional Polar codes :math:`s = 2`.\n+.. note:: This parameter can only be used to define mono-kernel polar codes.\n+\n.. _enc-polar_mk-enc-pc-path:\n``--enc-pc-path``\n@@ -103,6 +105,8 @@ Kronecker product:\n.. note:: When this parameter is used it overrides the\n:ref:`enc-polar_mk-enc-pc-kernel` parameter.\n+.. note:: This parameter is the only way to define multi-kernel polar codes.\n+\n.. _enc-polar_mk-enc-fb-gen-method:\n``--enc-fb-gen-method``\n@@ -132,10 +136,6 @@ Description of the allowed values:\n.. note:: When using the ``FILE`` method, the frozen bits are always the same\nregardless of the |SNR| value.\n-.. note:: At this time, the multi-kernel mode is not supported when using the\n- ``GA`` method, should be used with the :ref:`enc-polar_mk-enc-pc-kernel`\n- parameter.\n-\n.. _enc-polar_mk-enc-fb-awgn-path:\n``--enc-fb-awgn-path``\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Doc: improve the doc of the multi-kernel polar codes.
|
8,490 |
18.12.2019 11:09:49
| -3,600 |
96602c365c9a600278445db4111704d021b02062
|
CI: add './include' folder to cppcheck and sonarqube.
|
[
{
"change_type": "MODIFY",
"old_path": "ci/analysis-cppcheck.sh",
"new_path": "ci/analysis-cppcheck.sh",
"diff": "@@ -5,7 +5,8 @@ cppcheck --version\nmkdir cppcheck\n#cppcheck --suppress=missingIncludeSystem -I./src/ --force --enable=all --std=c++11 -U_MSC_VER ./src/ 2> cppcheck_all.log\n-find .\\/src\\/ -type f -follow -print | grep \"[.]h$\\|[.]hpp$\\|[.]hxx$\\|[.]cpp$\" > src_files.txt\n+find .\\/include\\/ -type f -follow -print | grep \"[.]h$\\|[.]hpp$\\|[.]hxx$\\|[.]cpp$\" > src_files.txt\n+find .\\/src\\/ -type f -follow -print | grep \"[.]h$\\|[.]hpp$\\|[.]hxx$\\|[.]cpp$\" >> src_files.txt\n# cppcheck for sonarqube\ncppcheck --language=c++ --suppress=missingIncludeSystem --force --enable=all --std=c++11 -U_MSC_VER --file-list=src_files.txt --xml --xml-version=2 2> cppcheck/cppcheck.xml\ncppcheck --language=c++ --suppress=missingIncludeSystem --force --enable=all --std=c++11 -U_MSC_VER --file-list=src_files.txt 2> cppcheck/cppcheck_all.log\n"
},
{
"change_type": "MODIFY",
"old_path": "ci/deploy-sonarqube-linux.sh",
"new_path": "ci/deploy-sonarqube-linux.sh",
"diff": "@@ -47,7 +47,7 @@ echo \"sonar.projectVersion=$GIT_SHORT_TAG\" >> sona\necho \"sonar.scm.disabled=false\" >> sonar-project.properties\necho \"sonar.scm.provider=git\" >> sonar-project.properties\necho \"sonar.login=$SONARQUBE_TOKEN\" >> sonar-project.properties\n-echo \"sonar.sources=./src/\" >> sonar-project.properties\n+echo \"sonar.sources=./src/,./include/\" >> sonar-project.properties\necho \"sonar.links.homepage=https://aff3ct.github.io/\" >> sonar-project.properties\necho \"sonar.links.scm=https://github.com/aff3ct/aff3ct/tree/$GIT_BRANCH\" >> sonar-project.properties\necho \"sonar.links.ci=https://gitlab.com/aff3ct/aff3ct/pipelines\" >> sonar-project.properties\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
CI: add './include' folder to cppcheck and sonarqube.
|
8,490 |
27.12.2019 10:55:48
| -3,600 |
5b6543dd355f19b671150bd1e3ab2463cbac4259
|
Add bound socket method for the other way.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hpp",
"new_path": "include/Module/Socket.hpp",
"diff": "@@ -32,6 +32,7 @@ protected:\nbool fast;\nvoid* dataptr;\nstd::vector<Socket*> bound_sockets;\n+ Socket* bound_socket;\npublic:\ninline Socket(Task &task, const std::string &name, const std::type_index datatype, const size_t databytes,\n@@ -48,12 +49,13 @@ public:\ninline bool is_fast () const;\ninline Task& get_task () const;\ninline const std::vector<Socket*> get_bound_sockets () const;\n+ inline const Socket& get_bound_socket () const;\ninline void set_fast(const bool fast);\n- inline void bind(Socket &s, const bool copy_dataptr = true);\n+ inline void bind(Socket &s_out, const bool copy_dataptr = true);\n- inline void operator()(Socket &s, const bool copy_dataptr = true);\n+ inline void operator()(Socket &s_out, const bool copy_dataptr = true);\ntemplate <typename T, class A = std::allocator<T>>\ninline void bind(std::vector<T,A> &vector);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hxx",
"new_path": "include/Module/Socket.hxx",
"diff": "@@ -24,7 +24,7 @@ static std::unordered_map<std::type_index,uint8_t> type_to_size = {{typeid(int8_\nSocket\n::Socket(Task &task, const std::string &name, const std::type_index datatype, const size_t databytes,\nconst bool fast, void *dataptr)\n-: task(task), name(name), datatype(datatype), databytes(databytes), fast(fast), dataptr(dataptr)\n+: task(task), name(name), datatype(datatype), databytes(databytes), fast(fast), dataptr(dataptr), bound_socket(nullptr)\n{\n}\n@@ -88,6 +88,18 @@ const std::vector<Socket*> Socket\nreturn this->bound_sockets;\n}\n+const Socket& Socket\n+::get_bound_socket() const\n+{\n+ if (this->bound_socket == nullptr)\n+ {\n+ std::stringstream message;\n+ message << \"bound_socket can't be nullptr.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ return *this->bound_socket;\n+}\n+\nvoid Socket\n::set_fast(const bool fast)\n{\n@@ -95,18 +107,18 @@ void Socket\n}\nvoid Socket\n-::bind(Socket &s, const bool copy_dataptr)\n+::bind(Socket &s_out, const bool copy_dataptr)\n{\nif (!is_fast())\n{\n- if (s.datatype != this->datatype)\n+ if (s_out.datatype != this->datatype)\n{\nstd::stringstream message;\n- message << \"'s.datatype' has to be equal to 'datatype' (\"\n- << \"'s.datatype'\" << \" = \" << type_to_string[s.datatype] << \", \"\n- << \"'s.name'\" << \" = \" << s.get_name() << \", \"\n- << \"'s.task.name'\" << \" = \" << s.task.get_name() << \", \"\n-// << \"'s.task.module.name'\" << \" = \" << s.task.get_module_name() << \", \"\n+ message << \"'s_out.datatype' has to be equal to 'datatype' (\"\n+ << \"'s_out.datatype'\" << \" = \" << type_to_string[s_out.datatype] << \", \"\n+ << \"'s_out.name'\" << \" = \" << s_out.get_name() << \", \"\n+ << \"'s_out.task.name'\" << \" = \" << s_out.task.get_name() << \", \"\n+// << \"'s_out.task.module.name'\" << \" = \" << s_out.task.get_module_name() << \", \"\n<< \"'datatype'\" << \" = \" << type_to_string[this->datatype] << \", \"\n<< \"'name'\" << \" = \" << get_name() << \", \"\n<< \"'task.name'\" << \" = \" << task.get_name() << \", \"\n@@ -115,14 +127,14 @@ void Socket\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if (s.databytes != this->databytes)\n+ if (s_out.databytes != this->databytes)\n{\nstd::stringstream message;\n- message << \"'s.databytes' has to be equal to 'databytes' (\"\n- << \"'s.databytes'\" << \" = \" << s.databytes << \", \"\n- << \"'s.name'\" << \" = \" << s.get_name() << \", \"\n- << \"'s.task.name'\" << \" = \" << s.task.get_name() << \", \"\n-// << \"'s.task.module.name'\" << \" = \" << s.task.get_module_name() << \", \"\n+ message << \"'s_out.databytes' has to be equal to 'databytes' (\"\n+ << \"'s_out.databytes'\" << \" = \" << s_out.databytes << \", \"\n+ << \"'s_out.name'\" << \" = \" << s_out.get_name() << \", \"\n+ << \"'s_out.task.name'\" << \" = \" << s_out.task.get_name() << \", \"\n+// << \"'s_out.task.module.name'\" << \" = \" << s_out.task.get_module_name() << \", \"\n<< \"'databytes'\" << \" = \" << this->databytes << \", \"\n<< \"'name'\" << \" = \" << get_name() << \", \"\n<< \"'task.name'\" << \" = \" << task.get_name() << \", \"\n@@ -132,24 +144,24 @@ void Socket\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if (copy_dataptr && s.dataptr == nullptr)\n+ if (copy_dataptr && s_out.dataptr == nullptr)\n{\nstd::stringstream message;\n- message << \"'s.dataptr' can't be NULL.\";\n+ message << \"'s_out.dataptr' can't be NULL.\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n}\n- // this->bound_sockets.push_back(&s);\n- s.bound_sockets.push_back(this);\n+ this->bound_socket = &s_out;\n+ s_out.bound_sockets.push_back(this);\nif (copy_dataptr)\n- this->dataptr = s.dataptr;\n+ this->dataptr = s_out.dataptr;\n}\nvoid Socket\n-::operator()(Socket &s, const bool copy_dataptr)\n+::operator()(Socket &s_out, const bool copy_dataptr)\n{\n- bind(s, copy_dataptr);\n+ bind(s_out, copy_dataptr);\n}\ntemplate <typename T, class A>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add bound socket method for the other way.
|
8,490 |
27.12.2019 10:57:03
| -3,600 |
920075e0247eeba840f07629cf0af910be0915d9
|
Rm constness to the 'get_module' method of the 'Task'.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Task.hpp",
"new_path": "include/Module/Task.hpp",
"diff": "@@ -93,7 +93,7 @@ public:\ninline bool is_last_input_socket(const Socket &s_in) const;\nbool can_exec ( ) const;\n- inline const Module& get_module ( ) const;\n+ inline Module& get_module ( ) const;\ninline std::string get_name ( ) const;\ninline uint32_t get_n_calls ( ) const;\nsocket_t get_socket_type(const Socket &s) const;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Task.hxx",
"new_path": "include/Module/Task.hxx",
"diff": "@@ -44,7 +44,7 @@ bool Task\nreturn last_input_socket == &s_in;\n}\n-const Module& Task\n+Module& Task\n::get_module() const\n{\nreturn *this->module;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rm constness to the 'get_module' method of the 'Task'.
|
8,490 |
27.12.2019 10:57:46
| -3,600 |
96e8e551c7aa74aab1b1f30fa0c61352ee9a5900
|
Create an 'add_children' method in the 'Generic_node'.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Algo/Tree/Generic/Generic_node.hpp",
"new_path": "include/Tools/Algo/Tree/Generic/Generic_node.hpp",
"diff": "@@ -68,6 +68,8 @@ public:\ninline bool cut_child(const size_t pos);\ninline bool cut_children();\n+\n+ inline void add_child(Generic_node<T>* child);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Algo/Tree/Generic/Generic_node.hxx",
"new_path": "include/Tools/Algo/Tree/Generic/Generic_node.hxx",
"diff": "@@ -145,5 +145,13 @@ bool Generic_node<T>\nelse\nreturn false;\n}\n+\n+template <typename T>\n+void Generic_node<T>\n+::add_child(Generic_node<T>* child)\n+{\n+ this->children.push_back(child);\n+}\n+\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Create an 'add_children' method in the 'Generic_node'.
|
8,490 |
27.12.2019 10:58:53
| -3,600 |
079b3804e3c16c231bcfead5ef0fc01db8f68544
|
Fix CRC memory leaks in the iterative simulations.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.cpp",
"new_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.cpp",
"diff": "@@ -132,10 +132,10 @@ std::unique_ptr<module::Loop_CRC<B,Q>> Simulation_chain_BFER_ite<B,R,Q>\n::build_loop_crc()\n{\ntools::Predicate_ite p(params_BFER_ite.n_ite);\n- auto crc = params_BFER_ite.crc->build<B>();\n+ auto crc = std::unique_ptr<module::CRC<B>>(params_BFER_ite.crc->build<B>());\nauto loop_crc = std::unique_ptr<module::Loop_CRC<B,Q>>(new module::Loop_CRC<B,Q>(\np,\n- *crc,\n+ *crc.get(),\n(size_t)crc->get_size() + (size_t)crc->get_K(),\nparams_BFER_ite.cdc->N_cw,\nparams_BFER_ite.crc_start,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Legacy/BFER/Iterative/BFER_ite.cpp",
"new_path": "src/Simulation/Legacy/BFER/Iterative/BFER_ite.cpp",
"diff": "@@ -347,7 +347,7 @@ std::unique_ptr<module::Loop_CRC<B,Q>> BFER_ite<B,R,Q>\n::build_loop_crc(const int tid)\n{\ntools::Predicate_ite p(params_BFER_ite.n_ite);\n- auto crc = params_BFER_ite.crc->build<B>();\n+ auto crc = std::unique_ptr<module::CRC<B>>(params_BFER_ite.crc->build<B>());\nauto loop_crc = std::unique_ptr<module::Loop_CRC<B,Q>>(new module::Loop_CRC<B,Q>(\np,\n*crc,\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix CRC memory leaks in the iterative simulations.
|
8,490 |
27.12.2019 11:02:06
| -3,600 |
910ff7b94a0cea0a6a314f76bc88ddc4957d566a
|
Add the first implementation of the 'Chain' with a tree engine.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "#include <mutex>\n#include \"Tools/Interface/Interface_clone.hpp\"\n+#include \"Tools/Algo/Tree/Generic/Generic_node.hpp\"\nnamespace aff3ct\n{\n@@ -27,10 +28,34 @@ namespace tools\nenum class subseq_t : size_t { STD, LOOP, ROUTER };\n+class Sub_sequence_const\n+{\n+public:\n+ subseq_t type;\n+ std::vector<const module::Task*> tasks;\n+ size_t id;\n+\n+ explicit Sub_sequence_const() : type(subseq_t::STD), id(0) {}\n+ virtual ~Sub_sequence_const() = default;\n+};\n+\n+class Sub_sequence\n+{\n+public:\n+ subseq_t type;\n+ std::vector<module::Task*> tasks;\n+ size_t id;\n+\n+ explicit Sub_sequence() : type(subseq_t::STD), id(0) {}\n+ virtual ~Sub_sequence() = default;\n+};\n+\nclass Chain : Interface_clone\n{\nprotected:\nsize_t n_threads;\n+ std::vector<Generic_node<Sub_sequence>*> sequences;\n+\nstd::vector<std::vector<std::vector<module::Task*>>> tasks_sequences;\nstd::vector<std::vector<std::shared_ptr<module::Module>>> modules;\nstd::vector<subseq_t> subseq_types;\n@@ -46,7 +71,7 @@ protected:\npublic:\nChain(const module::Task &first, const size_t n_threads = 1);\nChain(const module::Task &first, const module::Task &last, const size_t n_threads = 1);\n- virtual ~Chain() = default;\n+ virtual ~Chain();\nvirtual Chain* clone() const;\nvoid exec(std::function<bool(const std::vector<int>&)> stop_condition);\n@@ -81,6 +106,36 @@ protected:\nvoid _exec_without_statuses(std::function<bool()> &stop_condition,\nstd::vector<std::vector<module::Task*>> &tasks_sequence);\nvoid duplicate(const std::vector<std::vector<const module::Task*>> &tasks_sequence);\n+\n+ // new ------------------------------------------------------------------------------------------------------------\n+ // ----------------------------------------------------------------------------------------------------------------\n+\n+ template <class SS>\n+ void delete_tree(Generic_node<SS> *node);\n+\n+ static void init_recursive_new(Generic_node<Sub_sequence_const> *cur_subseq,\n+ size_t &ssid,\n+ std::vector<const module::Task*> &loops,\n+ const module::Task& first,\n+ const module::Task& current_task,\n+ const module::Task *last = nullptr);\n+\n+ void export_dot_new_subsequence(const std::vector<module::Task*> &subseq,\n+ const subseq_t &subseq_type,\n+ const std::string &subseq_name,\n+ const std::string &tab,\n+ std::ostream &stream = std::cout) const;\n+\n+ void export_dot_new_connections(const std::vector<module::Task*> &subseq,\n+ const std::string &tab,\n+ std::ostream &stream = std::cout) const;\n+\n+ void export_dot_new(Generic_node<Sub_sequence>* root, std::ostream &stream = std::cout) const;\n+\n+ void duplicate_new(const Generic_node<Sub_sequence_const> *sequence);\n+\n+ void _exec_without_statuses_new(std::function<bool()> &stop_condition, Generic_node<Sub_sequence>* sequence);\n+\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hxx",
"new_path": "include/Tools/Chain/Chain.hxx",
"diff": "@@ -49,5 +49,19 @@ const std::vector<std::vector<module::Task*>>& Chain\nreturn this->tasks_sequences[tid];\n}\n+template <class SS>\n+void Chain\n+::delete_tree(Generic_node<SS> *node)\n+{\n+ if (node != nullptr)\n+ {\n+ for (auto c : node->get_children())\n+ this->delete_tree(c);\n+ auto c = node->get_c();\n+ if (c != nullptr) delete c;\n+ delete node;\n+ }\n+}\n+\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "+#include <set>\n#include <thread>\n#include <utility>\n#include <sstream>\n+#include <fstream>\n#include <cstring>\n#include <exception>\n#include <algorithm>\nusing namespace aff3ct;\nusing namespace aff3ct::tools;\n+#define TREE_ENGINE\n+\nChain\n::Chain(const module::Task &first, const module::Task &last, const size_t n_threads)\n: n_threads(n_threads),\n+ sequences(n_threads, nullptr),\ntasks_sequences(n_threads),\nmodules(n_threads),\nmtx_exception(new std::mutex()),\n@@ -31,6 +36,7 @@ Chain\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+#ifndef TREE_ENGINE\nstd::vector<std::vector<const module::Task*>> tasks_sequence;\ntasks_sequence.push_back(std::vector<const module::Task*>());\nstd::vector<const module::Task*> loops;\n@@ -65,11 +71,20 @@ Chain\nfor (size_t ta = 0; ta < tasks_sequence[ss].size(); ta++)\nthis->task_id[ss][ta] = id++;\n}\n+#else\n+ auto root = new Generic_node<Sub_sequence_const>(nullptr, {}, nullptr, 0, 0, 0);\n+ size_t ssid = 0;\n+ std::vector<const module::Task*> loops;\n+ this->init_recursive_new(root, ssid, loops, first, first, &last);\n+ this->duplicate_new(root);\n+ this->delete_tree(root);\n+#endif\n}\nChain\n::Chain(const module::Task &first, const size_t n_threads)\n: n_threads(n_threads),\n+ sequences(n_threads, nullptr),\ntasks_sequences(n_threads),\nmodules(n_threads),\nmtx_exception(new std::mutex()),\n@@ -82,6 +97,7 @@ Chain\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+#ifndef TREE_ENGINE\nstd::vector<std::vector<const module::Task*>> tasks_sequence;\ntasks_sequence.push_back(std::vector<const module::Task*>());\nstd::vector<const module::Task*> loops;\n@@ -106,6 +122,23 @@ Chain\nfor (size_t ta = 0; ta < tasks_sequence[ss].size(); ta++)\nthis->task_id[ss][ta] = id++;\n}\n+#else\n+ auto root = new Generic_node<Sub_sequence_const>(nullptr, {}, nullptr, 0, 0, 0);\n+ size_t ssid = 0;\n+ std::vector<const module::Task*> loops;\n+ this->init_recursive_new(root, ssid, loops, first, first);\n+ this->duplicate_new(root);\n+ this->delete_tree(root);\n+#endif\n+}\n+\n+Chain::\n+~Chain()\n+{\n+#ifdef TREE_ENGINE\n+ for (auto s : this->sequences)\n+ this->delete_tree(s);\n+#endif\n}\nChain* Chain\n@@ -178,6 +211,7 @@ void Chain\nvoid Chain\n::export_dot(std::ostream &stream) const\n{\n+#ifndef TREE_ENGINE\nstd::string tab = \"\\t\";\nstream << \"digraph Chain {\" << std::endl;\n@@ -206,6 +240,122 @@ void Chain\n}\n}\n+ stream << \"}\" << std::endl;\n+#else\n+ this->export_dot_new(this->sequences[0], stream);\n+#endif\n+}\n+\n+void Chain\n+::export_dot_new_subsequence(const std::vector<module::Task*> &subseq,\n+ const subseq_t &subseq_type,\n+ const std::string &subseq_name,\n+ const std::string &tab,\n+ std::ostream &stream) const\n+{\n+ if (!subseq_name.empty())\n+ {\n+ stream << tab << \"subgraph \\\"cluster_\" << subseq_name << \"\\\" {\" << std::endl;\n+ stream << tab << tab << \"node [style=filled];\" << std::endl;\n+ }\n+ size_t exec_order = 0;\n+ for (auto &t : subseq)\n+ {\n+ stream << tab << tab << \"subgraph \\\"cluster_\" << +&t->get_module() << \"_\" << +&t << \"\\\" {\" << std::endl;\n+ stream << tab << tab << tab << \"node [style=filled];\" << std::endl;\n+ stream << tab << tab << tab << \"subgraph \\\"cluster_\" << +&t << \"\\\" {\" << std::endl;\n+ stream << tab << tab << tab << tab << \"node [style=filled];\" << std::endl;\n+ for (auto &s : t->sockets)\n+ {\n+ std::string stype;\n+ switch (t->get_socket_type(*s))\n+ {\n+ case module::socket_t::SIN: stype = \"in\"; break;\n+ case module::socket_t::SOUT: stype = \"out\"; break;\n+ case module::socket_t::SIN_SOUT: stype = \"in_out\"; break;\n+ default: stype = \"unkn\"; break;\n+ }\n+ stream << tab << tab << tab << tab << \"\\\"\" << +s.get() << \"\\\"\"\n+ << \"[label=\\\"\" << stype << \":\" << s->get_name() << \"\\\"];\" << std::endl;\n+ }\n+ stream << tab << tab << tab << tab << \"label=\\\"\" << t->get_name() << \"\\\";\" << std::endl;\n+ stream << tab << tab << tab << tab << \"color=blue;\" << std::endl;\n+ stream << tab << tab << tab << \"}\" << std::endl;\n+ stream << tab << tab << tab << \"label=\\\"\" << t->get_module().get_name() << \"\\n\"\n+ << \"exec order: [\" << exec_order++ << \"]\\n\"\n+ << \"addr: \" << +&t->get_module() << \"\\\";\" << std::endl;\n+ stream << tab << tab << tab << \"color=blue;\" << std::endl;\n+ stream << tab << tab << \"}\" << std::endl;\n+ }\n+ if (!subseq_name.empty())\n+ {\n+ stream << tab << tab << \"label=\\\"\" << subseq_name << \"\\\";\" << std::endl;\n+ std::string color = subseq_type == subseq_t::LOOP ? \"red\" : \"blue\";\n+ stream << tab << tab << \"color=\" << color << \";\" << std::endl;\n+ stream << tab << \"}\" << std::endl;\n+ }\n+}\n+\n+void Chain\n+::export_dot_new_connections(const std::vector<module::Task*> &subseq,\n+ const std::string &tab,\n+ std::ostream &stream) const\n+{\n+ for (auto &t : subseq)\n+ {\n+ for (auto &s : t->sockets)\n+ {\n+ if (t->get_socket_type(*s) == module::socket_t::SOUT ||\n+ t->get_socket_type(*s) == module::socket_t::SIN_SOUT)\n+ {\n+ for (auto &bs : s->get_bound_sockets())\n+ {\n+ stream << tab << \"\\\"\" << +s.get() << \"\\\" -> \\\"\" << +bs << \"\\\"\" << std::endl;\n+ }\n+ }\n+ }\n+ }\n+}\n+\n+void Chain\n+::export_dot_new(Generic_node<Sub_sequence>* root, std::ostream &stream) const\n+{\n+ std::function<void(Generic_node<Sub_sequence>*,\n+ const std::string&,\n+ std::ostream&)> export_dot_new_subsequences_rec =\n+ [&, this](Generic_node<Sub_sequence>* cur_node, const std::string &tab, std::ostream &stream)\n+ {\n+ if (cur_node != nullptr)\n+ {\n+ this->export_dot_new_subsequence(cur_node->get_c()->tasks,\n+ cur_node->get_c()->type,\n+ \"Sub-sequence\"+std::to_string(cur_node->get_c()->id),\n+ tab,\n+ stream);\n+\n+ for (auto c : cur_node->get_children())\n+ export_dot_new_subsequences_rec(c, tab, stream);\n+ }\n+ };\n+\n+ std::function<void(Generic_node<Sub_sequence>*,\n+ const std::string&,\n+ std::ostream&)> export_dot_new_connections_rec =\n+ [&, this](Generic_node<Sub_sequence> *cur_node, const std::string &tab, std::ostream &stream)\n+ {\n+ if (cur_node != nullptr)\n+ {\n+ this->export_dot_new_connections(cur_node->get_c()->tasks, tab, stream);\n+\n+ for (auto c : cur_node->get_children())\n+ export_dot_new_connections_rec(c, tab, stream);\n+ }\n+ };\n+\n+ std::string tab = \"\\t\";\n+ stream << \"digraph Chain {\" << std::endl;\n+ export_dot_new_subsequences_rec(root, tab, stream);\n+ export_dot_new_connections_rec (root, tab, stream);\nstream << \"}\" << std::endl;\n}\n@@ -329,6 +479,61 @@ void Chain\n}\n}\n+void Chain\n+::_exec_without_statuses_new(std::function<bool()> &stop_condition, Generic_node<Sub_sequence>* sequence)\n+{\n+ std::function<void(Generic_node<Sub_sequence>*)> exec_sequence =\n+ [&exec_sequence](Generic_node<Sub_sequence>* cur_ss)\n+ {\n+ auto c = *cur_ss->get_c();\n+ if (c.type == subseq_t::LOOP)\n+ {\n+ while (!c.tasks[0]->exec())\n+ exec_sequence(cur_ss->get_children()[0]);\n+ static_cast<module::Loop&>(c.tasks[0]->get_module()).reset();\n+ exec_sequence(cur_ss->get_children()[1]);\n+ }\n+ else\n+ {\n+ for (size_t ta = 0; ta < c.tasks.size(); ta++)\n+ c.tasks[ta]->exec();\n+ for (auto c : cur_ss->get_children())\n+ exec_sequence(c);\n+ }\n+ };\n+\n+ try\n+ {\n+ do\n+ {\n+ exec_sequence(sequence);\n+ }\n+ while (!*force_exit_loop && !stop_condition());\n+ }\n+ catch (std::exception const& e)\n+ {\n+ *force_exit_loop = true;\n+\n+ this->mtx_exception->lock();\n+\n+ auto save = tools::exception::no_backtrace;\n+ tools::exception::no_backtrace = true;\n+ std::string msg = e.what(); // get only the function signature\n+ tools::exception::no_backtrace = save;\n+\n+ if (std::find(this->prev_exception_messages.begin(), this->prev_exception_messages.end(), msg) ==\n+ this->prev_exception_messages.end())\n+ {\n+ this->prev_exception_messages.push_back(msg); // save only the function signature\n+ this->prev_exception_messages_to_display.push_back(e.what()); // with backtrace if debug mode\n+ }\n+ else if (std::strlen(e.what()) > this->prev_exception_messages_to_display.back().size())\n+ this->prev_exception_messages_to_display[prev_exception_messages_to_display.size() -1] = e.what();\n+\n+ this->mtx_exception->unlock();\n+ }\n+}\n+\nvoid Chain\n::exec(std::function<bool(const std::vector<int>&)> stop_condition)\n{\n@@ -348,6 +553,7 @@ void Chain\n}\n}\n+#ifndef TREE_ENGINE\nvoid Chain\n::exec(std::function<bool()> stop_condition)\n{\n@@ -367,6 +573,27 @@ void Chain\nthrow std::runtime_error(this->prev_exception_messages_to_display.back());\n}\n}\n+#else\n+void Chain\n+::exec(std::function<bool()> stop_condition)\n+{\n+ std::vector<std::thread> threads(n_threads);\n+ for (size_t tid = 1; tid < n_threads; tid++)\n+ threads[tid] = std::thread(&Chain::_exec_without_statuses_new, this, std::ref(stop_condition),\n+ std::ref(this->sequences[tid]));\n+\n+ this->_exec_without_statuses_new(stop_condition, this->sequences[0]);\n+\n+ for (size_t tid = 1; tid < n_threads; tid++)\n+ threads[tid].join();\n+\n+ if (!this->prev_exception_messages_to_display.empty())\n+ {\n+ *force_exit_loop = false;\n+ throw std::runtime_error(this->prev_exception_messages_to_display.back());\n+ }\n+}\n+#endif\nint Chain\n::exec(const size_t tid)\n@@ -495,6 +722,120 @@ void Chain\n}\n}\n+void Chain\n+::init_recursive_new(Generic_node<Sub_sequence_const> *cur_subseq,\n+ size_t &ssid,\n+ std::vector<const module::Task*> &loops,\n+ const module::Task &first,\n+ const module::Task ¤t_task,\n+ const module::Task *last)\n+{\n+ if (auto loop = dynamic_cast<const module::Loop*>(¤t_task.get_module()))\n+ {\n+ if (std::find(loops.begin(), loops.end(), ¤t_task) == loops.end())\n+ {\n+ loops.push_back(¤t_task);\n+ Generic_node<Sub_sequence_const>* node_loop = nullptr;\n+ if (&first == ¤t_task)\n+ node_loop = cur_subseq;\n+ else\n+ {\n+ ssid++;\n+ node_loop = new Generic_node<Sub_sequence_const>(cur_subseq, {}, nullptr, cur_subseq->get_depth() +1, 0, 0);\n+ }\n+\n+ auto node_loop_son0 = new Generic_node<Sub_sequence_const>(node_loop, {}, nullptr, node_loop->get_depth() +1, 0, 0);\n+ auto node_loop_son1 = new Generic_node<Sub_sequence_const>(node_loop, {}, nullptr, node_loop->get_depth() +1, 0, 1);\n+ node_loop->add_child(node_loop_son0);\n+ node_loop->add_child(node_loop_son1);\n+\n+ node_loop->set_contents(new Sub_sequence_const());\n+ node_loop_son0->set_contents(new Sub_sequence_const());\n+ node_loop_son1->set_contents(new Sub_sequence_const());\n+\n+ node_loop->get_c()->tasks.push_back(¤t_task);\n+ node_loop->get_c()->type = subseq_t::LOOP;\n+ node_loop->get_c()->id = ssid++;\n+\n+ if (!cur_subseq->get_children().size())\n+ cur_subseq->add_child(node_loop);\n+\n+ if (loop->tasks[0]->sockets[2]->get_bound_sockets().size() == 1)\n+ {\n+ node_loop_son0->get_c()->id = ssid++;\n+ auto &t = loop->tasks[0]->sockets[2]->get_bound_sockets()[0]->get_task();\n+ Chain::init_recursive_new(node_loop_son0, ssid, loops, first, t, last);\n+ }\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"'loop->tasks[0]->sockets[2]->get_bound_sockets().size()' has to be equal to 1 (\"\n+ << \"'loop->tasks[0]->sockets[2]->get_bound_sockets().size()' = \"\n+ << loop->tasks[0]->sockets[2]->get_bound_sockets().size() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (loop->tasks[0]->sockets[3]->get_bound_sockets().size() == 1)\n+ {\n+ node_loop_son1->get_c()->id = ssid++;\n+ auto &t = loop->tasks[0]->sockets[3]->get_bound_sockets()[0]->get_task();\n+ Chain::init_recursive_new(node_loop_son1, ssid, loops, first, t, last);\n+ }\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"'loop->tasks[0]->sockets[3]->get_bound_sockets().size()' has to be equal to 1 (\"\n+ << \"'loop->tasks[0]->sockets[3]->get_bound_sockets().size()' = \"\n+ << loop->tasks[0]->sockets[3]->get_bound_sockets().size() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ }\n+ else\n+ {\n+ if (&first == ¤t_task)\n+ cur_subseq->set_contents(new Sub_sequence_const());\n+\n+ cur_subseq->get_c()->tasks.push_back(¤t_task);\n+\n+ if (¤t_task != last)\n+ {\n+ for (auto &s : current_task.sockets)\n+ {\n+ if (current_task.get_socket_type(*s) == module::socket_t::SIN_SOUT ||\n+ current_task.get_socket_type(*s) == module::socket_t::SOUT)\n+ {\n+ auto bss = s->get_bound_sockets();\n+ for (auto &bs : bss)\n+ {\n+ if (bs != nullptr)\n+ {\n+ auto &t = bs->get_task();\n+ if (t.is_last_input_socket(*bs) || dynamic_cast<const module::Loop*>(&t.get_module()))\n+ Chain::init_recursive_new(cur_subseq, ssid, loops, first, t, last);\n+ }\n+ }\n+ }\n+ else if (current_task.get_socket_type(*s) == module::socket_t::SIN)\n+ {\n+ if (s->get_bound_sockets().size() > 1)\n+ {\n+ std::stringstream message;\n+ message << \"'s->get_bound_sockets().size()' has to be smaller or equal to 1 (\"\n+ << \"'s->get_bound_sockets().size()'\" << \" = \" << s->get_bound_sockets().size() << \", \"\n+ << \"'get_socket_type(*s)'\" << \" = \" << \"socket_t::SIN\" << \", \"\n+ << \"'s->get_name()'\" << \" = \" << s->get_name() << \", \"\n+ << \"'s->get_task().get_name()'\" << \" = \" << s->get_task().get_name() << \", \"\n+ << \"'s->get_task().get_module().get_name()'\" << \" = \" << s->get_task().get_module().get_name()\n+ << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ }\n+ }\n+ }\n+}\n+\nvoid Chain\n::duplicate(const std::vector<std::vector<const module::Task*>> &tasks_sequence)\n{\n@@ -633,3 +974,141 @@ void Chain\n}\n}\n}\n+\n+void Chain\n+::duplicate_new(const Generic_node<Sub_sequence_const> *sequence)\n+{\n+ std::set<const module::Module*> modules_set;\n+\n+ std::function<void(const Generic_node<Sub_sequence_const>*)> collect_modules_list;\n+ collect_modules_list = [&](const Generic_node<Sub_sequence_const> *node)\n+ {\n+ if (node != nullptr)\n+ {\n+ if (node->get_c())\n+ for (auto ta : node->get_c()->tasks)\n+ modules_set.insert(&ta->get_module());\n+ for (auto c : node->get_children())\n+ collect_modules_list(c);\n+ }\n+ };\n+ collect_modules_list(sequence);\n+\n+ std::vector<const module::Module*> modules_vec;\n+ for (auto m : modules_set)\n+ modules_vec.push_back(m);\n+\n+ // clone the modules\n+ for (size_t tid = 0; tid < this->n_threads; tid++)\n+ {\n+ this->modules[tid].resize(modules_vec.size());\n+ for (size_t m = 0; m < modules_vec.size(); m++)\n+ this->modules[tid][m].reset(modules_vec[m]->clone());\n+ }\n+\n+ auto get_module_id = [](const std::vector<const module::Module*> &modules, const module::Module &module)\n+ {\n+ int m_id;\n+ for (m_id = 0; m_id < (int)modules.size(); m_id++)\n+ if (modules[m_id] == &module)\n+ return m_id;\n+ return -1;\n+ };\n+\n+ auto get_task_id = [](const std::vector<std::shared_ptr<module::Task>> &tasks, const module::Task &task)\n+ {\n+ int t_id;\n+ for (t_id = 0; t_id < (int)tasks.size(); t_id++)\n+ if (tasks[t_id].get() == &task)\n+ return t_id;\n+ return -1;\n+ };\n+\n+ auto get_socket_id = [](const std::vector<std::shared_ptr<module::Socket>> &sockets, const module::Socket &socket)\n+ {\n+ int s_id;\n+ for (s_id = 0; s_id < (int)sockets.size(); s_id++)\n+ if (sockets[s_id].get() == &socket)\n+ return s_id;\n+ return -1;\n+ };\n+\n+ std::function<void(const Generic_node<Sub_sequence_const>*,\n+ Generic_node<Sub_sequence>*,\n+ const size_t)> duplicate_sequence;\n+\n+ duplicate_sequence = [&](const Generic_node<Sub_sequence_const> *sequence_ref,\n+ Generic_node<Sub_sequence > *sequence_cpy,\n+ const size_t thread_id)\n+ {\n+ if (sequence_ref != nullptr && sequence_ref->get_c())\n+ {\n+ auto ss_ref = sequence_ref->get_c();\n+ auto ss_cpy = new Sub_sequence();\n+\n+ ss_cpy->type = ss_ref->type;\n+ ss_cpy->id = ss_ref->id;\n+ for (auto t_ref : ss_ref->tasks)\n+ {\n+ auto &m_ref = t_ref->get_module();\n+\n+ auto m_id = get_module_id(modules_vec, m_ref);\n+ auto t_id = get_task_id(m_ref.tasks, *t_ref);\n+\n+ assert(m_id != -1);\n+ assert(t_id != -1);\n+\n+ // add the task to the sub-sequence\n+ ss_cpy->tasks.push_back(this->modules[thread_id][m_id]->tasks[t_id].get());\n+\n+ // replicate the sockets binding\n+ for (size_t s_id = 0; s_id < t_ref->sockets.size(); s_id++)\n+ {\n+ if (t_ref->get_socket_type(*t_ref->sockets[s_id]) == module::socket_t::SIN_SOUT ||\n+ t_ref->get_socket_type(*t_ref->sockets[s_id]) == module::socket_t::SIN)\n+ {\n+ try\n+ {\n+ auto &s_ref_out = t_ref->sockets[s_id]->get_bound_socket(); // can raise an exception\n+ auto &t_ref_out = s_ref_out.get_task();\n+ auto &m_ref_out = t_ref_out.get_module();\n+\n+ auto m_id_out = get_module_id(modules_vec, m_ref_out);\n+ auto t_id_out = get_task_id(m_ref_out.tasks, t_ref_out);\n+ auto s_id_out = get_socket_id(t_ref_out.sockets, s_ref_out);\n+\n+ assert(m_id_out != -1);\n+ assert(t_id_out != -1);\n+ assert(s_id_out != -1);\n+\n+ auto &s_in = (*this->modules[thread_id][m_id])[t_id][s_id];\n+ auto &s_out = (*this->modules[thread_id][m_id_out])[t_id_out][s_id_out];\n+\n+ s_in.bind(s_out);\n+ }\n+ catch (...) {}\n+ }\n+ }\n+ }\n+\n+ sequence_cpy->set_contents(ss_cpy);\n+\n+ for (size_t c = 0; c < sequence_ref->get_children().size(); c++)\n+ sequence_cpy->add_child(new Generic_node<Sub_sequence>(sequence_cpy,\n+ {},\n+ nullptr,\n+ sequence_cpy->get_depth() +1,\n+ 0,\n+ c));\n+\n+ for (size_t c = 0; c < sequence_ref->get_children().size(); c++)\n+ duplicate_sequence(sequence_ref->get_children()[c], sequence_cpy->get_children()[c], thread_id);\n+ }\n+ };\n+\n+ for (size_t thread_id = 0; thread_id < this->sequences.size(); thread_id++)\n+ {\n+ this->sequences[thread_id] = new Generic_node<Sub_sequence>(nullptr, {}, nullptr, 0, 0, 0);\n+ duplicate_sequence(sequence, this->sequences[thread_id], thread_id);\n+ }\n+}\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the first implementation of the 'Chain' with a tree engine.
|
8,490 |
28.12.2019 10:12:59
| -3,600 |
eed0085b0906fe792592604a30ee1de4a37c3cbe
|
Rm useless code.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.cpp",
"new_path": "src/Simulation/Chain/BFER/Iterative/Simulation_chain_BFER_ite.cpp",
"diff": "@@ -636,30 +636,12 @@ void Simulation_chain_BFER_ite<B,R,Q>\nauto monitors_er = this->chain->template get_modules<module::Monitor_BFER<B >>();\nauto decoders_siso = this->chain->template get_modules<module::Decoder_SISO<B,Q>>();\n- auto loops_ite = this->chain->template get_modules<module::Loop_predicate<Q >>();\n- auto loops_crc = this->chain->template get_modules<module::Loop_CRC <B,Q>>();\nfor (size_t m = 0; m < monitors_er.size(); m++)\n- {\n- auto cur_monitor_er = monitors_er[m];\n-\nif (m < decoders_siso.size())\n{\nauto cur_decoder_siso = decoders_siso[m];\ncur_decoder_siso->set_auto_reset(false);\n- cur_monitor_er->record_callback_check([cur_decoder_siso](){ cur_decoder_siso->reset(); });\n- }\n-\n- if (m < loops_ite.size())\n- {\n- auto cur_loop_ite = loops_ite[m];\n- cur_monitor_er->record_callback_check([cur_loop_ite](){ cur_loop_ite->reset(); });\n- }\n-\n- if (m < loops_crc.size())\n- {\n- auto cur_loop_crc = loops_crc[m];\n- cur_monitor_er->record_callback_check([cur_loop_crc](){ cur_loop_crc->reset(); });\n- }\n+ monitors_er[m]->record_callback_check([cur_decoder_siso](){ cur_decoder_siso->reset(); });\n}\nif (this->params_BFER_ite.err_track_enable)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rm useless code.
|
8,490 |
02.01.2020 14:34:19
| -3,600 |
1767eb64eb9481177cd69f87eb4e4d7b86d3bcb1
|
Fix bug in the chain engine.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -101,17 +101,20 @@ protected:\nconst module::Task& current_task,\nconst module::Task *last = nullptr);\n- void export_dot_subsequence(const std::vector<module::Task*> &subseq,\n+ template <class VTA>\n+ void export_dot_subsequence(const VTA &subseq,\nconst subseq_t &subseq_type,\nconst std::string &subseq_name,\nconst std::string &tab,\nstd::ostream &stream = std::cout) const;\n- void export_dot_connections(const std::vector<module::Task*> &subseq,\n+ template <class VTA>\n+ void export_dot_connections(const VTA &subseq,\nconst std::string &tab,\nstd::ostream &stream = std::cout) const;\n- void export_dot(Generic_node<Sub_sequence>* root, std::ostream &stream = std::cout) const;\n+ template <class SS>\n+ void export_dot(Generic_node<SS>* root, std::ostream &stream = std::cout) const;\ntemplate <class SS>\nvoid duplicate(const Generic_node<SS> *sequence);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -173,7 +173,6 @@ void Chain\n}\n};\n-\nstd::vector<int> statuses(this->n_tasks, 0);\ntry\n{\n@@ -425,15 +424,18 @@ const module::Task& Chain\ncurrent_task.get_socket_type(*s) == module::socket_t::SOUT)\n{\nauto bss = s->get_bound_sockets();\n+ const module::Task* last_task = nullptr;\nfor (auto &bs : bss)\n{\nif (bs != nullptr)\n{\nauto &t = bs->get_task();\nif (t.is_last_input_socket(*bs) || dynamic_cast<const module::Loop*>(&t.get_module()))\n- return Chain::init_recursive(cur_subseq, ssid, taid, loops, first, t, last);\n+ last_task = &Chain::init_recursive(cur_subseq, ssid, taid, loops, first, t, last);\n}\n}\n+ if (last_task)\n+ return *last_task;\n}\nelse if (current_task.get_socket_type(*s) == module::socket_t::SIN)\n{\n@@ -550,10 +552,11 @@ void Chain\nif (t_ref->get_socket_type(*t_ref->sockets[s_id]) == module::socket_t::SIN_SOUT ||\nt_ref->get_socket_type(*t_ref->sockets[s_id]) == module::socket_t::SIN)\n{\n- try\n+ const module::Socket* s_ref_out = nullptr;\n+ try { s_ref_out = &t_ref->sockets[s_id]->get_bound_socket(); } catch (...) {}\n+ if (s_ref_out)\n{\n- auto &s_ref_out = t_ref->sockets[s_id]->get_bound_socket(); // can raise an exception\n- auto &t_ref_out = s_ref_out.get_task();\n+ auto &t_ref_out = s_ref_out->get_task();\nauto &m_ref_out = t_ref_out.get_module();\nauto m_id_out = get_module_id(modules_vec, m_ref_out);\n@@ -561,18 +564,18 @@ void Chain\nif (m_id_out != -1)\n{\nauto t_id_out = get_task_id(m_ref_out.tasks, t_ref_out);\n- auto s_id_out = get_socket_id(t_ref_out.sockets, s_ref_out);\n+ auto s_id_out = get_socket_id(t_ref_out.sockets, *s_ref_out);\nassert(t_id_out != -1);\nassert(s_id_out != -1);\n- auto &s_in = (*this->modules[thread_id][m_id])[t_id][s_id];\n- auto &s_out = (*this->modules[thread_id][m_id_out])[t_id_out][s_id_out];\n+ (*this->modules[thread_id][m_id_out]).tasks[t_id_out]->set_autoalloc(true);\n+ auto &s_in = *this->modules[thread_id][m_id ]->tasks[t_id ]->sockets[s_id ];\n+ auto &s_out = *this->modules[thread_id][m_id_out]->tasks[t_id_out]->sockets[s_id_out];\ns_in.bind(s_out);\n}\n}\n- catch (...) {}\n}\n}\n}\n@@ -620,8 +623,9 @@ void Chain\ntemplate void tools::Chain::delete_tree<tools::Sub_sequence_const>(Generic_node<tools::Sub_sequence_const>*);\ntemplate void tools::Chain::delete_tree<tools::Sub_sequence >(Generic_node<tools::Sub_sequence >*);\n+template <class VTA>\nvoid Chain\n-::export_dot_subsequence(const std::vector<module::Task*> &subseq,\n+::export_dot_subsequence(const VTA &subseq,\nconst subseq_t &subseq_type,\nconst std::string &subseq_name,\nconst std::string &tab,\n@@ -670,8 +674,12 @@ void Chain\n}\n}\n+template void tools::Chain::export_dot_subsequence<std::vector< module::Task*>>(const std::vector< module::Task*>&, const subseq_t&, const std::string&, const std::string&, std::ostream&) const;\n+template void tools::Chain::export_dot_subsequence<std::vector<const module::Task*>>(const std::vector<const module::Task*>&, const subseq_t&, const std::string&, const std::string&, std::ostream&) const;\n+\n+template <class VTA>\nvoid Chain\n-::export_dot_connections(const std::vector<module::Task*> &subseq,\n+::export_dot_connections(const VTA &subseq,\nconst std::string &tab,\nstd::ostream &stream) const\n{\n@@ -691,13 +699,24 @@ void Chain\n}\n}\n+template void tools::Chain::export_dot_connections<std::vector< module::Task*>>(const std::vector< module::Task*>&, const std::string&, std::ostream&) const;\n+template void tools::Chain::export_dot_connections<std::vector<const module::Task*>>(const std::vector<const module::Task*>&, const std::string&, std::ostream&) const;\n+\nvoid Chain\n::export_dot(std::ostream &stream) const\n{\n- std::function<void(Generic_node<Sub_sequence>*,\n+ auto root = this->sequences[0];\n+ this->export_dot(root, stream);\n+}\n+\n+template <class SS>\n+void Chain\n+::export_dot(Generic_node<SS>* root, std::ostream &stream) const\n+{\n+ std::function<void(Generic_node<SS>*,\nconst std::string&,\nstd::ostream&)> export_dot_subsequences_recursive =\n- [&export_dot_subsequences_recursive, this](Generic_node<Sub_sequence>* cur_node,\n+ [&export_dot_subsequences_recursive, this](Generic_node<SS>* cur_node,\nconst std::string &tab,\nstd::ostream &stream)\n{\n@@ -714,10 +733,10 @@ void Chain\n}\n};\n- std::function<void(Generic_node<Sub_sequence>*,\n+ std::function<void(Generic_node<SS>*,\nconst std::string&,\nstd::ostream&)> export_dot_connections_recursive =\n- [&export_dot_connections_recursive, this](Generic_node<Sub_sequence> *cur_node,\n+ [&export_dot_connections_recursive, this](Generic_node<SS> *cur_node,\nconst std::string &tab,\nstd::ostream &stream)\n{\n@@ -730,7 +749,6 @@ void Chain\n}\n};\n- auto root = this->sequences[0];\nstd::string tab = \"\\t\";\nstream << \"digraph Chain {\" << std::endl;\nexport_dot_subsequences_recursive(root, tab, stream);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix bug in the chain engine.
|
8,490 |
02.01.2020 18:23:29
| -3,600 |
9e1dc009ba833c2f326705432c0d6455106fedec
|
Improve task error message.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "@@ -328,9 +328,17 @@ int Task\n}\nelse\n{\n+ std::stringstream socs;\n+ socs << \"'socket(s).name' = [\";\n+ auto s = 0;\n+ for (size_t i = 0; i < sockets.size(); i++)\n+ if (sockets[i]->dataptr == nullptr)\n+ socs << (s != 0 ? \", \" : \"\") << sockets[i]->name;\n+ socs << \"]\";\n+\nstd::stringstream message;\n- message << \"The task cannot be executed because some of the inputs/outputs are not fed ('task.name' = \"\n- << this->get_name() << \", 'module.name' = \" << module->get_name() << \").\";\n+ message << \"The task cannot be executed because some of the inputs/output sockets are not fed ('task.name' = \"\n+ << this->get_name() << \", 'module.name' = \" << module->get_name() << \", \" << socs.str() << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve task error message.
|
8,490 |
02.01.2020 18:23:49
| -3,600 |
8150b80c7494c41b9345f691c1c9753118adcdce
|
Fix 'Chain' bugs when using 'Subchain'.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -120,6 +120,20 @@ Chain* Chain\nc->duplicate(this->sequences[0]);\nc->mtx_exception.reset(new std::mutex());\nc->force_exit_loop.reset(new std::atomic<bool>(false));\n+\n+ std::function<Sub_sequence*(Generic_node<Sub_sequence>*)> get_last = [&get_last](Generic_node<Sub_sequence>* node)\n+ {\n+ Sub_sequence* last = node->get_c();\n+ for (auto c : node->get_children())\n+ last = get_last(c);\n+ return last;\n+ };\n+ for (size_t tid = 0; tid < c->n_threads; tid++)\n+ {\n+ c->first_tasks[tid] = c->sequences[tid]->get_c()->tasks.front();\n+ c->last_tasks[tid] = get_last(c->sequences[tid])->tasks.back();\n+ }\n+\nreturn c;\n}\n@@ -596,10 +610,20 @@ void Chain\n}\n};\n+ std::function<void(Generic_node<Sub_sequence>*)> set_autoalloc_true =\n+ [&set_autoalloc_true](Generic_node<Sub_sequence>* node)\n+ {\n+ for (auto t : node->get_c()->tasks)\n+ t->set_autoalloc(true);\n+ for (auto c : node->get_children())\n+ set_autoalloc_true(c);\n+ };\n+\nfor (size_t thread_id = 0; thread_id < this->sequences.size(); thread_id++)\n{\nthis->sequences[thread_id] = new Generic_node<Sub_sequence>(nullptr, {}, nullptr, 0, 0, 0);\nduplicate_sequence(sequence, this->sequences[thread_id], thread_id);\n+ set_autoalloc_true(this->sequences[thread_id]);\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix 'Chain' bugs when using 'Subchain'.
|
8,490 |
03.01.2020 10:42:02
| -3,600 |
e7eebcd6678c4e379a34867c4b0b4b2026789518
|
Simplify the source code of the 'Chain'.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -28,29 +28,21 @@ namespace tools\nenum class subseq_t : size_t { STD, LOOP, ROUTER };\n-class Sub_sequence_const\n+template <class VTA = std::vector<module::Task*>>\n+class Sub_sequence_generic\n{\npublic:\nsubseq_t type;\n- std::vector<const module::Task*> tasks;\n+ VTA tasks;\nstd::vector<size_t> tasks_id;\nsize_t id;\n- explicit Sub_sequence_const() : type(subseq_t::STD), id(0) {}\n- virtual ~Sub_sequence_const() = default;\n+ explicit Sub_sequence_generic() : type(subseq_t::STD), id(0) {}\n+ virtual ~Sub_sequence_generic() = default;\n};\n-class Sub_sequence\n-{\n-public:\n- subseq_t type;\n- std::vector<module::Task*> tasks;\n- std::vector<size_t> tasks_id;\n- size_t id;\n-\n- explicit Sub_sequence() : type(subseq_t::STD), id(0) {}\n- virtual ~Sub_sequence() = default;\n-};\n+using Sub_sequence = Sub_sequence_generic<std::vector< module::Task*>>;\n+using Sub_sequence_const = Sub_sequence_generic<std::vector<const module::Task*>>;\nclass Chain : Interface_clone\n{\n@@ -72,6 +64,7 @@ public:\nChain(const module::Task &first, const size_t n_threads = 1);\nChain(const module::Task &first, const module::Task &last, const size_t n_threads = 1);\nvirtual ~Chain();\n+ void init(const module::Task &first, const module::Task *last = nullptr);\nvirtual Chain* clone() const;\nvoid exec(std::function<bool(const std::vector<int>&)> stop_condition);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -28,43 +28,7 @@ Chain\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false))\n{\n- if (n_threads == 0)\n- {\n- std::stringstream message;\n- message << \"'n_threads' has to be strictly greater than 0.\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- auto root = new Generic_node<Sub_sequence_const>(nullptr, {}, nullptr, 0, 0, 0);\n- size_t ssid = 0, taid = 0;\n- std::vector<const module::Task*> loops;\n- auto &real_last = this->init_recursive(root, ssid, taid, loops, first, first, &last);\n- if (&real_last != &last)\n- {\n- std::stringstream message;\n- message << \"'&real_last' has to be equal to '&last' (\"\n- << \"'&real_last'\" << \" = \" << +&real_last << \", \"\n- << \"'&last'\" << \" = \" << +&last << \", \"\n- << \"'real_last.get_name()'\" << \" = \" << real_last.get_name() << \", \"\n- << \"'last.get_name()'\" << \" = \" << last.get_name() << \").\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n- this->n_tasks = taid;\n- this->duplicate(root);\n- this->delete_tree(root);\n-\n- std::function<Sub_sequence*(Generic_node<Sub_sequence>*)> get_last = [&get_last](Generic_node<Sub_sequence>* node)\n- {\n- Sub_sequence* last = node->get_c();\n- for (auto c : node->get_children())\n- last = get_last(c);\n- return last;\n- };\n- for (size_t tid = 0; tid < n_threads; tid++)\n- {\n- this->first_tasks[tid] = this->sequences[tid]->get_c()->tasks.front();\n- this->last_tasks[tid] = get_last(this->sequences[tid])->tasks.back();\n- }\n+ this->init(first, &last);\n}\nChain\n@@ -77,7 +41,20 @@ Chain\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false))\n{\n- if (n_threads == 0)\n+ this->init(first);\n+}\n+\n+Chain\n+::~Chain()\n+{\n+ for (auto s : this->sequences)\n+ this->delete_tree(s);\n+}\n+\n+void Chain\n+::init(const module::Task &first, const module::Task *last)\n+{\n+ if (this->n_threads == 0)\n{\nstd::stringstream message;\nmessage << \"'n_threads' has to be strictly greater than 0.\";\n@@ -87,7 +64,17 @@ Chain\nauto root = new Generic_node<Sub_sequence_const>(nullptr, {}, nullptr, 0, 0, 0);\nsize_t ssid = 0, taid = 0;\nstd::vector<const module::Task*> loops;\n- this->init_recursive(root, ssid, taid, loops, first, first);\n+ auto &real_last = this->init_recursive(root, ssid, taid, loops, first, first, last);\n+ if (last != nullptr && &real_last != last)\n+ {\n+ std::stringstream message;\n+ message << \"'&real_last' has to be equal to '&last' (\"\n+ << \"'&real_last'\" << \" = \" << +&real_last << \", \"\n+ << \"'last'\" << \" = \" << +last << \", \"\n+ << \"'real_last.get_name()'\" << \" = \" << real_last.get_name() << \", \"\n+ << \"'last->get_name()'\" << \" = \" << last->get_name() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\nthis->n_tasks = taid;\nthis->duplicate(root);\nthis->delete_tree(root);\n@@ -106,34 +93,13 @@ Chain\n}\n}\n-Chain::\n-~Chain()\n-{\n- for (auto s : this->sequences)\n- this->delete_tree(s);\n-}\n-\nChain* Chain\n::clone() const\n{\nauto c = new Chain(*this);\n- c->duplicate(this->sequences[0]);\n+ c->init(*this->get_first_tasks()[0]);\nc->mtx_exception.reset(new std::mutex());\nc->force_exit_loop.reset(new std::atomic<bool>(false));\n-\n- std::function<Sub_sequence*(Generic_node<Sub_sequence>*)> get_last = [&get_last](Generic_node<Sub_sequence>* node)\n- {\n- Sub_sequence* last = node->get_c();\n- for (auto c : node->get_children())\n- last = get_last(c);\n- return last;\n- };\n- for (size_t tid = 0; tid < c->n_threads; tid++)\n- {\n- c->first_tasks[tid] = c->sequences[tid]->get_c()->tasks.front();\n- c->last_tasks[tid] = get_last(c->sequences[tid])->tasks.back();\n- }\n-\nreturn c;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simplify the source code of the 'Chain'.
|
8,490 |
03.01.2020 11:36:53
| -3,600 |
a790e31b8e386007dace28865888359bc4b3988b
|
Fix perfo regression in the 'Chain'.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -136,18 +136,21 @@ void Chain\nstd::function<void(Generic_node<Sub_sequence>*, std::vector<int>&)> exec_sequence =\n[&exec_sequence](Generic_node<Sub_sequence>* cur_ss, std::vector<int>& statuses)\n{\n- auto c = *cur_ss->get_c();\n- if (c.type == subseq_t::LOOP)\n+ auto type = cur_ss->get_c()->type;\n+ auto &tasks = cur_ss->get_c()->tasks;\n+ auto &tasks_id = cur_ss->get_c()->tasks_id;\n+\n+ if (type == subseq_t::LOOP)\n{\n- while (!(statuses[c.tasks_id[0]] = c.tasks[0]->exec()))\n+ while (!(statuses[tasks_id[0]] = tasks[0]->exec()))\nexec_sequence(cur_ss->get_children()[0], statuses);\n- static_cast<module::Loop&>(c.tasks[0]->get_module()).reset();\n+ static_cast<module::Loop&>(tasks[0]->get_module()).reset();\nexec_sequence(cur_ss->get_children()[1], statuses);\n}\nelse\n{\n- for (size_t ta = 0; ta < c.tasks.size(); ta++)\n- statuses[c.tasks_id[ta]] = c.tasks[ta]->exec();\n+ for (size_t ta = 0; ta < tasks.size(); ta++)\n+ statuses[tasks_id[ta]] = tasks[ta]->exec();\nfor (auto c : cur_ss->get_children())\nexec_sequence(c, statuses);\n}\n@@ -192,18 +195,19 @@ void Chain\nstd::function<void(Generic_node<Sub_sequence>*)> exec_sequence =\n[&exec_sequence](Generic_node<Sub_sequence>* cur_ss)\n{\n- auto c = *cur_ss->get_c();\n- if (c.type == subseq_t::LOOP)\n+ auto type = cur_ss->get_c()->type;\n+ auto &tasks = cur_ss->get_c()->tasks;\n+ if (type == subseq_t::LOOP)\n{\n- while (!c.tasks[0]->exec())\n+ while (!tasks[0]->exec())\nexec_sequence(cur_ss->get_children()[0]);\n- static_cast<module::Loop&>(c.tasks[0]->get_module()).reset();\n+ static_cast<module::Loop&>(tasks[0]->get_module()).reset();\nexec_sequence(cur_ss->get_children()[1]);\n}\nelse\n{\n- for (size_t ta = 0; ta < c.tasks.size(); ta++)\n- c.tasks[ta]->exec();\n+ for (size_t ta = 0; ta < tasks.size(); ta++)\n+ tasks[ta]->exec();\nfor (auto c : cur_ss->get_children())\nexec_sequence(c);\n}\n@@ -294,19 +298,20 @@ int Chain\nstd::function<void(Generic_node<Sub_sequence>*, int&)> exec_sequence =\n[&exec_sequence](Generic_node<Sub_sequence>* cur_ss, int& ret)\n{\n- auto c = *cur_ss->get_c();\n- if (c.type == subseq_t::LOOP)\n+ auto type = cur_ss->get_c()->type;\n+ auto &tasks = cur_ss->get_c()->tasks;\n+ if (type == subseq_t::LOOP)\n{\n- while (!c.tasks[0]->exec())\n+ while (!tasks[0]->exec())\nexec_sequence(cur_ss->get_children()[0], ret);\nret++;\n- static_cast<module::Loop&>(c.tasks[0]->get_module()).reset();\n+ static_cast<module::Loop&>(tasks[0]->get_module()).reset();\nexec_sequence(cur_ss->get_children()[1], ret);\n}\nelse\n{\n- for (size_t ta = 0; ta < c.tasks.size(); ta++)\n- ret += c.tasks[ta]->exec();\n+ for (size_t ta = 0; ta < tasks.size(); ta++)\n+ ret += tasks[ta]->exec();\nfor (auto c : cur_ss->get_children())\nexec_sequence(c, ret);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix perfo regression in the 'Chain'.
|
8,490 |
07.01.2020 11:35:40
| -3,600 |
130cc2e0846b44ff843bf85365e242fb9cce7f35
|
Add '1 to N' and 'N to 1' adaptors (not tested).
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Adaptor/Adaptor.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Adaptor.\n+ */\n+#ifndef CONNECTOR_HPP_\n+#define CONNECTOR_HPP_\n+\n+#include <typeindex>\n+#include <cstddef>\n+#include <cstdint>\n+#include <memory>\n+#include <vector>\n+#include <atomic>\n+\n+#include \"Module/Task.hpp\"\n+#include \"Module/Socket.hpp\"\n+#include \"Module/Module.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+ namespace adp\n+ {\n+ enum class tsk : size_t { put_1, pull_n, put_n, pull_1, SIZE };\n+\n+ namespace sck\n+ {\n+ enum class put_1 : size_t { in, SIZE };\n+ enum class pull_n : size_t { out, SIZE };\n+ enum class put_n : size_t { in, SIZE };\n+ enum class pull_1 : size_t { out, SIZE };\n+ }\n+ }\n+\n+class Adaptor : public Module\n+{\n+protected:\n+ const size_t n_elmts;\n+ const size_t n_bytes;\n+ const std::type_index datatype;\n+ const size_t buffer_size;\n+ size_t id;\n+ size_t cur_id;\n+\n+ std::shared_ptr<std::vector<std::vector<std::vector<int8_t>>>> buffer;\n+ std::shared_ptr<std::vector<std::atomic<size_t>>> first;\n+ std::shared_ptr<std::vector<std::atomic<size_t>>> last;\n+\n+public:\n+ virtual Adaptor* clone() const;\n+ inline size_t get_n_elmts() const;\n+ inline size_t get_n_bytes() const;\n+ inline std::type_index get_datatype() const;\n+\n+protected:\n+ inline Adaptor(const size_t n_elmts,\n+ const std::type_index datatype,\n+ const size_t buffer_size,\n+ const int n_frames = 1);\n+ virtual ~Adaptor();\n+ virtual void deep_copy(const Adaptor &m);\n+ inline bool is_full(const size_t id);\n+ inline bool is_empty(const size_t id);\n+\n+private:\n+ static size_t compute_bytes(const size_t n_elmts, const std::type_index type);\n+};\n+}\n+}\n+\n+#ifndef DOXYGEN_SHOULD_SKIP_THIS\n+#include \"Module/Adaptor/Adaptor.hxx\"\n+#endif\n+\n+#endif /* CONNECTOR_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Adaptor/Adaptor.hxx",
"diff": "+#include <cmath>\n+#include <string>\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Module/Adaptor/Adaptor.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+Adaptor\n+::Adaptor(const size_t n_elmts,\n+ const std::type_index datatype,\n+ const size_t buffer_size,\n+ const int n_frames)\n+: Module(n_frames),\n+ n_elmts(n_elmts),\n+ n_bytes(compute_bytes(n_elmts, datatype)),\n+ datatype(datatype),\n+ buffer_size(buffer_size),\n+ id(0),\n+ cur_id(0),\n+ buffer(new std::vector<std::vector<std::vector<int8_t>>>\n+ (1, std::vector<std::vector<int8_t>>(buffer_size, std::vector<int8_t>(n_frames * n_bytes)))),\n+ first(new std::vector<std::atomic<size_t>>(1000)),\n+ last(new std::vector<std::atomic<size_t>>(1000))\n+{\n+ const std::string name = \"Adaptor\";\n+ this->set_name(name);\n+ this->set_short_name(name);\n+\n+ if (buffer_size == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'buffer_size' has to be greater than 0 ('buffer_size' = \" << buffer_size << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (n_elmts == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'n_elmts' has to be greater than 0 ('n_elmts' = \" << n_elmts << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ for (auto &a : *this->first.get()) a = 0;\n+ for (auto &a : *this->last .get()) a = 0;\n+}\n+\n+size_t Adaptor\n+::get_n_elmts() const\n+{\n+ return this->n_elmts;\n+}\n+\n+size_t Adaptor\n+::get_n_bytes() const\n+{\n+ return this->n_bytes;\n+}\n+\n+std::type_index Adaptor\n+::get_datatype() const\n+{\n+ return this->datatype;\n+}\n+\n+bool Adaptor\n+::is_empty(const size_t id)\n+{\n+ return (*this->first)[id] == (*this->last)[id];\n+}\n+\n+bool Adaptor\n+::is_full(const size_t id)\n+{\n+ return (size_t)std::abs((int)(*this->last)[id] - (int)(*this->first)[id]) == this->buffer_size;\n+}\n+\n+}\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Adaptor_1_to_n.\n+ */\n+#ifndef CONNECTOR_1_TO_N_HPP_\n+#define CONNECTOR_1_TO_N_HPP_\n+\n+#include <typeindex>\n+#include <cstddef>\n+#include <cstdint>\n+#include <memory>\n+#include <vector>\n+#include <atomic>\n+\n+#include \"Module/Task.hpp\"\n+#include \"Module/Socket.hpp\"\n+#include \"Module/Adaptor/Adaptor.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+class Adaptor_1_to_n : public Adaptor\n+{\n+public:\n+ inline Task& operator[](const adp::tsk t);\n+ inline Socket& operator[](const adp::sck::put_1 s);\n+ inline Socket& operator[](const adp::sck::pull_n s);\n+\n+public:\n+ inline Adaptor_1_to_n(const size_t n_elmts,\n+ const std::type_index datatype,\n+ const size_t buffer_size,\n+ const int n_frames = 1);\n+ virtual ~Adaptor_1_to_n() = default;\n+ virtual Adaptor_1_to_n* clone() const;\n+\n+ template <class A = std::allocator<int8_t>>\n+ void put_1(const std::vector<int8_t,A>& in, const int frame_id = -1);\n+ template <class A = std::allocator<int8_t>>\n+ void pull_n(std::vector<int8_t,A>& out, const int frame_id = -1);\n+\n+ virtual void put_1 (const int8_t *in, const int frame_id = -1);\n+ virtual void pull_n( int8_t *out, const int frame_id = -1);\n+};\n+}\n+}\n+\n+#ifndef DOXYGEN_SHOULD_SKIP_THIS\n+#include \"Module/Adaptor/Adaptor_1_to_n.hxx\"\n+#endif\n+\n+#endif /* CONNECTOR_1_TO_N_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"diff": "+#include <string>\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Module/Adaptor/Adaptor_1_to_n.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+Task& Adaptor_1_to_n\n+::operator[](const adp::tsk t)\n+{\n+ return Module::operator[]((size_t)t);\n+}\n+\n+Socket& Adaptor_1_to_n\n+::operator[](const adp::sck::put_1 s)\n+{\n+ return Module::operator[]((size_t)adp::tsk::put_1)[(size_t)s];\n+}\n+\n+Socket& Adaptor_1_to_n\n+::operator[](const adp::sck::pull_n s)\n+{\n+ return Module::operator[]((size_t)adp::tsk::pull_n)[(size_t)s];\n+}\n+\n+Adaptor_1_to_n\n+::Adaptor_1_to_n(const size_t n_elmts,\n+ const std::type_index datatype,\n+ const size_t buffer_size,\n+ const int n_frames)\n+: Adaptor(n_elmts, datatype, buffer_size, n_frames)\n+{\n+ const std::string name = \"Adaptor_1_to_n\";\n+ this->set_name(name);\n+ this->set_short_name(name);\n+\n+ std::function<size_t(Task&, const size_t, const std::type_index&)> create_socket_in =\n+ [this](Task& p, const size_t n_elmts, const std::type_index& datatype)\n+ {\n+ std::string n = \"in\";\n+ if (datatype == typeid(int8_t )) return this->template create_socket_in<int8_t >(p, n, n_elmts);\n+ else if (datatype == typeid(int16_t)) return this->template create_socket_in<int16_t>(p, n, n_elmts);\n+ else if (datatype == typeid(int32_t)) return this->template create_socket_in<int32_t>(p, n, n_elmts);\n+ else if (datatype == typeid(int64_t)) return this->template create_socket_in<int64_t>(p, n, n_elmts);\n+ else if (datatype == typeid(float )) return this->template create_socket_in<float >(p, n, n_elmts);\n+ else if (datatype == typeid(double )) return this->template create_socket_in<double >(p, n, n_elmts);\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"This should never happen.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ };\n+\n+ std::function<size_t(Task&, const size_t, const std::type_index&)> create_socket_out =\n+ [this](Task& p, const size_t n_elmts, const std::type_index& datatype)\n+ {\n+ std::string n = \"out\";\n+ if (datatype == typeid(int8_t )) return this->template create_socket_out<int8_t >(p, n, n_elmts);\n+ else if (datatype == typeid(int16_t)) return this->template create_socket_out<int16_t>(p, n, n_elmts);\n+ else if (datatype == typeid(int32_t)) return this->template create_socket_out<int32_t>(p, n, n_elmts);\n+ else if (datatype == typeid(int64_t)) return this->template create_socket_out<int64_t>(p, n, n_elmts);\n+ else if (datatype == typeid(float )) return this->template create_socket_out<float >(p, n, n_elmts);\n+ else if (datatype == typeid(double )) return this->template create_socket_out<double >(p, n, n_elmts);\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"This should never happen.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ };\n+\n+ auto &p1 = this->create_task(\"put_1\", (int)adp::tsk::put_1);\n+ auto p1s_in = create_socket_in(p1, n_elmts, datatype);\n+ this->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n+ {\n+ static_cast<Adaptor_1_to_n&>(m).put_1(static_cast<int8_t*>(t[p1s_in].get_dataptr()));\n+ return 0;\n+ });\n+\n+ auto &p2 = this->create_task(\"pull_n\", (int)adp::tsk::pull_n);\n+ auto p2s_out = create_socket_out(p2, n_elmts, datatype);\n+ this->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n+ {\n+ static_cast<Adaptor_1_to_n&>(m).pull_n(static_cast<int8_t*>(t[p2s_out].get_dataptr()));\n+ return 0;\n+ });\n+}\n+\n+template <class A>\n+void Adaptor_1_to_n\n+::put_1(const std::vector<int8_t,A>& in, const int frame_id)\n+{\n+ if (this->n_bytes * (size_t)this->n_frames != in.size())\n+ {\n+ std::stringstream message;\n+ message << \"'in.size()' has to be equal to 'n_bytes' * 'n_frames' ('in.size()' = \" << in.size()\n+ << \", 'n_bytes' = \" << this->n_bytes << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ this->put_1(in.data(), frame_id);\n+}\n+\n+template <class A>\n+void Adaptor_1_to_n\n+::pull_n(std::vector<int8_t,A>& out, const int frame_id)\n+{\n+ if (this->n_bytes * (size_t)this->n_frames != out.size())\n+ {\n+ std::stringstream message;\n+ message << \"'out.size()' has to be equal to 'n_bytes' * 'n_frames' ('out.size()' = \" << out.size()\n+ << \", 'n_bytes' = \" << this->n_bytes << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ this->pull_n(out.data(), frame_id);\n+}\n+\n+}\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Adaptor_n_to_1.\n+ */\n+#ifndef CONNECTOR_N_TO_1_HPP_\n+#define CONNECTOR_N_TO_1_HPP_\n+\n+#include <typeindex>\n+#include <cstddef>\n+#include <cstdint>\n+#include <memory>\n+#include <vector>\n+#include <atomic>\n+\n+#include \"Module/Task.hpp\"\n+#include \"Module/Socket.hpp\"\n+#include \"Module/Adaptor/Adaptor.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+class Adaptor_n_to_1 : public Adaptor\n+{\n+public:\n+ inline Task& operator[](const adp::tsk t);\n+ inline Socket& operator[](const adp::sck::put_n s);\n+ inline Socket& operator[](const adp::sck::pull_1 s);\n+\n+public:\n+ inline Adaptor_n_to_1(const size_t n_elmts,\n+ const std::type_index datatype,\n+ const size_t buffer_size,\n+ const int n_frames = 1);\n+ virtual ~Adaptor_n_to_1() = default;\n+ virtual Adaptor_n_to_1* clone() const;\n+\n+ template <class A = std::allocator<int8_t>>\n+ void put_n(const std::vector<int8_t,A>& in, const int frame_id = -1);\n+ template <class A = std::allocator<int8_t>>\n+ void pull_1(std::vector<int8_t,A>& out, const int frame_id = -1);\n+\n+ virtual void put_n (const int8_t *in, const int frame_id = -1);\n+ virtual void pull_1( int8_t *out, const int frame_id = -1);\n+};\n+}\n+}\n+\n+#ifndef DOXYGEN_SHOULD_SKIP_THIS\n+#include \"Module/Adaptor/Adaptor_n_to_1.hxx\"\n+#endif\n+\n+#endif /* CONNECTOR_N_TO_1_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"diff": "+#include <string>\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Module/Adaptor/Adaptor_n_to_1.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+Task& Adaptor_n_to_1\n+::operator[](const adp::tsk t)\n+{\n+ return Module::operator[]((size_t)t);\n+}\n+\n+Socket& Adaptor_n_to_1\n+::operator[](const adp::sck::put_n s)\n+{\n+ return Module::operator[]((size_t)adp::tsk::put_n)[(size_t)s];\n+}\n+\n+Socket& Adaptor_n_to_1\n+::operator[](const adp::sck::pull_1 s)\n+{\n+ return Module::operator[]((size_t)adp::tsk::pull_1)[(size_t)s];\n+}\n+\n+Adaptor_n_to_1\n+::Adaptor_n_to_1(const size_t n_elmts,\n+ const std::type_index datatype,\n+ const size_t buffer_size,\n+ const int n_frames)\n+: Adaptor(n_elmts, datatype, buffer_size, n_frames)\n+{\n+ const std::string name = \"Adaptor_n_to_1\";\n+ this->set_name(name);\n+ this->set_short_name(name);\n+\n+ std::function<size_t(Task&, const size_t, const std::type_index&)> create_socket_in =\n+ [this](Task& p, const size_t n_elmts, const std::type_index& datatype)\n+ {\n+ std::string n = \"in\";\n+ if (datatype == typeid(int8_t )) return this->template create_socket_in<int8_t >(p, n, n_elmts);\n+ else if (datatype == typeid(int16_t)) return this->template create_socket_in<int16_t>(p, n, n_elmts);\n+ else if (datatype == typeid(int32_t)) return this->template create_socket_in<int32_t>(p, n, n_elmts);\n+ else if (datatype == typeid(int64_t)) return this->template create_socket_in<int64_t>(p, n, n_elmts);\n+ else if (datatype == typeid(float )) return this->template create_socket_in<float >(p, n, n_elmts);\n+ else if (datatype == typeid(double )) return this->template create_socket_in<double >(p, n, n_elmts);\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"This should never happen.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ };\n+\n+ std::function<size_t(Task&, const size_t, const std::type_index&)> create_socket_out =\n+ [this](Task& p, const size_t n_elmts, const std::type_index& datatype)\n+ {\n+ std::string n = \"out\";\n+ if (datatype == typeid(int8_t )) return this->template create_socket_out<int8_t >(p, n, n_elmts);\n+ else if (datatype == typeid(int16_t)) return this->template create_socket_out<int16_t>(p, n, n_elmts);\n+ else if (datatype == typeid(int32_t)) return this->template create_socket_out<int32_t>(p, n, n_elmts);\n+ else if (datatype == typeid(int64_t)) return this->template create_socket_out<int64_t>(p, n, n_elmts);\n+ else if (datatype == typeid(float )) return this->template create_socket_out<float >(p, n, n_elmts);\n+ else if (datatype == typeid(double )) return this->template create_socket_out<double >(p, n, n_elmts);\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"This should never happen.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ };\n+\n+ auto &p1 = this->create_task(\"put_n\", (int)adp::tsk::put_n);\n+ auto p1s_in = create_socket_in(p1, n_elmts, datatype);\n+ this->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n+ {\n+ static_cast<Adaptor_n_to_1&>(m).put_n(static_cast<int8_t*>(t[p1s_in].get_dataptr()));\n+ return 0;\n+ });\n+\n+ auto &p2 = this->create_task(\"pull_1\", (int)adp::tsk::pull_1);\n+ auto p2s_out = create_socket_out(p2, n_elmts, datatype);\n+ this->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n+ {\n+ static_cast<Adaptor_n_to_1&>(m).pull_1(static_cast<int8_t*>(t[p2s_out].get_dataptr()));\n+ return 0;\n+ });\n+}\n+\n+template <class A>\n+void Adaptor_n_to_1\n+::put_n(const std::vector<int8_t,A>& in, const int frame_id)\n+{\n+ if (this->n_bytes * (size_t)this->n_frames != in.size())\n+ {\n+ std::stringstream message;\n+ message << \"'in.size()' has to be equal to 'n_bytes' * 'n_frames' ('in.size()' = \" << in.size()\n+ << \", 'n_bytes' = \" << this->n_bytes << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ this->put_n(in.data(), frame_id);\n+}\n+\n+template <class A>\n+void Adaptor_n_to_1\n+::pull_1(std::vector<int8_t,A>& out, const int frame_id)\n+{\n+ if (this->n_bytes * (size_t)this->n_frames != out.size())\n+ {\n+ std::stringstream message;\n+ message << \"'out.size()' has to be equal to 'n_bytes' * 'n_frames' ('out.size()' = \" << out.size()\n+ << \", 'n_bytes' = \" << this->n_bytes << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ this->pull_1(out.data(), frame_id);\n+}\n+\n+}\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/aff3ct.hpp",
"new_path": "include/aff3ct.hpp",
"diff": "#ifndef FACTORY_NOISE_HPP\n#include <Factory/Tools/Noise/Noise.hpp>\n#endif\n+#ifndef CONNECTOR_1_TO_N_HPP_\n+#include <Module/Adaptor/Adaptor_1_to_n.hpp>\n+#endif\n+#ifndef CONNECTOR_HPP_\n+#include <Module/Adaptor/Adaptor.hpp>\n+#endif\n+#ifndef CONNECTOR_N_TO_1_HPP_\n+#include <Module/Adaptor/Adaptor_n_to_1.hpp>\n+#endif\n#ifndef CHANNEL_AWGN_LLR_HPP_\n#include <Module/Channel/AWGN/Channel_AWGN_LLR.hpp>\n#endif\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Adaptor/Adaptor.cpp",
"diff": "+#include \"Module/Adaptor/Adaptor.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+Adaptor\n+::~Adaptor()\n+{\n+ (*this->buffer)[this->id].clear();\n+ (*this->first)[this->id] = 0;\n+ (*this->last )[this->id] = 0;\n+}\n+\n+Adaptor* Adaptor\n+::clone() const\n+{\n+ auto m = new Adaptor(*this);\n+ m->deep_copy(*this);\n+ return m;\n+}\n+\n+void Adaptor\n+::deep_copy(const Adaptor &m)\n+{\n+ Module::deep_copy(m);\n+\n+ int id = -1;\n+ for (size_t i = 0; i < this->buffer->size(); i++)\n+ if ((*this->buffer)[i].size() == 0)\n+ id = (int)i;\n+\n+ if (id == -1)\n+ {\n+ this->id = this->buffer->size();\n+ this->buffer->push_back(\n+ std::vector<std::vector<int8_t>>(this->buffer_size, std::vector<int8_t>(this->n_frames * this->n_bytes)));\n+ }\n+ else\n+ {\n+ this->id = (size_t)id;\n+ (*this->buffer)[this->id].resize(buffer_size, std::vector<int8_t>(this->n_frames * this->n_bytes));\n+ }\n+\n+ if (this->id >= this->first->size())\n+ {\n+ std::stringstream message;\n+ message << \"'id' can't be higher than 'first->size()' ('id' = \" << this->id\n+ << \", 'first->size()' = \" << this->first->size() << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n+size_t Adaptor\n+::compute_bytes(const size_t n_elmts, const std::type_index type)\n+{\n+ if (type == typeid(int8_t )) return n_elmts * sizeof(int8_t );\n+ else if (type == typeid(int16_t)) return n_elmts * sizeof(int16_t);\n+ else if (type == typeid(int32_t)) return n_elmts * sizeof(int32_t);\n+ else if (type == typeid(int64_t)) return n_elmts * sizeof(int64_t);\n+ else if (type == typeid(float )) return n_elmts * sizeof(float );\n+ else if (type == typeid(double )) return n_elmts * sizeof(double );\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"This should never happen.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"diff": "+#include <algorithm>\n+\n+#include \"Module/Adaptor/Adaptor_1_to_n.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+Adaptor_1_to_n* Adaptor_1_to_n\n+::clone() const\n+{\n+ auto m = new Adaptor_1_to_n(*this);\n+ m->deep_copy(*this);\n+ return m;\n+}\n+\n+void Adaptor_1_to_n\n+::put_1(const int8_t *in, const int frame_id)\n+{\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\n+ // active waiting\n+ while (this->is_full(this->cur_id));\n+\n+ int8_t* out = (*this->buffer)[this->cur_id][(*this->last)[this->cur_id]].data();\n+\n+ std::copy(in + f_start * this->n_bytes,\n+ in + f_stop * this->n_bytes,\n+ out + f_start * this->n_bytes);\n+\n+ (*this->last)[this->cur_id] = ((*this->last)[this->cur_id] +1) % this->buffer_size;\n+\n+ do\n+ {\n+ this->cur_id = (this->cur_id +1) % this->buffer->size();\n+ }\n+ while((*this->buffer)[this->cur_id].size() == 0);\n+}\n+\n+void Adaptor_1_to_n\n+::pull_n(int8_t *out, const int frame_id)\n+{\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\n+ // active waiting\n+ while (this->is_empty(this->id));\n+\n+ const int8_t* in = (*this->buffer)[this->id][(*this->last)[this->id]].data();\n+\n+ std::copy(in + f_start * this->n_bytes,\n+ in + f_stop * this->n_bytes,\n+ out + f_start * this->n_bytes);\n+\n+ (*this->first)[this->id] = ((*this->first)[this->id] +1) % this->buffer_size;\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"diff": "+#include <algorithm>\n+\n+#include \"Module/Adaptor/Adaptor_n_to_1.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+Adaptor_n_to_1* Adaptor_n_to_1\n+::clone() const\n+{\n+ auto m = new Adaptor_n_to_1(*this);\n+ m->deep_copy(*this);\n+ return m;\n+}\n+\n+void Adaptor_n_to_1\n+::put_n(const int8_t *in, const int frame_id)\n+{\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\n+ // active waiting\n+ while (this->is_full(this->id));\n+\n+ int8_t* out = (*this->buffer)[this->id][(*this->last)[this->id]].data();\n+\n+ std::copy(in + f_start * this->n_bytes,\n+ in + f_stop * this->n_bytes,\n+ out + f_start * this->n_bytes);\n+\n+ (*this->last)[this->id] = ((*this->last)[this->id] +1) % this->buffer_size;\n+}\n+\n+void Adaptor_n_to_1\n+::pull_1(int8_t *out, const int frame_id)\n+{\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\n+ // active waiting\n+ while (this->is_empty(this->cur_id));\n+\n+ const int8_t* in = (*this->buffer)[this->cur_id][(*this->last)[this->cur_id]].data();\n+\n+ std::copy(in + f_start * this->n_bytes,\n+ in + f_stop * this->n_bytes,\n+ out + f_start * this->n_bytes);\n+\n+ (*this->first)[this->cur_id] = ((*this->first)[this->cur_id] +1) % this->buffer_size;\n+\n+ do\n+ {\n+ this->cur_id = (this->cur_id +1) % this->buffer->size();\n+ }\n+ while((*this->buffer)[this->cur_id].size() == 0);\n+}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add '1 to N' and 'N to 1' adaptors (not tested).
|
8,490 |
07.01.2020 15:33:55
| -3,600 |
6c24f269a338cb0f2ea5aee2ec15bda42d43e995
|
Add binary sink module.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Sink/Sink.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Sink.\n+ */\n+#ifndef SINK_HPP\n+#define SINK_HPP\n+\n+#include <cstdint>\n+#include <memory>\n+#include <vector>\n+\n+#include \"Module/Task.hpp\"\n+#include \"Module/Socket.hpp\"\n+#include \"Module/Module.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+ namespace snk\n+ {\n+ enum class tsk : size_t { send, SIZE };\n+\n+ namespace sck\n+ {\n+ enum class send : size_t { V, SIZE };\n+ }\n+ }\n+\n+/*!\n+ * \\class Sink\n+ *\n+ * \\brief Send data into outer world.\n+ *\n+ * \\tparam B: type of the data to send or receive.\n+ *\n+ */\n+template <typename B = int>\n+class Sink : public Module\n+{\n+public:\n+ inline Task& operator[](const snk::tsk t);\n+ inline Socket& operator[](const snk::sck::send s);\n+\n+protected:\n+ const int N; /*!< Size of one frame (= number of samples in one frame) */\n+\n+public:\n+ /*!\n+ * \\brief Constructor.\n+ *\n+ * \\param N: Radio_frame length.\n+ */\n+ Sink(const int N, const int n_frames = 1);\n+\n+ /*!\n+ * \\brief Destructor.\n+ */\n+ virtual ~Sink() = default;\n+\n+ /*!\n+ * \\brief Consume a frame.\n+ *\n+ * \\param V : a vector of data to consume.\n+ */\n+ template <class A = std::allocator<B>>\n+ void send(const std::vector<B,A>& V, const int frame_id = -1);\n+\n+ virtual void send(const B *V, const int frame_id = -1);\n+\n+protected:\n+ virtual void _send(const B *V, const int frame_id);\n+};\n+\n+}\n+}\n+\n+#include \"Module/Sink/Sink.hxx\"\n+\n+#endif /* SINK_HPP */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Sink/Sink.hxx",
"diff": "+#include <sstream>\n+#include <string>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Module/Sink/Sink.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+template <typename B>\n+Task& Sink<B>\n+::operator[](const snk::tsk t)\n+{\n+ return Module::operator[]((size_t)t);\n+}\n+\n+template <typename B>\n+Socket& Sink<B>\n+::operator[](const snk::sck::send s)\n+{\n+ return Module::operator[]((size_t)snk::tsk::send)[(size_t)s];\n+}\n+\n+template <typename B>\n+Sink<B>\n+::Sink(const int N, const int n_frames)\n+: Module(n_frames), N(N)\n+{\n+ const std::string name = \"Sink\";\n+ this->set_name(name);\n+ this->set_short_name(name);\n+\n+ if (N <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'N' has to be greater than 0 ('N' = \" << N << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto &p1 = this->create_task(\"send\");\n+ auto p1s_V = this->template create_socket_in <B>(p1, \"V\", N);\n+ this->create_codelet(p1, [p1s_V](Module& m, Task& t) -> int\n+ {\n+ static_cast<Sink<B>&>(m).send(static_cast<B*>(t[p1s_V].get_dataptr()));\n+ return 0;\n+ });\n+}\n+\n+template <typename B>\n+template <class A>\n+void Sink<B>\n+::send(const std::vector<B,A>& V, const int frame_id)\n+{\n+ if (this->N * this->n_frames != (int)V.size())\n+ {\n+ std::stringstream message;\n+ message << \"'V.size()' has to be equal to 'N' * 'n_frames' ('V.size()' = \" << V.size()\n+ << \", 'N' = \" << this->N << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ this->send(V.data(), frame_id);\n+}\n+\n+template <typename B>\n+void Sink<B>\n+::send(const B *V, const int frame_id)\n+{\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\n+ for (auto f = f_start; f < f_stop; f++)\n+ this->_send(V + f * this->N, f);\n+}\n+\n+template <typename B>\n+void Sink<B>\n+::_send(const B *V, const int frame_id)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+}\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Sink/User/Sink_user_binary.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Sink_user_binary.\n+ */\n+#ifndef SINK_USER_BINARY_HPP\n+#define SINK_USER_BINARY_HPP\n+\n+#include <fstream>\n+#include <cstddef>\n+#include <string>\n+#include <vector>\n+\n+#include \"Module/Sink/Sink.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+/*!\n+ * \\class Sink_user_binary\n+ *\n+ * \\brief Send data to a binary file.\n+ *\n+ * \\tparam B: type of the data to send or receive.\n+ *\n+ */\n+template <typename B = int>\n+class Sink_user_binary : public Sink<B>\n+{\n+private:\n+ std::ofstream sink_file;\n+ std::vector<char> chunk;\n+ std::vector<B> reconstructed_buffer;\n+ size_t n_left; // number of bits left by last call\n+\n+public:\n+ /*!\n+ * \\brief Constructor.\n+ *\n+ * \\param N: Radio_frame length.\n+ * \\param n_frames: number of frames.\n+ */\n+ Sink_user_binary(const int N, const std::string &filename, const int n_frames = 1);\n+\n+ /*!\n+ * \\brief Destructor.\n+ */\n+ ~Sink_user_binary() = default;\n+\n+protected:\n+ virtual void _send(const B *V, const int frame_id);\n+};\n+\n+}\n+}\n+\n+#endif /* SINK_USER_BINARY_HPP */\n"
},
{
"change_type": "MODIFY",
"old_path": "include/aff3ct.hpp",
"new_path": "include/aff3ct.hpp",
"diff": "#ifndef SC_MODULE_HPP_\n#include <Module/SC_Module.hpp>\n#endif\n+#ifndef SINK_HPP\n+#include <Module/Sink/Sink.hpp>\n+#endif\n+#ifndef SINK_USER_BINARY_HPP\n+#include <Module/Sink/User/Sink_user_binary.hpp>\n+#endif\n#ifndef SOCKET_HPP_\n#include <Module/Socket.hpp>\n#endif\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Sink/User/Sink_user_binary.cpp",
"diff": "+#include <sstream>\n+#include <cstdint>\n+#include <ios>\n+\n+#include \"Tools/Algo/Bit_packer.hpp\"\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Module/Sink/User/Sink_user_binary.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+template <typename B>\n+Sink_user_binary<B>\n+::Sink_user_binary(const int N, const std::string &filename, const int n_frames)\n+: Sink<B>(N, n_frames),\n+ sink_file(filename.c_str(), std::ios::out | std::ios::binary),\n+ chunk(N),\n+ reconstructed_buffer(CHAR_BIT),\n+ n_left(0)\n+{\n+ const std::string name = \"Sink_user_binary\";\n+ this->set_name(name);\n+\n+ if (this->N < CHAR_BIT)\n+ {\n+ std::stringstream message;\n+ message << \"'N' has to be greater or equal to 'CHAR_BIT' ('N' = \" << this->N\n+ << \", 'CHAR_BIT' = \" << CHAR_BIT << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (sink_file.fail())\n+ {\n+ std::stringstream message;\n+ message << \"'filename' file name is not valid: sink file failbit is set.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n+template <typename B>\n+void Sink_user_binary<B>\n+::_send(const B *V, const int frame_id)\n+{\n+ size_t n_completing = (CHAR_BIT - this->n_left) % CHAR_BIT; // number of bits that are needed to complete one byte\n+ char reconstructed_byte; // to store reconstructed byte (n_left & n_completing)\n+\n+ if (sink_file.fail())\n+ {\n+ std::stringstream message;\n+ message << \"'filename' file name is not valid: sink file failbit is set.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (this->n_left != 0)\n+ {\n+ for (size_t i = 0; i < n_completing; i++) // completing byte with n_completing first bits of V\n+ this->reconstructed_buffer[i] = V[this->n_left + i];\n+ tools::Bit_packer::pack(this->reconstructed_buffer.data(), &reconstructed_byte, CHAR_BIT);\n+ sink_file.write(&reconstructed_byte, 1);\n+ }\n+\n+ size_t main_chunk_size = (this->N - n_completing) / CHAR_BIT; // en octet\n+ this->n_left = (this->N - n_completing) % CHAR_BIT;\n+\n+ tools::Bit_packer::pack(V + n_completing, this->chunk.data(), main_chunk_size * CHAR_BIT);\n+ sink_file.write(this->chunk.data(), main_chunk_size);\n+ sink_file.flush();\n+ this->n_left = 0;\n+ for (size_t i = n_completing + main_chunk_size * CHAR_BIT; i < (size_t)this->N; i++)\n+ this->reconstructed_buffer[this->n_left++] = V[i];\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef AFF3CT_MULTI_PREC\n+template class aff3ct::module::Sink_user_binary<B_8>;\n+template class aff3ct::module::Sink_user_binary<B_16>;\n+template class aff3ct::module::Sink_user_binary<B_32>;\n+template class aff3ct::module::Sink_user_binary<B_64>;\n+#else\n+template class aff3ct::module::Sink_user_binary<B>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add binary sink module.
|
8,490 |
12.01.2020 19:02:44
| -3,600 |
bf0040357adfc99a1d23ad60b706d6415c03747b
|
Fix dead lock in adaptor + improve subchain.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"diff": "@@ -53,9 +53,6 @@ public:\nvirtual void put_1 (const int8_t *in, const int frame_id = -1);\nvirtual void pull_n( int8_t *out, const int frame_id = -1);\n-\n-protected:\n- virtual void deep_copy(const Adaptor_1_to_n &m);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"diff": "@@ -53,9 +53,6 @@ public:\nvirtual void put_n (const int8_t *in, const int frame_id = -1);\nvirtual void pull_1( int8_t *out, const int frame_id = -1);\n-\n-protected:\n- virtual void deep_copy(const Adaptor_n_to_1 &m);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Subchain/Subchain.hpp",
"new_path": "include/Module/Subchain/Subchain.hpp",
"diff": "@@ -25,15 +25,18 @@ namespace module\nclass Subchain : public Module\n{\n- std::shared_ptr<tools::Chain> chain;\n+ std::shared_ptr<tools::Chain> chain_cloned;\n+ tools::Chain *chain_extern;\npublic:\ninline Task& operator[](const sch::tsk t);\nexplicit Subchain(const tools::Chain &chain);\n-\n+ explicit Subchain( tools::Chain &chain);\nvirtual ~Subchain() = default;\n+ virtual void init();\n+\nvirtual Subchain* clone() const;\ntools::Chain& get_chain();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"new_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"diff": "#include <algorithm>\n-#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Adaptor/Adaptor_1_to_n.hpp\"\nusing namespace aff3ct;\n@@ -14,26 +13,6 @@ Adaptor_1_to_n* Adaptor_1_to_n\nreturn m;\n}\n-void Adaptor_1_to_n\n-::deep_copy(const Adaptor_1_to_n &m)\n-{\n- Adaptor::deep_copy(m);\n-\n- // if (!this->active_waiting)\n- // {\n- // int id = -1;\n- // for (size_t i = 0; i < this->buffer->size(); i++)\n- // if ((*this->buffer)[i].size() == 0)\n- // id = (int)i;\n-\n- // if (id == -1)\n- // {\n- // (*this->cnd_pull.get()).resize((*this->cnd_pull.get()).size() +1);\n- // (*this->mtx_pull.get()).resize((*this->mtx_pull.get()).size() +1);\n- // }\n- // }\n-}\n-\nvoid Adaptor_1_to_n\n::put_1(const int8_t *in, const int frame_id)\n{\n@@ -49,14 +28,10 @@ void Adaptor_1_to_n\nif (this->is_full(this->cur_id))\n{\nstd::unique_lock<std::mutex> lock(*this->mtx_put.get());\n- // std::cout << \"put_1 - Sleep (cur_id = \" << this->cur_id << \")\" << std::endl;\n(*this->cnd_put.get()).wait(lock, [this]() { return !this->is_full(this->cur_id); });\n- // std::cout << \"put_1 - Wake up (cur_id = \" << this->cur_id << \")\" << std::endl;\n}\n}\n- // std::cout << \"put_1 - Out \" << ((*this->last)[this->cur_id] % this->buffer_size) << \" (cur_id = \"\n- // << this->cur_id << \")\" << std::endl;\nint8_t* out = (*this->buffer)[this->cur_id][(*this->last)[this->cur_id] % this->buffer_size].data();\nstd::copy(in + f_start * this->n_bytes,\n@@ -67,10 +42,9 @@ void Adaptor_1_to_n\nif (!this->active_waiting) // passive waiting\n{\n- if (this->is_full(this->cur_id))\n+ if (!this->is_empty(this->cur_id))\n{\nstd::lock_guard<std::mutex> lock((*this->mtx_pull.get())[this->cur_id]);\n- // std::cout << \"put_1 - Notify -> \" << this->cur_id << std::endl;\n(*this->cnd_pull.get())[this->cur_id].notify_one();\n}\n}\n@@ -97,13 +71,10 @@ void Adaptor_1_to_n\nif (this->is_empty(this->id))\n{\nstd::unique_lock<std::mutex> lock((*this->mtx_pull.get())[this->id]);\n- // std::cout << \"pull_n - Sleep (id = \" << this->id << \")\" << std::endl;\n(*this->cnd_pull.get())[this->id].wait(lock, [this](){ return !this->is_empty(this->id); });\n- // std::cout << \"pull_n - Wake up (id = \" << this->id << \")\" << std::endl;\n}\n}\n- // std::cout << \"pull_n - In \" << ((*this->first)[this->id] % this->buffer_size) << \" (id = \" << this->id << \")\" << std::endl;\nconst int8_t* in = (*this->buffer)[this->id][(*this->first)[this->id] % this->buffer_size].data();\nstd::copy(in + f_start * this->n_bytes,\n@@ -114,10 +85,9 @@ void Adaptor_1_to_n\nif (!this->active_waiting) // passive waiting\n{\n- if (this->is_empty(this->id))\n+ if (!this->is_full(this->id))\n{\nstd::lock_guard<std::mutex> lock(*this->mtx_put.get());\n- // std::cout << \"pull_n - Notify (id = \" << this->id << \")\" << std::endl;\n(*this->cnd_put.get()).notify_one();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"new_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"diff": "#include <algorithm>\n-#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Adaptor/Adaptor_n_to_1.hpp\"\nusing namespace aff3ct;\n@@ -14,26 +13,6 @@ Adaptor_n_to_1* Adaptor_n_to_1\nreturn m;\n}\n-void Adaptor_n_to_1\n-::deep_copy(const Adaptor_n_to_1 &m)\n-{\n- Adaptor::deep_copy(m);\n-\n- // if (!this->active_waiting)\n- // {\n- // int id = -1;\n- // for (size_t i = 0; i < this->buffer->size(); i++)\n- // if ((*this->buffer)[i].size() == 0)\n- // id = (int)i;\n-\n- // if (id == -1)\n- // {\n- // (*this->cnd_put.get()).resize((*this->cnd_put.get()).size() +1);\n- // (*this->mtx_put.get()).resize((*this->mtx_put.get()).size() +1);\n- // }\n- // }\n-}\n-\nvoid Adaptor_n_to_1\n::put_n(const int8_t *in, const int frame_id)\n{\n@@ -49,13 +28,10 @@ void Adaptor_n_to_1\nif (this->is_full(this->id))\n{\nstd::unique_lock<std::mutex> lock((*this->mtx_put.get())[this->id]);\n- // std::cout << \"put_n - Sleep (id = \" << this->id << \")\" << std::endl;\n(*this->cnd_put.get())[this->id].wait(lock, [this](){ return !this->is_full(this->id); });\n- // std::cout << \"put_n - Wake up (id = \" << this->id << \")\" << std::endl;\n}\n}\n- // std::cout << \"put_n - Out \" << ((*this->last)[this->id] % this->buffer_size) << \" (id = \" << this->id << \")\" << std::endl;\nint8_t* out = (*this->buffer)[this->id][(*this->last)[this->id] % this->buffer_size].data();\nstd::copy(in + f_start * this->n_bytes,\n@@ -66,10 +42,9 @@ void Adaptor_n_to_1\nif (!this->active_waiting) // passive waiting\n{\n- if (this->is_full(this->id))\n+ if (!this->is_empty(this->id))\n{\nstd::lock_guard<std::mutex> lock(*this->mtx_pull.get());\n- // std::cout << \"put_n - Notify (id = \" << this->id << \")\" << std::endl;\n(*this->cnd_pull.get()).notify_one();\n}\n}\n@@ -90,14 +65,10 @@ void Adaptor_n_to_1\nif (this->is_empty(this->cur_id))\n{\nstd::unique_lock<std::mutex> lock(*this->mtx_pull.get());\n- // std::cout << \"pull_1 - Sleep (cur_id = \" << this->cur_id << \")\" << std::endl;\n(*this->cnd_pull.get()).wait(lock, [this](){ return !this->is_empty(this->cur_id); });\n- // std::cout << \"pull_1 - Wake up (cur_id = \" << this->cur_id << \")\" << std::endl;\n}\n}\n- // std::cout << \"pull_1 - In \" << ((*this->first)[this->cur_id] % this->buffer_size) << \" (cur_id = \"\n- // << this->cur_id << \")\" << std::endl;\nconst int8_t* in = (*this->buffer)[this->cur_id][(*this->first)[this->cur_id] % this->buffer_size].data();\nstd::copy(in + f_start * this->n_bytes,\n@@ -108,10 +79,9 @@ void Adaptor_n_to_1\nif (!this->active_waiting) // passive waiting\n{\n- if (this->is_empty(this->cur_id))\n+ if (!this->is_full(this->cur_id))\n{\nstd::lock_guard<std::mutex> lock((*this->mtx_put.get())[this->cur_id]);\n- // std::cout << \"pull_1 - Notify -> \" << this->cur_id << std::endl;\n(*this->cnd_put.get())[this->cur_id].notify_one();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Subchain/Subchain.cpp",
"new_path": "src/Module/Subchain/Subchain.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::module;\n+Subchain\n+::Subchain(tools::Chain &chain)\n+: Module(chain.get_first_tasks()[0]->get_module().get_n_frames()),\n+ chain_extern(&chain)\n+{\n+ this->init();\n+}\n+\nSubchain\n::Subchain(const tools::Chain &chain)\n: Module(chain.get_first_tasks()[0]->get_module().get_n_frames()),\n- chain(chain.clone())\n+ chain_cloned(chain.clone()), chain_extern(nullptr)\n+{\n+ this->init();\n+}\n+\n+void Subchain\n+::init()\n{\nconst std::string name = \"Subchain\";\nthis->set_name(name);\nthis->set_short_name(name);\n+ auto &chain = this->get_chain();\n+\nif (chain.get_n_threads() != 1)\n{\nstd::stringstream message;\n@@ -28,7 +44,7 @@ Subchain\nauto &p = this->create_task(\"exec\");\np.set_autoalloc(true);\n- auto &first = *this->chain->get_first_tasks()[0];\n+ auto &first = *chain.get_first_tasks()[0];\nfor (auto &s : first.sockets)\n{\nif (first.get_socket_type(*s) == socket_t::SIN)\n@@ -62,7 +78,7 @@ Subchain\nthis->template create_socket_in_out<double >(p, s->get_name(), s->get_n_elmts() / this->get_n_frames());\n}\n}\n- auto &last = *this->chain->get_last_tasks()[0];\n+ auto &last = *chain.get_last_tasks()[0];\nfor (auto &s : last.sockets)\n{\nif (last.get_socket_type(*s) == socket_t::SOUT)\n@@ -122,7 +138,7 @@ Subchain\n{\nauto &c = static_cast<Subchain&>(m);\n- auto &first = *c.chain->get_first_tasks()[0];\n+ auto &first = *c.get_chain().get_first_tasks()[0];\nsize_t sid = 0;\nfor (auto &s : first.sockets)\n{\n@@ -143,14 +159,17 @@ Subchain\n}\n}\n- return c.chain->exec();\n+ return c.get_chain().exec();\n});\n}\ntools::Chain& Subchain\n::get_chain()\n{\n- return *this->chain;\n+ if (this->chain_extern)\n+ return *this->chain_extern;\n+ else\n+ return *this->chain_cloned;\n}\nSubchain* Subchain\n@@ -165,9 +184,15 @@ void Subchain\n::deep_copy(const Subchain& m)\n{\nModule::deep_copy(m);\n- if (m.chain != nullptr) this->chain.reset(m.chain->clone());\n+ if (m.chain_cloned != nullptr)\n+ this->chain_cloned.reset(m.chain_cloned->clone());\n+ else\n+ {\n+ this->chain_cloned.reset(m.chain_extern->clone());\n+ this->chain_extern = nullptr;\n+ }\n- auto &last = *this->chain->get_last_tasks()[0];\n+ auto &last = *this->get_chain().get_last_tasks()[0];\nauto &p = (*this)[sch::tsk::exec];\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix dead lock in adaptor + improve subchain.
|
8,490 |
12.01.2020 22:34:09
| -3,600 |
d8aa28451e0ebaabcff2ed2a49543f5879924321
|
Implement a new 'Interface_waiting' to manage waiting threads.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hpp",
"new_path": "include/Module/Adaptor/Adaptor.hpp",
"diff": "#include \"Module/Task.hpp\"\n#include \"Module/Socket.hpp\"\n#include \"Module/Module.hpp\"\n+#include \"Tools/Interface/Interface_waiting.hpp\"\nnamespace aff3ct\n{\n@@ -33,7 +34,7 @@ namespace module\n}\n}\n-class Adaptor : public Module\n+class Adaptor : public Module, public tools::Interface_waiting\n{\nprotected:\nconst size_t n_elmts;\n@@ -47,11 +48,14 @@ protected:\nstd::shared_ptr<std::vector<std::atomic<size_t>>> first;\nstd::shared_ptr<std::vector<std::atomic<size_t>>> last;\n+ std::shared_ptr<std::atomic<bool>> waiting_canceled;\n+\npublic:\n- virtual Adaptor* clone() const;\ninline size_t get_n_elmts() const;\ninline size_t get_n_bytes() const;\ninline std::type_index get_datatype() const;\n+ void send_cancel_signal();\n+ void reset();\nprotected:\ninline Adaptor(const size_t n_elmts,\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hxx",
"new_path": "include/Module/Adaptor/Adaptor.hxx",
"diff": "@@ -25,7 +25,8 @@ Adaptor\nbuffer(new std::vector<std::vector<std::vector<int8_t>>>\n(1, std::vector<std::vector<int8_t>>(buffer_size, std::vector<int8_t>(n_frames * n_bytes)))),\nfirst(new std::vector<std::atomic<size_t>>(1000)),\n- last(new std::vector<std::atomic<size_t>>(1000))\n+ last(new std::vector<std::atomic<size_t>>(1000)),\n+ waiting_canceled(new std::atomic<bool>(false))\n{\nconst std::string name = \"Adaptor\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"diff": "@@ -53,6 +53,9 @@ public:\nvirtual void put_1 (const int8_t *in, const int frame_id = -1);\nvirtual void pull_n( int8_t *out, const int frame_id = -1);\n+\n+ void wake_up();\n+ void cancel_waiting();\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"diff": "@@ -53,6 +53,9 @@ public:\nvirtual void put_n (const int8_t *in, const int frame_id = -1);\nvirtual void pull_1( int8_t *out, const int frame_id = -1);\n+\n+ void wake_up();\n+ void cancel_waiting();\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Exception/exception.hpp",
"new_path": "include/Tools/Exception/exception.hpp",
"diff": "@@ -57,5 +57,6 @@ public:\n#include \"runtime_error/runtime_error.hpp\"\n#include \"underflow_error/underflow_error.hpp\"\n#include \"unimplemented_error/unimplemented_error.hpp\"\n+#include \"waiting_canceled/waiting_canceled.hpp\"\n#endif /* EXCEPTION_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Tools/Exception/waiting_canceled/waiting_canceled.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class tools::waiting_canceled.\n+ */\n+#ifndef WAITING_CANCELED_HPP_\n+#define WAITING_CANCELED_HPP_\n+\n+#include <string>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+class waiting_canceled : public exception\n+{\n+ static const std::string default_message;\n+\n+public:\n+ waiting_canceled() throw();\n+\n+ explicit waiting_canceled(const std::string &message) throw();\n+\n+ waiting_canceled(const std::string &filename,\n+ const int line_num,\n+ const std::string &funcname = exception::empty_string,\n+ const std::string &message = exception::empty_string) throw();\n+\n+ virtual ~waiting_canceled() throw() = default;\n+};\n+}\n+}\n+\n+#endif /* WAITING_CANCELED_HPP_ */\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Interface/Interface_clone.hpp",
"new_path": "include/Tools/Interface/Interface_clone.hpp",
"diff": "@@ -18,4 +18,4 @@ public:\n}\n}\n-#endif // INTERFACE_RESET_HPP__\n\\ No newline at end of file\n+#endif // INTERFACE_CLONE_HPP__\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Tools/Interface/Interface_waiting.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class tools::Interface_waiting.\n+ */\n+#ifndef INTERFACE_WAITING_HPP__\n+#define INTERFACE_WAITING_HPP__\n+\n+#include \"Tools/Interface/Interface_reset.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+class Interface_waiting : public Interface_reset\n+{\n+public:\n+ virtual void reset() = 0;\n+ virtual void send_cancel_signal() = 0;\n+ virtual void wake_up() = 0;\n+ virtual void cancel_waiting() = 0;\n+};\n+\n+}\n+}\n+\n+#endif // INTERFACE_WAITING_HPP__\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "include/aff3ct.hpp",
"new_path": "include/aff3ct.hpp",
"diff": "#ifndef UNIMPLEMENTED_ERROR_HPP_\n#include <Tools/Exception/unimplemented_error/unimplemented_error.hpp>\n#endif\n+#ifndef WAITING_CANCELED_HPP_\n+#include <Tools/Exception/waiting_canceled/waiting_canceled.hpp>\n+#endif\n#ifndef COMMAND_PARSER_HPP\n#include <Tools/Factory/Command_parser.hpp>\n#endif\n#ifndef INTERFACE_SET_SEED_HPP__\n#include <Tools/Interface/Interface_set_seed.hpp>\n#endif\n+#ifndef INTERFACE_WAITING_HPP__\n+#include <Tools/Interface/Interface_waiting.hpp>\n+#endif\n#ifndef INTERLEAVER_CORE_ARP_DVB1_HPP\n#include <Tools/Interleaver/ARP/Interleaver_core_ARP_DVB_RCS1.hpp>\n#endif\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor.cpp",
"new_path": "src/Module/Adaptor/Adaptor.cpp",
"diff": "@@ -11,14 +11,6 @@ Adaptor\n(*this->last )[this->id] = 0;\n}\n-Adaptor* Adaptor\n-::clone() const\n-{\n- auto m = new Adaptor(*this);\n- m->deep_copy(*this);\n- return m;\n-}\n-\nvoid Adaptor\n::deep_copy(const Adaptor &m)\n{\n@@ -48,6 +40,8 @@ void Adaptor\n<< \", 'first->size()' = \" << this->first->size() << \").\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+\n+ this->waiting_canceled.reset(new std::atomic<bool>(m.waiting_canceled->load()));\n}\nsize_t Adaptor\n@@ -66,3 +60,13 @@ size_t Adaptor\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n}\n+\n+void Adaptor::send_cancel_signal()\n+{\n+ *this->waiting_canceled = true;\n+}\n+\n+void Adaptor::reset()\n+{\n+ *this->waiting_canceled = false;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"new_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"diff": "#include <algorithm>\n+#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Adaptor/Adaptor_1_to_n.hpp\"\nusing namespace aff3ct;\n@@ -21,17 +22,23 @@ void Adaptor_1_to_n\nif (this->active_waiting)\n{\n- while (this->is_full(this->cur_id));\n+ while (this->is_full(this->cur_id) && !*this->waiting_canceled);\n}\nelse // passive waiting\n{\n- if (this->is_full(this->cur_id))\n+ if (this->is_full(this->cur_id) && !*this->waiting_canceled)\n{\nstd::unique_lock<std::mutex> lock(*this->mtx_put.get());\n- (*this->cnd_put.get()).wait(lock, [this]() { return !this->is_full(this->cur_id); });\n+ (*this->cnd_put.get()).wait(lock, [this]()\n+ {\n+ return !(this->is_full(this->cur_id) && !*this->waiting_canceled);\n+ });\n}\n}\n+ if (*this->waiting_canceled)\n+ throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+\nint8_t* out = (*this->buffer)[this->cur_id][(*this->last)[this->cur_id] % this->buffer_size].data();\nstd::copy(in + f_start * this->n_bytes,\n@@ -64,17 +71,23 @@ void Adaptor_1_to_n\nif (this->active_waiting)\n{\n- while (this->is_empty(this->id));\n+ while (this->is_empty(this->id) && !*this->waiting_canceled);\n}\nelse // passive waiting\n{\n- if (this->is_empty(this->id))\n+ if (this->is_empty(this->id) && !*this->waiting_canceled)\n{\nstd::unique_lock<std::mutex> lock((*this->mtx_pull.get())[this->id]);\n- (*this->cnd_pull.get())[this->id].wait(lock, [this](){ return !this->is_empty(this->id); });\n+ (*this->cnd_pull.get())[this->id].wait(lock, [this]()\n+ {\n+ return !(this->is_empty(this->id) && !*this->waiting_canceled);\n+ });\n}\n}\n+ if (*this->waiting_canceled)\n+ throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+\nconst int8_t* in = (*this->buffer)[this->id][(*this->first)[this->id] % this->buffer_size].data();\nstd::copy(in + f_start * this->n_bytes,\n@@ -92,3 +105,27 @@ void Adaptor_1_to_n\n}\n}\n}\n+\n+void Adaptor_1_to_n\n+::wake_up()\n+{\n+ if (!this->active_waiting) // passive waiting\n+ {\n+ for (size_t i = 0; i < this->buffer->size(); i++)\n+ if ((*this->buffer)[i].size() != 0)\n+ {\n+ std::unique_lock<std::mutex> lock((*this->mtx_pull.get())[i]);\n+ (*this->cnd_pull.get())[i].notify_all();\n+ }\n+\n+ std::lock_guard<std::mutex> lock(*this->mtx_put.get());\n+ (*this->cnd_put.get()).notify_all();\n+ }\n+}\n+\n+void Adaptor_1_to_n\n+::cancel_waiting()\n+{\n+ this->send_cancel_signal();\n+ this->wake_up();\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"new_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"diff": "#include <algorithm>\n+#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Adaptor/Adaptor_n_to_1.hpp\"\nusing namespace aff3ct;\n@@ -21,17 +22,23 @@ void Adaptor_n_to_1\nif (this->active_waiting)\n{\n- while (this->is_full(this->id));\n+ while (this->is_full(this->id) && !*this->waiting_canceled);\n}\nelse // passive waiting\n{\n- if (this->is_full(this->id))\n+ if (this->is_full(this->id) && !*this->waiting_canceled)\n{\nstd::unique_lock<std::mutex> lock((*this->mtx_put.get())[this->id]);\n- (*this->cnd_put.get())[this->id].wait(lock, [this](){ return !this->is_full(this->id); });\n+ (*this->cnd_put.get())[this->id].wait(lock, [this]()\n+ {\n+ return !(this->is_full(this->id) && !*this->waiting_canceled);\n+ });\n}\n}\n+ if (*this->waiting_canceled)\n+ throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+\nint8_t* out = (*this->buffer)[this->id][(*this->last)[this->id] % this->buffer_size].data();\nstd::copy(in + f_start * this->n_bytes,\n@@ -58,17 +65,23 @@ void Adaptor_n_to_1\nif (this->active_waiting)\n{\n- while (this->is_empty(this->cur_id));\n+ while (this->is_empty(this->cur_id) && !*this->waiting_canceled);\n}\nelse // passive waiting\n{\n- if (this->is_empty(this->cur_id))\n+ if (this->is_empty(this->cur_id) && !*this->waiting_canceled)\n{\nstd::unique_lock<std::mutex> lock(*this->mtx_pull.get());\n- (*this->cnd_pull.get()).wait(lock, [this](){ return !this->is_empty(this->cur_id); });\n+ (*this->cnd_pull.get()).wait(lock, [this]()\n+ {\n+ return !(this->is_empty(this->cur_id) && !*this->waiting_canceled);\n+ });\n}\n}\n+ if (*this->waiting_canceled)\n+ throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+\nconst int8_t* in = (*this->buffer)[this->cur_id][(*this->first)[this->cur_id] % this->buffer_size].data();\nstd::copy(in + f_start * this->n_bytes,\n@@ -92,3 +105,27 @@ void Adaptor_n_to_1\n}\nwhile((*this->buffer)[this->cur_id].size() == 0);\n}\n+\n+void Adaptor_n_to_1\n+::wake_up()\n+{\n+ if (!this->active_waiting) // passive waiting\n+ {\n+ for (size_t i = 0; i < this->buffer->size(); i++)\n+ if ((*this->buffer)[i].size() != 0)\n+ {\n+ std::unique_lock<std::mutex> lock((*this->mtx_put.get())[i]);\n+ (*this->cnd_put.get())[i].notify_all();\n+ }\n+\n+ std::lock_guard<std::mutex> lock(*this->mtx_pull.get());\n+ (*this->cnd_pull.get()).notify_all();\n+ }\n+}\n+\n+void Adaptor_n_to_1\n+::cancel_waiting()\n+{\n+ this->send_cancel_signal();\n+ this->wake_up();\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -119,8 +119,6 @@ void Chain\nthis->n_tasks = taid;\nthis->_init<SS>(root);\n- // this->duplicate(root);\n- // this->delete_tree(root);\nstd::function<Sub_sequence*(Generic_node<Sub_sequence>*)> get_last = [&get_last](Generic_node<Sub_sequence>* node)\n{\n@@ -211,6 +209,10 @@ void Chain\n}\nwhile (!*force_exit_loop && !stop_condition(statuses));\n}\n+ catch (tools::waiting_canceled const&)\n+ {\n+ // do nothing, this is normal\n+ }\ncatch (std::exception const& e)\n{\n*force_exit_loop = true;\n@@ -267,6 +269,10 @@ void Chain\n}\nwhile (!*force_exit_loop && !stop_condition());\n}\n+ catch (tools::waiting_canceled const&)\n+ {\n+ // do nothing, this is normal\n+ }\ncatch (std::exception const& e)\n{\n*force_exit_loop = true;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Exception/waiting_canceled/waiting_canceled.cpp",
"diff": "+#include \"Tools/Exception/waiting_canceled/waiting_canceled.hpp\"\n+\n+using namespace aff3ct::tools;\n+\n+const std::string waiting_canceled::default_message = \"Waiting thread has been canceled.\";\n+\n+waiting_canceled\n+::waiting_canceled() throw()\n+: exception()\n+{\n+}\n+\n+waiting_canceled\n+::waiting_canceled(const std::string &message) throw()\n+: exception(message.empty() ? default_message : message)\n+{\n+}\n+\n+waiting_canceled\n+::waiting_canceled(const std::string &filename,\n+ const int line_num,\n+ const std::string &funcname,\n+ const std::string &message) throw()\n+: exception(filename, line_num, funcname, message.empty() ? default_message : message)\n+{\n+}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Implement a new 'Interface_waiting' to manage waiting threads.
|
8,490 |
13.01.2020 09:46:52
| -3,600 |
acc10e700383ca6259fcf43a7cb7df7cb47748a6
|
Doc: add '--src-no-reset' arg and sink args.
|
[
{
"change_type": "MODIFY",
"old_path": "doc/source/conf.py",
"new_path": "doc/source/conf.py",
"diff": "@@ -287,6 +287,7 @@ rst_epilog = \"\"\"\n.. |DVB-RCS2| replace:: :abbr:`DVB-RCS2 (Digital Video Broadcasting - Return Channel via Satellite 2)`\n.. |DVB-S1| replace:: :abbr:`DVB-S1 (Digital Video Broadcasting - Satellite 1)`\n.. |DVB-S2| replace:: :abbr:`DVB-S2 (Digital Video Broadcasting - Satellite 2)`\n+.. |EOF| replace:: :abbr:`EOF (End Of File)`\n.. |EP| replace:: :abbr:`EP (Event Probability)`\n.. |EXIT| replace:: :abbr:`EXIT (EXtrinsic Information Transfer chart)`\n.. |FER| replace:: :abbr:`FER (Frame Error Rate)`\n"
},
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/source/source.rst",
"new_path": "doc/source/user/simulation/parameters/source/source.rst",
"diff": "@@ -156,6 +156,13 @@ With the ``USER`` source type, an |ASCII| file is expected:\n# a sequence of 'F * K' bits (separated by spaces)\nB_0 B_1 B_2 B_3 B_4 B_5 [...] B_{(F*K)-1}\n+.. _src-src-no-reset:\n+\n+``--src-no-reset``\n+\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n+\n+|factory::Source::p+no-reset|\n+\n.. _src-src-start-idx:\n``--src-start-idx``\n"
},
{
"change_type": "MODIFY",
"old_path": "doc/strings.rst",
"new_path": "doc/strings.rst",
"diff": ".. |factory::Quantizer::p+range| replace::\nSelect the min/max bounds for the ``CUSTOM`` quantizer.\n+.. ---------------------------------------------------- factory Sink parameters\n+\n+.. |factory::Sink::p+info-bits,K| replace::\n+ Select the number of information bits :math:`K`.\n+\n+.. |factory::Sink::p+fra,F| replace::\n+ Set the number of frames to process for each task execution.\n+\n+.. |factory::Sink::p+type| replace::\n+ Select the sink type.\n+\n+.. |factory::Sink::p+implem| replace::\n+ Select the implementation of the sink.\n+\n+.. |factory::Sink::p+path| replace::\n+ Set the path to a file to write the :math:`K` bits, to use with the\n+ ``USER_BIN`` source type.\n+\n.. -------------------------------------------------- factory Source parameters\n.. |factory::Source::p+info-bits,K| replace::\n.. |factory::Source::p+seed,S| replace::\nSet the seed used to initialize the |PRNGs|.\n+.. |factory::Source::p+no-reset| replace::\n+ Do not reset the source (start to the beginning) if the file reach |EOF| and\n+ pad with zeros after |EOF| (work only for ``USER_BIN`` source type).\n+\n.. ------------------------------------ factory Frozenbits_generator parameters\n.. |factory::Frozenbits_generator::p+info-bits,K| replace::\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Doc: add '--src-no-reset' arg and sink args.
|
8,490 |
15.01.2020 16:20:56
| -3,600 |
66d330d633064ba616ae1b54282ba0867d677f8f
|
Add a new exception: 'processing_aborted'.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Exception/exception.hpp",
"new_path": "include/Tools/Exception/exception.hpp",
"diff": "@@ -58,5 +58,6 @@ public:\n#include \"underflow_error/underflow_error.hpp\"\n#include \"unimplemented_error/unimplemented_error.hpp\"\n#include \"waiting_canceled/waiting_canceled.hpp\"\n+#include \"processing_aborted/processing_aborted.hpp\"\n#endif /* EXCEPTION_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Tools/Exception/processing_aborted/processing_aborted.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class tools::processing_aborted.\n+ */\n+#ifndef PROCESSING_ABORTED_HPP_\n+#define PROCESSING_ABORTED_HPP_\n+\n+#include <string>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+class processing_aborted : public exception\n+{\n+ static const std::string default_message;\n+\n+public:\n+ processing_aborted() throw();\n+\n+ explicit processing_aborted(const std::string &message) throw();\n+\n+ processing_aborted(const std::string &filename,\n+ const int line_num,\n+ const std::string &funcname = exception::empty_string,\n+ const std::string &message = exception::empty_string) throw();\n+\n+ virtual ~processing_aborted() throw() = default;\n+};\n+}\n+}\n+\n+#endif /* PROCESSING_ABORTED_HPP_ */\n"
},
{
"change_type": "MODIFY",
"old_path": "include/aff3ct.hpp",
"new_path": "include/aff3ct.hpp",
"diff": "#ifndef OVERFLOW_ERROR_HPP_\n#include <Tools/Exception/overflow_error/overflow_error.hpp>\n#endif\n+#ifndef PROCESSING_ABORTED_HPP_\n+#include <Tools/Exception/processing_aborted/processing_aborted.hpp>\n+#endif\n#ifndef RANGE_ERROR_HPP_\n#include <Tools/Exception/range_error/range_error.hpp>\n#endif\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Exception/processing_aborted/processing_aborted.cpp",
"diff": "+#include \"Tools/Exception/processing_aborted/processing_aborted.hpp\"\n+\n+using namespace aff3ct::tools;\n+\n+const std::string processing_aborted::default_message = \"Processing has been aborted.\";\n+\n+processing_aborted\n+::processing_aborted() throw()\n+: exception()\n+{\n+}\n+\n+processing_aborted\n+::processing_aborted(const std::string &message) throw()\n+: exception(message.empty() ? default_message : message)\n+{\n+}\n+\n+processing_aborted\n+::processing_aborted(const std::string &filename,\n+ const int line_num,\n+ const std::string &funcname,\n+ const std::string &message) throw()\n+: exception(filename, line_num, funcname, message.empty() ? default_message : message)\n+{\n+}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a new exception: 'processing_aborted'.
|
8,490 |
16.01.2020 15:00:54
| -3,600 |
d603da486b748b036c00b574dc5a7deb054be727
|
Add 'clone' method to 'Sink_NO'.*
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Sink/NO/Sink_NO.hpp",
"new_path": "include/Module/Sink/NO/Sink_NO.hpp",
"diff": "@@ -36,6 +36,8 @@ public:\n*/\n~Sink_NO() = default;\n+ virtual Sink_NO<B>* clone() const;\n+\nprotected:\nvirtual void _send(const B *V, const int frame_id);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Sink/Sink.hpp",
"new_path": "include/Module/Sink/Sink.hpp",
"diff": "@@ -58,6 +58,8 @@ public:\n*/\nvirtual ~Sink() = default;\n+ virtual Sink<B>* clone() const;\n+\n/*!\n* \\brief Consume a frame.\n*\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Sink/Sink.hxx",
"new_path": "include/Module/Sink/Sink.hxx",
"diff": "@@ -48,6 +48,13 @@ Sink<B>\n});\n}\n+template <typename B>\n+Sink<B>* Sink<B>\n+::clone() const\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\ntemplate <typename B>\ntemplate <class A>\nvoid Sink<B>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Sink/NO/Sink_NO.cpp",
"new_path": "src/Module/Sink/NO/Sink_NO.cpp",
"diff": "@@ -14,6 +14,15 @@ Sink_NO<B>\nthis->set_name(name);\n}\n+template <typename B>\n+Sink_NO<B>* Sink_NO<B>\n+::clone() const\n+{\n+ auto m = new Sink_NO(*this);\n+ m->deep_copy(*this);\n+ return m;\n+}\n+\ntemplate <typename B>\nvoid Sink_NO<B>\n::_send(const B *V, const int frame_id)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add 'clone' method to 'Sink_NO'.*
|
8,490 |
16.01.2020 15:02:27
| -3,600 |
90295b103167eee670af7f69616e4599d48a6bc4
|
Add two getters and support of 'processing_aborted' exception in 'Chain'.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -85,6 +85,9 @@ public:\nstd::vector<std::vector<const module::Module*>> get_modules_per_threads() const;\nstd::vector<std::vector<const module::Module*>> get_modules_per_types () const;\n+ std::vector<std::vector<const module::Task*>> get_tasks_per_threads() const;\n+ std::vector<std::vector<const module::Task*>> get_tasks_per_types () const;\n+\ninline const std::vector<module::Task*>& get_first_tasks() const;\ninline const std::vector<module::Task*>& get_last_tasks() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -174,6 +174,52 @@ std::vector<std::vector<const module::Module*>> Chain\nreturn modules_per_types;\n}\n+std::vector<std::vector<const module::Task*>> Chain\n+::get_tasks_per_threads() const\n+{\n+ std::vector<std::vector<const module::Task*>> tasks_per_threads(this->n_threads);\n+\n+ std::function<void(Generic_node<Sub_sequence>*, const size_t)> get_tasks_recursive =\n+ [&](Generic_node<Sub_sequence>* cur_ss, const size_t tid)\n+ {\n+ tasks_per_threads[tid].insert(tasks_per_threads[tid].end(),\n+ cur_ss->get_c()->tasks.begin(),\n+ cur_ss->get_c()->tasks.end());\n+\n+ for (auto c : cur_ss->get_children())\n+ get_tasks_recursive(c, tid);\n+ };\n+\n+ for (size_t tid = 0; tid < this->n_threads; tid++)\n+ get_tasks_recursive(this->sequences[tid], tid);\n+\n+ return tasks_per_threads;\n+}\n+\n+std::vector<std::vector<const module::Task*>> Chain\n+::get_tasks_per_types() const\n+{\n+ std::vector<std::vector<const module::Task*>> tasks_per_types(this->n_tasks);\n+\n+ std::function<void(Generic_node<Sub_sequence>*, size_t&)> get_tasks_recursive =\n+ [&](Generic_node<Sub_sequence>* cur_ss, size_t &mid)\n+ {\n+ for (auto &t : cur_ss->get_c()->tasks)\n+ tasks_per_types[mid++].push_back(t);\n+\n+ for (auto c : cur_ss->get_children())\n+ get_tasks_recursive(c, mid);\n+ };\n+\n+ for (size_t tid = 0; tid < this->n_threads; tid++)\n+ {\n+ size_t mid = 0;\n+ get_tasks_recursive(this->sequences[tid], mid);\n+ }\n+\n+ return tasks_per_types;\n+}\n+\nvoid Chain\n::_exec(std::function<bool(const std::vector<int>&)> &stop_condition, Generic_node<Sub_sequence>* sequence)\n{\n@@ -204,9 +250,16 @@ void Chain\ntry\n{\ndo\n+ {\n+ try\n{\nexec_sequence(sequence, statuses);\n}\n+ catch (tools::processing_aborted const&)\n+ {\n+ // do nothing, this is normal\n+ }\n+ }\nwhile (!*force_exit_loop && !stop_condition(statuses));\n}\ncatch (tools::waiting_canceled const&)\n@@ -264,9 +317,16 @@ void Chain\ntry\n{\ndo\n+ {\n+ try\n{\nexec_sequence(sequence);\n}\n+ catch (tools::processing_aborted const&)\n+ {\n+ // do nothing, this is normal\n+ }\n+ }\nwhile (!*force_exit_loop && !stop_condition());\n}\ncatch (tools::waiting_canceled const&)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add two getters and support of 'processing_aborted' exception in 'Chain'.
|
8,490 |
16.01.2020 15:03:21
| -3,600 |
64e30c4a2d636f226822dab50dd7d98c0c76e222
|
Rename 'put' in 'push' in the adaptors.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hpp",
"new_path": "include/Module/Adaptor/Adaptor.hpp",
"diff": "@@ -23,13 +23,13 @@ namespace module\n{\nnamespace adp\n{\n- enum class tsk : size_t { put_1, pull_n, put_n, pull_1, SIZE };\n+ enum class tsk : size_t { push_1, pull_n, push_n, pull_1, SIZE };\nnamespace sck\n{\n- enum class put_1 : size_t { in, SIZE };\n+ enum class push_1 : size_t { in, SIZE };\nenum class pull_n : size_t { out, SIZE };\n- enum class put_n : size_t { in, SIZE };\n+ enum class push_n : size_t { in, SIZE };\nenum class pull_1 : size_t { out, SIZE };\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"diff": "@@ -27,7 +27,7 @@ class Adaptor_1_to_n : public Adaptor\n{\npublic:\ninline Task& operator[](const adp::tsk t);\n- inline Socket& operator[](const adp::sck::put_1 s);\n+ inline Socket& operator[](const adp::sck::push_1 s);\ninline Socket& operator[](const adp::sck::pull_n s);\nconst bool active_waiting;\n@@ -47,11 +47,11 @@ public:\nvirtual Adaptor_1_to_n* clone() const;\ntemplate <class A = std::allocator<int8_t>>\n- void put_1(const std::vector<int8_t,A>& in, const int frame_id = -1);\n+ void push_1(const std::vector<int8_t,A>& in, const int frame_id = -1);\ntemplate <class A = std::allocator<int8_t>>\nvoid pull_n(std::vector<int8_t,A>& out, const int frame_id = -1);\n- virtual void put_1 (const int8_t *in, const int frame_id = -1);\n+ virtual void push_1(const int8_t *in, const int frame_id = -1);\nvirtual void pull_n( int8_t *out, const int frame_id = -1);\nvoid wake_up();\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"diff": "@@ -16,9 +16,9 @@ Task& Adaptor_1_to_n\n}\nSocket& Adaptor_1_to_n\n-::operator[](const adp::sck::put_1 s)\n+::operator[](const adp::sck::push_1 s)\n{\n- return Module::operator[]((size_t)adp::tsk::put_1)[(size_t)s];\n+ return Module::operator[]((size_t)adp::tsk::push_1)[(size_t)s];\n}\nSocket& Adaptor_1_to_n\n@@ -80,11 +80,11 @@ Adaptor_1_to_n\n}\n};\n- auto &p1 = this->create_task(\"put_1\", (int)adp::tsk::put_1);\n+ auto &p1 = this->create_task(\"push_1\", (int)adp::tsk::push_1);\nauto p1s_in = create_socket_in(p1, n_elmts, datatype);\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n{\n- static_cast<Adaptor_1_to_n&>(m).put_1(static_cast<int8_t*>(t[p1s_in].get_dataptr()));\n+ static_cast<Adaptor_1_to_n&>(m).push_1(static_cast<int8_t*>(t[p1s_in].get_dataptr()));\nreturn 0;\n});\n@@ -99,7 +99,7 @@ Adaptor_1_to_n\ntemplate <class A>\nvoid Adaptor_1_to_n\n-::put_1(const std::vector<int8_t,A>& in, const int frame_id)\n+::push_1(const std::vector<int8_t,A>& in, const int frame_id)\n{\nif (this->n_bytes * (size_t)this->n_frames != in.size())\n{\n@@ -109,7 +109,7 @@ void Adaptor_1_to_n\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- this->put_1(in.data(), frame_id);\n+ this->push_1(in.data(), frame_id);\n}\ntemplate <class A>\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"diff": "@@ -27,7 +27,7 @@ class Adaptor_n_to_1 : public Adaptor\n{\npublic:\ninline Task& operator[](const adp::tsk t);\n- inline Socket& operator[](const adp::sck::put_n s);\n+ inline Socket& operator[](const adp::sck::push_n s);\ninline Socket& operator[](const adp::sck::pull_1 s);\nconst bool active_waiting;\n@@ -47,11 +47,11 @@ public:\nvirtual Adaptor_n_to_1* clone() const;\ntemplate <class A = std::allocator<int8_t>>\n- void put_n(const std::vector<int8_t,A>& in, const int frame_id = -1);\n+ void push_n(const std::vector<int8_t,A>& in, const int frame_id = -1);\ntemplate <class A = std::allocator<int8_t>>\nvoid pull_1(std::vector<int8_t,A>& out, const int frame_id = -1);\n- virtual void put_n (const int8_t *in, const int frame_id = -1);\n+ virtual void push_n(const int8_t *in, const int frame_id = -1);\nvirtual void pull_1( int8_t *out, const int frame_id = -1);\nvoid wake_up();\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"diff": "@@ -16,9 +16,9 @@ Task& Adaptor_n_to_1\n}\nSocket& Adaptor_n_to_1\n-::operator[](const adp::sck::put_n s)\n+::operator[](const adp::sck::push_n s)\n{\n- return Module::operator[]((size_t)adp::tsk::put_n)[(size_t)s];\n+ return Module::operator[]((size_t)adp::tsk::push_n)[(size_t)s];\n}\nSocket& Adaptor_n_to_1\n@@ -80,11 +80,11 @@ Adaptor_n_to_1\n}\n};\n- auto &p1 = this->create_task(\"put_n\", (int)adp::tsk::put_n);\n+ auto &p1 = this->create_task(\"push_n\", (int)adp::tsk::push_n);\nauto p1s_in = create_socket_in(p1, n_elmts, datatype);\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n{\n- static_cast<Adaptor_n_to_1&>(m).put_n(static_cast<int8_t*>(t[p1s_in].get_dataptr()));\n+ static_cast<Adaptor_n_to_1&>(m).push_n(static_cast<int8_t*>(t[p1s_in].get_dataptr()));\nreturn 0;\n});\n@@ -99,7 +99,7 @@ Adaptor_n_to_1\ntemplate <class A>\nvoid Adaptor_n_to_1\n-::put_n(const std::vector<int8_t,A>& in, const int frame_id)\n+::push_n(const std::vector<int8_t,A>& in, const int frame_id)\n{\nif (this->n_bytes * (size_t)this->n_frames != in.size())\n{\n@@ -109,7 +109,7 @@ void Adaptor_n_to_1\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- this->put_n(in.data(), frame_id);\n+ this->push_n(in.data(), frame_id);\n}\ntemplate <class A>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"new_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"diff": "@@ -15,7 +15,7 @@ Adaptor_1_to_n* Adaptor_1_to_n\n}\nvoid Adaptor_1_to_n\n-::put_1(const int8_t *in, const int frame_id)\n+::push_1(const int8_t *in, const int frame_id)\n{\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"new_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"diff": "@@ -15,7 +15,7 @@ Adaptor_n_to_1* Adaptor_n_to_1\n}\nvoid Adaptor_n_to_1\n-::put_n(const int8_t *in, const int frame_id)\n+::push_n(const int8_t *in, const int frame_id)\n{\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rename 'put' in 'push' in the adaptors.
|
8,490 |
16.01.2020 17:45:52
| -3,600 |
f9a8db5ae1a6a760c4fe889706c4a029c12149f3
|
Rm constness of the 'Chain' getters.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -82,11 +82,11 @@ public:\ntemplate <class C = module::Module>\nstd::vector<C*> get_modules(const bool subchain_modules = true) const;\n- std::vector<std::vector<const module::Module*>> get_modules_per_threads() const;\n- std::vector<std::vector<const module::Module*>> get_modules_per_types () const;\n+ std::vector<std::vector<module::Module*>> get_modules_per_threads() const;\n+ std::vector<std::vector<module::Module*>> get_modules_per_types () const;\n- std::vector<std::vector<const module::Task*>> get_tasks_per_threads() const;\n- std::vector<std::vector<const module::Task*>> get_tasks_per_types () const;\n+ std::vector<std::vector<module::Task*>> get_tasks_per_threads() const;\n+ std::vector<std::vector<module::Task*>> get_tasks_per_types () const;\ninline const std::vector<module::Task*>& get_first_tasks() const;\ninline const std::vector<module::Task*>& get_last_tasks() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -147,10 +147,10 @@ Chain* Chain\nreturn c;\n}\n-std::vector<std::vector<const module::Module*>> Chain\n+std::vector<std::vector<module::Module*>> Chain\n::get_modules_per_threads() const\n{\n- std::vector<std::vector<const module::Module*>> modules_per_threads(this->all_modules.size());\n+ std::vector<std::vector<module::Module*>> modules_per_threads(this->all_modules.size());\nsize_t tid = 0;\nfor (auto &e : this->all_modules)\n{\n@@ -161,10 +161,10 @@ std::vector<std::vector<const module::Module*>> Chain\nreturn modules_per_threads;\n}\n-std::vector<std::vector<const module::Module*>> Chain\n+std::vector<std::vector<module::Module*>> Chain\n::get_modules_per_types() const\n{\n- std::vector<std::vector<const module::Module*>> modules_per_types(this->all_modules[0].size());\n+ std::vector<std::vector<module::Module*>> modules_per_types(this->all_modules[0].size());\nfor (auto &e : this->all_modules)\n{\nsize_t mid = 0;\n@@ -174,10 +174,10 @@ std::vector<std::vector<const module::Module*>> Chain\nreturn modules_per_types;\n}\n-std::vector<std::vector<const module::Task*>> Chain\n+std::vector<std::vector<module::Task*>> Chain\n::get_tasks_per_threads() const\n{\n- std::vector<std::vector<const module::Task*>> tasks_per_threads(this->n_threads);\n+ std::vector<std::vector<module::Task*>> tasks_per_threads(this->n_threads);\nstd::function<void(Generic_node<Sub_sequence>*, const size_t)> get_tasks_recursive =\n[&](Generic_node<Sub_sequence>* cur_ss, const size_t tid)\n@@ -196,10 +196,10 @@ std::vector<std::vector<const module::Task*>> Chain\nreturn tasks_per_threads;\n}\n-std::vector<std::vector<const module::Task*>> Chain\n+std::vector<std::vector<module::Task*>> Chain\n::get_tasks_per_types() const\n{\n- std::vector<std::vector<const module::Task*>> tasks_per_types(this->n_tasks);\n+ std::vector<std::vector<module::Task*>> tasks_per_types(this->n_tasks);\nstd::function<void(Generic_node<Sub_sequence>*, size_t&)> get_tasks_recursive =\n[&](Generic_node<Sub_sequence>* cur_ss, size_t &mid)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rm constness of the 'Chain' getters.
|
8,490 |
16.01.2020 17:49:40
| -3,600 |
0b7cc02163bd98e1fd80d3ef25cad887ef6dbcbe
|
Add const and non-const support for modules and tasks in the stats.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Display/Statistics/Statistics.hpp",
"new_path": "include/Tools/Display/Statistics/Statistics.hpp",
"diff": "@@ -27,16 +27,27 @@ protected:\npublic:\nvirtual ~Statistics() = default;\n- static void show(std::vector<const module::Module*> modules, const bool ordered = false,\n+ template <class MODULE_OR_TASK>\n+ static void show(std::vector<MODULE_OR_TASK*> modules_or_tasks, const bool ordered = false,\nstd::ostream &stream = std::cout);\n- static void show(std::vector<const module::Task*> tasks, const bool ordered = false,\n+ template <class MODULE_OR_TASK>\n+ static void show(std::vector<std::vector<MODULE_OR_TASK*>> modules_or_tasks, const bool ordered = false,\nstd::ostream &stream = std::cout);\n- static void show(std::vector<std::vector<const module::Module*>> modules, const bool ordered = false,\n+\n+private:\n+ template <class MODULE = const module::Module>\n+ static void show_modules(std::vector<MODULE*> modules, const bool ordered = false,\n+ std::ostream &stream = std::cout);\n+ template <class TASK = const module::Task>\n+ static void show_tasks(std::vector<TASK*> tasks, const bool ordered = false,\nstd::ostream &stream = std::cout);\n- static void show(std::vector<std::vector<const module::Task*>> tasks, const bool ordered = false,\n+ template <class MODULE = const module::Module>\n+ static void show_modules(std::vector<std::vector<MODULE*>> modules, const bool ordered = false,\n+ std::ostream &stream = std::cout);\n+ template <class TASK = const module::Task>\n+ static void show_tasks(std::vector<std::vector<TASK*>> tasks, const bool ordered = false,\nstd::ostream &stream = std::cout);\n-private:\nstatic void separation1(std::ostream &stream = std::cout);\nstatic void separation2(std::ostream &stream = std::cout);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Statistics/Statistics.cpp",
"new_path": "src/Tools/Display/Statistics/Statistics.cpp",
"diff": "+#include <type_traits>\n#include <algorithm>\n#include <iomanip>\n+#include <sstream>\n#include <ios>\n+#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Display/rang_format/rang_format.h\"\n#include \"Tools/Display/Statistics/Statistics.hpp\"\n@@ -175,8 +178,51 @@ void Statistics\n<< std::endl;\n}\n+template <class MODULE_OR_TASK>\nvoid Statistics\n-::show(std::vector<const module::Module*> modules, const bool ordered, std::ostream &stream)\n+::show(std::vector<MODULE_OR_TASK*> modules_or_tasks, const bool ordered, std::ostream &stream)\n+{\n+ std::stringstream message;\n+ message << \"The 'Statistics::show' method expect a 'std::vector' of 'module::Module' or 'module::Task'.\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+}\n+\n+template <>\n+void Statistics\n+::show<module::Module>(std::vector<module::Module*> modules, const bool ordered, std::ostream &stream)\n+{\n+ Statistics::show_modules<module::Module>(modules, ordered, stream);\n+}\n+\n+template <>\n+void Statistics\n+::show<const module::Module>(std::vector<const module::Module*> modules, const bool ordered, std::ostream &stream)\n+{\n+ Statistics::show_modules<const module::Module>(modules, ordered, stream);\n+}\n+\n+template <>\n+void Statistics\n+::show<module::Task>(std::vector<module::Task*> tasks, const bool ordered, std::ostream &stream)\n+{\n+ Statistics::show_tasks<module::Task>(tasks, ordered, stream);\n+}\n+\n+template <>\n+void Statistics\n+::show<const module::Task>(std::vector<const module::Task*> tasks, const bool ordered, std::ostream &stream)\n+{\n+ Statistics::show_tasks<const module::Task>(tasks, ordered, stream);\n+}\n+\n+template void tools::Statistics::show<const module::Module>(std::vector<const module::Module*>, const bool, std::ostream&);\n+template void tools::Statistics::show< module::Module>(std::vector< module::Module*>, const bool, std::ostream&);\n+template void tools::Statistics::show<const module::Task >(std::vector<const module::Task *>, const bool, std::ostream&);\n+template void tools::Statistics::show< module::Task >(std::vector< module::Task *>, const bool, std::ostream&);\n+\n+template <class MODULE>\n+void Statistics\n+::show_modules(std::vector<MODULE*> modules, const bool ordered, std::ostream &stream)\n{\nstd::vector<const module::Task*> tasks;\nfor (auto& m : modules)\n@@ -185,11 +231,12 @@ void Statistics\nif (t->get_n_calls())\ntasks.push_back(t.get());\n- Statistics::show(tasks, ordered, stream);\n+ Statistics::show_tasks(tasks, ordered, stream);\n}\n+template <class TASK>\nvoid Statistics\n-::show(std::vector<const module::Task*> tasks, const bool ordered, std::ostream &stream)\n+::show_tasks(std::vector<TASK*> tasks, const bool ordered, std::ostream &stream)\n{\nfor (size_t t = 0; t < tasks.size(); t++)\nif (tasks[t] == nullptr)\n@@ -285,8 +332,52 @@ void Statistics\n}\n}\n+template <class MODULE_OR_TASK>\n+void Statistics\n+::show(std::vector<std::vector<MODULE_OR_TASK*>> modules_or_tasks, const bool ordered, std::ostream &stream)\n+{\n+ std::stringstream message;\n+ message << \"The 'Statistics::show' method expect a 'std::vector' of 'std::vector' of 'module::Module' or \"\n+ << \"'module::Task'.\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+}\n+\n+template <>\n+void Statistics\n+::show<module::Module>(std::vector<std::vector<module::Module*>> modules, const bool ordered, std::ostream &stream)\n+{\n+ Statistics::show_modules<module::Module>(modules, ordered, stream);\n+}\n+\n+template <>\n+void Statistics\n+::show<const module::Module>(std::vector<std::vector<const module::Module*>> modules, const bool ordered, std::ostream &stream)\n+{\n+ Statistics::show_modules<const module::Module>(modules, ordered, stream);\n+}\n+\n+template <>\n+void Statistics\n+::show<module::Task>(std::vector<std::vector<module::Task*>> tasks, const bool ordered, std::ostream &stream)\n+{\n+ Statistics::show_tasks<module::Task>(tasks, ordered, stream);\n+}\n+\n+template <>\n+void Statistics\n+::show<const module::Task>(std::vector<std::vector<const module::Task*>> tasks, const bool ordered, std::ostream &stream)\n+{\n+ Statistics::show_tasks<const module::Task>(tasks, ordered, stream);\n+}\n+\n+template void tools::Statistics::show<const module::Module>(std::vector<std::vector<const module::Module*>>, const bool, std::ostream&);\n+template void tools::Statistics::show< module::Module>(std::vector<std::vector< module::Module*>>, const bool, std::ostream&);\n+template void tools::Statistics::show<const module::Task >(std::vector<std::vector<const module::Task *>>, const bool, std::ostream&);\n+template void tools::Statistics::show< module::Task >(std::vector<std::vector< module::Task *>>, const bool, std::ostream&);\n+\n+template <class MODULE>\nvoid Statistics\n-::show(std::vector<std::vector<const module::Module*>> modules, const bool ordered, std::ostream &stream)\n+::show_modules(std::vector<std::vector<MODULE*>> modules, const bool ordered, std::ostream &stream)\n{\nstd::vector<std::vector<const module::Task*>> tasks;\nfor (auto &vm : modules)\n@@ -302,11 +393,12 @@ void Statistics\n}\n}\n- Statistics::show(tasks, ordered, stream);\n+ Statistics::show_tasks(tasks, ordered, stream);\n}\n+template <class TASK>\nvoid Statistics\n-::show(std::vector<std::vector<const module::Task*>> tasks, const bool ordered, std::ostream &stream)\n+::show_tasks(std::vector<std::vector<TASK*>> tasks, const bool ordered, std::ostream &stream)\n{\nusing namespace std::chrono;\n@@ -318,8 +410,8 @@ void Statistics\nif (ordered)\n{\n- std::sort(tasks.begin(), tasks.end(), [](const std::vector<const module::Task*> &t1,\n- const std::vector<const module::Task*> &t2)\n+ std::sort(tasks.begin(), tasks.end(), [](const std::vector<TASK*> &t1,\n+ const std::vector<TASK*> &t2)\n{\nauto total1 = nanoseconds(0);\nauto total2 = nanoseconds(0);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add const and non-const support for modules and tasks in the stats.
|
8,490 |
26.01.2020 11:41:48
| -3,600 |
3023bafb5e3521b4eb458ee24108d0212ec79b1f
|
Add missing getter in MK Polar codec.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Codec/Polar_MK/Codec_polar_MK.cpp",
"new_path": "src/Tools/Codec/Polar_MK/Codec_polar_MK.cpp",
"diff": "@@ -191,6 +191,20 @@ const Polar_code& Codec_polar_MK<B,Q>\nreturn *this->code;\n}\n+template <typename B, typename Q>\n+const Frozenbits_generator& Codec_polar_MK<B,Q>\n+::get_frozen_bits_generator() const\n+{\n+ if (this->fb_generator == nullptr)\n+ {\n+ std::stringstream message;\n+ message << \"'fb_generator' can't be nullptr.\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return *this->fb_generator.get();\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef AFF3CT_MULTI_PREC\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add missing getter in MK Polar codec.
|
8,490 |
26.01.2020 11:50:20
| -3,600 |
207c0886f90d37f8b64a010b6d1f7ac1f4ca40c4
|
Rm useless explicit template instantiation.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Statistics/Statistics.cpp",
"new_path": "src/Tools/Display/Statistics/Statistics.cpp",
"diff": "@@ -221,11 +221,6 @@ void Statistics\n}\n}\n-template void tools::Statistics::show<const module::Module>(std::vector<const module::Module*>, const bool, std::ostream&);\n-template void tools::Statistics::show< module::Module>(std::vector< module::Module*>, const bool, std::ostream&);\n-template void tools::Statistics::show<const module::Task >(std::vector<const module::Task *>, const bool, std::ostream&);\n-template void tools::Statistics::show< module::Task >(std::vector< module::Task *>, const bool, std::ostream&);\n-\ntemplate <class MODULE>\nvoid Statistics\n::show_modules(std::vector<MODULE*> modules, const bool ordered, std::ostream &stream)\n@@ -382,11 +377,6 @@ void Statistics\n}\n}\n-template void tools::Statistics::show<const module::Module>(std::vector<std::vector<const module::Module*>>, const bool, std::ostream&);\n-template void tools::Statistics::show< module::Module>(std::vector<std::vector< module::Module*>>, const bool, std::ostream&);\n-template void tools::Statistics::show<const module::Task >(std::vector<std::vector<const module::Task *>>, const bool, std::ostream&);\n-template void tools::Statistics::show< module::Task >(std::vector<std::vector< module::Task *>>, const bool, std::ostream&);\n-\ntemplate <class MODULE>\nvoid Statistics\n::show_modules(std::vector<std::vector<MODULE*>> modules, const bool ordered, std::ostream &stream)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rm useless explicit template instantiation.
|
8,490 |
26.01.2020 15:10:34
| -3,600 |
8c8c8213fe587a6ce2a5e805979db1f9c13fb06c
|
Improve the adaptors to manage more than a single socket (not tested).
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hpp",
"new_path": "include/Module/Adaptor/Adaptor.hpp",
"diff": "@@ -27,33 +27,34 @@ namespace module\nnamespace sck\n{\n- enum class push_1 : size_t { in, SIZE };\n- enum class pull_n : size_t { out, SIZE };\n- enum class push_n : size_t { in, SIZE };\n- enum class pull_1 : size_t { out, SIZE };\n+ enum class push_1 : size_t { in1, in2, in3, in4, SIZE };\n+ enum class pull_n : size_t { out1, out2, out3, out4, SIZE };\n+ enum class push_n : size_t { in1, in2, in3, in4, SIZE };\n+ enum class pull_1 : size_t { out1, out2, out3, out4, SIZE };\n}\n}\nclass Adaptor : public Module, public tools::Interface_waiting\n{\nprotected:\n- const size_t n_elmts;\n- const size_t n_bytes;\n- const std::type_index datatype;\n+ const std::vector<size_t> n_elmts;\n+ const std::vector<size_t> n_bytes;\n+ const std::vector<std::type_index> datatype;\nconst size_t buffer_size;\n+ const size_t n_sockets;\nsize_t id;\nsize_t cur_id;\n- std::shared_ptr<std::vector<std::vector<std::vector<int8_t>>>> buffer;\n+ std::shared_ptr<std::vector<std::vector<std::vector<std::vector<int8_t>>>>> buffer;\nstd::shared_ptr<std::vector<std::atomic<size_t>>> first;\nstd::shared_ptr<std::vector<std::atomic<size_t>>> last;\nstd::shared_ptr<std::atomic<bool>> waiting_canceled;\npublic:\n- inline size_t get_n_elmts() const;\n- inline size_t get_n_bytes() const;\n- inline std::type_index get_datatype() const;\n+ inline size_t get_n_elmts(const size_t sid = 0) const;\n+ inline size_t get_n_bytes(const size_t sid = 0) const;\n+ inline std::type_index get_datatype(const size_t sid = 0) const;\nvoid send_cancel_signal();\nvoid reset();\n@@ -62,6 +63,10 @@ protected:\nconst std::type_index datatype,\nconst size_t buffer_size,\nconst int n_frames = 1);\n+ inline Adaptor(const std::vector<size_t> &n_elmts,\n+ const std::vector<std::type_index> &datatype,\n+ const size_t buffer_size,\n+ const int n_frames = 1);\nvirtual ~Adaptor();\nvirtual void deep_copy(const Adaptor &m);\ninline bool is_full(const size_t id);\n@@ -71,6 +76,7 @@ protected:\nprivate:\nstatic size_t compute_bytes(const size_t n_elmts, const std::type_index type);\n+ static std::vector<size_t> compute_bytes(const std::vector<size_t> &n_elmts, const std::vector<std::type_index> &type);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hxx",
"new_path": "include/Module/Adaptor/Adaptor.hxx",
"diff": "@@ -15,15 +15,62 @@ Adaptor\nconst std::type_index datatype,\nconst size_t buffer_size,\nconst int n_frames)\n+: Module(n_frames),\n+ n_elmts(1, n_elmts),\n+ n_bytes(1, compute_bytes(n_elmts, datatype)),\n+ datatype(1, datatype),\n+ buffer_size(buffer_size),\n+ n_sockets(1),\n+ id(0),\n+ cur_id(0),\n+ buffer(new std::vector<std::vector<std::vector<std::vector<int8_t>>>>\n+ (1, std::vector<std::vector<std::vector<int8_t>>>(1,\n+ std::vector<std::vector<int8_t>>(buffer_size,\n+ std::vector<int8_t>(n_frames * this->n_bytes[0]))))),\n+ first(new std::vector<std::atomic<size_t>>(1000)),\n+ last(new std::vector<std::atomic<size_t>>(1000)),\n+ waiting_canceled(new std::atomic<bool>(false))\n+{\n+ const std::string name = \"Adaptor\";\n+ this->set_name(name);\n+ this->set_short_name(name);\n+\n+ if (buffer_size == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'buffer_size' has to be greater than 0 ('buffer_size' = \" << buffer_size << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (n_elmts == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'n_elmts' has to be greater than 0 ('n_elmts' = \" << n_elmts << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ for (auto &a : *this->first.get()) a = 0;\n+ for (auto &a : *this->last .get()) a = 0;\n+\n+ this->tasks_with_nullptr.resize((size_t)adp::tsk::SIZE);\n+}\n+\n+Adaptor\n+::Adaptor(const std::vector<size_t> &n_elmts,\n+ const std::vector<std::type_index> &datatype,\n+ const size_t buffer_size,\n+ const int n_frames)\n: Module(n_frames),\nn_elmts(n_elmts),\nn_bytes(compute_bytes(n_elmts, datatype)),\ndatatype(datatype),\nbuffer_size(buffer_size),\n+ n_sockets(n_elmts.size()),\nid(0),\ncur_id(0),\n- buffer(new std::vector<std::vector<std::vector<int8_t>>>\n- (1, std::vector<std::vector<int8_t>>(buffer_size, std::vector<int8_t>(n_frames * n_bytes)))),\n+ buffer(new std::vector<std::vector<std::vector<std::vector<int8_t>>>>\n+ (1, std::vector<std::vector<std::vector<int8_t>>>(n_sockets,\n+ std::vector<std::vector<int8_t>>(buffer_size)))),\nfirst(new std::vector<std::atomic<size_t>>(1000)),\nlast(new std::vector<std::atomic<size_t>>(1000)),\nwaiting_canceled(new std::atomic<bool>(false))\n@@ -39,13 +86,28 @@ Adaptor\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (n_elmts == 0)\n+ if (n_elmts.size() == 0)\n{\nstd::stringstream message;\n- message << \"'n_elmts' has to be greater than 0 ('n_elmts' = \" << n_elmts << \").\";\n+ message << \"'n_elmts.size()' has to be greater than 0 ('n_elmts.size()' = \" << n_elmts.size() << \").\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ for (size_t e = 0; e < n_elmts.size(); e++)\n+ {\n+ if (n_elmts[e] == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'n_elmts[e]' has to be greater than 0 ('e' = \" << e << \", 'n_elmts[e]' = \"\n+ << n_elmts[e] << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ for (size_t b = 0; b < this->buffer_size; b++)\n+ (*this->buffer)[0][s][b].resize(this->n_frames * this->n_bytes[s]);\n+\nfor (auto &a : *this->first.get()) a = 0;\nfor (auto &a : *this->last .get()) a = 0;\n@@ -53,21 +115,21 @@ Adaptor\n}\nsize_t Adaptor\n-::get_n_elmts() const\n+::get_n_elmts(const size_t sid) const\n{\n- return this->n_elmts;\n+ return this->n_elmts[sid];\n}\nsize_t Adaptor\n-::get_n_bytes() const\n+::get_n_bytes(const size_t sid) const\n{\n- return this->n_bytes;\n+ return this->n_bytes[sid];\n}\nstd::type_index Adaptor\n-::get_datatype() const\n+::get_datatype(const size_t sid) const\n{\n- return this->datatype;\n+ return this->datatype[sid];\n}\nbool Adaptor\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"diff": "@@ -43,19 +43,22 @@ public:\nconst size_t buffer_size = 1,\nconst bool active_waiting = true,\nconst int n_frames = 1);\n+ inline Adaptor_1_to_n(const std::vector<size_t> &n_elmts,\n+ const std::vector<std::type_index> &datatype,\n+ const size_t buffer_size = 1,\n+ const bool active_waiting = true,\n+ const int n_frames = 1);\nvirtual ~Adaptor_1_to_n() = default;\nvirtual Adaptor_1_to_n* clone() const;\n- template <class A = std::allocator<int8_t>>\n- void push_1(const std::vector<int8_t,A>& in, const int frame_id = -1);\n- template <class A = std::allocator<int8_t>>\n- void pull_n(std::vector<int8_t,A>& out, const int frame_id = -1);\n-\n- virtual void push_1(const int8_t *in, const int frame_id = -1);\n- virtual void pull_n( int8_t *out, const int frame_id = -1);\n+ void init();\nvoid wake_up();\nvoid cancel_waiting();\n+\n+protected:\n+ virtual void push_1(const std::vector<const int8_t*> &in, const int frame_id = -1);\n+ virtual void pull_n(const std::vector< int8_t*> &out, const int frame_id = -1);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"diff": "@@ -39,6 +39,28 @@ Adaptor_1_to_n\nmtx_pull(new std::vector<std::mutex >(1000)),\ncnd_put (new std::condition_variable ( )),\nmtx_put (new std::mutex ( ))\n+{\n+ this->init();\n+}\n+\n+Adaptor_1_to_n\n+::Adaptor_1_to_n(const std::vector<size_t> &n_elmts,\n+ const std::vector<std::type_index> &datatype,\n+ const size_t buffer_size,\n+ const bool active_waiting,\n+ const int n_frames)\n+: Adaptor(n_elmts, datatype, buffer_size, n_frames),\n+ active_waiting(active_waiting),\n+ cnd_pull(new std::vector<std::condition_variable>(1000)),\n+ mtx_pull(new std::vector<std::mutex >(1000)),\n+ cnd_put (new std::condition_variable ( )),\n+ mtx_put (new std::mutex ( ))\n+{\n+ this->init();\n+}\n+\n+void Adaptor_1_to_n\n+::init()\n{\nconst std::string name = \"Adaptor_1_to_n\";\nthis->set_name(name);\n@@ -81,51 +103,34 @@ Adaptor_1_to_n\n};\nauto &p1 = this->create_task(\"push_1\", (int)adp::tsk::push_1);\n- auto p1s_in = create_socket_in(p1, n_elmts, datatype);\n+ std::vector<size_t> p1s_in;\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s]));\n+\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n{\n- static_cast<Adaptor_1_to_n&>(m).push_1(static_cast<int8_t*>(t[p1s_in].get_dataptr()));\n+ std::vector<const int8_t*> sockets_dataptr(p1s_in.size());\n+ for (size_t s = 0; s < p1s_in.size(); s++)\n+ sockets_dataptr[s] = static_cast<const int8_t*>(t[p1s_in[s]].get_dataptr());\n+\n+ static_cast<Adaptor_1_to_n&>(m).push_1(sockets_dataptr);\nreturn 0;\n});\nauto &p2 = this->create_task(\"pull_n\", (int)adp::tsk::pull_n);\n- auto p2s_out = create_socket_out(p2, n_elmts, datatype);\n+ std::vector<size_t> p2s_out;\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ p2s_out.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s]));\n+\nthis->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n{\n- static_cast<Adaptor_1_to_n&>(m).pull_n(static_cast<int8_t*>(t[p2s_out].get_dataptr()));\n+ std::vector<int8_t*> sockets_dataptr(p2s_out.size());\n+ for (size_t s = 0; s < p2s_out.size(); s++)\n+ sockets_dataptr[s] = static_cast<int8_t*>(t[p2s_out[s]].get_dataptr());\n+\n+ static_cast<Adaptor_1_to_n&>(m).pull_n(sockets_dataptr);\nreturn 0;\n});\n}\n-\n-template <class A>\n-void Adaptor_1_to_n\n-::push_1(const std::vector<int8_t,A>& in, const int frame_id)\n-{\n- if (this->n_bytes * (size_t)this->n_frames != in.size())\n- {\n- std::stringstream message;\n- message << \"'in.size()' has to be equal to 'n_bytes' * 'n_frames' ('in.size()' = \" << in.size()\n- << \", 'n_bytes' = \" << this->n_bytes << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->push_1(in.data(), frame_id);\n-}\n-\n-template <class A>\n-void Adaptor_1_to_n\n-::pull_n(std::vector<int8_t,A>& out, const int frame_id)\n-{\n- if (this->n_bytes * (size_t)this->n_frames != out.size())\n- {\n- std::stringstream message;\n- message << \"'out.size()' has to be equal to 'n_bytes' * 'n_frames' ('out.size()' = \" << out.size()\n- << \", 'n_bytes' = \" << this->n_bytes << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->pull_n(out.data(), frame_id);\n-}\n-\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"diff": "@@ -43,19 +43,22 @@ public:\nconst size_t buffer_size = 1,\nconst bool active_waiting = true,\nconst int n_frames = 1);\n+ inline Adaptor_n_to_1(const std::vector<size_t> &n_elmts,\n+ const std::vector<std::type_index> &datatype,\n+ const size_t buffer_size = 1,\n+ const bool active_waiting = true,\n+ const int n_frames = 1);\nvirtual ~Adaptor_n_to_1() = default;\nvirtual Adaptor_n_to_1* clone() const;\n- template <class A = std::allocator<int8_t>>\n- void push_n(const std::vector<int8_t,A>& in, const int frame_id = -1);\n- template <class A = std::allocator<int8_t>>\n- void pull_1(std::vector<int8_t,A>& out, const int frame_id = -1);\n-\n- virtual void push_n(const int8_t *in, const int frame_id = -1);\n- virtual void pull_1( int8_t *out, const int frame_id = -1);\n+ void init();\nvoid wake_up();\nvoid cancel_waiting();\n+\n+protected:\n+ virtual void push_n(const std::vector<const int8_t*> &in, const int frame_id = -1);\n+ virtual void pull_1(const std::vector< int8_t*> &out, const int frame_id = -1);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"diff": "@@ -39,6 +39,28 @@ Adaptor_n_to_1\nmtx_put (new std::vector<std::mutex >(1000)),\ncnd_pull(new std::condition_variable ( )),\nmtx_pull(new std::mutex ( ))\n+{\n+ this->init();\n+}\n+\n+Adaptor_n_to_1\n+::Adaptor_n_to_1(const std::vector<size_t> &n_elmts,\n+ const std::vector<std::type_index> &datatype,\n+ const size_t buffer_size,\n+ const bool active_waiting,\n+ const int n_frames)\n+: Adaptor(n_elmts, datatype, buffer_size, n_frames),\n+ active_waiting(active_waiting),\n+ cnd_put (new std::vector<std::condition_variable>(1000)),\n+ mtx_put (new std::vector<std::mutex >(1000)),\n+ cnd_pull(new std::condition_variable ( )),\n+ mtx_pull(new std::mutex ( ))\n+{\n+ this->init();\n+}\n+\n+void Adaptor_n_to_1\n+::init()\n{\nconst std::string name = \"Adaptor_n_to_1\";\nthis->set_name(name);\n@@ -81,51 +103,34 @@ Adaptor_n_to_1\n};\nauto &p1 = this->create_task(\"push_n\", (int)adp::tsk::push_n);\n- auto p1s_in = create_socket_in(p1, n_elmts, datatype);\n+ std::vector<size_t> p1s_in;\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s]));\n+\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n{\n- static_cast<Adaptor_n_to_1&>(m).push_n(static_cast<int8_t*>(t[p1s_in].get_dataptr()));\n+ std::vector<const int8_t*> sockets_dataptr(p1s_in.size());\n+ for (size_t s = 0; s < p1s_in.size(); s++)\n+ sockets_dataptr[s] = static_cast<const int8_t*>(t[p1s_in[s]].get_dataptr());\n+\n+ static_cast<Adaptor_n_to_1&>(m).push_n(sockets_dataptr);\nreturn 0;\n});\nauto &p2 = this->create_task(\"pull_1\", (int)adp::tsk::pull_1);\n- auto p2s_out = create_socket_out(p2, n_elmts, datatype);\n+ std::vector<size_t> p2s_out;\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ p2s_out.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s]));\n+\nthis->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n{\n- static_cast<Adaptor_n_to_1&>(m).pull_1(static_cast<int8_t*>(t[p2s_out].get_dataptr()));\n+ std::vector<int8_t*> sockets_dataptr(p2s_out.size());\n+ for (size_t s = 0; s < p2s_out.size(); s++)\n+ sockets_dataptr[s] = static_cast<int8_t*>(t[p2s_out[s]].get_dataptr());\n+\n+ static_cast<Adaptor_n_to_1&>(m).pull_1(sockets_dataptr);\nreturn 0;\n});\n}\n-\n-template <class A>\n-void Adaptor_n_to_1\n-::push_n(const std::vector<int8_t,A>& in, const int frame_id)\n-{\n- if (this->n_bytes * (size_t)this->n_frames != in.size())\n- {\n- std::stringstream message;\n- message << \"'in.size()' has to be equal to 'n_bytes' * 'n_frames' ('in.size()' = \" << in.size()\n- << \", 'n_bytes' = \" << this->n_bytes << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->push_n(in.data(), frame_id);\n-}\n-\n-template <class A>\n-void Adaptor_n_to_1\n-::pull_1(std::vector<int8_t,A>& out, const int frame_id)\n-{\n- if (this->n_bytes * (size_t)this->n_frames != out.size())\n- {\n- std::stringstream message;\n- message << \"'out.size()' has to be equal to 'n_bytes' * 'n_frames' ('out.size()' = \" << out.size()\n- << \", 'n_bytes' = \" << this->n_bytes << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->pull_1(out.data(), frame_id);\n-}\n-\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor.cpp",
"new_path": "src/Module/Adaptor/Adaptor.cpp",
"diff": "@@ -24,15 +24,19 @@ void Adaptor\nif (id == -1)\n{\nthis->id = this->buffer->size();\n- this->buffer->push_back(\n- std::vector<std::vector<int8_t>>(this->buffer_size, std::vector<int8_t>(this->n_frames * this->n_bytes)));\n+ this->buffer->push_back(std::vector<std::vector<std::vector<int8_t>>>(this->n_sockets,\n+ std::vector<std::vector<int8_t>>(this->buffer_size)));\n}\nelse\n{\nthis->id = (size_t)id;\n- (*this->buffer)[this->id].resize(buffer_size, std::vector<int8_t>(this->n_frames * this->n_bytes));\n+ (*this->buffer)[this->id].resize(this->n_sockets, std::vector<std::vector<int8_t>>(this->buffer_size));\n}\n+ for (auto s = 0; s < this->n_sockets; s++)\n+ for (auto b = 0; b < this->buffer_size; b++)\n+ (*this->buffer)[this->id][s][b].resize(this->n_frames * this->n_bytes[s]);\n+\nif (this->id >= this->first->size())\n{\nstd::stringstream message;\n@@ -61,6 +65,23 @@ size_t Adaptor\n}\n}\n+std::vector<size_t> Adaptor\n+::compute_bytes(const std::vector<size_t> &n_elmts, const std::vector<std::type_index> &type)\n+{\n+ if (n_elmts.size() != type.size())\n+ {\n+ std::stringstream message;\n+ message << \"'n_elmts.size()' has to be equal to 'type.size()' ('n_elmts.size()' = \" << n_elmts.size()\n+ << \", 'type.size()' = \" << type.size() << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ std::vector<size_t> bytes(n_elmts.size());\n+ for (size_t i = 0; i < n_elmts.size(); i++)\n+ bytes[i] = Adaptor::compute_bytes(n_elmts[i], type[i]);\n+ return bytes;\n+}\n+\nvoid Adaptor::send_cancel_signal()\n{\n*this->waiting_canceled = true;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"new_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"diff": "@@ -15,7 +15,7 @@ Adaptor_1_to_n* Adaptor_1_to_n\n}\nvoid Adaptor_1_to_n\n-::push_1(const int8_t *in, const int frame_id)\n+::push_1(const std::vector<const int8_t*> &in, const int frame_id)\n{\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n@@ -39,11 +39,14 @@ void Adaptor_1_to_n\nif (*this->waiting_canceled)\nthrow tools::waiting_canceled(__FILE__, __LINE__, __func__);\n- int8_t* out = (*this->buffer)[this->cur_id][(*this->last)[this->cur_id] % this->buffer_size].data();\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ {\n+ int8_t* out = (*this->buffer)[this->cur_id][s][(*this->last)[this->cur_id] % this->buffer_size].data();\n- std::copy(in + f_start * this->n_bytes,\n- in + f_stop * this->n_bytes,\n- out + f_start * this->n_bytes);\n+ std::copy(in[s] + f_start * this->n_bytes[s],\n+ in[s] + f_stop * this->n_bytes[s],\n+ out + f_start * this->n_bytes[s]);\n+ }\n(*this->last)[this->cur_id]++;\n@@ -64,7 +67,7 @@ void Adaptor_1_to_n\n}\nvoid Adaptor_1_to_n\n-::pull_n(int8_t *out, const int frame_id)\n+::pull_n(const std::vector<int8_t*> &out, const int frame_id)\n{\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n@@ -88,11 +91,14 @@ void Adaptor_1_to_n\nif (*this->waiting_canceled)\nthrow tools::waiting_canceled(__FILE__, __LINE__, __func__);\n- const int8_t* in = (*this->buffer)[this->id][(*this->first)[this->id] % this->buffer_size].data();\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ {\n+ const int8_t* in = (*this->buffer)[this->id][s][(*this->first)[this->id] % this->buffer_size].data();\n- std::copy(in + f_start * this->n_bytes,\n- in + f_stop * this->n_bytes,\n- out + f_start * this->n_bytes);\n+ std::copy(in + f_start * this->n_bytes[s],\n+ in + f_stop * this->n_bytes[s],\n+ out[s] + f_start * this->n_bytes[s]);\n+ }\n(*this->first)[this->id]++;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"new_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"diff": "@@ -15,7 +15,7 @@ Adaptor_n_to_1* Adaptor_n_to_1\n}\nvoid Adaptor_n_to_1\n-::push_n(const int8_t *in, const int frame_id)\n+::push_n(const std::vector<const int8_t*> &in, const int frame_id)\n{\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n@@ -39,11 +39,14 @@ void Adaptor_n_to_1\nif (*this->waiting_canceled)\nthrow tools::waiting_canceled(__FILE__, __LINE__, __func__);\n- int8_t* out = (*this->buffer)[this->id][(*this->last)[this->id] % this->buffer_size].data();\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ {\n+ int8_t* out = (*this->buffer)[this->id][s][(*this->last)[this->id] % this->buffer_size].data();\n- std::copy(in + f_start * this->n_bytes,\n- in + f_stop * this->n_bytes,\n- out + f_start * this->n_bytes);\n+ std::copy(in[s] + f_start * this->n_bytes[s],\n+ in[s] + f_stop * this->n_bytes[s],\n+ out + f_start * this->n_bytes[s]);\n+ }\n(*this->last)[this->id]++;\n@@ -58,7 +61,7 @@ void Adaptor_n_to_1\n}\nvoid Adaptor_n_to_1\n-::pull_1(int8_t *out, const int frame_id)\n+::pull_1(const std::vector<int8_t*> &out, const int frame_id)\n{\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n@@ -82,11 +85,14 @@ void Adaptor_n_to_1\nif (*this->waiting_canceled)\nthrow tools::waiting_canceled(__FILE__, __LINE__, __func__);\n- const int8_t* in = (*this->buffer)[this->cur_id][(*this->first)[this->cur_id] % this->buffer_size].data();\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ {\n+ const int8_t* in = (*this->buffer)[this->cur_id][s][(*this->first)[this->cur_id] % this->buffer_size].data();\n- std::copy(in + f_start * this->n_bytes,\n- in + f_stop * this->n_bytes,\n- out + f_start * this->n_bytes);\n+ std::copy(in + f_start * this->n_bytes[s],\n+ in + f_stop * this->n_bytes[s],\n+ out[s] + f_start * this->n_bytes[s]);\n+ }\n(*this->first)[this->cur_id]++;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve the adaptors to manage more than a single socket (not tested).
|
8,490 |
26.01.2020 16:04:51
| -3,600 |
549d6775b47bfdd3fc39a6224dee8db01c12e6fc
|
Fix adaptors bugs (tested for 1 socket only).
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"diff": "@@ -51,7 +51,7 @@ public:\nvirtual ~Adaptor_1_to_n() = default;\nvirtual Adaptor_1_to_n* clone() const;\n- void init();\n+ inline void init();\nvoid wake_up();\nvoid cancel_waiting();\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"diff": "@@ -66,10 +66,9 @@ void Adaptor_1_to_n\nthis->set_name(name);\nthis->set_short_name(name);\n- std::function<size_t(Task&, const size_t, const std::type_index&)> create_socket_in =\n- [this](Task& p, const size_t n_elmts, const std::type_index& datatype)\n+ std::function<size_t(Task&, const size_t, const std::type_index&, const std::string&)> create_socket_in =\n+ [this](Task& p, const size_t n_elmts, const std::type_index& datatype, const std::string& n)\n{\n- std::string n = \"in\";\nif (datatype == typeid(int8_t )) return this->template create_socket_in<int8_t >(p, n, n_elmts);\nelse if (datatype == typeid(int16_t)) return this->template create_socket_in<int16_t>(p, n, n_elmts);\nelse if (datatype == typeid(int32_t)) return this->template create_socket_in<int32_t>(p, n, n_elmts);\n@@ -84,10 +83,9 @@ void Adaptor_1_to_n\n}\n};\n- std::function<size_t(Task&, const size_t, const std::type_index&)> create_socket_out =\n- [this](Task& p, const size_t n_elmts, const std::type_index& datatype)\n+ std::function<size_t(Task&, const size_t, const std::type_index&, const std::string&)> create_socket_out =\n+ [this](Task& p, const size_t n_elmts, const std::type_index& datatype, const std::string& n)\n{\n- std::string n = \"out\";\nif (datatype == typeid(int8_t )) return this->template create_socket_out<int8_t >(p, n, n_elmts);\nelse if (datatype == typeid(int16_t)) return this->template create_socket_out<int16_t>(p, n, n_elmts);\nelse if (datatype == typeid(int32_t)) return this->template create_socket_out<int32_t>(p, n, n_elmts);\n@@ -105,7 +103,7 @@ void Adaptor_1_to_n\nauto &p1 = this->create_task(\"push_1\", (int)adp::tsk::push_1);\nstd::vector<size_t> p1s_in;\nfor (size_t s = 0; s < this->n_sockets; s++)\n- p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s]));\n+ p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s], \"in\" + std::to_string(s)));\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n{\n@@ -120,7 +118,7 @@ void Adaptor_1_to_n\nauto &p2 = this->create_task(\"pull_n\", (int)adp::tsk::pull_n);\nstd::vector<size_t> p2s_out;\nfor (size_t s = 0; s < this->n_sockets; s++)\n- p2s_out.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s]));\n+ p2s_out.push_back(create_socket_out(p2, this->n_elmts[s], this->datatype[s], \"out\" + std::to_string(s)));\nthis->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"diff": "@@ -51,7 +51,7 @@ public:\nvirtual ~Adaptor_n_to_1() = default;\nvirtual Adaptor_n_to_1* clone() const;\n- void init();\n+ inline void init();\nvoid wake_up();\nvoid cancel_waiting();\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"diff": "@@ -66,10 +66,9 @@ void Adaptor_n_to_1\nthis->set_name(name);\nthis->set_short_name(name);\n- std::function<size_t(Task&, const size_t, const std::type_index&)> create_socket_in =\n- [this](Task& p, const size_t n_elmts, const std::type_index& datatype)\n+ std::function<size_t(Task&, const size_t, const std::type_index&, const std::string&)> create_socket_in =\n+ [this](Task& p, const size_t n_elmts, const std::type_index& datatype, const std::string& n)\n{\n- std::string n = \"in\";\nif (datatype == typeid(int8_t )) return this->template create_socket_in<int8_t >(p, n, n_elmts);\nelse if (datatype == typeid(int16_t)) return this->template create_socket_in<int16_t>(p, n, n_elmts);\nelse if (datatype == typeid(int32_t)) return this->template create_socket_in<int32_t>(p, n, n_elmts);\n@@ -84,10 +83,9 @@ void Adaptor_n_to_1\n}\n};\n- std::function<size_t(Task&, const size_t, const std::type_index&)> create_socket_out =\n- [this](Task& p, const size_t n_elmts, const std::type_index& datatype)\n+ std::function<size_t(Task&, const size_t, const std::type_index&, const std::string&)> create_socket_out =\n+ [this](Task& p, const size_t n_elmts, const std::type_index& datatype, const std::string& n)\n{\n- std::string n = \"out\";\nif (datatype == typeid(int8_t )) return this->template create_socket_out<int8_t >(p, n, n_elmts);\nelse if (datatype == typeid(int16_t)) return this->template create_socket_out<int16_t>(p, n, n_elmts);\nelse if (datatype == typeid(int32_t)) return this->template create_socket_out<int32_t>(p, n, n_elmts);\n@@ -105,7 +103,7 @@ void Adaptor_n_to_1\nauto &p1 = this->create_task(\"push_n\", (int)adp::tsk::push_n);\nstd::vector<size_t> p1s_in;\nfor (size_t s = 0; s < this->n_sockets; s++)\n- p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s]));\n+ p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s], \"in\" + std::to_string(s)));\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n{\n@@ -120,7 +118,7 @@ void Adaptor_n_to_1\nauto &p2 = this->create_task(\"pull_1\", (int)adp::tsk::pull_1);\nstd::vector<size_t> p2s_out;\nfor (size_t s = 0; s < this->n_sockets; s++)\n- p2s_out.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s]));\n+ p2s_out.push_back(create_socket_out(p2, this->n_elmts[s], this->datatype[s], \"out\" + std::to_string(s)));\nthis->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix adaptors bugs (tested for 1 socket only).
|
8,490 |
28.01.2020 10:00:00
| -3,600 |
a7d0998b1c537c378d91cfef956582b1fefa0a1b
|
Simplify the BCH encoder.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/BCH/Encoder_BCH.cpp",
"new_path": "src/Module/Encoder/BCH/Encoder_BCH.cpp",
"diff": "@@ -45,21 +45,9 @@ void Encoder_BCH<B>\nfor (auto i = this->K - 1; i >= 0; i--)\n{\nconst auto feedback = U_K[i] ^ par[n_rdncy - 1];\n- if (feedback != 0)\n- {\nfor (auto j = n_rdncy - 1; j > 0; j--)\n- if (g[j] != 0)\n- par[j] = par[j - 1] ^ feedback;\n- else\n- par[j] = par[j - 1];\n- par[0] = g[0] && feedback;\n- }\n- else\n- {\n- for (auto j = n_rdncy - 1; j > 0; j--)\n- par[j] = par[j - 1];\n- par[0] = 0;\n- }\n+ par[j] = g[j] ? par[j - 1] ^ feedback : par[j - 1];\n+ par[0] = feedback ? g[0] && feedback : 0;\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simplify the BCH encoder.
|
8,490 |
28.01.2020 17:16:35
| -3,600 |
ba5db0879a6cab5798b8c56355ce740a8f6205bd
|
Add an inter-SIMD version of the BCH encoder.
|
[
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/codec/bch/encoder.rst",
"new_path": "doc/source/user/simulation/parameters/codec/bch/encoder.rst",
"diff": "@@ -61,3 +61,29 @@ Description of the allowed values:\nparameter.\n.. |enc-type_descr_user| replace:: See the common :ref:`enc-common-enc-type`\nparameter.\n+\n+.. _enc-bch-enc-simd:\n+\n+``--enc-simd``\n+\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n+\n+ :Type: text\n+ :Allowed values: ``INTER``\n+ :Examples: ``--enc-simd INTER``\n+\n+|factory::Encoder_BCH::p+simd|\n+\n+Description of the allowed values:\n+\n++-----------+------------------------+\n+| Value | Description |\n++===========+========================+\n+| ``INTER`` | |dec-simd_descr_inter| |\n++-----------+------------------------+\n+\n+.. |dec-simd_descr_inter| replace:: Select the inter-frame strategy.\n+\n+.. note:: Be aware that running the simulator with the :ref:`src-src-fra`\n+ parameter set to 1 and the :ref:`dec-polar-dec-simd` parameter set to\n+ ``INTER`` will completely be counterproductive and will lead to no throughput\n+ improvements.\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/codec/ldpc/decoder.rst",
"new_path": "doc/source/user/simulation/parameters/codec/ldpc/decoder.rst",
"diff": "@@ -217,7 +217,7 @@ version 8.1.0). When compiling with the GNU compiler in C++11 mode, the\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n:Type: text\n- :Allowed values: ``INTER``\n+ :Allowed values: ``INTER``, ``INTRA``\n:Examples: ``--dec-simd INTER``\n|factory::Decoder_LDPC::p+simd|\n"
},
{
"change_type": "MODIFY",
"old_path": "doc/strings.rst",
"new_path": "doc/strings.rst",
"diff": ".. --------------------------------------------- factory Encoder_BCH parameters\n+.. |factory::Encoder_BCH::p+simd| replace::\n+ Select the |SIMD| strategy.\n+\n.. -------------------------------------------- factory Encoder_LDPC parameters\n.. |factory::Encoder_LDPC::p+h-path| replace::\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Factory/Module/Encoder/BCH/Encoder_BCH.hpp",
"new_path": "include/Factory/Module/Encoder/BCH/Encoder_BCH.hpp",
"diff": "@@ -24,7 +24,7 @@ class Encoder_BCH : public Encoder\n{\npublic:\n// ----------------------------------------------------------------------------------------------------- PARAMETERS\n- // empty\n+ std::string simd_strategy = \"\";\n// -------------------------------------------------------------------------------------------------------- METHODS\nexplicit Encoder_BCH(const std::string &p = Encoder_BCH_prefix);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Encoder/BCH/Encoder_BCH.hpp",
"new_path": "include/Module/Encoder/BCH/Encoder_BCH.hpp",
"diff": "@@ -33,6 +33,13 @@ public:\nbool is_codeword(const B *X_N);\nprotected:\n+ Encoder_BCH(const int& K,\n+ const int& N,\n+ const tools::BCH_polynomial_generator<B>& GF,\n+ const bool hack_ambiguous,\n+ const int n_frames = 1,\n+ const int simd_inter_frame_level = 1);\n+\nvirtual void _encode(const B *U_K, B *X_N, const int frame_id);\nvirtual void __encode(const B *U_K, B *bb);\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Module/Encoder/BCH/Encoder_BCH_inter.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class module::Encoder_BCH_inter.\n+ */\n+#ifndef ENCODER_BCH_INTER_HPP_\n+#define ENCODER_BCH_INTER_HPP_\n+\n+#include <vector>\n+\n+#include \"Tools/Code/BCH/BCH_polynomial_generator.hpp\"\n+#include \"Module/Encoder/BCH/Encoder_BCH.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int>\n+class Encoder_BCH_inter : public Encoder_BCH<B>\n+{\n+protected:\n+ std::vector<B> U_K_reordered;\n+ std::vector<B> par_reordered;\n+\n+ std::vector<mipp::Reg<B>> regs_par;\n+\n+public:\n+ Encoder_BCH_inter(const int& K, const int& N, const tools::BCH_polynomial_generator<B>& GF, const int n_frames = 1);\n+\n+ virtual ~Encoder_BCH_inter() = default;\n+\n+ virtual Encoder_BCH_inter<B>* clone() const;\n+\n+protected:\n+ virtual void _encode(const B *U_K, B *X_N, const int frame_id);\n+ virtual void __encode(const B *U_K, B *bb);\n+};\n+}\n+}\n+\n+#endif // ENCODER_BCH_INTER_HPP_\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Encoder/Encoder.hpp",
"new_path": "include/Module/Encoder/Encoder.hpp",
"diff": "@@ -46,12 +46,19 @@ public:\ninline Socket& operator[](const enc::sck::encode s);\nprotected:\n+ const int n_inter_frame_rest;\n+\nconst int K; /*!< Number of information bits in one frame */\nconst int N; /*!< Size of one frame (= number of bits in one frame) */\n+ const int simd_inter_frame_level; /*!< Number of frames absorbed by the SIMD instructions. */\n+ const int n_enc_waves;\n+\nbool sys; /*!< Is the generated codeword systematic ? */\nbool memorizing; /*!< If true, keep the last encoded frame(s) in memory */\nstd::vector<uint32_t> info_bits_pos; /*!< Positions of the information bits in the codeword */\n+ std::vector<B> U_K;\n+ std::vector<B> X_N;\nstd::vector<std::vector<B>> U_K_mem;\nstd::vector<std::vector<B>> X_N_mem;\n@@ -63,7 +70,7 @@ public:\n* \\param N: size of one frame.\n* \\param n_frames: number of frames to process in the Encoder.\n*/\n- Encoder(const int K, const int N, const int n_frames = 1);\n+ Encoder(const int K, const int N, const int n_frames = 1, const int simd_inter_frame_level = 1);\n/*!\n* \\brief Destructor.\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Encoder/Encoder.hxx",
"new_path": "include/Module/Encoder/Encoder.hxx",
"diff": "@@ -27,13 +27,18 @@ Socket& Encoder<B>\ntemplate <typename B>\nEncoder<B>\n-::Encoder(const int K, const int N, const int n_frames)\n+::Encoder(const int K, const int N, const int n_frames, const int simd_inter_frame_level)\n: Module(n_frames),\n+ n_inter_frame_rest(this->n_frames % simd_inter_frame_level),\nK(K),\nN(N),\n+ simd_inter_frame_level(simd_inter_frame_level),\n+ n_enc_waves((int)std::ceil((float)this->n_frames / (float)simd_inter_frame_level)),\nsys(true),\nmemorizing(false),\ninfo_bits_pos(this->K),\n+ U_K(this->n_inter_frame_rest ? this->simd_inter_frame_level * this->K : 0),\n+ X_N(this->n_inter_frame_rest ? this->simd_inter_frame_level * this->N : 0),\nU_K_mem(n_frames),\nX_N_mem(n_frames)\n{\n@@ -55,6 +60,14 @@ Encoder<B>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ if (simd_inter_frame_level <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'simd_inter_frame_level' has to be greater than 0 ('simd_inter_frame_level' = \"\n+ << simd_inter_frame_level << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nif (K > N)\n{\nstd::stringstream message;\n@@ -198,10 +211,56 @@ void Encoder<B>\nU_K + (f +1) * this->K,\nU_K_mem[f].begin());\n- for (auto f = f_start; f < f_stop; f++)\n- this->_encode(U_K + f * this->K,\n- X_N + f * this->N,\n- f);\n+ if (frame_id < 0 || this->simd_inter_frame_level == 1)\n+ {\n+ const auto w_start = (frame_id < 0) ? 0 : frame_id % this->n_enc_waves;\n+ const auto w_stop = (frame_id < 0) ? this->n_enc_waves : w_start +1;\n+\n+ auto w = 0;\n+ for (w = w_start; w < w_stop -1; w++)\n+ {\n+ this->_encode(U_K + w * this->K * this->simd_inter_frame_level,\n+ X_N + w * this->N * this->simd_inter_frame_level,\n+ w * this->simd_inter_frame_level);\n+ }\n+\n+ if (this->n_inter_frame_rest == 0)\n+ {\n+ this->_encode(U_K + w * this->K * this->simd_inter_frame_level,\n+ X_N + w * this->N * this->simd_inter_frame_level,\n+ w * this->simd_inter_frame_level);\n+ }\n+ else\n+ {\n+ const auto waves_off1 = w * this->simd_inter_frame_level * this->K;\n+ std::copy(U_K + waves_off1,\n+ U_K + waves_off1 + this->n_inter_frame_rest * this->K,\n+ this->U_K.begin());\n+\n+ this->_encode(this->U_K.data(), this->X_N.data(), w * this->simd_inter_frame_level);\n+\n+ const auto waves_off2 = w * this->simd_inter_frame_level * this->N;\n+ std::copy(this->X_N.begin(),\n+ this->X_N.begin() + this->n_inter_frame_rest * this->N,\n+ X_N + waves_off2);\n+ }\n+ }\n+ else\n+ {\n+ const auto w = (frame_id % this->n_frames) / this->simd_inter_frame_level;\n+ const auto w_pos = frame_id % this->simd_inter_frame_level;\n+\n+ // std::fill(this->U_K.begin(), this->U_K.end(), (B)0);\n+ std::copy(U_K + ((frame_id % this->n_frames) + 0) * this->K,\n+ U_K + ((frame_id % this->n_frames) + 1) * this->K,\n+ this->U_K.begin() + w_pos * this->K);\n+\n+ this->_encode(this->U_K.data(), this->X_N.data(), w * this->simd_inter_frame_level);\n+\n+ std::copy(this->X_N.begin() + (w_pos +0) * this->N,\n+ this->X_N.begin() + (w_pos +1) * this->N,\n+ X_N + (frame_id % this->n_frames) * this->N);\n+ }\nif (this->is_memorizing())\nfor (auto f = f_start; f < f_stop; f++)\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Modem/Generic/Modem_generic_fast.hxx",
"new_path": "include/Module/Modem/Generic/Modem_generic_fast.hxx",
"diff": "@@ -95,7 +95,7 @@ size_t kernel_demodulate_complex_SIMD(const Q *Y_N1,\n}\nconst mipp::Reg<Q> reg_Y_re = arr_Y_re;\nconst mipp::Reg<Q> reg_Y_im = arr_Y_im;\n- const mipp::Regx2<Q> reg_complex_Yk(reg_Y_re, reg_Y_im);;\n+ const mipp::Regx2<Q> reg_complex_Yk(reg_Y_re, reg_Y_im);\nmipp::Reg<I> regi_j = regi_zero;\nfor (auto j = 0; j < nbr_symbols; j++)\n"
},
{
"change_type": "MODIFY",
"old_path": "include/aff3ct.hpp",
"new_path": "include/aff3ct.hpp",
"diff": "#ifndef ENCODER_BCH_HPP_\n#include <Module/Encoder/BCH/Encoder_BCH.hpp>\n#endif\n+#ifndef ENCODER_BCH_INTER_HPP_\n+#include <Module/Encoder/BCH/Encoder_BCH_inter.hpp>\n+#endif\n#ifndef ENCODER_COSET_HPP_\n#include <Module/Encoder/Coset/Encoder_coset.hpp>\n#endif\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/BCH/Encoder_BCH.cpp",
"new_path": "src/Factory/Module/Encoder/BCH/Encoder_BCH.cpp",
"diff": "+#include \"Tools/Documentation/documentation.h\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Math/utils.h\"\n#include \"Module/Encoder/BCH/Encoder_BCH.hpp\"\n+#include \"Module/Encoder/BCH/Encoder_BCH_inter.hpp\"\n#include \"Factory/Module/Encoder/BCH/Encoder_BCH.hpp\"\nusing namespace aff3ct;\n@@ -28,27 +30,48 @@ void Encoder_BCH\nEncoder::get_description(args);\nauto p = this->get_prefix();\n+ const std::string class_name = \"factory::Encoder_BCH::\";\ncli::add_options(args.at({p+\"-type\"}), 0, \"BCH\");\n+\n+ tools::add_arg(args, p, class_name+\"p+simd\",\n+ cli::Text(cli::Including_set(\"INTER\")));\n}\nvoid Encoder_BCH\n::store(const cli::Argument_map_value &vals)\n{\nEncoder::store(vals);\n+\n+ auto p = this->get_prefix();\n+\n+ if(vals.exist({p+\"-simd\"})) this->simd_strategy = vals.at({p+\"-simd\"});\n}\nvoid Encoder_BCH\n::get_headers(std::map<std::string,tools::header_list>& headers, const bool full) const\n{\nEncoder::get_headers(headers, full);\n+\n+ auto p = this->get_prefix();\n+\n+ if (!this->simd_strategy.empty())\n+ headers[p].push_back(std::make_pair(\"SIMD strategy\", this->simd_strategy));\n}\ntemplate <typename B>\nmodule::Encoder_BCH<B>* Encoder_BCH\n::build(const tools::BCH_polynomial_generator<B> &GF) const\n{\n- if (this->type == \"BCH\") return new module::Encoder_BCH<B>(this->K, this->N_cw, GF, this->n_frames);\n+ if (this->type == \"BCH\")\n+ {\n+ if (this->simd_strategy == \"INTER\")\n+ return new module::Encoder_BCH_inter<B>(this->K, this->N_cw, GF, this->n_frames);\n+ else if (this->simd_strategy == \"INTRA\")\n+ throw tools::cannot_allocate(__FILE__, __LINE__, __func__);\n+ else\n+ return new module::Encoder_BCH<B>(this->K, this->N_cw, GF, this->n_frames);\n+ }\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/BCH/Encoder_BCH.cpp",
"new_path": "src/Module/Encoder/BCH/Encoder_BCH.cpp",
"diff": "@@ -10,8 +10,13 @@ using namespace aff3ct::module;\ntemplate <typename B>\nEncoder_BCH<B>\n-::Encoder_BCH(const int& K, const int& N, const tools::BCH_polynomial_generator<B>& GF_poly, const int n_frames)\n- : Encoder<B>(K, N, n_frames), n_rdncy(GF_poly.get_n_rdncy()), g(GF_poly.get_g()), bb(n_rdncy)\n+::Encoder_BCH(const int& K,\n+ const int& N,\n+ const tools::BCH_polynomial_generator<B>& GF_poly,\n+ const bool hack_ambigous,\n+ const int n_frames,\n+ const int simd_inter_frame_level)\n+ : Encoder<B>(K, N, n_frames, simd_inter_frame_level), n_rdncy(GF_poly.get_n_rdncy()), g(GF_poly.get_g()), bb(n_rdncy)\n{\nconst std::string name = \"Encoder_BCH\";\nthis->set_name(name);\n@@ -27,6 +32,13 @@ Encoder_BCH<B>\nstd::iota(this->info_bits_pos.begin(), this->info_bits_pos.end(), n_rdncy); // redundancy on the first 'n_rdncy' bits\n}\n+template <typename B>\n+Encoder_BCH<B>\n+::Encoder_BCH(const int& K, const int& N, const tools::BCH_polynomial_generator<B>& GF_poly, const int n_frames)\n+ : Encoder_BCH<B>(K, N, GF_poly, true, n_frames, 1)\n+{\n+}\n+\ntemplate <typename B>\nEncoder_BCH<B>* Encoder_BCH<B>\n::clone() const\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Encoder/BCH/Encoder_BCH_inter.cpp",
"diff": "+#include <numeric>\n+#include <sstream>\n+#include <algorithm>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Perf/Reorderer/Reorderer.hpp\"\n+#include \"Module/Encoder/BCH/Encoder_BCH_inter.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+template <typename B>\n+Encoder_BCH_inter<B>\n+::Encoder_BCH_inter(const int& K, const int& N, const tools::BCH_polynomial_generator<B>& GF_poly, const int n_frames)\n+: Encoder_BCH<B>(K, N, GF_poly, true, n_frames, mipp::N<B>()),\n+ U_K_reordered(this->K * mipp::N<B>()),\n+ par_reordered(this->n_rdncy * mipp::N<B>())\n+{\n+ const std::string name = \"Encoder_BCH_inter\";\n+ this->set_name(name);\n+}\n+\n+template <typename B>\n+Encoder_BCH_inter<B>* Encoder_BCH_inter<B>\n+::clone() const\n+{\n+ auto m = new Encoder_BCH_inter(*this);\n+ m->deep_copy(*this);\n+ return m;\n+}\n+\n+template <typename B>\n+void Encoder_BCH_inter<B>\n+::__encode(const B *U_K, B *par)\n+{\n+ mipp::Reg<B> reg_g_0 = this->g[0];\n+ mipp::Reg<B> reg_zero = (B)0;\n+\n+ std::vector<mipp::Reg<B>> regs_par(this->n_rdncy, mipp::Reg<B>((B)0));\n+\n+ for (auto i = this->K - 1; i >= 0; i--)\n+ {\n+ const auto reg_feedback = regs_par[this->n_rdncy -1] ^ &U_K[i * mipp::N<B>()];\n+ for (auto j = this->n_rdncy -1; j > 0; j--)\n+ regs_par[j] = this->g[j] ? regs_par[j -1] ^ reg_feedback : regs_par[j -1];\n+ regs_par[0] = mipp::blend(reg_g_0 & reg_feedback, reg_zero, reg_feedback == 1);\n+ }\n+\n+ for (size_t p = 0; p < regs_par.size(); p++)\n+ regs_par[p].store(&par[p * mipp::N<B>()]);\n+}\n+\n+template <typename B>\n+void Encoder_BCH_inter<B>\n+::_encode(const B *U_K, B *X_N, const int frame_id)\n+{\n+ constexpr int n_frames = mipp::N<B>();\n+ std::vector<const B*> frames_in(n_frames);\n+ for (auto f = 0; f < n_frames; f++)\n+ frames_in[f] = U_K + f*this->K;\n+\n+ tools::Reorderer_static<B,n_frames>::apply(frames_in, this->U_K_reordered.data(), this->K);\n+\n+ // generate the parity bits\n+ this->__encode(this->U_K_reordered.data(), par_reordered.data());\n+\n+ std::vector<B*> frames_out(n_frames);\n+ for (auto f = 0; f < n_frames; f++)\n+ frames_out[f] = X_N + f * this->N;\n+ tools::Reorderer_static<B,n_frames>::apply_rev(this->par_reordered.data(), frames_out, this->n_rdncy);\n+\n+ // copy the sys bits at the end of the codeword\n+ for (auto f = 0; f < n_frames; f++)\n+ std::copy(U_K + (f +0) * this->K,\n+ U_K + (f +1) * this->K,\n+ X_N + (f +0) * this->N + this->n_rdncy);\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef AFF3CT_MULTI_PREC\n+template class aff3ct::module::Encoder_BCH_inter<B_8>;\n+template class aff3ct::module::Encoder_BCH_inter<B_16>;\n+template class aff3ct::module::Encoder_BCH_inter<B_32>;\n+template class aff3ct::module::Encoder_BCH_inter<B_64>;\n+#else\n+template class aff3ct::module::Encoder_BCH_inter<B>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add an inter-SIMD version of the BCH encoder.
|
8,490 |
30.01.2020 16:28:41
| -3,600 |
1d2110e83bd74d3e3106ccd0ce29613397ecccd2
|
Improve BCH encoders.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/BCH/Encoder_BCH.cpp",
"new_path": "src/Module/Encoder/BCH/Encoder_BCH.cpp",
"diff": "@@ -58,7 +58,7 @@ void Encoder_BCH<B>\n{\nconst auto feedback = U_K[i] ^ par[n_rdncy - 1];\nfor (auto j = n_rdncy - 1; j > 0; j--)\n- par[j] = g[j] ? par[j - 1] ^ feedback : par[j - 1];\n+ par[j] = par[j - 1] ^ (g[j] & feedback);\npar[0] = feedback ? g[0] && feedback : 0;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/BCH/Encoder_BCH_inter.cpp",
"new_path": "src/Module/Encoder/BCH/Encoder_BCH_inter.cpp",
"diff": "@@ -36,18 +36,20 @@ void Encoder_BCH_inter<B>\nmipp::Reg<B> reg_g_0 = this->g[0];\nmipp::Reg<B> reg_zero = (B)0;\n- std::vector<mipp::Reg<B>> regs_par(this->n_rdncy, mipp::Reg<B>((B)0));\n-\nfor (auto i = this->K -1; i >= 0; i--)\n{\n- const auto reg_feedback = regs_par[this->n_rdncy -1] ^ &U_K[i * mipp::N<B>()];\n+ mipp::Reg<B> reg_par_n = &par[(this->n_rdncy -1) * mipp::N<B>()];\n+ const auto reg_feedback = reg_par_n ^ &U_K[i * mipp::N<B>()];\nfor (auto j = this->n_rdncy -1; j > 0; j--)\n- regs_par[j] = this->g[j] ? regs_par[j -1] ^ reg_feedback : regs_par[j -1];\n- regs_par[0] = mipp::blend(reg_g_0 & reg_feedback, reg_zero, reg_feedback == 1);\n+ {\n+ mipp::Reg<B> reg_par_j_1 = &par[(j -1) * mipp::N<B>()];\n+ auto reg_par_j = this->g[j] ? reg_par_j_1 ^ reg_feedback : reg_par_j_1;\n+ reg_par_j.store(&par[j * mipp::N<B>()]);\n}\n- for (size_t p = 0; p < regs_par.size(); p++)\n- regs_par[p].store(&par[p * mipp::N<B>()]);\n+ auto reg_par_0 = mipp::blend(reg_g_0 & reg_feedback, reg_zero, reg_feedback == 1);\n+ reg_par_0.store(&par[0 * mipp::N<B>()]);\n+ }\n}\ntemplate <typename B>\n@@ -61,6 +63,8 @@ void Encoder_BCH_inter<B>\ntools::Reorderer_static<B,n_frames>::apply(frames_in, this->U_K_reordered.data(), this->K);\n+ std::fill(par_reordered.begin(), par_reordered.end(), (B)0);\n+\n// generate the parity bits\nthis->__encode(this->U_K_reordered.data(), par_reordered.data());\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve BCH encoders.
|
8,490 |
30.01.2020 17:08:41
| -3,600 |
c978b10407bda7feaae6dd59b31f39ec16c41224
|
Mv zeros fill in the inter-SIMD BCH decoder.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/BCH/Encoder_BCH_inter.cpp",
"new_path": "src/Module/Encoder/BCH/Encoder_BCH_inter.cpp",
"diff": "@@ -33,6 +33,8 @@ template <typename B>\nvoid Encoder_BCH_inter<B>\n::__encode(const B *U_K, B *par)\n{\n+ std::fill(par, par + this->n_rdncy * mipp::N<B>(), (B)0);\n+\nmipp::Reg<B> reg_g_0 = this->g[0];\nmipp::Reg<B> reg_zero = (B)0;\n@@ -63,8 +65,6 @@ void Encoder_BCH_inter<B>\ntools::Reorderer_static<B,n_frames>::apply(frames_in, this->U_K_reordered.data(), this->K);\n- std::fill(par_reordered.begin(), par_reordered.end(), (B)0);\n-\n// generate the parity bits\nthis->__encode(this->U_K_reordered.data(), par_reordered.data());\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Mv zeros fill in the inter-SIMD BCH decoder.
|
8,490 |
30.01.2020 18:38:49
| -3,600 |
b09a7f97ade6b172281e1af92873ec30d103d9e8
|
Make the reordering process of the BCH encoder in the '__encode' method.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/BCH/Encoder_BCH_inter.cpp",
"new_path": "src/Module/Encoder/BCH/Encoder_BCH_inter.cpp",
"diff": "@@ -33,47 +33,48 @@ template <typename B>\nvoid Encoder_BCH_inter<B>\n::__encode(const B *U_K, B *par)\n{\n- std::fill(par, par + this->n_rdncy * mipp::N<B>(), (B)0);\n+ constexpr int n_frames = mipp::N<B>();\n+ std::vector<const B*> frames_in(n_frames);\n+ for (auto f = 0; f < n_frames; f++)\n+ frames_in[f] = U_K + f*this->K;\n+\n+ tools::Reorderer_static<B,n_frames>::apply(frames_in, this->U_K_reordered.data(), this->K);\n+\n+ std::fill(this->par_reordered.begin(), this->par_reordered.end(), (B)0);\nmipp::Reg<B> reg_g_0 = this->g[0];\nmipp::Reg<B> reg_zero = (B)0;\nfor (auto i = this->K -1; i >= 0; i--)\n{\n- mipp::Reg<B> reg_par_n = &par[(this->n_rdncy -1) * mipp::N<B>()];\n- const auto reg_feedback = reg_par_n ^ &U_K[i * mipp::N<B>()];\n+ mipp::Reg<B> reg_par_n = &this->par_reordered[(this->n_rdncy -1) * mipp::N<B>()];\n+ const auto reg_feedback = reg_par_n ^ &this->U_K_reordered[i * mipp::N<B>()];\nfor (auto j = this->n_rdncy -1; j > 0; j--)\n{\n- mipp::Reg<B> reg_par_j_1 = &par[(j -1) * mipp::N<B>()];\n+ mipp::Reg<B> reg_par_j_1 = &this->par_reordered[(j -1) * mipp::N<B>()];\nauto reg_par_j = this->g[j] ? reg_par_j_1 ^ reg_feedback : reg_par_j_1;\n- reg_par_j.store(&par[j * mipp::N<B>()]);\n+ reg_par_j.store(&this->par_reordered[j * mipp::N<B>()]);\n}\nauto reg_par_0 = mipp::blend(reg_g_0 & reg_feedback, reg_zero, reg_feedback == 1);\n- reg_par_0.store(&par[0 * mipp::N<B>()]);\n+ reg_par_0.store(&this->par_reordered[0 * mipp::N<B>()]);\n}\n+\n+ std::vector<B*> frames_out(n_frames);\n+ for (auto f = 0; f < n_frames; f++)\n+ frames_out[f] = par + f * this->N;\n+ tools::Reorderer_static<B,n_frames>::apply_rev(this->par_reordered.data(), frames_out, this->n_rdncy);\n}\ntemplate <typename B>\nvoid Encoder_BCH_inter<B>\n::_encode(const B *U_K, B *X_N, const int frame_id)\n{\n- constexpr int n_frames = mipp::N<B>();\n- std::vector<const B*> frames_in(n_frames);\n- for (auto f = 0; f < n_frames; f++)\n- frames_in[f] = U_K + f*this->K;\n-\n- tools::Reorderer_static<B,n_frames>::apply(frames_in, this->U_K_reordered.data(), this->K);\n-\n// generate the parity bits\n- this->__encode(this->U_K_reordered.data(), par_reordered.data());\n-\n- std::vector<B*> frames_out(n_frames);\n- for (auto f = 0; f < n_frames; f++)\n- frames_out[f] = X_N + f * this->N;\n- tools::Reorderer_static<B,n_frames>::apply_rev(this->par_reordered.data(), frames_out, this->n_rdncy);\n+ this->__encode(U_K, X_N);\n// copy the sys bits at the end of the codeword\n+ constexpr int n_frames = mipp::N<B>();\nfor (auto f = 0; f < n_frames; f++)\nstd::copy(U_K + (f +0) * this->K,\nU_K + (f +1) * this->K,\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Make the reordering process of the BCH encoder in the '__encode' method.
|
8,490 |
02.02.2020 12:42:27
| -3,600 |
dc6e5f1794177913996d338dcfad89c433a3f116
|
Add a first basic thread pinning strategy with the hwloc library.
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -20,6 +20,7 @@ option(AFF3CT_COMPILE_STATIC_LIB \"Compile the static library\"\noption(AFF3CT_COMPILE_SHARED_LIB \"Compile the shared library\" OFF)\noption(AFF3CT_LINK_GSL \"Link with the GSL library (used in the channels)\" OFF)\noption(AFF3CT_LINK_MKL \"Link with the MKL library (used in the channels)\" OFF)\n+option(AFF3CT_LINK_HWLOC \"Link with the hwloc library (used for threads pinning)\" OFF)\noption(AFF3CT_SYSTEMC_SIMU \"Enable the SystemC simulation (incompatible with the library compilation)\" OFF)\noption(AFF3CT_SYSTEMC_MODULE \"Enable the SystemC support (only for the modules)\" OFF)\noption(AFF3CT_MPI \"Enable the MPI support\" OFF)\n@@ -469,6 +470,18 @@ if(AFF3CT_LINK_MKL)\nendif(MKL_FOUND)\nendif(AFF3CT_LINK_MKL)\n+# hwloc\n+if(AFF3CT_LINK_HWLOC)\n+ aff3ct_target_compile_definitions(PUBLIC \"AFF3CT_HWLOC\")\n+\n+ find_package(Hwloc REQUIRED QUIET)\n+ if(Hwloc_FOUND)\n+ message(STATUS \"AFF3CT - Library found: hwloc\")\n+ aff3ct_target_include_directories2(PUBLIC \"${Hwloc_INCLUDE_DIRS}\")\n+ aff3ct_target_link_libraries(PUBLIC \"${Hwloc_LIBRARIES}\")\n+ endif(Hwloc_FOUND)\n+endif(AFF3CT_LINK_HWLOC)\n+\n# MPI\nif(AFF3CT_MPI)\naff3ct_target_compile_definitions(PUBLIC \"AFF3CT_MPI\")\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -61,6 +61,7 @@ protected:\nsize_t n_tasks;\nbool tasks_inplace;\n+ bool thread_pinning;\npublic:\nChain(const module::Task &first, const size_t n_threads = 1 );\n@@ -75,6 +76,9 @@ public:\ninline void _init(Generic_node<SS> *root);\nvirtual Chain* clone() const;\n+ void set_thread_pinning(const bool thread_pinning);\n+ bool is_thread_pinning();\n+\nvoid exec(std::function<bool(const std::vector<int>&)> stop_condition);\nvoid exec(std::function<bool( )> stop_condition);\nint exec(const size_t tid = 0 );\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Tools/Thread_pinning/Thread_pinning.hpp",
"diff": "+#ifndef THREAD_PINNING_HPP\n+#define THREAD_PINNING_HPP\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+class Thread_pinning\n+{\n+public:\n+ static void init();\n+ static void destroy();\n+ static void pin();\n+ static void unpin();\n+\n+ static void set_logs(const bool enable_logs);\n+ static bool is_logs();\n+\n+ static void example1();\n+ static void example2();\n+ static void example3();\n+ static void example4();\n+ static void example5();\n+ static void example6();\n+};\n+}\n+}\n+\n+#endif /* THREAD_PINNING_HPP */\n"
},
{
"change_type": "MODIFY",
"old_path": "include/aff3ct.hpp",
"new_path": "include/aff3ct.hpp",
"diff": "#ifndef SC_ROUTER_HPP_\n#include <Tools/SystemC/SC_Router.hpp>\n#endif\n+#ifndef THREAD_PINNING_HPP\n+#include <Tools/Thread_pinning/Thread_pinning.hpp>\n+#endif\n#ifndef TYPES_H_\n#include <Tools/types.h>\n#endif\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "#include <exception>\n#include <algorithm>\n+#include \"Tools/Thread_pinning/Thread_pinning.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Module.hpp\"\n#include \"Module/Task.hpp\"\n@@ -28,7 +29,8 @@ Chain\nall_modules(n_threads),\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false)),\n- tasks_inplace(false)\n+ tasks_inplace(false),\n+ thread_pinning(false)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first, &last);\n}\n@@ -43,7 +45,8 @@ Chain\nall_modules(n_threads),\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false)),\n- tasks_inplace(false)\n+ tasks_inplace(false),\n+ thread_pinning(false)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first);\n}\n@@ -58,7 +61,8 @@ Chain\nall_modules(n_threads),\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false)),\n- tasks_inplace(tasks_inplace)\n+ tasks_inplace(tasks_inplace),\n+ thread_pinning(false)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first, &last);\n@@ -76,7 +80,8 @@ Chain\nall_modules(n_threads),\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false)),\n- tasks_inplace(tasks_inplace)\n+ tasks_inplace(tasks_inplace),\n+ thread_pinning(false)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first);\n@@ -147,6 +152,18 @@ Chain* Chain\nreturn c;\n}\n+void Chain\n+::set_thread_pinning(const bool thread_pinning)\n+{\n+ this->thread_pinning = thread_pinning;\n+}\n+\n+bool Chain\n+::is_thread_pinning()\n+{\n+ return this->thread_pinning;\n+}\n+\nstd::vector<std::vector<module::Module*>> Chain\n::get_modules_per_threads() const\n{\n@@ -223,6 +240,11 @@ std::vector<std::vector<module::Task*>> Chain\nvoid Chain\n::_exec(std::function<bool(const std::vector<int>&)> &stop_condition, Generic_node<Sub_sequence>* sequence)\n{\n+ if (this->is_thread_pinning())\n+ {\n+ aff3ct::tools::Thread_pinning::pin();\n+ }\n+\nstd::function<void(Generic_node<Sub_sequence>*, std::vector<int>&)> exec_sequence =\n[&exec_sequence](Generic_node<Sub_sequence>* cur_ss, std::vector<int>& statuses)\n{\n@@ -288,11 +310,19 @@ void Chain\nthis->mtx_exception->unlock();\n}\n+\n+ if (this->is_thread_pinning())\n+ {\n+ aff3ct::tools::Thread_pinning::unpin();\n+ }\n}\nvoid Chain\n::_exec_without_statuses(std::function<bool()> &stop_condition, Generic_node<Sub_sequence>* sequence)\n{\n+ if (this->is_thread_pinning())\n+ aff3ct::tools::Thread_pinning::pin();\n+\nstd::function<void(Generic_node<Sub_sequence>*)> exec_sequence =\n[&exec_sequence](Generic_node<Sub_sequence>* cur_ss)\n{\n@@ -355,6 +385,9 @@ void Chain\nthis->mtx_exception->unlock();\n}\n+\n+ if (this->is_thread_pinning())\n+ aff3ct::tools::Thread_pinning::unpin();\n}\nvoid Chain\n@@ -364,8 +397,14 @@ void Chain\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid] = std::thread(&Chain::_exec, this, std::ref(stop_condition), std::ref(this->sequences[tid]));\n+ if (this->is_thread_pinning())\n+ aff3ct::tools::Thread_pinning::pin();\n+\nthis->_exec(stop_condition, this->sequences[0]);\n+ if (this->is_thread_pinning())\n+ aff3ct::tools::Thread_pinning::unpin();\n+\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n@@ -384,8 +423,14 @@ void Chain\nthreads[tid] = std::thread(&Chain::_exec_without_statuses, this, std::ref(stop_condition),\nstd::ref(this->sequences[tid]));\n+ if (this->is_thread_pinning())\n+ aff3ct::tools::Thread_pinning::pin();\n+\nthis->_exec_without_statuses(stop_condition, this->sequences[0]);\n+ if (this->is_thread_pinning())\n+ aff3ct::tools::Thread_pinning::unpin();\n+\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Thread_pinning/Thread_pinning.cpp",
"diff": "+#include <functional>\n+#include <iostream>\n+#include <sstream>\n+#include <errno.h>\n+#include <stdio.h>\n+#include <string.h>\n+#include <vector>\n+#include <mutex>\n+#ifdef AFF3CT_HWLOC\n+#include <hwloc.h>\n+#endif\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Thread_pinning/Thread_pinning.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::tools;\n+\n+#ifdef AFF3CT_HWLOC\n+static hwloc_topology_t g_topology;\n+static int g_topodepth = 0;\n+static std::vector<hwloc_uint64_t> g_pinned_threads;\n+static hwloc_obj_t g_cur_core_obj;\n+#endif\n+static bool g_is_init = false;\n+static std::mutex g_mtx;\n+static bool g_enable_logs = false;\n+\n+void Thread_pinning\n+::init()\n+{\n+ if (!g_is_init)\n+ {\n+ g_mtx.lock();\n+ if (!g_is_init)\n+ {\n+ g_is_init = true;\n+\n+#ifdef AFF3CT_HWLOC\n+ /* Allocate and initialize topology object. */\n+ hwloc_topology_init(&g_topology);\n+\n+ /* ... Optionally, put detection configuration here to ignore\n+ some objects types, define a synthetic topology, etc....\n+ The default is to detect all the objects of the machine that\n+ the caller is allowed to access. See Configure Topology\n+ Detection. */\n+\n+ /* Perform the topology detection. */\n+ hwloc_topology_load(g_topology);\n+\n+ /* Optionally, get some additional topology information\n+ in case we need the topology depth later. */\n+ g_topodepth = hwloc_topology_get_depth(g_topology);\n+\n+ int core_depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n+ /* Get last core. */\n+ int depth_core = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n+ int core_id = hwloc_get_nbobjs_by_depth(g_topology, depth_core) -1;\n+ g_cur_core_obj = hwloc_get_obj_by_depth(g_topology, core_depth, core_id);\n+#endif\n+ }\n+ g_mtx.unlock();\n+ }\n+}\n+\n+void Thread_pinning\n+::destroy()\n+{\n+ if (g_is_init)\n+ {\n+ g_mtx.lock();\n+ if (g_is_init)\n+ {\n+#ifdef AFF3CT_HWLOC\n+ /* Destroy topology object. */\n+ hwloc_topology_destroy(g_topology);\n+ g_topodepth = 0;\n+#endif\n+ g_is_init = false;\n+ }\n+ g_mtx.unlock();\n+ }\n+\n+}\n+\n+void Thread_pinning\n+::set_logs(const bool enable_logs)\n+{\n+ g_mtx.lock();\n+ g_enable_logs = enable_logs;\n+ g_mtx.unlock();\n+}\n+\n+bool Thread_pinning\n+::is_logs()\n+{\n+ return g_enable_logs;\n+}\n+\n+void Thread_pinning\n+::pin()\n+{\n+ g_mtx.lock();\n+#ifdef AFF3CT_HWLOC\n+ if (g_is_init)\n+ {\n+ if (g_cur_core_obj)\n+ {\n+ /* Get the first PU of the core */\n+ if (g_cur_core_obj->arity == 0)\n+ {\n+ std::stringstream message;\n+ message << \"Unsupported architecture, a core should have at least one PU.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ hwloc_obj_t cur_core_pu0_obj = g_cur_core_obj->children[0];\n+\n+ if (g_enable_logs)\n+ std::cerr << \"Thread pinning info -- \"\n+ << \"CORE logical index (hwloc): \" << g_cur_core_obj->logical_index << \" -- \"\n+ << \"PU logical index (hwloc): \" << cur_core_pu0_obj->logical_index << \" -- \"\n+ << \"P OS index: \" << cur_core_pu0_obj->os_index << std::endl;\n+\n+ /* Get a copy of its cpuset that we may modify. */\n+ hwloc_cpuset_t cpuset = hwloc_bitmap_dup(cur_core_pu0_obj->cpuset);\n+ /* Get only one logical processor (in case the core is\n+ SMT/hyper-threaded). */\n+ hwloc_bitmap_singlify(cpuset);\n+ /* And try to bind ourself there. */\n+ if (hwloc_set_cpubind(g_topology, cpuset, HWLOC_CPUBIND_THREAD))\n+ {\n+ char *str;\n+ int error = errno;\n+ hwloc_bitmap_asprintf(&str, cur_core_pu0_obj->cpuset);\n+ printf(\"Couldn't bind to cpuset %s: %s\\n\", str, strerror(error));\n+ free(str);\n+ }\n+ /* Free our cpuset copy */\n+ hwloc_bitmap_free(cpuset);\n+ }\n+\n+ /* Get next core. */\n+ g_cur_core_obj = g_cur_core_obj->prev_cousin;\n+\n+ if (g_cur_core_obj == nullptr)\n+ {\n+ std::stringstream message;\n+ message << \"There is no more available cores.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ else\n+ {\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"You can't call the 'pin' method if you have not call the 'init' method before, nothing will \"\n+ << \"be done.\" << std::endl;\n+ }\n+ }\n+#else\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"'pin' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n+ }\n+#endif\n+ g_mtx.unlock();\n+}\n+\n+void Thread_pinning\n+::unpin()\n+{\n+ g_mtx.lock();\n+#ifdef AFF3CT_HWLOC\n+ if (!g_is_init)\n+ {\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"You can't call the 'unpin' method if you have not call the 'init' method before, nothing \"\n+ << \"will be done.\" << std::endl;\n+ }\n+ }\n+#else\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"'unpin' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n+ }\n+#endif\n+ g_mtx.unlock();\n+}\n+\n+void Thread_pinning\n+::example1()\n+{\n+#ifdef AFF3CT_HWLOC\n+ if (g_is_init)\n+ {\n+ /*****************************************************************\n+ * First example:\n+ * Walk the topology with an array style, from level 0 (always\n+ * the system level) to the lowest level (always the proc level).\n+ *****************************************************************/\n+\n+ char string[128];\n+ for (int depth = 0; depth < g_topodepth; depth++)\n+ {\n+ printf(\"*** Objects at level %d\\n\", depth);\n+ for (unsigned i = 0; i < hwloc_get_nbobjs_by_depth(g_topology, depth); i++)\n+ {\n+ hwloc_obj_type_snprintf(string, sizeof(string),\n+ hwloc_get_obj_by_depth(g_topology, depth, i), 0);\n+ printf(\"Index %u: %s\\n\", i, string);\n+ }\n+ }\n+ }\n+ else\n+ {\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"You can't call the 'example1' method if you have not call the 'init' method before, \"\n+ << \"nothing will be done.\" << std::endl;\n+ }\n+ }\n+#else\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"'example1' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n+ }\n+#endif\n+}\n+\n+void Thread_pinning\n+::example2()\n+{\n+#ifdef AFF3CT_HWLOC\n+ if (g_is_init)\n+ {\n+ /*****************************************************************\n+ * Second example:\n+ * Walk the topology with a tree style.\n+ *****************************************************************/\n+\n+ std::function<void(hwloc_topology_t, hwloc_obj_t, int)> print_children =\n+ [&print_children](hwloc_topology_t topology, hwloc_obj_t obj, int depth)\n+ {\n+ char type[32], attr[1024];\n+ unsigned i;\n+ hwloc_obj_type_snprintf(type, sizeof(type), obj, 0);\n+ printf(\"%*s%s\", 2*depth, \"\", type);\n+ if (obj->os_index != (unsigned) -1)\n+ printf(\"#%u\", obj->os_index);\n+ hwloc_obj_attr_snprintf(attr, sizeof(attr), obj, \" \", 0);\n+ if (*attr)\n+ printf(\"(%s)\", attr);\n+\n+ printf(\"\\n\");\n+ for (i = 0; i < obj->arity; i++) {\n+ print_children(topology, obj->children[i], depth + 1);\n+ }\n+ };\n+\n+ printf(\"*** Printing overall tree\\n\");\n+ print_children(g_topology, hwloc_get_root_obj(g_topology), 0);\n+ }\n+ else\n+ {\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"You can't call the 'example2' method if you have not call the 'init' method before, \"\n+ << \"nothing will be done.\" << std::endl;\n+ }\n+ }\n+#else\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"'example2' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n+ }\n+#endif\n+}\n+\n+void Thread_pinning\n+::example3()\n+{\n+#ifdef AFF3CT_HWLOC\n+ if (g_is_init)\n+ {\n+ /*****************************************************************\n+ * Third example:\n+ * Print the number of packages.\n+ *****************************************************************/\n+\n+ int depth = hwloc_get_type_depth(g_topology, HWLOC_OBJ_PACKAGE);\n+ if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)\n+ {\n+ printf(\"*** The number of packages is unknown\\n\");\n+ }\n+ else\n+ {\n+ printf(\"*** %u package(s)\\n\",\n+ hwloc_get_nbobjs_by_depth(g_topology, depth));\n+ }\n+ }\n+ else\n+ {\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"You can't call the 'example3' method if you have not call the 'init' method before, \"\n+ << \"nothing will be done.\" << std::endl;\n+ }\n+ }\n+#else\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"'example3' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n+ }\n+#endif\n+}\n+\n+void Thread_pinning\n+::example4()\n+{\n+#ifdef AFF3CT_HWLOC\n+ if (g_is_init)\n+ {\n+ /*****************************************************************\n+ * Fourth example:\n+ * Compute the amount of cache that the first logical processor\n+ * has above it.\n+ *****************************************************************/\n+\n+ // This block has been commented to compile with hwloc v2 (HWLOC_OBJ_CACHE does not exist with this version)\n+ // int levels = 0;\n+ // unsigned long size = 0;\n+ // for (hwloc_obj_t obj = hwloc_get_obj_by_type(g_topology, HWLOC_OBJ_PU, 0); obj; obj = obj->parent)\n+ // {\n+ // if (obj->type == HWLOC_OBJ_CACHE)\n+ // {\n+ // levels++;\n+ // size += obj->attr->cache.size;\n+ // }\n+ // }\n+ // printf(\"*** Logical processor 0 has %d caches totaling %luKB\\n\", levels, size / 1024);\n+ }\n+ else\n+ {\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"You can't call the 'example4' method if you have not call the 'init' method before, \"\n+ << \"nothing will be done.\" << std::endl;\n+ }\n+ }\n+#else\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"'example4' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n+ }\n+#endif\n+}\n+\n+void Thread_pinning\n+::example5()\n+{\n+#ifdef AFF3CT_HWLOC\n+ if (g_is_init)\n+ {\n+ /*****************************************************************\n+ * Fifth example:\n+ * Bind to only one thread of the last core of the machine.\n+ *\n+ * First find out where cores are, or else smaller sets of CPUs if\n+ * the OS doesn't have the notion of a \"core\".\n+ *****************************************************************/\n+\n+ int depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n+ /* Get last core. */\n+ hwloc_obj_t obj = hwloc_get_obj_by_depth(g_topology, depth,\n+ hwloc_get_nbobjs_by_depth(g_topology, depth) - 1);\n+ if (obj)\n+ {\n+ /* Get a copy of its cpuset that we may modify. */\n+ hwloc_cpuset_t cpuset = hwloc_bitmap_dup(obj->cpuset);\n+ /* Get only one logical processor (in case the core is\n+ SMT/hyper-threaded). */\n+ hwloc_bitmap_singlify(cpuset);\n+ /* And try to bind ourself there. */\n+ if (hwloc_set_cpubind(g_topology, cpuset, 0))\n+ {\n+ char *str;\n+ int error = errno;\n+ hwloc_bitmap_asprintf(&str, obj->cpuset);\n+ printf(\"Couldn't bind to cpuset %s: %s\\n\", str, strerror(error));\n+ free(str);\n+ }\n+ /* Free our cpuset copy */\n+ hwloc_bitmap_free(cpuset);\n+ }\n+ }\n+ else\n+ {\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"You can't call the 'example5' method if you have not call the 'init' method before, \"\n+ << \"nothing will be done.\" << std::endl;\n+ }\n+ }\n+#else\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"'example5' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n+ }\n+#endif\n+}\n+\n+void Thread_pinning\n+::example6()\n+{\n+#ifdef AFF3CT_HWLOC\n+ if (g_is_init)\n+ {\n+ /*****************************************************************\n+ * Sixth example:\n+ * Allocate some memory on the last NUMA node, bind some existing\n+ * memory to the last NUMA node.\n+ *****************************************************************/\n+\n+ /* Get last node. */\n+ int n = hwloc_get_nbobjs_by_type(g_topology, HWLOC_OBJ_NUMANODE);\n+ if (n)\n+ {\n+ void *m;\n+ int size = 1024*1024;\n+ hwloc_obj_t obj = hwloc_get_obj_by_type(g_topology, HWLOC_OBJ_NUMANODE, n - 1);\n+ m = hwloc_alloc_membind_nodeset(g_topology, size, obj->nodeset, HWLOC_MEMBIND_BIND, 0);\n+ hwloc_free(g_topology, m, size);\n+ m = malloc(size);\n+ hwloc_set_area_membind_nodeset(g_topology, m, size, obj->nodeset, HWLOC_MEMBIND_BIND, 0);\n+ free(m);\n+ }\n+ }\n+ else\n+ {\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"You can't call the 'example6' method if you have not call the 'init' method before, \"\n+ << \"nothing will be done.\" << std::endl;\n+ }\n+ }\n+#else\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"'example6' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n+ }\n+#endif\n+}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a first basic thread pinning strategy with the hwloc library.
|
8,490 |
02.02.2020 14:55:06
| -3,600 |
5515b1177b7d981adf41234ad42940af1deb6b21
|
Fix duplicate threads binding.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -241,9 +241,7 @@ void Chain\n::_exec(std::function<bool(const std::vector<int>&)> &stop_condition, Generic_node<Sub_sequence>* sequence)\n{\nif (this->is_thread_pinning())\n- {\naff3ct::tools::Thread_pinning::pin();\n- }\nstd::function<void(Generic_node<Sub_sequence>*, std::vector<int>&)> exec_sequence =\n[&exec_sequence](Generic_node<Sub_sequence>* cur_ss, std::vector<int>& statuses)\n@@ -312,10 +310,8 @@ void Chain\n}\nif (this->is_thread_pinning())\n- {\naff3ct::tools::Thread_pinning::unpin();\n}\n-}\nvoid Chain\n::_exec_without_statuses(std::function<bool()> &stop_condition, Generic_node<Sub_sequence>* sequence)\n@@ -397,14 +393,8 @@ void Chain\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid] = std::thread(&Chain::_exec, this, std::ref(stop_condition), std::ref(this->sequences[tid]));\n- if (this->is_thread_pinning())\n- aff3ct::tools::Thread_pinning::pin();\n-\nthis->_exec(stop_condition, this->sequences[0]);\n- if (this->is_thread_pinning())\n- aff3ct::tools::Thread_pinning::unpin();\n-\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n@@ -423,14 +413,8 @@ void Chain\nthreads[tid] = std::thread(&Chain::_exec_without_statuses, this, std::ref(stop_condition),\nstd::ref(this->sequences[tid]));\n- if (this->is_thread_pinning())\n- aff3ct::tools::Thread_pinning::pin();\n-\nthis->_exec_without_statuses(stop_condition, this->sequences[0]);\n- if (this->is_thread_pinning())\n- aff3ct::tools::Thread_pinning::unpin();\n-\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix duplicate threads binding.
|
8,490 |
03.02.2020 16:47:59
| 0 |
5927e2f1f43f5ea34d210ab45c7f5059dd2179e1
|
Add the possibility to manually choose the PUs in thread pinning.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -62,6 +62,7 @@ protected:\nsize_t n_tasks;\nbool tasks_inplace;\nbool thread_pinning;\n+ std::vector<size_t> puids;\npublic:\nChain(const module::Task &first, const size_t n_threads = 1 );\n@@ -77,6 +78,7 @@ public:\nvirtual Chain* clone() const;\nvoid set_thread_pinning(const bool thread_pinning);\n+ void set_thread_pinning(const bool thread_pinning, const std::vector<size_t> &puids = {});\nbool is_thread_pinning();\nvoid exec(std::function<bool(const std::vector<int>&)> stop_condition);\n@@ -128,8 +130,13 @@ protected:\ntemplate <class SS, class MO>\nvoid duplicate(const Generic_node<SS> *sequence);\n- void _exec(std::function<bool(const std::vector<int>&)> &stop_condition, Generic_node<Sub_sequence>* sequence);\n- void _exec_without_statuses(std::function<bool()> &stop_condition, Generic_node<Sub_sequence>* sequence);\n+ void _exec(const size_t tid,\n+ std::function<bool(const std::vector<int>&)> &stop_condition,\n+ Generic_node<Sub_sequence>* sequence);\n+\n+ void _exec_without_statuses(const size_t tid,\n+ std::function<bool()> &stop_condition,\n+ Generic_node<Sub_sequence>* sequence);\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Thread_pinning/Thread_pinning.hpp",
"new_path": "include/Tools/Thread_pinning/Thread_pinning.hpp",
"diff": "#ifndef THREAD_PINNING_HPP\n#define THREAD_PINNING_HPP\n+#include <string>\n+\nnamespace aff3ct\n{\nnamespace tools\n@@ -11,8 +13,11 @@ public:\nstatic void init();\nstatic void destroy();\nstatic void pin();\n+ static void pin(const size_t puid);\nstatic void unpin();\n+ static std::string get_cur_cpuset_str();\n+\nstatic void set_logs(const bool enable_logs);\nstatic bool is_logs();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -153,9 +153,10 @@ Chain* Chain\n}\nvoid Chain\n-::set_thread_pinning(const bool thread_pinning)\n+::set_thread_pinning(const bool thread_pinning, const std::vector<size_t> &puids)\n{\nthis->thread_pinning = thread_pinning;\n+ this->puids = puids;\n}\nbool Chain\n@@ -238,10 +239,17 @@ std::vector<std::vector<module::Task*>> Chain\n}\nvoid Chain\n-::_exec(std::function<bool(const std::vector<int>&)> &stop_condition, Generic_node<Sub_sequence>* sequence)\n+::_exec(const size_t tid,\n+ std::function<bool(const std::vector<int>&)> &stop_condition,\n+ Generic_node<Sub_sequence>* sequence)\n{\nif (this->is_thread_pinning())\n+ {\n+ if (tid < this->puids.size())\n+ aff3ct::tools::Thread_pinning::pin(this->puids[tid]);\n+ else\naff3ct::tools::Thread_pinning::pin();\n+ }\nstd::function<void(Generic_node<Sub_sequence>*, std::vector<int>&)> exec_sequence =\n[&exec_sequence](Generic_node<Sub_sequence>* cur_ss, std::vector<int>& statuses)\n@@ -314,10 +322,17 @@ void Chain\n}\nvoid Chain\n-::_exec_without_statuses(std::function<bool()> &stop_condition, Generic_node<Sub_sequence>* sequence)\n+::_exec_without_statuses(const size_t tid,\n+ std::function<bool()> &stop_condition,\n+ Generic_node<Sub_sequence>* sequence)\n{\nif (this->is_thread_pinning())\n+ {\n+ if (tid < this->puids.size())\n+ aff3ct::tools::Thread_pinning::pin(this->puids[tid]);\n+ else\naff3ct::tools::Thread_pinning::pin();\n+ }\nstd::function<void(Generic_node<Sub_sequence>*)> exec_sequence =\n[&exec_sequence](Generic_node<Sub_sequence>* cur_ss)\n@@ -391,9 +406,9 @@ void Chain\n{\nstd::vector<std::thread> threads(n_threads);\nfor (size_t tid = 1; tid < n_threads; tid++)\n- threads[tid] = std::thread(&Chain::_exec, this, std::ref(stop_condition), std::ref(this->sequences[tid]));\n+ threads[tid] = std::thread(&Chain::_exec, this, tid, std::ref(stop_condition), std::ref(this->sequences[tid]));\n- this->_exec(stop_condition, this->sequences[0]);\n+ this->_exec(0, stop_condition, this->sequences[0]);\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n@@ -410,10 +425,12 @@ void Chain\n{\nstd::vector<std::thread> threads(n_threads);\nfor (size_t tid = 1; tid < n_threads; tid++)\n- threads[tid] = std::thread(&Chain::_exec_without_statuses, this, std::ref(stop_condition),\n+ {\n+ threads[tid] = std::thread(&Chain::_exec_without_statuses, this, tid, std::ref(stop_condition),\nstd::ref(this->sequences[tid]));\n+ }\n- this->_exec_without_statuses(stop_condition, this->sequences[0]);\n+ this->_exec_without_statuses(0, stop_condition, this->sequences[0]);\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Thread_pinning/Thread_pinning.cpp",
"new_path": "src/Tools/Thread_pinning/Thread_pinning.cpp",
"diff": "@@ -21,6 +21,9 @@ static hwloc_topology_t g_topology;\nstatic int g_topodepth = 0;\nstatic std::vector<hwloc_uint64_t> g_pinned_threads;\nstatic hwloc_obj_t g_cur_core_obj;\n+// static std::vector<int> g_thread_binding = {47, 46, 45, 44, 43, 23, 22, 21, 20, 19, 35, 18, 34, 17, 33, 16, 32, 15, 31, 14};\n+// // static std::vector<int> g_thread_binding = {47, 46, 45, 44, 43, 42, 23, 22, 21, 20, 19, 35, 18, 34, 17, 33, 16, 32, 15, 31, 14};\n+// static size_t g_thread_binding_id = 0;\n#endif\nstatic bool g_is_init = false;\nstatic std::mutex g_mtx;\n@@ -53,10 +56,9 @@ void Thread_pinning\nin case we need the topology depth later. */\ng_topodepth = hwloc_topology_get_depth(g_topology);\n- int core_depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n/* Get last core. */\n- int depth_core = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n- int core_id = hwloc_get_nbobjs_by_depth(g_topology, depth_core) -1;\n+ int core_depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n+ int core_id = hwloc_get_nbobjs_by_depth(g_topology, core_depth) -1;\ng_cur_core_obj = hwloc_get_obj_by_depth(g_topology, core_depth, core_id);\n#endif\n}\n@@ -98,9 +100,76 @@ bool Thread_pinning\nreturn g_enable_logs;\n}\n+void Thread_pinning\n+::pin(const size_t puid)\n+{\n+ g_mtx.lock();\n+#ifdef AFF3CT_HWLOC\n+ if (g_is_init)\n+ {\n+ /* Get the first PU of the core */\n+ if (g_cur_core_obj->arity == 0)\n+ {\n+ std::stringstream message;\n+ message << \"Unsupported architecture, a core should have at least one PU.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ int core_depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n+ hwloc_obj_t pu_obj = hwloc_get_obj_by_depth(g_topology, core_depth, puid);\n+\n+ /* Get a copy of its cpuset that we may modify. */\n+ hwloc_cpuset_t cpuset = hwloc_bitmap_dup(pu_obj->cpuset);\n+\n+ /* Get only one logical processor (in case the core is\n+ SMT/hyper-threaded). */\n+ hwloc_bitmap_singlify(cpuset);\n+\n+ if (g_enable_logs)\n+ {\n+ char c[128];\n+ hwloc_bitmap_snprintf(c, 128, cpuset);\n+\n+ std::cerr << \"Thread pinning info -- \"\n+ << \"PU logical index (hwloc): \" << pu_obj->logical_index << \" -- \"\n+ << \"P OS index: \" << pu_obj->os_index << \" -- \"\n+ << \"bitmap: \" << c << std::endl;\n+ }\n+\n+ /* And try to bind ourself there. */\n+ if (hwloc_set_cpubind(g_topology, cpuset, HWLOC_CPUBIND_THREAD))\n+ {\n+ char *str;\n+ int error = errno;\n+ hwloc_bitmap_asprintf(&str, pu_obj->cpuset);\n+ printf(\"Couldn't bind to cpuset %s: %s\\n\", str, strerror(error));\n+ free(str);\n+ }\n+\n+ /* Free our cpuset copy */\n+ hwloc_bitmap_free(cpuset);\n+ }\n+ else\n+ {\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"You can't call the 'pin' method if you have not call the 'init' method before, nothing will \"\n+ << \"be done.\" << std::endl;\n+ }\n+ }\n+#else\n+ if (g_enable_logs)\n+ {\n+ std::clog << \"'pin' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n+ }\n+#endif\n+ g_mtx.unlock();\n+}\n+\nvoid Thread_pinning\n::pin()\n{\n+ std::cout << \"coucou\" << std::endl;\ng_mtx.lock();\n#ifdef AFF3CT_HWLOC\nif (g_is_init)\n@@ -117,17 +186,28 @@ void Thread_pinning\nhwloc_obj_t cur_core_pu0_obj = g_cur_core_obj->children[0];\n- if (g_enable_logs)\n- std::cerr << \"Thread pinning info -- \"\n- << \"CORE logical index (hwloc): \" << g_cur_core_obj->logical_index << \" -- \"\n- << \"PU logical index (hwloc): \" << cur_core_pu0_obj->logical_index << \" -- \"\n- << \"P OS index: \" << cur_core_pu0_obj->os_index << std::endl;\n+ // // HACK\n+ // int core_depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n+ // cur_core_pu0_obj = hwloc_get_obj_by_depth(g_topology, core_depth, g_thread_binding[g_thread_binding_id++]);\n/* Get a copy of its cpuset that we may modify. */\nhwloc_cpuset_t cpuset = hwloc_bitmap_dup(cur_core_pu0_obj->cpuset);\n/* Get only one logical processor (in case the core is\nSMT/hyper-threaded). */\nhwloc_bitmap_singlify(cpuset);\n+\n+ if (g_enable_logs)\n+ {\n+ char c[128];\n+ hwloc_bitmap_snprintf(c, 128, cpuset);\n+\n+ std::cerr << \"Thread pinning info -- \"\n+ << \"CORE logical index (hwloc): \" << g_cur_core_obj->logical_index << \" -- \"\n+ << \"PU logical index (hwloc): \" << cur_core_pu0_obj->logical_index << \" -- \"\n+ << \"P OS index: \" << cur_core_pu0_obj->os_index << \" -- \"\n+ << \"bitmap: \" << c << std::endl;\n+ }\n+\n/* And try to bind ourself there. */\nif (hwloc_set_cpubind(g_topology, cpuset, HWLOC_CPUBIND_THREAD))\n{\n@@ -190,6 +270,22 @@ void Thread_pinning\ng_mtx.unlock();\n}\n+std::string Thread_pinning\n+::get_cur_cpuset_str()\n+{\n+ hwloc_cpuset_t cur_cpuset = hwloc_bitmap_alloc();\n+\n+ hwloc_get_cpubind(g_topology, cur_cpuset, HWLOC_CPUBIND_THREAD);\n+\n+ char c[128];\n+ hwloc_bitmap_snprintf(c, 128, cur_cpuset);\n+\n+ /* Free our cpuset copy */\n+ hwloc_bitmap_free(cur_cpuset);\n+\n+ return std::string(c);\n+}\n+\nvoid Thread_pinning\n::example1()\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the possibility to manually choose the PUs in thread pinning.
|
8,490 |
03.02.2020 18:03:03
| -3,600 |
4480dd5004cea0ba28a9c90ffd87131e4cf09ce8
|
Fix pin method.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Thread_pinning/Thread_pinning.cpp",
"new_path": "src/Tools/Thread_pinning/Thread_pinning.cpp",
"diff": "@@ -107,17 +107,16 @@ void Thread_pinning\n#ifdef AFF3CT_HWLOC\nif (g_is_init)\n{\n- /* Get the first PU of the core */\n- if (g_cur_core_obj->arity == 0)\n+ int pu_depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_PU);\n+ hwloc_obj_t pu_obj = hwloc_get_obj_by_depth(g_topology, pu_depth, puid);\n+\n+ if (pu_obj == nullptr)\n{\nstd::stringstream message;\n- message << \"Unsupported architecture, a core should have at least one PU.\";\n+ message << \"'pu_obj' is nullptr ('puid' = \" << puid << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- int core_depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n- hwloc_obj_t pu_obj = hwloc_get_obj_by_depth(g_topology, core_depth, puid);\n-\n/* Get a copy of its cpuset that we may modify. */\nhwloc_cpuset_t cpuset = hwloc_bitmap_dup(pu_obj->cpuset);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix pin method.
|
8,490 |
05.02.2020 08:53:48
| 0 |
5dff33a8c7b286d0dfd6dfadcf5f03d9a53ff064
|
Pin the threads during the memory alloc process in the Chain.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -65,10 +65,26 @@ protected:\nstd::vector<size_t> puids;\npublic:\n- Chain(const module::Task &first, const size_t n_threads = 1 );\n- Chain(const module::Task &first, const module::Task &last, const size_t n_threads = 1 );\n- Chain( module::Task &first, const size_t n_threads = 1, const bool tasks_inplace = true);\n- Chain( module::Task &first, module::Task &last, const size_t n_threads = 1, const bool tasks_inplace = true);\n+ Chain(const module::Task &first,\n+ const size_t n_threads = 1,\n+ const bool thread_pinning = false,\n+ const std::vector<size_t> &puids = {} );\n+ Chain(const module::Task &first,\n+ const module::Task &last,\n+ const size_t n_threads = 1,\n+ const bool thread_pinning = false,\n+ const std::vector<size_t> &puids = {});\n+ Chain(module::Task &first,\n+ const size_t n_threads = 1,\n+ const bool thread_pinning = false,\n+ const std::vector<size_t> &puids = {},\n+ const bool tasks_inplace = true);\n+ Chain(module::Task &first,\n+ module::Task &last,\n+ const size_t n_threads = 1,\n+ const bool thread_pinning = false,\n+ const std::vector<size_t> &puids = {},\n+ const bool tasks_inplace = true);\nvirtual ~Chain();\ntemplate <class SS, class TA>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -20,7 +20,11 @@ using namespace aff3ct;\nusing namespace aff3ct::tools;\nChain\n-::Chain(const module::Task &first, const module::Task &last, const size_t n_threads)\n+::Chain(const module::Task &first,\n+ const module::Task &last,\n+ const size_t n_threads,\n+ const bool thread_pinning,\n+ const std::vector<size_t> &puids)\n: n_threads(n_threads),\nsequences(n_threads, nullptr),\nfirst_tasks(n_threads, nullptr),\n@@ -30,13 +34,17 @@ Chain\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false)),\ntasks_inplace(false),\n- thread_pinning(false)\n+ thread_pinning(thread_pinning),\n+ puids(puids)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first, &last);\n}\nChain\n-::Chain(const module::Task &first, const size_t n_threads)\n+::Chain(const module::Task &first,\n+ const size_t n_threads,\n+ const bool thread_pinning,\n+ const std::vector<size_t> &puids)\n: n_threads(n_threads),\nsequences(n_threads, nullptr),\nfirst_tasks(n_threads, nullptr),\n@@ -46,13 +54,19 @@ Chain\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false)),\ntasks_inplace(false),\n- thread_pinning(false)\n+ thread_pinning(thread_pinning),\n+ puids(puids)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first);\n}\nChain\n-::Chain(module::Task &first, module::Task &last, const size_t n_threads, const bool tasks_inplace)\n+::Chain(module::Task &first,\n+ module::Task &last,\n+ const size_t n_threads,\n+ const bool thread_pinning,\n+ const std::vector<size_t> &puids,\n+ const bool tasks_inplace)\n: n_threads(n_threads),\nsequences(n_threads, nullptr),\nfirst_tasks(n_threads, nullptr),\n@@ -62,7 +76,8 @@ Chain\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false)),\ntasks_inplace(tasks_inplace),\n- thread_pinning(false)\n+ thread_pinning(thread_pinning),\n+ puids(puids)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first, &last);\n@@ -71,7 +86,11 @@ Chain\n}\nChain\n-::Chain(module::Task &first, const size_t n_threads, const bool tasks_inplace)\n+::Chain(module::Task &first,\n+ const size_t n_threads,\n+ const bool thread_pinning,\n+ const std::vector<size_t> &puids,\n+ const bool tasks_inplace)\n: n_threads(n_threads),\nsequences(n_threads, nullptr),\nfirst_tasks(n_threads, nullptr),\n@@ -81,7 +100,8 @@ Chain\nmtx_exception(new std::mutex()),\nforce_exit_loop(new std::atomic<bool>(false)),\ntasks_inplace(tasks_inplace),\n- thread_pinning(false)\n+ thread_pinning(false),\n+ puids(puids)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first);\n@@ -100,6 +120,14 @@ template <class SS, class TA>\nvoid Chain\n::init(TA &first, TA *last)\n{\n+ if (this->is_thread_pinning())\n+ {\n+ if (0 < this->puids.size())\n+ aff3ct::tools::Thread_pinning::pin(0);\n+ else\n+ aff3ct::tools::Thread_pinning::pin();\n+ }\n+\nif (this->n_threads == 0)\n{\nstd::stringstream message;\n@@ -642,6 +670,14 @@ void Chain\n// clone the modules\nfor (size_t tid = 0; tid < this->n_threads - (this->tasks_inplace ? 1 : 0); tid++)\n{\n+ if (this->is_thread_pinning())\n+ {\n+ if (tid < this->puids.size())\n+ aff3ct::tools::Thread_pinning::pin(this->puids[tid]);\n+ else\n+ aff3ct::tools::Thread_pinning::pin();\n+ }\n+\nthis->modules[tid].resize(modules_vec.size());\nthis->all_modules[tid + (this->tasks_inplace ? 1 : 0)].resize(modules_vec.size());\nfor (size_t m = 0; m < modules_vec.size(); m++)\n@@ -767,6 +803,14 @@ void Chain\nfor (size_t thread_id = (this->tasks_inplace ? 1 : 0); thread_id < this->sequences.size(); thread_id++)\n{\n+ if (this->is_thread_pinning())\n+ {\n+ if (thread_id < this->puids.size())\n+ aff3ct::tools::Thread_pinning::pin(this->puids[thread_id]);\n+ else\n+ aff3ct::tools::Thread_pinning::pin();\n+ }\n+\nthis->sequences[thread_id] = new Generic_node<Sub_sequence>(nullptr, {}, nullptr, 0, 0, 0);\nduplicate_sequence(sequence, this->sequences[thread_id], thread_id);\nset_autoalloc_true(this->sequences[thread_id]);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Pin the threads during the memory alloc process in the Chain.
|
8,490 |
05.02.2020 10:03:56
| 0 |
5bcd5041b9328cda70fb181f1af427c6b7f37542
|
Fix pinning for clones.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -123,7 +123,7 @@ void Chain\nif (this->is_thread_pinning())\n{\nif (0 < this->puids.size())\n- aff3ct::tools::Thread_pinning::pin(0);\n+ aff3ct::tools::Thread_pinning::pin(this->puids[0]);\nelse\naff3ct::tools::Thread_pinning::pin();\n}\n@@ -672,8 +672,9 @@ void Chain\n{\nif (this->is_thread_pinning())\n{\n- if (tid < this->puids.size())\n- aff3ct::tools::Thread_pinning::pin(this->puids[tid]);\n+ const auto real_tid = tid + (this->tasks_inplace ? 1 : 0);\n+ if (real_tid < this->puids.size())\n+ aff3ct::tools::Thread_pinning::pin(this->puids[real_tid]);\nelse\naff3ct::tools::Thread_pinning::pin();\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix pinning for clones.
|
8,490 |
06.02.2020 13:26:56
| 0 |
0c3f06888c4a876f4ff05116c8acda521378c3ad
|
Working on 0 copy adaptors.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hpp",
"new_path": "include/Module/Adaptor/Adaptor.hpp",
"diff": "#include \"Module/Task.hpp\"\n#include \"Module/Socket.hpp\"\n#include \"Module/Module.hpp\"\n+#include \"Tools/Chain/Chain.hpp\"\n#include \"Tools/Interface/Interface_waiting.hpp\"\nnamespace aff3ct\n@@ -36,6 +37,9 @@ namespace module\nclass Adaptor : public Module, public tools::Interface_waiting\n{\n+\n+friend tools::Chain; // Chain is friend to enable the hack mode (0 copy)\n+\nprotected:\nconst std::vector<size_t> n_elmts;\nconst std::vector<size_t> n_bytes;\n@@ -51,6 +55,9 @@ protected:\nstd::shared_ptr<std::atomic<bool>> waiting_canceled;\n+ bool no_copy_pull;\n+ bool no_copy_push;\n+\npublic:\ninline size_t get_n_elmts(const size_t sid = 0) const;\ninline size_t get_n_bytes(const size_t sid = 0) const;\n@@ -74,6 +81,15 @@ protected:\ninline size_t n_free_slots(const size_t id);\ninline size_t n_fill_slots(const size_t id);\n+ void set_no_copy_push(const bool hack_mode);\n+ void set_no_copy_pull(const bool hack_mode);\n+ bool is_no_copy_push();\n+ bool is_no_copy_pull();\n+ virtual void* get_empty_buffer(const size_t sid) = 0;\n+ virtual void* get_filled_buffer(const size_t sid) = 0;\n+ virtual void wake_up_pusher() = 0;\n+ virtual void wake_up_puller() = 0;\n+\nprivate:\nstatic size_t compute_bytes(const size_t n_elmts, const std::type_index type);\nstatic std::vector<size_t> compute_bytes(const std::vector<size_t> &n_elmts, const std::vector<std::type_index> &type);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hxx",
"new_path": "include/Module/Adaptor/Adaptor.hxx",
"diff": "@@ -29,7 +29,9 @@ Adaptor\nstd::vector<int8_t>(n_frames * this->n_bytes[0]))))),\nfirst(new std::vector<std::atomic<size_t>>(1000)),\nlast(new std::vector<std::atomic<size_t>>(1000)),\n- waiting_canceled(new std::atomic<bool>(false))\n+ waiting_canceled(new std::atomic<bool>(false)),\n+ no_copy_pull(false),\n+ no_copy_push(false)\n{\nconst std::string name = \"Adaptor\";\nthis->set_name(name);\n@@ -73,7 +75,9 @@ Adaptor\nstd::vector<std::vector<int8_t>>(buffer_size)))),\nfirst(new std::vector<std::atomic<size_t>>(1000)),\nlast(new std::vector<std::atomic<size_t>>(1000)),\n- waiting_canceled(new std::atomic<bool>(false))\n+ waiting_canceled(new std::atomic<bool>(false)),\n+ no_copy_pull(false),\n+ no_copy_push(false)\n{\nconst std::string name = \"Adaptor\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"diff": "@@ -59,6 +59,11 @@ public:\nprotected:\nvirtual void push_1(const std::vector<const int8_t*> &in, const int frame_id = -1);\nvirtual void pull_n(const std::vector< int8_t*> &out, const int frame_id = -1);\n+\n+ void* get_empty_buffer(const size_t sid);\n+ void* get_filled_buffer(const size_t sid);\n+ void wake_up_pusher();\n+ void wake_up_puller();\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"diff": "@@ -59,6 +59,11 @@ public:\nprotected:\nvirtual void push_n(const std::vector<const int8_t*> &in, const int frame_id = -1);\nvirtual void pull_1(const std::vector< int8_t*> &out, const int frame_id = -1);\n+\n+ void* get_empty_buffer(const size_t sid);\n+ void* get_filled_buffer(const size_t sid);\n+ void wake_up_pusher();\n+ void wake_up_puller();\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -26,7 +26,7 @@ class Module;\nnamespace tools\n{\n-enum class subseq_t : size_t { STD, LOOP, ROUTER };\n+enum class subseq_t : size_t { STD, LOOP, ROUTER, FIRST_ADP, LAST_ADP, FIRST_LAST_ADP };\ntemplate <class VTA = std::vector<module::Task*>>\nclass Sub_sequence_generic\n@@ -64,7 +64,10 @@ protected:\nbool thread_pinning;\nstd::vector<size_t> puids;\n+ bool no_copy_mode_adaptors;\n+\npublic:\n+\nChain(const module::Task &first,\nconst size_t n_threads = 1,\nconst bool thread_pinning = false,\n@@ -115,6 +118,9 @@ public:\nvoid export_dot(std::ostream &stream = std::cout) const;\n+ void set_no_copy_mode_adaptors(const bool no_copy_mode);\n+ bool is_no_copy_mode_adaptors() const;\n+\nprotected:\ntemplate <class SS>\nvoid delete_tree(Generic_node<SS> *node);\n@@ -153,7 +159,6 @@ protected:\nvoid _exec_without_statuses(const size_t tid,\nstd::function<bool()> &stop_condition,\nGeneric_node<Sub_sequence>* sequence);\n-\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor.cpp",
"new_path": "src/Module/Adaptor/Adaptor.cpp",
"diff": "@@ -82,12 +82,38 @@ std::vector<size_t> Adaptor\nreturn bytes;\n}\n-void Adaptor::send_cancel_signal()\n+void Adaptor\n+::send_cancel_signal()\n{\n*this->waiting_canceled = true;\n}\n-void Adaptor::reset()\n+void Adaptor\n+::reset()\n{\n*this->waiting_canceled = false;\n}\n+\n+void Adaptor\n+::set_no_copy_pull(const bool hack_mode)\n+{\n+ this->no_copy_pull = hack_mode;\n+}\n+\n+void Adaptor\n+::set_no_copy_push(const bool hack_mode)\n+{\n+ this->no_copy_push = hack_mode;\n+}\n+\n+bool Adaptor\n+::is_no_copy_pull()\n+{\n+ return this->no_copy_pull;\n+}\n+\n+bool Adaptor\n+::is_no_copy_push()\n+{\n+ return this->no_copy_push;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"new_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"diff": "@@ -17,9 +17,6 @@ Adaptor_1_to_n* Adaptor_1_to_n\nvoid Adaptor_1_to_n\n::push_1(const std::vector<const int8_t*> &in, const int frame_id)\n{\n- const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n- const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n-\nif (this->active_waiting)\n{\nwhile (this->is_full(this->cur_id) && !*this->waiting_canceled);\n@@ -39,39 +36,27 @@ void Adaptor_1_to_n\nif (*this->waiting_canceled)\nthrow tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+ if (!this->is_no_copy_push())\n+ {\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\nfor (size_t s = 0; s < this->n_sockets; s++)\n{\n- int8_t* out = (*this->buffer)[this->cur_id][s][(*this->last)[this->cur_id] % this->buffer_size].data();\n+ int8_t* out = (int8_t*)this->get_empty_buffer(s);\nstd::copy(in[s] + f_start * this->n_bytes[s],\nin[s] + f_stop * this->n_bytes[s],\nout + f_start * this->n_bytes[s]);\n}\n- (*this->last)[this->cur_id]++;\n-\n- if (!this->active_waiting) // passive waiting\n- {\n- if (!this->is_empty(this->cur_id))\n- {\n- std::lock_guard<std::mutex> lock((*this->mtx_pull.get())[this->cur_id]);\n- (*this->cnd_pull.get())[this->cur_id].notify_one();\n+ this->wake_up_puller();\n}\n}\n- do\n- {\n- this->cur_id = (this->cur_id +1) % this->buffer->size();\n- }\n- while((*this->buffer)[this->cur_id].size() == 0);\n-}\n-\nvoid Adaptor_1_to_n\n::pull_n(const std::vector<int8_t*> &out, const int frame_id)\n{\n- const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n- const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n-\nif (this->active_waiting)\n{\nwhile (this->is_empty(this->id) && !*this->waiting_canceled);\n@@ -91,24 +76,21 @@ void Adaptor_1_to_n\nif (*this->waiting_canceled)\nthrow tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+ if (!this->is_no_copy_pull())\n+ {\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\nfor (size_t s = 0; s < this->n_sockets; s++)\n{\n- const int8_t* in = (*this->buffer)[this->id][s][(*this->first)[this->id] % this->buffer_size].data();\n+ const int8_t* in = (const int8_t*)this->get_filled_buffer(s);\nstd::copy(in + f_start * this->n_bytes[s],\nin + f_stop * this->n_bytes[s],\nout[s] + f_start * this->n_bytes[s]);\n}\n- (*this->first)[this->id]++;\n-\n- if (!this->active_waiting) // passive waiting\n- {\n- if (!this->is_full(this->id))\n- {\n- std::lock_guard<std::mutex> lock(*this->mtx_put.get());\n- (*this->cnd_put.get()).notify_one();\n- }\n+ this->wake_up_pusher();\n}\n}\n@@ -135,3 +117,51 @@ void Adaptor_1_to_n\nthis->send_cancel_signal();\nthis->wake_up();\n}\n+\n+void* Adaptor_1_to_n\n+::get_empty_buffer(const size_t sid)\n+{\n+ return (void*)(*this->buffer)[this->cur_id][sid][(*this->last)[this->cur_id] % this->buffer_size].data();\n+}\n+\n+void* Adaptor_1_to_n\n+::get_filled_buffer(const size_t sid)\n+{\n+ return (*this->buffer)[this->id][sid][(*this->first)[this->id] % this->buffer_size].data();\n+}\n+\n+void Adaptor_1_to_n\n+::wake_up_puller()\n+{\n+ (*this->last)[this->cur_id]++;\n+\n+ if (!this->active_waiting) // passive waiting\n+ {\n+ if (!this->is_empty(this->cur_id))\n+ {\n+ std::lock_guard<std::mutex> lock((*this->mtx_pull.get())[this->cur_id]);\n+ (*this->cnd_pull.get())[this->cur_id].notify_one();\n+ }\n+ }\n+\n+ do\n+ {\n+ this->cur_id = (this->cur_id +1) % this->buffer->size();\n+ }\n+ while((*this->buffer)[this->cur_id].size() == 0);\n+}\n+\n+void Adaptor_1_to_n\n+::wake_up_pusher()\n+{\n+ (*this->first)[this->id]++;\n+\n+ if (!this->active_waiting) // passive waiting\n+ {\n+ if (!this->is_full(this->id))\n+ {\n+ std::lock_guard<std::mutex> lock(*this->mtx_put.get());\n+ (*this->cnd_put.get()).notify_one();\n+ }\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"new_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"diff": "@@ -17,9 +17,6 @@ Adaptor_n_to_1* Adaptor_n_to_1\nvoid Adaptor_n_to_1\n::push_n(const std::vector<const int8_t*> &in, const int frame_id)\n{\n- const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n- const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n-\nif (this->active_waiting)\n{\nwhile (this->is_full(this->id) && !*this->waiting_canceled);\n@@ -39,33 +36,27 @@ void Adaptor_n_to_1\nif (*this->waiting_canceled)\nthrow tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+ if (!this->is_no_copy_push())\n+ {\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\nfor (size_t s = 0; s < this->n_sockets; s++)\n{\n- int8_t* out = (*this->buffer)[this->id][s][(*this->last)[this->id] % this->buffer_size].data();\n+ int8_t* out = (int8_t*)this->get_empty_buffer(s);\nstd::copy(in[s] + f_start * this->n_bytes[s],\nin[s] + f_stop * this->n_bytes[s],\nout + f_start * this->n_bytes[s]);\n}\n- (*this->last)[this->id]++;\n-\n- if (!this->active_waiting) // passive waiting\n- {\n- if (!this->is_empty(this->id))\n- {\n- std::lock_guard<std::mutex> lock(*this->mtx_pull.get());\n- (*this->cnd_pull.get()).notify_one();\n- }\n+ this->wake_up_puller();\n}\n}\nvoid Adaptor_n_to_1\n::pull_1(const std::vector<int8_t*> &out, const int frame_id)\n{\n- const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n- const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n-\nif (this->active_waiting)\n{\nwhile (this->is_empty(this->cur_id) && !*this->waiting_canceled);\n@@ -85,33 +76,24 @@ void Adaptor_n_to_1\nif (*this->waiting_canceled)\nthrow tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+ if (!this->is_no_copy_pull())\n+ {\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n+\nfor (size_t s = 0; s < this->n_sockets; s++)\n{\n- const int8_t* in = (*this->buffer)[this->cur_id][s][(*this->first)[this->cur_id] % this->buffer_size].data();\n+ const int8_t* in = (const int8_t*)this->get_filled_buffer(s);\nstd::copy(in + f_start * this->n_bytes[s],\nin + f_stop * this->n_bytes[s],\nout[s] + f_start * this->n_bytes[s]);\n}\n- (*this->first)[this->cur_id]++;\n-\n- if (!this->active_waiting) // passive waiting\n- {\n- if (!this->is_full(this->cur_id))\n- {\n- std::lock_guard<std::mutex> lock((*this->mtx_put.get())[this->cur_id]);\n- (*this->cnd_put.get())[this->cur_id].notify_one();\n+ this->wake_up_pusher();\n}\n}\n- do\n- {\n- this->cur_id = (this->cur_id +1) % this->buffer->size();\n- }\n- while((*this->buffer)[this->cur_id].size() == 0);\n-}\n-\nvoid Adaptor_n_to_1\n::wake_up()\n{\n@@ -135,3 +117,51 @@ void Adaptor_n_to_1\nthis->send_cancel_signal();\nthis->wake_up();\n}\n+\n+void* Adaptor_n_to_1\n+::get_empty_buffer(const size_t sid)\n+{\n+ return (*this->buffer)[this->id][sid][(*this->last)[this->id] % this->buffer_size].data();\n+}\n+\n+void* Adaptor_n_to_1\n+::get_filled_buffer(const size_t sid)\n+{\n+ return (*this->buffer)[this->cur_id][sid][(*this->first)[this->cur_id] % this->buffer_size].data();\n+}\n+\n+void Adaptor_n_to_1\n+::wake_up_puller()\n+{\n+ (*this->last)[this->id]++;\n+\n+ if (!this->active_waiting) // passive waiting\n+ {\n+ if (!this->is_empty(this->id))\n+ {\n+ std::lock_guard<std::mutex> lock(*this->mtx_pull.get());\n+ (*this->cnd_pull.get()).notify_one();\n+ }\n+ }\n+}\n+\n+void Adaptor_n_to_1\n+::wake_up_pusher()\n+{\n+ (*this->first)[this->cur_id]++;\n+\n+ if (!this->active_waiting) // passive waiting\n+ {\n+ if (!this->is_full(this->cur_id))\n+ {\n+ std::lock_guard<std::mutex> lock((*this->mtx_put.get())[this->cur_id]);\n+ (*this->cnd_put.get())[this->cur_id].notify_one();\n+ }\n+ }\n+\n+ do\n+ {\n+ this->cur_id = (this->cur_id +1) % this->buffer->size();\n+ }\n+ while((*this->buffer)[this->cur_id].size() == 0);\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "#include \"Module/Socket.hpp\"\n#include \"Module/Loop/Loop.hpp\"\n#include \"Module/Router/Router.hpp\"\n+#include \"Module/Adaptor/Adaptor.hpp\"\n#include \"Tools/Chain/Chain.hpp\"\nusing namespace aff3ct;\n@@ -35,7 +36,8 @@ Chain\nforce_exit_loop(new std::atomic<bool>(false)),\ntasks_inplace(false),\nthread_pinning(thread_pinning),\n- puids(puids)\n+ puids(puids),\n+ no_copy_mode_adaptors(false)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first, &last);\n}\n@@ -55,7 +57,8 @@ Chain\nforce_exit_loop(new std::atomic<bool>(false)),\ntasks_inplace(false),\nthread_pinning(thread_pinning),\n- puids(puids)\n+ puids(puids),\n+ no_copy_mode_adaptors(false)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first);\n}\n@@ -77,7 +80,8 @@ Chain\nforce_exit_loop(new std::atomic<bool>(false)),\ntasks_inplace(tasks_inplace),\nthread_pinning(thread_pinning),\n- puids(puids)\n+ puids(puids),\n+ no_copy_mode_adaptors(false)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first, &last);\n@@ -101,7 +105,8 @@ Chain\nforce_exit_loop(new std::atomic<bool>(false)),\ntasks_inplace(tasks_inplace),\nthread_pinning(false),\n- puids(puids)\n+ puids(puids),\n+ no_copy_mode_adaptors(false)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first);\n@@ -362,11 +367,15 @@ void Chain\nThread_pinning::pin();\n}\n+ const size_t n_threads = this->n_threads;\n+ const bool no_copy_mode_adaptors = this->is_no_copy_mode_adaptors();\n+\nstd::function<void(Generic_node<Sub_sequence>*)> exec_sequence =\n- [&exec_sequence](Generic_node<Sub_sequence>* cur_ss)\n+ [&exec_sequence, n_threads, no_copy_mode_adaptors](Generic_node<Sub_sequence>* cur_ss)\n{\nauto type = cur_ss->get_c()->type;\nauto &tasks = cur_ss->get_c()->tasks;\n+\nif (type == subseq_t::LOOP)\n{\nwhile (!tasks[0]->exec())\n@@ -374,7 +383,202 @@ void Chain\nstatic_cast<module::Loop&>(tasks[0]->get_module()).reset();\nexec_sequence(cur_ss->get_children()[1]);\n}\n- else\n+ else if (type == subseq_t::FIRST_ADP && no_copy_mode_adaptors)\n+ {\n+ auto pull_task = tasks[0];\n+ auto first_task = tasks[1];\n+\n+ auto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\n+ adp_pull->set_no_copy_pull(true);\n+ size_t sin_id = 0;\n+ std::vector<void*> dataptrs_in; // save the original pointers\n+ pull_task->exec(); // active or passive waiting here\n+ for (size_t s = 0; s < first_task->sockets.size(); s++)\n+ {\n+ if (first_task->get_socket_type(*first_task->sockets[s]) == module::socket_t::SIN)\n+ {\n+ dataptrs_in.push_back(first_task->sockets[s]->get_dataptr());\n+ auto buff = adp_pull->get_filled_buffer(sin_id++);\n+ first_task->sockets[s]->bind(buff);\n+ }\n+ }\n+ first_task->exec();\n+ adp_pull->wake_up_pusher();\n+\n+ // revert the hack\n+ adp_pull->set_no_copy_pull(false);\n+ sin_id = 0;\n+ for (size_t s = 0; s < first_task->sockets.size(); s++)\n+ if (first_task->get_socket_type(*first_task->sockets[s]) == module::socket_t::SIN)\n+ first_task->sockets[s]->bind(dataptrs_in[sin_id++]);\n+\n+ for (size_t ta = 2; ta < tasks.size(); ta++)\n+ tasks[ta]->exec();\n+\n+ for (auto c : cur_ss->get_children())\n+ exec_sequence(c);\n+ }\n+ else if (type == subseq_t::LAST_ADP && no_copy_mode_adaptors)\n+ {\n+ for (size_t ta = 0; ta < tasks.size() -2; ta++)\n+ tasks[ta]->exec();\n+\n+ auto last_task = tasks[tasks.size() -2];\n+ auto push_task = tasks[tasks.size() -1];\n+\n+ auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n+ adp_push->set_no_copy_push(true);\n+ size_t sout_id = 0;\n+ std::vector<void*> dataptrs_out; // save the original pointers\n+ push_task->exec(); // active or passive waiting here\n+ for (size_t s = 0; s < last_task->sockets.size(); s++)\n+ {\n+ if (last_task->get_socket_type(*last_task->sockets[s]) == module::socket_t::SOUT)\n+ {\n+ dataptrs_out.push_back(last_task->sockets[s]->get_dataptr());\n+ auto buff = adp_push->get_empty_buffer(sout_id++);\n+ last_task->sockets[s]->bind(buff);\n+ }\n+ }\n+ last_task->exec();\n+ adp_push->wake_up_puller();\n+\n+ // revert the hack\n+ adp_push->set_no_copy_push(false);\n+ sout_id = 0;\n+ for (size_t s = 0; s < last_task->sockets.size(); s++)\n+ if (last_task->get_socket_type(*last_task->sockets[s]) == module::socket_t::SOUT)\n+ last_task->sockets[s]->bind(dataptrs_out[sout_id++]);\n+\n+ for (auto c : cur_ss->get_children())\n+ exec_sequence(c);\n+ }\n+ else if (type == subseq_t::FIRST_LAST_ADP && no_copy_mode_adaptors && tasks.size() == 3) // Gardner\n+ {\n+ auto pull_task = tasks[0];\n+ auto task = tasks[1];\n+ auto push_task = tasks[2];\n+\n+ auto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\n+ auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n+ adp_pull->set_no_copy_pull(true);\n+ adp_push->set_no_copy_push(true);\n+ size_t sin_id = 0;\n+ size_t sout_id = 0;\n+ std::vector<void*> dataptrs_in; // save the original pointers\n+ std::vector<void*> dataptrs_out; // save the original pointers\n+ push_task->exec(); // active or passive waiting here\n+ pull_task->exec(); // active or passive waiting here\n+ for (size_t s = 0; s < task->sockets.size(); s++)\n+ {\n+ void* buff = nullptr;\n+ switch (task->get_socket_type(*task->sockets[s]))\n+ {\n+ case module::socket_t::SIN:\n+ dataptrs_in.push_back(task->sockets[s]->get_dataptr());\n+ buff = adp_pull->get_filled_buffer(sin_id++);\n+ break;\n+ case module::socket_t::SOUT:\n+ dataptrs_out.push_back(task->sockets[s]->get_dataptr());\n+ buff = adp_push->get_empty_buffer(sout_id++);\n+ break;\n+ default:\n+ break;\n+ }\n+\n+ task->sockets[s]->bind(buff);\n+ }\n+ task->exec();\n+ adp_pull->wake_up_pusher();\n+ adp_push->wake_up_puller();\n+\n+ // revert the hack\n+ adp_pull->set_no_copy_pull(false);\n+ adp_push->set_no_copy_push(false);\n+ sin_id = 0;\n+ sout_id = 0;\n+ for (size_t s = 0; s < task->sockets.size(); s++)\n+ {\n+ switch (task->get_socket_type(*task->sockets[s]))\n+ {\n+ case module::socket_t::SIN:\n+ task->sockets[s]->bind(dataptrs_in[sin_id++]);\n+ break;\n+ case module::socket_t::SOUT:\n+ task->sockets[s]->bind(dataptrs_out[sout_id++]);\n+ break;\n+ default:\n+ break;\n+ }\n+ }\n+\n+ for (auto c : cur_ss->get_children())\n+ exec_sequence(c);\n+ }\n+ else if (type == subseq_t::FIRST_LAST_ADP && no_copy_mode_adaptors)\n+ {\n+ auto pull_task = tasks[0];\n+ auto first_task = tasks[1];\n+\n+ auto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\n+ adp_pull->set_no_copy_pull(true);\n+ size_t sin_id = 0;\n+ std::vector<void*> dataptrs_in; // save the original pointers\n+ pull_task->exec(); // active or passive waiting here\n+\n+ for (size_t s = 0; s < first_task->sockets.size(); s++)\n+ {\n+ if (first_task->get_socket_type(*first_task->sockets[s]) == module::socket_t::SIN)\n+ {\n+ dataptrs_in.push_back(first_task->sockets[s]->get_dataptr());\n+ auto buff = adp_pull->get_filled_buffer(sin_id++);\n+ first_task->sockets[s]->bind(buff);\n+ }\n+ }\n+ first_task->exec();\n+ adp_pull->wake_up_pusher();\n+\n+ // revert the hack\n+ adp_pull->set_no_copy_pull(false);\n+ sin_id = 0;\n+ for (size_t s = 0; s < first_task->sockets.size(); s++)\n+ if (first_task->get_socket_type(*first_task->sockets[s]) == module::socket_t::SIN)\n+ first_task->sockets[s]->bind(dataptrs_in[sin_id++]);\n+\n+ for (size_t ta = 2; ta < tasks.size() -2; ta++)\n+ tasks[ta]->exec();\n+\n+ auto last_task = tasks[tasks.size() -2];\n+ auto push_task = tasks[tasks.size() -1];\n+\n+ auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n+ adp_push->set_no_copy_push(true);\n+ size_t sout_id = 0;\n+ std::vector<void*> dataptrs_out; // save the original pointers\n+ push_task->exec(); // active or passive waiting here\n+ for (size_t s = 0; s < last_task->sockets.size(); s++)\n+ {\n+ if (last_task->get_socket_type(*last_task->sockets[s]) == module::socket_t::SOUT)\n+ {\n+ dataptrs_out.push_back(last_task->sockets[s]->get_dataptr());\n+ auto buff = adp_push->get_empty_buffer(sout_id++);\n+ last_task->sockets[s]->bind(buff);\n+ }\n+ }\n+ last_task->exec();\n+ adp_push->wake_up_puller();\n+\n+ // revert the hack\n+ adp_push->set_no_copy_push(false);\n+ sout_id = 0;\n+ for (size_t s = 0; s < last_task->sockets.size(); s++)\n+ if (last_task->get_socket_type(*last_task->sockets[s]) == module::socket_t::SOUT)\n+ last_task->sockets[s]->bind(dataptrs_out[sout_id++]);\n+\n+ for (auto c : cur_ss->get_children())\n+ exec_sequence(c);\n+ }\n+ else /*if (type == subseq_t::STD)*/\n{\nfor (size_t ta = 0; ta < tasks.size(); ta++)\ntasks[ta]->exec();\n@@ -597,6 +801,22 @@ const module::Task& Chain\ncur_subseq->get_c()->tasks.push_back(¤t_task);\ncur_subseq->get_c()->tasks_id.push_back(taid++);\n+ // TAG sub-sequences with adaptors\n+ if (auto adp = dynamic_cast<const module::Adaptor*>(¤t_task.get_module()))\n+ {\n+ if (cur_subseq->get_c()->tasks.size() == 1)\n+ {\n+ cur_subseq->get_c()->type = subseq_t::FIRST_ADP;\n+ }\n+ else\n+ {\n+ if (cur_subseq->get_c()->type == subseq_t::FIRST_ADP)\n+ cur_subseq->get_c()->type = subseq_t::FIRST_LAST_ADP;\n+ else\n+ cur_subseq->get_c()->type = subseq_t::LAST_ADP;\n+ }\n+ }\n+\nif (¤t_task != last)\n{\nfor (auto &s : current_task.sockets)\n@@ -875,6 +1095,7 @@ void Chain\nstream << tab << tab << tab << tab << \"color=blue;\" << std::endl;\nstream << tab << tab << tab << \"}\" << std::endl;\nstream << tab << tab << tab << \"label=\\\"\" << t->get_module().get_name() << \"\\n\"\n+ << (t->get_module().get_custom_name().empty() ? \"\" : t->get_module().get_custom_name() + \"\\n\")\n<< \"exec order: [\" << exec_order++ << \"]\\n\"\n<< \"addr: \" << +&t->get_module() << \"\\\";\" << std::endl;\nstream << tab << tab << tab << \"color=blue;\" << std::endl;\n@@ -970,3 +1191,30 @@ void Chain\nexport_dot_connections_recursive (root, tab, stream);\nstream << \"}\" << std::endl;\n}\n+\n+// void Chain\n+// ::set_no_copy_mode_adaptors(const bool hack_mode)\n+// {\n+// for (auto vm : this->all_modules)\n+// for (auto m : vm)\n+// {\n+// auto adp = dynamic_cast<module::Adaptor*>(m);\n+// if (adp)\n+// {\n+// adp->set_no_copy_push(hack_mode);\n+// adp->set_no_copy_pull(hack_mode);\n+// }\n+// }\n+// }\n+\n+void Chain\n+::set_no_copy_mode_adaptors(const bool no_copy_mode)\n+{\n+ this->no_copy_mode_adaptors = no_copy_mode;\n+}\n+\n+bool Chain\n+::is_no_copy_mode_adaptors() const\n+{\n+ return this->no_copy_mode_adaptors;\n+}\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Working on 0 copy adaptors.
|
8,490 |
06.02.2020 16:11:45
| 0 |
735f187140fdeacfd81b822127d58c01504a5518
|
Working zero copy adaptors.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hpp",
"new_path": "include/Module/Adaptor/Adaptor.hpp",
"diff": "@@ -49,7 +49,9 @@ protected:\nsize_t id;\nsize_t cur_id;\n- std::shared_ptr<std::vector<std::vector<std::vector<std::vector<int8_t>>>>> buffer;\n+ std::shared_ptr<std::vector<std::vector<std::vector<int8_t*>>>> buffer;\n+ std::vector<int8_t*> buffer_to_free;\n+\nstd::shared_ptr<std::vector<std::atomic<size_t>>> first;\nstd::shared_ptr<std::vector<std::atomic<size_t>>> last;\n@@ -87,6 +89,8 @@ protected:\nbool is_no_copy_pull();\nvirtual void* get_empty_buffer(const size_t sid) = 0;\nvirtual void* get_filled_buffer(const size_t sid) = 0;\n+ virtual void* get_empty_buffer(const size_t sid, void* swap_buffer) = 0;\n+ virtual void* get_filled_buffer(const size_t sid, void* swap_buffer) = 0;\nvirtual void wake_up_pusher() = 0;\nvirtual void wake_up_puller() = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hxx",
"new_path": "include/Module/Adaptor/Adaptor.hxx",
"diff": "@@ -23,10 +23,10 @@ Adaptor\nn_sockets(1),\nid(0),\ncur_id(0),\n- buffer(new std::vector<std::vector<std::vector<std::vector<int8_t>>>>\n- (1, std::vector<std::vector<std::vector<int8_t>>>(1,\n- std::vector<std::vector<int8_t>>(buffer_size,\n- std::vector<int8_t>(n_frames * this->n_bytes[0]))))),\n+ buffer(new std::vector<std::vector<std::vector<int8_t*>>>\n+ (1, std::vector<std::vector<int8_t*>>(1,\n+ std::vector<int8_t*>(buffer_size,\n+ new int8_t[n_frames * this->n_bytes[0]])))),\nfirst(new std::vector<std::atomic<size_t>>(1000)),\nlast(new std::vector<std::atomic<size_t>>(1000)),\nwaiting_canceled(new std::atomic<bool>(false)),\n@@ -51,6 +51,10 @@ Adaptor\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ for (size_t b = 0; b < this->buffer_size; b++)\n+ this->buffer_to_free.push_back((*this->buffer)[0][s][b]);\n+\nfor (auto &a : *this->first.get()) a = 0;\nfor (auto &a : *this->last .get()) a = 0;\n@@ -70,9 +74,9 @@ Adaptor\nn_sockets(n_elmts.size()),\nid(0),\ncur_id(0),\n- buffer(new std::vector<std::vector<std::vector<std::vector<int8_t>>>>\n- (1, std::vector<std::vector<std::vector<int8_t>>>(n_sockets,\n- std::vector<std::vector<int8_t>>(buffer_size)))),\n+ buffer(new std::vector<std::vector<std::vector<int8_t*>>>\n+ (1, std::vector<std::vector<int8_t*>>(n_sockets,\n+ std::vector<int8_t*>(buffer_size)))),\nfirst(new std::vector<std::atomic<size_t>>(1000)),\nlast(new std::vector<std::atomic<size_t>>(1000)),\nwaiting_canceled(new std::atomic<bool>(false)),\n@@ -110,7 +114,10 @@ Adaptor\nfor (size_t s = 0; s < this->n_sockets; s++)\nfor (size_t b = 0; b < this->buffer_size; b++)\n- (*this->buffer)[0][s][b].resize(this->n_frames * this->n_bytes[s]);\n+ {\n+ (*this->buffer)[0][s][b] = new int8_t[this->n_frames * this->n_bytes[s]];\n+ this->buffer_to_free.push_back((*this->buffer)[0][s][b]);\n+ }\nfor (auto &a : *this->first.get()) a = 0;\nfor (auto &a : *this->last .get()) a = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"diff": "@@ -62,6 +62,8 @@ protected:\nvoid* get_empty_buffer(const size_t sid);\nvoid* get_filled_buffer(const size_t sid);\n+ void* get_empty_buffer(const size_t sid, void* swap_buffer);\n+ void* get_filled_buffer(const size_t sid, void* swap_buffer);\nvoid wake_up_pusher();\nvoid wake_up_puller();\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"diff": "@@ -62,6 +62,8 @@ protected:\nvoid* get_empty_buffer(const size_t sid);\nvoid* get_filled_buffer(const size_t sid);\n+ void* get_empty_buffer(const size_t sid, void* swap_buffer);\n+ void* get_filled_buffer(const size_t sid, void* swap_buffer);\nvoid wake_up_pusher();\nvoid wake_up_puller();\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor.cpp",
"new_path": "src/Module/Adaptor/Adaptor.cpp",
"diff": "@@ -6,6 +6,9 @@ using namespace aff3ct::module;\nAdaptor\n::~Adaptor()\n{\n+ for (auto b : this->buffer_to_free)\n+ delete[] b;\n+\n(*this->buffer)[this->id].clear();\n(*this->first)[this->id] = 0;\n(*this->last )[this->id] = 0;\n@@ -24,18 +27,22 @@ void Adaptor\nif (id == -1)\n{\nthis->id = this->buffer->size();\n- this->buffer->push_back(std::vector<std::vector<std::vector<int8_t>>>(this->n_sockets,\n- std::vector<std::vector<int8_t>>(this->buffer_size)));\n+ this->buffer->push_back(std::vector<std::vector<int8_t*>>(this->n_sockets,\n+ std::vector<int8_t*>(this->buffer_size)));\n}\nelse\n{\nthis->id = (size_t)id;\n- (*this->buffer)[this->id].resize(this->n_sockets, std::vector<std::vector<int8_t>>(this->buffer_size));\n+ (*this->buffer)[this->id].resize(this->n_sockets, std::vector<int8_t*>(this->buffer_size));\n}\n+ this->buffer_to_free.clear();\nfor (size_t s = 0; s < this->n_sockets; s++)\nfor (size_t b = 0; b < this->buffer_size; b++)\n- (*this->buffer)[this->id][s][b].resize(this->n_frames * this->n_bytes[s]);\n+ {\n+ (*this->buffer)[this->id][s][b] = new int8_t[this->n_frames * this->n_bytes[s]];\n+ this->buffer_to_free.push_back((*this->buffer)[this->id][s][b]);\n+ }\nif (this->id >= this->first->size())\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"new_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"diff": "@@ -121,13 +121,29 @@ void Adaptor_1_to_n\nvoid* Adaptor_1_to_n\n::get_empty_buffer(const size_t sid)\n{\n- return (void*)(*this->buffer)[this->cur_id][sid][(*this->last)[this->cur_id] % this->buffer_size].data();\n+ return (void*)(*this->buffer)[this->cur_id][sid][(*this->last)[this->cur_id] % this->buffer_size];\n}\nvoid* Adaptor_1_to_n\n::get_filled_buffer(const size_t sid)\n{\n- return (*this->buffer)[this->id][sid][(*this->first)[this->id] % this->buffer_size].data();\n+ return (void*)(*this->buffer)[this->id][sid][(*this->first)[this->id] % this->buffer_size];\n+}\n+\n+void* Adaptor_1_to_n\n+::get_empty_buffer(const size_t sid, void* swap_buffer)\n+{\n+ void* empty_buffer = (void*)(*this->buffer)[this->cur_id][sid][(*this->last)[this->cur_id] % this->buffer_size];\n+ (*this->buffer)[this->cur_id][sid][(*this->last)[this->cur_id] % this->buffer_size] = (int8_t*)swap_buffer;\n+ return empty_buffer;\n+}\n+\n+void* Adaptor_1_to_n\n+::get_filled_buffer(const size_t sid, void* swap_buffer)\n+{\n+ void* filled_buffer = (void*)(*this->buffer)[this->id][sid][(*this->first)[this->id] % this->buffer_size];\n+ (*this->buffer)[this->id][sid][(*this->first)[this->id] % this->buffer_size] = (int8_t*)swap_buffer;\n+ return filled_buffer;\n}\nvoid Adaptor_1_to_n\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"new_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"diff": "@@ -121,13 +121,29 @@ void Adaptor_n_to_1\nvoid* Adaptor_n_to_1\n::get_empty_buffer(const size_t sid)\n{\n- return (*this->buffer)[this->id][sid][(*this->last)[this->id] % this->buffer_size].data();\n+ return (void*)(*this->buffer)[this->id][sid][(*this->last)[this->id] % this->buffer_size];\n}\nvoid* Adaptor_n_to_1\n::get_filled_buffer(const size_t sid)\n{\n- return (*this->buffer)[this->cur_id][sid][(*this->first)[this->cur_id] % this->buffer_size].data();\n+ return (void*)(*this->buffer)[this->cur_id][sid][(*this->first)[this->cur_id] % this->buffer_size];\n+}\n+\n+void* Adaptor_n_to_1\n+::get_empty_buffer(const size_t sid, void* swap_buffer)\n+{\n+ void* empty_buffer = (void*)(*this->buffer)[this->id][sid][(*this->last)[this->id] % this->buffer_size];\n+ (*this->buffer)[this->id][sid][(*this->last)[this->id] % this->buffer_size] = (int8_t*)swap_buffer;\n+ return empty_buffer;\n+}\n+\n+void* Adaptor_n_to_1\n+::get_filled_buffer(const size_t sid, void* swap_buffer)\n+{\n+ void* filled_buffer = (void*)(*this->buffer)[this->cur_id][sid][(*this->first)[this->cur_id] % this->buffer_size];\n+ (*this->buffer)[this->cur_id][sid][(*this->first)[this->cur_id] % this->buffer_size] = (int8_t*)swap_buffer;\n+ return filled_buffer;\n}\nvoid Adaptor_n_to_1\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -367,11 +367,9 @@ void Chain\nThread_pinning::pin();\n}\n- const size_t n_threads = this->n_threads;\nconst bool no_copy_mode_adaptors = this->is_no_copy_mode_adaptors();\n-\nstd::function<void(Generic_node<Sub_sequence>*)> exec_sequence =\n- [&exec_sequence, n_threads, no_copy_mode_adaptors](Generic_node<Sub_sequence>* cur_ss)\n+ [&exec_sequence, no_copy_mode_adaptors](Generic_node<Sub_sequence>* cur_ss)\n{\nauto type = cur_ss->get_c()->type;\nauto &tasks = cur_ss->get_c()->tasks;\n@@ -383,208 +381,68 @@ void Chain\nstatic_cast<module::Loop&>(tasks[0]->get_module()).reset();\nexec_sequence(cur_ss->get_children()[1]);\n}\n- else if (type == subseq_t::FIRST_ADP && no_copy_mode_adaptors)\n- {\n- auto pull_task = tasks[0];\n- auto first_task = tasks[1];\n-\n- auto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\n- adp_pull->set_no_copy_pull(true);\n- size_t sin_id = 0;\n- std::vector<void*> dataptrs_in; // save the original pointers\n- pull_task->exec(); // active or passive waiting here\n- for (size_t s = 0; s < first_task->sockets.size(); s++)\n- {\n- if (first_task->get_socket_type(*first_task->sockets[s]) == module::socket_t::SIN)\n- {\n- dataptrs_in.push_back(first_task->sockets[s]->get_dataptr());\n- auto buff = adp_pull->get_filled_buffer(sin_id++);\n- first_task->sockets[s]->bind(buff);\n- }\n- }\n- first_task->exec();\n- adp_pull->wake_up_pusher();\n-\n- // revert the hack\n- adp_pull->set_no_copy_pull(false);\n- sin_id = 0;\n- for (size_t s = 0; s < first_task->sockets.size(); s++)\n- if (first_task->get_socket_type(*first_task->sockets[s]) == module::socket_t::SIN)\n- first_task->sockets[s]->bind(dataptrs_in[sin_id++]);\n-\n- for (size_t ta = 2; ta < tasks.size(); ta++)\n- tasks[ta]->exec();\n-\n- for (auto c : cur_ss->get_children())\n- exec_sequence(c);\n- }\n- else if (type == subseq_t::LAST_ADP && no_copy_mode_adaptors)\n- {\n- for (size_t ta = 0; ta < tasks.size() -2; ta++)\n- tasks[ta]->exec();\n-\n- auto last_task = tasks[tasks.size() -2];\n- auto push_task = tasks[tasks.size() -1];\n-\n- auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n- adp_push->set_no_copy_push(true);\n- size_t sout_id = 0;\n- std::vector<void*> dataptrs_out; // save the original pointers\n- push_task->exec(); // active or passive waiting here\n- for (size_t s = 0; s < last_task->sockets.size(); s++)\n- {\n- if (last_task->get_socket_type(*last_task->sockets[s]) == module::socket_t::SOUT)\n- {\n- dataptrs_out.push_back(last_task->sockets[s]->get_dataptr());\n- auto buff = adp_push->get_empty_buffer(sout_id++);\n- last_task->sockets[s]->bind(buff);\n- }\n- }\n- last_task->exec();\n- adp_push->wake_up_puller();\n-\n- // revert the hack\n- adp_push->set_no_copy_push(false);\n- sout_id = 0;\n- for (size_t s = 0; s < last_task->sockets.size(); s++)\n- if (last_task->get_socket_type(*last_task->sockets[s]) == module::socket_t::SOUT)\n- last_task->sockets[s]->bind(dataptrs_out[sout_id++]);\n-\n- for (auto c : cur_ss->get_children())\n- exec_sequence(c);\n- }\n- else if (type == subseq_t::FIRST_LAST_ADP && no_copy_mode_adaptors && tasks.size() == 3) // Gardner\n- {\n- auto pull_task = tasks[0];\n- auto task = tasks[1];\n- auto push_task = tasks[2];\n-\n- auto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\n- auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n- adp_pull->set_no_copy_pull(true);\n- adp_push->set_no_copy_push(true);\n- size_t sin_id = 0;\n- size_t sout_id = 0;\n- std::vector<void*> dataptrs_in; // save the original pointers\n- std::vector<void*> dataptrs_out; // save the original pointers\n- push_task->exec(); // active or passive waiting here\n- pull_task->exec(); // active or passive waiting here\n- for (size_t s = 0; s < task->sockets.size(); s++)\n- {\n- void* buff = nullptr;\n- switch (task->get_socket_type(*task->sockets[s]))\n- {\n- case module::socket_t::SIN:\n- dataptrs_in.push_back(task->sockets[s]->get_dataptr());\n- buff = adp_pull->get_filled_buffer(sin_id++);\n- break;\n- case module::socket_t::SOUT:\n- dataptrs_out.push_back(task->sockets[s]->get_dataptr());\n- buff = adp_push->get_empty_buffer(sout_id++);\n- break;\n- default:\n- break;\n- }\n-\n- task->sockets[s]->bind(buff);\n- }\n- task->exec();\n- adp_pull->wake_up_pusher();\n- adp_push->wake_up_puller();\n-\n- // revert the hack\n- adp_pull->set_no_copy_pull(false);\n- adp_push->set_no_copy_push(false);\n- sin_id = 0;\n- sout_id = 0;\n- for (size_t s = 0; s < task->sockets.size(); s++)\n- {\n- switch (task->get_socket_type(*task->sockets[s]))\n+ else\n{\n- case module::socket_t::SIN:\n- task->sockets[s]->bind(dataptrs_in[sin_id++]);\n- break;\n- case module::socket_t::SOUT:\n- task->sockets[s]->bind(dataptrs_out[sout_id++]);\n- break;\n- default:\n- break;\n- }\n- }\n+ size_t start_task = 0;\n+ size_t end_task = tasks.size();\n- for (auto c : cur_ss->get_children())\n- exec_sequence(c);\n- }\n- else if (type == subseq_t::FIRST_LAST_ADP && no_copy_mode_adaptors)\n+ if ((type == subseq_t::FIRST_ADP || type == subseq_t::FIRST_LAST_ADP) && no_copy_mode_adaptors)\n{\n- auto pull_task = tasks[0];\n- auto first_task = tasks[1];\n+ auto pull_task = tasks[start_task +0];\n+ auto first_task = tasks[start_task +1];\nauto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\nadp_pull->set_no_copy_pull(true);\nsize_t sin_id = 0;\n- std::vector<void*> dataptrs_in; // save the original pointers\npull_task->exec(); // active or passive waiting here\n-\nfor (size_t s = 0; s < first_task->sockets.size(); s++)\n- {\nif (first_task->get_socket_type(*first_task->sockets[s]) == module::socket_t::SIN)\n{\n- dataptrs_in.push_back(first_task->sockets[s]->get_dataptr());\n- auto buff = adp_pull->get_filled_buffer(sin_id++);\n+ auto buff = adp_pull->get_filled_buffer(sin_id++, first_task->sockets[s]->get_dataptr());\nfirst_task->sockets[s]->bind(buff);\n}\n- }\nfirst_task->exec();\nadp_pull->wake_up_pusher();\n+ start_task += 2;\n+ }\n- // revert the hack\n- adp_pull->set_no_copy_pull(false);\n- sin_id = 0;\n- for (size_t s = 0; s < first_task->sockets.size(); s++)\n- if (first_task->get_socket_type(*first_task->sockets[s]) == module::socket_t::SIN)\n- first_task->sockets[s]->bind(dataptrs_in[sin_id++]);\n+ if ((type == subseq_t::LAST_ADP || type == subseq_t::FIRST_LAST_ADP) && no_copy_mode_adaptors)\n+ end_task -= 2;\n- for (size_t ta = 2; ta < tasks.size() -2; ta++)\n+ for (size_t ta = start_task; ta < end_task; ta++)\ntasks[ta]->exec();\n- auto last_task = tasks[tasks.size() -2];\n- auto push_task = tasks[tasks.size() -1];\n+ if ((type == subseq_t::LAST_ADP || type == subseq_t::FIRST_LAST_ADP) && no_copy_mode_adaptors)\n+ {\n+ auto last_task = tasks[end_task +0];\n+ auto push_task = tasks[end_task +1];\nauto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\nadp_push->set_no_copy_push(true);\nsize_t sout_id = 0;\n- std::vector<void*> dataptrs_out; // save the original pointers\n+ // do not re-execute 'last_task' if 'last_task' and 'first_task' are the same task\n+ if (!(type == subseq_t::FIRST_LAST_ADP && tasks.size() <= 3))\n+ last_task->exec();\npush_task->exec(); // active or passive waiting here\nfor (size_t s = 0; s < last_task->sockets.size(); s++)\n- {\nif (last_task->get_socket_type(*last_task->sockets[s]) == module::socket_t::SOUT)\n{\n- dataptrs_out.push_back(last_task->sockets[s]->get_dataptr());\n- auto buff = adp_push->get_empty_buffer(sout_id++);\n+ auto buff = adp_push->get_empty_buffer(sout_id++, last_task->sockets[s]->get_dataptr());\nlast_task->sockets[s]->bind(buff);\n}\n- }\n- last_task->exec();\nadp_push->wake_up_puller();\n-\n- // revert the hack\n- adp_push->set_no_copy_push(false);\n- sout_id = 0;\n- for (size_t s = 0; s < last_task->sockets.size(); s++)\n- if (last_task->get_socket_type(*last_task->sockets[s]) == module::socket_t::SOUT)\n- last_task->sockets[s]->bind(dataptrs_out[sout_id++]);\n-\n- for (auto c : cur_ss->get_children())\n- exec_sequence(c);\n}\n- else /*if (type == subseq_t::STD)*/\n- {\n- for (size_t ta = 0; ta < tasks.size(); ta++)\n- tasks[ta]->exec();\n+\nfor (auto c : cur_ss->get_children())\nexec_sequence(c);\n}\n+ // else /*if (type == subseq_t::STD)*/\n+ // {\n+ // for (size_t ta = 0; ta < tasks.size(); ta++)\n+ // tasks[ta]->exec();\n+ // for (auto c : cur_ss->get_children())\n+ // exec_sequence(c);\n+ // }\n};\ntry\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Working zero copy adaptors.
|
8,490 |
06.02.2020 22:27:09
| 0 |
29a2a7f800ff4ca6e4a95f61e849138e8242bcfb
|
Improve the 0-copy adaptor mode and enable it by default.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hpp",
"new_path": "include/Module/Adaptor/Adaptor.hpp",
"diff": "@@ -38,7 +38,7 @@ namespace module\nclass Adaptor : public Module, public tools::Interface_waiting\n{\n-friend tools::Chain; // Chain is friend to enable the hack mode (0 copy)\n+friend tools::Chain; // Chain is friend to enable the no copy mode (0 copy)\nprotected:\nconst std::vector<size_t> n_elmts;\n@@ -83,10 +83,11 @@ protected:\ninline size_t n_free_slots(const size_t id);\ninline size_t n_fill_slots(const size_t id);\n- void set_no_copy_push(const bool hack_mode);\n- void set_no_copy_pull(const bool hack_mode);\n+ void set_no_copy_push(const bool no_copy_push);\n+ void set_no_copy_pull(const bool no_copy_pull);\nbool is_no_copy_push();\nbool is_no_copy_pull();\n+ void reset_buffer();\nvirtual void* get_empty_buffer(const size_t sid) = 0;\nvirtual void* get_filled_buffer(const size_t sid) = 0;\nvirtual void* get_empty_buffer(const size_t sid, void* swap_buffer) = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hxx",
"new_path": "include/Module/Adaptor/Adaptor.hxx",
"diff": "@@ -53,7 +53,7 @@ Adaptor\nfor (size_t s = 0; s < this->n_sockets; s++)\nfor (size_t b = 0; b < this->buffer_size; b++)\n- this->buffer_to_free.push_back((*this->buffer)[0][s][b]);\n+ this->buffer_to_free.push_back((*this->buffer)[this->id][s][b]);\nfor (auto &a : *this->first.get()) a = 0;\nfor (auto &a : *this->last .get()) a = 0;\n@@ -115,8 +115,8 @@ Adaptor\nfor (size_t s = 0; s < this->n_sockets; s++)\nfor (size_t b = 0; b < this->buffer_size; b++)\n{\n- (*this->buffer)[0][s][b] = new int8_t[this->n_frames * this->n_bytes[s]];\n- this->buffer_to_free.push_back((*this->buffer)[0][s][b]);\n+ (*this->buffer)[this->id][s][b] = new int8_t[this->n_frames * this->n_bytes[s]];\n+ this->buffer_to_free.push_back((*this->buffer)[this->id][s][b]);\n}\nfor (auto &a : *this->first.get()) a = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Sink/Sink.hpp",
"new_path": "include/Module/Sink/Sink.hpp",
"diff": "#include <memory>\n#include <vector>\n+#include \"Tools/Interface/Interface_reset.hpp\"\n#include \"Module/Task.hpp\"\n#include \"Module/Socket.hpp\"\n#include \"Module/Module.hpp\"\n@@ -36,7 +37,7 @@ namespace module\n*\n*/\ntemplate <typename B = int>\n-class Sink : public Module\n+class Sink : public Module, public tools::Interface_reset\n{\npublic:\ninline Task& operator[](const snk::tsk t);\n@@ -70,6 +71,8 @@ public:\nvirtual void send(const B *V, const int frame_id = -1);\n+ virtual void reset();\n+\nprotected:\nvirtual void _send(const B *V, const int frame_id);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Sink/Sink.hxx",
"new_path": "include/Module/Sink/Sink.hxx",
"diff": "@@ -89,5 +89,12 @@ void Sink<B>\nthrow tools::unimplemented_error(__FILE__, __LINE__, __func__);\n}\n+template <typename B>\n+void Sink<B>\n+::reset()\n+{\n+ // do nothing in the general case, this method has to be overrided\n+}\n+\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Sink/User/Sink_user_binary.hpp",
"new_path": "include/Module/Sink/User/Sink_user_binary.hpp",
"diff": "@@ -28,6 +28,7 @@ template <typename B = int>\nclass Sink_user_binary : public Sink<B>\n{\nprivate:\n+ const std::string filename;\nstd::ofstream sink_file;\nstd::vector<char> chunk;\nstd::vector<B> reconstructed_buffer;\n@@ -47,6 +48,8 @@ public:\n*/\n~Sink_user_binary() = default;\n+ virtual void reset();\n+\nprotected:\nvirtual void _send(const B *V, const int frame_id);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hpp",
"new_path": "include/Module/Socket.hpp",
"diff": "@@ -50,6 +50,7 @@ public:\ninline Task& get_task () const;\ninline const std::vector<Socket*> get_bound_sockets () const;\ninline const Socket& get_bound_socket () const;\n+ inline Socket& get_bound_socket ();\ninline void set_fast(const bool fast);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hxx",
"new_path": "include/Module/Socket.hxx",
"diff": "@@ -88,6 +88,18 @@ const std::vector<Socket*> Socket\nreturn this->bound_sockets;\n}\n+Socket& Socket\n+::get_bound_socket()\n+{\n+ if (this->bound_socket == nullptr)\n+ {\n+ std::stringstream message;\n+ message << \"bound_socket can't be nullptr.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ return *this->bound_socket;\n+}\n+\nconst Socket& Socket\n::get_bound_socket() const\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "#include <atomic>\n#include <mutex>\n+#include \"Module/Socket.hpp\"\n#include \"Tools/Interface/Interface_clone.hpp\"\n#include \"Tools/Algo/Tree/Generic/Generic_node.hpp\"\n@@ -34,9 +35,16 @@ class Sub_sequence_generic\npublic:\nsubseq_t type;\nVTA tasks;\n+ std::vector<std::function<int()>> processes;\nstd::vector<size_t> tasks_id;\nsize_t id;\n+ // usefull in case of adaptor to make zero copy and restore original states at the end of the chain execution\n+ std::vector<std::vector<module::Socket*>> rebind_in_sockets;\n+ std::vector<std::vector<void*>> rebind_in_dataptrs;\n+ std::vector<module::Socket*> rebind_out_sockets;\n+ std::vector<void*> rebind_out_dataptrs;\n+\nexplicit Sub_sequence_generic() : type(subseq_t::STD), id(0) {}\nvirtual ~Sub_sequence_generic() = default;\n};\n@@ -159,6 +167,9 @@ protected:\nvoid _exec_without_statuses(const size_t tid,\nstd::function<bool()> &stop_condition,\nGeneric_node<Sub_sequence>* sequence);\n+\n+ void gen_processes(const bool no_copy_mode_adaptors = false);\n+ void reset_no_copy_mode_adaptors();\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor.cpp",
"new_path": "src/Module/Adaptor/Adaptor.cpp",
"diff": "@@ -99,18 +99,22 @@ void Adaptor\n::reset()\n{\n*this->waiting_canceled = false;\n+ for (auto &a : *this->first.get()) a = 0;\n+ for (auto &a : *this->last .get()) a = 0;\n+ this->cur_id = 0;\n+ this->reset_buffer();\n}\nvoid Adaptor\n-::set_no_copy_pull(const bool hack_mode)\n+::set_no_copy_pull(const bool no_copy_pull)\n{\n- this->no_copy_pull = hack_mode;\n+ this->no_copy_pull = no_copy_pull;\n}\nvoid Adaptor\n-::set_no_copy_push(const bool hack_mode)\n+::set_no_copy_push(const bool no_copy_push)\n{\n- this->no_copy_push = hack_mode;\n+ this->no_copy_push = no_copy_push;\n}\nbool Adaptor\n@@ -124,3 +128,12 @@ bool Adaptor\n{\nreturn this->no_copy_push;\n}\n+\n+void Adaptor\n+::reset_buffer()\n+{\n+ size_t id_buff = 0;\n+ for (size_t s = 0; s < this->n_sockets; s++)\n+ for (size_t b = 0; b < this->buffer_size; b++)\n+ (*this->buffer)[this->id][s][b] = buffer_to_free[id_buff++];\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Sink/User/Sink_user_binary.cpp",
"new_path": "src/Module/Sink/User/Sink_user_binary.cpp",
"diff": "@@ -13,6 +13,7 @@ template <typename B>\nSink_user_binary<B>\n::Sink_user_binary(const int K, const std::string &filename, const int n_frames)\n: Sink<B>(K, n_frames),\n+ filename(filename),\nsink_file(filename.c_str(), std::ios::out | std::ios::binary),\nchunk(K),\nreconstructed_buffer(CHAR_BIT),\n@@ -37,6 +38,17 @@ Sink_user_binary<B>\n}\n}\n+template <typename B>\n+void Sink_user_binary<B>\n+::reset()\n+{\n+ sink_file.close();\n+ sink_file.open(this->filename.c_str(), std::ios::out | std::ios::binary);\n+ if (sink_file.fail())\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, \"Could not go back to the beginning of the file.\");\n+ this->n_left = 0;\n+}\n+\ntemplate <typename B>\nvoid Sink_user_binary<B>\n::_send(const B *V, const int frame_id)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -37,7 +37,7 @@ Chain\ntasks_inplace(false),\nthread_pinning(thread_pinning),\npuids(puids),\n- no_copy_mode_adaptors(false)\n+ no_copy_mode_adaptors(true)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first, &last);\n}\n@@ -58,7 +58,7 @@ Chain\ntasks_inplace(false),\nthread_pinning(thread_pinning),\npuids(puids),\n- no_copy_mode_adaptors(false)\n+ no_copy_mode_adaptors(true)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first);\n}\n@@ -81,7 +81,7 @@ Chain\ntasks_inplace(tasks_inplace),\nthread_pinning(thread_pinning),\npuids(puids),\n- no_copy_mode_adaptors(false)\n+ no_copy_mode_adaptors(true)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first, &last);\n@@ -106,7 +106,7 @@ Chain\ntasks_inplace(tasks_inplace),\nthread_pinning(false),\npuids(puids),\n- no_copy_mode_adaptors(false)\n+ no_copy_mode_adaptors(true)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first);\n@@ -170,6 +170,8 @@ void Chain\nthis->first_tasks[tid] = this->sequences[tid]->get_c()->tasks.front();\nthis->last_tasks[tid] = get_last(this->sequences[tid])->tasks.back();\n}\n+\n+ this->gen_processes();\n}\ntemplate void tools::Chain::init<tools::Sub_sequence_const, const module::Task>(const module::Task&, const module::Task*);\n@@ -290,18 +292,19 @@ void Chain\nauto type = cur_ss->get_c()->type;\nauto &tasks = cur_ss->get_c()->tasks;\nauto &tasks_id = cur_ss->get_c()->tasks_id;\n+ auto &processes = cur_ss->get_c()->processes;\nif (type == subseq_t::LOOP)\n{\n- while (!(statuses[tasks_id[0]] = tasks[0]->exec()))\n+ while (!(statuses[tasks_id[0]] = processes[0]()))\nexec_sequence(cur_ss->get_children()[0], statuses);\nstatic_cast<module::Loop&>(tasks[0]->get_module()).reset();\nexec_sequence(cur_ss->get_children()[1], statuses);\n}\nelse\n{\n- for (size_t ta = 0; ta < tasks.size(); ta++)\n- statuses[tasks_id[ta]] = tasks[ta]->exec();\n+ for (size_t p = 0; p < processes.size(); p++)\n+ statuses[tasks_id[p]] = processes[p]();\nfor (auto c : cur_ss->get_children())\nexec_sequence(c, statuses);\n}\n@@ -373,76 +376,22 @@ void Chain\n{\nauto type = cur_ss->get_c()->type;\nauto &tasks = cur_ss->get_c()->tasks;\n+ auto &processes = cur_ss->get_c()->processes;\nif (type == subseq_t::LOOP)\n{\n- while (!tasks[0]->exec())\n+ while (!processes[0]())\nexec_sequence(cur_ss->get_children()[0]);\nstatic_cast<module::Loop&>(tasks[0]->get_module()).reset();\nexec_sequence(cur_ss->get_children()[1]);\n}\nelse\n{\n- size_t start_task = 0;\n- size_t end_task = tasks.size();\n-\n- if ((type == subseq_t::FIRST_ADP || type == subseq_t::FIRST_LAST_ADP) && no_copy_mode_adaptors)\n- {\n- auto pull_task = tasks[start_task +0];\n- auto first_task = tasks[start_task +1];\n-\n- auto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\n- adp_pull->set_no_copy_pull(true);\n- size_t sin_id = 0;\n- pull_task->exec(); // active or passive waiting here\n- for (size_t s = 0; s < first_task->sockets.size(); s++)\n- if (first_task->get_socket_type(*first_task->sockets[s]) == module::socket_t::SIN)\n- {\n- auto buff = adp_pull->get_filled_buffer(sin_id++, first_task->sockets[s]->get_dataptr());\n- first_task->sockets[s]->bind(buff);\n- }\n- first_task->exec();\n- adp_pull->wake_up_pusher();\n- start_task += 2;\n- }\n-\n- if ((type == subseq_t::LAST_ADP || type == subseq_t::FIRST_LAST_ADP) && no_copy_mode_adaptors)\n- end_task -= 2;\n-\n- for (size_t ta = start_task; ta < end_task; ta++)\n- tasks[ta]->exec();\n-\n- if ((type == subseq_t::LAST_ADP || type == subseq_t::FIRST_LAST_ADP) && no_copy_mode_adaptors)\n- {\n- auto last_task = tasks[end_task +0];\n- auto push_task = tasks[end_task +1];\n-\n- auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n- adp_push->set_no_copy_push(true);\n- size_t sout_id = 0;\n- // do not re-execute 'last_task' if 'last_task' and 'first_task' are the same task\n- if (!(type == subseq_t::FIRST_LAST_ADP && tasks.size() <= 3))\n- last_task->exec();\n- push_task->exec(); // active or passive waiting here\n- for (size_t s = 0; s < last_task->sockets.size(); s++)\n- if (last_task->get_socket_type(*last_task->sockets[s]) == module::socket_t::SOUT)\n- {\n- auto buff = adp_push->get_empty_buffer(sout_id++, last_task->sockets[s]->get_dataptr());\n- last_task->sockets[s]->bind(buff);\n- }\n- adp_push->wake_up_puller();\n- }\n-\n+ for (auto &process : processes)\n+ process();\nfor (auto c : cur_ss->get_children())\nexec_sequence(c);\n}\n- // else /*if (type == subseq_t::STD)*/\n- // {\n- // for (size_t ta = 0; ta < tasks.size(); ta++)\n- // tasks[ta]->exec();\n- // for (auto c : cur_ss->get_children())\n- // exec_sequence(c);\n- // }\n};\ntry\n@@ -494,6 +443,9 @@ void Chain\nvoid Chain\n::exec(std::function<bool(const std::vector<int>&)> stop_condition)\n{\n+ if (this->is_no_copy_mode_adaptors())\n+ this->gen_processes(true);\n+\nstd::vector<std::thread> threads(n_threads);\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid] = std::thread(&Chain::_exec, this, tid, std::ref(stop_condition), std::ref(this->sequences[tid]));\n@@ -503,6 +455,12 @@ void Chain\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n+ if (this->is_no_copy_mode_adaptors())\n+ {\n+ this->gen_processes(false);\n+ this->reset_no_copy_mode_adaptors();\n+ }\n+\nif (!this->prev_exception_messages_to_display.empty())\n{\n*force_exit_loop = false;\n@@ -513,6 +471,9 @@ void Chain\nvoid Chain\n::exec(std::function<bool()> stop_condition)\n{\n+ if (this->is_no_copy_mode_adaptors())\n+ this->gen_processes(true);\n+\nstd::vector<std::thread> threads(n_threads);\nfor (size_t tid = 1; tid < n_threads; tid++)\n{\n@@ -525,6 +486,12 @@ void Chain\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n+ if (this->is_no_copy_mode_adaptors())\n+ {\n+ this->gen_processes(false);\n+ this->reset_no_copy_mode_adaptors();\n+ }\n+\nif (!this->prev_exception_messages_to_display.empty())\n{\n*force_exit_loop = false;\n@@ -659,7 +626,7 @@ const module::Task& Chain\ncur_subseq->get_c()->tasks.push_back(¤t_task);\ncur_subseq->get_c()->tasks_id.push_back(taid++);\n- // TAG sub-sequences with adaptors\n+ // tag sub-sequences with adaptors\nif (auto adp = dynamic_cast<const module::Adaptor*>(¤t_task.get_module()))\n{\nif (cur_subseq->get_c()->tasks.size() == 1)\n@@ -1050,20 +1017,208 @@ void Chain\nstream << \"}\" << std::endl;\n}\n-// void Chain\n-// ::set_no_copy_mode_adaptors(const bool hack_mode)\n-// {\n-// for (auto vm : this->all_modules)\n-// for (auto m : vm)\n-// {\n-// auto adp = dynamic_cast<module::Adaptor*>(m);\n-// if (adp)\n-// {\n-// adp->set_no_copy_push(hack_mode);\n-// adp->set_no_copy_pull(hack_mode);\n-// }\n-// }\n-// }\n+void Chain\n+::gen_processes(const bool no_copy_mode_adaptors)\n+{\n+ std::function<void(Generic_node<Sub_sequence>*)> gen_processes_recursive =\n+ [&gen_processes_recursive, no_copy_mode_adaptors](Generic_node<Sub_sequence>* cur_node)\n+ {\n+ if (cur_node != nullptr)\n+ {\n+ auto contents = cur_node->get_c();\n+ contents->processes.clear();\n+ std::set<module::Task*> skipped_tasks;\n+\n+ if ((contents->type == subseq_t::FIRST_ADP || contents->type == subseq_t::FIRST_LAST_ADP) &&\n+ no_copy_mode_adaptors)\n+ {\n+ auto pull_task = contents->tasks[0];\n+ skipped_tasks.insert(pull_task);\n+ auto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\n+ adp_pull->set_no_copy_pull(true);\n+ contents->rebind_in_sockets.clear();\n+ contents->rebind_in_dataptrs.clear();\n+\n+ for (size_t s = 0; s < pull_task->sockets.size(); s++)\n+ if (pull_task->get_socket_type(*pull_task->sockets[s]) == module::socket_t::SOUT)\n+ {\n+ auto bound_sockets = pull_task->sockets[s]->get_bound_sockets();\n+ std::vector<void*> dataptrs;\n+ for (auto s : bound_sockets)\n+ {\n+ skipped_tasks.insert(&s->get_task());\n+ dataptrs.push_back(s->get_dataptr());\n+ }\n+ contents->rebind_in_sockets.push_back(bound_sockets);\n+ contents->rebind_in_dataptrs.push_back(dataptrs);\n+ }\n+\n+ contents->processes.push_back([contents, pull_task, adp_pull]() -> int\n+ {\n+ // active or passive waiting here\n+ int ret = pull_task->exec();\n+ // rebind input sockets on the fly\n+ for (size_t sin_id = 0; sin_id < contents->rebind_in_sockets.size(); sin_id++)\n+ {\n+ auto swap_buff = contents->rebind_in_sockets[sin_id][0]->get_dataptr();\n+ auto buff = adp_pull->get_filled_buffer(sin_id, swap_buff);\n+ contents->rebind_in_sockets[sin_id][0]->bind(buff);\n+ // for the next tasks the same buffer 'buff' is required, an easy mistake is to re-swap and\n+ // the data will be false, this is why we just bind 'buff'\n+ for (size_t ta = 1; ta < contents->rebind_in_sockets[sin_id].size(); ta++)\n+ contents->rebind_in_sockets[sin_id][ta]->bind(buff);\n+ }\n+ return ret;\n+ });\n+\n+ for (size_t s = 0; s < contents->rebind_in_sockets[0].size(); s++)\n+ {\n+ auto cur_task = &contents->rebind_in_sockets[0][s]->get_task();\n+ if (s < contents->rebind_in_sockets[0].size() -1)\n+ {\n+ contents->processes.push_back([cur_task]() -> int\n+ {\n+ return cur_task->exec();\n+ });\n+ }\n+ else\n+ {\n+ // trick to avoid to have a additionally process: we include the 'wake_up_pusher' method\n+ // after the last task execution, this way we have the same number of tasks and processes\n+ contents->processes.push_back([cur_task, adp_pull]() -> int\n+ {\n+ auto ret = cur_task->exec();\n+ adp_pull->wake_up_pusher();\n+ return ret;\n+ });\n+ }\n+ }\n+ }\n+\n+ if ((contents->type == subseq_t::LAST_ADP || contents->type == subseq_t::FIRST_LAST_ADP) &&\n+ no_copy_mode_adaptors)\n+ {\n+ auto push_task = contents->tasks[contents->tasks.size() -1];\n+ skipped_tasks.insert(push_task);\n+ auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n+ adp_push->set_no_copy_push(true);\n+ contents->rebind_out_sockets.clear();\n+ contents->rebind_out_dataptrs.clear();\n+\n+ for (size_t s = 0; s < push_task->sockets.size(); s++)\n+ if (push_task->get_socket_type(*push_task->sockets[s]) == module::socket_t::SIN)\n+ {\n+ auto bound_socket = &push_task->sockets[s]->get_bound_socket();\n+\n+ skipped_tasks.insert(&bound_socket->get_task());\n+ void* dataptr = bound_socket->get_dataptr();\n+\n+ contents->rebind_out_sockets.push_back(bound_socket);\n+ contents->rebind_out_dataptrs.push_back(dataptr);\n+ }\n+ }\n+\n+ for (size_t ta = 0; ta < contents->tasks.size(); ta++)\n+ if (!skipped_tasks.count(contents->tasks[ta]))\n+ {\n+ auto cur_task = contents->tasks[ta];\n+ contents->processes.push_back([cur_task]() -> int\n+ {\n+ return cur_task->exec();\n+ });\n+ }\n+\n+ if ((contents->type == subseq_t::LAST_ADP || contents->type == subseq_t::FIRST_LAST_ADP) &&\n+ no_copy_mode_adaptors)\n+ {\n+ auto push_task = contents->tasks[contents->tasks.size() -1];\n+ auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n+\n+ const bool should_not_execute_task = contents->type == subseq_t::FIRST_LAST_ADP &&\n+ contents->tasks.size() <= 3;\n+\n+ // do not execute the task if the task has been executed before\n+ if (!should_not_execute_task)\n+ {\n+ auto cur_task = &contents->rebind_out_sockets[0]->get_task();\n+ contents->processes.push_back([cur_task]() -> int\n+ {\n+ return cur_task->exec();\n+ });\n+ }\n+\n+ contents->processes.push_back([contents, push_task, adp_push]() -> int\n+ {\n+ // active or passive waiting here\n+ auto ret = push_task->exec();\n+ // rebind output sockets on the fly\n+ for (size_t sout_id = 0; sout_id < contents->rebind_out_sockets.size(); sout_id++)\n+ {\n+ auto swap_buff = contents->rebind_out_sockets[sout_id]->get_dataptr();\n+ auto buff = adp_push->get_empty_buffer(sout_id, swap_buff);\n+ contents->rebind_out_sockets[sout_id]->bind(buff);\n+ }\n+ adp_push->wake_up_puller();\n+ return ret;\n+ });\n+ }\n+\n+ for (auto c : cur_node->get_children())\n+ gen_processes_recursive(c);\n+ }\n+ };\n+\n+ size_t thread_id = 0;\n+ for (auto &sequence : this->sequences)\n+ {\n+ if (this->is_thread_pinning())\n+ {\n+ if (thread_id < this->puids.size())\n+ Thread_pinning::pin(this->puids[thread_id++]);\n+ else\n+ Thread_pinning::pin();\n+ }\n+\n+ gen_processes_recursive(sequence);\n+ }\n+}\n+\n+void Chain\n+::reset_no_copy_mode_adaptors()\n+{\n+ std::function<void(Generic_node<Sub_sequence>*)> reset_no_copy_mode_recursive =\n+ [&reset_no_copy_mode_recursive](Generic_node<Sub_sequence>* cur_node)\n+ {\n+ if (cur_node != nullptr)\n+ {\n+ auto contents = cur_node->get_c();\n+\n+ if (contents->type == subseq_t::FIRST_ADP || contents->type == subseq_t::FIRST_LAST_ADP)\n+ {\n+ auto pull_task = contents->tasks[0];\n+ auto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\n+ adp_pull->set_no_copy_pull(false);\n+ adp_pull->reset_buffer();\n+ for (size_t s = 0; s < contents->rebind_in_sockets.size(); s++)\n+ for (size_t ta = 0; ta < contents->rebind_in_sockets[s].size(); ta++)\n+ contents->rebind_in_sockets[s][ta]->bind(contents->rebind_in_dataptrs[s][ta]);\n+ }\n+\n+ if (contents->type == subseq_t::LAST_ADP || contents->type == subseq_t::FIRST_LAST_ADP)\n+ {\n+ auto push_task = contents->tasks[contents->tasks.size() -1];\n+ auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n+ adp_push->set_no_copy_push(false);\n+ adp_push->reset_buffer();\n+ for (size_t s = 0; s < contents->rebind_out_sockets.size(); s++)\n+ contents->rebind_out_sockets[s]->bind(contents->rebind_out_dataptrs[s]);\n+ }\n+ }\n+ };\n+\n+ for (auto &sequence : this->sequences)\n+ reset_no_copy_mode_recursive(sequence);\n+}\nvoid Chain\n::set_no_copy_mode_adaptors(const bool no_copy_mode)\n@@ -1076,3 +1231,4 @@ bool Chain\n{\nreturn this->no_copy_mode_adaptors;\n}\n+\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve the 0-copy adaptor mode and enable it by default.
|
8,488 |
07.02.2020 10:30:22
| -3,600 |
cb3ca94ae1077024fabab82fa117a7611e6ad051
|
Fix BEC frozen bits generator.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_BEC.cpp",
"new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_BEC.cpp",
"diff": "@@ -34,28 +34,23 @@ void Frozenbits_generator_BEC\n{\nthis->check_noise();\n- for (unsigned i = 0; i != this->best_channels.size(); i++)\n- this->best_channels[i] = i;\n+ std::iota(this->best_channels.begin(), this->best_channels.end(), 0);\n- for (auto i = 0; i < std::exp2(m); i++)\n- z[i] = static_cast<double>(this->noise->get_value());\n+ z[0] = std::log(static_cast<double>(this->noise->get_value()));\nfor (auto l = 1; l <= m; l++)\n{\n- auto o1 = (int)std::exp2(m - l +1);\n- auto o2 = (int)std::exp2(m - l );\n-\n- for (auto t = 0; t < (int)std::exp2(l -1); t++)\n+ auto b = exp2(l);\n+ auto stride = N / b;\n+ for (auto j = 0; j < b / 2; j++)\n{\n- double T = z[t * o1];\n-\n- z[t * o1] = T * T;\n-\n- z[t * o1 + o2] = 2 * T - T * T ;\n+ auto t = z[j * 2 * stride ];\n+ z[j * 2 * stride ] = std::log(2) + t + std::log1p(- std::exp(2 * t - (std::log(2) + t)));\n+ z[j * 2 * stride + stride] = 2 * t;\n}\n}\n- std::sort(this->best_channels.begin(), this->best_channels.end(), [this](int i1, int i2) { return z[i1] > z[i2]; });\n+ std::sort(this->best_channels.begin(), this->best_channels.end(), [this](int i1, int i2) { return z[i1] < z[i2]; });\n}\nvoid Frozenbits_generator_BEC\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix BEC frozen bits generator.
|
8,490 |
07.02.2020 17:22:53
| 0 |
81c5c5baf05a09e32e689922f30f44f429d690c9
|
Improve processes management in the chain.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -1023,17 +1023,16 @@ void Chain\nstd::function<void(Generic_node<Sub_sequence>*)> gen_processes_recursive =\n[&gen_processes_recursive, no_copy_mode_adaptors](Generic_node<Sub_sequence>* cur_node)\n{\n+ std::map<module::Task*, std::function<int()>> modified_tasks;\nif (cur_node != nullptr)\n{\nauto contents = cur_node->get_c();\ncontents->processes.clear();\n- std::set<module::Task*> skipped_tasks;\nif ((contents->type == subseq_t::FIRST_ADP || contents->type == subseq_t::FIRST_LAST_ADP) &&\nno_copy_mode_adaptors)\n{\nauto pull_task = contents->tasks[0];\n- skipped_tasks.insert(pull_task);\nauto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\nadp_pull->set_no_copy_pull(true);\ncontents->rebind_in_sockets.clear();\n@@ -1045,15 +1044,12 @@ void Chain\nauto bound_sockets = pull_task->sockets[s]->get_bound_sockets();\nstd::vector<void*> dataptrs;\nfor (auto s : bound_sockets)\n- {\n- skipped_tasks.insert(&s->get_task());\ndataptrs.push_back(s->get_dataptr());\n- }\ncontents->rebind_in_sockets.push_back(bound_sockets);\ncontents->rebind_in_dataptrs.push_back(dataptrs);\n}\n- contents->processes.push_back([contents, pull_task, adp_pull]() -> int\n+ modified_tasks[pull_task] = [contents, pull_task, adp_pull]() -> int\n{\n// active or passive waiting here\nint ret = pull_task->exec();\n@@ -1068,38 +1064,15 @@ void Chain\nfor (size_t ta = 1; ta < contents->rebind_in_sockets[sin_id].size(); ta++)\ncontents->rebind_in_sockets[sin_id][ta]->bind(buff);\n}\n- return ret;\n- });\n-\n- for (size_t s = 0; s < contents->rebind_in_sockets[0].size(); s++)\n- {\n- auto cur_task = &contents->rebind_in_sockets[0][s]->get_task();\n- if (s < contents->rebind_in_sockets[0].size() -1)\n- {\n- contents->processes.push_back([cur_task]() -> int\n- {\n- return cur_task->exec();\n- });\n- }\n- else\n- {\n- // trick to avoid to have a additionally process: we include the 'wake_up_pusher' method\n- // after the last task execution, this way we have the same number of tasks and processes\n- contents->processes.push_back([cur_task, adp_pull]() -> int\n- {\n- auto ret = cur_task->exec();\nadp_pull->wake_up_pusher();\nreturn ret;\n- });\n- }\n- }\n+ };\n}\nif ((contents->type == subseq_t::LAST_ADP || contents->type == subseq_t::FIRST_LAST_ADP) &&\nno_copy_mode_adaptors)\n{\nauto push_task = contents->tasks[contents->tasks.size() -1];\n- skipped_tasks.insert(push_task);\nauto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\nadp_push->set_no_copy_push(true);\ncontents->rebind_out_sockets.clear();\n@@ -1109,45 +1082,12 @@ void Chain\nif (push_task->get_socket_type(*push_task->sockets[s]) == module::socket_t::SIN)\n{\nauto bound_socket = &push_task->sockets[s]->get_bound_socket();\n-\n- skipped_tasks.insert(&bound_socket->get_task());\nvoid* dataptr = bound_socket->get_dataptr();\n-\ncontents->rebind_out_sockets.push_back(bound_socket);\ncontents->rebind_out_dataptrs.push_back(dataptr);\n}\n- }\n- for (size_t ta = 0; ta < contents->tasks.size(); ta++)\n- if (!skipped_tasks.count(contents->tasks[ta]))\n- {\n- auto cur_task = contents->tasks[ta];\n- contents->processes.push_back([cur_task]() -> int\n- {\n- return cur_task->exec();\n- });\n- }\n-\n- if ((contents->type == subseq_t::LAST_ADP || contents->type == subseq_t::FIRST_LAST_ADP) &&\n- no_copy_mode_adaptors)\n- {\n- auto push_task = contents->tasks[contents->tasks.size() -1];\n- auto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\n-\n- const bool should_not_execute_task = contents->type == subseq_t::FIRST_LAST_ADP &&\n- contents->tasks.size() <= 3;\n-\n- // do not execute the task if the task has been executed before\n- if (!should_not_execute_task)\n- {\n- auto cur_task = &contents->rebind_out_sockets[0]->get_task();\n- contents->processes.push_back([cur_task]() -> int\n- {\n- return cur_task->exec();\n- });\n- }\n-\n- contents->processes.push_back([contents, push_task, adp_push]() -> int\n+ modified_tasks[push_task] = [contents, push_task, adp_push]() -> int\n{\n// active or passive waiting here\nauto ret = push_task->exec();\n@@ -1160,6 +1100,18 @@ void Chain\n}\nadp_push->wake_up_puller();\nreturn ret;\n+ };\n+ }\n+\n+ for (size_t ta = 0; ta < contents->tasks.size(); ta++)\n+ {\n+ auto cur_task = contents->tasks[ta];\n+ if (modified_tasks.count(cur_task))\n+ contents->processes.push_back(modified_tasks[cur_task]);\n+ else\n+ contents->processes.push_back([cur_task]() -> int\n+ {\n+ return cur_task->exec();\n});\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve processes management in the chain.
|
8,490 |
08.02.2020 10:44:02
| -3,600 |
8dd63fa4f8354fefb757642f652342357ee8b541
|
Simplify the zero copy mode for adaptors in the chain.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -27,7 +27,7 @@ class Module;\nnamespace tools\n{\n-enum class subseq_t : size_t { STD, LOOP, ROUTER, FIRST_ADP, LAST_ADP, FIRST_LAST_ADP };\n+enum class subseq_t : size_t { STD, LOOP, ROUTER };\ntemplate <class VTA = std::vector<module::Task*>>\nclass Sub_sequence_generic\n@@ -40,10 +40,10 @@ public:\nsize_t id;\n// usefull in case of adaptor to make zero copy and restore original states at the end of the chain execution\n- std::vector<std::vector<module::Socket*>> rebind_in_sockets;\n- std::vector<std::vector<void*>> rebind_in_dataptrs;\n- std::vector<module::Socket*> rebind_out_sockets;\n- std::vector<void*> rebind_out_dataptrs;\n+ std::vector<std::vector<std::vector<module::Socket*>>> rebind_in_sockets;\n+ std::vector<std::vector<std::vector<void*>>> rebind_in_dataptrs;\n+ std::vector<std::vector<module::Socket*>> rebind_out_sockets;\n+ std::vector<std::vector<void*>> rebind_out_dataptrs;\nexplicit Sub_sequence_generic() : type(subseq_t::STD), id(0) {}\nvirtual ~Sub_sequence_generic() = default;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -457,8 +457,8 @@ void Chain\nif (this->is_no_copy_mode_adaptors())\n{\n- this->gen_processes(false);\nthis->reset_no_copy_mode_adaptors();\n+ this->gen_processes(false);\n}\nif (!this->prev_exception_messages_to_display.empty())\n@@ -488,8 +488,8 @@ void Chain\nif (this->is_no_copy_mode_adaptors())\n{\n- this->gen_processes(false);\nthis->reset_no_copy_mode_adaptors();\n+ this->gen_processes(false);\n}\nif (!this->prev_exception_messages_to_display.empty())\n@@ -626,22 +626,6 @@ const module::Task& Chain\ncur_subseq->get_c()->tasks.push_back(¤t_task);\ncur_subseq->get_c()->tasks_id.push_back(taid++);\n- // tag sub-sequences with adaptors\n- if (auto adp = dynamic_cast<const module::Adaptor*>(¤t_task.get_module()))\n- {\n- if (cur_subseq->get_c()->tasks.size() == 1)\n- {\n- cur_subseq->get_c()->type = subseq_t::FIRST_ADP;\n- }\n- else\n- {\n- if (cur_subseq->get_c()->type == subseq_t::FIRST_ADP)\n- cur_subseq->get_c()->type = subseq_t::FIRST_LAST_ADP;\n- else\n- cur_subseq->get_c()->type = subseq_t::LAST_ADP;\n- }\n- }\n-\nif (¤t_task != last)\n{\nfor (auto &s : current_task.sockets)\n@@ -1023,20 +1007,26 @@ void Chain\nstd::function<void(Generic_node<Sub_sequence>*)> gen_processes_recursive =\n[&gen_processes_recursive, no_copy_mode_adaptors](Generic_node<Sub_sequence>* cur_node)\n{\n- std::map<module::Task*, std::function<int()>> modified_tasks;\nif (cur_node != nullptr)\n{\n+ std::map<module::Task*, std::function<int()>> modified_tasks;\nauto contents = cur_node->get_c();\ncontents->processes.clear();\n-\n- if ((contents->type == subseq_t::FIRST_ADP || contents->type == subseq_t::FIRST_LAST_ADP) &&\n- no_copy_mode_adaptors)\n+ contents->rebind_in_sockets.clear();\n+ contents->rebind_in_dataptrs.clear();\n+ contents->rebind_out_sockets.clear();\n+ contents->rebind_out_dataptrs.clear();\n+ for (auto task : contents->tasks)\n+ {\n+ if (dynamic_cast<module::Adaptor*>(&task->get_module()) &&\n+ task->get_name().find(\"pull\") != std::string::npos && no_copy_mode_adaptors)\n{\n- auto pull_task = contents->tasks[0];\n+ auto pull_task = task;\nauto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\nadp_pull->set_no_copy_pull(true);\n- contents->rebind_in_sockets.clear();\n- contents->rebind_in_dataptrs.clear();\n+ const auto cur_adp_pull = contents->rebind_in_sockets.size();\n+ contents->rebind_in_sockets.resize(cur_adp_pull +1);\n+ contents->rebind_in_dataptrs.resize(cur_adp_pull +1);\nfor (size_t s = 0; s < pull_task->sockets.size(); s++)\nif (pull_task->get_socket_type(*pull_task->sockets[s]) == module::socket_t::SOUT)\n@@ -1044,76 +1034,94 @@ void Chain\nauto bound_sockets = pull_task->sockets[s]->get_bound_sockets();\nstd::vector<void*> dataptrs;\nfor (auto s : bound_sockets)\n+ {\n+ if (s->get_task().get_socket_type(*s) == module::socket_t::SIN_SOUT)\n+ {\n+ std::stringstream message;\n+ message << \"'SIN_SOUT' socket type is unsupported at this time (\"\n+ << \"'s->get_name()' = \" << s->get_name() << \", \"\n+ << \"'s->get_task().get_name()' = .\" << s->get_task().get_name() << \".)\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\ndataptrs.push_back(s->get_dataptr());\n- contents->rebind_in_sockets.push_back(bound_sockets);\n- contents->rebind_in_dataptrs.push_back(dataptrs);\n+ }\n+ contents->rebind_in_sockets[cur_adp_pull].push_back(bound_sockets);\n+ contents->rebind_in_dataptrs[cur_adp_pull].push_back(dataptrs);\n}\n- modified_tasks[pull_task] = [contents, pull_task, adp_pull]() -> int\n+ modified_tasks[pull_task] = [contents, pull_task, adp_pull, cur_adp_pull]() -> int\n{\n// active or passive waiting here\nint ret = pull_task->exec();\n// rebind input sockets on the fly\n- for (size_t sin_id = 0; sin_id < contents->rebind_in_sockets.size(); sin_id++)\n+ for (size_t sin_id = 0; sin_id < contents->rebind_in_sockets[cur_adp_pull].size(); sin_id++)\n{\n- auto swap_buff = contents->rebind_in_sockets[sin_id][0]->get_dataptr();\n+ auto swap_buff = contents->rebind_in_sockets[cur_adp_pull][sin_id][0]->get_dataptr();\nauto buff = adp_pull->get_filled_buffer(sin_id, swap_buff);\n- contents->rebind_in_sockets[sin_id][0]->bind(buff);\n- // for the next tasks the same buffer 'buff' is required, an easy mistake is to re-swap and\n- // the data will be false, this is why we just bind 'buff'\n- for (size_t ta = 1; ta < contents->rebind_in_sockets[sin_id].size(); ta++)\n- contents->rebind_in_sockets[sin_id][ta]->bind(buff);\n+ contents->rebind_in_sockets[cur_adp_pull][sin_id][0]->bind(buff);\n+ // for the next tasks the same buffer 'buff' is required, an easy mistake is to re-swap\n+ // and the data will be false, this is why we just bind 'buff'\n+ for (size_t ta = 1; ta < contents->rebind_in_sockets[cur_adp_pull][sin_id].size(); ta++)\n+ contents->rebind_in_sockets[cur_adp_pull][sin_id][ta]->bind(buff);\n}\nadp_pull->wake_up_pusher();\nreturn ret;\n};\n}\n- if ((contents->type == subseq_t::LAST_ADP || contents->type == subseq_t::FIRST_LAST_ADP) &&\n- no_copy_mode_adaptors)\n+ if (dynamic_cast<module::Adaptor*>(&task->get_module()) &&\n+ task->get_name().find(\"push\") != std::string::npos && no_copy_mode_adaptors)\n{\n- auto push_task = contents->tasks[contents->tasks.size() -1];\n+ auto push_task = task;\nauto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\nadp_push->set_no_copy_push(true);\n- contents->rebind_out_sockets.clear();\n- contents->rebind_out_dataptrs.clear();\n+ const auto cur_adp_push = contents->rebind_out_sockets.size();\n+ contents->rebind_out_sockets.resize(cur_adp_push +1);\n+ contents->rebind_out_dataptrs.resize(cur_adp_push +1);\nfor (size_t s = 0; s < push_task->sockets.size(); s++)\nif (push_task->get_socket_type(*push_task->sockets[s]) == module::socket_t::SIN)\n{\nauto bound_socket = &push_task->sockets[s]->get_bound_socket();\n+ if (bound_socket->get_task().get_socket_type(*bound_socket) ==\n+ module::socket_t::SIN_SOUT)\n+ {\n+ std::stringstream message;\n+ message << \"'SIN_SOUT' socket type is unsupported at this time (\"\n+ << \"'bound_socket->get_name()' = \" << bound_socket->get_name() << \", \"\n+ << \"'bound_socket->get_task().get_name()' = .\"\n+ << bound_socket->get_task().get_name() << \".)\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nvoid* dataptr = bound_socket->get_dataptr();\n- contents->rebind_out_sockets.push_back(bound_socket);\n- contents->rebind_out_dataptrs.push_back(dataptr);\n+ contents->rebind_out_sockets[cur_adp_push].push_back(bound_socket);\n+ contents->rebind_out_dataptrs[cur_adp_push].push_back(dataptr);\n}\n- modified_tasks[push_task] = [contents, push_task, adp_push]() -> int\n+ modified_tasks[push_task] = [contents, push_task, adp_push, cur_adp_push]() -> int\n{\n// active or passive waiting here\nauto ret = push_task->exec();\n// rebind output sockets on the fly\n- for (size_t sout_id = 0; sout_id < contents->rebind_out_sockets.size(); sout_id++)\n+ for (size_t sout_id = 0; sout_id < contents->rebind_out_sockets[cur_adp_push].size();\n+ sout_id++)\n{\n- auto swap_buff = contents->rebind_out_sockets[sout_id]->get_dataptr();\n+ auto swap_buff = contents->rebind_out_sockets[cur_adp_push][sout_id]->get_dataptr();\nauto buff = adp_push->get_empty_buffer(sout_id, swap_buff);\n- contents->rebind_out_sockets[sout_id]->bind(buff);\n+ contents->rebind_out_sockets[cur_adp_push][sout_id]->bind(buff);\n}\nadp_push->wake_up_puller();\nreturn ret;\n};\n}\n+ }\n- for (size_t ta = 0; ta < contents->tasks.size(); ta++)\n- {\n- auto cur_task = contents->tasks[ta];\n- if (modified_tasks.count(cur_task))\n- contents->processes.push_back(modified_tasks[cur_task]);\n+ for (auto task : contents->tasks)\n+ if (modified_tasks.count(task))\n+ contents->processes.push_back(modified_tasks[task]);\nelse\n- contents->processes.push_back([cur_task]() -> int\n- {\n- return cur_task->exec();\n- });\n- }\n+ contents->processes.push_back([task]() -> int { return task->exec(); });\nfor (auto c : cur_node->get_children())\ngen_processes_recursive(c);\n@@ -1144,32 +1152,46 @@ void Chain\nif (cur_node != nullptr)\n{\nauto contents = cur_node->get_c();\n-\n- if (contents->type == subseq_t::FIRST_ADP || contents->type == subseq_t::FIRST_LAST_ADP)\n+ for (auto task : contents->tasks)\n+ {\n+ if (dynamic_cast<module::Adaptor*>(&task->get_module()) &&\n+ task->get_name().find(\"pull\") != std::string::npos)\n{\n- auto pull_task = contents->tasks[0];\n+ auto pull_task = task;\nauto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\nadp_pull->set_no_copy_pull(false);\nadp_pull->reset_buffer();\n- for (size_t s = 0; s < contents->rebind_in_sockets.size(); s++)\n- for (size_t ta = 0; ta < contents->rebind_in_sockets[s].size(); ta++)\n- contents->rebind_in_sockets[s][ta]->bind(contents->rebind_in_dataptrs[s][ta]);\n}\n- if (contents->type == subseq_t::LAST_ADP || contents->type == subseq_t::FIRST_LAST_ADP)\n+ if (dynamic_cast<module::Adaptor*>(&task->get_module()) &&\n+ task->get_name().find(\"push\") != std::string::npos)\n{\n- auto push_task = contents->tasks[contents->tasks.size() -1];\n+ auto push_task = task;\nauto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\nadp_push->set_no_copy_push(false);\nadp_push->reset_buffer();\n- for (size_t s = 0; s < contents->rebind_out_sockets.size(); s++)\n- contents->rebind_out_sockets[s]->bind(contents->rebind_out_dataptrs[s]);\n}\n}\n+\n+ for (size_t adp_pull = 0; adp_pull < contents->rebind_in_sockets.size(); adp_pull++)\n+ for (size_t s = 0; s < contents->rebind_in_sockets[adp_pull].size(); s++)\n+ for (size_t ta = 0; ta < contents->rebind_in_sockets[adp_pull][s].size(); ta++)\n+ contents->rebind_in_sockets[adp_pull][s][ta]\n+ ->bind(contents->rebind_in_dataptrs[adp_pull][s][ta]);\n+\n+ for (size_t adp_push = 0; adp_push < contents->rebind_out_sockets.size(); adp_push++)\n+ for (size_t s = 0; s < contents->rebind_out_sockets[adp_push].size(); s++)\n+ contents->rebind_out_sockets[adp_push][s]\n+ ->bind(contents->rebind_out_dataptrs[adp_push][s]);\n+ }\n+\n+ for (auto c : cur_node->get_children())\n+ reset_no_copy_mode_recursive(c);\n};\nfor (auto &sequence : this->sequences)\nreset_no_copy_mode_recursive(sequence);\n+\n}\nvoid Chain\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simplify the zero copy mode for adaptors in the chain.
|
8,490 |
08.02.2020 16:28:05
| -3,600 |
de15a1bd9d5e73619d812c7863e9a5d915406767
|
Improve 0-copy mode in the chain + fix segfaults and debug mode.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hxx",
"new_path": "include/Module/Adaptor/Adaptor.hxx",
"diff": "@@ -25,8 +25,7 @@ Adaptor\ncur_id(0),\nbuffer(new std::vector<std::vector<std::vector<int8_t*>>>\n(1, std::vector<std::vector<int8_t*>>(1,\n- std::vector<int8_t*>(buffer_size,\n- new int8_t[n_frames * this->n_bytes[0]])))),\n+ std::vector<int8_t*>(buffer_size)))),\nfirst(new std::vector<std::atomic<size_t>>(1000)),\nlast(new std::vector<std::atomic<size_t>>(1000)),\nwaiting_canceled(new std::atomic<bool>(false)),\n@@ -53,7 +52,10 @@ Adaptor\nfor (size_t s = 0; s < this->n_sockets; s++)\nfor (size_t b = 0; b < this->buffer_size; b++)\n+ {\n+ (*this->buffer)[this->id][s][b] = new int8_t[this->n_frames * this->n_bytes[s]];\nthis->buffer_to_free.push_back((*this->buffer)[this->id][s][b]);\n+ }\nfor (auto &a : *this->first.get()) a = 0;\nfor (auto &a : *this->last .get()) a = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hpp",
"diff": "@@ -60,6 +60,8 @@ protected:\nvirtual void push_1(const std::vector<const int8_t*> &in, const int frame_id = -1);\nvirtual void pull_n(const std::vector< int8_t*> &out, const int frame_id = -1);\n+ void wait_push();\n+ void wait_pull();\nvoid* get_empty_buffer(const size_t sid);\nvoid* get_filled_buffer(const size_t sid);\nvoid* get_empty_buffer(const size_t sid, void* swap_buffer);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"diff": "@@ -106,12 +106,22 @@ void Adaptor_1_to_n\np1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s], \"in\" + std::to_string(s)));\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n+ {\n+ auto &adp = static_cast<Adaptor_1_to_n&>(m);\n+ if (adp.is_no_copy_push())\n+ {\n+ adp.wait_push();\n+ // for debug mode coherence\n+ for (size_t s = 0; s < t.sockets.size(); s++)\n+ t.sockets[s]->bind(adp.get_empty_buffer(s));\n+ }\n+ else\n{\nstd::vector<const int8_t*> sockets_dataptr(p1s_in.size());\nfor (size_t s = 0; s < p1s_in.size(); s++)\nsockets_dataptr[s] = static_cast<const int8_t*>(t[p1s_in[s]].get_dataptr());\n-\n- static_cast<Adaptor_1_to_n&>(m).push_1(sockets_dataptr);\n+ adp.push_1(sockets_dataptr);\n+ }\nreturn 0;\n});\n@@ -121,12 +131,22 @@ void Adaptor_1_to_n\np2s_out.push_back(create_socket_out(p2, this->n_elmts[s], this->datatype[s], \"out\" + std::to_string(s)));\nthis->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n+ {\n+ auto &adp = static_cast<Adaptor_1_to_n&>(m);\n+ if (adp.is_no_copy_pull())\n+ {\n+ adp.wait_pull();\n+ // for debug mode coherence\n+ for (size_t s = 0; s < t.sockets.size(); s++)\n+ t.sockets[s]->bind(adp.get_filled_buffer(s));\n+ }\n+ else\n{\nstd::vector<int8_t*> sockets_dataptr(p2s_out.size());\nfor (size_t s = 0; s < p2s_out.size(); s++)\nsockets_dataptr[s] = static_cast<int8_t*>(t[p2s_out[s]].get_dataptr());\n-\n- static_cast<Adaptor_1_to_n&>(m).pull_n(sockets_dataptr);\n+ adp.pull_n(sockets_dataptr);\n+ }\nreturn 0;\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hpp",
"diff": "@@ -60,6 +60,8 @@ protected:\nvirtual void push_n(const std::vector<const int8_t*> &in, const int frame_id = -1);\nvirtual void pull_1(const std::vector< int8_t*> &out, const int frame_id = -1);\n+ void wait_push();\n+ void wait_pull();\nvoid* get_empty_buffer(const size_t sid);\nvoid* get_filled_buffer(const size_t sid);\nvoid* get_empty_buffer(const size_t sid, void* swap_buffer);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"diff": "@@ -106,12 +106,22 @@ void Adaptor_n_to_1\np1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s], \"in\" + std::to_string(s)));\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n+ {\n+ auto &adp = static_cast<Adaptor_n_to_1&>(m);\n+ if (adp.is_no_copy_push())\n+ {\n+ adp.wait_push();\n+ // for debug mode coherence\n+ for (size_t s = 0; s < t.sockets.size(); s++)\n+ t.sockets[s]->bind(adp.get_empty_buffer(s));\n+ }\n+ else\n{\nstd::vector<const int8_t*> sockets_dataptr(p1s_in.size());\nfor (size_t s = 0; s < p1s_in.size(); s++)\nsockets_dataptr[s] = static_cast<const int8_t*>(t[p1s_in[s]].get_dataptr());\n-\n- static_cast<Adaptor_n_to_1&>(m).push_n(sockets_dataptr);\n+ adp.push_n(sockets_dataptr);\n+ }\nreturn 0;\n});\n@@ -121,12 +131,22 @@ void Adaptor_n_to_1\np2s_out.push_back(create_socket_out(p2, this->n_elmts[s], this->datatype[s], \"out\" + std::to_string(s)));\nthis->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n+ {\n+ auto &adp = static_cast<Adaptor_n_to_1&>(m);\n+ if (adp.is_no_copy_pull())\n+ {\n+ adp.wait_pull();\n+ // for debug mode coherence\n+ for (size_t s = 0; s < t.sockets.size(); s++)\n+ t.sockets[s]->bind(adp.get_filled_buffer(s));\n+ }\n+ else\n{\nstd::vector<int8_t*> sockets_dataptr(p2s_out.size());\nfor (size_t s = 0; s < p2s_out.size(); s++)\nsockets_dataptr[s] = static_cast<int8_t*>(t[p2s_out[s]].get_dataptr());\n-\n- static_cast<Adaptor_n_to_1&>(m).pull_1(sockets_dataptr);\n+ adp.pull_1(sockets_dataptr);\n+ }\nreturn 0;\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hpp",
"new_path": "include/Module/Socket.hpp",
"diff": "@@ -48,7 +48,7 @@ public:\ninline void* get_dataptr () const;\ninline bool is_fast () const;\ninline Task& get_task () const;\n- inline const std::vector<Socket*> get_bound_sockets () const;\n+ inline const std::vector<Socket*>& get_bound_sockets () const;\ninline const Socket& get_bound_socket () const;\ninline Socket& get_bound_socket ();\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hxx",
"new_path": "include/Module/Socket.hxx",
"diff": "@@ -82,7 +82,7 @@ Task& Socket\nreturn this->task;\n}\n-const std::vector<Socket*> Socket\n+const std::vector<Socket*>& Socket\n::get_bound_sockets() const\n{\nreturn this->bound_sockets;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "@@ -40,10 +40,8 @@ public:\nsize_t id;\n// usefull in case of adaptor to make zero copy and restore original states at the end of the chain execution\n- std::vector<std::vector<std::vector<module::Socket*>>> rebind_in_sockets;\n- std::vector<std::vector<std::vector<void*>>> rebind_in_dataptrs;\n- std::vector<std::vector<module::Socket*>> rebind_out_sockets;\n- std::vector<std::vector<void*>> rebind_out_dataptrs;\n+ std::vector<std::vector<std::vector<module::Socket*>>> rebind_sockets;\n+ std::vector<std::vector<std::vector<void*>>> rebind_dataptrs;\nexplicit Sub_sequence_generic() : type(subseq_t::STD), id(0) {}\nvirtual ~Sub_sequence_generic() = default;\n@@ -72,7 +70,7 @@ protected:\nbool thread_pinning;\nstd::vector<size_t> puids;\n- bool no_copy_mode_adaptors;\n+ bool no_copy_mode;\npublic:\n@@ -126,8 +124,8 @@ public:\nvoid export_dot(std::ostream &stream = std::cout) const;\n- void set_no_copy_mode_adaptors(const bool no_copy_mode);\n- bool is_no_copy_mode_adaptors() const;\n+ void set_no_copy_mode(const bool no_copy_mode);\n+ bool is_no_copy_mode() const;\nprotected:\ntemplate <class SS>\n@@ -168,8 +166,8 @@ protected:\nstd::function<bool()> &stop_condition,\nGeneric_node<Sub_sequence>* sequence);\n- void gen_processes(const bool no_copy_mode_adaptors = false);\n- void reset_no_copy_mode_adaptors();\n+ void gen_processes(const bool no_copy_mode = false);\n+ void reset_no_copy_mode();\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"new_path": "src/Module/Adaptor/Adaptor_1_to_n.cpp",
"diff": "@@ -17,27 +17,8 @@ Adaptor_1_to_n* Adaptor_1_to_n\nvoid Adaptor_1_to_n\n::push_1(const std::vector<const int8_t*> &in, const int frame_id)\n{\n- if (this->active_waiting)\n- {\n- while (this->is_full(this->cur_id) && !*this->waiting_canceled);\n- }\n- else // passive waiting\n- {\n- if (this->is_full(this->cur_id) && !*this->waiting_canceled)\n- {\n- std::unique_lock<std::mutex> lock(*this->mtx_put.get());\n- (*this->cnd_put.get()).wait(lock, [this]()\n- {\n- return !(this->is_full(this->cur_id) && !*this->waiting_canceled);\n- });\n- }\n- }\n-\n- if (*this->waiting_canceled)\n- throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+ this->wait_push();\n- if (!this->is_no_copy_push())\n- {\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n@@ -52,32 +33,12 @@ void Adaptor_1_to_n\nthis->wake_up_puller();\n}\n-}\nvoid Adaptor_1_to_n\n::pull_n(const std::vector<int8_t*> &out, const int frame_id)\n{\n- if (this->active_waiting)\n- {\n- while (this->is_empty(this->id) && !*this->waiting_canceled);\n- }\n- else // passive waiting\n- {\n- if (this->is_empty(this->id) && !*this->waiting_canceled)\n- {\n- std::unique_lock<std::mutex> lock((*this->mtx_pull.get())[this->id]);\n- (*this->cnd_pull.get())[this->id].wait(lock, [this]()\n- {\n- return !(this->is_empty(this->id) && !*this->waiting_canceled);\n- });\n- }\n- }\n-\n- if (*this->waiting_canceled)\n- throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+ this->wait_pull();\n- if (!this->is_no_copy_pull())\n- {\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n@@ -92,30 +53,51 @@ void Adaptor_1_to_n\nthis->wake_up_pusher();\n}\n-}\nvoid Adaptor_1_to_n\n-::wake_up()\n+::wait_push()\n{\n- if (!this->active_waiting) // passive waiting\n+ if (this->active_waiting)\n{\n- for (size_t i = 0; i < this->buffer->size(); i++)\n- if ((*this->buffer)[i].size() != 0)\n+ while (this->is_full(this->cur_id) && !*this->waiting_canceled);\n+ }\n+ else // passive waiting\n{\n- std::unique_lock<std::mutex> lock((*this->mtx_pull.get())[i]);\n- (*this->cnd_pull.get())[i].notify_all();\n+ if (this->is_full(this->cur_id) && !*this->waiting_canceled)\n+ {\n+ std::unique_lock<std::mutex> lock(*this->mtx_put.get());\n+ (*this->cnd_put.get()).wait(lock, [this]()\n+ {\n+ return !(this->is_full(this->cur_id) && !*this->waiting_canceled);\n+ });\n}\n-\n- std::lock_guard<std::mutex> lock(*this->mtx_put.get());\n- (*this->cnd_put.get()).notify_all();\n}\n+\n+ if (*this->waiting_canceled)\n+ throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n}\nvoid Adaptor_1_to_n\n-::cancel_waiting()\n+::wait_pull()\n{\n- this->send_cancel_signal();\n- this->wake_up();\n+ if (this->active_waiting)\n+ {\n+ while (this->is_empty(this->id) && !*this->waiting_canceled);\n+ }\n+ else // passive waiting\n+ {\n+ if (this->is_empty(this->id) && !*this->waiting_canceled)\n+ {\n+ std::unique_lock<std::mutex> lock((*this->mtx_pull.get())[this->id]);\n+ (*this->cnd_pull.get())[this->id].wait(lock, [this]()\n+ {\n+ return !(this->is_empty(this->id) && !*this->waiting_canceled);\n+ });\n+ }\n+ }\n+\n+ if (*this->waiting_canceled)\n+ throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n}\nvoid* Adaptor_1_to_n\n@@ -181,3 +163,27 @@ void Adaptor_1_to_n\n}\n}\n}\n+\n+void Adaptor_1_to_n\n+::wake_up()\n+{\n+ if (!this->active_waiting) // passive waiting\n+ {\n+ for (size_t i = 0; i < this->buffer->size(); i++)\n+ if ((*this->buffer)[i].size() != 0)\n+ {\n+ std::unique_lock<std::mutex> lock((*this->mtx_pull.get())[i]);\n+ (*this->cnd_pull.get())[i].notify_all();\n+ }\n+\n+ std::lock_guard<std::mutex> lock(*this->mtx_put.get());\n+ (*this->cnd_put.get()).notify_all();\n+ }\n+}\n+\n+void Adaptor_1_to_n\n+::cancel_waiting()\n+{\n+ this->send_cancel_signal();\n+ this->wake_up();\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"new_path": "src/Module/Adaptor/Adaptor_n_to_1.cpp",
"diff": "@@ -17,27 +17,8 @@ Adaptor_n_to_1* Adaptor_n_to_1\nvoid Adaptor_n_to_1\n::push_n(const std::vector<const int8_t*> &in, const int frame_id)\n{\n- if (this->active_waiting)\n- {\n- while (this->is_full(this->id) && !*this->waiting_canceled);\n- }\n- else // passive waiting\n- {\n- if (this->is_full(this->id) && !*this->waiting_canceled)\n- {\n- std::unique_lock<std::mutex> lock((*this->mtx_put.get())[this->id]);\n- (*this->cnd_put.get())[this->id].wait(lock, [this]()\n- {\n- return !(this->is_full(this->id) && !*this->waiting_canceled);\n- });\n- }\n- }\n-\n- if (*this->waiting_canceled)\n- throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+ this->wait_push();\n- if (!this->is_no_copy_push())\n- {\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n@@ -52,32 +33,12 @@ void Adaptor_n_to_1\nthis->wake_up_puller();\n}\n-}\nvoid Adaptor_n_to_1\n::pull_1(const std::vector<int8_t*> &out, const int frame_id)\n{\n- if (this->active_waiting)\n- {\n- while (this->is_empty(this->cur_id) && !*this->waiting_canceled);\n- }\n- else // passive waiting\n- {\n- if (this->is_empty(this->cur_id) && !*this->waiting_canceled)\n- {\n- std::unique_lock<std::mutex> lock(*this->mtx_pull.get());\n- (*this->cnd_pull.get()).wait(lock, [this]()\n- {\n- return !(this->is_empty(this->cur_id) && !*this->waiting_canceled);\n- });\n- }\n- }\n-\n- if (*this->waiting_canceled)\n- throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n+ this->wait_pull();\n- if (!this->is_no_copy_pull())\n- {\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n@@ -92,30 +53,51 @@ void Adaptor_n_to_1\nthis->wake_up_pusher();\n}\n-}\nvoid Adaptor_n_to_1\n-::wake_up()\n+::wait_push()\n{\n- if (!this->active_waiting) // passive waiting\n+ if (this->active_waiting)\n{\n- for (size_t i = 0; i < this->buffer->size(); i++)\n- if ((*this->buffer)[i].size() != 0)\n+ while (this->is_full(this->id) && !*this->waiting_canceled);\n+ }\n+ else // passive waiting\n{\n- std::unique_lock<std::mutex> lock((*this->mtx_put.get())[i]);\n- (*this->cnd_put.get())[i].notify_all();\n+ if (this->is_full(this->id) && !*this->waiting_canceled)\n+ {\n+ std::unique_lock<std::mutex> lock((*this->mtx_put.get())[this->id]);\n+ (*this->cnd_put.get())[this->id].wait(lock, [this]()\n+ {\n+ return !(this->is_full(this->id) && !*this->waiting_canceled);\n+ });\n}\n-\n- std::lock_guard<std::mutex> lock(*this->mtx_pull.get());\n- (*this->cnd_pull.get()).notify_all();\n}\n+\n+ if (*this->waiting_canceled)\n+ throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n}\nvoid Adaptor_n_to_1\n-::cancel_waiting()\n+::wait_pull()\n{\n- this->send_cancel_signal();\n- this->wake_up();\n+ if (this->active_waiting)\n+ {\n+ while (this->is_empty(this->cur_id) && !*this->waiting_canceled);\n+ }\n+ else // passive waiting\n+ {\n+ if (this->is_empty(this->cur_id) && !*this->waiting_canceled)\n+ {\n+ std::unique_lock<std::mutex> lock(*this->mtx_pull.get());\n+ (*this->cnd_pull.get()).wait(lock, [this]()\n+ {\n+ return !(this->is_empty(this->cur_id) && !*this->waiting_canceled);\n+ });\n+ }\n+ }\n+\n+ if (*this->waiting_canceled)\n+ throw tools::waiting_canceled(__FILE__, __LINE__, __func__);\n}\nvoid* Adaptor_n_to_1\n@@ -181,3 +163,27 @@ void Adaptor_n_to_1\n}\nwhile((*this->buffer)[this->cur_id].size() == 0);\n}\n+\n+void Adaptor_n_to_1\n+::wake_up()\n+{\n+ if (!this->active_waiting) // passive waiting\n+ {\n+ for (size_t i = 0; i < this->buffer->size(); i++)\n+ if ((*this->buffer)[i].size() != 0)\n+ {\n+ std::unique_lock<std::mutex> lock((*this->mtx_put.get())[i]);\n+ (*this->cnd_put.get())[i].notify_all();\n+ }\n+\n+ std::lock_guard<std::mutex> lock(*this->mtx_pull.get());\n+ (*this->cnd_pull.get()).notify_all();\n+ }\n+}\n+\n+void Adaptor_n_to_1\n+::cancel_waiting()\n+{\n+ this->send_cancel_signal();\n+ this->wake_up();\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -37,7 +37,7 @@ Chain\ntasks_inplace(false),\nthread_pinning(thread_pinning),\npuids(puids),\n- no_copy_mode_adaptors(true)\n+ no_copy_mode(true)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first, &last);\n}\n@@ -58,7 +58,7 @@ Chain\ntasks_inplace(false),\nthread_pinning(thread_pinning),\npuids(puids),\n- no_copy_mode_adaptors(true)\n+ no_copy_mode(true)\n{\nthis->init<tools::Sub_sequence_const,const module::Task>(first);\n}\n@@ -81,7 +81,7 @@ Chain\ntasks_inplace(tasks_inplace),\nthread_pinning(thread_pinning),\npuids(puids),\n- no_copy_mode_adaptors(true)\n+ no_copy_mode(true)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first, &last);\n@@ -106,7 +106,7 @@ Chain\ntasks_inplace(tasks_inplace),\nthread_pinning(false),\npuids(puids),\n- no_copy_mode_adaptors(true)\n+ no_copy_mode(true)\n{\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first);\n@@ -370,9 +370,9 @@ void Chain\nThread_pinning::pin();\n}\n- const bool no_copy_mode_adaptors = this->is_no_copy_mode_adaptors();\n+ const bool no_copy_mode = this->is_no_copy_mode();\nstd::function<void(Generic_node<Sub_sequence>*)> exec_sequence =\n- [&exec_sequence, no_copy_mode_adaptors](Generic_node<Sub_sequence>* cur_ss)\n+ [&exec_sequence, no_copy_mode](Generic_node<Sub_sequence>* cur_ss)\n{\nauto type = cur_ss->get_c()->type;\nauto &tasks = cur_ss->get_c()->tasks;\n@@ -443,7 +443,7 @@ void Chain\nvoid Chain\n::exec(std::function<bool(const std::vector<int>&)> stop_condition)\n{\n- if (this->is_no_copy_mode_adaptors())\n+ if (this->is_no_copy_mode())\nthis->gen_processes(true);\nstd::vector<std::thread> threads(n_threads);\n@@ -455,9 +455,9 @@ void Chain\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n- if (this->is_no_copy_mode_adaptors())\n+ if (this->is_no_copy_mode())\n{\n- this->reset_no_copy_mode_adaptors();\n+ this->reset_no_copy_mode();\nthis->gen_processes(false);\n}\n@@ -471,7 +471,7 @@ void Chain\nvoid Chain\n::exec(std::function<bool()> stop_condition)\n{\n- if (this->is_no_copy_mode_adaptors())\n+ if (this->is_no_copy_mode())\nthis->gen_processes(true);\nstd::vector<std::thread> threads(n_threads);\n@@ -486,9 +486,9 @@ void Chain\nfor (size_t tid = 1; tid < n_threads; tid++)\nthreads[tid].join();\n- if (this->is_no_copy_mode_adaptors())\n+ if (this->is_no_copy_mode())\n{\n- this->reset_no_copy_mode_adaptors();\n+ this->reset_no_copy_mode();\nthis->gen_processes(false);\n}\n@@ -1002,67 +1002,76 @@ void Chain\n}\nvoid Chain\n-::gen_processes(const bool no_copy_mode_adaptors)\n+::gen_processes(const bool no_copy_mode)\n{\nstd::function<void(Generic_node<Sub_sequence>*)> gen_processes_recursive =\n- [&gen_processes_recursive, no_copy_mode_adaptors](Generic_node<Sub_sequence>* cur_node)\n+ [&gen_processes_recursive, no_copy_mode](Generic_node<Sub_sequence>* cur_node)\n{\nif (cur_node != nullptr)\n{\nstd::map<module::Task*, std::function<int()>> modified_tasks;\nauto contents = cur_node->get_c();\ncontents->processes.clear();\n- contents->rebind_in_sockets.clear();\n- contents->rebind_in_dataptrs.clear();\n- contents->rebind_out_sockets.clear();\n- contents->rebind_out_dataptrs.clear();\n+ contents->rebind_sockets.clear();\n+ contents->rebind_dataptrs.clear();\nfor (auto task : contents->tasks)\n{\nif (dynamic_cast<module::Adaptor*>(&task->get_module()) &&\n- task->get_name().find(\"pull\") != std::string::npos && no_copy_mode_adaptors)\n+ task->get_name().find(\"pull\") != std::string::npos && no_copy_mode)\n{\nauto pull_task = task;\nauto adp_pull = dynamic_cast<module::Adaptor*>(&pull_task->get_module());\nadp_pull->set_no_copy_pull(true);\n- const auto cur_adp_pull = contents->rebind_in_sockets.size();\n- contents->rebind_in_sockets.resize(cur_adp_pull +1);\n- contents->rebind_in_dataptrs.resize(cur_adp_pull +1);\n+ const auto rebind_id = contents->rebind_sockets.size();\n+ contents->rebind_sockets.resize(rebind_id +1);\n+ contents->rebind_dataptrs.resize(rebind_id +1);\nfor (size_t s = 0; s < pull_task->sockets.size(); s++)\nif (pull_task->get_socket_type(*pull_task->sockets[s]) == module::socket_t::SOUT)\n{\n- auto bound_sockets = pull_task->sockets[s]->get_bound_sockets();\n+ std::vector<module::Socket*> bound_sockets;\nstd::vector<void*> dataptrs;\n- for (auto s : bound_sockets)\n+\n+ bound_sockets.push_back(pull_task->sockets[s].get());\n+ dataptrs.push_back(pull_task->sockets[s]->get_dataptr());\n+\n+ bound_sockets.insert(bound_sockets.end(),\n+ pull_task->sockets[s]->get_bound_sockets().begin(),\n+ pull_task->sockets[s]->get_bound_sockets().end());\n+ for (auto sck : bound_sockets)\n{\n- if (s->get_task().get_socket_type(*s) == module::socket_t::SIN_SOUT)\n+ if (sck->get_task().get_socket_type(*sck) == module::socket_t::SIN_SOUT)\n{\nstd::stringstream message;\nmessage << \"'SIN_SOUT' socket type is unsupported at this time (\"\n- << \"'s->get_name()' = \" << s->get_name() << \", \"\n- << \"'s->get_task().get_name()' = .\" << s->get_task().get_name() << \".)\";\n+ << \"'sck->get_name()' = \" << sck->get_name() << \", \"\n+ << \"'sck->get_task().get_name()' = .\" << sck->get_task().get_name()\n+ << \".)\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- dataptrs.push_back(s->get_dataptr());\n+ dataptrs.push_back(sck->get_dataptr());\n}\n- contents->rebind_in_sockets[cur_adp_pull].push_back(bound_sockets);\n- contents->rebind_in_dataptrs[cur_adp_pull].push_back(dataptrs);\n+\n+ contents->rebind_sockets[rebind_id].push_back(bound_sockets);\n+ contents->rebind_dataptrs[rebind_id].push_back(dataptrs);\n}\n- modified_tasks[pull_task] = [contents, pull_task, adp_pull, cur_adp_pull]() -> int\n+ modified_tasks[pull_task] = [contents, pull_task, adp_pull, rebind_id]() -> int\n{\n// active or passive waiting here\nint ret = pull_task->exec();\n// rebind input sockets on the fly\n- for (size_t sin_id = 0; sin_id < contents->rebind_in_sockets[cur_adp_pull].size(); sin_id++)\n+ for (size_t sin_id = 0; sin_id < contents->rebind_sockets[rebind_id].size(); sin_id++)\n{\n- auto swap_buff = contents->rebind_in_sockets[cur_adp_pull][sin_id][0]->get_dataptr();\n+ // we start to 1 because the rebinding of the 'pull_task' is made in the\n+ // 'pull_task->exec()' call (this way the debug mode is still working)\n+ auto swap_buff = contents->rebind_sockets[rebind_id][sin_id][1]->get_dataptr();\nauto buff = adp_pull->get_filled_buffer(sin_id, swap_buff);\n- contents->rebind_in_sockets[cur_adp_pull][sin_id][0]->bind(buff);\n+ contents->rebind_sockets[rebind_id][sin_id][1]->bind(buff);\n// for the next tasks the same buffer 'buff' is required, an easy mistake is to re-swap\n// and the data will be false, this is why we just bind 'buff'\n- for (size_t ta = 1; ta < contents->rebind_in_sockets[cur_adp_pull][sin_id].size(); ta++)\n- contents->rebind_in_sockets[cur_adp_pull][sin_id][ta]->bind(buff);\n+ for (size_t ta = 2; ta < contents->rebind_sockets[rebind_id][sin_id].size(); ta++)\n+ contents->rebind_sockets[rebind_id][sin_id][ta]->bind(buff);\n}\nadp_pull->wake_up_pusher();\nreturn ret;\n@@ -1070,18 +1079,24 @@ void Chain\n}\nif (dynamic_cast<module::Adaptor*>(&task->get_module()) &&\n- task->get_name().find(\"push\") != std::string::npos && no_copy_mode_adaptors)\n+ task->get_name().find(\"push\") != std::string::npos && no_copy_mode)\n{\nauto push_task = task;\nauto adp_push = dynamic_cast<module::Adaptor*>(&push_task->get_module());\nadp_push->set_no_copy_push(true);\n- const auto cur_adp_push = contents->rebind_out_sockets.size();\n- contents->rebind_out_sockets.resize(cur_adp_push +1);\n- contents->rebind_out_dataptrs.resize(cur_adp_push +1);\n+ const auto rebind_id = contents->rebind_sockets.size();\n+ contents->rebind_sockets.resize(rebind_id +1);\n+ contents->rebind_dataptrs.resize(rebind_id +1);\nfor (size_t s = 0; s < push_task->sockets.size(); s++)\nif (push_task->get_socket_type(*push_task->sockets[s]) == module::socket_t::SIN)\n{\n+ std::vector<module::Socket*> bound_sockets;\n+ std::vector<void*> dataptrs;\n+\n+ bound_sockets.push_back(push_task->sockets[s].get());\n+ dataptrs.push_back(push_task->sockets[s]->get_dataptr());\n+\nauto bound_socket = &push_task->sockets[s]->get_bound_socket();\nif (bound_socket->get_task().get_socket_type(*bound_socket) ==\nmodule::socket_t::SIN_SOUT)\n@@ -1093,23 +1108,48 @@ void Chain\n<< bound_socket->get_task().get_name() << \".)\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ bound_sockets.push_back(bound_socket);\n+ dataptrs.push_back(bound_socket->get_dataptr());\n+\n+ auto &bs = bound_socket->get_bound_sockets();\n+ for (size_t s = 0; s < bs.size(); s++)\n+ if (&bs[s]->get_task() != push_task)\n+ {\n+ if (bs[s]->get_task().get_socket_type(*bs[s]) == module::socket_t::SIN_SOUT)\n+ {\n+ std::stringstream message;\n+ message << \"'SIN_SOUT' socket type is unsupported at this time (\"\n+ << \"'s' = \" << s << \", \"\n+ << \"'bs[s]->get_name()' = \" << bs[s]->get_name() << \", \"\n+ << \"'bs[s]->get_task().get_name()' = .\"\n+ << bs[s]->get_task().get_name() << \".)\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ bound_sockets.push_back(bs[s]);\n+ dataptrs.push_back(bs[s]->get_dataptr());\n+ }\n- void* dataptr = bound_socket->get_dataptr();\n- contents->rebind_out_sockets[cur_adp_push].push_back(bound_socket);\n- contents->rebind_out_dataptrs[cur_adp_push].push_back(dataptr);\n+ contents->rebind_sockets[rebind_id].push_back(bound_sockets);\n+ contents->rebind_dataptrs[rebind_id].push_back(dataptrs);\n}\n- modified_tasks[push_task] = [contents, push_task, adp_push, cur_adp_push]() -> int\n+ modified_tasks[push_task] = [contents, push_task, adp_push, rebind_id]() -> int\n{\n// active or passive waiting here\nauto ret = push_task->exec();\n// rebind output sockets on the fly\n- for (size_t sout_id = 0; sout_id < contents->rebind_out_sockets[cur_adp_push].size();\n- sout_id++)\n+ for (size_t sout_id = 0; sout_id < contents->rebind_sockets[rebind_id].size(); sout_id++)\n{\n- auto swap_buff = contents->rebind_out_sockets[cur_adp_push][sout_id]->get_dataptr();\n+ // we start to 1 because the rebinding of the 'push_task' is made in the\n+ // 'push_task->exec()' call (this way the debug mode is still working)\n+ auto swap_buff = contents->rebind_sockets[rebind_id][sout_id][1]->get_dataptr();\nauto buff = adp_push->get_empty_buffer(sout_id, swap_buff);\n- contents->rebind_out_sockets[cur_adp_push][sout_id]->bind(buff);\n+ contents->rebind_sockets[rebind_id][sout_id][1]->bind(buff);\n+ // the output socket linked to the push adp can have more than one socket bound and so\n+ // we have to rebind all the input sokects bound to the current output socket\n+ for (size_t ta = 2; ta < contents->rebind_sockets[rebind_id][sout_id].size(); ta++)\n+ contents->rebind_sockets[rebind_id][sout_id][ta]->bind(buff);\n}\nadp_push->wake_up_puller();\nreturn ret;\n@@ -1144,7 +1184,7 @@ void Chain\n}\nvoid Chain\n-::reset_no_copy_mode_adaptors()\n+::reset_no_copy_mode()\n{\nstd::function<void(Generic_node<Sub_sequence>*)> reset_no_copy_mode_recursive =\n[&reset_no_copy_mode_recursive](Generic_node<Sub_sequence>* cur_node)\n@@ -1173,16 +1213,11 @@ void Chain\n}\n}\n- for (size_t adp_pull = 0; adp_pull < contents->rebind_in_sockets.size(); adp_pull++)\n- for (size_t s = 0; s < contents->rebind_in_sockets[adp_pull].size(); s++)\n- for (size_t ta = 0; ta < contents->rebind_in_sockets[adp_pull][s].size(); ta++)\n- contents->rebind_in_sockets[adp_pull][s][ta]\n- ->bind(contents->rebind_in_dataptrs[adp_pull][s][ta]);\n-\n- for (size_t adp_push = 0; adp_push < contents->rebind_out_sockets.size(); adp_push++)\n- for (size_t s = 0; s < contents->rebind_out_sockets[adp_push].size(); s++)\n- contents->rebind_out_sockets[adp_push][s]\n- ->bind(contents->rebind_out_dataptrs[adp_push][s]);\n+ for (size_t rebind_id = 0; rebind_id < contents->rebind_sockets.size(); rebind_id++)\n+ for (size_t s = 0; s < contents->rebind_sockets[rebind_id].size(); s++)\n+ for (size_t ta = 0; ta < contents->rebind_sockets[rebind_id][s].size(); ta++)\n+ contents->rebind_sockets[rebind_id][s][ta]\n+ ->bind(contents->rebind_dataptrs[rebind_id][s][ta]);\n}\nfor (auto c : cur_node->get_children())\n@@ -1195,14 +1230,14 @@ void Chain\n}\nvoid Chain\n-::set_no_copy_mode_adaptors(const bool no_copy_mode)\n+::set_no_copy_mode(const bool no_copy_mode)\n{\n- this->no_copy_mode_adaptors = no_copy_mode;\n+ this->no_copy_mode = no_copy_mode;\n}\nbool Chain\n-::is_no_copy_mode_adaptors() const\n+::is_no_copy_mode() const\n{\n- return this->no_copy_mode_adaptors;\n+ return this->no_copy_mode;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve 0-copy mode in the chain + fix segfaults and debug mode.
|
8,490 |
08.02.2020 19:18:41
| -3,600 |
0110288007c22c12ed3810360b481cf8714bf7ff
|
Throw if a chain contains adaptors and if task_inplace is set to false.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -556,6 +556,13 @@ const module::Task& Chain\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n+ if (dynamic_cast<const module::Adaptor*>(¤t_task.get_module()) && !this->tasks_inplace)\n+ {\n+ std::stringstream message;\n+ message << \"'module::Adaptor' objects are not supported if 'tasks_inplace' is set to false.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nif (auto loop = dynamic_cast<const module::Loop*>(¤t_task.get_module()))\n{\nif (std::find(loops.begin(), loops.end(), ¤t_task) == loops.end())\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Throw if a chain contains adaptors and if task_inplace is set to false.
|
8,490 |
08.02.2020 19:45:28
| -3,600 |
079a243cb4ff8c4e89f97bebfd3a1fed41a302e6
|
Add a warning when thread pinning is requested without link to hwloc.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Thread_pinning/Thread_pinning.hpp",
"new_path": "include/Tools/Thread_pinning/Thread_pinning.hpp",
"diff": "@@ -12,7 +12,6 @@ class Thread_pinning\npublic:\nstatic void init();\nstatic void destroy();\n- static void pin();\nstatic void pin(const size_t puid);\nstatic void unpin();\n@@ -20,13 +19,6 @@ public:\nstatic void set_logs(const bool enable_logs);\nstatic bool is_logs();\n-\n- static void example1();\n- static void example2();\n- static void example3();\n- static void example4();\n- static void example5();\n- static void example6();\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "#include <exception>\n#include <algorithm>\n+#include \"Tools/Display/rang_format/rang_format.h\"\n#include \"Tools/Thread_pinning/Thread_pinning.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Module.hpp\"\n@@ -39,6 +40,20 @@ Chain\npuids(puids),\nno_copy_mode(true)\n{\n+#ifndef AFF3CT_HWLOC\n+ if (thread_pinning)\n+ std::clog << rang::tag::warning << \"AFF3CT has not been linked with the 'hwloc' library, the 'thread_pinning' \"\n+ \"option of the 'tools::Chain' will have no effect.\" << std::endl;\n+#endif\n+\n+ if (thread_pinning && puids.size() < n_threads)\n+ {\n+ std::stringstream message;\n+ message << \"'puids.size()' has greater or equal to 'n_threads' ('puids.size()' = \" << puids.size()\n+ << \" , 'n_threads' = \" << n_threads << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nthis->init<tools::Sub_sequence_const,const module::Task>(first, &last);\n}\n@@ -60,6 +75,14 @@ Chain\npuids(puids),\nno_copy_mode(true)\n{\n+ if (thread_pinning && puids.size() < n_threads)\n+ {\n+ std::stringstream message;\n+ message << \"'puids.size()' has greater or equal to 'n_threads' ('puids.size()' = \" << puids.size()\n+ << \" , 'n_threads' = \" << n_threads << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nthis->init<tools::Sub_sequence_const,const module::Task>(first);\n}\n@@ -83,6 +106,14 @@ Chain\npuids(puids),\nno_copy_mode(true)\n{\n+ if (thread_pinning && puids.size() < n_threads)\n+ {\n+ std::stringstream message;\n+ message << \"'puids.size()' has greater or equal to 'n_threads' ('puids.size()' = \" << puids.size()\n+ << \" , 'n_threads' = \" << n_threads << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first, &last);\nelse\n@@ -108,6 +139,14 @@ Chain\npuids(puids),\nno_copy_mode(true)\n{\n+ if (thread_pinning && puids.size() < n_threads)\n+ {\n+ std::stringstream message;\n+ message << \"'puids.size()' has greater or equal to 'n_threads' ('puids.size()' = \" << puids.size()\n+ << \" , 'n_threads' = \" << n_threads << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nif (tasks_inplace)\nthis->init<tools::Sub_sequence,module::Task>(first);\nelse\n@@ -126,12 +165,7 @@ void Chain\n::init(TA &first, TA *last)\n{\nif (this->is_thread_pinning())\n- {\n- if (0 < this->puids.size())\nThread_pinning::pin(this->puids[0]);\n- else\n- Thread_pinning::pin();\n- }\nif (this->n_threads == 0)\n{\n@@ -190,6 +224,14 @@ Chain* Chain\nvoid Chain\n::set_thread_pinning(const bool thread_pinning, const std::vector<size_t> &puids)\n{\n+ if (thread_pinning && puids.size() < n_threads)\n+ {\n+ std::stringstream message;\n+ message << \"'puids.size()' has greater or equal to 'n_threads' ('puids.size()' = \" << puids.size()\n+ << \" , 'n_threads' = \" << n_threads << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nthis->thread_pinning = thread_pinning;\nthis->puids = puids;\n}\n@@ -279,12 +321,7 @@ void Chain\nGeneric_node<Sub_sequence>* sequence)\n{\nif (this->is_thread_pinning())\n- {\n- if (tid < this->puids.size())\nThread_pinning::pin(this->puids[tid]);\n- else\n- Thread_pinning::pin();\n- }\nstd::function<void(Generic_node<Sub_sequence>*, std::vector<int>&)> exec_sequence =\n[&exec_sequence](Generic_node<Sub_sequence>* cur_ss, std::vector<int>& statuses)\n@@ -354,7 +391,7 @@ void Chain\n}\nif (this->is_thread_pinning())\n- aff3ct::tools::Thread_pinning::unpin();\n+ Thread_pinning::unpin();\n}\nvoid Chain\n@@ -363,12 +400,7 @@ void Chain\nGeneric_node<Sub_sequence>* sequence)\n{\nif (this->is_thread_pinning())\n- {\n- if (tid < this->puids.size())\nThread_pinning::pin(this->puids[tid]);\n- else\n- Thread_pinning::pin();\n- }\nconst bool no_copy_mode = this->is_no_copy_mode();\nstd::function<void(Generic_node<Sub_sequence>*)> exec_sequence =\n@@ -437,7 +469,7 @@ void Chain\n}\nif (this->is_thread_pinning())\n- aff3ct::tools::Thread_pinning::unpin();\n+ Thread_pinning::unpin();\n}\nvoid Chain\n@@ -709,10 +741,7 @@ void Chain\nif (this->is_thread_pinning())\n{\nconst auto real_tid = tid + (this->tasks_inplace ? 1 : 0);\n- if (real_tid < this->puids.size())\nThread_pinning::pin(this->puids[real_tid]);\n- else\n- Thread_pinning::pin();\n}\nthis->modules[tid].resize(modules_vec.size());\n@@ -722,6 +751,9 @@ void Chain\nthis->modules[tid][m].reset(modules_vec[m]->clone());\nthis->all_modules[tid + (this->tasks_inplace ? 1 : 0)][m] = this->modules[tid][m].get();\n}\n+\n+ if (this->is_thread_pinning())\n+ Thread_pinning::unpin();\n}\nauto get_module_id = [](const std::vector<MO*> &modules, const module::Module &module)\n@@ -841,16 +873,14 @@ void Chain\nfor (size_t thread_id = (this->tasks_inplace ? 1 : 0); thread_id < this->sequences.size(); thread_id++)\n{\nif (this->is_thread_pinning())\n- {\n- if (thread_id < this->puids.size())\nThread_pinning::pin(this->puids[thread_id]);\n- else\n- Thread_pinning::pin();\n- }\nthis->sequences[thread_id] = new Generic_node<Sub_sequence>(nullptr, {}, nullptr, 0, 0, 0);\nduplicate_sequence(sequence, this->sequences[thread_id], thread_id);\nset_autoalloc_true(this->sequences[thread_id]);\n+\n+ if (this->is_thread_pinning())\n+ Thread_pinning::unpin();\n}\n}\n@@ -1179,14 +1209,12 @@ void Chain\nfor (auto &sequence : this->sequences)\n{\nif (this->is_thread_pinning())\n- {\n- if (thread_id < this->puids.size())\nThread_pinning::pin(this->puids[thread_id++]);\n- else\n- Thread_pinning::pin();\n- }\ngen_processes_recursive(sequence);\n+\n+ if (this->is_thread_pinning())\n+ Thread_pinning::unpin();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Thread_pinning/Thread_pinning.cpp",
"new_path": "src/Tools/Thread_pinning/Thread_pinning.cpp",
"diff": "@@ -19,11 +19,6 @@ using namespace aff3ct::tools;\n#ifdef AFF3CT_HWLOC\nstatic hwloc_topology_t g_topology;\nstatic int g_topodepth = 0;\n-static std::vector<hwloc_uint64_t> g_pinned_threads;\n-static hwloc_obj_t g_cur_core_obj;\n-// static std::vector<int> g_thread_binding = {47, 46, 45, 44, 43, 23, 22, 21, 20, 19, 35, 18, 34, 17, 33, 16, 32, 15, 31, 14};\n-// // static std::vector<int> g_thread_binding = {47, 46, 45, 44, 43, 42, 23, 22, 21, 20, 19, 35, 18, 34, 17, 33, 16, 32, 15, 31, 14};\n-// static size_t g_thread_binding_id = 0;\n#endif\nstatic bool g_is_init = false;\nstatic std::mutex g_mtx;\n@@ -55,11 +50,6 @@ void Thread_pinning\n/* Optionally, get some additional topology information\nin case we need the topology depth later. */\ng_topodepth = hwloc_topology_get_depth(g_topology);\n-\n- /* Get last core. */\n- int core_depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n- int core_id = hwloc_get_nbobjs_by_depth(g_topology, core_depth) -1;\n- g_cur_core_obj = hwloc_get_obj_by_depth(g_topology, core_depth, core_id);\n#endif\n}\ng_mtx.unlock();\n@@ -165,88 +155,6 @@ void Thread_pinning\ng_mtx.unlock();\n}\n-void Thread_pinning\n-::pin()\n-{\n- std::cout << \"coucou\" << std::endl;\n- g_mtx.lock();\n-#ifdef AFF3CT_HWLOC\n- if (g_is_init)\n- {\n- if (g_cur_core_obj)\n- {\n- /* Get the first PU of the core */\n- if (g_cur_core_obj->arity == 0)\n- {\n- std::stringstream message;\n- message << \"Unsupported architecture, a core should have at least one PU.\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- hwloc_obj_t cur_core_pu0_obj = g_cur_core_obj->children[0];\n-\n- // // HACK\n- // int core_depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n- // cur_core_pu0_obj = hwloc_get_obj_by_depth(g_topology, core_depth, g_thread_binding[g_thread_binding_id++]);\n-\n- /* Get a copy of its cpuset that we may modify. */\n- hwloc_cpuset_t cpuset = hwloc_bitmap_dup(cur_core_pu0_obj->cpuset);\n- /* Get only one logical processor (in case the core is\n- SMT/hyper-threaded). */\n- hwloc_bitmap_singlify(cpuset);\n-\n- if (g_enable_logs)\n- {\n- char c[128];\n- hwloc_bitmap_snprintf(c, 128, cpuset);\n-\n- std::cerr << \"Thread pinning info -- \"\n- << \"CORE logical index (hwloc): \" << g_cur_core_obj->logical_index << \" -- \"\n- << \"PU logical index (hwloc): \" << cur_core_pu0_obj->logical_index << \" -- \"\n- << \"P OS index: \" << cur_core_pu0_obj->os_index << \" -- \"\n- << \"bitmap: \" << c << std::endl;\n- }\n-\n- /* And try to bind ourself there. */\n- if (hwloc_set_cpubind(g_topology, cpuset, HWLOC_CPUBIND_THREAD))\n- {\n- char *str;\n- int error = errno;\n- hwloc_bitmap_asprintf(&str, cur_core_pu0_obj->cpuset);\n- printf(\"Couldn't bind to cpuset %s: %s\\n\", str, strerror(error));\n- free(str);\n- }\n- /* Free our cpuset copy */\n- hwloc_bitmap_free(cpuset);\n- }\n-\n- /* Get next core. */\n- g_cur_core_obj = g_cur_core_obj->prev_cousin;\n-\n- if (g_cur_core_obj == nullptr)\n- {\n- std::stringstream message;\n- message << \"There is no more available cores.\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n- }\n- else\n- {\n- if (g_enable_logs)\n- {\n- std::clog << \"You can't call the 'pin' method if you have not call the 'init' method before, nothing will \"\n- << \"be done.\" << std::endl;\n- }\n- }\n-#else\n- if (g_enable_logs)\n- {\n- std::clog << \"'pin' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n- }\n-#endif\n- g_mtx.unlock();\n-}\n-\nvoid Thread_pinning\n::unpin()\n{\n@@ -290,267 +198,3 @@ std::string Thread_pinning\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n#endif\n}\n-\n-void Thread_pinning\n-::example1()\n-{\n-#ifdef AFF3CT_HWLOC\n- if (g_is_init)\n- {\n- /*****************************************************************\n- * First example:\n- * Walk the topology with an array style, from level 0 (always\n- * the system level) to the lowest level (always the proc level).\n- *****************************************************************/\n-\n- char string[128];\n- for (int depth = 0; depth < g_topodepth; depth++)\n- {\n- printf(\"*** Objects at level %d\\n\", depth);\n- for (unsigned i = 0; i < hwloc_get_nbobjs_by_depth(g_topology, depth); i++)\n- {\n- hwloc_obj_type_snprintf(string, sizeof(string),\n- hwloc_get_obj_by_depth(g_topology, depth, i), 0);\n- printf(\"Index %u: %s\\n\", i, string);\n- }\n- }\n- }\n- else\n- {\n- if (g_enable_logs)\n- {\n- std::clog << \"You can't call the 'example1' method if you have not call the 'init' method before, \"\n- << \"nothing will be done.\" << std::endl;\n- }\n- }\n-#else\n- if (g_enable_logs)\n- {\n- std::clog << \"'example1' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n- }\n-#endif\n-}\n-\n-void Thread_pinning\n-::example2()\n-{\n-#ifdef AFF3CT_HWLOC\n- if (g_is_init)\n- {\n- /*****************************************************************\n- * Second example:\n- * Walk the topology with a tree style.\n- *****************************************************************/\n-\n- std::function<void(hwloc_topology_t, hwloc_obj_t, int)> print_children =\n- [&print_children](hwloc_topology_t topology, hwloc_obj_t obj, int depth)\n- {\n- char type[32], attr[1024];\n- unsigned i;\n- hwloc_obj_type_snprintf(type, sizeof(type), obj, 0);\n- printf(\"%*s%s\", 2*depth, \"\", type);\n- if (obj->os_index != (unsigned) -1)\n- printf(\"#%u\", obj->os_index);\n- hwloc_obj_attr_snprintf(attr, sizeof(attr), obj, \" \", 0);\n- if (*attr)\n- printf(\"(%s)\", attr);\n-\n- printf(\"\\n\");\n- for (i = 0; i < obj->arity; i++) {\n- print_children(topology, obj->children[i], depth + 1);\n- }\n- };\n-\n- printf(\"*** Printing overall tree\\n\");\n- print_children(g_topology, hwloc_get_root_obj(g_topology), 0);\n- }\n- else\n- {\n- if (g_enable_logs)\n- {\n- std::clog << \"You can't call the 'example2' method if you have not call the 'init' method before, \"\n- << \"nothing will be done.\" << std::endl;\n- }\n- }\n-#else\n- if (g_enable_logs)\n- {\n- std::clog << \"'example2' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n- }\n-#endif\n-}\n-\n-void Thread_pinning\n-::example3()\n-{\n-#ifdef AFF3CT_HWLOC\n- if (g_is_init)\n- {\n- /*****************************************************************\n- * Third example:\n- * Print the number of packages.\n- *****************************************************************/\n-\n- int depth = hwloc_get_type_depth(g_topology, HWLOC_OBJ_PACKAGE);\n- if (depth == HWLOC_TYPE_DEPTH_UNKNOWN)\n- {\n- printf(\"*** The number of packages is unknown\\n\");\n- }\n- else\n- {\n- printf(\"*** %u package(s)\\n\",\n- hwloc_get_nbobjs_by_depth(g_topology, depth));\n- }\n- }\n- else\n- {\n- if (g_enable_logs)\n- {\n- std::clog << \"You can't call the 'example3' method if you have not call the 'init' method before, \"\n- << \"nothing will be done.\" << std::endl;\n- }\n- }\n-#else\n- if (g_enable_logs)\n- {\n- std::clog << \"'example3' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n- }\n-#endif\n-}\n-\n-void Thread_pinning\n-::example4()\n-{\n-#ifdef AFF3CT_HWLOC\n- if (g_is_init)\n- {\n- /*****************************************************************\n- * Fourth example:\n- * Compute the amount of cache that the first logical processor\n- * has above it.\n- *****************************************************************/\n-\n- // This block has been commented to compile with hwloc v2 (HWLOC_OBJ_CACHE does not exist with this version)\n- // int levels = 0;\n- // unsigned long size = 0;\n- // for (hwloc_obj_t obj = hwloc_get_obj_by_type(g_topology, HWLOC_OBJ_PU, 0); obj; obj = obj->parent)\n- // {\n- // if (obj->type == HWLOC_OBJ_CACHE)\n- // {\n- // levels++;\n- // size += obj->attr->cache.size;\n- // }\n- // }\n- // printf(\"*** Logical processor 0 has %d caches totaling %luKB\\n\", levels, size / 1024);\n- }\n- else\n- {\n- if (g_enable_logs)\n- {\n- std::clog << \"You can't call the 'example4' method if you have not call the 'init' method before, \"\n- << \"nothing will be done.\" << std::endl;\n- }\n- }\n-#else\n- if (g_enable_logs)\n- {\n- std::clog << \"'example4' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n- }\n-#endif\n-}\n-\n-void Thread_pinning\n-::example5()\n-{\n-#ifdef AFF3CT_HWLOC\n- if (g_is_init)\n- {\n- /*****************************************************************\n- * Fifth example:\n- * Bind to only one thread of the last core of the machine.\n- *\n- * First find out where cores are, or else smaller sets of CPUs if\n- * the OS doesn't have the notion of a \"core\".\n- *****************************************************************/\n-\n- int depth = hwloc_get_type_or_below_depth(g_topology, HWLOC_OBJ_CORE);\n- /* Get last core. */\n- hwloc_obj_t obj = hwloc_get_obj_by_depth(g_topology, depth,\n- hwloc_get_nbobjs_by_depth(g_topology, depth) - 1);\n- if (obj)\n- {\n- /* Get a copy of its cpuset that we may modify. */\n- hwloc_cpuset_t cpuset = hwloc_bitmap_dup(obj->cpuset);\n- /* Get only one logical processor (in case the core is\n- SMT/hyper-threaded). */\n- hwloc_bitmap_singlify(cpuset);\n- /* And try to bind ourself there. */\n- if (hwloc_set_cpubind(g_topology, cpuset, 0))\n- {\n- char *str;\n- int error = errno;\n- hwloc_bitmap_asprintf(&str, obj->cpuset);\n- printf(\"Couldn't bind to cpuset %s: %s\\n\", str, strerror(error));\n- free(str);\n- }\n- /* Free our cpuset copy */\n- hwloc_bitmap_free(cpuset);\n- }\n- }\n- else\n- {\n- if (g_enable_logs)\n- {\n- std::clog << \"You can't call the 'example5' method if you have not call the 'init' method before, \"\n- << \"nothing will be done.\" << std::endl;\n- }\n- }\n-#else\n- if (g_enable_logs)\n- {\n- std::clog << \"'example5' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n- }\n-#endif\n-}\n-\n-void Thread_pinning\n-::example6()\n-{\n-#ifdef AFF3CT_HWLOC\n- if (g_is_init)\n- {\n- /*****************************************************************\n- * Sixth example:\n- * Allocate some memory on the last NUMA node, bind some existing\n- * memory to the last NUMA node.\n- *****************************************************************/\n-\n- /* Get last node. */\n- int n = hwloc_get_nbobjs_by_type(g_topology, HWLOC_OBJ_NUMANODE);\n- if (n)\n- {\n- void *m;\n- int size = 1024*1024;\n- hwloc_obj_t obj = hwloc_get_obj_by_type(g_topology, HWLOC_OBJ_NUMANODE, n - 1);\n- m = hwloc_alloc_membind_nodeset(g_topology, size, obj->nodeset, HWLOC_MEMBIND_BIND, 0);\n- hwloc_free(g_topology, m, size);\n- m = malloc(size);\n- hwloc_set_area_membind_nodeset(g_topology, m, size, obj->nodeset, HWLOC_MEMBIND_BIND, 0);\n- free(m);\n- }\n- }\n- else\n- {\n- if (g_enable_logs)\n- {\n- std::clog << \"You can't call the 'example6' method if you have not call the 'init' method before, \"\n- << \"nothing will be done.\" << std::endl;\n- }\n- }\n-#else\n- if (g_enable_logs)\n- {\n- std::clog << \"'example6' method do nothing as AFF3CT has not been linked with the 'hwloc' library.\" << std::endl;\n- }\n-#endif\n-}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a warning when thread pinning is requested without link to hwloc.
|
8,490 |
10.02.2020 12:11:07
| -3,600 |
0ea661076624b10b58d048923539d40a7f6ff8f5
|
Use 64-bit unsigned integers for first and last pointers in adaptors.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hpp",
"new_path": "include/Module/Adaptor/Adaptor.hpp",
"diff": "@@ -52,8 +52,8 @@ protected:\nstd::shared_ptr<std::vector<std::vector<std::vector<int8_t*>>>> buffer;\nstd::vector<int8_t*> buffer_to_free;\n- std::shared_ptr<std::vector<std::atomic<size_t>>> first;\n- std::shared_ptr<std::vector<std::atomic<size_t>>> last;\n+ std::shared_ptr<std::vector<std::atomic<uint64_t>>> first;\n+ std::shared_ptr<std::vector<std::atomic<uint64_t>>> last;\nstd::shared_ptr<std::atomic<bool>> waiting_canceled;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor.hxx",
"new_path": "include/Module/Adaptor/Adaptor.hxx",
"diff": "@@ -26,8 +26,8 @@ Adaptor\nbuffer(new std::vector<std::vector<std::vector<int8_t*>>>\n(1, std::vector<std::vector<int8_t*>>(1,\nstd::vector<int8_t*>(buffer_size)))),\n- first(new std::vector<std::atomic<size_t>>(1000)),\n- last(new std::vector<std::atomic<size_t>>(1000)),\n+ first(new std::vector<std::atomic<uint64_t>>(1000)),\n+ last(new std::vector<std::atomic<uint64_t>>(1000)),\nwaiting_canceled(new std::atomic<bool>(false)),\nno_copy_pull(false),\nno_copy_push(false)\n@@ -79,8 +79,8 @@ Adaptor\nbuffer(new std::vector<std::vector<std::vector<int8_t*>>>\n(1, std::vector<std::vector<int8_t*>>(n_sockets,\nstd::vector<int8_t*>(buffer_size)))),\n- first(new std::vector<std::atomic<size_t>>(1000)),\n- last(new std::vector<std::atomic<size_t>>(1000)),\n+ first(new std::vector<std::atomic<uint64_t>>(1000)),\n+ last(new std::vector<std::atomic<uint64_t>>(1000)),\nwaiting_canceled(new std::atomic<bool>(false)),\nno_copy_pull(false),\nno_copy_push(false)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use 64-bit unsigned integers for first and last pointers in adaptors.
|
8,490 |
11.02.2020 13:26:32
| -3,600 |
e95e8b83877fe3652c9dd75ee6aa67baf2ccc480
|
Fix bugs in prev. commit.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Task.hpp",
"new_path": "include/Module/Task.hpp",
"diff": "@@ -45,7 +45,7 @@ protected:\nint32_t debug_frame_max;\nstd::function<int(Module &m, Task& t)> codelet;\n- int status;\n+ std::vector<int> status;\nstd::vector<mipp::vector<uint8_t>> out_buffers;\n// stats\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "@@ -28,6 +28,7 @@ Task\ndebug_precision(2),\ndebug_frame_max(-1),\ncodelet([](Module &m, Task &t) -> int { throw tools::unimplemented_error(__FILE__, __LINE__, __func__); return 0; }),\n+ status(module.get_n_frames()),\nn_calls(0),\nduration_total(std::chrono::nanoseconds(0)),\nduration_min(std::chrono::nanoseconds(0)),\n@@ -214,7 +215,7 @@ int Task\n{\nauto exec_status = this->codelet(*this->module, *this);\nthis->n_calls++;\n- (*(int*)this->sockets.back()->get_dataptr()) = exec_status;\n+ ((int*)this->sockets.back()->get_dataptr())[0] = exec_status;\nreturn exec_status;\n}\n@@ -293,7 +294,7 @@ int Task\n}\nelse\nexec_status = this->codelet(*this->module, *this);\n- (*(int*)this->sockets.back()->get_dataptr()) = exec_status;\n+ ((int*)this->sockets.back()->get_dataptr())[0] = exec_status;\nthis->n_calls++;\nif (debug)\n@@ -435,8 +436,8 @@ void Task\n// create automatically a socket that contains the status of the task\nconst bool hack_status = true;\n- auto s = this->template create_socket_out<int>(\"status\", 1, hack_status);\n- this->sockets[s]->dataptr = (void*)&this->status;\n+ auto s = this->template create_socket_out<int>(\"status\", /*1*/this->get_module().get_n_frames(), hack_status);\n+ this->sockets[s]->dataptr = (void*)this->status.data();\n}\nbool Task\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -1064,6 +1064,7 @@ void Chain\ncontents->rebind_dataptrs.resize(rebind_id +1);\nfor (size_t s = 0; s < pull_task->sockets.size() -1; s++)\n+ {\nif (pull_task->get_socket_type(*pull_task->sockets[s]) == module::socket_t::SOUT)\n{\nstd::vector<module::Socket*> bound_sockets;\n@@ -1072,10 +1073,9 @@ void Chain\nbound_sockets.push_back(pull_task->sockets[s].get());\ndataptrs.push_back(pull_task->sockets[s]->get_dataptr());\n- bound_sockets.insert(bound_sockets.end(),\n- pull_task->sockets[s]->get_bound_sockets().begin(),\n- pull_task->sockets[s]->get_bound_sockets().end());\n- for (auto sck : bound_sockets)\n+ auto bs = pull_task->sockets[s]->get_bound_sockets();\n+ bound_sockets.insert(bound_sockets.end(), bs.begin(), bs.end());\n+ for (auto sck : bs)\n{\nif (sck->get_task().get_socket_type(*sck) == module::socket_t::SIN_SOUT)\n{\n@@ -1092,6 +1092,7 @@ void Chain\ncontents->rebind_sockets[rebind_id].push_back(bound_sockets);\ncontents->rebind_dataptrs[rebind_id].push_back(dataptrs);\n}\n+ }\nmodified_tasks[pull_task] = [contents, pull_task, adp_pull, rebind_id]() -> int\n{\n@@ -1099,6 +1100,8 @@ void Chain\nint ret = pull_task->exec();\n// rebind input sockets on the fly\nfor (size_t sin_id = 0; sin_id < contents->rebind_sockets[rebind_id].size(); sin_id++)\n+ {\n+ if (contents->rebind_sockets[rebind_id][sin_id].size() > 1)\n{\n// we start to 1 because the rebinding of the 'pull_task' is made in the\n// 'pull_task->exec()' call (this way the debug mode is still working)\n@@ -1110,6 +1113,7 @@ void Chain\nfor (size_t ta = 2; ta < contents->rebind_sockets[rebind_id][sin_id].size(); ta++)\ncontents->rebind_sockets[rebind_id][sin_id][ta]->bind(buff);\n}\n+ }\nadp_pull->wake_up_pusher();\nreturn ret;\n};\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix bugs in prev. commit.
|
8,490 |
11.02.2020 14:31:17
| -3,600 |
2b10849c2b63daea6334066ab44e0bc970342b5c
|
Add priority parameter when socket binding.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hpp",
"new_path": "include/Module/Socket.hpp",
"diff": "@@ -54,9 +54,9 @@ public:\ninline void set_fast(const bool fast);\n- inline void bind(Socket &s_out, const bool copy_dataptr = true);\n+ inline void bind(Socket &s_out, const int priority = -1);\n- inline void operator()(Socket &s_out, const bool copy_dataptr = true);\n+ inline void operator()(Socket &s_out, const int priority = -1);\ntemplate <typename T, class A = std::allocator<T>>\ninline void bind(std::vector<T,A> &vector);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Socket.hxx",
"new_path": "include/Module/Socket.hxx",
"diff": "@@ -119,7 +119,7 @@ void Socket\n}\nvoid Socket\n-::bind(Socket &s_out, const bool copy_dataptr)\n+::bind(Socket &s_out, const int priority)\n{\nif (!is_fast())\n{\n@@ -156,7 +156,7 @@ void Socket\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if (copy_dataptr && s_out.dataptr == nullptr)\n+ if (s_out.dataptr == nullptr)\n{\nstd::stringstream message;\nmessage << \"'s_out.dataptr' can't be NULL.\";\n@@ -165,15 +165,17 @@ void Socket\n}\nthis->bound_socket = &s_out;\n+ if ((size_t)priority >= s_out.bound_sockets.size() || priority == -1)\ns_out.bound_sockets.push_back(this);\n- if (copy_dataptr)\n+ else\n+ s_out.bound_sockets.insert(s_out.bound_sockets.begin() + priority, this);\nthis->dataptr = s_out.dataptr;\n}\nvoid Socket\n-::operator()(Socket &s_out, const bool copy_dataptr)\n+::operator()(Socket &s_out, const int priority)\n{\n- bind(s_out, copy_dataptr);\n+ bind(s_out, priority);\n}\ntemplate <typename T, class A>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add priority parameter when socket binding.
|
8,490 |
17.02.2020 13:44:43
| -3,600 |
98b53ef60c54358075875479465c234157cdc680
|
Fix debug mode issue.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "@@ -233,7 +233,7 @@ int Task\n<< \"::\"\n<< rang::style::bold << rang::fg::magenta << get_name() << rang::style::reset\n<< \"(\";\n- for (auto i = 0; i < (int)sockets.size(); i++)\n+ for (auto i = 0; i < (int)sockets.size() -1; i++)\n{\nauto &s = *sockets[i];\nauto s_type = get_socket_type(s);\n@@ -242,7 +242,7 @@ int Task\n<< s.get_datatype_string() << rang::style::reset\n<< \" \" << s.get_name() << \"[\" << (n_fra > 1 ? std::to_string(n_fra) + \"x\" : \"\")\n<< (n_elmts / n_fra) << \"]\"\n- << (i < (int)sockets.size() -1 ? \", \" : \"\");\n+ << (i < (int)sockets.size() -2 ? \", \" : \"\");\nmax_n_chars = std::max(s.get_name().size(), max_n_chars);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix debug mode issue.
|
8,486 |
17.02.2020 18:05:25
| -3,600 |
a80cc2f160328c41b06797f7a22f443290fa8a67
|
Change Terminal_std to handle a list of Reporter*.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Display/Terminal/Standard/Terminal_std.hpp",
"new_path": "include/Tools/Display/Terminal/Standard/Terminal_std.hpp",
"diff": "@@ -37,9 +37,15 @@ public:\nstatic const int column_width;\nprotected:\n- const std::vector<std::unique_ptr<tools::Reporter>>& reporters;\n+ //const std::vector<std::unique_ptr<tools::Reporter>>& reporters;\n+ std::vector<tools::Reporter*> reporters;\npublic:\n+ /*!\n+ * \\brief Constructor.\n+ */\n+ explicit Terminal_std(const std::vector<tools::Reporter*>& reporters);\n+\n/*!\n* \\brief Constructor.\n*/\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"new_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"diff": "@@ -27,11 +27,21 @@ const int aff3ct::tools::Terminal_std::column_width = 10;\n#endif\nTerminal_std\n-::Terminal_std(const std::vector<std::unique_ptr<tools::Reporter>>& reporters)\n+::Terminal_std(const std::vector<tools::Reporter*>& reporters)\n: Terminal(), reporters(reporters)\n{\n}\n+Terminal_std\n+::Terminal_std(const std::vector<std::unique_ptr<tools::Reporter>>& reporters)\n+: Terminal(), reporters()\n+{\n+ for(auto const &r:reporters)\n+ {\n+ this->reporters.push_back(r.get());\n+ }\n+}\n+\nvoid Terminal_std\n::legend(std::ostream &stream) const\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change Terminal_std to handle a list of Reporter*.
|
8,490 |
18.02.2020 10:39:20
| 0 |
fbdef7a8bed58f065ebf1123fc072159fe119973
|
Add status enum and reserve negative statuses for specific signals.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Decoder/Decoder.hpp",
"new_path": "include/Module/Decoder/Decoder.hpp",
"diff": "@@ -48,6 +48,7 @@ protected:\nconst int simd_inter_frame_level; /*!< Number of frames absorbed by the SIMD instructions. */\nconst int n_dec_waves;\nbool auto_reset;\n+ const int mask;\npublic:\nDecoder(const int K, const int N, const int n_frames = 1, const int simd_inter_frame_level = 1);\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Decoder/Decoder_HIHO.hxx",
"new_path": "include/Module/Decoder/Decoder_HIHO.hxx",
"diff": "#include <string>\n+#include <limits>\n#include <sstream>\n#include <algorithm>\n@@ -182,8 +183,7 @@ int Decoder_HIHO<B>\nthis->V_KN.begin() + (w_pos +1) * this->K,\nV_K + (frame_id % this->n_frames) * this->K);\n}\n-\n- return status;\n+ return status & this->mask;\n}\ntemplate <typename B>\n@@ -219,8 +219,7 @@ int Decoder_HIHO<B>\nif (this->is_auto_reset())\nthis->reset(frame_id);\n-\n- return status;\n+ return status & this->mask;\n}\ntemplate <typename B>\n@@ -298,7 +297,7 @@ int Decoder_HIHO<B>\nthis->V_KN.begin() + (w_pos +1) * this->N,\nV_N + (frame_id % this->n_frames) * this->N);\n}\n- return status;\n+ return status & this->mask;\n}\ntemplate <typename B>\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Decoder/Decoder_SIHO.hxx",
"new_path": "include/Module/Decoder/Decoder_SIHO.hxx",
"diff": "#include <string>\n+#include <limits>\n#include <sstream>\n#include <algorithm>\n@@ -197,7 +198,7 @@ int Decoder_SIHO<B,R>\nthis->V_KN.begin() + (w_pos +1) * this->K,\nV_K + (frame_id % this->n_frames) * this->K);\n}\n- return status;\n+ return status & this->mask;\n}\ntemplate <typename B, typename R>\n@@ -307,7 +308,7 @@ int Decoder_SIHO<B,R>\nthis->V_KN.begin() + (w_pos +1) * this->N,\nV_N + (frame_id % this->n_frames) * this->N);\n}\n- return status;\n+ return status & this->mask;\n}\ntemplate <typename B, typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Decoder/Decoder_SISO.hxx",
"new_path": "include/Module/Decoder/Decoder_SISO.hxx",
"diff": "#include <string>\n+#include <limits>\n#include <sstream>\n#include <algorithm>\n@@ -161,8 +162,7 @@ int Decoder_SISO<B,R>\nif (this->is_auto_reset())\nthis->_reset(w * this->simd_inter_frame_level);\n}\n-\n- return status;\n+ return status & this->mask;\n}\ntemplate <typename B, typename R>\n@@ -272,7 +272,7 @@ int Decoder_SISO<B,R>\nthis->Y_N2.begin() + (w_pos +1) * this->N,\nY_N2 + (frame_id % this->n_frames) * this->N);\n}\n- return status;\n+ return status & this->mask;\n}\ntemplate <typename B, typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Tools/Chain/Chain.hpp",
"new_path": "include/Tools/Chain/Chain.hpp",
"diff": "#include <functional>\n#include <iostream>\n+#include <limits>\n#include <memory>\n#include <vector>\n#include <string>\n@@ -27,6 +28,8 @@ class Module;\nnamespace tools\n{\n+enum status_t : int { OK = 0, SKIPPED = std::numeric_limits<int>::min() };\n+\nenum class subseq_t : size_t { STD, LOOP, ROUTER };\ntemplate <class VTA = std::vector<module::Task*>>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Decoder.cpp",
"new_path": "src/Module/Decoder/Decoder.cpp",
"diff": "@@ -16,7 +16,8 @@ Decoder\nN(N),\nsimd_inter_frame_level(simd_inter_frame_level),\nn_dec_waves((int)std::ceil((float)this->n_frames / (float)simd_inter_frame_level)),\n- auto_reset(true)\n+ auto_reset(true),\n+ mask(std::numeric_limits<int>::max())\n{\nconst std::string name = \"Decoder\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "@@ -327,6 +327,13 @@ int Task\nstd::cout << \"#\" << std::endl;\n}\n+ if (exec_status < 0)\n+ {\n+ std::stringstream message;\n+ message << \"'exec_status' can't be negative ('exec_status' = \" << exec_status << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nreturn exec_status;\n}\nelse\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -352,6 +352,7 @@ void Chain\n{\ndo\n{\n+ std::fill(statuses.begin(), statuses.end(), tools::status_t::SKIPPED);\ntry\n{\nexec_sequence(sequence, statuses);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add status enum and reserve negative statuses for specific signals.
|
8,490 |
18.02.2020 15:05:51
| 0 |
44aed70c183264bd5a30f30c73f34ea0deeb0eb0
|
Add BCH decoder status.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/BCH/Standard/Decoder_BCH_std.cpp",
"new_path": "src/Module/Decoder/BCH/Standard/Decoder_BCH_std.cpp",
"diff": "@@ -204,10 +204,16 @@ int Decoder_BCH_std<B, R>\nif (loc[i] < this->N)\nY_N[loc[i]] ^= 1;\n}\n+\n+ return status_t::OK;\n}\n+ else\n+ return 1;\n+ }\n+ else\n+ {\n+ return status_t::OK;\n}\n-\n- return 0;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add BCH decoder status.
|
8,490 |
18.02.2020 15:06:18
| 0 |
a3d63f0e5162c4ac7d33077ddf89bb4366d609c4
|
Fix a bug in the chain construction.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -668,13 +668,13 @@ const module::Task& Chain\nif (¤t_task != last)\n{\n+ const module::Task* last_task = nullptr;\nfor (auto &s : current_task.sockets)\n{\nif (current_task.get_socket_type(*s) == module::socket_t::SIN_SOUT ||\ncurrent_task.get_socket_type(*s) == module::socket_t::SOUT)\n{\nauto bss = s->get_bound_sockets();\n- const module::Task* last_task = nullptr;\nfor (auto &bs : bss)\n{\nif (bs != nullptr)\n@@ -684,8 +684,6 @@ const module::Task& Chain\nlast_task = &Chain::init_recursive<SS,TA>(cur_subseq, ssid, taid, loops, first, t, last);\n}\n}\n- if (last_task)\n- return *last_task;\n}\nelse if (current_task.get_socket_type(*s) == module::socket_t::SIN)\n{\n@@ -703,6 +701,8 @@ const module::Task& Chain\n}\n}\n}\n+ if (last_task)\n+ return *last_task;\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix a bug in the chain construction.
|
8,490 |
20.02.2020 13:46:29
| 0 |
f9a12a2002c93cf03a2a80d1978cc3fac9e51ae1
|
Fix numbering in the adaptors.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"new_path": "include/Module/Adaptor/Adaptor_1_to_n.hxx",
"diff": "@@ -103,7 +103,7 @@ void Adaptor_1_to_n\nauto &p1 = this->create_task(\"push_1\", (int)adp::tsk::push_1);\nstd::vector<size_t> p1s_in;\nfor (size_t s = 0; s < this->n_sockets; s++)\n- p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s], \"in\" + std::to_string(s)));\n+ p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s], \"in\" + std::to_string(s+1)));\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n{\n@@ -128,7 +128,7 @@ void Adaptor_1_to_n\nauto &p2 = this->create_task(\"pull_n\", (int)adp::tsk::pull_n);\nstd::vector<size_t> p2s_out;\nfor (size_t s = 0; s < this->n_sockets; s++)\n- p2s_out.push_back(create_socket_out(p2, this->n_elmts[s], this->datatype[s], \"out\" + std::to_string(s)));\n+ p2s_out.push_back(create_socket_out(p2, this->n_elmts[s], this->datatype[s], \"out\" + std::to_string(s+1)));\nthis->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"new_path": "include/Module/Adaptor/Adaptor_n_to_1.hxx",
"diff": "@@ -103,7 +103,7 @@ void Adaptor_n_to_1\nauto &p1 = this->create_task(\"push_n\", (int)adp::tsk::push_n);\nstd::vector<size_t> p1s_in;\nfor (size_t s = 0; s < this->n_sockets; s++)\n- p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s], \"in\" + std::to_string(s)));\n+ p1s_in.push_back(create_socket_in(p1, this->n_elmts[s], this->datatype[s], \"in\" + std::to_string(s+1)));\nthis->create_codelet(p1, [p1s_in](Module &m, Task &t) -> int\n{\n@@ -128,7 +128,7 @@ void Adaptor_n_to_1\nauto &p2 = this->create_task(\"pull_1\", (int)adp::tsk::pull_1);\nstd::vector<size_t> p2s_out;\nfor (size_t s = 0; s < this->n_sockets; s++)\n- p2s_out.push_back(create_socket_out(p2, this->n_elmts[s], this->datatype[s], \"out\" + std::to_string(s)));\n+ p2s_out.push_back(create_socket_out(p2, this->n_elmts[s], this->datatype[s], \"out\" + std::to_string(s+1)));\nthis->create_codelet(p2, [p2s_out](Module &m, Task &t) -> int\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix numbering in the adaptors.
|
8,490 |
20.02.2020 13:47:09
| 0 |
8e17b369b36e028fb4ce7bd81d55901950426734
|
Add a new terminal to dump stats frame by frame.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "include/Tools/Display/Terminal/Dump/Terminal_dump.hpp",
"diff": "+/*!\n+ * \\file\n+ * \\brief Class tools::Terminal_dump.\n+ */\n+#ifndef TERMINAL_DUMP_HPP_\n+#define TERMINAL_DUMP_HPP_\n+\n+#include <iostream>\n+#include <vector>\n+\n+#include \"Tools/Display/Reporter/Reporter.hpp\"\n+#include \"Tools/Display/Terminal/Standard/Terminal_std.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+/*!\n+ * \\class Terminal_dump\n+ *\n+ * \\brief The Terminal_dump display.\n+ */\n+class Terminal_dump : public Terminal_std\n+{\n+public:\n+ /*!\n+ * \\brief Constructor.\n+ */\n+ explicit Terminal_dump(const std::vector<tools::Reporter*>& reporters);\n+\n+ /*!\n+ * \\brief Constructor.\n+ */\n+ explicit Terminal_dump(const std::vector<std::unique_ptr<tools::Reporter>>& reporters);\n+\n+ /*!\n+ * \\brief Destructor.\n+ */\n+ virtual ~Terminal_dump() = default;\n+\n+protected:\n+ virtual void report(std::ostream &stream = std::cout, bool final = false);\n+};\n+}\n+}\n+\n+#endif /* TERMINAL_DUMP_HPP_ */\n"
},
{
"change_type": "MODIFY",
"old_path": "include/aff3ct.hpp",
"new_path": "include/aff3ct.hpp",
"diff": "#ifndef STATISTICS_HPP_\n#include <Tools/Display/Statistics/Statistics.hpp>\n#endif\n+#ifndef TERMINAL_DUMP_HPP_\n+#include <Tools/Display/Terminal/Dump/Terminal_dump.hpp>\n+#endif\n#ifndef TERMINAL_STD_HPP_\n#include <Tools/Display/Terminal/Standard/Terminal_std.hpp>\n#endif\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Display/Terminal/Dump/Terminal_dump.cpp",
"diff": "+#include <algorithm>\n+#include <cassert>\n+#include <iomanip>\n+#include <cmath>\n+#include <ios>\n+\n+#include \"Tools/Display/rang_format/rang_format.h\"\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Display/Terminal/Dump/Terminal_dump.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::tools;\n+\n+Terminal_dump\n+::Terminal_dump(const std::vector<tools::Reporter*>& reporters)\n+: Terminal_std(reporters)\n+{\n+}\n+\n+Terminal_dump\n+::Terminal_dump(const std::vector<std::unique_ptr<tools::Reporter>>& reporters)\n+: Terminal_std(reporters)\n+{\n+}\n+\n+void Terminal_dump\n+::report(std::ostream &stream, bool final)\n+{\n+ std::ios::fmtflags f(stream.flags());\n+\n+ std::vector<Reporter::report_t> report_list;\n+ for (unsigned r = 0; r < this->reporters.size(); r++)\n+ report_list.push_back(this->reporters[r]->report(final));\n+\n+ bool is_not_over = true;\n+ while (is_not_over)\n+ {\n+ stream << data_tag;\n+\n+ is_not_over = false;\n+ for (unsigned r = 0; r < this->reporters.size(); r++)\n+ if (this->reporters[r] != nullptr)\n+ {\n+ auto& report = report_list[r];\n+ auto& groups = this->reporters[r]->get_groups();\n+\n+ assert(report.size() == groups.size());\n+\n+ for (unsigned g = 0; g < groups.size(); g++)\n+ {\n+ if (report[g].size())\n+ assert(report[g].size() % groups[g].second.size() == 0);\n+\n+ stream << report_style << std::string(extra_spaces(groups[g]), ' ') << rang::style::reset;\n+\n+ for (unsigned c = 0; c < groups[g].second.size(); c++)\n+ {\n+ auto text = report[g].size() ? report[g][c] : \"-\";\n+\n+ if (text.size() < (size_t)column_width)\n+ {\n+ text += \" \";\n+ text.insert(0, column_width - text.size(), ' ');\n+ }\n+\n+ stream << text;\n+\n+ if (c != (groups[g].second.size() - 1))\n+ stream << report_style << col_separator << rang::style::reset;\n+ }\n+ if (report[g].size())\n+ report[g].erase(report[g].begin(), report[g].begin() + groups[g].second.size());\n+ is_not_over = is_not_over ? is_not_over : report[g].size() > 0;\n+\n+ if (g != (groups.size() - 1))\n+ stream << report_style << group_separator << rang::style::reset;\n+ }\n+\n+ if (r != (this->reporters.size() - 1))\n+ stream << report_style << group_separator << rang::style::reset;\n+ }\n+ else\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, \"'this->reporters' contains null pointer.\");\n+\n+ stream << std::endl;\n+ }\n+\n+ stream.flags(f);\n+ stream.flush();\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"new_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"diff": "@@ -249,7 +249,7 @@ void Terminal_std\n{\nauto& text = report[g][c];\n- if (text.size() < column_width)\n+ if (text.size() < (size_t)column_width)\n{\ntext += \" \";\ntext.insert(0, column_width - text.size(), ' ');\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a new terminal to dump stats frame by frame.
|
8,486 |
20.02.2020 15:22:23
| 0 |
8e550eac5da4dd9f8f930ee5b9aea679c6218ca4
|
Add FRA BE FE BER and FER as output sockets for monitor BFER.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Monitor/BFER/Monitor_BFER.hpp",
"new_path": "include/Module/Monitor/BFER/Monitor_BFER.hpp",
"diff": "@@ -72,9 +72,9 @@ public:\n* \\param Y: the decoded message (from the Decoder).\n*/\ntemplate <class A = std::allocator<B>>\n- int check_errors(const std::vector<B,A>& U, const std::vector<B,A>& Y, const int frame_id = -1);\n+ int check_errors(const std::vector<B,A>& U, const std::vector<B,A>& Y, std::vector<int64_t>& FRA, std::vector<int64_t>& BE, std::vector<int64_t>& FE, std::vector<float>& BER, std::vector<float>& FER, const int frame_id = -1);\n- virtual int check_errors(const B *U, const B *Y, const int frame_id = -1);\n+ virtual int check_errors(const B *U, const B *Y, int64_t *FRA, int64_t *BE, int64_t *FE, float *BER, float *FER, const int frame_id = -1);\nbool fe_limit_achieved() const;\nbool frame_limit_achieved() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Monitor/BFER/Monitor_BFER.hxx",
"new_path": "include/Module/Monitor/BFER/Monitor_BFER.hxx",
"diff": "@@ -26,7 +26,7 @@ Socket& Monitor_BFER<B>\ntemplate <typename B>\ntemplate <class A>\nint Monitor_BFER<B>\n-::check_errors(const std::vector<B,A>& U, const std::vector<B,A>& Y, const int frame_id)\n+::check_errors(const std::vector<B,A>& U, const std::vector<B,A>& Y, std::vector<int64_t>& FRA, std::vector<int64_t>& BE, std::vector<int64_t>& FE, std::vector<float>& BER, std::vector<float>& FER, const int frame_id)\n{\nif ((int)U.size() != this->K * this->n_frames)\n{\n@@ -44,6 +44,46 @@ int Monitor_BFER<B>\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n+ if ((int)FRA.size() != this->n_frames)\n+ {\n+ std::stringstream message;\n+ message << \"'FRA.size()' has to be equal to 'n_frames' ('FRA.size()' = \" << FRA.size()\n+ << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if ((int)BE.size() != this->n_frames)\n+ {\n+ std::stringstream message;\n+ message << \"'BE.size()' has to be equal to 'n_frames' ('BE.size()' = \" << BE.size()\n+ << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if ((int)FE.size() != this->n_frames)\n+ {\n+ std::stringstream message;\n+ message << \"'FE.size()' has to be equal to 'n_frames' ('FE.size()' = \" << FE.size()\n+ << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if ((int)BER.size() != this->n_frames)\n+ {\n+ std::stringstream message;\n+ message << \"'BER.size()' has to be equal to 'n_frames' ('BER.size()' = \" << BER.size()\n+ << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if ((int)FER.size() != this->n_frames)\n+ {\n+ std::stringstream message;\n+ message << \"'FER.size()' has to be equal to 'n_frames' ('FER.size()' = \" << FER.size()\n+ << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nif (frame_id != -1 && frame_id >= this->n_frames)\n{\nstd::stringstream message;\n@@ -52,7 +92,7 @@ int Monitor_BFER<B>\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- return this->check_errors(U.data(), Y.data(), frame_id);\n+ return this->check_errors(U.data(), Y.data(), FRA.data(), BE.data(), FE.data(), BER.data(), FER.data(), frame_id);\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Monitor/Monitor.hpp",
"new_path": "include/Module/Monitor/Monitor.hpp",
"diff": "@@ -21,7 +21,7 @@ namespace module\nnamespace sck\n{\n- enum class check_errors : size_t { U, V, status };\n+ enum class check_errors : size_t { U, V, FRA, BE, FE, BER, FER, status };\nenum class get_mutual_info : size_t { X, Y, status };\nenum class check_mutual_info : size_t { bits, llrs_a, llrs_e, status };\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -29,10 +29,22 @@ Monitor_BFER<B>\nauto &p = this->create_task(\"check_errors\", (int)mnt::tsk::check_errors);\nauto ps_U = this->template create_socket_in <B >(p, \"U\", get_K());\nauto ps_V = this->template create_socket_in <B >(p, \"V\", get_K());\n- this->create_codelet(p, [ps_U, ps_V](Module &m, Task &t) -> int\n+ auto ps_FRA = this->template create_socket_out<int64_t>(p, \"FRA\", 1 );\n+ auto ps_BE = this->template create_socket_out<int64_t>(p, \"BE\", 1 );\n+ auto ps_FE = this->template create_socket_out<int64_t>(p, \"FE\", 1 );\n+ auto ps_BER = this->template create_socket_out<float >(p, \"BER\", 1 );\n+ auto ps_FER = this->template create_socket_out<float >(p, \"FER\", 1 );\n+\n+ this->create_codelet(p, [ps_U, ps_V, ps_FRA, ps_BE, ps_FE, ps_BER, ps_FER](Module &m, Task &t) -> int\n{\nreturn static_cast<Monitor_BFER<B>&>(m).check_errors(static_cast<B* >(t[ps_U ].get_dataptr()),\n- static_cast<B*>(t[ps_V].get_dataptr()));\n+ static_cast<B* >(t[ps_V ].get_dataptr()),\n+ static_cast<int64_t*>(t[ps_FRA].get_dataptr()),\n+ static_cast<int64_t*>(t[ps_BE ].get_dataptr()),\n+ static_cast<int64_t*>(t[ps_FE ].get_dataptr()),\n+ static_cast<float* >(t[ps_BER].get_dataptr()),\n+ static_cast<float* >(t[ps_FER].get_dataptr())\n+ );\n});\nreset();\n@@ -122,16 +134,23 @@ bool Monitor_BFER<B>\ntemplate <typename B>\nint Monitor_BFER<B>\n-::check_errors(const B *U, const B *V, const int frame_id)\n+::check_errors(const B *U, const B *V, int64_t *FRA, int64_t *BE, int64_t *FE, float *BER, float *FER, const int frame_id)\n{\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % get_n_frames();\nconst auto f_stop = (frame_id < 0) ? get_n_frames() : f_start +1;\nint n_be = 0;\nfor (auto f = f_start; f < f_stop; f++)\n+ {\nn_be += this->_check_errors(U + f * get_K(),\nV + f * get_K(),\nf);\n+ FRA[f] = (int64_t)this->get_n_analyzed_fra();\n+ BE [f] = (int64_t)this->get_n_be();\n+ FE [f] = (int64_t)this->get_n_fe();\n+ BER[f] = this->get_ber();\n+ FER[f] = this->get_fer();\n+ }\nthis->callback_check.notify();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add FRA BE FE BER and FER as output sockets for monitor BFER.
|
8,490 |
21.02.2020 13:35:11
| 0 |
0c553edf832d189a1b06a1a118a7e30169342c8c
|
Fix tasks_id copy bug in chain.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Chain/Chain.cpp",
"new_path": "src/Tools/Chain/Chain.cpp",
"diff": "@@ -799,6 +799,7 @@ void Chain\nss_cpy->type = ss_ref->type;\nss_cpy->id = ss_ref->id;\n+ ss_cpy->tasks_id = ss_ref->tasks_id;\nfor (auto t_ref : ss_ref->tasks)\n{\nauto &m_ref = t_ref->get_module();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix tasks_id copy bug in chain.
|
8,490 |
21.02.2020 15:01:35
| 0 |
602f5c79570587579c99e53885acbc31e0f46683
|
Try to fix CI bug.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "@@ -323,8 +323,8 @@ int Task\nstd::cout << \"]\" << std::endl;\n}\n}\n- std::cout << \"# Returned status: \" << std::hex << exec_status << std::endl;\n- std::cout << \"#\" << std::endl;\n+ std::cout << \"# Returned status: \" << std::hex << std::showbase << exec_status << std::endl;\n+ std::cout << \"#\" << std::noshowbase << std::endl;\n}\nif (exec_status < 0)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Try to fix CI bug.
|
8,490 |
25.02.2020 07:03:25
| 0 |
e05359a00ed3c92c30c027c8567a62f8e9a27292
|
Put instant BE and FE in output sockets instead of total.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Module/Monitor/BFER/Monitor_BFER.hpp",
"new_path": "include/Module/Monitor/BFER/Monitor_BFER.hpp",
"diff": "@@ -74,7 +74,7 @@ public:\ntemplate <class A = std::allocator<B>>\nint check_errors(const std::vector<B,A>& U, const std::vector<B,A>& Y, std::vector<int64_t>& FRA, std::vector<int64_t>& BE, std::vector<int64_t>& FE, std::vector<float>& BER, std::vector<float>& FER, const int frame_id = -1);\n- virtual int check_errors(const B *U, const B *Y, int64_t *FRA, int64_t *BE, int64_t *FE, float *BER, float *FER, const int frame_id = -1);\n+ virtual int check_errors(const B *U, const B *Y, int64_t *FRA, int32_t *BE, int32_t *FE, float *BER, float *FER, const int frame_id = -1);\nbool fe_limit_achieved() const;\nbool frame_limit_achieved() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -30,8 +30,8 @@ Monitor_BFER<B>\nauto ps_U = this->template create_socket_in <B >(p, \"U\", get_K());\nauto ps_V = this->template create_socket_in <B >(p, \"V\", get_K());\nauto ps_FRA = this->template create_socket_out<int64_t>(p, \"FRA\", 1 );\n- auto ps_BE = this->template create_socket_out<int64_t>(p, \"BE\", 1 );\n- auto ps_FE = this->template create_socket_out<int64_t>(p, \"FE\", 1 );\n+ auto ps_BE = this->template create_socket_out<int32_t>(p, \"BE\", 1 );\n+ auto ps_FE = this->template create_socket_out<int32_t>(p, \"FE\", 1 );\nauto ps_BER = this->template create_socket_out<float >(p, \"BER\", 1 );\nauto ps_FER = this->template create_socket_out<float >(p, \"FER\", 1 );\n@@ -40,8 +40,8 @@ Monitor_BFER<B>\nreturn static_cast<Monitor_BFER<B>&>(m).check_errors(static_cast<B* >(t[ps_U ].get_dataptr()),\nstatic_cast<B* >(t[ps_V ].get_dataptr()),\nstatic_cast<int64_t*>(t[ps_FRA].get_dataptr()),\n- static_cast<int64_t*>(t[ps_BE ].get_dataptr()),\n- static_cast<int64_t*>(t[ps_FE ].get_dataptr()),\n+ static_cast<int32_t*>(t[ps_BE ].get_dataptr()),\n+ static_cast<int32_t*>(t[ps_FE ].get_dataptr()),\nstatic_cast<float* >(t[ps_BER].get_dataptr()),\nstatic_cast<float* >(t[ps_FER].get_dataptr())\n);\n@@ -134,20 +134,22 @@ bool Monitor_BFER<B>\ntemplate <typename B>\nint Monitor_BFER<B>\n-::check_errors(const B *U, const B *V, int64_t *FRA, int64_t *BE, int64_t *FE, float *BER, float *FER, const int frame_id)\n+::check_errors(const B *U, const B *V, int64_t *FRA, int32_t *BE, int32_t *FE, float *BER, float *FER, const int frame_id)\n{\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % get_n_frames();\nconst auto f_stop = (frame_id < 0) ? get_n_frames() : f_start +1;\n- int n_be = 0;\n+ int n_be_total = 0;\nfor (auto f = f_start; f < f_stop; f++)\n{\n- n_be += this->_check_errors(U + f * get_K(),\n+ auto n_be = this->_check_errors(U + f * get_K(),\nV + f * get_K(),\nf);\n+ n_be_total += n_be;\n+\nFRA[f] = (int64_t)this->get_n_analyzed_fra();\n- BE [f] = (int64_t)this->get_n_be();\n- FE [f] = (int64_t)this->get_n_fe();\n+ BE [f] = n_be;\n+ FE [f] = n_be ? 1 : 0;\nBER[f] = this->get_ber();\nFER[f] = this->get_fer();\n}\n@@ -157,7 +159,7 @@ int Monitor_BFER<B>\nif (this->fe_limit_achieved())\nthis->callback_fe_limit_achieved.notify();\n- return n_be;\n+ return n_be_total;\n}\ntemplate <typename B>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Put instant BE and FE in output sockets instead of total.
|
8,490 |
25.02.2020 09:08:08
| 0 |
f2f2dcce11b98f8b7c33c33f136fc90307ca779f
|
Switch from hexadecimal to decimal output for the task status.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "@@ -323,7 +323,7 @@ int Task\nstd::cout << \"]\" << std::endl;\n}\n}\n- std::cout << \"# Returned status: \" << std::hex << std::showbase << exec_status << std::endl;\n+ std::cout << \"# Returned status: \" << std::dec << exec_status << std::endl;\nstd::cout << \"#\" << std::noshowbase << std::endl;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Switch from hexadecimal to decimal output for the task status.
|
8,490 |
25.02.2020 10:46:34
| -3,600 |
422550e68a20fb34bbb8b5ee5030b64a3aebef6c
|
Add a static init method to the terminal.
|
[
{
"change_type": "MODIFY",
"old_path": "include/Tools/Display/Terminal/Terminal.hpp",
"new_path": "include/Tools/Display/Terminal/Terminal.hpp",
"diff": "@@ -76,6 +76,8 @@ public:\nvoid stop_temp_report();\n+ static void init();\n+\n/*!\n* \\brief Tells if the user asked for stopping the current computations.\n*\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.cpp",
"new_path": "src/Tools/Display/Terminal/Terminal.cpp",
"diff": "@@ -25,7 +25,12 @@ Terminal\nreal_time_state(0)\n{\nTerminal::interrupt = false;\n+ Terminal::init();\n+}\n+void Terminal\n+::init()\n+{\n// Install a signal handler\n#if !defined(_WIN64) && !defined(_WIN32)\nstd::signal(SIGUSR1, Terminal::signal_interrupt_handler);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a static init method to the terminal.
|
8,490 |
28.02.2020 15:41:57
| -3,600 |
a082a375d452bcdb25f44577b425a4361674a76b
|
Add a FIFO flag to enable read retry in binary source.
|
[
{
"change_type": "MODIFY",
"old_path": "doc/source/user/simulation/parameters/source/source.rst",
"new_path": "doc/source/user/simulation/parameters/source/source.rst",
"diff": "@@ -163,6 +163,13 @@ With the ``USER`` source type, an |ASCII| file is expected:\n|factory::Source::p+no-reset|\n+.. _src-src-fifo:\n+\n+``--src-fifo``\n+\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n+\n+|factory::Source::p+fifo|\n+\n.. _src-src-start-idx:\n``--src-start-idx``\n"
},
{
"change_type": "MODIFY",
"old_path": "doc/strings.rst",
"new_path": "doc/strings.rst",
"diff": "Do not reset the source (start to the beginning) if the file reach |EOF| and\npad with zeros after |EOF| (work only for ``USER_BIN`` source type).\n+.. |factory::Source::p+fifo| replace::\n+ If the FIFO (or pipe) reach the end, then reset the |EOF| flag and retry to\n+ read in loop.\n+\n.. ------------------------------------ factory Frozenbits_generator parameters\n.. |factory::Frozenbits_generator::p+info-bits,K| replace::\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Factory/Module/Source/Source.hpp",
"new_path": "include/Factory/Module/Source/Source.hpp",
"diff": "@@ -31,6 +31,7 @@ public:\nstd::string implem = \"STD\";\nstd::string path = \"\";\nbool auto_reset = true;\n+ bool fifo_mode = false;\nint n_frames = 1;\nint seed = 0;\nint start_idx = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "include/Module/Source/User/Source_user_binary.hpp",
"new_path": "include/Module/Source/User/Source_user_binary.hpp",
"diff": "@@ -18,13 +18,18 @@ class Source_user_binary : public Source<B>\nprivate:\nstd::ifstream source_file;\nconst bool auto_reset;\n+ const bool fifo_mode;\nbool over;\nsize_t n_left;\nstd::vector<char> memblk;\nstd::vector<B> left_bits; // to store bits that are left by last call (n_left & n_completing)\npublic:\n- Source_user_binary(const int K, std::string filename, const bool auto_reset = true, const int n_frames = 1);\n+ Source_user_binary(const int K,\n+ const std::string &filename,\n+ const bool auto_reset = true,\n+ const bool fifo_mode = false,\n+ const int n_frames = 1);\nvirtual ~Source_user_binary() = default;\nvirtual bool is_over() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Source/Source.cpp",
"new_path": "src/Factory/Module/Source/Source.cpp",
"diff": "@@ -57,6 +57,9 @@ void Source\ntools::add_arg(args, p, class_name+\"p+no-reset\",\ncli::None());\n+\n+ tools::add_arg(args, p, class_name+\"p+fifo\",\n+ cli::None());\n}\nvoid Source\n@@ -72,6 +75,10 @@ void Source\nif(vals.exist({p+\"-seed\", \"S\"})) this->seed = vals.to_int ({p+\"-seed\", \"S\"});\nif(vals.exist({p+\"-start-idx\" })) this->start_idx = vals.to_int ({p+\"-start-idx\" });\nif(vals.exist({p+\"-no-reset\" })) this->auto_reset = false;\n+ if(vals.exist({p+\"-fifo\" })) this->fifo_mode = true;\n+\n+ if (this->fifo_mode)\n+ this->auto_reset = true;\n}\nvoid Source\n@@ -88,7 +95,10 @@ void Source\nif (this->type == \"RAND\" && full)\nheaders[p].push_back(std::make_pair(\"Seed\", std::to_string(this->seed)));\nif (this->type == \"USER_BIN\")\n+ {\nheaders[p].push_back(std::make_pair(\"Auto reset\", std::string(this->auto_reset ? \"on\" : \"off\")));\n+ headers[p].push_back(std::make_pair(\"Fifo mode\", std::string(this->auto_reset ? \"on\" : \"off\")));\n+ }\n}\n@@ -108,7 +118,7 @@ module::Source<B>* Source\nif (this->type == \"USER\") return new module::Source_user<B>(this->K, this->path, this->n_frames, this->start_idx);\nif (this->type == \"USER_BIN\")\n- return new module::Source_user_binary<B>(this->K, this->path, this->auto_reset, this->n_frames);\n+ return new module::Source_user_binary<B>(this->K, this->path, this->auto_reset, this->fifo_mode, this->n_frames);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Source/User/Source_user_binary.cpp",
"new_path": "src/Module/Source/User/Source_user_binary.cpp",
"diff": "@@ -7,10 +7,15 @@ using namespace aff3ct::module;\ntemplate <typename B>\nSource_user_binary<B>\n-::Source_user_binary(const int K, const std::string filename, const bool auto_reset, const int n_frames)\n+::Source_user_binary(const int K,\n+ const std::string &filename,\n+ const bool auto_reset,\n+ const bool fifo_mode,\n+ const int n_frames)\n: Source<B>(K, n_frames),\nsource_file(filename.c_str(), std::ios::in | std::ios::binary),\n- auto_reset(auto_reset),\n+ auto_reset(fifo_mode ? true : auto_reset),\n+ fifo_mode(fifo_mode),\nover(false),\nn_left(0),\nmemblk(K),\n@@ -32,6 +37,7 @@ void Source_user_binary<B>\n::reset()\n{\nsource_file.clear();\n+ if (!this->fifo_mode)\nsource_file.seekg(0, std::ios::beg);\nif (source_file.fail())\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, \"Could not go back to the beginning of the file.\");\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a FIFO flag to enable read retry in binary source.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.