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
03.07.2018 14:17:10
-7,200
e0ee680c4ce7ae6c913303b54426d775c8406b32
Rename 'BP_LAYERED' in 'BP_HORIZONTAL_LAYERED'.
[ { "change_type": "MODIFY", "old_path": "refs", "new_path": "refs", "diff": "-Subproject commit 2e83d27d36a32742ce471d238ac6660d10247906\n+Subproject commit 17a8f91e7cb887c2c5c94b72e15918e0ffc0b4cf\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp", "new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp", "diff": "#include \"Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp\"\n#include \"Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hpp\"\n-#include \"Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hpp\"\n+#include \"Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/LSPA/Update_rule_LSPA.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/AMS/Update_rule_AMS.hpp\"\n#ifdef __cpp_aligned_new\n-#include \"Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered_inter.hpp\"\n+#include \"Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hpp\"\n#include \"Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding_inter.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/MS/Update_rule_MS_inter.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/OMS/Update_rule_OMS_inter.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/NMS/Update_rule_NMS_inter.hpp\"\n#endif\n-#include \"Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.hpp\"\n+#include \"Module/Decoder/LDPC/BP/Horizontal_layered/ONMS/Decoder_LDPC_BP_horizontal_layered_ONMS_inter.hpp\"\n#include \"Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.hpp\"\n#include \"Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.hpp\"\n@@ -68,9 +68,9 @@ void Decoder_LDPC::parameters\nargs.add_link({p+\"-h-path\"}, {p+\"-info-bits\", \"K\"}); // if there is no K, then H is considered regular,\n// so K is the N - H's height\n- tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_FLOODING\", \"BP_LAYERED\", \"BP_PEELING\");\n+ tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_FLOODING\", \"BP_HORIZONTAL_LAYERED\", \"BP_PEELING\");\n#ifdef __cpp_aligned_new\n- tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_LAYERED_LEGACY\");\n+ tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_HORIZONTAL_LAYERED_LEGACY\");\n#endif\ntools::add_options(args.at({p+\"-implem\" }), 0, \"SPA\", \"LSPA\", \"MS\", \"OMS\", \"NMS\", \"AMS\", \"GALA\");\n@@ -199,56 +199,56 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\nelse if (this->min == \"MINS\") return new module::Decoder_LDPC_BP_flooding<B,Q,tools::Update_rule_AMS <Q,tools::min_star <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min_star <Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n}\n- else if (this->type == \"BP_LAYERED\" && this->simd_strategy.empty())\n+ else if (this->type == \"BP_HORIZONTAL_LAYERED\" && this->simd_strategy.empty())\n{\nconst auto max_CN_degree = H.get_cols_max_degree();\n- if (this->implem == \"MS\" ) return new module::Decoder_LDPC_BP_layered<B,Q,tools::Update_rule_MS <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_MS <Q >( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->implem == \"OMS\" ) return new module::Decoder_LDPC_BP_layered<B,Q,tools::Update_rule_OMS <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_OMS <Q >((Q)this->offset ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->implem == \"NMS\" ) return new module::Decoder_LDPC_BP_layered<B,Q,tools::Update_rule_NMS <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS <Q >(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->implem == \"SPA\" ) return new module::Decoder_LDPC_BP_layered<B,Q,tools::Update_rule_SPA <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_SPA <Q >(max_CN_degree ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->implem == \"LSPA\") return new module::Decoder_LDPC_BP_layered<B,Q,tools::Update_rule_LSPA<Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_LSPA<Q >(max_CN_degree ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ if (this->implem == \"MS\" ) return new module::Decoder_LDPC_BP_horizontal_layered<B,Q,tools::Update_rule_MS <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_MS <Q >( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"OMS\" ) return new module::Decoder_LDPC_BP_horizontal_layered<B,Q,tools::Update_rule_OMS <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_OMS <Q >((Q)this->offset ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"NMS\" ) return new module::Decoder_LDPC_BP_horizontal_layered<B,Q,tools::Update_rule_NMS <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS <Q >(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"SPA\" ) return new module::Decoder_LDPC_BP_horizontal_layered<B,Q,tools::Update_rule_SPA <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_SPA <Q >(max_CN_degree ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"LSPA\") return new module::Decoder_LDPC_BP_horizontal_layered<B,Q,tools::Update_rule_LSPA<Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_LSPA<Q >(max_CN_degree ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\nelse if (this->implem == \"AMS\" )\n{\n- if (this->min == \"MIN\" ) return new module::Decoder_LDPC_BP_layered<B,Q,tools::Update_rule_AMS <Q,tools::min <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min <Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->min == \"MINL\") return new module::Decoder_LDPC_BP_layered<B,Q,tools::Update_rule_AMS <Q,tools::min_star_linear2<Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min_star_linear2<Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->min == \"MINS\") return new module::Decoder_LDPC_BP_layered<B,Q,tools::Update_rule_AMS <Q,tools::min_star <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min_star <Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ if (this->min == \"MIN\" ) return new module::Decoder_LDPC_BP_horizontal_layered<B,Q,tools::Update_rule_AMS <Q,tools::min <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min <Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->min == \"MINL\") return new module::Decoder_LDPC_BP_horizontal_layered<B,Q,tools::Update_rule_AMS <Q,tools::min_star_linear2<Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min_star_linear2<Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->min == \"MINS\") return new module::Decoder_LDPC_BP_horizontal_layered<B,Q,tools::Update_rule_AMS <Q,tools::min_star <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min_star <Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n}\n#ifdef __cpp_aligned_new\n- else if (this->type == \"BP_LAYERED\" && this->simd_strategy == \"INTER\")\n+ else if (this->type == \"BP_HORIZONTAL_LAYERED\" && this->simd_strategy == \"INTER\")\n{\n- if (this->implem == \"MS\" ) return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_MS_inter <Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_MS_inter <Q>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->implem == \"OMS\") return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_OMS_inter<Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_OMS_inter<Q>(this->offset), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ if (this->implem == \"MS\" ) return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_MS_inter <Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_MS_inter <Q>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"OMS\") return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_OMS_inter<Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_OMS_inter<Q>(this->offset), this->enable_syndrome, this->syndrome_depth, this->n_frames);\nelse if (this->implem == \"NMS\")\n{\nif (typeid(Q) == typeid(int16_t) || typeid(Q) == typeid(int8_t))\n{\n- if (this->norm_factor == 0.125f) return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,1>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,1>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->norm_factor == 0.250f) return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,2>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,2>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->norm_factor == 0.375f) return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,3>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,3>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->norm_factor == 0.500f) return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,4>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,4>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->norm_factor == 0.625f) return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,5>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,5>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->norm_factor == 0.750f) return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,6>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,6>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->norm_factor == 0.875f) return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,7>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,7>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->norm_factor == 1.000f) return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,8>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,8>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ if (this->norm_factor == 0.125f) return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,1>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,1>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.250f) return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,2>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,2>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.375f) return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,3>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,3>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.500f) return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,4>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,4>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.625f) return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,5>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,5>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.750f) return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,6>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,6>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.875f) return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,7>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,7>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 1.000f) return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,8>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,8>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\nelse\n- return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\nelse\n- return new module::Decoder_LDPC_BP_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ return new module::Decoder_LDPC_BP_horizontal_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n}\n#endif\n#ifdef __cpp_aligned_new\n- else if (this->type == \"BP_LAYERED_LEGACY\" && this->simd_strategy == \"INTER\")\n+ else if (this->type == \"BP_HORIZONTAL_LAYERED_LEGACY\" && this->simd_strategy == \"INTER\")\n#else\n- else if (this->type == \"BP_LAYERED\" && this->simd_strategy == \"INTER\")\n+ else if (this->type == \"BP_HORIZONTAL_LAYERED\" && this->simd_strategy == \"INTER\")\n#endif\n{\n- if (this->implem == \"MS\" ) return new module::Decoder_LDPC_BP_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, 1.f , (Q)0 , this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->implem == \"NMS\") return new module::Decoder_LDPC_BP_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->norm_factor, (Q)0 , this->enable_syndrome, this->syndrome_depth, this->n_frames);\n- else if (this->implem == \"OMS\") return new module::Decoder_LDPC_BP_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, 1.f , (Q)this->offset, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ if (this->implem == \"MS\" ) return new module::Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, 1.f , (Q)0 , this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"NMS\") return new module::Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->norm_factor, (Q)0 , this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"OMS\") return new module::Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, 1.f , (Q)this->offset, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n#ifdef __cpp_aligned_new\nelse if (this->type == \"BP_FLOODING\" && this->simd_strategy == \"INTER\")\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding_inter.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding_inter.hxx", "diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Perf/Reorderer/Reorderer.hpp\"\n-#include \"../Layered/Decoder_LDPC_BP_layered_inter.hpp\"\n+#include \"../Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hpp\"\n#include \"Decoder_LDPC_BP_flooding_inter.hpp\"\nnamespace aff3ct\n" }, { "change_type": "RENAME", "old_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hpp", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hpp", "diff": "-#ifndef DECODER_LDPC_BP_LAYERED_HPP_\n-#define DECODER_LDPC_BP_LAYERED_HPP_\n+#ifndef DECODER_LDPC_BP_HORIZONTAL_LAYERED_HPP_\n+#define DECODER_LDPC_BP_HORIZONTAL_LAYERED_HPP_\n#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp\"\n@@ -12,7 +12,7 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename B = int, typename R = float, class Update_rule = tools::Update_rule_SPA<R>>\n-class Decoder_LDPC_BP_layered : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n+class Decoder_LDPC_BP_horizontal_layered : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n{\nprotected:\nconst std::vector<uint32_t> &info_bits_pos;\n@@ -27,14 +27,14 @@ protected:\nbool init_flag; // reset the chk_to_var vector at the begining of the iterative decoding\npublic:\n- Decoder_LDPC_BP_layered(const int K, const int N, const int n_ite,\n+ Decoder_LDPC_BP_horizontal_layered(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &H,\nconst std::vector<unsigned> &info_bits_pos,\nconst Update_rule &up_rule,\nconst bool enable_syndrome = true,\nconst int syndrome_depth = 1,\nconst int n_frames = 1);\n- virtual ~Decoder_LDPC_BP_layered();\n+ virtual ~Decoder_LDPC_BP_horizontal_layered();\nvoid reset();\nprotected:\n@@ -49,6 +49,6 @@ protected:\n}\n}\n-#include \"Decoder_LDPC_BP_layered.hxx\"\n+#include \"Decoder_LDPC_BP_horizontal_layered.hxx\"\n-#endif /* DECODER_LDPC_BP_LAYERED_HPP_ */\n+#endif /* DECODER_LDPC_BP_HORIZONTAL_LAYERED_HPP_ */\n" }, { "change_type": "RENAME", "old_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hxx", "diff": "#include \"Tools/Perf/common/hard_decide.h\"\n#include \"Tools/Math/utils.h\"\n-#include \"Decoder_LDPC_BP_layered.hpp\"\n+#include \"Decoder_LDPC_BP_horizontal_layered.hpp\"\nnamespace aff3ct\n{\nnamespace module\n{\ntemplate <typename B, typename R, class Update_rule>\n-Decoder_LDPC_BP_layered<B,R,Update_rule>\n-::Decoder_LDPC_BP_layered(const int K, const int N, const int n_ite,\n+Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n+::Decoder_LDPC_BP_horizontal_layered(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst Update_rule &up_rule,\n@@ -31,25 +31,25 @@ Decoder_LDPC_BP_layered<B,R,Update_rule>\ncontributions (this->H.get_cols_max_degree() ),\ninit_flag (true )\n{\n- const std::string name = \"Decoder_LDPC_BP_layered<\" + this->up_rule.get_name() + \">\";\n+ const std::string name = \"Decoder_LDPC_BP_horizontal_layered<\" + this->up_rule.get_name() + \">\";\nthis->set_name(name);\n}\ntemplate <typename B, typename R, class Update_rule>\n-Decoder_LDPC_BP_layered<B,R,Update_rule>\n-::~Decoder_LDPC_BP_layered()\n+Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n+::~Decoder_LDPC_BP_horizontal_layered()\n{\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n::reset()\n{\nthis->init_flag = true;\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n::_load(const R *Y_N, const int frame_id)\n{\n// memory zones initialization\n@@ -67,7 +67,7 @@ void Decoder_LDPC_BP_layered<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n::_decode_siso(const R *Y_N1, R *Y_N2, const int frame_id)\n{\n// memory zones initialization\n@@ -85,7 +85,7 @@ void Decoder_LDPC_BP_layered<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n{\n// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n@@ -112,7 +112,7 @@ void Decoder_LDPC_BP_layered<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n{\n// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n@@ -134,7 +134,7 @@ void Decoder_LDPC_BP_layered<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n::_decode(const int frame_id)\n{\nthis->up_rule.begin_decoding(this->n_ite);\n@@ -153,7 +153,7 @@ void Decoder_LDPC_BP_layered<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n::_decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &branches)\n{\nauto kr = 0;\n" }, { "change_type": "RENAME", "old_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered_inter.hpp", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hpp", "diff": "-#ifndef DECODER_LDPC_BP_LAYERED_INTER_HPP_\n-#define DECODER_LDPC_BP_LAYERED_INTER_HPP_\n+#ifndef DECODER_LDPC_BP_HORIZONTAL_LAYERED_INTER_HPP_\n+#define DECODER_LDPC_BP_HORIZONTAL_LAYERED_INTER_HPP_\n#include <mipp.h>\n@@ -14,7 +14,7 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename B = int, typename R = float, class Update_rule = tools::Update_rule_NMS_inter<R>>\n-class Decoder_LDPC_BP_layered_inter : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n+class Decoder_LDPC_BP_horizontal_layered_inter : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n{\nprotected:\nconst std::vector<unsigned> &info_bits_pos;\n@@ -34,14 +34,14 @@ protected:\nbool init_flag;\npublic:\n- Decoder_LDPC_BP_layered_inter(const int K, const int N, const int n_ite,\n+ Decoder_LDPC_BP_horizontal_layered_inter(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &H,\nconst std::vector<unsigned> &info_bits_pos,\nconst Update_rule &up_rule,\nconst bool enable_syndrome = true,\nconst int syndrome_depth = 1,\nconst int n_frames = 1);\n- virtual ~Decoder_LDPC_BP_layered_inter();\n+ virtual ~Decoder_LDPC_BP_horizontal_layered_inter();\nvoid reset();\nprotected:\n@@ -57,6 +57,6 @@ protected:\n}\n}\n-#include \"Decoder_LDPC_BP_layered_inter.hxx\"\n+#include \"Decoder_LDPC_BP_horizontal_layered_inter.hxx\"\n-#endif /* DECODER_LDPC_BP_LAYERED_INTER_HPP_ */\n\\ No newline at end of file\n+#endif /* DECODER_LDPC_BP_HORIZONTAL_LAYERED_INTER_HPP_ */\n\\ No newline at end of file\n" }, { "change_type": "RENAME", "old_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered_inter.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hxx", "diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Perf/Reorderer/Reorderer.hpp\"\n-#include \"Decoder_LDPC_BP_layered_inter.hpp\"\n+#include \"Decoder_LDPC_BP_horizontal_layered_inter.hpp\"\nnamespace aff3ct\n{\n@@ -32,8 +32,8 @@ inline mipp::Reg<int8_t> saturate(const mipp::Reg<int8_t> v, const int8_t s)\n}\ntemplate <typename B, typename R, class Update_rule>\n-Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n-::Decoder_LDPC_BP_layered_inter(const int K, const int N, const int n_ite,\n+Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n+::Decoder_LDPC_BP_horizontal_layered_inter(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst Update_rule &up_rule,\n@@ -53,7 +53,7 @@ Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\nV_reorderered (N ),\ninit_flag (true )\n{\n- const std::string name = \"Decoder_LDPC_BP_layered_inter<\" + this->up_rule.get_name() + \">\";\n+ const std::string name = \"Decoder_LDPC_BP_horizontal_layered_inter<\" + this->up_rule.get_name() + \">\";\nthis->set_name(name);\nif (this->sat_val <= 0)\n@@ -65,20 +65,20 @@ Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n-::~Decoder_LDPC_BP_layered_inter()\n+Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n+::~Decoder_LDPC_BP_horizontal_layered_inter()\n{\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n::reset()\n{\nthis->init_flag = true;\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n::_load(const R *Y_N, const int frame_id)\n{\nconst auto cur_wave = frame_id / this->simd_inter_frame_level;\n@@ -102,7 +102,7 @@ void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n::_decode_siso(const R *Y_N1, R *Y_N2, const int frame_id)\n{\n// memory zones initialization\n@@ -121,7 +121,7 @@ void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n{\n// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n@@ -152,7 +152,7 @@ void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n{\n// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n@@ -180,7 +180,7 @@ void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n::_decode(const int frame_id)\n{\nconst auto cur_wave = frame_id / this->simd_inter_frame_level;\n@@ -201,7 +201,7 @@ void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n+void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n::_decode_single_ite(mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &branches)\n{\nauto kr = 0;\n@@ -231,7 +231,7 @@ void Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n}\ntemplate <typename B, typename R, class Update_rule>\n-bool Decoder_LDPC_BP_layered_inter<B,R,Update_rule>\n+bool Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n::_check_syndrome_soft(const mipp::vector<mipp::Reg<R>> &var_nodes)\n{\nif (this->enable_syndrome)\n" }, { "change_type": "RENAME", "old_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.cpp", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/ONMS/Decoder_LDPC_BP_horizontal_layered_ONMS_inter.cpp", "diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Perf/Reorderer/Reorderer.hpp\"\n-#include \"Decoder_LDPC_BP_layered_ONMS_inter.hpp\"\n+#include \"Decoder_LDPC_BP_horizontal_layered_ONMS_inter.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\ntemplate <typename B, typename R>\n-Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n-::Decoder_LDPC_BP_layered_ONMS_inter(const int K, const int N, const int n_ite,\n+Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n+::Decoder_LDPC_BP_horizontal_layered_ONMS_inter(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst float normalize_factor,\n@@ -37,7 +37,7 @@ Decoder_LDPC_BP_layered_ONMS_inter<B,R>\nY_N_reorderered (N ),\nV_reorderered (N )\n{\n- const std::string name = \"Decoder_LDPC_BP_layered_ONMS_inter\";\n+ const std::string name = \"Decoder_LDPC_BP_horizontal_layered_ONMS_inter\";\nthis->set_name(name);\nif (sizeof(R) == 1)\n@@ -52,20 +52,20 @@ Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n}\ntemplate <typename B, typename R>\n-Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n-::~Decoder_LDPC_BP_layered_ONMS_inter()\n+Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n+::~Decoder_LDPC_BP_horizontal_layered_ONMS_inter()\n{\n}\ntemplate <typename B, typename R>\n-void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n+void Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n::reset()\n{\nthis->init_flag = true;\n}\ntemplate <typename B, typename R>\n-void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n+void Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n::_load(const R *Y_N, const int frame_id)\n{\nconst auto cur_wave = frame_id / this->simd_inter_frame_level;\n@@ -89,7 +89,7 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n}\ntemplate <typename B, typename R>\n-void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n+void Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n::_decode_siso(const R *Y_N1, R *Y_N2, const int frame_id)\n{\n// memory zones initialization\n@@ -131,7 +131,7 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n}\ntemplate <typename B, typename R>\n-void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n+void Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n{\n// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n@@ -186,7 +186,7 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n}\ntemplate <typename B, typename R>\n-void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n+void Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n{\n// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n@@ -239,7 +239,7 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\ntemplate <typename B, typename R>\ntemplate <int F>\n-void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n+void Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n::_decode(const int frame_id)\n{\nconst auto cur_wave = frame_id / this->simd_inter_frame_level;\n@@ -299,7 +299,7 @@ template <> inline mipp::Reg<double> simd_normalize<double,8>(const mipp::Reg<do\n// BP algorithm\ntemplate <typename B, typename R>\ntemplate <int F>\n-void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n+void Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n::_decode_single_ite(mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &branches)\n{\nauto kr = 0;\n@@ -348,7 +348,7 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n}\ntemplate <typename B, typename R>\n-bool Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n+bool Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,R>\n::_check_syndrome(const int frame_id)\n{\nconst auto cur_wave = frame_id / this->simd_inter_frame_level;\n@@ -378,11 +378,11 @@ bool Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template class aff3ct::module::Decoder_LDPC_BP_layered_ONMS_inter<B_8,Q_8>;\n-template class aff3ct::module::Decoder_LDPC_BP_layered_ONMS_inter<B_16,Q_16>;\n-template class aff3ct::module::Decoder_LDPC_BP_layered_ONMS_inter<B_32,Q_32>;\n-template class aff3ct::module::Decoder_LDPC_BP_layered_ONMS_inter<B_64,Q_64>;\n+template class aff3ct::module::Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B_8,Q_8>;\n+template class aff3ct::module::Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B_16,Q_16>;\n+template class aff3ct::module::Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B_32,Q_32>;\n+template class aff3ct::module::Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B_64,Q_64>;\n#else\n-template class aff3ct::module::Decoder_LDPC_BP_layered_ONMS_inter<B,Q>;\n+template class aff3ct::module::Decoder_LDPC_BP_horizontal_layered_ONMS_inter<B,Q>;\n#endif\n// ==================================================================================== explicit template instantiation\n" }, { "change_type": "RENAME", "old_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.hpp", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/ONMS/Decoder_LDPC_BP_horizontal_layered_ONMS_inter.hpp", "diff": "-#ifndef DECODER_LDPC_BP_LAYERED_ONMS_INTER_HPP_\n-#define DECODER_LDPC_BP_LAYERED_ONMS_INTER_HPP_\n+#ifndef DECODER_LDPC_BP_HORIZONTAL_LAYERED_ONMS_INTER_HPP_\n+#define DECODER_LDPC_BP_HORIZONTAL_LAYERED_ONMS_INTER_HPP_\n#include <mipp.h>\n@@ -13,7 +13,7 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename B = int, typename R = float>\n-class Decoder_LDPC_BP_layered_ONMS_inter : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n+class Decoder_LDPC_BP_horizontal_layered_ONMS_inter : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n{\nprivate:\nconst float normalize_factor;\n@@ -36,7 +36,7 @@ protected:\nmipp::vector<mipp::Reg<B>> V_reorderered;\npublic:\n- Decoder_LDPC_BP_layered_ONMS_inter(const int K, const int N, const int n_ite,\n+ Decoder_LDPC_BP_horizontal_layered_ONMS_inter(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &H,\nconst std::vector<unsigned> &info_bits_pos,\nconst float normalize_factor = 1.f,\n@@ -44,7 +44,7 @@ public:\nconst bool enable_syndrome = true,\nconst int syndrome_depth = 1,\nconst int n_frames = 1);\n- virtual ~Decoder_LDPC_BP_layered_ONMS_inter();\n+ virtual ~Decoder_LDPC_BP_horizontal_layered_ONMS_inter();\nvoid reset();\n@@ -63,4 +63,4 @@ protected:\n}\n}\n-#endif /* DECODER_LDPC_BP_LAYERED_ONMS_INTER_HPP_ */\n+#endif /* DECODER_LDPC_BP_HORIZONTAL_LAYERED_ONMS_INTER_HPP_ */\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp", "new_path": "src/Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp", "diff": "@@ -59,7 +59,7 @@ public:\n// incoming values from the variable nodes into the check nodes\ninline void begin_chk_node_in(const int chk_id, const int chk_degree)\n{\n- assert(chk_degree <= (int)values.size());\n+ assert(chk_degree <= (int)this->values.size());\nthis->sign = 0;\nthis->product = 1;\n@@ -87,7 +87,7 @@ public:\ninline R compute_chk_node_out(const int var_id, const R var_val)\n{\n- auto res_tmp = product / values[var_id];\n+ auto res_tmp = product / this->values[var_id];\nres_tmp = (res_tmp < (R)1.0) ? res_tmp : (R)1.0 - std::numeric_limits<R>::epsilon();\nconst auto res_abs = (R)2.0 * std::atanh(res_tmp);\nconst auto res_sng = this->sign ^ (std::signbit((float)var_val) ? -1 : 0);\n" } ]
C++
MIT License
aff3ct/aff3ct
Rename 'BP_LAYERED' in 'BP_HORIZONTAL_LAYERED'.
8,483
04.07.2018 09:33:12
-7,200
22d8cf63aa867445b568ffea8a3201c8bdd37caf
Makes monitor reduction MPI works with a intermediate data structure creation to transfert Monitor data
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "diff": "#include \"Tools/Perf/common/mutual_info.h\"\n#include \"Tools/Perf/common/hamming_distance.h\"\n#include \"Tools/Math/utils.h\"\n+#include \"Tools/general_utils.h\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\n@@ -326,18 +327,18 @@ Monitor_BFER<B>& Monitor_BFER<B>\nreturn *this;\n}\n-#ifdef ENABLE_MPI\n-template <typename B>\n-void Monitor_BFER<B>\n-::create_MPI_struct(int blen [n_MPI_attributes],\n- MPI_Aint displacements[n_MPI_attributes],\n- MPI_Datatype oldtypes [n_MPI_attributes])\n-{\n- blen[0] = 1; displacements[0] = offsetof(Monitor_BFER<B>, n_be ); oldtypes[0] = MPI_UNSIGNED_LONG_LONG;\n- blen[1] = 1; displacements[1] = offsetof(Monitor_BFER<B>, n_fe ); oldtypes[1] = MPI_UNSIGNED_LONG_LONG;\n- blen[2] = 1; displacements[2] = offsetof(Monitor_BFER<B>, n_fra); oldtypes[2] = MPI_UNSIGNED_LONG_LONG;\n-}\n-#endif\n+// #ifdef ENABLE_MPI\n+// template <typename B>\n+// void Monitor_BFER<B>\n+// ::create_MPI_struct(int blen [n_MPI_attributes],\n+// MPI_Aint displacements[n_MPI_attributes],\n+// MPI_Datatype oldtypes [n_MPI_attributes])\n+// {\n+// blen[0] = 1; displacements[0] = tools::offsetOf(&Monitor_BFER<B>::n_be ); oldtypes[0] = MPI_UNSIGNED_LONG_LONG;\n+// blen[1] = 1; displacements[1] = tools::offsetOf(&Monitor_BFER<B>::n_fe ); oldtypes[1] = MPI_UNSIGNED_LONG_LONG;\n+// blen[2] = 1; displacements[2] = tools::offsetOf(&Monitor_BFER<B>::n_fra); oldtypes[2] = MPI_UNSIGNED_LONG_LONG;\n+// }\n+// #endif\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "diff": "@@ -123,14 +123,71 @@ public:\nMonitor_BFER<B>& operator=(const Monitor_BFER<B>& m); // not full \"copy\" call\n- #ifdef ENABLE_MPI\n- static void create_MPI_struct(int blen [n_MPI_attributes],\n- MPI_Aint displacements[n_MPI_attributes],\n- MPI_Datatype oldtypes [n_MPI_attributes]);\n- #endif\n+ // #ifdef ENABLE_MPI\n+ // static void create_MPI_struct(int blen [n_MPI_attributes],\n+ // MPI_Aint displacements[n_MPI_attributes],\n+ // MPI_Datatype oldtypes [n_MPI_attributes]);\n+ // #endif\nprotected:\nvirtual int _check_errors(const B *U, const B *Y, const int frame_id);\n+\n+\n+#ifdef ENABLE_MPI\n+public:\n+\n+ struct Vals_mpi\n+ {\n+ int n_frames;\n+\n+ unsigned long long n_fra;\n+ unsigned long long n_be;\n+ unsigned long long n_fe;\n+\n+ int K;\n+ unsigned max_fe;\n+ bool count_unknown_values;\n+ };\n+\n+ // static void create_MPI_struct(int blen [n_MPI_attributes],\n+ // MPI_Aint displacements[n_MPI_attributes],\n+ // MPI_Datatype oldtypes [n_MPI_attributes]);\n+\n+ Monitor_BFER(const Vals_mpi& v)\n+ : Monitor(v.n_frames),\n+ n_fra (v.n_fra),\n+ n_be (v.n_be),\n+ n_fe (v.n_fe),\n+ K (v.K),\n+ max_fe (v.max_fe),\n+ count_unknown_values(v.count_unknown_values)\n+ {\n+\n+ }\n+\n+ Vals_mpi get_vals_mpi() const\n+ {\n+ Vals_mpi v;\n+\n+ v.n_frames = this->n_frames;\n+ v.n_fra = this->n_fra;\n+ v.n_be = this->n_be;\n+ v.n_fe = this->n_fe;\n+ v.K = this->K;\n+ v.max_fe = this->max_fe;\n+ v.count_unknown_values = this->count_unknown_values;\n+\n+ return v;\n+ }\n+\n+ virtual void copy(const Vals_mpi& v)\n+ {\n+ n_fra = v.n_fra;\n+ n_be = v.n_be;\n+ n_fe = v.n_fe;\n+ }\n+\n+#endif\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/MI/Monitor_MI.cpp", "new_path": "src/Module/Monitor/MI/Monitor_MI.cpp", "diff": "#include <stdexcept>\n#include \"Monitor_MI.hpp\"\n+\n#include \"Tools/Perf/common/mutual_info.h\"\n#include \"Tools/Perf/common/hamming_distance.h\"\n#include \"Tools/Math/utils.h\"\n+#include \"Tools/general_utils.h\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\n@@ -305,21 +307,32 @@ Monitor_MI<B,R>& Monitor_MI<B,R>\nreturn *this;\n}\n-#ifdef ENABLE_MPI\n-template <typename B, typename R>\n-void Monitor_MI<B,R>\n-::create_MPI_struct(int blen [n_MPI_attributes],\n- MPI_Aint displacements[n_MPI_attributes],\n- MPI_Datatype oldtypes [n_MPI_attributes])\n-{\n- using MPI_R_type = typename std::conditional<std::is_same<R,double>::value, MPI_DOUBLE, MPI_FLOAT>;\n+// #ifdef ENABLE_MPI\n+// template <typename B, typename R>\n+// void Monitor_MI<B,R>\n+// ::create_MPI_struct(int blen [n_MPI_attributes],\n+// MPI_Aint displacements[n_MPI_attributes],\n+// MPI_Datatype oldtypes [n_MPI_attributes])\n+// {\n+// int world_rank;\n+// MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);\n- blen[0] = 1; displacements[0] = offsetof(Monitor_MI<B,R>, n_trials); oldtypes[0] = MPI_UNSIGNED_LONG_LONG;\n- blen[1] = 1; displacements[1] = offsetof(Monitor_MI<B,R>, MI ); oldtypes[1] = MPI_R_type;\n- blen[2] = 1; displacements[2] = offsetof(Monitor_MI<B,R>, MI_min ); oldtypes[2] = MPI_R_type;\n- blen[3] = 1; displacements[3] = offsetof(Monitor_MI<B,R>, MI_max ); oldtypes[3] = MPI_R_type;\n-}\n-#endif\n+// std::cout << world_rank << \" : create_MPI_struct\" << std::endl;\n+\n+// auto MPI_R_type = std::is_same<R,double>::value ? MPI_DOUBLE : MPI_FLOAT;\n+\n+// blen[0] = 1; displacements[0] = tools::offsetOf(&Monitor_MI<B,R>::n_trials); oldtypes[0] = MPI_UNSIGNED_LONG_LONG;\n+// blen[1] = 1; displacements[1] = tools::offsetOf(&Monitor_MI<B,R>::MI ); oldtypes[1] = MPI_R_type;\n+// blen[2] = 1; displacements[2] = tools::offsetOf(&Monitor_MI<B,R>::MI_min ); oldtypes[2] = MPI_R_type;\n+// blen[3] = 1; displacements[3] = tools::offsetOf(&Monitor_MI<B,R>::MI_max ); oldtypes[3] = MPI_R_type;\n+\n+\n+// std::cout << \"tools::offsetOf(&Monitor_MI<B,R>::n_trials): \" << tools::offsetOf(&Monitor_MI<B,R>::n_trials) << std::endl;\n+// std::cout << \"tools::offsetOf(&Monitor_MI<B,R>::MI ): \" << tools::offsetOf(&Monitor_MI<B,R>::MI ) << std::endl;\n+// std::cout << \"tools::offsetOf(&Monitor_MI<B,R>::MI_min ): \" << tools::offsetOf(&Monitor_MI<B,R>::MI_min ) << std::endl;\n+// std::cout << \"tools::offsetOf(&Monitor_MI<B,R>::MI_max ): \" << tools::offsetOf(&Monitor_MI<B,R>::MI_max ) << std::endl;\n+// }\n+// #endif\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "new_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "diff": "@@ -20,9 +20,7 @@ public:\ninline Task& operator[](const mnt::tsk t) { return Module::operator[]((int)t); }\ninline Socket& operator[](const mnt::sck::get_mutual_info s) { return Module::operator[]((int)mnt::tsk::get_mutual_info)[(int)s]; }\n-protected:\n- static constexpr unsigned n_MPI_attributes = 4;\n-\n+public://protected:\nunsigned long long n_trials; // Number of checked trials\nR MI; // the mutual information\nR MI_max; // the maximum obtained MI\n@@ -113,16 +111,69 @@ public:\nMonitor_MI<B,R>& operator=(const Monitor_MI<B,R>& m); // not full \"copy\" call\n- #ifdef ENABLE_MPI\n- static void create_MPI_struct(int blen [n_MPI_attributes],\n- MPI_Aint displacements[n_MPI_attributes],\n- MPI_Datatype oldtypes [n_MPI_attributes]);\n- #endif\nprotected:\nvirtual R _get_mutual_info(const B *X, const R *Y, const int frame_id);\nvoid add_MI_value(const R mi);\n+\n+\n+#ifdef ENABLE_MPI\n+public:\n+\n+ struct Vals_mpi\n+ {\n+ int n_frames;\n+\n+ int N;\n+ unsigned max_n_trials;\n+\n+ unsigned long long n_trials;\n+ R MI;\n+ R MI_max;\n+ R MI_min;\n+ };\n+\n+ // static void create_MPI_struct(int blen [n_MPI_attributes],\n+ // MPI_Aint displacements[n_MPI_attributes],\n+ // MPI_Datatype oldtypes [n_MPI_attributes]);\n+\n+ Monitor_MI(const Vals_mpi& v)\n+ : Monitor (v.n_frames),\n+ n_trials (v.n_trials),\n+ MI (v.MI),\n+ MI_max (v.MI_max),\n+ MI_min (v.MI_min),\n+ N (v.N),\n+ max_n_trials(v.max_n_trials)\n+ {\n+\n+ }\n+\n+ Vals_mpi get_vals_mpi() const\n+ {\n+ Vals_mpi v;\n+\n+ v.n_frames = this->n_frames;\n+ v.N = this->N;\n+ v.max_n_trials = this->max_n_trials;\n+ v.n_trials = this->n_trials;\n+ v.MI = this->MI;\n+ v.MI_max = this->MI_max;\n+ v.MI_min = this->MI_min;\n+\n+ return v;\n+ }\n+\n+ virtual void copy(const Vals_mpi& v)\n+ {\n+ n_trials = v.n_trials;\n+ MI = v.MI;\n+ MI_max = v.MI_max;\n+ MI_min = v.MI_min;\n+ }\n+\n+#endif\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hpp", "new_path": "src/Module/Monitor/Monitor_reduction_mpi.hpp", "diff": "@@ -20,9 +20,9 @@ class Monitor_reduction_mpi : public Monitor_reduction<M>\n{\nprivate:\nconst std::thread::id master_thread_id;\n+ const std::chrono::nanoseconds d_mpi_comm_frequency;\nstd::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> t_last_mpi_comm;\n- std::chrono::nanoseconds d_mpi_comm_frequency;\nMPI_Datatype MPI_monitor_vals;\nMPI_Op MPI_SUM_monitor_vals;\n@@ -38,6 +38,7 @@ public:\n};\n}\n}\n+#include \"Monitor_reduction_mpi.hxx\"\n#endif /* MONITOR_REDUCTION_MPI_HPP_ */\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hxx", "new_path": "src/Module/Monitor/Monitor_reduction_mpi.hxx", "diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Monitor_reduction_mpi.hpp\"\n+#include \"MI/Monitor_MI.hpp\"\n-using namespace aff3ct;\n-using namespace aff3ct::module;\n-\n+namespace aff3ct\n+{\n+namespace module\n+{\ntemplate<class M>\nvoid MPI_SUM_monitor_vals_func(void *in, void *inout, int *len, MPI_Datatype *datatype)\n{\n- auto in_cvt = static_cast<M::Values_t*>(in );\n- auto inout_cvt = static_cast<M::Values_t*>(inout);\n+ auto in_cvt = static_cast<typename M::Vals_mpi*>(in );\n+ auto inout_cvt = static_cast<typename M::Vals_mpi*>(inout);\nfor (auto i = 0; i < *len; i++)\n- inout_cvt[i] += in_cvt[i]\n+ {\n+ M m_in (in_cvt [i]);\n+ M m_inout(inout_cvt[i]);\n+ m_inout += m_in;\n+ inout_cvt[i] = m_inout.get_vals_mpi();\n+ }\n}\ntemplate <class M>\n@@ -31,19 +38,38 @@ Monitor_reduction_mpi<M>\nconst std::chrono::nanoseconds d_mpi_comm_frequency)\n: Monitor_reduction<M>(monitors),\nmaster_thread_id(master_thread_id),\n- t_last_mpi_comm(std::chrono::steady_clock::now()),\n- d_mpi_comm_frequency(d_mpi_comm_frequency)\n+ d_mpi_comm_frequency(d_mpi_comm_frequency),\n+ t_last_mpi_comm(std::chrono::steady_clock::now())\n{\nconst std::string name = \"Monitor_reduction_mpi<\" + monitors[0]->get_name() + \">\";\nthis->set_name(name);\n- int blen [M::vals::n_attributes];\n- MPI_Aint displacements[M::vals::n_attributes];\n- MPI_Datatype oldtypes [M::vals::n_attributes];\n+ // int blen [M::n_MPI_attributes];\n+ // MPI_Aint displacements[M::n_MPI_attributes];\n+ // MPI_Datatype oldtypes [M::n_MPI_attributes];\n+\n+ // M::create_MPI_struct(blen, displacements, oldtypes);\n- M::vals::create_MPI_struct(blen, displacements, oldtypes);\n+ // MPI_Datatype MPI_monitor_vals_tmp;\n- if (auto ret = MPI_Type_create_struct(M::vals::n_attributes, blen, displacements, oldtypes, &MPI_monitor_vals))\n+ // if (auto ret = MPI_Type_create_struct(M::n_MPI_attributes, blen, displacements, oldtypes, &MPI_monitor_vals_tmp))\n+ // {\n+ // std::stringstream message;\n+ // message << \"'MPI_Type_create_struct' returned '\" << ret << \"' error code.\";\n+ // throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ // }\n+\n+\n+ // MPI_Aint lb, extent;\n+ // MPI_Type_get_extent( MPI_monitor_vals_tmp, &lb, &extent );\n+ // extent = sizeof (M);\n+ // MPI_Type_create_resized( MPI_monitor_vals_tmp, lb, extent, &MPI_monitor_vals );\n+\n+ int blen = sizeof(typename M::Vals_mpi);\n+ MPI_Aint displacements = 0;\n+ MPI_Datatype oldtypes = MPI_CHAR;\n+\n+ if (auto ret = MPI_Type_create_struct(1, &blen, &displacements, &oldtypes, &MPI_monitor_vals))\n{\nstd::stringstream message;\nmessage << \"'MPI_Type_create_struct' returned '\" << ret << \"' error code.\";\n@@ -69,23 +95,39 @@ template <class M>\nvoid Monitor_reduction_mpi<M>\n::reduce(bool fully)\n{\n+ fully = false;\n+\n// only the master thread can do this\nif (std::this_thread::get_id() == this->master_thread_id &&\n((std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_mpi_comm_frequency))\n{\nMonitor_reduction<M>::reduce(fully);\n- M::Values_t mvals_recv;\n- auto& mvals_send = this->vals;\n+ typename M::Vals_mpi mvals_recv;\n- MPI_Allreduce(&mvals_send, &mvals_recv, 1, MPI_monitor_vals, MPI_SUM_monitor_vals, MPI_COMM_WORLD);\n+ auto mvals_send = this->get_vals_mpi();\n- this->vals = mvals_recv;\n+ MPI_Allreduce(&mvals_send, &mvals_recv, 1,\n+ MPI_monitor_vals, MPI_SUM_monitor_vals, MPI_COMM_WORLD);\n+\n+ M::copy(mvals_recv);\nt_last_mpi_comm = std::chrono::steady_clock::now();\n}\n}\n+template <class M>\n+void Monitor_reduction_mpi<M>\n+::reset()\n+{\n+ Monitor_reduction<M>::reset();\n+\n+ t_last_mpi_comm = std::chrono::steady_clock::now();\n+}\n+\n+}\n+}\n+\n#endif // MONITOR_REDUCTION_MPI_HXX_\n#endif // ENABLE_MPI\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.cpp", "new_path": "src/Simulation/BFER/BFER.cpp", "diff": "@@ -80,7 +80,7 @@ BFER<B,R,Q>\n#ifdef ENABLE_MPI\n// build a monitor to compute BER/FER (reduce the other monitors)\n- this->monitor_er_red = new module::Monitor_reduction_mpi<Monitor_BFER_type*>(this->monitor_er,\n+ this->monitor_er_red = new module::Monitor_reduction_mpi<Monitor_BFER_type>(this->monitor_er,\nstd::this_thread::get_id(),\nparams_BFER.mpi_comm_freq);\n#else\n@@ -100,7 +100,7 @@ BFER<B,R,Q>\n#ifdef ENABLE_MPI\n// build a monitor to compute BER/FER (reduce the other monitors)\n- this->monitor_mi_red = new module::Monitor_reduction_mpi<Monitor_MI_type>(this->monitor,\n+ this->monitor_mi_red = new module::Monitor_reduction_mpi<Monitor_MI_type>(this->monitor_mi,\nstd::this_thread::get_id(),\nparams_BFER.mpi_comm_freq);\n#else\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/general_utils.h", "new_path": "src/Tools/general_utils.h", "diff": "@@ -77,6 +77,16 @@ inline void mutual_unique(std::vector<Ta>& vec_abscissa, std::vector<std::vector\ntemplate <typename T>\nstd::string get_time_format(T secondes);\n+/*\n+ * calculate offset of a class member at compile time\n+ * Source : https://stackoverflow.com/a/20141143/7219905\n+ */\n+template<typename T, typename U>\n+constexpr size_t offsetOf(U T::*member)\n+{\n+ return (char*)&((T*)nullptr->*member) - (char*)nullptr;\n+}\n+\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Makes monitor reduction MPI works with a intermediate data structure creation to transfert Monitor data
8,483
04.07.2018 10:45:23
-7,200
91f192ac9e011e3bb4ebaba94e75dbc37e3c2b60
Cosmetics and add a SIGUSR1 signal handler for MPI runs
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "diff": "@@ -20,8 +20,6 @@ public:\ninline Task& operator[](const mnt::tsk t) { return Module::operator[]((int)t); }\ninline Socket& operator[](const mnt::sck::check_errors s) { return Module::operator[]((int)mnt::tsk::check_errors)[(int)s]; }\n- static constexpr unsigned n_MPI_attributes = 3;\n-\nunsigned long long n_fra; // the number of checked frames\nunsigned long long n_be; // the number of wrong bits\nunsigned long long n_fe; // the number of wrong frames\n@@ -122,13 +120,6 @@ public:\nMonitor_BFER<B>& operator=(const Monitor_BFER<B>& m); // not full \"copy\" call\n-\n- // #ifdef ENABLE_MPI\n- // static void create_MPI_struct(int blen [n_MPI_attributes],\n- // MPI_Aint displacements[n_MPI_attributes],\n- // MPI_Datatype oldtypes [n_MPI_attributes]);\n- // #endif\n-\nprotected:\nvirtual int _check_errors(const B *U, const B *Y, const int frame_id);\n@@ -136,6 +127,8 @@ protected:\n#ifdef ENABLE_MPI\npublic:\n+ // static constexpr unsigned n_MPI_attributes = 3;\n+\nstruct Vals_mpi\n{\nint n_frames;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "new_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "diff": "@@ -121,6 +121,8 @@ protected:\n#ifdef ENABLE_MPI\npublic:\n+ // static constexpr unsigned n_MPI_attributes = 4;\n+\nstruct Vals_mpi\n{\nint n_frames;\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Display/Terminal/Terminal.cpp", "new_path": "src/Tools/Display/Terminal/Terminal.cpp", "diff": "@@ -22,8 +22,10 @@ Terminal\n{\nTerminal::interrupt = false;\n-#ifndef ENABLE_MPI\n// Install a signal handler\n+#ifdef ENABLE_MPI\n+ std::signal(SIGUSR1, Terminal::signal_interrupt_handler);\n+#else\nstd::signal(SIGINT, Terminal::signal_interrupt_handler);\n#endif\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Cosmetics and add a SIGUSR1 signal handler for MPI runs
8,483
04.07.2018 15:01:43
-7,200
5717943633fb7f816252527bacce8479078f5f20
Add test regression with MPI run. Fix BFER factory when getting prefix of mnt_mi because in BFERI it is not instantiated
[ { "change_type": "MODIFY", "old_path": "ci/test-regression.py", "new_path": "ci/test-regression.py", "diff": "@@ -30,6 +30,7 @@ parser.add_argument('--max-fe', action='store', dest='maxFE', ty\nparser.add_argument('--weak-rate', action='store', dest='weakRate', type=float, default=0.8, help='Rate of valid noise points to passe a test.') # choices=xrange(0.0, 1.0 )\nparser.add_argument('--max-snr-time', action='store', dest='maxSNRTime', type=int, default=600, help='The maximum amount of time to spend to compute a noise point in seconds (0 = illimited)') # choices=xrange(0, +inf)\nparser.add_argument('--verbose', action='store', dest='verbose', type=bool, default=False, help='Enable the verbose mode.')\n+parser.add_argument('--mpi-np', action='store', dest='mpinp', type=int, default=0, help='Enable MPI run with the given number of process each running on \"--n-threads\" threads.')\n# supported file extensions (filename suffix)\nextensions = ['.txt', '.perf', '.data', '.dat']\n@@ -442,6 +443,7 @@ print('# max fe =', args.maxFE )\nprint('# weak rate =', args.weakRate )\nprint('# max snr time =', args.maxSNRTime )\nprint('# verbose =', args.verbose )\n+print('# MPI nbr proc =', args.mpinp )\nprint('#')\nPathOrigin = os.getcwd()\n@@ -489,6 +491,13 @@ for fn in fileNames:\n# get the command line to run\nargsAFFECT = splitAsCommand(simuRef.RunCommand)\n+\n+ if args.mpinp > 0:\n+ argsAFFECT.insert(0, str(args.mpinp))\n+ argsAFFECT.insert(0, \"-np\")\n+ argsAFFECT.insert(0, \"mpirun\")\n+\n+\nargsAFFECT.append(\"--ter-freq\")\nargsAFFECT.append(\"0\")\nif args.maxFE:\n@@ -516,7 +525,6 @@ for fn in fileNames:\nargsAFFECT.append(\"EBN0\")\n-\n# run the tested simulator\nos.chdir(args.buildPath)\nstartTime = time.time()\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Simulation/BFER/BFER.cpp", "new_path": "src/Factory/Simulation/BFER/BFER.cpp", "diff": "@@ -137,10 +137,10 @@ void BFER::parameters\n\"enable the coded monitoring (extends the monitored bits to the entire codeword).\");\n- auto pmi = mnt_mi->get_prefix();\n+ auto pmon = mnt_er->get_prefix();\nargs.add(\n- {pmi+\"-mutinfo\"},\n+ {pmon+\"-mutinfo\"},\ntools::None(),\n\"allow the computation of the mutual information.\");\n}\n@@ -169,9 +169,9 @@ void BFER::parameters\nthis->n_threads = 1;\n}\n- auto pmi = mnt_mi->get_prefix();\n+ auto pmon = mnt_er->get_prefix();\n- if(vals.exist({pmi+\"-mutinfo\"})) this->mutinfo = true;\n+ if(vals.exist({pmon+\"-mutinfo\"})) this->mutinfo = true;\n}\nvoid BFER::parameters\n@@ -222,9 +222,9 @@ void BFER::parameters\nif (this->mnt_er != nullptr) { this->mnt_er->get_headers(headers, full); }\n- headers[this->mnt_mi->get_prefix()].push_back(std::make_pair(\"Compute mutual info\", this->mutinfo ? \"yes\" : \"no\"));\n+ headers[this->mnt_er->get_prefix()].push_back(std::make_pair(\"Compute mutual info\", this->mutinfo ? \"yes\" : \"no\"));\nif (this->mutinfo)\n- if (this->mnt_mi != nullptr) { this->mnt_mi->get_headers(headers, full); }\n+ if (this->mnt_er != nullptr) { this->mnt_er->get_headers(headers, full); }\nif (this->ter != nullptr) { this->ter->get_headers(headers, full); }\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Add test regression with MPI run. Fix BFER factory when getting prefix of mnt_mi because in BFERI it is not instantiated
8,483
04.07.2018 15:44:03
-7,200
f33f6e85dd756a9742e82cea113d70c709f151d2
Fix the binding of Monitor MI in STD simu when using demodulation with gain
[ { "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": "@@ -251,7 +251,12 @@ void BFER_std_threads<B,R,Q>\nauto &mnt = *this->monitor_mi[tid];\nmnt[mnt::sck::get_mutual_info::X](mdm[mdm::sck::modulate ::X_N1]);\n+\n+ if (this->params_BFER_std.chn->type.find(\"RAYLEIGH\") != std::string::npos)\n+ mnt[mnt::sck::get_mutual_info::Y](mdm[mdm::sck::demodulate_wg::Y_N2]);\n+ else\nmnt[mnt::sck::get_mutual_info::Y](mdm[mdm::sck::demodulate::Y_N2]);\n+\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the binding of Monitor MI in STD simu when using demodulation with gain
8,483
04.07.2018 15:44:21
-7,200
ba4d19336b0ea344242f6d8f8385fbd2d6c54b0d
Fix the SystemC binding with new monitors
[ { "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": "@@ -49,9 +49,9 @@ void SC_BFER_ite<B,R,Q>\nthis->interleaver_bit[tid]->set_name(this->interleaver_llr[tid]->get_name() + \"_bit\");\nthis->interleaver_llr[tid]->set_name(this->interleaver_llr[tid]->get_name() + \"_llr\");\n- this->monitor[tid]->add_handler_check([&]() -> void\n+ this->monitor_er[tid]->add_handler_check([&]() -> void\n{\n- if (this->monitor_red->fe_limit_achieved()) // will make the MPI communication\n+ if (this->monitor_er_red->fe_limit_achieved()) // will make the MPI communication\nsc_core::sc_stop();\n});\n}\n@@ -87,7 +87,8 @@ void SC_BFER_ite<B,R,Q>\nthis->interleaver_llr[tid] ->sc.create_module(+itl::tsk::deinterleave);\nthis->codec [tid]->get_decoder_siho()->sc.create_module(+dec::tsk::decode_siho );\nthis->codec [tid]->get_decoder_siso()->sc.create_module(+dec::tsk::decode_siso );\n- this->monitor [tid] ->sc.create_module(+mnt::tsk::check_errors);\n+ this->monitor_er [tid] ->sc.create_module(+mnt::tsk::check_errors);\n+\nif (this->params_BFER_ite.coset)\n{\nthis->coset_real[tid]->sc.create_module(+cst::tsk::apply);\n@@ -186,7 +187,7 @@ void SC_BFER_ite<B,R,Q>\nauto &dch = *this->codec [0]->get_decoder_siho();\nauto &dcs = *this->codec [0]->get_decoder_siso();\nauto &csb = *this->coset_bit [0];\n- auto &mnt = *this->monitor [0];\n+ auto &mnt = *this->monitor_er [0];\nusing namespace module;\nif (this->params_BFER_ite.coset)\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/Standard/SystemC/SC_BFER_std.cpp", "new_path": "src/Simulation/BFER/Standard/SystemC/SC_BFER_std.cpp", "diff": "@@ -37,9 +37,9 @@ void SC_BFER_std<B,R,Q>\n{\nBFER_std<B,R,Q>::__build_communication_chain(tid);\n- this->monitor[tid]->add_handler_check([&]() -> void\n+ this->monitor_er[tid]->add_handler_check([&]() -> void\n{\n- if (this->monitor_red->fe_limit_achieved()) // will make the MPI communication\n+ if (this->monitor_er_red->fe_limit_achieved()) // will make the MPI communication\nsc_core::sc_stop();\n});\n}\n@@ -72,7 +72,8 @@ void SC_BFER_std<B,R,Q>\n}\nthis->quantizer [tid] ->sc.create_module(+qnt::tsk::process );\nthis->codec [tid]->get_decoder_siho()->sc.create_module(+dec::tsk::decode_siho );\n- this->monitor [tid] ->sc.create_module(+mnt::tsk::check_errors);\n+ this->monitor_er[tid] ->sc.create_module(+mnt::tsk::check_errors );\n+ this->monitor_mi[tid] ->sc.create_module(+mnt::tsk::get_mutual_info);\nif (this->params_BFER_std.coset)\n{\nthis->coset_real[tid]->sc.create_module(+cst::tsk::apply);\n@@ -134,7 +135,7 @@ void SC_BFER_std<B,R,Q>\nauto &csr = *this->coset_real[0];\nauto &dec = *this->codec [0]->get_decoder_siho();\nauto &csb = *this->coset_bit [0];\n- auto &mnt = *this->monitor [0];\n+ auto &mnt = *this->monitor_er[0];\nif (this->params_BFER_std.coset)\n{\n@@ -192,6 +193,17 @@ void SC_BFER_std<B,R,Q>\ndec.sc [+dec::tsk::decode_siho ].s_out [+dec::sck::decode_siho ::V_K ](crc.sc[+crc::tsk::extract ].s_in[+crc::sck::extract ::V_K1]);\ncrc.sc [+crc::tsk::extract ].s_out [+crc::sck::extract ::V_K2](mnt.sc[+mnt::tsk::check_errors ].s_in[+mnt::sck::check_errors ::V ]);\n}\n+\n+ if (this->params_BFER_std.mutinfo)\n+ {\n+ auto &mnt = *this->monitor_mi[0];\n+ pct.sc[+pct::tsk::puncture].s_out [+pct::sck::puncture::X_N2](mnt.sc[+mnt::tsk::get_mutual_info].s_in[+mnt::sck::get_mutual_info::X]);\n+\n+ if (this->params_BFER_std.chn->type.find(\"RAYLEIGH\") != std::string::npos) // Rayleigh chn\n+ mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate_wg::Y_N2](mnt.sc[+mnt::tsk::get_mutual_info].s_in[+mnt::sck::get_mutual_info::Y]);\n+ else\n+ mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate::Y_N2](mnt.sc[+mnt::tsk::get_mutual_info].s_in[+mnt::sck::get_mutual_info::Y]);\n+ }\n}\n// ==================================================================================== explicit template instantiation\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the SystemC binding with new monitors
8,483
04.07.2018 17:30:39
-7,200
72e65e7b9d8691defa63dbb94d16ed09150a58bd
Fix the argument definition of --dec-alpha for TPC
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "new_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "diff": "@@ -106,13 +106,7 @@ void Decoder_turbo_product::parameters\nargs.add(\n{p+\"-alpha\"},\n- tools::List<float,Real_splitter>(tools::Real()),\n- \"extrinsic coefficients, one by half iteration (so twice more than number of iterations).\"\n- \" If not enough given values, then automatically extends the last to all iterations.\");\n-\n- args.add(\n- {p+\"-alpha\"},\n- tools::Text(),\n+ tools::List<float,Real_splitter>(tools::Real(), tools::Length(1)),\n\"extrinsic coefficients, one by half iteration (so twice more than number of iterations).\"\n\" If not enough given values, then automatically extends the last to all iterations.\");\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the argument definition of --dec-alpha for TPC
8,490
04.07.2018 17:38:53
-7,200
2bca8281673d59cd2cfe102a400c7d40f5d626c7
First 'working' implem of the LDPC BP vertical layered scheduler.
[ { "change_type": "MODIFY", "old_path": "conf", "new_path": "conf", "diff": "-Subproject commit 1a235468ab507b08eb9513ec62a5f4646bc97953\n+Subproject commit d36d091f421b4d30ce28de4edf29f052c1da3b90\n" }, { "change_type": "MODIFY", "old_path": "refs", "new_path": "refs", "diff": "-Subproject commit 17a8f91e7cb887c2c5c94b72e15918e0ffc0b4cf\n+Subproject commit 76b30ad52d26a9b17d4d61d21dd72fddb575bd00\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp", "new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp", "diff": "#include \"Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hpp\"\n#include \"Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hpp\"\n+#include \"Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/LSPA/Update_rule_LSPA.hpp\"\n@@ -68,7 +69,7 @@ void Decoder_LDPC::parameters\nargs.add_link({p+\"-h-path\"}, {p+\"-info-bits\", \"K\"}); // if there is no K, then H is considered regular,\n// so K is the N - H's height\n- tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_FLOODING\", \"BP_HORIZONTAL_LAYERED\", \"BP_PEELING\");\n+ tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_FLOODING\", \"BP_HORIZONTAL_LAYERED\", \"BP_VERTICAL_LAYERED\", \"BP_PEELING\");\n#ifdef __cpp_aligned_new\ntools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_HORIZONTAL_LAYERED_LEGACY\");\n#endif\n@@ -215,6 +216,22 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\nelse if (this->min == \"MINS\") return new module::Decoder_LDPC_BP_horizontal_layered<B,Q,tools::Update_rule_AMS <Q,tools::min_star <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min_star <Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n}\n+ else if (this->type == \"BP_VERTICAL_LAYERED\" && this->simd_strategy.empty())\n+ {\n+ const auto max_CN_degree = H.get_cols_max_degree();\n+\n+ if (this->implem == \"MS\" ) return new module::Decoder_LDPC_BP_vertical_layered<B,Q,tools::Update_rule_MS <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_MS <Q >( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"OMS\" ) return new module::Decoder_LDPC_BP_vertical_layered<B,Q,tools::Update_rule_OMS <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_OMS <Q >((Q)this->offset ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"NMS\" ) return new module::Decoder_LDPC_BP_vertical_layered<B,Q,tools::Update_rule_NMS <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS <Q >(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"SPA\" ) return new module::Decoder_LDPC_BP_vertical_layered<B,Q,tools::Update_rule_SPA <Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_SPA <Q >(max_CN_degree ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"LSPA\") return new module::Decoder_LDPC_BP_vertical_layered<B,Q,tools::Update_rule_LSPA<Q >>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_LSPA<Q >(max_CN_degree ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"AMS\" )\n+ {\n+ if (this->min == \"MIN\" ) return new module::Decoder_LDPC_BP_vertical_layered<B,Q,tools::Update_rule_AMS <Q,tools::min <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min <Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->min == \"MINL\") return new module::Decoder_LDPC_BP_vertical_layered<B,Q,tools::Update_rule_AMS <Q,tools::min_star_linear2<Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min_star_linear2<Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->min == \"MINS\") return new module::Decoder_LDPC_BP_vertical_layered<B,Q,tools::Update_rule_AMS <Q,tools::min_star <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS <Q,tools::min_star <Q>>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ }\n+ }\n#ifdef __cpp_aligned_new\nelse if (this->type == \"BP_HORIZONTAL_LAYERED\" && this->simd_strategy == \"INTER\")\n{\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hxx", "diff": "@@ -159,7 +159,7 @@ void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\nauto kr = 0;\nauto kw = 0;\n- // layered scheduling\n+ // horizontal layered scheduling\nconst auto n_chk_nodes = (int)this->H.get_n_cols();\nfor (auto c = 0; c < n_chk_nodes; c++)\n{\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hxx", "diff": "@@ -207,7 +207,7 @@ void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\nauto kr = 0;\nauto kw = 0;\n- // layered scheduling\n+ // horizontal layered scheduling\nconst auto n_chk_nodes = (int)this->H.get_n_cols();\nfor (auto c = 0; c < n_chk_nodes; c++)\n{\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered.hpp", "diff": "+#ifndef DECODER_LDPC_BP_VERTICAL_LAYERED_HPP_\n+#define DECODER_LDPC_BP_VERTICAL_LAYERED_HPP_\n+\n+#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n+#include \"Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp\"\n+\n+#include \"../../../Decoder_SISO_SIHO.hpp\"\n+#include \"../Decoder_LDPC_BP.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int, typename R = float, class Update_rule = tools::Update_rule_SPA<R>>\n+class Decoder_LDPC_BP_vertical_layered : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n+{\n+protected:\n+ const std::vector<uint32_t> &info_bits_pos;\n+\n+ Update_rule up_rule;\n+\n+ // data structures for iterative decoding\n+ std::vector<std::vector<R>> var_nodes;\n+ std::vector<std::vector<R>> branches;\n+ std::vector<R > contributions;\n+ std::vector<uint32_t > branches_offsets;\n+\n+ bool init_flag; // reset the chk_to_var vector at the begining of the iterative decoding\n+\n+public:\n+ Decoder_LDPC_BP_vertical_layered(const int K, const int N, const int n_ite,\n+ const tools::Sparse_matrix &H,\n+ const std::vector<unsigned> &info_bits_pos,\n+ const Update_rule &up_rule,\n+ const bool enable_syndrome = true,\n+ const int syndrome_depth = 1,\n+ const int n_frames = 1);\n+ virtual ~Decoder_LDPC_BP_vertical_layered();\n+ void reset();\n+\n+protected:\n+ void _decode_siso (const R *Y_N1, R *Y_N2, const int frame_id);\n+ void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n+ void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n+\n+ void _load (const R *Y_N, const int frame_id);\n+ void _decode (const int frame_id);\n+ void _decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &branches);\n+};\n+}\n+}\n+\n+#include \"Decoder_LDPC_BP_vertical_layered.hxx\"\n+\n+#endif /* DECODER_LDPC_BP_VERTICAL_LAYERED_HPP_ */\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered.hxx", "diff": "+#include <chrono>\n+#include <limits>\n+#include <cmath>\n+#include <stdexcept>\n+\n+#include \"Tools/Perf/common/hard_decide.h\"\n+#include \"Tools/Math/utils.h\"\n+\n+#include \"Decoder_LDPC_BP_vertical_layered.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B, typename R, class Update_rule>\n+Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n+::Decoder_LDPC_BP_vertical_layered(const int K, const int N, const int n_ite,\n+ const tools::Sparse_matrix &_H,\n+ const std::vector<unsigned> &info_bits_pos,\n+ const Update_rule &up_rule,\n+ const bool enable_syndrome,\n+ const int syndrome_depth,\n+ const int n_frames)\n+: Decoder (K, N, n_frames, 1 ),\n+ Decoder_SISO_SIHO<B,R>(K, N, n_frames, 1 ),\n+ Decoder_LDPC_BP (K, N, n_ite, _H, enable_syndrome, syndrome_depth ),\n+ info_bits_pos (info_bits_pos ),\n+ up_rule (up_rule ),\n+ var_nodes (n_frames, std::vector<R>(N )),\n+ branches (n_frames, std::vector<R>(this->H.get_n_connections())),\n+ contributions (this->H.get_cols_max_degree() ),\n+ branches_offsets (this->H.get_n_cols() ),\n+ init_flag (true )\n+{\n+ const std::string name = \"Decoder_LDPC_BP_vertical_layered<\" + this->up_rule.get_name() + \">\";\n+ this->set_name(name);\n+\n+ size_t cur_offb = 0;\n+ const auto n_chk_nodes = (int)this->H.get_n_cols();\n+ for (auto c = 0; c < n_chk_nodes; c++)\n+ {\n+ branches_offsets[c] = (uint32_t)cur_offb;\n+ cur_offb += this->H[c].size();\n+ }\n+\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n+::~Decoder_LDPC_BP_vertical_layered()\n+{\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n+::reset()\n+{\n+ this->init_flag = true;\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n+::_load(const R *Y_N, const int frame_id)\n+{\n+ // memory zones initialization\n+ if (this->init_flag)\n+ {\n+ std::fill(this->branches [frame_id].begin(), this->branches [frame_id].end(), (R)0);\n+ std::fill(this->var_nodes[frame_id].begin(), this->var_nodes[frame_id].end(), (R)0);\n+\n+ if (frame_id == Decoder_SIHO<B,R>::n_frames -1)\n+ this->init_flag = false;\n+ }\n+\n+ for (auto v = 0; v < (int)var_nodes[frame_id].size(); v++)\n+ this->var_nodes[frame_id][v] += Y_N[v]; // var_nodes contain previous extrinsic information\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n+::_decode_siso(const R *Y_N1, R *Y_N2, const int frame_id)\n+{\n+ // memory zones initialization\n+ this->_load(Y_N1, frame_id);\n+\n+ // actual decoding\n+ this->_decode(frame_id);\n+\n+ // prepare for next round by processing extrinsic information\n+ for (auto v = 0; v < this->N; v++)\n+ Y_N2[v] = this->var_nodes[frame_id][v] - Y_N1[v];\n+\n+ // copy extrinsic information into var_nodes for next TURBO iteration\n+ std::copy(Y_N2, Y_N2 + this->N, this->var_nodes[frame_id].begin());\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n+::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n+{\n+// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n+ this->_load(Y_N, frame_id);\n+// auto d_load = std::chrono::steady_clock::now() - t_load;\n+\n+// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n+ // actual decoding\n+ this->_decode(frame_id);\n+// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n+\n+// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n+ // take the hard decision\n+ for (auto i = 0; i < this->K; i++)\n+ {\n+ const auto k = this->info_bits_pos[i];\n+ V_K[i] = !(this->var_nodes[frame_id][k] >= 0);\n+ }\n+// auto d_store = std::chrono::steady_clock::now() - t_store;\n+\n+// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::load, d_load);\n+// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::decode, d_decod);\n+// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::store, d_store);\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n+::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n+{\n+// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n+ this->_load(Y_N, frame_id);\n+// auto d_load = std::chrono::steady_clock::now() - t_load;\n+\n+// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n+ // actual decoding\n+ this->_decode(frame_id);\n+// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n+\n+// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n+ tools::hard_decide(this->var_nodes[frame_id].data(), V_N, this->N);\n+// auto d_store = std::chrono::steady_clock::now() - t_store;\n+\n+// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::load, d_load);\n+// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::decode, d_decod);\n+// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::store, d_store);\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n+::_decode(const int frame_id)\n+{\n+ this->up_rule.begin_decoding(this->n_ite);\n+\n+ for (auto ite = 0; ite < this->n_ite; ite++)\n+ {\n+ this->up_rule.begin_ite(ite);\n+ this->_decode_single_ite(this->var_nodes[frame_id], this->branches[frame_id]);\n+ this->up_rule.end_ite();\n+\n+ if (this->check_syndrome_soft(this->var_nodes[frame_id].data()))\n+ break;\n+ }\n+\n+ this->up_rule.end_decoding();\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n+::_decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &branches)\n+{\n+ // vertical layered scheduling\n+ const auto n_var_nodes = (int)this->H.get_n_rows();\n+ for (auto vv = 0; vv < n_var_nodes; vv++)\n+ {\n+ auto msg_acc = (R)0;\n+ // auto msg_acc = var_nodes[vv];\n+ const auto var_degree = (int)this->H.get_cols_from_row(vv).size();\n+ for (auto c = 0; c < var_degree; c++)\n+ {\n+ auto v_out = -1;\n+ const auto cc = (int)this->H.get_cols_from_row(vv)[c];\n+ const auto offb = (int)this->branches_offsets[cc];\n+ const auto chk_degree = (int)this->H[cc].size();\n+ this->up_rule.begin_chk_node_in(cc, chk_degree);\n+ for (auto v = 0; v < chk_degree; v++)\n+ {\n+ const auto var_id = this->H[cc][v];\n+ v_out = (var_id == (unsigned)vv) ? v : v_out;\n+ contributions[v] = var_nodes[var_id] - branches[offb +v];\n+ this->up_rule.compute_chk_node_in(v, contributions[v]);\n+ }\n+ this->up_rule.end_chk_node_in();\n+\n+ this->up_rule.begin_chk_node_out(cc, chk_degree);\n+ branches[offb + v_out] = this->up_rule.compute_chk_node_out(v_out, contributions[v_out]);\n+ // msg_acc += contributions[v_out] + branches[offb + v_out];\n+ msg_acc += (contributions[v_out] - var_nodes[vv]) + branches[offb + v_out];\n+ this->up_rule.end_chk_node_out();\n+ }\n+ var_nodes[vv] += msg_acc;\n+ }\n+}\n+}\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp", "new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp", "diff": "@@ -246,3 +246,9 @@ void Sparse_matrix\n}\n}\n}\n+\n+std::ostream& operator<<(std::ostream& os, const Sparse_matrix& sm)\n+{\n+ sm.print(0, os);\n+ return os;\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp", "new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp", "diff": "@@ -123,4 +123,6 @@ public:\n}\n}\n+std::ostream& operator<<(std::ostream& os, const aff3ct::tools::Sparse_matrix& sm);\n+\n#endif /* SPARSE_MATRIX_HPP_ */\n" } ]
C++
MIT License
aff3ct/aff3ct
First 'working' implem of the LDPC BP vertical layered scheduler.
8,490
05.07.2018 09:55:08
-7,200
a0aee5915033f9895db209e5f02d6951e30362c1
Simplify the LDPC vertical layered scheduler + variables renaming.
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hpp", "new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hpp", "diff": "@@ -21,10 +21,10 @@ protected:\nstd::vector<uint32_t > transpose;\nstd::vector<R > post; // a posteriori information\n- std::vector<std::vector<R>> chk_to_var; // check nodes to variable nodes messages\n- std::vector<std::vector<R>> var_to_chk; // variable nodes to check nodes messages\n+ std::vector<std::vector<R>> msg_chk_to_var; // check nodes to variable nodes messages\n+ std::vector<std::vector<R>> msg_var_to_chk; // variable nodes to check nodes messages\n- bool init_flag; // reset the chk_to_var vector at the begining of the iterative decoding\n+ bool init_flag; // reset the msg_chk_to_var vector at the begining of the iterative decoding\npublic:\nDecoder_LDPC_BP_flooding(const int K, const int N, const int n_ite,\n@@ -43,9 +43,9 @@ protected:\nvoid _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\nvoid _decode (const R *Y_N, const int frame_id);\n- void _initialize_var_to_chk(const R *Y_N, const std::vector<R> &chk_to_var, std::vector<R> &var_to_chk);\n- void _decode_single_ite (const std::vector<R> &var_to_chk, std::vector<R> &chk_to_var);\n- void _compute_post (const R *Y_N, const std::vector<R> &chk_to_var, std::vector<R> &post);\n+ void _initialize_var_to_chk(const R *Y_N, const std::vector<R> &msg_chk_to_var, std::vector<R> &msg_var_to_chk);\n+ void _decode_single_ite ( const std::vector<R> &msg_var_to_chk, std::vector<R> &msg_chk_to_var);\n+ void _compute_post (const R *Y_N, const std::vector<R> &msg_chk_to_var, std::vector<R> &post);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hxx", "diff": "@@ -28,8 +28,8 @@ Decoder_LDPC_BP_flooding<B,R,Update_rule>\nup_rule (up_rule ),\ntranspose (this->H.get_n_connections() ),\npost (N, -1 ),\n- chk_to_var (n_frames, std::vector<R>(this->H.get_n_connections())),\n- var_to_chk (n_frames, std::vector<R>(this->H.get_n_connections())),\n+ msg_chk_to_var (n_frames, std::vector<R>(this->H.get_n_connections())),\n+ msg_var_to_chk (n_frames, std::vector<R>(this->H.get_n_connections())),\ninit_flag (true )\n{\nconst std::string name = \"Decoder_LDPC_BP_flooding<\" + this->up_rule.get_name() + \">\";\n@@ -37,28 +37,28 @@ Decoder_LDPC_BP_flooding<B,R,Update_rule>\nmipp::vector<unsigned char> connections(this->H.get_n_rows(), 0);\n- const auto &chk_to_var_id = this->H.get_col_to_rows();\n- const auto &var_to_chk_id = this->H.get_row_to_cols();\n+ const auto &msg_chk_to_var_id = this->H.get_col_to_rows();\n+ const auto &msg_var_to_chk_id = this->H.get_row_to_cols();\nauto k = 0;\n- for (auto i = 0; i < (int)chk_to_var_id.size(); i++)\n+ for (auto i = 0; i < (int)msg_chk_to_var_id.size(); i++)\n{\n- for (auto j = 0; j < (int)chk_to_var_id[i].size(); j++)\n+ for (auto j = 0; j < (int)msg_chk_to_var_id[i].size(); j++)\n{\n- auto var_id = chk_to_var_id[i][j];\n+ auto var_id = msg_chk_to_var_id[i][j];\nauto branch_id = 0;\nfor (auto ii = 0; ii < (int)var_id; ii++)\n- branch_id += (int)var_to_chk_id[ii].size();\n+ branch_id += (int)msg_var_to_chk_id[ii].size();\nbranch_id += connections[var_id];\nconnections[var_id]++;\n- if (connections[var_id] > (int)var_to_chk_id[var_id].size())\n+ if (connections[var_id] > (int)msg_var_to_chk_id[var_id].size())\n{\nstd::stringstream message;\n- message << \"'connections[var_id]' has to be equal or smaller than 'var_to_chk_id[var_id].size()' \"\n+ message << \"'connections[var_id]' has to be equal or smaller than 'msg_var_to_chk_id[var_id].size()' \"\n<< \"('var_id' = \" << var_id << \", 'connections[var_id]' = \" << connections[var_id]\n- << \", 'var_to_chk_id[var_id].size()' = \" << var_to_chk_id[var_id].size() << \").\";\n+ << \", 'msg_var_to_chk_id[var_id].size()' = \" << msg_var_to_chk_id[var_id].size() << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n@@ -88,7 +88,7 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\n// memory zones initialization\nif (this->init_flag)\n{\n- std::fill(this->chk_to_var[frame_id].begin(), this->chk_to_var[frame_id].end(), (R)0);\n+ std::fill(this->msg_chk_to_var[frame_id].begin(), this->msg_chk_to_var[frame_id].end(), (R)0);\nif (frame_id == Decoder_SIHO<B,R>::n_frames -1)\nthis->init_flag = false;\n@@ -109,7 +109,7 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\n// memory zones initialization\nif (this->init_flag)\n{\n- std::fill(this->chk_to_var[frame_id].begin(), this->chk_to_var[frame_id].end(), (R)0);\n+ std::fill(this->msg_chk_to_var[frame_id].begin(), this->msg_chk_to_var[frame_id].end(), (R)0);\nif (frame_id == Decoder_SIHO<B,R>::n_frames -1)\nthis->init_flag = false;\n@@ -143,7 +143,7 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\n// memory zones initialization\nif (this->init_flag)\n{\n- std::fill(this->chk_to_var[frame_id].begin(), this->chk_to_var[frame_id].end(), (R)0);\n+ std::fill(this->msg_chk_to_var[frame_id].begin(), this->msg_chk_to_var[frame_id].end(), (R)0);\nif (frame_id == Decoder_SIHO<B,R>::n_frames -1)\nthis->init_flag = false;\n@@ -174,51 +174,51 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\nfor (; ite < this->n_ite; ite++)\n{\nthis->up_rule.begin_ite(ite);\n- this->_initialize_var_to_chk(Y_N, this->chk_to_var[frame_id], this->var_to_chk[frame_id]);\n- this->_decode_single_ite(this->var_to_chk[frame_id], this->chk_to_var[frame_id]);\n+ this->_initialize_var_to_chk(Y_N, this->msg_chk_to_var[frame_id], this->msg_var_to_chk[frame_id]);\n+ this->_decode_single_ite(this->msg_var_to_chk[frame_id], this->msg_chk_to_var[frame_id]);\nthis->up_rule.end_ite();\nif (this->enable_syndrome && ite != this->n_ite -1)\n{\n- this->_compute_post(Y_N, this->chk_to_var[frame_id], this->post);\n+ this->_compute_post(Y_N, this->msg_chk_to_var[frame_id], this->post);\nif (this->check_syndrome_soft(this->post.data()))\nbreak;\n}\n}\nif (ite == this->n_ite)\n- this->_compute_post(Y_N, this->chk_to_var[frame_id], this->post);\n+ this->_compute_post(Y_N, this->msg_chk_to_var[frame_id], this->post);\nthis->up_rule.end_decoding();\n}\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_flooding<B,R,Update_rule>\n-::_initialize_var_to_chk(const R *Y_N, const std::vector<R> &chk_to_var, std::vector<R> &var_to_chk)\n+::_initialize_var_to_chk(const R *Y_N, const std::vector<R> &msg_chk_to_var, std::vector<R> &msg_var_to_chk)\n{\n- auto *chk_to_var_ptr = chk_to_var.data();\n- auto *var_to_chk_ptr = var_to_chk.data();\n+ auto *msg_chk_to_var_ptr = msg_chk_to_var.data();\n+ auto *msg_var_to_chk_ptr = msg_var_to_chk.data();\nconst auto n_var_nodes = (int)this->H.get_n_rows();;\nfor (auto v = 0; v < n_var_nodes; v++)\n{\nconst auto var_degree = (int)this->H.get_row_to_cols()[v].size();\n- auto sum_chk_to_var = (R)0;\n+ auto sum_msg_chk_to_var = (R)0;\nfor (auto c = 0; c < var_degree; c++)\n- sum_chk_to_var += chk_to_var_ptr[c];\n+ sum_msg_chk_to_var += msg_chk_to_var_ptr[c];\n- const auto tmp = Y_N[v] + sum_chk_to_var;\n+ const auto tmp = Y_N[v] + sum_msg_chk_to_var;\nfor (auto c = 0; c < var_degree; c++)\n- var_to_chk_ptr[c] = tmp - chk_to_var_ptr[c];\n+ msg_var_to_chk_ptr[c] = tmp - msg_chk_to_var_ptr[c];\n- chk_to_var_ptr += var_degree;\n- var_to_chk_ptr += var_degree;\n+ msg_chk_to_var_ptr += var_degree;\n+ msg_var_to_chk_ptr += var_degree;\n}\n}\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_flooding<B,R,Update_rule>\n-::_decode_single_ite(const std::vector<R> &var_to_chk, std::vector<R> &chk_to_var)\n+::_decode_single_ite(const std::vector<R> &msg_var_to_chk, std::vector<R> &msg_chk_to_var)\n{\nauto transpose_ptr = this->transpose.data();\n@@ -230,12 +230,12 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\nthis->up_rule.begin_chk_node_in(c, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n- this->up_rule.compute_chk_node_in(v, var_to_chk[transpose_ptr[v]]);\n+ this->up_rule.compute_chk_node_in(v, msg_var_to_chk[transpose_ptr[v]]);\nthis->up_rule.end_chk_node_in();\nthis->up_rule.begin_chk_node_out(c, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n- chk_to_var[transpose_ptr[v]] = this->up_rule.compute_chk_node_out(v, var_to_chk[transpose_ptr[v]]);\n+ msg_chk_to_var[transpose_ptr[v]] = this->up_rule.compute_chk_node_out(v, msg_var_to_chk[transpose_ptr[v]]);\nthis->up_rule.end_chk_node_out();\ntranspose_ptr += chk_degree;\n@@ -244,23 +244,23 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_flooding<B,R,Update_rule>\n-::_compute_post(const R *Y_N, const std::vector<R> &chk_to_var, std::vector<R> &post)\n+::_compute_post(const R *Y_N, const std::vector<R> &msg_chk_to_var, std::vector<R> &post)\n{\n// compute the a posteriori info\n- const auto *chk_to_var_ptr = chk_to_var.data();\n+ const auto *msg_chk_to_var_ptr = msg_chk_to_var.data();\nconst auto n_var_nodes = (int)this->H.get_n_rows();;\nfor (auto v = 0; v < n_var_nodes; v++)\n{\nconst auto var_degree = (int)this->H.get_row_to_cols()[v].size();\n- auto sum_chk_to_var = (R)0;\n+ auto sum_msg_chk_to_var = (R)0;\nfor (auto c = 0; c < var_degree; c++)\n- sum_chk_to_var += chk_to_var_ptr[c];\n+ sum_msg_chk_to_var += msg_chk_to_var_ptr[c];\n// filling the output\n- post[v] = Y_N[v] + sum_chk_to_var;\n+ post[v] = Y_N[v] + sum_msg_chk_to_var;\n- chk_to_var_ptr += var_degree;\n+ msg_chk_to_var_ptr += var_degree;\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding_inter.hpp", "new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding_inter.hpp", "diff": "@@ -26,8 +26,8 @@ protected:\nstd::vector<uint32_t> transpose;\nmipp::vector<mipp::Reg<R>> post; // a posteriori information\n- std::vector<mipp::vector<mipp::Reg<R>>> chk_to_var; // check nodes to variable nodes messages\n- std::vector<mipp::vector<mipp::Reg<R>>> var_to_chk; // variable nodes to check nodes messages\n+ std::vector<mipp::vector<mipp::Reg<R>>> msg_chk_to_var; // check nodes to variable nodes messages\n+ std::vector<mipp::vector<mipp::Reg<R>>> msg_var_to_chk; // variable nodes to check nodes messages\nmipp::vector<mipp::Reg<R>> Y_N_reorderered;\nmipp::vector<mipp::Reg<B>> V_reorderered;\n@@ -52,10 +52,11 @@ protected:\nvoid _load (const R *Y_N, const int frame_id);\nvoid _decode (const mipp::Reg<R> *Y_N, const int cur_wave);\n- void _initialize_var_to_chk(const mipp::Reg<R> *Y_N, const mipp::vector<mipp::Reg<R>> &chk_to_var,\n- mipp::vector<mipp::Reg<R>> &var_to_chk);\n- void _decode_single_ite (const mipp::vector<mipp::Reg<R>> &var_to_chk, mipp::vector<mipp::Reg<R>> &chk_to_var);\n- void _compute_post (const mipp::Reg<R> *Y_N, const mipp::vector<mipp::Reg<R>> &chk_to_var,\n+ void _initialize_var_to_chk(const mipp::Reg<R> *Y_N, const mipp::vector<mipp::Reg<R>> &msg_chk_to_var,\n+ mipp::vector<mipp::Reg<R>> &msg_var_to_chk);\n+ void _decode_single_ite (const mipp::vector<mipp::Reg<R>> &msg_var_to_chk,\n+ mipp::vector<mipp::Reg<R>> &msg_chk_to_var);\n+ void _compute_post (const mipp::Reg<R> *Y_N, const mipp::vector<mipp::Reg<R>> &msg_chk_to_var,\nmipp::vector<mipp::Reg<R>> &post);\nbool _check_syndrome_soft (const mipp::vector<mipp::Reg<R>> &var_nodes);\n};\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding_inter.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding_inter.hxx", "diff": "@@ -32,8 +32,8 @@ Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\nsat_val ((R)((1 << ((sizeof(R) * 8 -2) - (int)std::log2(this->H.get_rows_max_degree()))) -1)),\ntranspose (this->H.get_n_connections() ),\npost (N, -1 ),\n- chk_to_var (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(this->H.get_n_connections()) ),\n- var_to_chk (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(this->H.get_n_connections()) ),\n+ msg_chk_to_var (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(this->H.get_n_connections()) ),\n+ msg_var_to_chk (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(this->H.get_n_connections()) ),\nY_N_reorderered (N ),\nV_reorderered (N ),\ninit_flag (true )\n@@ -50,28 +50,28 @@ Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\nmipp::vector<unsigned char> connections(this->H.get_n_rows(), 0);\n- const auto &chk_to_var_id = this->H.get_col_to_rows();\n- const auto &var_to_chk_id = this->H.get_row_to_cols();\n+ const auto &msg_chk_to_var_id = this->H.get_col_to_rows();\n+ const auto &msg_var_to_chk_id = this->H.get_row_to_cols();\nauto k = 0;\n- for (auto i = 0; i < (int)chk_to_var_id.size(); i++)\n+ for (auto i = 0; i < (int)msg_chk_to_var_id.size(); i++)\n{\n- for (auto j = 0; j < (int)chk_to_var_id[i].size(); j++)\n+ for (auto j = 0; j < (int)msg_chk_to_var_id[i].size(); j++)\n{\n- auto var_id = chk_to_var_id[i][j];\n+ auto var_id = msg_chk_to_var_id[i][j];\nauto branch_id = 0;\nfor (auto ii = 0; ii < (int)var_id; ii++)\n- branch_id += (int)var_to_chk_id[ii].size();\n+ branch_id += (int)msg_var_to_chk_id[ii].size();\nbranch_id += connections[var_id];\nconnections[var_id]++;\n- if (connections[var_id] > (int)var_to_chk_id[var_id].size())\n+ if (connections[var_id] > (int)msg_var_to_chk_id[var_id].size())\n{\nstd::stringstream message;\n- message << \"'connections[var_id]' has to be equal or smaller than 'var_to_chk_id[var_id].size()' \"\n+ message << \"'connections[var_id]' has to be equal or smaller than 'msg_var_to_chk_id[var_id].size()' \"\n<< \"('var_id' = \" << var_id << \", 'connections[var_id]' = \" << connections[var_id]\n- << \", 'var_to_chk_id[var_id].size()' = \" << var_to_chk_id[var_id].size() << \").\";\n+ << \", 'msg_var_to_chk_id[var_id].size()' = \" << msg_var_to_chk_id[var_id].size() << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n@@ -104,7 +104,7 @@ void Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\nif (this->init_flag)\n{\nconst auto zero = mipp::Reg<R>((R)0);\n- std::fill(this->chk_to_var[cur_wave].begin(), this->chk_to_var[cur_wave].end(), zero);\n+ std::fill(this->msg_chk_to_var[cur_wave].begin(), this->msg_chk_to_var[cur_wave].end(), zero);\nif (cur_wave == this->n_dec_waves -1) this->init_flag = false;\n}\n@@ -130,7 +130,7 @@ void Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\nif (this->init_flag)\n{\nconst auto zero = mipp::Reg<R>((R)0);\n- std::fill(this->chk_to_var[cur_wave].begin(), this->chk_to_var[cur_wave].end(), zero);\n+ std::fill(this->msg_chk_to_var[cur_wave].begin(), this->msg_chk_to_var[cur_wave].end(), zero);\nif (cur_wave == this->n_dec_waves -1) this->init_flag = false;\n}\n@@ -170,7 +170,7 @@ void Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\nif (this->init_flag)\n{\nconst auto zero = mipp::Reg<R>((R)0);\n- std::fill(this->chk_to_var[frame_id].begin(), this->chk_to_var[frame_id].end(), zero);\n+ std::fill(this->msg_chk_to_var[frame_id].begin(), this->msg_chk_to_var[frame_id].end(), zero);\nif (cur_wave == this->n_dec_waves -1) this->init_flag = false;\n}\n@@ -205,19 +205,19 @@ void Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\nfor (; ite < this->n_ite; ite++)\n{\nthis->up_rule.begin_ite(ite);\n- this->_initialize_var_to_chk(Y_N, this->chk_to_var[cur_wave], this->var_to_chk[cur_wave]);\n- this->_decode_single_ite(this->var_to_chk[cur_wave], this->chk_to_var[cur_wave]);\n+ this->_initialize_var_to_chk(Y_N, this->msg_chk_to_var[cur_wave], this->msg_var_to_chk[cur_wave]);\n+ this->_decode_single_ite(this->msg_var_to_chk[cur_wave], this->msg_chk_to_var[cur_wave]);\nthis->up_rule.end_ite();\nif (this->enable_syndrome && ite != this->n_ite -1)\n{\n- this->_compute_post(Y_N, this->chk_to_var[cur_wave], this->post);\n+ this->_compute_post(Y_N, this->msg_chk_to_var[cur_wave], this->post);\nif (this->_check_syndrome_soft(this->post))\nbreak;\n}\n}\nif (ite == this->n_ite)\n- this->_compute_post(Y_N, this->chk_to_var[cur_wave], this->post);\n+ this->_compute_post(Y_N, this->msg_chk_to_var[cur_wave], this->post);\nthis->up_rule.end_decoding();\n}\n@@ -225,33 +225,33 @@ void Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\n::_initialize_var_to_chk(const mipp::Reg<R> *Y_N,\n- const mipp::vector<mipp::Reg<R>> &chk_to_var,\n- mipp::vector<mipp::Reg<R>> &var_to_chk)\n+ const mipp::vector<mipp::Reg<R>> &msg_chk_to_var,\n+ mipp::vector<mipp::Reg<R>> &msg_var_to_chk)\n{\n- auto *chk_to_var_ptr = chk_to_var.data();\n- auto *var_to_chk_ptr = var_to_chk.data();\n+ auto *msg_chk_to_var_ptr = msg_chk_to_var.data();\n+ auto *msg_var_to_chk_ptr = msg_var_to_chk.data();\nconst auto n_var_nodes = (int)this->H.get_n_rows();;\nfor (auto v = 0; v < n_var_nodes; v++)\n{\nconst auto var_degree = (int)this->H.get_row_to_cols()[v].size();\n- auto sum_chk_to_var = mipp::Reg<R>((R)0);\n+ auto sum_msg_chk_to_var = mipp::Reg<R>((R)0);\nfor (auto c = 0; c < var_degree; c++)\n- sum_chk_to_var += chk_to_var_ptr[c];\n+ sum_msg_chk_to_var += msg_chk_to_var_ptr[c];\n- const auto tmp = Y_N[v] + sum_chk_to_var;\n+ const auto tmp = Y_N[v] + sum_msg_chk_to_var;\nfor (auto c = 0; c < var_degree; c++)\n- var_to_chk_ptr[c] = tmp - chk_to_var_ptr[c];\n+ msg_var_to_chk_ptr[c] = tmp - msg_chk_to_var_ptr[c];\n- chk_to_var_ptr += var_degree;\n- var_to_chk_ptr += var_degree;\n+ msg_chk_to_var_ptr += var_degree;\n+ msg_var_to_chk_ptr += var_degree;\n}\n}\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\n-::_decode_single_ite(const mipp::vector<mipp::Reg<R>> &var_to_chk, mipp::vector<mipp::Reg<R>> &chk_to_var)\n+::_decode_single_ite(const mipp::vector<mipp::Reg<R>> &msg_var_to_chk, mipp::vector<mipp::Reg<R>> &msg_chk_to_var)\n{\nauto transpose_ptr = this->transpose.data();\n@@ -263,14 +263,14 @@ void Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\nthis->up_rule.begin_chk_node_in(c, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n- this->up_rule.compute_chk_node_in(v, var_to_chk[transpose_ptr[v]]);\n+ this->up_rule.compute_chk_node_in(v, msg_var_to_chk[transpose_ptr[v]]);\nthis->up_rule.end_chk_node_in();\nthis->up_rule.begin_chk_node_out(c, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n{\n- auto val = saturate<R>(this->up_rule.compute_chk_node_out(v, var_to_chk[transpose_ptr[v]]), this->sat_val);\n- chk_to_var[transpose_ptr[v]] = val;\n+ auto val = saturate<R>(this->up_rule.compute_chk_node_out(v, msg_var_to_chk[transpose_ptr[v]]), this->sat_val);\n+ msg_chk_to_var[transpose_ptr[v]] = val;\n}\nthis->up_rule.end_chk_node_out();\n@@ -281,24 +281,24 @@ void Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_flooding_inter<B,R,Update_rule>\n::_compute_post(const mipp::Reg<R> *Y_N,\n- const mipp::vector<mipp::Reg<R>> &chk_to_var,\n+ const mipp::vector<mipp::Reg<R>> &msg_chk_to_var,\nmipp::vector<mipp::Reg<R>> &post)\n{\n// compute the a posteriori info\n- const auto *chk_to_var_ptr = chk_to_var.data();\n+ const auto *msg_chk_to_var_ptr = msg_chk_to_var.data();\nconst auto n_var_nodes = (int)this->H.get_n_rows();;\nfor (auto v = 0; v < n_var_nodes; v++)\n{\nconst auto var_degree = (int)this->H.get_row_to_cols()[v].size();\n- auto sum_chk_to_var = mipp::Reg<R>((R)0);\n+ auto sum_msg_chk_to_var = mipp::Reg<R>((R)0);\nfor (auto c = 0; c < var_degree; c++)\n- sum_chk_to_var += chk_to_var_ptr[c];\n+ sum_msg_chk_to_var += msg_chk_to_var_ptr[c];\n// filling the output\n- post[v] = Y_N[v] + sum_chk_to_var;\n+ post[v] = Y_N[v] + sum_msg_chk_to_var;\n- chk_to_var_ptr += var_degree;\n+ msg_chk_to_var_ptr += var_degree;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hpp", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hpp", "diff": "@@ -21,7 +21,7 @@ protected:\n// data structures for iterative decoding\nstd::vector<std::vector<R>> var_nodes;\n- std::vector<std::vector<R>> branches;\n+ std::vector<std::vector<R>> messages;\nstd::vector<R > contributions;\nbool init_flag; // reset the chk_to_var vector at the begining of the iterative decoding\n@@ -44,7 +44,7 @@ protected:\nvoid _load (const R *Y_N, const int frame_id);\nvoid _decode (const int frame_id);\n- void _decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &branches);\n+ void _decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &messages);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered.hxx", "diff": "@@ -27,7 +27,7 @@ Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\ninfo_bits_pos (info_bits_pos ),\nup_rule (up_rule ),\nvar_nodes (n_frames, std::vector<R>(N )),\n- branches (n_frames, std::vector<R>(this->H.get_n_connections())),\n+ messages (n_frames, std::vector<R>(this->H.get_n_connections())),\ncontributions (this->H.get_cols_max_degree() ),\ninit_flag (true )\n{\n@@ -55,7 +55,7 @@ void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n// memory zones initialization\nif (this->init_flag)\n{\n- std::fill(this->branches [frame_id].begin(), this->branches [frame_id].end(), (R)0);\n+ std::fill(this->messages [frame_id].begin(), this->messages [frame_id].end(), (R)0);\nstd::fill(this->var_nodes[frame_id].begin(), this->var_nodes[frame_id].end(), (R)0);\nif (frame_id == Decoder_SIHO<B,R>::n_frames -1)\n@@ -142,7 +142,7 @@ void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\nfor (auto ite = 0; ite < this->n_ite; ite++)\n{\nthis->up_rule.begin_ite(ite);\n- this->_decode_single_ite(this->var_nodes[frame_id], this->branches[frame_id]);\n+ this->_decode_single_ite(this->var_nodes[frame_id], this->messages[frame_id]);\nthis->up_rule.end_ite();\nif (this->check_syndrome_soft(this->var_nodes[frame_id].data()))\n@@ -154,7 +154,7 @@ void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\n-::_decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &branches)\n+::_decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &messages)\n{\nauto kr = 0;\nauto kw = 0;\n@@ -167,7 +167,7 @@ void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\nthis->up_rule.begin_chk_node_in(c, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n{\n- contributions[v] = var_nodes[this->H[c][v]] - branches[kr++];\n+ contributions[v] = var_nodes[this->H[c][v]] - messages[kr++];\nthis->up_rule.compute_chk_node_in(v, contributions[v]);\n}\nthis->up_rule.end_chk_node_in();\n@@ -175,8 +175,8 @@ void Decoder_LDPC_BP_horizontal_layered<B,R,Update_rule>\nthis->up_rule.begin_chk_node_out(c, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n{\n- branches[kw] = this->up_rule.compute_chk_node_out(v, contributions[v]);\n- var_nodes[this->H[c][v]] = contributions[v] + branches[kw++];\n+ messages[kw] = this->up_rule.compute_chk_node_out(v, contributions[v]);\n+ var_nodes[this->H[c][v]] = contributions[v] + messages[kw++];\n}\nthis->up_rule.end_chk_node_out();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hpp", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hpp", "diff": "@@ -25,7 +25,7 @@ protected:\n// data structures for iterative decoding\nstd::vector<mipp::vector<mipp::Reg<R>>> var_nodes;\n- std::vector<mipp::vector<mipp::Reg<R>>> branches;\n+ std::vector<mipp::vector<mipp::Reg<R>>> messages;\nmipp::vector<mipp::Reg<R>> contributions;\nmipp::vector<mipp::Reg<R>> Y_N_reorderered;\n@@ -51,7 +51,7 @@ protected:\nvoid _load (const R *Y_N, const int frame_id);\nvoid _decode (const int frame_id);\n- void _decode_single_ite (mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &branches);\n+ void _decode_single_ite (mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &messages);\nbool _check_syndrome_soft(const mipp::vector<mipp::Reg<R>> &var_nodes);\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hxx", "diff": "@@ -47,7 +47,7 @@ Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\nup_rule (up_rule ),\nsat_val ((R)((1 << ((sizeof(R) * 8 -2) - (int)std::log2(this->H.get_rows_max_degree()))) -1)),\nvar_nodes (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(N) ),\n- branches (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(this->H.get_n_connections()) ),\n+ messages (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(this->H.get_n_connections()) ),\ncontributions (this->H.get_cols_max_degree() ),\nY_N_reorderered (N ),\nV_reorderered (N ),\n@@ -87,7 +87,7 @@ void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\nif (this->init_flag)\n{\nconst auto zero = mipp::Reg<R>((R)0);\n- std::fill(this->branches [cur_wave].begin(), this->branches [cur_wave].end(), zero);\n+ std::fill(this->messages [cur_wave].begin(), this->messages [cur_wave].end(), zero);\nstd::fill(this->var_nodes[cur_wave].begin(), this->var_nodes[cur_wave].end(), zero);\nif (cur_wave == this->n_dec_waves -1) this->init_flag = false;\n@@ -190,7 +190,7 @@ void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\nfor (auto ite = 0; ite < this->n_ite; ite++)\n{\nthis->up_rule.begin_ite(ite);\n- this->_decode_single_ite(this->var_nodes[cur_wave], this->branches[cur_wave]);\n+ this->_decode_single_ite(this->var_nodes[cur_wave], this->messages[cur_wave]);\nthis->up_rule.end_ite();\nif (this->_check_syndrome_soft(this->var_nodes[cur_wave]))\n@@ -202,7 +202,7 @@ void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\n-::_decode_single_ite(mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &branches)\n+::_decode_single_ite(mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &messages)\n{\nauto kr = 0;\nauto kw = 0;\n@@ -215,7 +215,7 @@ void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\nthis->up_rule.begin_chk_node_in(c, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n{\n- this->contributions[v] = var_nodes[this->H[c][v]] - branches[kr++];\n+ this->contributions[v] = var_nodes[this->H[c][v]] - messages[kr++];\nthis->up_rule.compute_chk_node_in(v, this->contributions[v]);\n}\nthis->up_rule.end_chk_node_in();\n@@ -223,8 +223,8 @@ void Decoder_LDPC_BP_horizontal_layered_inter<B,R,Update_rule>\nthis->up_rule.begin_chk_node_out(c, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n{\n- branches[kw] = saturate<R>(this->up_rule.compute_chk_node_out(v, this->contributions[v]), this->sat_val);\n- var_nodes[this->H[c][v]] = this->contributions[v] + branches[kw++];\n+ messages[kw] = saturate<R>(this->up_rule.compute_chk_node_out(v, this->contributions[v]), this->sat_val);\n+ var_nodes[this->H[c][v]] = this->contributions[v] + messages[kw++];\n}\nthis->up_rule.end_chk_node_out();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered.hpp", "new_path": "src/Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered.hpp", "diff": "@@ -21,9 +21,9 @@ protected:\n// data structures for iterative decoding\nstd::vector<std::vector<R>> var_nodes;\n- std::vector<std::vector<R>> branches;\n+ std::vector<std::vector<R>> messages;\nstd::vector<R > contributions;\n- std::vector<uint32_t > branches_offsets;\n+ std::vector<uint32_t > messages_offsets;\nbool init_flag; // reset the chk_to_var vector at the begining of the iterative decoding\n@@ -45,7 +45,7 @@ protected:\nvoid _load (const R *Y_N, const int frame_id);\nvoid _decode (const int frame_id);\n- void _decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &branches);\n+ void _decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &messages);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered.hxx", "new_path": "src/Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered.hxx", "diff": "@@ -27,20 +27,20 @@ Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\ninfo_bits_pos (info_bits_pos ),\nup_rule (up_rule ),\nvar_nodes (n_frames, std::vector<R>(N )),\n- branches (n_frames, std::vector<R>(this->H.get_n_connections())),\n+ messages (n_frames, std::vector<R>(this->H.get_n_connections())),\ncontributions (this->H.get_cols_max_degree() ),\n- branches_offsets (this->H.get_n_cols() ),\n+ messages_offsets (this->H.get_n_cols() ),\ninit_flag (true )\n{\nconst std::string name = \"Decoder_LDPC_BP_vertical_layered<\" + this->up_rule.get_name() + \">\";\nthis->set_name(name);\n- size_t cur_offb = 0;\n+ size_t cur_off_msg = 0;\nconst auto n_chk_nodes = (int)this->H.get_n_cols();\nfor (auto c = 0; c < n_chk_nodes; c++)\n{\n- branches_offsets[c] = (uint32_t)cur_offb;\n- cur_offb += this->H[c].size();\n+ messages_offsets[c] = (uint32_t)cur_off_msg;\n+ cur_off_msg += this->H[c].size();\n}\n}\n@@ -65,7 +65,7 @@ void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n// memory zones initialization\nif (this->init_flag)\n{\n- std::fill(this->branches [frame_id].begin(), this->branches [frame_id].end(), (R)0);\n+ std::fill(this->messages [frame_id].begin(), this->messages [frame_id].end(), (R)0);\nstd::fill(this->var_nodes[frame_id].begin(), this->var_nodes[frame_id].end(), (R)0);\nif (frame_id == Decoder_SIHO<B,R>::n_frames -1)\n@@ -152,7 +152,7 @@ void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\nfor (auto ite = 0; ite < this->n_ite; ite++)\n{\nthis->up_rule.begin_ite(ite);\n- this->_decode_single_ite(this->var_nodes[frame_id], this->branches[frame_id]);\n+ this->_decode_single_ite(this->var_nodes[frame_id], this->messages[frame_id]);\nthis->up_rule.end_ite();\nif (this->check_syndrome_soft(this->var_nodes[frame_id].data()))\n@@ -164,36 +164,35 @@ void Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_vertical_layered<B,R,Update_rule>\n-::_decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &branches)\n+::_decode_single_ite(std::vector<R> &var_nodes, std::vector<R> &messages)\n{\n// vertical layered scheduling\nconst auto n_var_nodes = (int)this->H.get_n_rows();\nfor (auto vv = 0; vv < n_var_nodes; vv++)\n{\nauto msg_acc = (R)0;\n- // auto msg_acc = var_nodes[vv];\nconst auto var_degree = (int)this->H.get_cols_from_row(vv).size();\nfor (auto c = 0; c < var_degree; c++)\n{\nauto v_out = -1;\nconst auto cc = (int)this->H.get_cols_from_row(vv)[c];\n- const auto offb = (int)this->branches_offsets[cc];\n+ const auto off_msg = (int)this->messages_offsets[cc];\nconst auto chk_degree = (int)this->H[cc].size();\nthis->up_rule.begin_chk_node_in(cc, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n{\nconst auto var_id = this->H[cc][v];\nv_out = (var_id == (unsigned)vv) ? v : v_out;\n- contributions[v] = var_nodes[var_id] - branches[offb +v];\n+ contributions[v] = var_nodes[var_id] - messages[off_msg +v];\nthis->up_rule.compute_chk_node_in(v, contributions[v]);\n}\nthis->up_rule.end_chk_node_in();\n+ msg_acc -= messages[off_msg + v_out];\nthis->up_rule.begin_chk_node_out(cc, chk_degree);\n- branches[offb + v_out] = this->up_rule.compute_chk_node_out(v_out, contributions[v_out]);\n- // msg_acc += contributions[v_out] + branches[offb + v_out];\n- msg_acc += (contributions[v_out] - var_nodes[vv]) + branches[offb + v_out];\n+ messages[off_msg + v_out] = this->up_rule.compute_chk_node_out(v_out, contributions[v_out]);\nthis->up_rule.end_chk_node_out();\n+ msg_acc += messages[off_msg + v_out];\n}\nvar_nodes[vv] += msg_acc;\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Simplify the LDPC vertical layered scheduler + variables renaming.
8,483
05.07.2018 11:22:53
-7,200
30c4a222acf1f6dee218402d9eea5daf294ba63d
Fix the decoder_siho frame starting id
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Decoder_SIHO.hxx", "new_path": "src/Module/Decoder/Decoder_SIHO.hxx", "diff": "@@ -108,8 +108,8 @@ decode_siho(const R *Y_N, B *V_K, const int frame_id)\nconst auto w_start = (frame_id < 0) ? 0 : frame_id % this->n_dec_waves;\nconst auto w_stop = (frame_id < 0) ? this->n_dec_waves : w_start +1;\n- auto w = w_start;\n- for (w = 0; w < w_stop -1; w++)\n+ auto w = 0;\n+ for (w = w_start; w < w_stop -1; w++)\nthis->_decode_siho(Y_N + w * this->N * this->simd_inter_frame_level,\nV_K + w * this->K * this->simd_inter_frame_level,\nw * this->simd_inter_frame_level);\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the decoder_siho frame starting id
8,490
05.07.2018 14:43:19
-7,200
ca9c1a7b396c7016c3006c44f9bb7bf20b77a132
Add LDPC vertical layered scheduler with inter SIMD.
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp", "new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp", "diff": "#ifdef __cpp_aligned_new\n#include \"Module/Decoder/LDPC/BP/Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hpp\"\n+#include \"Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered_inter.hpp\"\n#include \"Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding_inter.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/MS/Update_rule_MS_inter.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/OMS/Update_rule_OMS_inter.hpp\"\n@@ -292,6 +293,31 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\n}\n}\n#endif\n+#ifdef __cpp_aligned_new\n+ else if (this->type == \"BP_VERTICAL_LAYERED\" && this->simd_strategy == \"INTER\")\n+ {\n+ if (this->implem == \"MS\" ) return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_MS_inter <Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_MS_inter <Q>( ), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"OMS\") return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_OMS_inter<Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_OMS_inter<Q>(this->offset), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"NMS\")\n+ {\n+ if (typeid(Q) == typeid(int16_t) || typeid(Q) == typeid(int8_t))\n+ {\n+ if (this->norm_factor == 0.125f) return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,1>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,1>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.250f) return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,2>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,2>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.375f) return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,3>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,3>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.500f) return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,4>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,4>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.625f) return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,5>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,5>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.750f) return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,6>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,6>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 0.875f) return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,7>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,7>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->norm_factor == 1.000f) return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q,8>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q,8>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else\n+ return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ }\n+ else\n+ return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_NMS_inter<Q>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_NMS_inter<Q>(this->norm_factor), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ }\n+ }\n+#endif\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered_inter.hpp", "diff": "+#ifndef DECODER_LDPC_BP_VERTICAL_LAYERED_INTER_HPP_\n+#define DECODER_LDPC_BP_VERTICAL_LAYERED_INTER_HPP_\n+\n+#include <mipp.h>\n+\n+#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n+#include \"Tools/Code/LDPC/Update_rule/NMS/Update_rule_NMS_inter.hpp\"\n+\n+#include \"../../../Decoder_SISO_SIHO.hpp\"\n+#include \"../Decoder_LDPC_BP.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int, typename R = float, class Update_rule = tools::Update_rule_NMS_inter<R>>\n+class Decoder_LDPC_BP_vertical_layered_inter : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n+{\n+protected:\n+ const std::vector<unsigned> &info_bits_pos;\n+\n+ Update_rule up_rule;\n+\n+ const R sat_val;\n+\n+ // data structures for iterative decoding\n+ std::vector<mipp::vector<mipp::Reg<R>>> var_nodes;\n+ std::vector<mipp::vector<mipp::Reg<R>>> messages;\n+\n+ mipp::vector<mipp::Reg<R>> contributions;\n+ std::vector<uint32_t > messages_offsets;\n+ mipp::vector<mipp::Reg<R>> Y_N_reorderered;\n+ mipp::vector<mipp::Reg<B>> V_reorderered;\n+\n+ bool init_flag;\n+\n+public:\n+ Decoder_LDPC_BP_vertical_layered_inter(const int K, const int N, const int n_ite,\n+ const tools::Sparse_matrix &H,\n+ const std::vector<unsigned> &info_bits_pos,\n+ const Update_rule &up_rule,\n+ const bool enable_syndrome = true,\n+ const int syndrome_depth = 1,\n+ const int n_frames = 1);\n+ virtual ~Decoder_LDPC_BP_vertical_layered_inter();\n+ void reset();\n+\n+protected:\n+ void _decode_siso (const R *Y_N1, R *Y_N2, const int frame_id);\n+ void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n+ void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n+\n+ void _load (const R *Y_N, const int frame_id);\n+ void _decode (const int frame_id);\n+ void _decode_single_ite (mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &messages);\n+ bool _check_syndrome_soft(const mipp::vector<mipp::Reg<R>> &var_nodes);\n+};\n+}\n+}\n+\n+#include \"Decoder_LDPC_BP_vertical_layered_inter.hxx\"\n+\n+#endif /* DECODER_LDPC_BP_VERTICAL_LAYERED_INTER_HPP_ */\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Module/Decoder/LDPC/BP/Vertical_layered/Decoder_LDPC_BP_vertical_layered_inter.hxx", "diff": "+#include <limits>\n+#include <cmath>\n+#include <sstream>\n+#include <iostream>\n+\n+#include \"Tools/general_utils.h\"\n+#include \"Tools/Math/utils.h\"\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Perf/Reorderer/Reorderer.hpp\"\n+\n+#include \"../Horizontal_layered/Decoder_LDPC_BP_horizontal_layered_inter.hpp\"\n+\n+#include \"Decoder_LDPC_BP_vertical_layered_inter.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+template <typename B, typename R, class Update_rule>\n+Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::Decoder_LDPC_BP_vertical_layered_inter(const int K, const int N, const int n_ite,\n+ const tools::Sparse_matrix &_H,\n+ const std::vector<unsigned> &info_bits_pos,\n+ const Update_rule &up_rule,\n+ const bool enable_syndrome,\n+ const int syndrome_depth,\n+ const int n_frames)\n+: Decoder (K, N, n_frames, mipp::N<R>() ),\n+ Decoder_SISO_SIHO<B,R>(K, N, n_frames, mipp::N<R>() ),\n+ Decoder_LDPC_BP (K, N, n_ite, _H, enable_syndrome, syndrome_depth ),\n+ info_bits_pos (info_bits_pos ),\n+ up_rule (up_rule ),\n+ sat_val ((R)((1 << ((sizeof(R) * 8 -2) - (int)std::log2(this->H.get_rows_max_degree()))) -1)),\n+ var_nodes (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(N) ),\n+ messages (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(this->H.get_n_connections()) ),\n+ contributions (this->H.get_cols_max_degree() ),\n+ messages_offsets (this->H.get_n_cols() ),\n+ Y_N_reorderered (N ),\n+ V_reorderered (N ),\n+ init_flag (true )\n+{\n+ const std::string name = \"Decoder_LDPC_BP_vertical_layered_inter<\" + this->up_rule.get_name() + \">\";\n+ this->set_name(name);\n+\n+ if (this->sat_val <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'sat_val' has to be greater than 0 ('sat_val' = \" << this->sat_val << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ size_t cur_off_msg = 0;\n+ const auto n_chk_nodes = (int)this->H.get_n_cols();\n+ for (auto c = 0; c < n_chk_nodes; c++)\n+ {\n+ messages_offsets[c] = (uint32_t)cur_off_msg;\n+ cur_off_msg += this->H[c].size();\n+ }\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::~Decoder_LDPC_BP_vertical_layered_inter()\n+{\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::reset()\n+{\n+ this->init_flag = true;\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::_load(const R *Y_N, const int frame_id)\n+{\n+ const auto cur_wave = frame_id / this->simd_inter_frame_level;\n+\n+ // memory zones initialization\n+ if (this->init_flag)\n+ {\n+ const auto zero = mipp::Reg<R>((R)0);\n+ std::fill(this->messages [cur_wave].begin(), this->messages [cur_wave].end(), zero);\n+ std::fill(this->var_nodes[cur_wave].begin(), this->var_nodes[cur_wave].end(), zero);\n+\n+ if (cur_wave == this->n_dec_waves -1) this->init_flag = false;\n+ }\n+\n+ std::vector<const R*> frames(mipp::N<R>());\n+ for (auto f = 0; f < mipp::N<R>(); f++) frames[f] = Y_N + f * this->N;\n+ tools::Reorderer_static<R,mipp::N<R>()>::apply(frames, (R*)this->Y_N_reorderered.data(), this->N);\n+\n+ for (auto i = 0; i < (int)var_nodes[cur_wave].size(); i++)\n+ this->var_nodes[cur_wave][i] += this->Y_N_reorderered[i]; // var_nodes contain previous extrinsic information\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::_decode_siso(const R *Y_N1, R *Y_N2, const int frame_id)\n+{\n+ // memory zones initialization\n+ this->_load(Y_N1, frame_id);\n+\n+ this->_decode(frame_id);\n+\n+ // prepare for next round by processing extrinsic information\n+ const auto cur_wave = frame_id / this->simd_inter_frame_level;\n+ for (auto v = 0; v < this->N; v++)\n+ this->var_nodes[cur_wave][v] -= Y_N_reorderered[v];\n+\n+ std::vector<R*> frames(mipp::N<R>());\n+ for (auto f = 0; f < mipp::N<R>(); f++) frames[f] = Y_N2 + f * this->N;\n+ tools::Reorderer_static<R,mipp::N<R>()>::apply_rev((R*)this->var_nodes[cur_wave].data(), frames, this->N);\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n+{\n+// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n+ this->_load(Y_N, frame_id);\n+// auto d_load = std::chrono::steady_clock::now() - t_load;\n+\n+// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n+ this->_decode(frame_id);\n+// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n+\n+// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n+ // take the hard decision\n+ const auto cur_wave = frame_id / this->simd_inter_frame_level;\n+ for (auto v = 0; v < this->K; v++)\n+ {\n+ const auto k = this->info_bits_pos[v];\n+ V_reorderered[v] = mipp::cast<R,B>(this->var_nodes[cur_wave][k]) >> (sizeof(B) * 8 - 1);\n+ }\n+\n+ std::vector<B*> frames(mipp::N<R>());\n+ for (auto f = 0; f < mipp::N<R>(); f++) frames[f] = V_K + f * this->K;\n+ tools::Reorderer_static<B,mipp::N<R>()>::apply_rev((B*)V_reorderered.data(), frames, this->K);\n+// auto d_store = std::chrono::steady_clock::now() - t_store;\n+\n+// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::load, d_load);\n+// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::decode, d_decod);\n+// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::store, d_store);\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n+{\n+// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n+ this->_load(Y_N, frame_id);\n+// auto d_load = std::chrono::steady_clock::now() - t_load;\n+\n+// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n+ this->_decode(frame_id);\n+// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n+\n+// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n+ // take the hard decision\n+ const auto cur_wave = frame_id / this->simd_inter_frame_level;\n+ for (auto v = 0; v < this->N; v++)\n+ V_reorderered[v] = mipp::cast<R,B>(this->var_nodes[cur_wave][v]) >> (sizeof(B) * 8 - 1);\n+\n+ std::vector<B*> frames(mipp::N<R>());\n+ for (auto f = 0; f < mipp::N<R>(); f++) frames[f] = V_N + f * this->N;\n+ tools::Reorderer_static<B,mipp::N<R>()>::apply_rev((B*)V_reorderered.data(), frames, this->N);\n+// auto d_store = std::chrono::steady_clock::now() - t_store;\n+\n+// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::load, d_load);\n+// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::decode, d_decod);\n+// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::store, d_store);\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::_decode(const int frame_id)\n+{\n+ const auto cur_wave = frame_id / this->simd_inter_frame_level;\n+\n+ this->up_rule.begin_decoding(this->n_ite);\n+\n+ for (auto ite = 0; ite < this->n_ite; ite++)\n+ {\n+ this->up_rule.begin_ite(ite);\n+ this->_decode_single_ite(this->var_nodes[cur_wave], this->messages[cur_wave]);\n+ this->up_rule.end_ite();\n+\n+ if (this->_check_syndrome_soft(this->var_nodes[cur_wave]))\n+ break;\n+ }\n+\n+ this->up_rule.end_decoding();\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::_decode_single_ite(mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &messages)\n+{\n+ // vertical layered scheduling\n+ const auto n_var_nodes = (int)this->H.get_n_rows();\n+ for (auto vv = 0; vv < n_var_nodes; vv++)\n+ {\n+ auto msg_acc = mipp::Reg<R>((R)0);\n+ const auto var_degree = (int)this->H.get_cols_from_row(vv).size();\n+ for (auto c = 0; c < var_degree; c++)\n+ {\n+ auto v_out = -1;\n+ const auto cc = (int)this->H.get_cols_from_row(vv)[c];\n+ const auto off_msg = (int)this->messages_offsets[cc];\n+ const auto chk_degree = (int)this->H[cc].size();\n+ this->up_rule.begin_chk_node_in(cc, chk_degree);\n+ for (auto v = 0; v < chk_degree; v++)\n+ {\n+ const auto var_id = this->H[cc][v];\n+ v_out = (var_id == (unsigned)vv) ? v : v_out;\n+ contributions[v] = var_nodes[var_id] - messages[off_msg +v];\n+ this->up_rule.compute_chk_node_in(v, contributions[v]);\n+ }\n+ this->up_rule.end_chk_node_in();\n+\n+ msg_acc -= messages[off_msg + v_out];\n+ this->up_rule.begin_chk_node_out(cc, chk_degree);\n+ messages[off_msg + v_out] = this->up_rule.compute_chk_node_out(v_out, contributions[v_out]);\n+ this->up_rule.end_chk_node_out();\n+ msg_acc += messages[off_msg + v_out];\n+ }\n+ var_nodes[vv] += msg_acc;\n+ }\n+}\n+\n+template <typename B, typename R, class Update_rule>\n+bool Decoder_LDPC_BP_vertical_layered_inter<B,R,Update_rule>\n+::_check_syndrome_soft(const mipp::vector<mipp::Reg<R>> &var_nodes)\n+{\n+ if (this->enable_syndrome)\n+ {\n+ const auto zero = mipp::Msk<mipp::N<B>()>(false);\n+ auto syndrome = zero;\n+\n+ auto n_chk_nodes = (int)H.get_n_cols();\n+ auto c = 0;\n+ auto syndrome_scalar = true;\n+ while (c < n_chk_nodes && (syndrome_scalar = mipp::testz(syndrome)))\n+ {\n+ auto sign = zero;\n+ const auto chk_degree = (int)this->H[c].size();\n+ for (auto v = 0; v < chk_degree; v++)\n+ {\n+ const auto value = var_nodes[this->H[c][v]];\n+ sign ^= mipp::sign(value);\n+ }\n+\n+ syndrome |= sign;\n+ c++;\n+ }\n+\n+ this->cur_syndrome_depth = syndrome_scalar ? (this->cur_syndrome_depth +1) % this->syndrome_depth : 0;\n+ return syndrome_scalar && (this->cur_syndrome_depth == 0);\n+ }\n+ else\n+ return false;\n+}\n+\n+}\n+}\n\\ No newline at end of file\n" } ]
C++
MIT License
aff3ct/aff3ct
Add LDPC vertical layered scheduler with inter SIMD.
8,483
06.07.2018 11:05:12
-7,200
d80279994478e3248e48ae2115d33ec067a74b91
Make the TPC works with inter frame level
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "new_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "diff": "@@ -187,7 +187,7 @@ void Decoder_turbo_product::parameters\n}\n- this->sub->n_frames = this->n_frames;\n+ // this->sub->n_frames = this->n_frames;\nsub->store(vals);\n@@ -266,7 +266,7 @@ module::Decoder_SIHO<B,Q>* Decoder_turbo_product::parameters\nif (this->type == \"CP\")\n{\nif (this->implem == \"STD\")\n- return new module::Decoder_turbo_product<B,Q>(n_ite, alpha, itl, cp_r, cp_c);\n+ return new module::Decoder_turbo_product<B,Q>(n_ite, alpha, itl, cp_r, cp_c, n_frames);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Encoder/Turbo_product/Encoder_turbo_product.cpp", "new_path": "src/Factory/Module/Encoder/Turbo_product/Encoder_turbo_product.cpp", "diff": "@@ -105,7 +105,7 @@ void Encoder_turbo_product::parameters\nif(vals.exist({p+\"-ext\"})) this->parity_extended = true;\n- this->sub->n_frames = this->n_frames;\n+ // this->sub->n_frames = this->n_frames;\nsub->store(vals);\n@@ -147,7 +147,7 @@ module::Encoder_turbo_product<B>* Encoder_turbo_product::parameters\nmodule::Encoder_BCH<B> &enc_r,\nmodule::Encoder_BCH<B> &enc_c) const\n{\n- if (this->type == \"TURBO_PROD\") return new module::Encoder_turbo_product<B>(itl, enc_r, enc_c);\n+ if (this->type == \"TURBO_PROD\") return new module::Encoder_turbo_product<B>(itl, enc_r, enc_c, n_frames);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Launcher/Code/Turbo_product/Turbo_product.cpp", "new_path": "src/Launcher/Code/Turbo_product/Turbo_product.cpp", "diff": "@@ -40,7 +40,7 @@ void Turbo_product<L,B,R,Q>\nauto psrc = this->params.src->get_prefix();\nthis->args.erase({psrc+\"-info-bits\", \"K\"});\n- this->args.erase({psrc+\"-fra\", \"F\"});\n+ // this->args.erase({psrc+\"-fra\", \"F\"});\n}\ntemplate <class L, typename B, typename R, typename Q>\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Codec/Turbo_product/Codec_turbo_product.cpp", "new_path": "src/Module/Codec/Turbo_product/Codec_turbo_product.cpp", "diff": "@@ -51,19 +51,19 @@ Codec_turbo_product<B,Q>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (enc_params.n_frames != 1)\n- {\n- std::stringstream message;\n- message << \"'enc_params.n_frames' has to be equal to 1 ('enc_params.n_frames' = \"\n- << enc_params.n_frames << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\nif (dec_params.sub->implem == \"GENIUS\")\n{\nstd::stringstream message;\nmessage << \"sub decoder can't have a GENIUS implem (dec_params.sub->implem).\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+\n+ // if (enc_params.n_frames != 1)\n+ // {\n+ // std::stringstream message;\n+ // message << \"'enc_params.n_frames' has to be equal to 1 ('enc_params.n_frames' = \"\n+ // << enc_params.n_frames << \").\";\n+ // throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ // }\n}\n// ---------------------------------------------------------------------------------------------------- allocations\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "new_path": "src/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "diff": "@@ -19,9 +19,10 @@ Decoder_turbo_product<B,R>\nconst std::vector<float>& alpha,\nconst Interleaver<R>& pi,\nDecoder_chase_pyndiah<B,R> &cp_r,\n- Decoder_chase_pyndiah<B,R> &cp_c)\n-: Decoder (cp_r.get_K() * cp_c.get_K(), pi.get_core().get_size(), 1, 1),//cp_r.get_n_frames(), cp_r.get_simd_inter_frame_level()),\n- Decoder_SISO_SIHO<B,R>(cp_r.get_K() * cp_c.get_K(), pi.get_core().get_size(), 1, 1),//cp_r.get_n_frames(), cp_r.get_simd_inter_frame_level()),\n+ Decoder_chase_pyndiah<B,R> &cp_c,\n+ const int n_frames)\n+: Decoder (cp_r.get_K() * cp_c.get_K(), pi.get_core().get_size(), n_frames, 1),\n+ Decoder_SISO_SIHO<B,R>(cp_r.get_K() * cp_c.get_K(), pi.get_core().get_size(), n_frames, 1),\nn_ite(n_ite),\nalpha(alpha),\npi (pi ),\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Decoder_turbo_product.hpp", "new_path": "src/Module/Decoder/Turbo_product/Decoder_turbo_product.hpp", "diff": "@@ -37,7 +37,8 @@ public:\nconst std::vector<float>& alpha,\nconst Interleaver<R> &pi,\nDecoder_chase_pyndiah<B,R> &cp_r,\n- Decoder_chase_pyndiah<B,R> &cp_c);\n+ Decoder_chase_pyndiah<B,R> &cp_c,\n+ const int n_frames = 1);\nvirtual ~Decoder_turbo_product();\nprotected:\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Encoder/Turbo_product/Encoder_turbo_product.cpp", "new_path": "src/Module/Encoder/Turbo_product/Encoder_turbo_product.cpp", "diff": "@@ -12,8 +12,8 @@ using namespace aff3ct::module;\ntemplate <typename B>\nEncoder_turbo_product<B>\n-::Encoder_turbo_product(const Interleaver<B> &pi, Encoder<B> &enc_r, Encoder<B> &enc_c)\n-: Encoder<B>(enc_r.get_K() * enc_c.get_K(), pi.get_core().get_size(), 1), //enc_r.get_n_frames()),\n+::Encoder_turbo_product(const Interleaver<B> &pi, Encoder<B> &enc_r, Encoder<B> &enc_c, const int n_frames)\n+: Encoder<B>(enc_r.get_K() * enc_c.get_K(), pi.get_core().get_size(), n_frames),\npi (pi ),\nenc_r(enc_r),\nenc_c(enc_c),\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Encoder/Turbo_product/Encoder_turbo_product.hpp", "new_path": "src/Module/Encoder/Turbo_product/Encoder_turbo_product.hpp", "diff": "@@ -25,12 +25,13 @@ protected:\nstd::vector<B> X_N_i; // internal buffer in the interleaved domain\npublic:\n- Encoder_turbo_product(const Interleaver<B> &pi, Encoder<B> &enc_r, Encoder<B> &enc_c);\n+ Encoder_turbo_product(const Interleaver<B> &pi, Encoder<B> &enc_r, Encoder<B> &enc_c, const int n_frames = 1);\nvirtual ~Encoder_turbo_product() {}\nvirtual void _encode(const B *U_K, B *X_N, const int frame_id); using Encoder<B>::encode;\n- /* to use with a GENIUS BCH decoder\n+ /* to use with a GENIUS BCH decoder to save data in the sub encoders : will work only with a inter frame level of 1\n+ else data is overwritten by the following frames\nprivate :\n// access to enc_r protected/private members thanks to this robber\n" } ]
C++
MIT License
aff3ct/aff3ct
Make the TPC works with inter frame level
8,483
06.07.2018 11:09:52
-7,200
faa569fb01c633e7156db34db1bedb01dd38c51f
Fix the 'has a constructor with 1 argument that is not explicit' warning
[ { "change_type": "MODIFY", "old_path": "src/Tools/Math/Galois.hpp", "new_path": "src/Tools/Math/Galois.hpp", "diff": "@@ -18,7 +18,7 @@ protected:\nstd::vector<int> p; // coefficients of a primitive polynomial used to generate GF(2**m)\npublic:\n- Galois(const int& N);\n+ explicit Galois(const int& N);\nvirtual ~Galois();\nint get_N() const;\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Noise/Event_probability.hpp", "new_path": "src/Tools/Noise/Event_probability.hpp", "diff": "@@ -15,7 +15,7 @@ public:\nEvent_probability() = default;\nexplicit Event_probability(R noise);\ntemplate<typename T>\n- Event_probability(const Event_probability<T>& other);\n+ explicit Event_probability(const Event_probability<T>& other);\nvirtual ~Event_probability() = default;\nvirtual std::string get_unity() const;\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Noise/Noise.hpp", "new_path": "src/Tools/Noise/Noise.hpp", "diff": "@@ -22,7 +22,7 @@ public:\nNoise();\nexplicit Noise(R noise);\ntemplate<typename T>\n- Noise(const Noise<T>& other);\n+ explicit Noise(const Noise<T>& other);\nvirtual ~Noise() = default;\nvirtual bool is_set() const noexcept; // return true if the Noise object has been correctly initialized\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Noise/Received_optical_power.hpp", "new_path": "src/Tools/Noise/Received_optical_power.hpp", "diff": "@@ -15,7 +15,7 @@ public:\nReceived_optical_power() = default;\nexplicit Received_optical_power(R noise);\ntemplate<typename T>\n- Received_optical_power(const Received_optical_power<T>& other);\n+ explicit Received_optical_power(const Received_optical_power<T>& other);\nvirtual ~Received_optical_power() = default;\nvirtual std::string get_unity() const;\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Noise/Sigma.hpp", "new_path": "src/Tools/Noise/Sigma.hpp", "diff": "@@ -16,7 +16,7 @@ public:\nexplicit Sigma(R noise);\nSigma(R noise, R ebn0, R esn0);\ntemplate<typename T>\n- Sigma(const Sigma<T>& other);\n+ explicit Sigma(const Sigma<T>& other);\nvirtual ~Sigma() = default;\nvirtual bool is_set() const noexcept; // return true sigma, ebn0 and esn0 have been initialized\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the 'has a constructor with 1 argument that is not explicit' warning
8,483
06.07.2018 11:12:53
-7,200
bee45364721f5adcf277068e18e0d2aec9802d5c
Fix 'Clarify calculation precedence for '^' and '?'.' warning
[ { "change_type": "MODIFY", "old_path": "src/Tools/Perf/common/hamming_distance.cpp", "new_path": "src/Tools/Perf/common/hamming_distance.cpp", "diff": "@@ -23,7 +23,7 @@ inline size_t hamming_distance_seq_real(const B *in1, const B *in2, const unsign\nsize_t ham_dist = 0;\nfor (unsigned i = 0; i < size; i++)\n- ham_dist += std::signbit(in1[i]) ^ std::signbit(in2[i]) ? (size_t)1 : (size_t)0;\n+ ham_dist += (std::signbit(in1[i]) ^ std::signbit(in2[i])) ? (size_t)1 : (size_t)0;\nreturn ham_dist;\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix 'Clarify calculation precedence for '^' and '?'.' warning
8,483
06.07.2018 13:11:07
-7,200
21773c9f441c858aadf97db300ad5c0d134384fb
Fix the Frame trace when there are several lines.
[ { "change_type": "MODIFY", "old_path": "src/Module/Task.cpp", "new_path": "src/Module/Task.cpp", "diff": "#include <rang.hpp>\n-#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n-\n#include \"Module.hpp\"\n#include \"Socket.hpp\"\n#include \"Task.hpp\"\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": "#include <thread>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n#include \"Tools/Display/rang_format/rang_format.h\"\n#include \"Factory/Tools/Display/Terminal/BFER/Terminal_BFER.hpp\"\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": "#include <thread>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n#include \"Tools/Display/rang_format/rang_format.h\"\n#include \"Factory/Tools/Display/Terminal/BFER/Terminal_BFER.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Display/Frame_trace/Frame_trace.hpp", "new_path": "src/Tools/Display/Frame_trace/Frame_trace.hpp", "diff": "@@ -31,6 +31,7 @@ private:\nconst int n_bits; /*!< Number of bits to display per frame (if n_bits = 0, display all the bits of the frame). */\nconst int prec; /*!< Number of characters used to display the number if real vectors */\n+ const bool display_indexes = true;\npublic:\n/*!\n@@ -39,7 +40,7 @@ public:\n* \\param n_bits: number of bits to display per frame (if n_bits = 0, display all the bits of the frame).\n* \\param stream: stream to trace the frame(s).\n*/\n- Frame_trace(const int n_bits = 0, const int prec = 5, std::ostream &stream = std::cout)\n+ explicit Frame_trace(const int n_bits = 0, const int prec = 5, std::ostream &stream = std::cout)\n: stream(stream), n_bits(n_bits), prec(prec)\n{\n}\n@@ -52,12 +53,13 @@ public:\n}\n/*!\n- * \\brief Display a vector (= a frame) of bits.\n+ * \\brief Display a vector (= a frame) of bits (0 or 1).\n*\n* \\tparam D: type of the bits in the input vector.\n*\n* \\param vec: a vector to display.\n* \\param ref: a reference vector to compare with the other one (do not perform the comparison if ref is unset).\n+ * ref at 1 means a bit at 1 and ref at 0 means a bit at 0\n*/\ntemplate <typename D, class AD = std::allocator<D>, class AB = std::allocator<B>>\nvoid display_bit_vector(std::vector<D,AD> vec, std::vector<B,AB> ref = {});\n@@ -65,22 +67,24 @@ public:\n/*!\n* \\brief Display a vector (= a frame) of reals.\n*\n- * \\tparam D: type of the bits in the input vector.\n+ * \\tparam D: type of the values in the input vector.\n*\n* \\param vec: a vector to display.\n* \\param ref: a reference vector to compare with the other one (do not perform the comparison if ref is unset).\n+ * ref at 1 means a negative value and ref at 0 means a positive value\n*/\ntemplate <typename D, class AD = std::allocator<D>, class AB = std::allocator<B>>\nvoid display_real_vector(std::vector<D,AD> vec, std::vector<B,AB> ref = {});\n/*!\n- * \\brief Display a vector (= a frame) of bits in 2D.\n+ * \\brief Display a vector (= a frame) of bits (0 or 1) in 2D.\n*\n* \\tparam D: type of the bits in the input vector.\n*\n* \\param vec: a vector to display.\n* \\param row_width: number of bits in a row (size of the x dimension).\n* \\param ref: a reference vector to compare with the other one (do not perform the comparison if ref is unset).\n+ * ref at 1 means a bit at 1 and ref at 0 means a bit at 0\n*/\ntemplate <typename D, class AD = std::allocator<D>, class AB = std::allocator<B>>\nvoid display_bit_vector(std::vector<D,AD> vec, unsigned int row_width, std::vector<B,AB> ref = {});\n@@ -88,11 +92,12 @@ public:\n/*!\n* \\brief Display a vector (= a frame) of reals in 2D.\n*\n- * \\tparam D: type of the bits in the input vector.\n+ * \\tparam D: type of the values in the input vector.\n*\n* \\param vec: a vector to display.\n- * \\param row_width: number of bits in a row (size of the x dimension).\n+ * \\param row_width: number of values in a row (size of the x dimension).\n* \\param ref: a reference vector to compare with the other one (do not perform the comparison if ref is unset).\n+ * ref at 1 means a negative value and ref at 0 means a positive value\n*/\ntemplate <typename D, class AD = std::allocator<D>, class AB = std::allocator<B>>\nvoid display_real_vector(std::vector<D,AD> vec, unsigned int row_width, std::vector<B,AB> ref = {});\n@@ -102,10 +107,7 @@ private:\nvoid display_vector(std::vector<D,AD> vec, unsigned int row_width, std::vector<B,AB> ref, debug_version version);\ntemplate <typename D>\n- void display_value (D value, debug_version version);\n-\n- template <typename D>\n- void display_value (D value, debug_version version, B ref);\n+ void display_value (D value, debug_version version, B ref = -1);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Display/Frame_trace/Frame_trace.hxx", "new_path": "src/Tools/Display/Frame_trace/Frame_trace.hxx", "diff": "@@ -48,7 +48,6 @@ template <typename D, class AD, class AB>\nvoid Frame_trace<B>\n::display_vector(std::vector<D,AD> vec, unsigned int row_width, std::vector<B,AB> ref, debug_version version)\n{\n- unsigned int stride = 0;\nbool enable_ref = !ref.empty();\nif (enable_ref && ref.size() != vec.size())\n@@ -67,19 +66,27 @@ void Frame_trace<B>\n}\nconst auto n_bits = this->n_bits ? (this->n_bits <= (int)vec.size() ? this->n_bits : (int)vec.size()) : (int)vec.size();\n- if (row_width == vec.size())\n+\n+ // display the bits indexes\n+ if (this->display_indexes)\n{\nfor (auto i = 0; i < n_bits; i++)\n- stream << std::setw(prec+2) << i << \"|\";\n+ stream << rang::style::bold << std::setw(prec+2) << i\n+ << rang::style::underline << \"|\"\n+ << rang::style::reset;\nif (n_bits < (int)vec.size())\nstream << \" ...\";\n+\nstream << std::endl;\n}\n+\n+ unsigned int stride = 0;\n+\nwhile (stride < vec.size())\n{\n- for (auto i = stride; (i < stride + n_bits) && i < vec.size(); i++)\n+ for (auto i = stride; (i < stride + row_width) && (i < stride + n_bits) && i < vec.size(); i++)\nif (enable_ref)\ndisplay_value(vec[i], version, ref[i]);\nelse\n@@ -87,6 +94,7 @@ void Frame_trace<B>\nif (n_bits < (int)vec.size())\nstream << \" ...\";\n+\nstream << std::endl;\nstride += row_width;\n@@ -96,75 +104,45 @@ void Frame_trace<B>\ntemplate <typename B>\ntemplate <typename D>\nvoid Frame_trace<B>\n-::display_value(D value, debug_version version)\n+::display_value(D value, debug_version version, B ref)\n{\n- std::stringstream sstream;\n- std::string value_string;\n+ if (ref != -1)\n+ stream << rang::style::bold;\nswitch(version)\n{\ncase debug_version::BIT:\n- stream << std::setw(prec+2) << ((value == 0) ? (int) 0 : (int) 1) << \"|\";\n- break;\n- case debug_version::REAL:\n- sstream << std::setprecision(prec) << std::setw(prec+2) << value;\n- value_string = sstream.str();\n- size_t pos = value_string.find('e');\n- if (pos != std::string::npos) // then scientific notation has been used (too big number)\n- value_string = value_string.substr(0, prec-2) + value_string.substr(pos);\n- else\n- value_string = value_string.substr(0, prec+2);\n+ if (ref != -1)\n+ stream << ( ((value == 0) != (ref == 0)) ? rang::fg::red : rang::fg::green);\n+ stream << std::setw(prec+2) << ((value == 0) ? (int) 0 : (int) 1);\n- stream << value_string << \"|\";\nbreak;\n- }\n-}\n-template <typename B>\n-template <typename D>\n-void Frame_trace<B>\n-::display_value(D value, debug_version version, B ref)\n+ case debug_version::REAL:\n{\nstd::stringstream sstream;\n- std::string value_string;\n+ sstream << std::setprecision(prec) << std::setw(prec+2) << +value;\n- switch(version)\n- {\n- case debug_version::BIT:\n- value_string.append(prec+1, ' ');\n- if (value == 0)\n- if (ref == 0)\n- stream << rang::style::bold << rang::fg::green << value_string << \"0\" << rang::style::reset << \"|\";\n- else\n- stream << rang::style::bold << rang::fg::red << value_string << \"0\" << rang::style::reset << \"|\";\n- else\n- if (ref == 0)\n- stream << rang::style::bold << rang::fg::red << value_string << \"1\" << rang::style::reset << \"|\";\n- else\n- stream << rang::style::bold << rang::fg::green << value_string << \"1\" << rang::style::reset << \"|\";\n- break;\n+ auto value_string = sstream.str();\n- case debug_version::REAL:\n- sstream << std::setprecision(prec) << std::setw(prec+2) << value;\n- value_string = sstream.str();\n- size_t pos = value_string.find('e');\n+ auto pos = value_string.find('e');\nif (pos != std::string::npos) // then scientific notation has been used (too big number)\nvalue_string = value_string.substr(0, prec-2) + value_string.substr(pos);\nelse\nvalue_string = value_string.substr(0, prec+2);\n- if (value >= 0)\n- if (ref == 0)\n- stream << rang::style::bold << rang::fg::green << value_string << rang::style::reset << \"|\";\n- else\n- stream << rang::style::bold << rang::fg::red << value_string << rang::style::reset << \"|\";\n- else\n- if (ref == 0)\n- stream << rang::style::bold << rang::fg::red << value_string << rang::style::reset << \"|\";\n- else\n- stream << rang::style::bold << rang::fg::green << value_string << rang::style::reset << \"|\";\n+ if (ref != -1)\n+ stream << ( ((value >= (D)0) != (ref == 0)) ? rang::fg::red : rang::fg::green);\n+ stream << value_string;\n+\nbreak;\n}\n}\n+\n+ if (ref != -1)\n+ stream << rang::style::reset;\n+\n+ stream << \"|\";\n+}\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the Frame trace when there are several lines.
8,483
06.07.2018 14:03:58
-7,200
36e1bd275f25dbfea68ba990e2341326060c1a6b
Fix compilation in simple precision
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.cpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.cpp", "diff": "@@ -503,6 +503,6 @@ template class aff3ct::module::Decoder_chase_pyndiah<B_16,Q_16>;\ntemplate class aff3ct::module::Decoder_chase_pyndiah<B_32,Q_32>;\ntemplate class aff3ct::module::Decoder_chase_pyndiah<B_64,Q_64>;\n#else\n-template class aff3ct::module::Decoder_chase_pyndiah<B,R>;\n+template class aff3ct::module::Decoder_chase_pyndiah<B,Q>;\n#endif\n// ==================================================================================== explicit template instantiation\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix compilation in simple precision
8,483
06.07.2018 17:25:59
-7,200
efd17c308a552bc0cc9e30267d3c2f52e9fa7f1c
Implement a fast decoder chase pyndiah with optimised with MIPP the compute metrics and reliability functions
[ { "change_type": "MODIFY", "old_path": "src/Module/Codec/Turbo_product/Codec_turbo_product.cpp", "new_path": "src/Module/Codec/Turbo_product/Codec_turbo_product.cpp", "diff": "@@ -93,14 +93,14 @@ Codec_turbo_product<B,Q>\ndec_bch_rows = dynamic_cast<Decoder_BCH<B,Q>*>(factory::Decoder_BCH::build_hiho<B,Q>(*dec_params.sub, GF_poly, enc_bch_rows));\ndec_bch_cols = dynamic_cast<Decoder_BCH<B,Q>*>(factory::Decoder_BCH::build_hiho<B,Q>(*dec_params.sub, GF_poly, enc_bch_cols));\n- cp_rows = new Decoder_chase_pyndiah<B,Q>(dec_bch_rows->get_K(), N_cw_p, N_cw_p,\n+ cp_rows = new Decoder_chase_pyndiah_fast<B,Q>(dec_bch_rows->get_K(), N_cw_p, N_cw_p,\n*dec_bch_rows, *enc_bch_rows,\ndec_params.n_least_reliable_positions,\ndec_params.n_test_vectors,\ndec_params.n_competitors,\ndec_params.cp_coef);\n- cp_cols = new Decoder_chase_pyndiah<B,Q>(dec_bch_cols->get_K(), N_cw_p, N_cw_p,\n+ cp_cols = new Decoder_chase_pyndiah_fast<B,Q>(dec_bch_cols->get_K(), N_cw_p, N_cw_p,\n*dec_bch_cols, *enc_bch_cols,\ndec_params.n_least_reliable_positions,\ndec_params.n_test_vectors,\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Codec/Turbo_product/Codec_turbo_product.hpp", "new_path": "src/Module/Codec/Turbo_product/Codec_turbo_product.hpp", "diff": "#include \"Module/Decoder/BCH/Decoder_BCH.hpp\"\n#include \"Module/Decoder/Decoder_SISO_SIHO.hpp\"\n#include \"Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp\"\n+#include \"Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.hpp\"\n#include \"Factory/Module/Encoder/Turbo_product/Encoder_turbo_product.hpp\"\n#include \"Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp", "diff": "@@ -76,7 +76,10 @@ public:\nconst int n_least_reliable_positions = 2,\nconst int n_test_vectors = 0,\nconst int n_competitors = 0,\n- const std::vector<float>& cp_coef = {1,1,1,1,0});\n+ const std::vector<float>& cp_coef = {1,1,1,1,0}); // the a b c d and e coef\n+\n+ ~Decoder_chase_pyndiah() = default;\n+\nvoid _decode_siso (const R *Y_N1, R *Y_N2, const int frame_id); // size is length with parity bit if any\nvoid _decode_siho (const R *Y_N, B *V_K , const int frame_id);\n@@ -85,11 +88,11 @@ public:\nconst std::vector<uint32_t>& get_info_bits_pos();\nprotected:\n- void decode_chase (const R *Y_N, const int frame_id);\n- void find_least_reliable_pos(const R* Y_N);\n- void compute_test_vectors ( const int frame_id);\n- void compute_metrics (const R* Y_N);\n- void compute_reliability (const R* Y_N1, R* Y_N2);\n+ virtual void decode_chase (const R *Y_N, const int frame_id);\n+ virtual void find_least_reliable_pos(const R* Y_N);\n+ virtual void compute_test_vectors ( const int frame_id);\n+ virtual void compute_metrics (const R* Y_N);\n+ virtual void compute_reliability (const R* Y_N1, R* Y_N2);\nvoid bit_flipping(B* hard_vect, const int c);\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.cpp", "diff": "+#include <iostream>\n+#include <sstream>\n+#include <algorithm>\n+#include <cmath>\n+\n+#include \"Decoder_chase_pyndiah_fast.hpp\"\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Perf/common/hard_decide.h\"\n+#include \"Tools/Perf/compute_parity.h\"\n+\n+\n+#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n+\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+#define NDEBUG\n+\n+template <typename B, typename R>\n+Decoder_chase_pyndiah_fast<B,R>\n+::Decoder_chase_pyndiah_fast(const int K, const int N, // N includes the parity bit if any\n+ const int n_frames,\n+ Decoder_BCH<B,R> &dec_,\n+ Encoder <B > &enc_,\n+ const int n_least_reliable_positions_,\n+ const int n_test_vectors_,\n+ const int n_competitors_,\n+ const std::vector<float>& cp_coef)\n+: Decoder(K, N, n_frames),\n+ Decoder_chase_pyndiah<B,R>(K, N, n_frames, dec_, enc_, n_least_reliable_positions_, n_test_vectors_, n_competitors_, cp_coef)\n+{\n+ const std::string name = \"Decoder_chase_pyndiah_fast\";\n+ this->set_name(name);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_chase_pyndiah_fast<B,R>\n+::compute_metrics(const R* Y_N)\n+{\n+ const auto N_loop_size = (this->N / mipp::nElReg<B>()) * mipp::nElReg<B>();\n+\n+\n+ std::fill(this->metrics.begin(), this->metrics.end(), (R)0);\n+\n+ this->n_good_competitors = 0;\n+ for (int c = 0; c < this->n_test_vectors; c++)\n+ {\n+ if (this->is_wrong[c])\n+ {\n+ this->metrics[c] = std::numeric_limits<R>::max()/2;\n+ continue;\n+ }\n+ this->n_good_competitors++;\n+\n+ mipp::Reg<R> r_metric = (R)0;\n+ const mipp::Reg<R> r_zero = (R)0;\n+ int tv_off = c * this->N;\n+\n+ for (auto i = 0; i < N_loop_size; i += mipp::nElReg<R>())\n+ {\n+ const mipp::Reg<R> r_yn = &Y_N[i];\n+ const mipp::Reg<B> r_yh = &this->hard_Y_N[i];\n+ const mipp::Reg<B> r_tv = &this->test_vect[tv_off + i];\n+\n+ r_metric += mipp::blend(mipp::abs(r_yn), r_zero, r_yh != r_tv);\n+ }\n+\n+ this->metrics[c] = mipp::hadd(r_metric);\n+\n+ for (int i = N_loop_size; i < this->N; i++)\n+ if (this->hard_Y_N[i] ^ this->test_vect[tv_off + i])\n+ this->metrics[c] += std::abs(Y_N[i]);\n+ }\n+\n+ // reorder this->metrics -> decided word is at first position of this->competitors list\n+ for (int c = 0; c < this->n_test_vectors; c++)\n+ {\n+ this->competitors[c].metric = this->metrics[c];\n+ this->competitors[c].pos = c*this->N;\n+ }\n+\n+ std::sort(this->competitors.begin(), this->competitors.end(), [](const typename Decoder_chase_pyndiah<B,R>::info& a, const typename Decoder_chase_pyndiah<B,R>::info& b) { return a.metric < b.metric; });\n+}\n+\n+template <typename B, typename R>\n+void Decoder_chase_pyndiah_fast<B,R>\n+::compute_reliability(const R* Y_N1, R* Y_N2)\n+{\n+ const auto & DW = this->competitors.front(); // the Decided Word\n+\n+ // compute beta, the sum of the least reliable position reliabilities in the decided word\n+ R beta = 0;\n+ int max_sum = this->cp_coef[4] ? std::min((int)this->cp_coef[4], this->n_least_reliable_positions) : this->n_least_reliable_positions;\n+ for (int i = 0; i < max_sum; i++)\n+ beta += this->least_reliable_pos[i].metric;\n+\n+ beta -= this->cp_coef[2] * DW.metric;\n+\n+ this->n_good_competitors = std::min(this->n_good_competitors, this->n_competitors); // if there is less than 'this->n_competitors' good this->competitors\n+ // then take only them for reliability calculation\n+\n+ for (int j = 1; j < this->n_good_competitors; j++)\n+ this->competitors[j].metric = (this->competitors[j].metric - DW.metric) * this->cp_coef[1];\n+\n+\n+\n+ const auto N_loop_size = (this->N / mipp::nElReg<B>()) * mipp::nElReg<B>();\n+ const mipp::Reg<R> r_zero = (R)0;\n+\n+ for (auto i = 0; i < N_loop_size; i += mipp::nElReg<R>())\n+ {\n+ const mipp::Reg<B> r_DB = &this->test_vect[DW.pos + i];\n+ const mipp::Reg<R> r_Y1 = &Y_N1[i];\n+\n+ mipp::Reg<R> r_reliability = mipp::abs(r_Y1) * this->cp_coef[3] + beta; // reliability when no competitor with different bit\n+ r_reliability = mipp::blend(r_zero, r_reliability, r_reliability < (R)0);\n+\n+\n+ for (B j = this->n_good_competitors -1; j > 0; j--) // j = 0 == DW\n+ {\n+ const mipp::Reg<B> r_comp_bit = &this->test_vect[this->competitors[j].pos + i];\n+ const mipp::Reg<R> r_comp_met = this->competitors[j].metric;\n+\n+ r_reliability = mipp::blend(r_reliability, r_comp_met, r_comp_bit == r_DB);\n+ }\n+\n+ r_reliability = mipp::neg(r_reliability, r_DB != (B)0);\n+ r_reliability -= r_Y1 * this->cp_coef[0];\n+\n+ r_reliability.store(&Y_N2[i]);\n+ }\n+\n+ for (int i = N_loop_size; i < this->N; i++)\n+ {\n+ const auto DB = this->test_vect[DW.pos + i]; // decided bit at the position i\n+\n+ int j = 1;\n+ for (; j < this->n_good_competitors; j++)\n+ if (this->test_vect[this->competitors[j].pos + i] != DB)\n+ break;\n+\n+ R reliability;\n+\n+ if (j < this->n_good_competitors) // then the competitor j has a different bit at the position i\n+ {\n+ reliability = this->competitors[j].metric;\n+ }\n+ else // same bits for each candidates\n+ {\n+ reliability = beta + this->cp_coef[3] * std::abs(Y_N1[i]);\n+ if (reliability < 0)\n+ reliability = 0;\n+ }\n+\n+ if (DB) // if DB is a 1\n+ reliability = -reliability; // set as negative\n+\n+ Y_N2[i] = reliability - this->cp_coef[0] * Y_N1[i];\n+ }\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::module::Decoder_chase_pyndiah_fast<B_8,Q_8>;\n+template class aff3ct::module::Decoder_chase_pyndiah_fast<B_16,Q_16>;\n+template class aff3ct::module::Decoder_chase_pyndiah_fast<B_32,Q_32>;\n+template class aff3ct::module::Decoder_chase_pyndiah_fast<B_64,Q_64>;\n+#else\n+template class aff3ct::module::Decoder_chase_pyndiah_fast<B,Q>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.hpp", "diff": "+#ifndef Decoder_chase_pyndiah_fast_HPP_\n+#define Decoder_chase_pyndiah_fast_HPP_\n+\n+#include <aff3ct.hpp>\n+#include <vector>\n+#include <cassert>\n+#include <chrono>\n+\n+// #include \"../Decoder_turbo_product.hpp\"\n+#include \"../../Decoder_SISO_SIHO.hpp\"\n+\n+#include \"Decoder_chase_pyndiah.hpp\"\n+\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+/*\n+ * Chase :\n+ * - take hard decision H on input R\n+ * - create test vectors from test patterns after selecting the p least reliable positions -> give a p metric set Pm\n+ * - hard decode with the HIHO decoder -> get the competitors C -> remove competitors that have not been corrected\n+ * - compute the metrics Cm: euclidean distance of each competitor m compared to H\n+ * - select the competitor with the smallest metric Dm -> get the decided word D\n+ * - if SIHO, return D, if SISO, compute reliabilities of each bit of D -> Pyndiah\n+ * Pyndiah :\n+ * - Compute extrinsic W as\n+ * W = F - a * R\n+ * - Compute the reliability F of D as, for each bit j of the word:\n+ * Fj = Dj * [Cm - Dm] * b when Cj /= Dj in the competitor with the smallest metric Cm\n+ * = Dj * [beta - c * Dm + d * |Rj|] when there is no such competitor as described above\n+ * with Dj = 1 when Hj = 0\n+ * = -1 when Hj = 1\n+ * with beta = sum from 0 to e of the Pm where 0 <= e < p\n+\n+ * - a, b, c, d and e are simulation constants changeable by the user\n+ */\n+\n+template <typename B = int, typename R = float>\n+class Decoder_chase_pyndiah_fast : public Decoder_chase_pyndiah<B,R>\n+{\n+ static_assert(mipp::nElReg<B>() == mipp::nElReg<R>(), \"Type 'R' and 'B' have to be of the same size.\");\n+\n+public:\n+ Decoder_chase_pyndiah_fast(const int K, const int N, // N with the parity bit if any\n+ const int n_frames,\n+ Decoder_BCH<B,R> &dec,\n+ Encoder <B > &enc,\n+ const int n_least_reliable_positions = 2,\n+ const int n_test_vectors = 0,\n+ const int n_competitors = 0,\n+ const std::vector<float>& cp_coef = {1,1,1,1,0}); // the a b c d and e coef\n+\n+ ~Decoder_chase_pyndiah_fast() = default;\n+\n+protected:\n+ virtual void compute_metrics (const R* Y_N);\n+ virtual void compute_reliability(const R* Y_N1, R* Y_N2);\n+};\n+\n+}\n+}\n+\n+#endif /* Decoder_chase_pyndiah_fast_HPP_ */\n\\ No newline at end of file\n" } ]
C++
MIT License
aff3ct/aff3ct
Implement a fast decoder chase pyndiah with optimised with MIPP the compute metrics and reliability functions
8,483
09.07.2018 10:11:33
-7,200
c6cb13378ed2e9ed9ad3f2bd0f2bb15bf5deb536
Cosmetics; Fix include wrong headers; Fix g++4.x compilation errors
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "new_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/general_utils.h\"\n+#include \"Tools/Arguments/Splitter/Splitter.hpp\"\n#include \"Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp\"\n#include \"Module/Decoder/Turbo_product/Decoder_turbo_product.hpp\"\n@@ -75,7 +76,7 @@ struct Real_splitter\nconst std::string queue = \"})]\";\nconst std::string separator = \",\";\n- return Splitter::split(val, head, queue, separator);\n+ return tools::Splitter::split(val, head, queue, separator);\n}\n};\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.cpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.cpp", "diff": "#include \"Tools/Perf/compute_parity.h\"\n-#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n-\n-\nusing namespace aff3ct;\nusing namespace aff3ct::module;\n-#define NDEBUG\n+#define NDEBUG_TPC\n+\n+#ifndef NDEBUG_TPC\n+#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n+#endif\n+\ntemplate <typename B, typename R>\nDecoder_chase_pyndiah<B,R>\n@@ -141,7 +143,7 @@ void Decoder_chase_pyndiah<B,R>\ncompute_reliability(Y_N1, Y_N2);\n-#ifndef NDEBUG\n+#ifndef NDEBUG_TPC\nstd::cerr << \"(II) Y_N2 : \" << std::endl;\nfor (int i = 0; i < this->N; i++)\n@@ -156,7 +158,7 @@ void Decoder_chase_pyndiah<B,R>\n{\ntools::hard_decide(Y_N, hard_Y_N.data(), this->N);\n-#ifndef NDEBUG\n+#ifndef NDEBUG_TPC\ntools::Frame_trace<> ft(0,3,std::cerr);\nstd::cerr << \"(II) Y_N : \" << std::endl;\n@@ -189,7 +191,7 @@ void Decoder_chase_pyndiah<B,R>\ncompute_test_vectors (frame_id); // make bit flipping of least reliable positions and try to decode them\ncompute_metrics (Y_N); // compute euclidian metrics for each test vectors\n-#ifndef NDEBUG\n+#ifndef NDEBUG_TPC\nstd::cerr << \"(II) least_reliable_pos : \" << std::endl;\nfor (unsigned i = 0; i < least_reliable_pos.size(); i++)\n{\n@@ -270,7 +272,7 @@ void Decoder_chase_pyndiah<B,R>\nif (this->parity_extended)\ntest_vect[(c+1)*this->N -1] = tools::compute_parity(test_vect.data() + c*this->N, N_np);\n-#ifndef NDEBUG\n+#ifndef NDEBUG_TPC\ntools::Frame_trace<> ft(0,3,std::cerr);\nstd::cerr << \"(II) Test vectors \" << c << \" before correction\" << std::endl;\nft.display_bit_vector(hard_Y_N);\n@@ -341,7 +343,7 @@ void Decoder_chase_pyndiah<B,R>\n// competitors.resize(n_test_vectors);\n-#ifndef NDEBUG\n+#ifndef NDEBUG_TPC\nstd::cerr << \"(II) competitors : \" << std::endl;\nfor (unsigned i = 0; i < competitors.size(); i++)\n{\n@@ -365,7 +367,7 @@ void Decoder_chase_pyndiah<B,R>\nbeta -= cp_coef[2] * DW.metric;\n-#ifndef NDEBUG\n+#ifndef NDEBUG_TPC\nstd::cerr << \"beta = \" << beta << \", DW.metric = \" << DW.metric << std::endl;\n#endif\n@@ -401,13 +403,13 @@ void Decoder_chase_pyndiah<B,R>\nif (DB) // if DB is a 1\nreliability = -reliability; // set as negative\n-#ifndef NDEBUG\n+#ifndef NDEBUG_TPC\nstd::cerr << \"Rel: i = \" << i << \", Y_N1 = \" << Y_N1[i] << \", competitors[\" << j << \"].metric = \" << competitors[j].metric;\n#endif\nY_N2[i] = reliability - cp_coef[0] * Y_N1[i];\n-#ifndef NDEBUG\n+#ifndef NDEBUG_TPC\nstd::cerr << \", reliability = \" << reliability << \", Y_N2 = \" << Y_N2[i] << std::endl;\n#endif\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp", "diff": "#ifndef DECODER_CHASE_PYNDIAH_HPP_\n#define DECODER_CHASE_PYNDIAH_HPP_\n-#include <aff3ct.hpp>\n#include <vector>\n-#include <chrono>\n-\n-// #include \"../Decoder_turbo_product.hpp\"\n#include \"../../Decoder_SISO_SIHO.hpp\"\n+#include \"Module/Decoder/BCH/Decoder_BCH.hpp\"\n+#include \"Module/Encoder/Encoder.hpp\"\n+\n+\nnamespace aff3ct\n{\n@@ -38,14 +38,20 @@ namespace module\ntemplate <typename B = int, typename R = float>\nclass Decoder_chase_pyndiah : public Decoder_SISO_SIHO<B,R>\n{\n+// Test for GCC > 5.1.0\n+// Compilation error under when struct 'info' is protected\n+#if GCC_VERSION >= 50100\nprotected:\n-\n+#else\n+public:\n+#endif\nstruct info\n{\nR metric;\nint pos;\n};\n+protected:\nDecoder_BCH<B,R> &dec;\nEncoder <B > &enc;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.cpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.cpp", "diff": "#include \"Tools/Perf/compute_parity.h\"\n-#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n-\n-\nusing namespace aff3ct;\nusing namespace aff3ct::module;\n-#define NDEBUG\ntemplate <typename B, typename R>\nDecoder_chase_pyndiah_fast<B,R>\n@@ -81,7 +77,9 @@ void Decoder_chase_pyndiah_fast<B,R>\nthis->competitors[c].pos = c*this->N;\n}\n- std::sort(this->competitors.begin(), this->competitors.end(), [](const typename Decoder_chase_pyndiah<B,R>::info& a, const typename Decoder_chase_pyndiah<B,R>::info& b) { return a.metric < b.metric; });\n+ std::sort(this->competitors.begin(), this->competitors.end(),\n+ [](const typename Decoder_chase_pyndiah<B,R>::info& a,\n+ const typename Decoder_chase_pyndiah<B,R>::info& b) { return a.metric < b.metric; });\n}\ntemplate <typename B, typename R>\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.hpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.hpp", "diff": "#ifndef Decoder_chase_pyndiah_fast_HPP_\n#define Decoder_chase_pyndiah_fast_HPP_\n-#include <aff3ct.hpp>\n-#include <vector>\n-#include <cassert>\n-#include <chrono>\n-\n-// #include \"../Decoder_turbo_product.hpp\"\n-#include \"../../Decoder_SISO_SIHO.hpp\"\n#include \"Decoder_chase_pyndiah.hpp\"\n" } ]
C++
MIT License
aff3ct/aff3ct
Cosmetics; Fix include wrong headers; Fix g++4.x compilation errors
8,483
09.07.2018 10:19:34
-7,200
df42019e1b5412958bbb5ff226168f2a3572c4b5
Add Turbo prod in regression tests
[ { "change_type": "MODIFY", "old_path": ".gitlab-ci.yml", "new_path": ".gitlab-ci.yml", "diff": "@@ -360,6 +360,27 @@ test-regression-polar:\n- source ./ci/tools/threads.sh\n- ./ci/test-regression.py --refs-path refs/POLAR --results-path test-regression-results-polar --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n+test-regression-turbo-prod:\n+ stage: test\n+ retry: 1\n+ dependencies:\n+ - build-linux-gcc-x64-sse4.2\n+ tags:\n+ - linux\n+ - x86\n+ - 64-bit\n+ - sse4.2\n+ - powerful\n+ - python\n+ artifacts:\n+ name: test-regression-results-turbo-prod\n+ when: always\n+ paths:\n+ - test-regression-results-turbo-prod/\n+ script:\n+ - source ./ci/tools/threads.sh\n+ - ./ci/test-regression.py --refs-path refs/TURBO_PROD --results-path test-regression-results-turbo-prod --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n+\ntest-regression-turbo:\nstage: test\nretry: 1\n" }, { "change_type": "MODIFY", "old_path": "refs", "new_path": "refs", "diff": "-Subproject commit 469011d822b76011af54658917f0d972e16f1a4a\n+Subproject commit 630f71f832bce1955caaef825355b765a4557df0\n" } ]
C++
MIT License
aff3ct/aff3ct
Add Turbo prod in regression tests
8,483
09.07.2018 11:04:49
-7,200
89c7d08866f7b93dbb46a4e0816dca41cbd327f1
Fix poncturer LDPC pattern display
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Puncturer/LDPC/Puncturer_LDPC.cpp", "new_path": "src/Factory/Module/Puncturer/LDPC/Puncturer_LDPC.cpp", "diff": "+#include <sstream>\n+\n#include \"Tools/general_utils.h\"\n#include \"Tools/Exception/exception.hpp\"\n@@ -106,7 +108,11 @@ void Puncturer_LDPC::parameters\nif (this->type != \"NO\")\n{\n- headers[p].push_back(std::make_pair(std::string(\"Pattern\"), std::string(\"{\" + std::string(this->pattern.begin(),this->pattern.end())) + \"}\"));\n+ std::stringstream pat;\n+ for(auto p : this->pattern)\n+ pat << p;\n+\n+ headers[p].push_back(std::make_pair(std::string(\"Pattern\"), std::string(\"{\" + pat.str() + \"}\")));\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix poncturer LDPC pattern display
8,483
09.07.2018 11:29:12
-7,200
12f10b60e8d066843879d4d0e88bc2540a161977
Increase the regression test simulation time to 30 sec for Turbo prod
[ { "change_type": "MODIFY", "old_path": ".gitlab-ci.yml", "new_path": ".gitlab-ci.yml", "diff": "@@ -360,7 +360,7 @@ test-regression-polar:\n- source ./ci/tools/threads.sh\n- ./ci/test-regression.py --refs-path refs/POLAR --results-path test-regression-results-polar --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n-test-regression-turbo-prod:\n+test-regression-turbo:\nstage: test\nretry: 1\ndependencies:\n@@ -373,15 +373,15 @@ test-regression-turbo-prod:\n- powerful\n- python\nartifacts:\n- name: test-regression-results-turbo-prod\n+ name: test-regression-results-turbo\nwhen: always\npaths:\n- - test-regression-results-turbo-prod/\n+ - test-regression-results-turbo/\nscript:\n- source ./ci/tools/threads.sh\n- - ./ci/test-regression.py --refs-path refs/TURBO_PROD --results-path test-regression-results-turbo-prod --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n+ - ./ci/test-regression.py --refs-path refs/TURBO --results-path test-regression-results-turbo --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n-test-regression-turbo:\n+test-regression-turbo-db:\nstage: test\nretry: 1\ndependencies:\n@@ -394,15 +394,15 @@ test-regression-turbo:\n- powerful\n- python\nartifacts:\n- name: test-regression-results-turbo\n+ name: test-regression-results-turbo-db\nwhen: always\npaths:\n- - test-regression-results-turbo/\n+ - test-regression-results-turbo-db/\nscript:\n- source ./ci/tools/threads.sh\n- - ./ci/test-regression.py --refs-path refs/TURBO --results-path test-regression-results-turbo --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n+ - ./ci/test-regression.py --refs-path refs/TURBO_DB --results-path test-regression-results-turbo-db --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n-test-regression-turbo-db:\n+test-regression-turbo-prod:\nstage: test\nretry: 1\ndependencies:\n@@ -415,13 +415,13 @@ test-regression-turbo-db:\n- powerful\n- python\nartifacts:\n- name: test-regression-results-turbo-db\n+ name: test-regression-results-turbo-prod\nwhen: always\npaths:\n- - test-regression-results-turbo-db/\n+ - test-regression-results-turbo-prod/\nscript:\n- source ./ci/tools/threads.sh\n- - ./ci/test-regression.py --refs-path refs/TURBO_DB --results-path test-regression-results-turbo-db --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n+ - ./ci/test-regression.py --refs-path refs/TURBO_PROD --results-path test-regression-results-turbo-prod --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 30 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\ntest-regression-uncoded:\nstage: test\n" } ]
C++
MIT License
aff3ct/aff3ct
Increase the regression test simulation time to 30 sec for Turbo prod
8,483
10.07.2018 14:46:42
-7,200
4e32be0624ede7be2cf40398e52d1f873cb2be30
Fix the Factory::Codec cloning methods by setting correcly the cloned puncturers in the parent Codec
[ { "change_type": "MODIFY", "old_path": "refs", "new_path": "refs", "diff": "-Subproject commit 2e83d27d36a32742ce471d238ac6660d10247906\n+Subproject commit 630f71f832bce1955caaef825355b765a4557df0\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Codec/LDPC/Codec_LDPC.cpp", "new_path": "src/Factory/Module/Codec/LDPC/Codec_LDPC.cpp", "diff": "@@ -30,6 +30,7 @@ Codec_LDPC::parameters\nCodec::parameters::enc = nullptr;\nCodec::parameters::dec = nullptr;\n+ Codec::parameters::pct = nullptr;\n}\nCodec_LDPC::parameters* Codec_LDPC::parameters\n@@ -43,6 +44,7 @@ Codec_LDPC::parameters* Codec_LDPC::parameters\nclone->set_enc(clone->enc);\nclone->set_dec(clone->dec);\n+ clone->set_pct(clone->pct);\nreturn clone;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Codec/Polar/Codec_polar.cpp", "new_path": "src/Factory/Module/Codec/Polar/Codec_polar.cpp", "diff": "@@ -29,6 +29,7 @@ Codec_polar::parameters\nCodec::parameters::enc = nullptr;\nCodec::parameters::dec = nullptr;\n+ Codec::parameters::pct = nullptr;\n}\nCodec_polar::parameters* Codec_polar::parameters\n@@ -43,6 +44,7 @@ Codec_polar::parameters* Codec_polar::parameters\nclone->set_enc(clone->enc);\nclone->set_dec(clone->dec);\n+ clone->set_pct(clone->pct);\nreturn clone;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Codec/Turbo/Codec_turbo.cpp", "new_path": "src/Factory/Module/Codec/Turbo/Codec_turbo.cpp", "diff": "@@ -29,6 +29,7 @@ Codec_turbo::parameters\nCodec::parameters::enc = nullptr;\nCodec::parameters::dec = nullptr;\n+ Codec::parameters::pct = nullptr;\nif (Codec::parameters::itl != nullptr)\n{\ndelete Codec::parameters::itl;\n@@ -47,6 +48,7 @@ Codec_turbo::parameters* Codec_turbo::parameters\nclone->set_enc(clone->enc);\nclone->set_dec(clone->dec);\n+ clone->set_pct(clone->pct);\nclone->set_itl(clone->enc->itl);\ndelete clone->dec->itl; clone->dec->itl = clone->enc->itl;\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Codec/Turbo_DB/Codec_turbo_DB.cpp", "new_path": "src/Factory/Module/Codec/Turbo_DB/Codec_turbo_DB.cpp", "diff": "@@ -29,6 +29,7 @@ Codec_turbo_DB::parameters\nCodec::parameters::enc = nullptr;\nCodec::parameters::dec = nullptr;\n+ Codec::parameters::pct = nullptr;\nif (Codec::parameters::itl != nullptr)\n{\ndelete Codec::parameters::itl;\n@@ -47,6 +48,7 @@ Codec_turbo_DB::parameters* Codec_turbo_DB::parameters\nclone->set_enc(clone->enc);\nclone->set_dec(clone->dec);\n+ clone->set_pct(clone->pct);\nclone->set_itl(clone->enc->itl);\ndelete clone->dec->itl; clone->dec->itl = clone->enc->itl;\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the Factory::Codec cloning methods by setting correcly the cloned puncturers in the parent Codec
8,490
10.07.2018 15:05:33
-7,200
978d1a7f063c01bf846c33fddd0302507a836dc6
Simplify MS, OMS and NMS update rules.
[ { "change_type": "MODIFY", "old_path": "src/Tools/Code/LDPC/Update_rule/MS/Update_rule_MS.hpp", "new_path": "src/Tools/Code/LDPC/Update_rule/MS/Update_rule_MS.hpp", "diff": "@@ -69,17 +69,16 @@ public:\n{\nconst auto var_abs = (R)std::abs(var_val);\nconst auto var_sign = std::signbit((float)var_val) ? -1 : 0;\n- const auto tmp = min1;\nthis->sign ^= var_sign;\n+ this->min2 = std::min(this->min2, std::max(var_abs, this->min1));\nthis->min1 = std::min(this->min1, var_abs );\n- this->min2 = std::min(this->min2, std::max(var_abs, tmp));\n}\ninline void end_chk_node_in()\n{\n- this->cst1 = (this->min2 < 0) ? 0 : this->min2;\n- this->cst2 = (this->min1 < 0) ? 0 : this->min1;\n+ this->cst1 = std::max((R)0, this->min2);\n+ this->cst2 = std::max((R)0, this->min1);\n}\n// outcomming values from the check nodes into the variable nodes\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/LDPC/Update_rule/MS/Update_rule_MS_simd.hpp", "new_path": "src/Tools/Code/LDPC/Update_rule/MS/Update_rule_MS_simd.hpp", "diff": "@@ -81,17 +81,16 @@ public:\n{\nconst auto var_abs = mipp::abs(var_val);\nconst auto var_sign = mipp::sign(var_val);\n- const auto tmp = this->min1;\nthis->sign ^= var_sign;\n+ this->min2 = mipp::min(this->min2, mipp::max(var_abs, this->min1));\nthis->min1 = mipp::min(this->min1, var_abs );\n- this->min2 = mipp::min(this->min2, mipp::max(var_abs, tmp));\n}\ninline void end_chk_node_in()\n{\n- this->cst1 = mipp::blend(this->zero, this->min2, this->min2 < this->zero);\n- this->cst2 = mipp::blend(this->zero, this->min1, this->min1 < this->zero);\n+ this->cst1 = mipp::max(this->zero, this->min2);\n+ this->cst2 = mipp::max(this->zero, this->min1);\n}\n// outcomming values from the check nodes into the variable nodes\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/LDPC/Update_rule/NMS/Update_rule_NMS.hpp", "new_path": "src/Tools/Code/LDPC/Update_rule/NMS/Update_rule_NMS.hpp", "diff": "@@ -95,8 +95,8 @@ public:\n{\nMS.cst1 = normalize<R>(MS.min2, this->normalize_factor);\nMS.cst2 = normalize<R>(MS.min1, this->normalize_factor);\n- MS.cst1 = (MS.cst1 < 0) ? 0 : MS.cst1;\n- MS.cst2 = (MS.cst2 < 0) ? 0 : MS.cst2;\n+ MS.cst1 = std::max((R)0, MS.cst1);\n+ MS.cst2 = std::max((R)0, MS.cst2);\n}\n// outcomming values from the check nodes into the variable nodes\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/LDPC/Update_rule/NMS/Update_rule_NMS_simd.hpp", "new_path": "src/Tools/Code/LDPC/Update_rule/NMS/Update_rule_NMS_simd.hpp", "diff": "@@ -116,8 +116,8 @@ public:\n{\nMS.cst1 = normalize<R,F>(MS.min2, this->normalize_factor);\nMS.cst2 = normalize<R,F>(MS.min1, this->normalize_factor);\n- MS.cst1 = mipp::blend(MS.zero, MS.cst1, MS.cst1 < MS.zero);\n- MS.cst2 = mipp::blend(MS.zero, MS.cst2, MS.cst2 < MS.zero);\n+ MS.cst1 = mipp::max(MS.zero, MS.cst1);\n+ MS.cst2 = mipp::max(MS.zero, MS.cst2);\n}\n// outcomming values from the check nodes into the variable nodes\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/LDPC/Update_rule/OMS/Update_rule_OMS.hpp", "new_path": "src/Tools/Code/LDPC/Update_rule/OMS/Update_rule_OMS.hpp", "diff": "@@ -62,8 +62,8 @@ public:\n{\nMS.cst1 = MS.min2 - this->offset;\nMS.cst2 = MS.min1 - this->offset;\n- MS.cst1 = (MS.cst1 < 0) ? 0 : MS.cst1;\n- MS.cst2 = (MS.cst2 < 0) ? 0 : MS.cst2;\n+ MS.cst1 = std::max((R)0, MS.cst1);\n+ MS.cst2 = std::max((R)0, MS.cst2);\n}\n// outcomming values from the check nodes into the variable nodes\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/LDPC/Update_rule/OMS/Update_rule_OMS_simd.hpp", "new_path": "src/Tools/Code/LDPC/Update_rule/OMS/Update_rule_OMS_simd.hpp", "diff": "@@ -61,8 +61,8 @@ public:\n{\nMS.cst1 = MS.min2 - this->offset;\nMS.cst2 = MS.min1 - this->offset;\n- MS.cst1 = mipp::blend(MS.zero, MS.cst1, MS.cst1 < MS.zero);\n- MS.cst2 = mipp::blend(MS.zero, MS.cst2, MS.cst2 < MS.zero);\n+ MS.cst1 = mipp::max(MS.zero, MS.cst1);\n+ MS.cst2 = mipp::max(MS.zero, MS.cst2);\n}\n// outcomming values from the check nodes into the variable nodes\n" } ]
C++
MIT License
aff3ct/aff3ct
Simplify MS, OMS and NMS update rules.
8,483
10.07.2018 15:43:47
-7,200
fa63f28758f0dc76b5ee971fa008f5e2e527d0e0
Fix g++4.x compilation errors with protected parent type use
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp", "diff": "@@ -38,13 +38,7 @@ namespace module\ntemplate <typename B = int, typename R = float>\nclass Decoder_chase_pyndiah : public Decoder_SISO_SIHO<B,R>\n{\n-// Test for GCC > 5.1.0\n-// Compilation error under when struct 'info' is protected\n-#if GCC_VERSION >= 50100\nprotected:\n-#else\n-public:\n-#endif\nstruct info\n{\nR metric;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.cpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.cpp", "diff": "@@ -77,9 +77,11 @@ void Decoder_chase_pyndiah_fast<B,R>\nthis->competitors[c].pos = c*this->N;\n}\n+ using I = typename Decoder_chase_pyndiah<B,R>::info; // trick to avoid g++4.x compilation error\n+\nstd::sort(this->competitors.begin(), this->competitors.end(),\n- [](const typename Decoder_chase_pyndiah<B,R>::info& a,\n- const typename Decoder_chase_pyndiah<B,R>::info& b) { return a.metric < b.metric; });\n+ [](const I& a,\n+ const I& b) { return a.metric < b.metric; });\n}\ntemplate <typename B, typename R>\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix g++4.x compilation errors with protected parent type use
8,488
10.07.2018 16:09:09
-7,200
3c7199f4e84aab7409ed821f9a2bd7491f023374
Add BEC frozen bits generator.
[ { "change_type": "MODIFY", "old_path": "src/Factory/Tools/Code/Polar/Frozenbits_generator.cpp", "new_path": "src/Factory/Tools/Code/Polar/Frozenbits_generator.cpp", "diff": "#include \"Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_file.hpp\"\n#include \"Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_TV.hpp\"\n#include \"Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_GA.hpp\"\n+#include \"Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_BEC.hpp\"\n#include \"Frozenbits_generator.hpp\"\n@@ -52,7 +53,7 @@ void Frozenbits_generator::parameters\nargs.add(\n{p+\"-gen-method\"},\n- tools::Text(tools::Including_set(\"GA\", \"FILE\", \"TV\")),\n+ tools::Text(tools::Including_set(\"GA\", \"FILE\", \"TV\", \"BEC\")),\n\"select the frozen bits generation method.\");\nargs.add(\n@@ -104,9 +105,10 @@ void Frozenbits_generator::parameters\ntools::Frozenbits_generator* Frozenbits_generator::parameters\n::build() const\n{\n- if (this->type == \"GA\" ) return new tools::Frozenbits_generator_GA (this->K, this->N_cw, this->sigma);\n- else if (this->type == \"TV\" ) return new tools::Frozenbits_generator_TV (this->K, this->N_cw, this->path_fb, this->path_pb, this->sigma);\n+ if (this->type == \"GA\" ) return new tools::Frozenbits_generator_GA (this->K, this->N_cw );\n+ else if (this->type == \"TV\" ) return new tools::Frozenbits_generator_TV (this->K, this->N_cw, this->path_fb, this->path_pb);\nelse if (this->type == \"FILE\") return new tools::Frozenbits_generator_file(this->K, this->N_cw, this->path_fb );\n+ else if (this->type == \"BEC\" ) return new tools::Frozenbits_generator_BEC (this->K, this->N_cw );\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Codec/Polar/Codec_polar.cpp", "new_path": "src/Module/Codec/Polar/Codec_polar.cpp", "diff": "@@ -171,9 +171,7 @@ void Codec_polar<B,Q>\n// adaptive frozen bits generation\nif (adaptive_fb && !generated_decoder)\n{\n- this->n->is_of_type_throw(tools::Noise_type::SIGMA);\n-\n- fb_generator->set_sigma(this->n->get_noise());\n+ fb_generator->set_noise(noise);\nfb_generator->generate(frozen_bits);\nthis->notify_frozenbits_update();\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator.hpp", "new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator.hpp", "diff": "#include <sstream>\n#include <vector>\n+#include <Tools/Noise/Noise.hpp>\n+#include <Tools/Noise/noise_utils.h>\n#include \"Tools/Exception/exception.hpp\"\n@@ -26,7 +28,7 @@ class Frozenbits_generator\nprotected:\nconst int K; /*!< Number of information bits in the frame. */\nconst int N; /*!< Codeword size (or frame size). */\n- float sigma; /*!< The AWGN channel sigma value. */\n+ tools::Noise<float>* n; /*!< The current noise to apply to the input signal */\nstd::vector<uint32_t> best_channels; /*!< The best channels in a codeword sorted by descending order. */\n@@ -36,10 +38,9 @@ public:\n*\n* \\param K: number of information bits in the frame.\n* \\param N: codeword size (or frame size).\n- * \\param sigma: the AWGN channel sigma value.\n*/\n- Frozenbits_generator(const int K, const int N, const float sigma = 0.f)\n- : K(K), N(N), sigma(sigma), best_channels(N) {}\n+ Frozenbits_generator(const int K, const int N)\n+ : K(K), N(N), best_channels(N) {}\n/*!\n* \\brief Destructor.\n@@ -57,18 +58,30 @@ public:\n}\n/*!\n- * \\brief Sets the AWGN channel sigma value.\n+ * \\brief Sets the current noise to apply to the input signal\n*\n- * \\param sigma: the AWGN channel sigma value.\n+ * \\param sigma: the current noise to apply to the input signal\n*/\n- void set_sigma(const float sigma)\n+ void set_noise(const tools::Noise<float>& noise)\n{\n- this->sigma = sigma;\n+ if (this->n != nullptr)\n+ delete this->n;\n+\n+ this->n = tools::cast<float>(noise);\n}\n- float get_sigma() const\n+ /*!\n+ * \\brief Sets the current noise to apply to the input signal\n+ *\n+ * \\param sigma: the current noise to apply to the input signal\n+ */\n+ void set_noise(const tools::Noise<double>& noise)\n{\n- return this->sigma;\n+ if (this->n != nullptr)\n+ delete this->n;\n+\n+ this->n = tools::cast<float>(noise);\n+ this->check_noise();\n}\n/*!\n@@ -105,6 +118,7 @@ public:\n}\nprotected:\n+\n/*!\n* \\brief Evaluates the best channels.\n*\n@@ -112,6 +126,19 @@ protected:\n* This method fills the internal Frozenbits_generator::best_channels attribute.\n*/\nvirtual void evaluate() = 0;\n+\n+ /*!\n+ * \\brief Check that the noise has the expected type\n+ */\n+ virtual void check_noise()\n+ {\n+ if (this->n == nullptr)\n+ {\n+ std::stringstream message;\n+ message << \"No noise has been set.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n};\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_BEC.cpp", "diff": "+#ifndef _USE_MATH_DEFINES\n+#define _USE_MATH_DEFINES\n+#endif\n+\n+#include <cmath>\n+#include <limits>\n+#include <fstream>\n+#include <iostream>\n+#include <algorithm>\n+#include <Tools/Noise/Noise.hpp>\n+\n+#include \"Frozenbits_generator_BEC.hpp\"\n+\n+using namespace aff3ct::tools;\n+\n+Frozenbits_generator_BEC\n+::Frozenbits_generator_BEC(const int K, const int N)\n+: Frozenbits_generator(K, N), m((int)std::log2(N)), z((int)std::exp2(m), 0)\n+{\n+}\n+\n+Frozenbits_generator_BEC\n+::~Frozenbits_generator_BEC()\n+{\n+}\n+\n+void Frozenbits_generator_BEC\n+::evaluate()\n+{\n+ for (unsigned i = 0; i != this->best_channels.size(); i++)\n+ this->best_channels[i] = i;\n+\n+ for (auto i = 0; i < std::exp2(m); i++)\n+ z[i] = 2.0 / std::pow((double)this->n->get_noise(), 2.0);\n+\n+ for (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+// {\n+// double T = z[t * o1];\n+//\n+// z[t * o1] = phi_inv(1.0 - std::pow(1.0 - phi(T), 2.0));\n+// if (z[t * o1] == HUGE_VAL)\n+// z[t * o1] = T + M_LN2 / (alpha * gamma);\n+//\n+// z[t * o1 + o2] = 2.0 * T;\n+// }\n+ }\n+\n+ std::sort(this->best_channels.begin(), this->best_channels.end(), [this](int i1, int i2) { return z[i1] > z[i2]; });\n+}\n+\n+void Frozenbits_generator_BEC\n+::check_noise()\n+{\n+ Frozenbits_generator::check_noise();\n+\n+ this->n->is_of_type_throw(tools::Noise_type::EP);\n+}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_BEC.hpp", "diff": "+#ifndef FROZENBITS_GENERATOR_BEC_HPP_\n+#define FROZENBITS_GENERATOR_BEC_HPP_\n+\n+#include <limits>\n+#include <vector>\n+\n+#include \"Frozenbits_generator.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+class Frozenbits_generator_BEC : public Frozenbits_generator\n+{\n+private:\n+ const int m;\n+ std::vector<double> z;\n+\n+ const double alpha = -0.4527;\n+ const double beta = 0.0218;\n+ const double gamma = 0.8600;\n+\n+ const double a = 1.0 / alpha;\n+ const double b = -beta / alpha;\n+ const double c = 1.0 / gamma;\n+\n+ const double phi_pivot = 0.867861;\n+ const double phi_inv_pivot = 0.6845772418;\n+\n+ const double bisection_max = std::numeric_limits<double>::max();\n+\n+public:\n+ Frozenbits_generator_BEC(const int K, const int N);\n+\n+ ~Frozenbits_generator_BEC();\n+\n+protected:\n+ void evaluate();\n+ double phi (double t);\n+ double phi_inv(double t);\n+ virtual void check_noise();\n+};\n+}\n+}\n+\n+#endif /* FROZENBITS_GENERATOR_BEC_HPP_ */\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_GA.cpp", "new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_GA.cpp", "diff": "using namespace aff3ct::tools;\nFrozenbits_generator_GA\n-::Frozenbits_generator_GA(const int K, const int N, const float sigma)\n-: Frozenbits_generator(K, N, sigma), m((int)std::log2(N)), z((int)std::exp2(m), 0)\n+::Frozenbits_generator_GA(const int K, const int N)\n+: Frozenbits_generator(K, N), m((int)std::log2(N)), z((int)std::exp2(m), 0)\n{\n}\n@@ -30,7 +30,7 @@ void Frozenbits_generator_GA\nthis->best_channels[i] = i;\nfor (auto i = 0; i < std::exp2(m); i++)\n- z[i] = 2.0 / std::pow((double)this->sigma, 2.0);\n+ z[i] = 2.0 / std::pow((double)this->n->get_noise(), 2.0);\nfor (auto l = 1; l <= m; l++)\n{\n@@ -69,3 +69,11 @@ double Frozenbits_generator_GA\nelse\nreturn std::pow(a * std::log(t) + b, c);\n}\n+\n+void Frozenbits_generator_GA\n+::check_noise()\n+{\n+ Frozenbits_generator::check_noise();\n+\n+ this->n->is_of_type_throw(tools::Noise_type::SIGMA);\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_GA.hpp", "new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_GA.hpp", "diff": "@@ -30,7 +30,7 @@ private:\nconst double bisection_max = std::numeric_limits<double>::max();\npublic:\n- Frozenbits_generator_GA(const int K, const int N, const float sigma = 0.f);\n+ Frozenbits_generator_GA(const int K, const int N);\n~Frozenbits_generator_GA();\n@@ -38,6 +38,7 @@ protected:\nvoid evaluate();\ndouble phi (double t);\ndouble phi_inv(double t);\n+ virtual void check_noise();\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_TV.cpp", "new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_TV.cpp", "diff": "@@ -24,9 +24,8 @@ const int Frozenbits_generator_TV::Mu = 100;\nFrozenbits_generator_TV\n::Frozenbits_generator_TV(const int K, const int N,\nconst std::string &awgn_codes_dir,\n- const std::string &bin_pb_path,\n- const float sigma)\n-: Frozenbits_generator_file(K, N, sigma), m((int)std::log2(N)), awgn_codes_dir(awgn_codes_dir), bin_pb_path(bin_pb_path)\n+ const std::string &bin_pb_path)\n+: Frozenbits_generator_file(K, N), m((int)std::log2(N)), awgn_codes_dir(awgn_codes_dir), bin_pb_path(bin_pb_path)\n{\n}\n@@ -39,7 +38,7 @@ void Frozenbits_generator_TV\n::evaluate()\n{\nstd::ostringstream s_stream;\n- s_stream << std::setiosflags(std::ios::fixed) << std::setprecision(3) << this->sigma;\n+ s_stream << std::setiosflags(std::ios::fixed) << std::setprecision(3) << this->n->get_noise();\nauto str_sigma = s_stream.str();\nauto str_N = std::to_string(this->N);\nauto str_m = std::to_string(m);\n@@ -131,3 +130,11 @@ void Frozenbits_generator_TV\n}\n}\n}\n+\n+void Frozenbits_generator_TV\n+::check_noise()\n+{\n+ Frozenbits_generator::check_noise();\n+\n+ this->n->is_of_type_throw(tools::Noise_type::SIGMA);\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_TV.hpp", "new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_TV.hpp", "diff": "@@ -23,13 +23,13 @@ private:\npublic:\nFrozenbits_generator_TV(const int K, const int N,\nconst std::string &awgn_codes_dir,\n- const std::string &bin_pb_path,\n- float sigma = 0.f);\n+ const std::string &bin_pb_path);\nvirtual ~Frozenbits_generator_TV();\nprotected:\nvoid evaluate();\n+ virtual void check_noise();\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_file.cpp", "new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_file.cpp", "diff": "@@ -15,13 +15,13 @@ using namespace aff3ct::tools;\nFrozenbits_generator_file\n::Frozenbits_generator_file(const int K, const int N, const std::string& filename)\n-: Frozenbits_generator(K, N, 0.f), filename(filename)\n+: Frozenbits_generator(K, N), filename(filename)\n{\n}\nFrozenbits_generator_file\n-::Frozenbits_generator_file(const int K, const int N, const float sigma)\n-: Frozenbits_generator(K, N, sigma), filename(\"\")\n+::Frozenbits_generator_file(const int K, const int N)\n+: Frozenbits_generator(K, N), filename(\"\")\n{\n}\n@@ -66,3 +66,9 @@ bool Frozenbits_generator_file\nelse\nreturn false;\n}\n+\n+void Frozenbits_generator_file\n+::check_noise()\n+{\n+ Frozenbits_generator::check_noise();\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_file.hpp", "new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_file.hpp", "diff": "@@ -16,7 +16,7 @@ private:\nconst std::string filename;\nprotected:\n- Frozenbits_generator_file(const int K, const int N, const float sigma = 0.f);\n+ Frozenbits_generator_file(const int K, const int N);\npublic:\nFrozenbits_generator_file(const int K, const int N, const std::string& filename);\n@@ -26,6 +26,7 @@ public:\nprotected:\nvoid evaluate();\nbool load_channels_file(const std::string& filename);\n+ virtual void check_noise();\n};\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Add BEC frozen bits generator.
8,483
10.07.2018 16:56:48
-7,200
72e311de7045730cae1eafed19d879722c43c3dc
Add the minFE argument to do not take into account the noise points with not enough wrong frames.
[ { "change_type": "MODIFY", "old_path": "ci/test-regression.py", "new_path": "ci/test-regression.py", "diff": "@@ -27,6 +27,7 @@ parser.add_argument('--sensibility', action='store', dest='sensibility', ty\nparser.add_argument('--n-threads', action='store', dest='nThreads', type=int, default=0, help='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)\n+parser.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)\nparser.add_argument('--weak-rate', action='store', dest='weakRate', type=float, default=0.8, help='Rate of valid noise points to passe a test.') # choices=xrange(0.0, 1.0 )\nparser.add_argument('--max-snr-time', action='store', dest='maxSNRTime', type=int, default=600, help='The maximum amount of time to spend to compute a noise point in seconds (0 = illimited)') # choices=xrange(0, +inf)\nparser.add_argument('--verbose', action='store', dest='verbose', type=bool, default=False, help='Enable the verbose mode.')\n@@ -125,6 +126,7 @@ class simuData:\nself.BER = []\nself.FER = []\nself.MI = []\n+ self.FE = []\nself.RunCommand = \"\"\nself.CurveName = \"\"\nself.NoiseType = \"\"\n@@ -196,6 +198,13 @@ def dataReader(aff3ctOutput):\nelse:\ndata.MI = data.All[idx]\n+ # set FE\n+ idx = getLegendIdx(data.Legend, \"FE\")\n+ if idx == -1:\n+ data.FE = []\n+ else:\n+ data.FE = data.All[idx]\n+\n# set ESN0\nidx = getLegendIdx(data.Legend, \"Es/N0\")\nif idx == -1 or data.NoiseType == \"Es/N0\":\n@@ -245,7 +254,7 @@ def splitAsCommand(runCommand):\nreturn argsList\nclass tableStats:\n- def __init__(self, tableCur, tableRef, sensibility, name):\n+ def __init__(self, tableCur, tableRef, sensibility, name, nData = 0):\nif len(tableCur) > len(tableRef) : # can't have less ref than checked points\nraise RuntimeError\n@@ -259,7 +268,11 @@ class tableStats:\nself.avgSensibility = 0\nself.rateSensibility = 0\nself.valid = 0\n+\n+ if nData == 0 or nData > len(tableCur) :\nself.nData = len(tableCur)\n+ else :\n+ self.nData = nData\nself.errorsList = []\nself.errorsPos = []\nself.errorsMessage = []\n@@ -319,18 +332,24 @@ class tableStats:\nreturn float(self.valid) / float(self.nData)\nclass compStats:\n- def __init__(self, dataCur, dataRef, sensibility):\n+ def __init__(self, dataCur, dataRef, sensibility, asked_n_fe):\nif not isinstance(dataCur, simuData) or not isinstance(dataRef, simuData) :\nraise TypeError\n+ self.nValidData = len(dataCur.FE)\n+ for d in range(len(dataCur.FE)) :\n+ if dataCur.FE[d] < asked_n_fe :\n+ self.nValidData = d\n+\n+\nself.dataCur = dataCur\nself.dataRef = dataRef\nself.dataList = []\n- self.dataList.append(tableStats(dataCur.Noise, dataRef.Noise, 0.0, dataRef.NoiseType))\n- self.dataList.append(tableStats(dataCur.ESN0, dataRef.ESN0, 0.0, \"Es/N0\"))\n- self.dataList.append(tableStats(dataCur.FER, dataRef.FER, sensibility, \"FER\" ))\n- self.dataList.append(tableStats(dataCur.BER, dataRef.BER, sensibility, \"BER\" ))\n- self.dataList.append(tableStats(dataCur.MI, dataRef.MI, sensibility, \"MI\" ))\n+ self.dataList.append(tableStats(dataCur.Noise, dataRef.Noise, 0.0, dataRef.NoiseType, self.nValidData))\n+ self.dataList.append(tableStats(dataCur.ESN0, dataRef.ESN0, 0.0, \"Es/N0\" , self.nValidData))\n+ self.dataList.append(tableStats(dataCur.FER, dataRef.FER, sensibility, \"FER\" , self.nValidData))\n+ self.dataList.append(tableStats(dataCur.BER, dataRef.BER, sensibility, \"BER\" , self.nValidData))\n+ self.dataList.append(tableStats(dataCur.MI, dataRef.MI, sensibility, \"MI\" , self.nValidData))\ndef errorMessage(self, idx):\nmessage = \"\"\n@@ -529,7 +548,7 @@ for fn in fileNames:\nerrAndWarnMessages = stderrAFFECT.decode(encoding='UTF-8')\n- # compare ref and nex results to check if the simulator is still OK\n+ # compare ref and new results to check if the simulator is still OK\nos.chdir(PathOrigin)\n# get the results\n@@ -565,7 +584,7 @@ for fn in fileNames:\nelse:\n# parse the results to validate (or not) the BER/FER/MI performance\n- comp = compStats(simuCur, simuRef, args.sensibility)\n+ comp = compStats(simuCur, simuRef, args.sensibility, args.minFE)\n# print the header\nfRes.write(\"Run command:\\n\" + simuCur.RunCommand + \"\\n\")\n" } ]
C++
MIT License
aff3ct/aff3ct
Add the minFE argument to do not take into account the noise points with not enough wrong frames.
8,483
11.07.2018 10:52:43
-7,200
41e50824987596868990cbe9d6781cc4cd899b85
Add a start index in the source/encoder user modules to not always start at the 0 index
[ { "change_type": "MODIFY", "old_path": "src/Module/Encoder/User/Encoder_user.cpp", "new_path": "src/Module/Encoder/User/Encoder_user.cpp", "diff": "@@ -10,8 +10,8 @@ using namespace aff3ct::module;\ntemplate <typename B>\nEncoder_user<B>\n-::Encoder_user(const int K, const int N, const std::string &filename, const int n_frames)\n-: Encoder<B>(K, N, n_frames), codewords(), cw_counter(0)\n+::Encoder_user(const int K, const int N, const std::string &filename, const int n_frames, const int start_idx)\n+: Encoder<B>(K, N, n_frames), codewords(), cw_counter(start_idx)\n{\nconst std::string name = \"Encoder_user\";\nthis->set_name(name);\n@@ -78,6 +78,8 @@ Encoder_user<B>\nmessage << \"Can't open '\" + filename + \"' file.\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+\n+ cw_counter %= (int)codewords.size();\n}\ntemplate <typename B>\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Encoder/User/Encoder_user.hpp", "new_path": "src/Module/Encoder/User/Encoder_user.hpp", "diff": "@@ -17,7 +17,7 @@ private:\nint cw_counter;\npublic:\n- Encoder_user(const int K, const int N, const std::string &filename, const int n_frames = 1);\n+ Encoder_user(const int K, const int N, const std::string &filename, const int n_frames = 1, const int start_idx = 0);\nvirtual ~Encoder_user();\nconst std::vector<uint32_t>& get_info_bits_pos() const;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Source/User/Source_user.cpp", "new_path": "src/Module/Source/User/Source_user.cpp", "diff": "@@ -10,8 +10,8 @@ using namespace aff3ct::module;\ntemplate <typename B>\nSource_user<B>\n-::Source_user(const int K, const std::string filename, const int n_frames)\n-: Source<B>(K, n_frames), source(), src_counter(0)\n+::Source_user(const int K, const std::string filename, const int n_frames, const int start_idx)\n+: Source<B>(K, n_frames), source(), src_counter(start_idx)\n{\nconst std::string name = \"Source_user\";\nthis->set_name(name);\n@@ -64,6 +64,8 @@ Source_user<B>\n}\nelse\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"Can't open '\" + filename + \"' file.\");\n+\n+ src_counter %= (int)source.size();\n}\ntemplate <typename B>\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Source/User/Source_user.hpp", "new_path": "src/Module/Source/User/Source_user.hpp", "diff": "@@ -19,7 +19,7 @@ private:\nint src_counter;\npublic:\n- Source_user(const int K, std::string filename, const int n_frames = 1);\n+ Source_user(const int K, std::string filename, const int n_frames = 1, const int start_idx = 0);\nvirtual ~Source_user();\nprotected:\n" } ]
C++
MIT License
aff3ct/aff3ct
Add a start index in the source/encoder user modules to not always start at the 0 index
8,483
11.07.2018 10:59:35
-7,200
f9ede55d894ffec74a3b4eddb0ee8d82669e6158
Add the start idx parameter in the Source/encoder factories but without matching argument. Do not take into account the selected implem when building AZCW/USER type sources
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Encoder/Encoder.cpp", "new_path": "src/Factory/Module/Encoder/Encoder.cpp", "diff": "@@ -114,7 +114,7 @@ module::Encoder<B>* Encoder::parameters\nif (this->type == \"NO\" ) return new module::Encoder_NO <B>(this->K, this->n_frames);\nelse if (this->type == \"AZCW\" ) return new module::Encoder_AZCW <B>(this->K, this->N_cw, this->n_frames);\nelse if (this->type == \"COSET\") return new module::Encoder_coset<B>(this->K, this->N_cw, this->seed, this->n_frames);\n- else if (this->type == \"USER\" ) return new module::Encoder_user <B>(this->K, this->N_cw, this->path, this->n_frames);\n+ else if (this->type == \"USER\" ) return new module::Encoder_user <B>(this->K, this->N_cw, this->path, this->n_frames, this->start_idx);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Encoder/Encoder.hpp", "new_path": "src/Factory/Module/Encoder/Encoder.hpp", "diff": "@@ -30,6 +30,7 @@ struct Encoder : public Factory\nint n_frames = 1;\nint seed = 0;\nint tail_length = 0;\n+ int start_idx = 0;\n// deduced parameters\nfloat R = -1.f;\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Source/Source.cpp", "new_path": "src/Factory/Module/Source/Source.cpp", "diff": "@@ -99,10 +99,15 @@ template <typename B>\nmodule::Source<B>* Source::parameters\n::build() const\n{\n- if (this->type == \"RAND\" && this->implem == \"STD\" ) return new module::Source_random <B>(this->K, this->seed, this->n_frames);\n- else if (this->type == \"RAND\" && this->implem == \"FAST\") return new module::Source_random_fast<B>(this->K, this->seed, this->n_frames);\n- else if (this->type == \"AZCW\" && this->implem == \"STD\" ) return new module::Source_AZCW <B>(this->K, this->n_frames);\n- else if (this->type == \"USER\" && this->implem == \"STD\" ) return new module::Source_user <B>(this->K, this->path, this->n_frames);\n+ if (this->type == \"RAND\")\n+ {\n+ if (this->implem == \"STD\")\n+ return new module::Source_random <B>(this->K, this->seed, this->n_frames);\n+ else if (this->implem == \"FAST\")\n+ return new module::Source_random_fast<B>(this->K, this->seed, this->n_frames);\n+ }\n+ else if (this->type == \"AZCW\") return new module::Source_AZCW<B>(this->K, this->n_frames);\n+ else if (this->type == \"USER\") return new module::Source_user<B>(this->K, this->path, this->n_frames, this->start_idx);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Source/Source.hpp", "new_path": "src/Factory/Module/Source/Source.hpp", "diff": "@@ -28,6 +28,7 @@ struct Source : public Factory\nstd::string path = \"\";\nint n_frames = 1;\nint seed = 0;\n+ int start_idx= 0;\n// ---------------------------------------------------------------------------------------------------- METHODS\nexplicit parameters(const std::string &p = Source_prefix);\n" } ]
C++
MIT License
aff3ct/aff3ct
Add the start idx parameter in the Source/encoder factories but without matching argument. Do not take into account the selected implem when building AZCW/USER type sources
8,483
11.07.2018 11:03:29
-7,200
d16f905776f1ec8a6e803b4a532628df48bcc525
Add start-idx argument in source and encoder factories
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Encoder/Encoder.cpp", "new_path": "src/Factory/Module/Encoder/Encoder.cpp", "diff": "@@ -68,6 +68,11 @@ void Encoder::parameters\ntools::File(tools::openmode::read),\n\"path to a file containing one or a set of pre-computed codewords, to use with \\\"--enc-type USER\\\".\");\n+ args.add(\n+ {p+\"-start-idx\"},\n+ tools::Integer(tools::Positive()),\n+ \"Start idx to use in the USER type encoder.\");\n+\nargs.add(\n{p+\"-seed\", \"S\"},\ntools::Integer(tools::Positive()),\n@@ -86,6 +91,7 @@ void Encoder::parameters\nif(vals.exist({p+\"-type\" })) this->type = vals.at ({p+\"-type\" });\nif(vals.exist({p+\"-path\" })) this->path = vals.at ({p+\"-path\" });\nif(vals.exist({p+\"-no-sys\" })) this->systematic = false;\n+ if(vals.exist({p+\"-start-idx\" })) this->start_idx = vals.to_int({p+\"-start-idx\" });\nthis->R = (float)this->K / (float)this->N_cw;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Source/Source.cpp", "new_path": "src/Factory/Module/Source/Source.cpp", "diff": "@@ -61,6 +61,11 @@ void Source::parameters\ntools::File(tools::openmode::read),\n\"path to a file containing one or a set of pre-computed source bits, to use with \\\"--src-type USER\\\".\");\n+ args.add(\n+ {p+\"-start-idx\"},\n+ tools::Integer(tools::Positive()),\n+ \"Start idx to use in the USER type source.\");\n+\nargs.add(\n{p+\"-seed\", \"S\"},\ntools::Integer(tools::Positive()),\n@@ -78,6 +83,7 @@ void Source::parameters\nif(vals.exist({p+\"-implem\" })) this->implem = vals.at ({p+\"-implem\" });\nif(vals.exist({p+\"-path\" })) this->path = vals.at ({p+\"-path\" });\nif(vals.exist({p+\"-seed\", \"S\"})) this->seed = vals.to_int({p+\"-seed\", \"S\"});\n+ if(vals.exist({p+\"-start-idx\" })) this->start_idx= vals.to_int({p+\"-start-idx\" });\n}\nvoid Source::parameters\n" } ]
C++
MIT License
aff3ct/aff3ct
Add start-idx argument in source and encoder factories
8,483
11.07.2018 11:34:42
-7,200
f4172cdff63e0b404860cd8da08337206bf982fe
Remove argument mnt-trials from the arg lists in std simu chain
[ { "change_type": "MODIFY", "old_path": "src/Launcher/Simulation/BFER_std.cpp", "new_path": "src/Launcher/Simulation/BFER_std.cpp", "diff": "@@ -80,6 +80,7 @@ void BFER_std<B,R,Q>\nthis->args.erase({pmnt+\"-info-bits\", \"K\"});\nthis->args.erase({pmnt+\"-fra-size\", \"N\"});\nthis->args.erase({pmnt+\"-fra\", \"F\"});\n+ this->args.erase({pmnt+\"-trials\", \"n\"});\nthis->args.erase({pter+\"-info-bits\", \"K\"});\nthis->args.erase({pter+\"-cw-size\", \"N\"});\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Remove argument mnt-trials from the arg lists in std simu chain
8,483
13.07.2018 09:09:50
-7,200
453f04ef1d687ec14e100b446c63aacf87e24ac3
Fix MPI build error in Monitor_EXIT
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "diff": "@@ -131,11 +131,6 @@ protected:\npublic:\n// static constexpr unsigned n_MPI_attributes = 3;\n-\n- R I_A_sum;\n- unsigned long long n_trials;\n-\n- const unsigned max_n_trials;\nstruct Vals_mpi\n{\nint n_frames;\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix MPI build error in Monitor_EXIT
8,483
13.07.2018 09:17:57
-7,200
e2b1d2b8a488c0363d3d9451a15ed0e2cec15beb
Fix the monitor_exit constructor in MPI
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "diff": "@@ -146,7 +146,7 @@ public:\n// MPI_Aint displacements[n_MPI_attributes],\n// MPI_Datatype oldtypes [n_MPI_attributes]);\n- Monitor_BFER(const Vals_mpi& v)\n+ Monitor_EXIT(const Vals_mpi& v)\n: Monitor(v.n_frames),\nI_A_sum(v.I_A_sum),\nn_trials(v.n_trials),\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the monitor_exit constructor in MPI
8,483
13.07.2018 11:25:26
-7,200
afbc6b5cd5aee2a29785e6d03fd79d54ca0368ab
Enhance reporter noise to have link with a noise value, a pointer/reference to a noise and a pointer to a pointer to a noise
[ { "change_type": "MODIFY", "old_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.cpp", "new_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.cpp", "diff": "@@ -14,19 +14,40 @@ using namespace aff3ct::tools;\ntemplate <typename R>\nReporter_noise<R>\n-::Reporter_noise(Noise<R>* const& noise)\n+::Reporter_noise(const Noise<R>* const* _noise)\n+: Reporter_noise(new Noise_ptr(_noise))\n+{\n+}\n+\n+template <typename R>\n+Reporter_noise<R>\n+::Reporter_noise(const Noise<R>* _noise)\n+: Reporter_noise(new Noise_ptr(_noise))\n+{\n+}\n+\n+template <typename R>\n+Reporter_noise<R>\n+::Reporter_noise(const Noise<R>& _noise)\n+: Reporter_noise(new Noise_ptr(_noise))\n+{\n+}\n+\n+template <typename R>\n+Reporter_noise<R>\n+::Reporter_noise(Noise_ptr* noise_ptr)\n: Reporter(),\n- noise(noise),\n- saved_noise_type(noise != nullptr ? noise->get_type() : Noise_type::SIGMA)\n+ noise_ptr(noise_ptr),\n+ saved_noise_type(get_noise_ptr() != nullptr ? get_noise_ptr()->get_type() : Noise_type::SIGMA)\n{\n- if (noise == nullptr)\n- throw invalid_argument(__FILE__, __LINE__, __func__, \"'noise' is null pointer.\");\n+ if (get_noise_ptr() == nullptr)\n+ throw invalid_argument(__FILE__, __LINE__, __func__, \"'noise' is a null pointer.\");\nauto& Noise_title = noise_group.first;\nauto& Noise_cols = noise_group.second;\n- switch (this->noise->get_type())\n+ switch (get_noise_ptr()->get_type())\n{\ncase Noise_type::SIGMA :\nNoise_title = {\"Signal Noise Ratio\", \"(SNR)\"};\n@@ -46,16 +67,23 @@ Reporter_noise<R>\nthis->cols_groups.push_back(noise_group);\n}\n+template <typename R>\n+Reporter_noise<R>\n+::~Reporter_noise()\n+{\n+ if (noise_ptr != nullptr) delete noise_ptr;\n+}\n+\ntemplate <typename R>\nReporter::report_t Reporter_noise<R>\n::report(bool final)\n{\n- if (this->saved_noise_type != this->noise->get_type())\n+ if (this->saved_noise_type != get_noise_ptr()->get_type())\n{\nstd::stringstream message;\n- message << \"The noise to report has a different noise type 'noise.get_type()' than the one saved in\"\n+ message << \"The noise to report has a different noise type '(*noise)->get_type()' than the one saved in\"\n<< \" the constructor 'saved_noise_type' ('saved_noise_type' = \" << type_to_str(this->saved_noise_type)\n- << \" and 'noise.get_type()' = \" << type_to_str(this->noise->get_type()) << \").\";\n+ << \" and '(*noise)->get_type()' = \" << type_to_str(get_noise_ptr()->get_type()) << \").\";\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n@@ -69,11 +97,11 @@ Reporter::report_t Reporter_noise<R>\nstd::stringstream stream;\n- switch (this->noise->get_type())\n+ switch (get_noise_ptr()->get_type())\n{\ncase Noise_type::SIGMA :\n{\n- auto sig = dynamic_cast<const tools::Sigma<>*>(this->noise);\n+ auto sig = dynamic_cast<const tools::Sigma<>*>(get_noise_ptr());\nstream << std::setprecision(2) << std::fixed << sig->get_esn0();\nnoise_report.push_back(stream.str());\n@@ -84,12 +112,12 @@ Reporter::report_t Reporter_noise<R>\n}\ncase Noise_type::ROP :\n{\n- stream << std::setprecision(2) << std::fixed << this->noise->get_noise();\n+ stream << std::setprecision(2) << std::fixed << get_noise_ptr()->get_noise();\nbreak;\n}\ncase Noise_type::EP :\n{\n- stream << std::setprecision(4) << std::fixed << this->noise->get_noise();\n+ stream << std::setprecision(4) << std::fixed << get_noise_ptr()->get_noise();\nbreak;\n}\n}\n@@ -100,6 +128,15 @@ Reporter::report_t Reporter_noise<R>\nreturn the_report;\n}\n+template <typename R>\n+const Noise<R>* Reporter_noise<R>\n+::get_noise_ptr() const\n+{\n+ return noise_ptr->get_noise_ptr();\n+}\n+\n+\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.hpp", "new_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.hpp", "diff": "@@ -15,17 +15,43 @@ namespace tools\ntemplate <typename R = float>\nclass Reporter_noise : public Reporter\n{\n+public:\n+ explicit Reporter_noise(const Noise<R>* const* noise);\n+ explicit Reporter_noise(const Noise<R>* noise);\n+ explicit Reporter_noise(const Noise<R>& noise);\n+\n+ virtual ~Reporter_noise();\n+\n+ report_t report(bool final = false);\n+\n+private:\n+ struct Noise_ptr\n+ {\n+ Noise_ptr(const Noise<R>* const* n) : noise(nullptr), noise_ptr(n) {}\n+ Noise_ptr(const Noise<R>* n) : noise(n), noise_ptr(&noise) {}\n+ Noise_ptr(const Noise<R>& n) : noise(&n), noise_ptr(&noise) {}\n+\n+ const Noise<R>* get_noise_ptr() const\n+ {\n+ return *noise_ptr;\n+ }\n+\n+ private:\n+ const Noise<R>* noise;\n+ const Noise<R>* const* noise_ptr;\n+\n+ };\n+\n+ explicit Reporter_noise(Noise_ptr* noise_ptr);\n+ Noise_ptr* noise_ptr;\n+\nprotected:\n- Noise<R>* const& noise;\nconst Noise_type saved_noise_type;\n-\ngroup_t noise_group;\n-public:\n- explicit Reporter_noise(Noise<R>* const& noise);\n- virtual ~Reporter_noise() = default;\n+protected:\n+ const Noise<R>* get_noise_ptr() const;\n- report_t report(bool final = false);\n};\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Enhance reporter noise to have link with a noise value, a pointer/reference to a noise and a pointer to a pointer to a noise
8,483
13.07.2018 11:26:24
-7,200
09fc5e8aabc8a7f4a6e1f8c976cae873582125b4
Fix siga range build in factory EXIT
[ { "change_type": "MODIFY", "old_path": "src/Factory/Simulation/EXIT/EXIT.cpp", "new_path": "src/Factory/Simulation/EXIT/EXIT.cpp", "diff": "@@ -96,7 +96,7 @@ void EXIT::parameters\nargs.add(\n{p+\"-siga-range\"},\n- tools::Matlab_vector<float>(tools::Real(), std::make_tuple(tools::Length(1)), std::make_tuple(tools::Length(1,3))),\n+ tools::Matlab_vector<float>(tools::Real(tools::Positive()), std::make_tuple(tools::Length(1)), std::make_tuple(tools::Length(1,3))),\n\"sigma range used in EXIT charts (Matlab style: \\\"0.5:2.5,2.55,2.6:0.05:3\\\" with a default step of 0.1).\",\ntools::arg_rank::REQ);\n@@ -133,8 +133,8 @@ void EXIT::parameters\nelse\n{\nfloat sig_a_min = 0.f, sig_a_max = 0.f, sig_a_step = 0.1f;\n- if(vals.exist({p+\"-siga-min\", \"m\"})) sig_a_min = vals.to_float({p+\"-siga-min\", \"m\"});\n- if(vals.exist({p+\"-siga-max\", \"M\"})) sig_a_max = vals.to_float({p+\"-siga-max\", \"M\"});\n+ if(vals.exist({p+\"-siga-min\", \"a\"})) sig_a_min = vals.to_float({p+\"-siga-min\", \"a\"});\n+ if(vals.exist({p+\"-siga-max\", \"A\"})) sig_a_max = vals.to_float({p+\"-siga-max\", \"A\"});\nif(vals.exist({p+\"-siga-step\" })) sig_a_step = vals.to_float({p+\"-siga-step\" });\nthis->sig_a_range = tools::generate_range({{sig_a_min, sig_a_max}}, sig_a_step);\n@@ -174,11 +174,11 @@ template <typename B, typename R>\nsimulation::EXIT<B,R>* EXIT::parameters\n::build() const\n{\n-// #if defined(SYSTEMC)\n-// throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"SystemC/TLM simulation is not available.\");\n-// #else\n-// return new simulation::EXIT<B,R>(*this);\n-// #endif\n+#if defined(SYSTEMC)\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"SystemC/TLM simulation is not available.\");\n+#else\n+ return new simulation::EXIT<B,R>(*this);\n+#endif\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix siga range build in factory EXIT
8,483
13.07.2018 11:27:05
-7,200
51399fccecc36a4b87c87573f8b2c96bd466e7f8
Fix reporter/simulation/monitor EXIT
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp", "diff": "@@ -13,7 +13,8 @@ Monitor_EXIT<B,R>\n: Monitor(n_frames),\nI_A_sum((R)0),\nn_trials(0),\n- max_n_trials(max_n_trials)\n+ max_n_trials(max_n_trials),\n+ N(N)\n{\nconst std::string name = \"Monitor_EXIT\";\nthis->set_name(name);\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "diff": "@@ -24,13 +24,13 @@ protected:\nunsigned long long n_trials;\nconst unsigned max_n_trials;\n+ const int N;\nstd::vector<std::function<void(void)>> callbacks_measure;\nstd::vector<B> bits_buff;\nstd::vector<R> llrs_e_buff;\n- int N;\npublic:\nMonitor_EXIT(const int size, const unsigned max_n_trials, const int n_frames = 1);\n@@ -137,8 +137,8 @@ public:\nR I_A_sum;\nunsigned long long n_trials;\n- unsigned max_n_trials;\n+ unsigned max_n_trials;\nint N;\n};\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.cpp", "new_path": "src/Simulation/BFER/BFER.cpp", "diff": "@@ -116,7 +116,7 @@ BFER<B,R,Q>\nthis->noise = params_BFER.noise->template build<R>(0);\n- rep_noise = new tools::Reporter_noise<R>(this->noise);\n+ rep_noise = new tools::Reporter_noise<R>(&this->noise);\nreporters.push_back(rep_noise);\nif (params_BFER.mutinfo)\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/EXIT/EXIT.cpp", "new_path": "src/Simulation/EXIT/EXIT.cpp", "diff": "@@ -64,8 +64,7 @@ EXIT<B,R>\nthis->modules[\"monitor\"][0] = this->monitor;\n-\n- rep_noise = new tools::Reporter_noise<R>(&this->noise);\n+ rep_noise = new tools::Reporter_noise<R>(this->noise);\nreporters.push_back(rep_noise);\nrep_exit = new tools::Reporter_EXIT<B,R>(*this->monitor, this->noise_a);\n@@ -173,17 +172,23 @@ void EXIT<B,R>\nauto mdm_bytes = mdm[mdm::sck::demodulate::Y_N2].get_databytes();\nstd::fill(mdm_data, mdm_data + mdm_bytes, 0);\n}\n+ this->noise_a.set_noise(std::numeric_limits<R>::infinity());\n}\nelse\n{\n- this->noise_a.set_noise(2.f / sig_a);\n+ const R bit_rate = 1.;\n+ auto sig_a_2 = (R)2. / sig_a;\n+ R sig_a_esn0 = tools::sigma_to_esn0(sig_a_2, params_EXIT.mdm->upf);\n+ R sig_a_ebn0 = tools::esn0_to_ebn0 (sig_a_esn0, bit_rate, params_EXIT.mdm->bps);\n+\n+ this->noise_a.set_noise(sig_a_2, sig_a_ebn0, sig_a_esn0);\nchannel_a->set_noise(this->noise_a);\nmodem_a ->set_noise(this->noise_a);\n}\n- if (((!params_EXIT.ter->disabled && noise_idx == 0 && sig_a_idx == 0 &&\n- !params_EXIT.debug) || (params_EXIT.statistics && !params_EXIT.debug)))\n+ if ((!params_EXIT.ter->disabled && noise_idx == 0 && sig_a_idx == 0 && !params_EXIT.debug)\n+ || (params_EXIT.statistics && !params_EXIT.debug))\nterminal->legend(std::cout);\n// start the terminal to display BER/FER results\n@@ -191,8 +196,10 @@ void EXIT<B,R>\n!params_EXIT.debug)\nthis->terminal->start_temp_report(params_EXIT.ter->frequency);\n+\nthis->simulation_loop();\n+\nif (!params_EXIT.ter->disabled)\n{\nif (params_EXIT.debug)\n@@ -327,7 +334,7 @@ void EXIT<B,R>\nmodem [mdm::tsk::modulate].exec();\n//if sig_a = 0, La_K = 0, no noise to add\n- if (sig_a != 0)\n+ if (sig_a != (R)0.)\n{\n// Rayleigh channel\nif (params_EXIT.chn->type.find(\"RAYLEIGH\") != std::string::npos)\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/EXIT/EXIT.hpp", "new_path": "src/Simulation/EXIT/EXIT.hpp", "diff": "@@ -37,7 +37,7 @@ protected:\n// code specifications\ntools::Sigma<R> noise; // current noise simulated\ntools::Sigma<R> noise_a; // current noise simulated for the \"a\" part\n- float sig_a;\n+ R sig_a;\n// communication chain\nmodule::Source <B > *source;\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Display/Reporter/EXIT/Reporter_EXIT.cpp", "new_path": "src/Tools/Display/Reporter/EXIT/Reporter_EXIT.cpp", "diff": "@@ -44,11 +44,19 @@ Reporter::report_t Reporter_EXIT<B,R>\nconst auto fra = monitor.get_n_trials();\nconst auto I_A = monitor.get_I_A();\nconst auto I_E = monitor.get_I_E();\n- const auto sig_a = noise_a.get_noise();\nstd::stringstream str_sig_a, str_fra, str_I_A, str_I_E;\n- str_sig_a << std::setprecision(2) << std::fixed << sig_a;\n+ str_sig_a << std::setprecision(2) << std::fixed;\n+ try\n+ {\n+ str_sig_a << noise_a.get_noise();\n+ }\n+ catch(tools::runtime_error&)\n+ {\n+ str_sig_a << (R)0.;\n+ }\n+\nstr_fra << std::setprecision(2) << std::fixed << fra;\nstr_I_A << std::setprecision(6) << std::fixed << I_A;\nstr_I_E << std::setprecision(6) << std::fixed << I_E;\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix reporter/simulation/monitor EXIT
8,483
13.07.2018 14:30:51
-7,200
459f5b109ee978070288b754a0fb8641ad8b7a11
Do not display factory errors when on mpi on others nodes
[ { "change_type": "MODIFY", "old_path": "src/Launcher/Launcher.cpp", "new_path": "src/Launcher/Launcher.cpp", "diff": "@@ -82,6 +82,10 @@ int Launcher::read_arguments()\ntools::exception::no_backtrace = save;\n}\n+#ifdef ENABLE_MPI\n+ if (this->params_common.mpi_rank == 0)\n+ {\n+#endif\nif (params_common.display_help)\n{\nauto grps = factory::Factory::create_groups({&params_common});\n@@ -107,6 +111,9 @@ int Launcher::read_arguments()\nstd::cerr << std::endl << rang::tag::info << message << std::endl;\n}\n+#ifdef ENABLE_MPI\n+ }\n+#endif\nreturn (!cmd_error.empty() || params_common.display_help) ? EXIT_FAILURE : EXIT_SUCCESS;\n}\n@@ -148,10 +155,9 @@ int Launcher::launch()\n// write the command and he curve name in the PyBER format\n#ifdef ENABLE_MPI\n- if (!this->params_common.pyber.empty() && this->params_common.mpi_rank == 0)\n-#else\n- if (!this->params_common.pyber.empty())\n+ if (this->params_common.mpi_rank == 0)\n#endif\n+ if (!this->params_common.pyber.empty())\n{\nstream << \"Run command:\" << std::endl;\nstream << cmd_line << std::endl;\n" } ]
C++
MIT License
aff3ct/aff3ct
Do not display factory errors when on mpi on others nodes
8,483
13.07.2018 18:39:01
-7,200
af7fa8fbce5be7c0dfa5304d23c5599b784f73e2
Fix monitor MPI communication issues by adding a mother class Monitor_mpi that manage the communications between different monitors sequentially
[ { "change_type": "ADD", "old_path": null, "new_path": "src/Module/Monitor/Monitor_reduction_mpi.cpp", "diff": "+#ifdef ENABLE_MPI\n+#include <sstream>\n+#include \"Tools/Exception/exception.hpp\"\n+\n+#include \"Monitor_reduction_mpi.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+std::vector<aff3ct::module::Monitor_mpi*> aff3ct::module::Monitor_mpi::monitors;\n+std::thread::id aff3ct::module::Monitor_mpi::master_thread_id;\n+std::chrono::nanoseconds aff3ct::module::Monitor_mpi::d_mpi_comm_frequency;\n+std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> aff3ct::module::Monitor_mpi::t_last_mpi_comm;\n+\n+\n+Monitor_mpi\n+::Monitor_mpi()\n+{\n+ Monitor_mpi::add_monitor(this);\n+ Monitor_mpi::reset();\n+}\n+\n+void Monitor_mpi\n+::add_monitor(Monitor_mpi* m)\n+{\n+ monitors.push_back(m);\n+}\n+\n+void Monitor_mpi\n+::reset()\n+{\n+ t_last_mpi_comm = std::chrono::steady_clock::now();\n+ d_mpi_comm_frequency = std::chrono::milliseconds(1000);\n+}\n+\n+void Monitor_mpi\n+::reduce(bool fully)\n+{\n+ // only the master thread can do this\n+ if (std::this_thread::get_id() == master_thread_id &&\n+ ((std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_mpi_comm_frequency))\n+ {\n+ fully = false;\n+\n+ for(auto& m : monitors)\n+ m->_reduce(fully);\n+\n+ t_last_mpi_comm = std::chrono::steady_clock::now();\n+ }\n+}\n+\n+void Monitor_mpi\n+::set_master_thread_id(std::thread::id t)\n+{\n+ master_thread_id = t;\n+}\n+\n+void Monitor_mpi\n+::set_mpi_comm_frequency(std::chrono::nanoseconds d)\n+{\n+ d_mpi_comm_frequency = d;\n+}\n+\n+\n+#endif // ENABLE_MPI\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hpp", "new_path": "src/Module/Monitor/Monitor_reduction_mpi.hpp", "diff": "@@ -15,26 +15,47 @@ namespace aff3ct\n{\nnamespace module\n{\n-template <class M> // M is the monitor on which must be applied the reduction\n-class Monitor_reduction_mpi : public Monitor_reduction<M>\n+\n+class Monitor_mpi\n{\n+public:\n+ static void reduce(bool fully = false);\n+\n+ static void set_master_thread_id (std::thread::id );\n+ static void set_mpi_comm_frequency(std::chrono::nanoseconds);\n+\n+protected:\n+ Monitor_mpi();\n+\n+ virtual void _reduce(bool fully = false) = 0;\n+\nprivate:\n- const std::thread::id master_thread_id;\n- const std::chrono::nanoseconds d_mpi_comm_frequency;\n+ static void add_monitor(Monitor_mpi*);\n+ static void reset();\n- std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> t_last_mpi_comm;\n+ static std::vector<Monitor_mpi*> monitors;\n+ static std::thread::id master_thread_id;\n+ static std::chrono::nanoseconds d_mpi_comm_frequency;\n+ static std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> t_last_mpi_comm;\n+};\n+\n+\n+template <class M> // M is the monitor on which must be applied the reduction\n+class Monitor_reduction_mpi : public Monitor_mpi, public Monitor_reduction<M>\n+{\n+private:\nMPI_Datatype MPI_monitor_vals;\nMPI_Op MPI_SUM_monitor_vals;\npublic:\n- Monitor_reduction_mpi(const std::vector<M*> &monitors,\n- const std::thread::id master_thread_id,\n- const std::chrono::nanoseconds d_mpi_comm_frequency = std::chrono::milliseconds(1000));\n+ Monitor_reduction_mpi(const std::vector<M*> &monitors);\nvirtual ~Monitor_reduction_mpi() = default;\nvoid reset();\n- void reduce(bool fully = false);\n+\n+protected:\n+ void _reduce(bool fully = false);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hxx", "new_path": "src/Module/Monitor/Monitor_reduction_mpi.hxx", "diff": "@@ -33,13 +33,9 @@ void MPI_SUM_monitor_vals_func(void *in, void *inout, int *len, MPI_Datatype *da\ntemplate <class M>\nMonitor_reduction_mpi<M>\n-::Monitor_reduction_mpi(const std::vector<M*> &monitors,\n- const std::thread::id master_thread_id,\n- const std::chrono::nanoseconds d_mpi_comm_frequency)\n-: Monitor_reduction<M>(monitors),\n- master_thread_id(master_thread_id),\n- d_mpi_comm_frequency(d_mpi_comm_frequency),\n- t_last_mpi_comm(std::chrono::steady_clock::now())\n+::Monitor_reduction_mpi(const std::vector<M*> &monitors)\n+: Monitor_mpi(),\n+ Monitor_reduction<M>(monitors)\n{\nconst std::string name = \"Monitor_reduction_mpi<\" + monitors[0]->get_name() + \">\";\nthis->set_name(name);\n@@ -93,13 +89,7 @@ Monitor_reduction_mpi<M>\ntemplate <class M>\nvoid Monitor_reduction_mpi<M>\n-::reduce(bool fully)\n-{\n- fully = false;\n-\n- // only the master thread can do this\n- if (std::this_thread::get_id() == this->master_thread_id &&\n- ((std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_mpi_comm_frequency))\n+::_reduce(bool fully)\n{\nMonitor_reduction<M>::reduce(fully);\n@@ -111,9 +101,6 @@ void Monitor_reduction_mpi<M>\nMPI_monitor_vals, MPI_SUM_monitor_vals, MPI_COMM_WORLD);\nM::copy(mvals_recv);\n-\n- t_last_mpi_comm = std::chrono::steady_clock::now();\n- }\n}\ntemplate <class M>\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.cpp", "new_path": "src/Simulation/BFER/BFER.cpp", "diff": "@@ -80,9 +80,7 @@ BFER<B,R,Q>\n#ifdef ENABLE_MPI\n// build a monitor to compute BER/FER (reduce the other monitors)\n- this->monitor_er_red = new module::Monitor_reduction_mpi<Monitor_BFER_type>(this->monitor_er,\n- std::this_thread::get_id(),\n- params_BFER.mpi_comm_freq);\n+ this->monitor_er_red = new module::Monitor_reduction_mpi<Monitor_BFER_type>(this->monitor_er);\n#else\n// build a monitor to compute BER/FER (reduce the other monitors)\nthis->monitor_er_red = new Monitor_BFER_reduction_type(this->monitor_er);\n@@ -100,15 +98,19 @@ BFER<B,R,Q>\n#ifdef ENABLE_MPI\n// build a monitor to compute BER/FER (reduce the other monitors)\n- this->monitor_mi_red = new module::Monitor_reduction_mpi<Monitor_MI_type>(this->monitor_mi,\n- std::this_thread::get_id(),\n- params_BFER.mpi_comm_freq);\n+ this->monitor_mi_red = new module::Monitor_reduction_mpi<Monitor_MI_type>(this->monitor_mi);\n#else\n// build a monitor to compute BER/FER (reduce the other monitors)\nthis->monitor_mi_red = new Monitor_MI_reduction_type(this->monitor_mi);\n#endif\n}\n+\n+ #ifdef ENABLE_MPI\n+ module::Monitor_mpi::set_master_thread_id (std::this_thread::get_id());\n+ module::Monitor_mpi::set_mpi_comm_frequency(params_BFER.mpi_comm_freq );\n+ #endif\n+\nif (!params_BFER.noise->pdf_path.empty())\ndistributions = new tools::Distributions<R>(params_BFER.noise->pdf_path);\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": "#include <chrono>\n#include <thread>\n+#ifdef ENABLE_MPI\n+#include \"Module/Monitor/Monitor_reduction_mpi.hpp\"\n+#endif\n+\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Display/rang_format/rang_format.h\"\n@@ -468,8 +472,12 @@ void BFER_ite_threads<B,R,Q>\nmonitor[mnt::tsk::check_errors].exec();\n+#ifndef ENABLE_MPI\nif (tid == 0)\nthis->monitor_er_red->reduce(false);\n+#else\n+ module::Monitor_mpi::reduce(false);\n+#endif\n}\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": "#include <chrono>\n#include <thread>\n+#ifdef ENABLE_MPI\n+#include \"Module/Monitor/Monitor_reduction_mpi.hpp\"\n+#endif\n+\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Display/rang_format/rang_format.h\"\n@@ -374,12 +378,19 @@ void BFER_std_threads<B,R,Q>\nmonitor[mnt::tsk::get_mutual_info].exec();\n+#ifndef ENABLE_MPI\nif (tid == 0)\nthis->monitor_mi_red->reduce(false);\n+#endif\n}\n+#ifndef ENABLE_MPI\nif (tid == 0)\nthis->monitor_er_red->reduce(false);\n+#else\n+ module::Monitor_mpi::reduce(false);\n+#endif\n+\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix monitor MPI communication issues by adding a mother class Monitor_mpi that manage the communications between different monitors sequentially
8,483
13.07.2018 18:43:50
-7,200
6b6c2bef37982c71ac93e77a4a6b4b63852a9a64
Add correctly the monitor_mpi::reduce when the simulation loop finished
[ { "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": "@@ -54,7 +54,11 @@ void BFER_ite_threads<B,R,Q>\nfor (auto tid = 1; tid < this->params_BFER_ite.n_threads; tid++)\nthreads[tid -1].join();\n+#ifndef ENABLE_MPI\nthis->monitor_er_red->reduce(true);\n+#else\n+ module::Monitor_mpi::reduce(true);\n+#endif\nif (!this->prev_err_messages.empty())\nthrow std::runtime_error(this->prev_err_messages.back());\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": "@@ -54,11 +54,13 @@ void BFER_std_threads<B,R,Q>\nfor (auto tid = 1; tid < this->params_BFER_std.n_threads; tid++)\nthreads[tid -1].join();\n-\n+#ifndef ENABLE_MPI\nthis->monitor_er_red->reduce(true);\n-\nif (this->params_BFER_std.mutinfo) // this->monitor_mi_red != nullptr\nthis->monitor_mi_red->reduce(true);\n+#else\n+ module::Monitor_mpi::reduce(true);\n+#endif\nif (!this->prev_err_messages_to_display.empty())\nthrow std::runtime_error(this->prev_err_messages_to_display.back());\n" } ]
C++
MIT License
aff3ct/aff3ct
Add correctly the monitor_mpi::reduce when the simulation loop finished
8,488
16.07.2018 09:25:43
-7,200
01c7b4fee819572ea1e4ec4eca69d4af72ba4df2
Implement 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": "@@ -31,26 +31,27 @@ void Frozenbits_generator_BEC\nthis->best_channels[i] = i;\nfor (auto i = 0; i < std::exp2(m); i++)\n- z[i] = 2.0 / std::pow((double)this->n->get_noise(), 2.0);\n+ z[i] = static_cast<double>(this->n->get_noise());\nfor (auto l = 1; l <= m; l++)\n{\nauto o1 = (int)std::exp2(m - l +1);\nauto o2 = (int)std::exp2(m - l );\n-// for (auto t = 0; t < (int)std::exp2(l -1); t++)\n-// {\n-// double T = z[t * o1];\n-//\n-// z[t * o1] = phi_inv(1.0 - std::pow(1.0 - phi(T), 2.0));\n-// if (z[t * o1] == HUGE_VAL)\n-// z[t * o1] = T + M_LN2 / (alpha * gamma);\n-//\n-// z[t * o1 + o2] = 2.0 * T;\n-// }\n+ for (auto t = 0; t < (int)std::exp2(l -1); t++)\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+ }\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+// for (auto chan : this->best_channels)\n+// std::cout << chan << \" \";\n+// std::cout << std::endl;\n}\nvoid Frozenbits_generator_BEC\n" } ]
C++
MIT License
aff3ct/aff3ct
Implement BEC frozen bits generator.
8,483
16.07.2018 09:46:41
-7,200
9559535aeac3113bb9649fe54f7d1a1afc149985
Enhance regression test command line creation; Add argument for mpi host file
[ { "change_type": "MODIFY", "old_path": "ci/test-regression.py", "new_path": "ci/test-regression.py", "diff": "@@ -32,6 +32,7 @@ parser.add_argument('--weak-rate', action='store', dest='weakRate', ty\nparser.add_argument('--max-snr-time', action='store', dest='maxSNRTime', type=int, default=600, help='The maximum amount of time to spend to compute a noise point in seconds (0 = illimited)') # choices=xrange(0, +inf)\nparser.add_argument('--verbose', action='store', dest='verbose', type=bool, default=False, help='Enable the verbose mode.')\nparser.add_argument('--mpi-np', action='store', dest='mpinp', type=int, default=0, help='Enable MPI run with the given number of process each running on \"--n-threads\" threads.')\n+parser.add_argument('--mpi-host', action='store', dest='mpihost', type=str, default=\"\", help='Run MPI with the given hosts (file).')\n# supported file extensions (filename suffix)\nextensions = ['.txt', '.perf', '.data', '.dat']\n@@ -463,6 +464,7 @@ print('# weak rate =', args.weakRate )\nprint('# max snr time =', args.maxSNRTime )\nprint('# verbose =', args.verbose )\nprint('# MPI nbr proc =', args.mpinp )\n+print('# MPI host file =', args.mpihost )\nprint('#')\nPathOrigin = os.getcwd()\n@@ -508,40 +510,42 @@ for fn in fileNames:\n# parse the reference file\nsimuRef = dataReader(lines)\n- # get the command line to run\n- argsAFFECT = splitAsCommand(simuRef.RunCommand)\n+ argsAFFECT = []\n+\n+ if args.mpinp > 0 or args.mpihost != \"\":\n+ argsAFFECT += [\"mpirun\", \"--map-by\", \"socket\"]\nif args.mpinp > 0:\n- argsAFFECT.insert(0, str(args.mpinp))\n- argsAFFECT.insert(0, \"-np\")\n- argsAFFECT.insert(0, \"mpirun\")\n+ argsAFFECT += [\"-np\", str(args.mpinp)]\n+\n+ if args.mpihost != \"\":\n+ argsAFFECT += [\"--hostfile\", str(args.mpihost)]\n+\n+\n+ # get the command line to run\n+ argsAFFECT += splitAsCommand(simuRef.RunCommand)\n- argsAFFECT.append(\"--ter-freq\")\n- argsAFFECT.append(\"0\")\n+ argsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-no-colors\"]\nif args.maxFE:\n- argsAFFECT.append(\"-e\")\n- argsAFFECT.append(str(args.maxFE))\n- argsAFFECT.append(\"-t\")\n- argsAFFECT.append(str(args.nThreads))\n- argsAFFECT.append(\"--sim-no-colors\")\n+ argsAFFECT += [\"-e\", str(args.maxFE)]\n+\nif args.maxSNRTime:\n- argsAFFECT.append(\"--sim-stop-time\")\n- argsAFFECT.append(str(args.maxSNRTime))\n+ argsAFFECT += [\"--sim-stop-time\", str(args.maxSNRTime)]\n+\nnoiseVals = \"\"\nfor n in range(len(simuRef.Noise)):\nif n != 0:\nnoiseVals += \",\";\n-\nnoiseVals += str(simuRef.Noise[n])\n- argsAFFECT.append(\"-R\")\n- argsAFFECT.append(noiseVals)\n+\n+ argsAFFECT += [\"-R\", noiseVals]\nif simuRef.NoiseType == \"Eb/N0\":\n- argsAFFECT.append(\"-E\")\n- argsAFFECT.append(\"EBN0\")\n+ argsAFFECT += [\"-E\", \"EBN0\"]\n+\n# run the tested simulator\n" } ]
C++
MIT License
aff3ct/aff3ct
Enhance regression test command line creation; Add argument for mpi host file
8,483
16.07.2018 10:07:06
-7,200
94d0237c9302ffb0618f7af7e74a5c2eaac453b9
Cosmetics: factorize aff3ct command generation
[ { "change_type": "MODIFY", "old_path": "ci/test-regression.py", "new_path": "ci/test-regression.py", "diff": "@@ -486,9 +486,37 @@ if (len(fileNames) - (args.startId -1) > 0) :\nelse:\nprint(\"# (WW) There is no simulation to replay.\")\n+\n+\n+argsAFFECTcommand = []\n+\n+if args.mpinp > 0 or args.mpihost != \"\":\n+ argsAFFECTcommand += [\"mpirun\", \"--map-by\", \"socket\"]\n+\n+ if args.mpinp > 0:\n+ argsAFFECTcommand += [\"-np\", str(args.mpinp)]\n+\n+ if args.mpihost != \"\":\n+ argsAFFECTcommand += [\"--hostfile\", str(args.mpihost)]\n+\n+\n+argsAFFECTcommand += [\"./bin/aff3ct\"]\n+\n+\n+argsAFFECTcommand += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-no-colors\"]\n+if args.maxFE:\n+ argsAFFECTcommand += [\"-e\", str(args.maxFE)]\n+\n+if args.maxSNRTime:\n+ argsAFFECTcommand += [\"--sim-stop-time\", str(args.maxSNRTime)]\n+\n+\n+\nfailIds = []\nnErrors = 0\ntestId = 0\n+\n+\nfor fn in fileNames:\nif testId < args.startId -1:\ntestId = testId + 1\n@@ -510,29 +538,10 @@ for fn in fileNames:\n# parse the reference file\nsimuRef = dataReader(lines)\n- argsAFFECT = []\n-\n- if args.mpinp > 0 or args.mpihost != \"\":\n- argsAFFECT += [\"mpirun\", \"--map-by\", \"socket\"]\n-\n- if args.mpinp > 0:\n- argsAFFECT += [\"-np\", str(args.mpinp)]\n-\n- if args.mpihost != \"\":\n- argsAFFECT += [\"--hostfile\", str(args.mpihost)]\n-\n# get the command line to run\n- argsAFFECT += splitAsCommand(simuRef.RunCommand)\n-\n-\n- argsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-no-colors\"]\n- if args.maxFE:\n- argsAFFECT += [\"-e\", str(args.maxFE)]\n-\n- if args.maxSNRTime:\n- argsAFFECT += [\"--sim-stop-time\", str(args.maxSNRTime)]\n-\n+ argsAFFECT = argsAFFECTcommand\n+ argsAFFECT += splitAsCommand(simuRef.RunCommand)[1:]\nnoiseVals = \"\"\nfor n in range(len(simuRef.Noise)):\n" } ]
C++
MIT License
aff3ct/aff3ct
Cosmetics: factorize aff3ct command generation
8,483
16.07.2018 10:34:09
-7,200
4ab2274d0bf9807ae1bb65a473490b7e7050d137
Fix terminal display frequency to the MPI frequency by default
[ { "change_type": "MODIFY", "old_path": "src/Launcher/Simulation/BFER_ite.cpp", "new_path": "src/Launcher/Simulation/BFER_ite.cpp", "diff": "@@ -178,6 +178,13 @@ void BFER_ite<B,R,Q>\nparams.chn-> n_frames = params.src->n_frames;\nparams.qnt-> n_frames = params.src->n_frames;\nparams.mnt_er-> n_frames = params.src->n_frames;\n+\n+\n+#ifdef ENABLE_MPI\n+ auto pter = params.ter->get_prefix();\n+ if (!this->arg_vals.exist({pter+\"-freq\"}))\n+ params.ter->frequency = params.mpi_comm_freq;\n+#endif\n}\ntemplate <typename B, typename R, typename Q>\n" }, { "change_type": "MODIFY", "old_path": "src/Launcher/Simulation/BFER_std.cpp", "new_path": "src/Launcher/Simulation/BFER_std.cpp", "diff": "@@ -185,6 +185,14 @@ void BFER_std<B,R,Q>\nparams.qnt ->n_frames = params.src->n_frames;\nparams.mnt_er->n_frames = params.src->n_frames;\nparams.mnt_mi->n_frames = params.src->n_frames;\n+\n+\n+#ifdef ENABLE_MPI\n+ auto pter = params.ter->get_prefix();\n+ if (!this->arg_vals.exist({pter+\"-freq\"}))\n+ params.ter->frequency = params.mpi_comm_freq;\n+#endif\n+\n}\ntemplate <typename B, typename R, typename Q>\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix terminal display frequency to the MPI frequency by default
8,483
16.07.2018 10:38:55
-7,200
d63e4a2a3e0b8d52b5b095849400c9e8ce4f70fc
Only thread 0 can call mpi reduce also in BFERI simu
[ { "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": "@@ -480,6 +480,7 @@ void BFER_ite_threads<B,R,Q>\nif (tid == 0)\nthis->monitor_er_red->reduce(false);\n#else\n+ if (tid == 0)\nmodule::Monitor_mpi::reduce(false);\n#endif\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Only thread 0 can call mpi reduce also in BFERI simu
8,483
16.07.2018 14:37:12
-7,200
8447d38a8a0b3ddd1226e8907d61f750fda08c69
Add a force parameter to the reduce method of Monitor MPI, to force the reduce at the whole end of the simulation
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.cpp", "new_path": "src/Module/Monitor/Monitor_reduction_mpi.cpp", "diff": "@@ -34,11 +34,11 @@ void Monitor_mpi\n}\nvoid Monitor_mpi\n-::reduce(bool fully)\n+::reduce(bool fully, bool force)\n{\n// only the master thread can do this\n- if (std::this_thread::get_id() == master_thread_id &&\n- ((std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_mpi_comm_frequency))\n+ if (force || (std::this_thread::get_id() == master_thread_id &&\n+ ((std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_mpi_comm_frequency)))\n{\nfully = false;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hpp", "new_path": "src/Module/Monitor/Monitor_reduction_mpi.hpp", "diff": "@@ -19,7 +19,7 @@ namespace module\nclass Monitor_mpi\n{\npublic:\n- static void reduce(bool fully = false);\n+ static void reduce(bool fully = false, bool force = false);\nstatic void set_master_thread_id (std::thread::id );\nstatic void set_mpi_comm_frequency(std::chrono::nanoseconds);\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": "@@ -57,7 +57,7 @@ void BFER_ite_threads<B,R,Q>\n#ifndef ENABLE_MPI\nthis->monitor_er_red->reduce(true);\n#else\n- module::Monitor_mpi::reduce(true);\n+ module::Monitor_mpi::reduce(true, true);\n#endif\nif (!this->prev_err_messages.empty())\n@@ -480,7 +480,6 @@ void BFER_ite_threads<B,R,Q>\nif (tid == 0)\nthis->monitor_er_red->reduce(false);\n#else\n- if (tid == 0)\nmodule::Monitor_mpi::reduce(false);\n#endif\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": "@@ -59,7 +59,7 @@ void BFER_std_threads<B,R,Q>\nif (this->params_BFER_std.mutinfo) // this->monitor_mi_red != nullptr\nthis->monitor_mi_red->reduce(true);\n#else\n- module::Monitor_mpi::reduce(true);\n+ module::Monitor_mpi::reduce(true, true);\n#endif\nif (!this->prev_err_messages_to_display.empty())\n@@ -390,8 +390,7 @@ void BFER_std_threads<B,R,Q>\nif (tid == 0)\nthis->monitor_er_red->reduce(false);\n#else\n- if (tid == 0)\n- module::Monitor_mpi::reduce(false);\n+ module::Monitor_mpi::reduce(false); // if (tid == 0) done inside\n#endif\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Add a force parameter to the reduce method of Monitor MPI, to force the reduce at the whole end of the simulation
8,483
16.07.2018 14:47:11
-7,200
463ad37d0ec4f81531d93a08c4befbfbfb22c56b
Fix the regression test script with a copy by value of the arg list and not by reference
[ { "change_type": "MODIFY", "old_path": "ci/test-regression.py", "new_path": "ci/test-regression.py", "diff": "@@ -528,7 +528,7 @@ for fn in fileNames:\n# get the command line to run\n- argsAFFECT = argsAFFECTcommand\n+ argsAFFECT = argsAFFECTcommand[:]\nargsAFFECT += splitAsCommand(simuRef.RunCommand)\nargsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-no-colors\"]\n@@ -552,7 +552,6 @@ for fn in fileNames:\nargsAFFECT += [\"-E\", \"EBN0\"]\n-\n# run the tested simulator\nos.chdir(args.buildPath)\nstartTime = time.time()\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the regression test script with a copy by value of the arg list and not by reference
8,483
16.07.2018 18:11:56
-7,200
60f81efb5a40bce33ba16e099274008c8db8f6c4
Create Monitor_reduction parent of Monitor_reduction_M<M> to have a generic interface with and without MPI
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor.hpp", "new_path": "src/Module/Monitor/Monitor.hpp", "diff": "@@ -40,9 +40,6 @@ namespace module\n*\n* \\brief Monitors the simulated frames, tells if there is a frame errors and counts the number of bit errors.\n*\n- * \\tparam B: type of the bits in the frames to compare.\n- * \\tparam R: type of the samples in the channel frame.\n- *\n* Please use Monitor for inheritance (instead of Monitor).\n*/\nclass Monitor : public Module\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/Module/Monitor/Monitor_reduction.cpp", "diff": "+#include <sstream>\n+#include \"Tools/Exception/exception.hpp\"\n+\n+#include \"Monitor_reduction.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+std::vector<aff3ct::module::Monitor_reduction*> aff3ct::module::Monitor_reduction::monitors;\n+std::thread::id aff3ct::module::Monitor_reduction::master_thread_id = std::this_thread::get_id();\n+std::chrono::nanoseconds aff3ct::module::Monitor_reduction::d_reduce_frequency = std::chrono::milliseconds(1000);\n+std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> aff3ct::module::Monitor_reduction::t_last_mpi_comm;\n+\n+\n+Monitor_reduction\n+::Monitor_reduction()\n+{\n+ Monitor_reduction::add_monitor(this);\n+ Monitor_reduction::reset();\n+}\n+\n+void Monitor_reduction\n+::add_monitor(Monitor_reduction* m)\n+{\n+ monitors.push_back(m);\n+}\n+\n+void Monitor_reduction\n+::reset()\n+{\n+ master_thread_id = std::this_thread::get_id();\n+ t_last_mpi_comm = std::chrono::steady_clock::now();\n+}\n+\n+void Monitor_reduction\n+::reduce(bool fully, bool force)\n+{\n+ // only the master thread can do this\n+ if (force ||\n+ (std::this_thread::get_id() == master_thread_id &&\n+ (std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_reduce_frequency)\n+ )\n+ {\n+ for(auto& m : monitors)\n+ m->_reduce(fully);\n+\n+ t_last_mpi_comm = std::chrono::steady_clock::now();\n+ }\n+}\n+\n+void Monitor_reduction\n+::set_master_thread_id(std::thread::id t)\n+{\n+ master_thread_id = t;\n+}\n+\n+void Monitor_reduction\n+::set_reduce_frequency(std::chrono::nanoseconds d)\n+{\n+ d_reduce_frequency = d;\n+}\n+\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.hpp", "new_path": "src/Module/Monitor/Monitor_reduction.hpp", "diff": "#ifndef MONITOR_REDUCTION_HPP_\n#define MONITOR_REDUCTION_HPP_\n+#include <thread>\n#include <string>\n#include <vector>\n#include <cassert>\n@@ -11,8 +12,35 @@ namespace aff3ct\n{\nnamespace module\n{\n+\n+class Monitor_reduction\n+{\n+public:\n+ static void reduce(bool fully = false, bool force = false);\n+\n+ static void set_master_thread_id(std::thread::id t);\n+ static void set_reduce_frequency(std::chrono::nanoseconds d);\n+\n+protected:\n+ Monitor_reduction();\n+ virtual ~Monitor_reduction() = default;\n+\n+ virtual void _reduce(bool fully = false) = 0;\n+\n+private:\n+ static void add_monitor(Monitor_reduction*);\n+ static void reset();\n+\n+ static std::vector<Monitor_reduction*> monitors;\n+ static std::thread::id master_thread_id;\n+ static std::chrono::nanoseconds d_reduce_frequency;\n+\n+ static std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> t_last_mpi_comm;\n+};\n+\n+\ntemplate <class M> // M is the monitor on which must be applied the reduction\n-class Monitor_reduction : public M\n+class Monitor_reduction_M : public Monitor_reduction, public M\n{\nstatic_assert(std::is_base_of<Monitor, M>::value, \"M shall be based on a module::Monitor class.\");\n@@ -20,12 +48,14 @@ private:\nstd::vector<M*> monitors;\npublic:\n- explicit Monitor_reduction(const std::vector<M*> &monitors);\n- virtual ~Monitor_reduction() = default;\n+ explicit Monitor_reduction_M(const std::vector<M*> &monitors);\n+ virtual ~Monitor_reduction_M() = default;\nvirtual void reset();\nvirtual void clear_callbacks();\n- virtual void reduce(bool fully = false);\n+\n+protected:\n+ virtual void _reduce(bool fully = false);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.hxx", "new_path": "src/Module/Monitor/Monitor_reduction.hxx", "diff": "@@ -13,9 +13,10 @@ namespace module\n{\ntemplate <class M>\n-Monitor_reduction<M>\n-::Monitor_reduction(const std::vector<M*> &_monitors)\n-: M((_monitors.size() && _monitors.front()) ? *_monitors.front() : M(),\n+Monitor_reduction_M<M>\n+::Monitor_reduction_M(const std::vector<M*> &_monitors)\n+: Monitor_reduction(),\n+ M((_monitors.size() && _monitors.front()) ? *_monitors.front() : M(),\nstd::accumulate(_monitors.begin(), _monitors.end(), 0,\n[](int tot, const M* m) { return tot + m->get_n_frames(); })),\nmonitors(_monitors)\n@@ -27,7 +28,7 @@ Monitor_reduction<M>\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- const std::string name = \"Monitor_reduction<\" + monitors[0]->get_name() + \">\";\n+ const std::string name = \"Monitor_reduction_M<\" + monitors[0]->get_name() + \">\";\nthis->set_name(name);\nfor (size_t m = 0; m < monitors.size(); m++)\n@@ -60,7 +61,7 @@ Monitor_reduction<M>\n}\ntemplate <class M>\n-void Monitor_reduction<M>\n+void Monitor_reduction_M<M>\n::reset()\n{\nM::reset();\n@@ -70,7 +71,7 @@ void Monitor_reduction<M>\n}\ntemplate <class M>\n-void Monitor_reduction<M>\n+void Monitor_reduction_M<M>\n::clear_callbacks()\n{\nM::clear_callbacks();\n@@ -80,8 +81,8 @@ void Monitor_reduction<M>\n}\ntemplate <class M>\n-void Monitor_reduction<M>\n-::reduce(bool fully)\n+void Monitor_reduction_M<M>\n+::_reduce(bool fully)\n{\nM collecter(*this);\n" }, { "change_type": "DELETE", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.cpp", "new_path": null, "diff": "-#ifdef ENABLE_MPI\n-#include <sstream>\n-#include \"Tools/Exception/exception.hpp\"\n-\n-#include \"Monitor_reduction_mpi.hpp\"\n-\n-using namespace aff3ct;\n-using namespace aff3ct::module;\n-\n-std::vector<aff3ct::module::Monitor_mpi*> aff3ct::module::Monitor_mpi::monitors;\n-std::thread::id aff3ct::module::Monitor_mpi::master_thread_id;\n-std::chrono::nanoseconds aff3ct::module::Monitor_mpi::d_mpi_comm_frequency;\n-std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> aff3ct::module::Monitor_mpi::t_last_mpi_comm;\n-\n-\n-Monitor_mpi\n-::Monitor_mpi()\n-{\n- Monitor_mpi::add_monitor(this);\n- Monitor_mpi::reset();\n-}\n-\n-void Monitor_mpi\n-::add_monitor(Monitor_mpi* m)\n-{\n- monitors.push_back(m);\n-}\n-\n-void Monitor_mpi\n-::reset()\n-{\n- t_last_mpi_comm = std::chrono::steady_clock::now();\n- d_mpi_comm_frequency = std::chrono::milliseconds(1000);\n-}\n-\n-void Monitor_mpi\n-::reduce(bool fully, bool force)\n-{\n- // only the master thread can do this\n- if (force || (std::this_thread::get_id() == master_thread_id &&\n- ((std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_mpi_comm_frequency)))\n- {\n- fully = false;\n-\n- for(auto& m : monitors)\n- m->_reduce(fully);\n-\n- t_last_mpi_comm = std::chrono::steady_clock::now();\n- }\n-}\n-\n-void Monitor_mpi\n-::set_master_thread_id(std::thread::id t)\n-{\n- master_thread_id = t;\n-}\n-\n-void Monitor_mpi\n-::set_mpi_comm_frequency(std::chrono::nanoseconds d)\n-{\n- d_mpi_comm_frequency = d;\n-}\n-\n-\n-#endif // ENABLE_MPI\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hpp", "new_path": "src/Module/Monitor/Monitor_reduction_mpi.hpp", "diff": "#ifndef MONITOR_REDUCTION_MPI_HPP_\n#define MONITOR_REDUCTION_MPI_HPP_\n-#include <thread>\n-#include <chrono>\n-#include <vector>\n-\n#include <mpi.h>\n#include \"Monitor_reduction.hpp\"\n@@ -15,34 +11,8 @@ namespace aff3ct\n{\nnamespace module\n{\n-\n-class Monitor_mpi\n-{\n-public:\n- static void reduce(bool fully = false, bool force = false);\n-\n- static void set_master_thread_id (std::thread::id );\n- static void set_mpi_comm_frequency(std::chrono::nanoseconds);\n-\n-protected:\n- Monitor_mpi();\n-\n- virtual void _reduce(bool fully = false) = 0;\n-\n-private:\n- static void add_monitor(Monitor_mpi*);\n- static void reset();\n-\n- static std::vector<Monitor_mpi*> monitors;\n- static std::thread::id master_thread_id;\n- static std::chrono::nanoseconds d_mpi_comm_frequency;\n-\n- static std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> t_last_mpi_comm;\n-};\n-\n-\ntemplate <class M> // M is the monitor on which must be applied the reduction\n-class Monitor_reduction_mpi : public Monitor_mpi, public Monitor_reduction<M>\n+class Monitor_reduction_mpi : public Monitor_reduction_M<M>\n{\nprivate:\nMPI_Datatype MPI_monitor_vals;\n@@ -55,7 +25,7 @@ public:\nvoid reset();\nprotected:\n- void _reduce(bool fully = false);\n+ virtual void _reduce(bool fully = false);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hxx", "new_path": "src/Module/Monitor/Monitor_reduction_mpi.hxx", "diff": "@@ -34,8 +34,7 @@ void MPI_SUM_monitor_vals_func(void *in, void *inout, int *len, MPI_Datatype *da\ntemplate <class M>\nMonitor_reduction_mpi<M>\n::Monitor_reduction_mpi(const std::vector<M*> &monitors)\n-: Monitor_mpi(),\n- Monitor_reduction<M>(monitors)\n+: Monitor_reduction_M<M>(monitors)\n{\nconst std::string name = \"Monitor_reduction_mpi<\" + monitors[0]->get_name() + \">\";\nthis->set_name(name);\n@@ -91,7 +90,9 @@ template <class M>\nvoid Monitor_reduction_mpi<M>\n::_reduce(bool fully)\n{\n- Monitor_reduction<M>::reduce(fully);\n+ fully = false;\n+\n+ Monitor_reduction_M<M>::_reduce(fully);\ntypename M::Vals_mpi mvals_recv;\n@@ -107,9 +108,7 @@ template <class M>\nvoid Monitor_reduction_mpi<M>\n::reset()\n{\n- Monitor_reduction<M>::reset();\n-\n- t_last_mpi_comm = std::chrono::steady_clock::now();\n+ Monitor_reduction_M<M>::reset();\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.cpp", "new_path": "src/Simulation/BFER/BFER.cpp", "diff": "#include \"Tools/Display/Statistics/Statistics.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n-#ifdef ENABLE_MPI\n-#include \"Module/Monitor/Monitor_reduction_mpi.hpp\"\n-#endif\n-\n#include \"Factory/Module/Monitor/Monitor.hpp\"\n#include \"Factory/Tools/Display/Terminal/Terminal.hpp\"\n@@ -78,13 +74,8 @@ BFER<B,R,Q>\nmodules[\"monitor_er\"][tid] = this->monitor_er[tid];\n}\n- #ifdef ENABLE_MPI\n- // build a monitor to compute BER/FER (reduce the other monitors)\n- this->monitor_er_red = new module::Monitor_reduction_mpi<Monitor_BFER_type>(this->monitor_er);\n- #else\n// build a monitor to compute BER/FER (reduce the other monitors)\nthis->monitor_er_red = new Monitor_BFER_reduction_type(this->monitor_er);\n- #endif\nif (params_BFER.mutinfo)\n@@ -96,19 +87,14 @@ BFER<B,R,Q>\nmodules[\"monitor_mi\"][tid] = this->monitor_mi[tid];\n}\n- #ifdef ENABLE_MPI\n- // build a monitor to compute BER/FER (reduce the other monitors)\n- this->monitor_mi_red = new module::Monitor_reduction_mpi<Monitor_MI_type>(this->monitor_mi);\n- #else\n- // build a monitor to compute BER/FER (reduce the other monitors)\n+ // build a monitor to compute MI (reduce the other monitors)\nthis->monitor_mi_red = new Monitor_MI_reduction_type(this->monitor_mi);\n- #endif\n}\n+ module::Monitor_reduction::set_master_thread_id(std::this_thread::get_id());\n#ifdef ENABLE_MPI\n- module::Monitor_mpi::set_master_thread_id (std::this_thread::get_id());\n- module::Monitor_mpi::set_mpi_comm_frequency(params_BFER.mpi_comm_freq );\n+ module::Monitor_reduction::set_reduce_frequency(params_BFER.mpi_comm_freq);\n#endif\nif (!params_BFER.noise->pdf_path.empty())\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.hpp", "new_path": "src/Simulation/BFER/BFER.hpp", "diff": "#include \"Module/Monitor/BFER/Monitor_BFER.hpp\"\n#include \"Module/Monitor/Monitor_reduction.hpp\"\n+#ifdef ENABLE_MPI\n+#include \"Module/Monitor/Monitor_reduction_mpi.hpp\"\n+#define FORCE_REDUCE_EVERY_LOOP false\n+#else\n+#define FORCE_REDUCE_EVERY_LOOP true\n+#endif\n+\n#include \"Factory/Simulation/BFER/BFER.hpp\"\n#include \"../Simulation.hpp\"\n@@ -53,10 +60,15 @@ protected:\n// the monitors of the the BFER simulation\nusing Monitor_BFER_type = module::Monitor_BFER<B>;\n- using Monitor_BFER_reduction_type = module::Monitor_reduction<Monitor_BFER_type>;\n-\nusing Monitor_MI_type = module::Monitor_MI<B,R>;\n- using Monitor_MI_reduction_type = module::Monitor_reduction<Monitor_MI_type>;\n+\n+#ifdef ENABLE_MPI\n+ using Monitor_BFER_reduction_type = module::Monitor_reduction_mpi<Monitor_BFER_type>;\n+ using Monitor_MI_reduction_type = module::Monitor_reduction_mpi<Monitor_MI_type >;\n+#else\n+ using Monitor_BFER_reduction_type = module::Monitor_reduction_M<Monitor_BFER_type>;\n+ using Monitor_MI_reduction_type = module::Monitor_reduction_M<Monitor_MI_type >;\n+#endif\nstd::vector<Monitor_MI_type*> monitor_mi;\nMonitor_MI_reduction_type* monitor_mi_red;\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": "#include <chrono>\n#include <thread>\n-#ifdef ENABLE_MPI\n-#include \"Module/Monitor/Monitor_reduction_mpi.hpp\"\n-#endif\n-\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Display/rang_format/rang_format.h\"\n@@ -54,11 +50,7 @@ void BFER_ite_threads<B,R,Q>\nfor (auto tid = 1; tid < this->params_BFER_ite.n_threads; tid++)\nthreads[tid -1].join();\n-#ifndef ENABLE_MPI\n- this->monitor_er_red->reduce(true);\n-#else\n- module::Monitor_mpi::reduce(true, true);\n-#endif\n+ module::Monitor_reduction::reduce(true, true);\nif (!this->prev_err_messages.empty())\nthrow std::runtime_error(this->prev_err_messages.back());\n@@ -476,12 +468,7 @@ void BFER_ite_threads<B,R,Q>\nmonitor[mnt::tsk::check_errors].exec();\n-#ifndef ENABLE_MPI\n- if (tid == 0)\n- this->monitor_er_red->reduce(false);\n-#else\n- module::Monitor_mpi::reduce(false);\n-#endif\n+ module::Monitor_reduction::reduce(false, FORCE_REDUCE_EVERY_LOOP);\n}\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": "#include <chrono>\n#include <thread>\n-#ifdef ENABLE_MPI\n-#include \"Module/Monitor/Monitor_reduction_mpi.hpp\"\n-#endif\n-\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Display/rang_format/rang_format.h\"\n@@ -54,13 +50,9 @@ void BFER_std_threads<B,R,Q>\nfor (auto tid = 1; tid < this->params_BFER_std.n_threads; tid++)\nthreads[tid -1].join();\n-#ifndef ENABLE_MPI\n- this->monitor_er_red->reduce(true);\n- if (this->params_BFER_std.mutinfo) // this->monitor_mi_red != nullptr\n- this->monitor_mi_red->reduce(true);\n-#else\n- module::Monitor_mpi::reduce(true, true);\n-#endif\n+\n+ module::Monitor_reduction::reduce(true, true);\n+\nif (!this->prev_err_messages_to_display.empty())\nthrow std::runtime_error(this->prev_err_messages_to_display.back());\n@@ -379,20 +371,9 @@ void BFER_std_threads<B,R,Q>\nauto &monitor = *this->monitor_mi[tid];\nmonitor[mnt::tsk::get_mutual_info].exec();\n-\n-#ifndef ENABLE_MPI\n- if (tid == 0)\n- this->monitor_mi_red->reduce(false);\n-#endif\n}\n-#ifndef ENABLE_MPI\n- if (tid == 0)\n- this->monitor_er_red->reduce(false);\n-#else\n- module::Monitor_mpi::reduce(false); // if (tid == 0) done inside\n-#endif\n-\n+ module::Monitor_reduction::reduce(false, FORCE_REDUCE_EVERY_LOOP); // if (tid == 0) done inside\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Create Monitor_reduction parent of Monitor_reduction_M<M> to have a generic interface with and without MPI
8,483
17.07.2018 10:53:43
-7,200
ded90ff48db21fdea35a5de6dd2ed0b1c361e032
Refacto simus BFER Create a keep_looping_noise_point function in simu BFER mother class to factorize the simulation while loop condition to keep running or not the noise point. Create sub-routines max_frame_reached() and stop_time_reached(). Clear the simu BFER class constructor by creating sub-routines to build monitors and reporters objects.
[ { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.cpp", "new_path": "src/Simulation/BFER/BFER.cpp", "diff": "@@ -65,59 +65,13 @@ BFER<B,R,Q>\ndumper_red = new tools::Dumper_reduction(dumpers);\n}\n-\n-\n- modules[\"monitor_er\"] = std::vector<module::Module*>(params_BFER.n_threads, nullptr);\n- for (auto tid = 0; tid < params_BFER.n_threads; tid++)\n- {\n- this->monitor_er[tid] = this->build_monitor_er(tid);\n- modules[\"monitor_er\"][tid] = this->monitor_er[tid];\n- }\n-\n- // build a monitor to compute BER/FER (reduce the other monitors)\n- this->monitor_er_red = new Monitor_BFER_reduction_type(this->monitor_er);\n-\n-\n- if (params_BFER.mutinfo)\n- {\n- modules[\"monitor_mi\"] = std::vector<module::Module*>(params_BFER.n_threads, nullptr);\n- for (auto tid = 0; tid < params_BFER.n_threads; tid++)\n- {\n- this->monitor_mi[tid] = this->build_monitor_mi(tid);\n- modules[\"monitor_mi\"][tid] = this->monitor_mi[tid];\n- }\n-\n- // build a monitor to compute MI (reduce the other monitors)\n- this->monitor_mi_red = new Monitor_MI_reduction_type(this->monitor_mi);\n- }\n-\n-\n- module::Monitor_reduction::set_master_thread_id(std::this_thread::get_id());\n- #ifdef ENABLE_MPI\n- module::Monitor_reduction::set_reduce_frequency(params_BFER.mpi_comm_freq);\n- #endif\n-\nif (!params_BFER.noise->pdf_path.empty())\ndistributions = new tools::Distributions<R>(params_BFER.noise->pdf_path);\n+ this->build_monitors ();\n+ this->build_reporters();\n-\n- this->noise = params_BFER.noise->template build<R>(0);\n-\n- rep_noise = new tools::Reporter_noise<R>(&this->noise);\n- reporters.push_back(rep_noise);\n-\n- if (params_BFER.mutinfo)\n- {\n- rep_mi = new tools::Reporter_MI<B,R>(*this->monitor_mi_red);\n- reporters.push_back(rep_mi);\n- }\n-\n- rep_er = new tools::Reporter_BFER<B>(*this->monitor_er_red);\n- reporters.push_back(rep_er);\n-\n- rep_throughput = new tools::Reporter_throughput<uint64_t>(*this->monitor_er_red);\n- reporters.push_back(rep_throughput);\n+ this->terminal = this->build_terminal();\n}\ntemplate <typename B, typename R, typename Q>\n@@ -167,10 +121,7 @@ template <typename B, typename R, typename Q>\nvoid BFER<B,R,Q>\n::launch()\n{\n- this->terminal = this->build_terminal();\n-\n-\n- if (!this->params_BFER.err_track_revert)\n+ if (!params_BFER.err_track_revert)\n{\nthis->build_communication_chain();\n@@ -204,7 +155,7 @@ void BFER<B,R,Q>\nthis->distributions->read_distribution(this->noise->get_noise());\n- if (this->params_BFER.err_track_revert)\n+ if (params_BFER.err_track_revert)\n{\nthis->release_objects();\nthis->monitor_er_red->clear_callbacks();\n@@ -247,10 +198,10 @@ void BFER<B,R,Q>\n}\n}\n- if (params_BFER.display_legend)\n#ifdef ENABLE_MPI\nif (params_BFER.mpi_rank == 0)\n#endif\n+ if (params_BFER.display_legend)\nif ((!params_BFER.ter->disabled && noise_idx == noise_begin && !params_BFER.debug)\n|| (params_BFER.statistics && !params_BFER.debug))\nterminal->legend(std::cout);\n@@ -262,6 +213,9 @@ void BFER<B,R,Q>\nif (!params_BFER.ter->disabled && params_BFER.ter->frequency != std::chrono::nanoseconds(0) && !params_BFER.debug)\nterminal->start_temp_report(params_BFER.ter->frequency);\n+\n+ this->t_start_noise_point = std::chrono::steady_clock::now();\n+\ntry\n{\nthis->_launch();\n@@ -400,6 +354,66 @@ tools::Terminal* BFER<B,R,Q>\nreturn params_BFER.ter->build(this->reporters);\n}\n+template <typename B, typename R, typename Q>\n+void BFER<B,R,Q>\n+::build_reporters()\n+{\n+ this->noise = params_BFER.noise->template build<R>(0);\n+\n+ this->rep_noise = new tools::Reporter_noise<R>(&this->noise);\n+ this->reporters.push_back(this->rep_noise);\n+\n+ if (params_BFER.mutinfo)\n+ {\n+ this->rep_mi = new tools::Reporter_MI<B,R>(*this->monitor_mi_red);\n+ this->reporters.push_back(this->rep_mi);\n+ }\n+\n+ this->rep_er = new tools::Reporter_BFER<B>(*this->monitor_er_red);\n+ this->reporters.push_back(this->rep_er);\n+\n+ this->rep_throughput = new tools::Reporter_throughput<uint64_t>(*this->monitor_er_red);\n+ this->reporters.push_back(this->rep_throughput);\n+\n+}\n+\n+template <typename B, typename R, typename Q>\n+void BFER<B,R,Q>\n+::build_monitors()\n+{\n+ // build a monitor to compute BER/FER on each thread\n+ this->modules[\"monitor_er\"] = std::vector<module::Module*>(params_BFER.n_threads, nullptr);\n+ for (auto tid = 0; tid < params_BFER.n_threads; tid++)\n+ {\n+ this->monitor_er[tid] = this->build_monitor_er(tid);\n+ this->modules[\"monitor_er\"][tid] = this->monitor_er[tid];\n+ }\n+\n+ // build a monitor to reduce BER/FER from the other monitors\n+ this->monitor_er_red = new Monitor_BFER_reduction_type(this->monitor_er);\n+\n+\n+ if (params_BFER.mutinfo)\n+ {\n+ // build a monitor to compute MIon each thread\n+ this->modules[\"monitor_mi\"] = std::vector<module::Module*>(params_BFER.n_threads, nullptr);\n+ for (auto tid = 0; tid < params_BFER.n_threads; tid++)\n+ {\n+ this->monitor_mi[tid] = this->build_monitor_mi(tid);\n+ this->modules[\"monitor_mi\"][tid] = this->monitor_mi[tid];\n+ }\n+\n+ // build a monitor to reduce M from the other monitors\n+ this->monitor_mi_red = new Monitor_MI_reduction_type(this->monitor_mi);\n+ }\n+\n+ module::Monitor_reduction::set_master_thread_id(std::this_thread::get_id());\n+ #ifdef ENABLE_MPI\n+ module::Monitor_reduction::set_reduce_frequency(params_BFER.mpi_comm_freq);\n+ // #else reduction is forced for every loop with macro FORCE_REDUCE_EVERY_LOOP\n+ #endif\n+}\n+\ntemplate <typename B, typename R, typename Q>\nvoid BFER<B,R,Q>\n::start_thread_build_comm_chain(BFER<B,R,Q> *simu, const int tid)\n@@ -434,6 +448,32 @@ void BFER<B,R,Q>\n}\n}\n+template <typename B, typename R, typename Q>\n+bool BFER<B,R,Q>\n+::keep_looping_noise_point()\n+{\n+ // communication chain execution\n+ return !tools::Terminal::is_interrupt() // if user stopped the simulation\n+ && !this->monitor_er_red->fe_limit_achieved() // while max frame error count has not been reached\n+ && !this->stop_time_reached()\n+ && !this->max_frame_reached();\n+}\n+\n+template <typename B, typename R, typename Q>\n+bool BFER<B,R,Q>\n+::max_frame_reached()\n+{\n+ return params_BFER.max_frame > 0 && this->monitor_er_red->get_n_analyzed_fra() >= params_BFER.max_frame;\n+}\n+\n+template <typename B, typename R, typename Q>\n+bool BFER<B,R,Q>\n+::stop_time_reached()\n+{\n+ using namespace std::chrono;\n+ return params_BFER.stop_time != seconds(0) && (steady_clock::now() - this->t_start_noise_point) >= params_BFER.stop_time;\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.hpp", "new_path": "src/Simulation/BFER/BFER.hpp", "diff": "@@ -91,6 +91,9 @@ protected:\n// noise distribution\ntools::Distributions<R> *distributions;\n+ std::chrono::steady_clock::time_point t_start_noise_point;\n+\n+\npublic:\nexplicit BFER(const factory::BFER::parameters& params_BFER);\nvirtual ~BFER();\n@@ -106,9 +109,17 @@ protected:\nMonitor_BFER_type* build_monitor_er(const int tid = 0);\ntools::Terminal* build_terminal();\n+ void build_reporters();\n+ void build_monitors ();\n+\n+ virtual bool keep_looping_noise_point();\n+ bool max_frame_reached();\n+ bool stop_time_reached();\nprivate:\nstatic void start_thread_build_comm_chain(BFER<B,R,Q> *simu, const int tid);\n+\n+\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": "@@ -331,15 +331,8 @@ void BFER_ite_threads<B,R,Q>\nauto &decoder_siho = *codec.get_decoder_siho();\nusing namespace module;\n- using namespace std::chrono;\n- auto t_snr = steady_clock::now();\n-\n- while (!tools::Terminal::is_interrupt()\n- && !this->monitor_er_red->fe_limit_achieved() // while max frame error count has not been reached\n- && (this->params_BFER_ite.stop_time == seconds(0)\n- || (steady_clock::now() - t_snr) < this->params_BFER_ite.stop_time)\n- && (this->params_BFER_ite.max_frame == 0\n- || this->monitor_er_red->get_n_analyzed_fra() < this->params_BFER_ite.max_frame))\n+\n+ while (this->keep_looping_noise_point())\n{\nif (this->params_BFER_ite.debug)\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": "@@ -50,10 +50,8 @@ void BFER_std_threads<B,R,Q>\nfor (auto tid = 1; tid < this->params_BFER_std.n_threads; tid++)\nthreads[tid -1].join();\n-\nmodule::Monitor_reduction::reduce(true, true);\n-\nif (!this->prev_err_messages_to_display.empty())\nthrow std::runtime_error(this->prev_err_messages_to_display.back());\n}\n@@ -274,15 +272,9 @@ void BFER_std_threads<B,R,Q>\nauto &monitor = *this->monitor_er[tid];\nusing namespace module;\n- using namespace std::chrono;\n- auto t_snr = steady_clock::now();\n// communication chain execution\n- while (!tools::Terminal::is_interrupt() && !this->monitor_er_red->fe_limit_achieved() && // while max frame error count has not been reached\n- (this->params_BFER_std.stop_time == seconds(0) ||\n- (steady_clock::now() - t_snr) < this->params_BFER_std.stop_time) &&\n- (this->params_BFER_std.max_frame == 0 ||\n- this->monitor_er_red->get_n_analyzed_fra() < this->params_BFER_std.max_frame))\n+ while (this->keep_looping_noise_point())\n{\nif (this->params_BFER_std.debug)\n{\n" } ]
C++
MIT License
aff3ct/aff3ct
Refacto simus BFER Create a keep_looping_noise_point function in simu BFER mother class to factorize the simulation while loop condition to keep running or not the noise point. Create sub-routines max_frame_reached() and stop_time_reached(). Clear the simu BFER class constructor by creating sub-routines to build monitors and reporters objects.
8,483
18.07.2018 15:11:10
-7,200
2887313e6627ce79311f06ad8fefe04c5d8841ad
Add a MPI Barrier in Monitor MPI reduction to keep synchro between nodes
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hxx", "new_path": "src/Module/Monitor/Monitor_reduction_mpi.hxx", "diff": "@@ -98,6 +98,8 @@ void Monitor_reduction_mpi<M>\nauto mvals_send = this->get_vals_mpi();\n+ MPI_Barrier(MPI_COMM_WORLD);\n+\nMPI_Allreduce(&mvals_send, &mvals_recv, 1,\nMPI_monitor_vals, MPI_SUM_monitor_vals, MPI_COMM_WORLD);\n" } ]
C++
MIT License
aff3ct/aff3ct
Add a MPI Barrier in Monitor MPI reduction to keep synchro between nodes
8,483
18.07.2018 15:15:14
-7,200
e58d721c8982a7e50e6092e5f2104eda91e72622
Rename Monitor_reduction_mpi -> Monitor_reduction_MPI
[ { "change_type": "RENAME", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hpp", "new_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp", "diff": "@@ -12,15 +12,15 @@ namespace aff3ct\nnamespace module\n{\ntemplate <class M> // M is the monitor on which must be applied the reduction\n-class Monitor_reduction_mpi : public Monitor_reduction_M<M>\n+class Monitor_reduction_MPI : public Monitor_reduction_M<M>\n{\nprivate:\nMPI_Datatype MPI_monitor_vals;\nMPI_Op MPI_SUM_monitor_vals;\npublic:\n- Monitor_reduction_mpi(const std::vector<M*> &monitors);\n- virtual ~Monitor_reduction_mpi() = default;\n+ Monitor_reduction_MPI(const std::vector<M*> &monitors);\n+ virtual ~Monitor_reduction_MPI() = default;\nvoid reset();\n@@ -29,7 +29,7 @@ protected:\n};\n}\n}\n-#include \"Monitor_reduction_mpi.hxx\"\n+#include \"Monitor_reduction_MPI.hxx\"\n#endif /* MONITOR_REDUCTION_MPI_HPP_ */\n" }, { "change_type": "RENAME", "old_path": "src/Module/Monitor/Monitor_reduction_mpi.hxx", "new_path": "src/Module/Monitor/Monitor_reduction_MPI.hxx", "diff": "#include \"Tools/Exception/exception.hpp\"\n-#include \"Monitor_reduction_mpi.hpp\"\n+#include \"Monitor_reduction_MPI.hpp\"\n#include \"MI/Monitor_MI.hpp\"\nnamespace aff3ct\n@@ -32,11 +32,11 @@ void MPI_SUM_monitor_vals_func(void *in, void *inout, int *len, MPI_Datatype *da\n}\ntemplate <class M>\n-Monitor_reduction_mpi<M>\n-::Monitor_reduction_mpi(const std::vector<M*> &monitors)\n+Monitor_reduction_MPI<M>\n+::Monitor_reduction_MPI(const std::vector<M*> &monitors)\n: Monitor_reduction_M<M>(monitors)\n{\n- const std::string name = \"Monitor_reduction_mpi<\" + monitors[0]->get_name() + \">\";\n+ const std::string name = \"Monitor_reduction_MPI<\" + monitors[0]->get_name() + \">\";\nthis->set_name(name);\n// int blen [M::n_MPI_attributes];\n@@ -87,7 +87,7 @@ Monitor_reduction_mpi<M>\n}\ntemplate <class M>\n-void Monitor_reduction_mpi<M>\n+void Monitor_reduction_MPI<M>\n::_reduce(bool fully)\n{\nfully = false;\n@@ -107,7 +107,7 @@ void Monitor_reduction_mpi<M>\n}\ntemplate <class M>\n-void Monitor_reduction_mpi<M>\n+void Monitor_reduction_MPI<M>\n::reset()\n{\nMonitor_reduction_M<M>::reset();\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.hpp", "new_path": "src/Simulation/BFER/BFER.hpp", "diff": "#include \"Module/Monitor/Monitor_reduction.hpp\"\n#ifdef ENABLE_MPI\n-#include \"Module/Monitor/Monitor_reduction_mpi.hpp\"\n+#include \"Module/Monitor/Monitor_reduction_MPI.hpp\"\n#define FORCE_REDUCE_EVERY_LOOP false\n#else\n#define FORCE_REDUCE_EVERY_LOOP true\n@@ -63,8 +63,8 @@ protected:\nusing Monitor_MI_type = module::Monitor_MI<B,R>;\n#ifdef ENABLE_MPI\n- using Monitor_BFER_reduction_type = module::Monitor_reduction_mpi<Monitor_BFER_type>;\n- using Monitor_MI_reduction_type = module::Monitor_reduction_mpi<Monitor_MI_type >;\n+ using Monitor_BFER_reduction_type = module::Monitor_reduction_MPI<Monitor_BFER_type>;\n+ using Monitor_MI_reduction_type = module::Monitor_reduction_MPI<Monitor_MI_type >;\n#else\nusing Monitor_BFER_reduction_type = module::Monitor_reduction_M<Monitor_BFER_type>;\nusing Monitor_MI_reduction_type = module::Monitor_reduction_M<Monitor_MI_type >;\n" } ]
C++
MIT License
aff3ct/aff3ct
Rename Monitor_reduction_mpi -> Monitor_reduction_MPI
8,483
19.07.2018 17:05:46
-7,200
63e7fcc8b9fb2c835822fda354bee4322bf6962b
Fix reporter exit linker error
[ { "change_type": "MODIFY", "old_path": "src/Tools/Display/Reporter/EXIT/Reporter_EXIT.cpp", "new_path": "src/Tools/Display/Reporter/EXIT/Reporter_EXIT.cpp", "diff": "@@ -72,8 +72,6 @@ Reporter::report_t Reporter_EXIT<B,R>\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template class aff3ct::tools::Reporter_EXIT<B_8 , R_8 >;\n-template class aff3ct::tools::Reporter_EXIT<B_16, R_16>;\ntemplate class aff3ct::tools::Reporter_EXIT<B_32, R_32>;\ntemplate class aff3ct::tools::Reporter_EXIT<B_64, R_64>;\n#else\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix reporter exit linker error
8,483
20.07.2018 11:25:11
-7,200
d1cd1204aba421f080f5590124a507c16c82e778
Remove some no mean virtual keywords on monitor methods and add a virtual 'done' method
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "diff": "@@ -152,7 +152,7 @@ int Monitor_BFER<B>\ntemplate <typename B>\nbool Monitor_BFER<B>\n-::fe_limit_achieved()\n+::fe_limit_achieved() const\n{\nreturn get_n_fe() >= get_fe_limit();\n}\n@@ -327,6 +327,13 @@ Monitor_BFER<B>& Monitor_BFER<B>\nreturn *this;\n}\n+template <typename B>\n+bool Monitor_BFER<B>\n+::done() const\n+{\n+ return fe_limit_achieved();\n+}\n+\n// #ifdef ENABLE_MPI\n// template <typename B>\n// void Monitor_BFER<B>\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "diff": "@@ -89,15 +89,15 @@ public:\nvirtual int check_errors(const B *U, const B *Y, const int frame_id = -1);\n- virtual bool fe_limit_achieved();\n+ bool fe_limit_achieved() const;\nunsigned get_fe_limit() const;\nbool get_count_unknown_values() const;\n- virtual unsigned long long get_n_analyzed_fra() const;\n- virtual unsigned long long get_n_fe () const;\n- virtual unsigned long long get_n_be () const;\n- virtual tools::Histogram<int> get_err_hist () const;\n+ unsigned long long get_n_analyzed_fra() const;\n+ unsigned long long get_n_fe () const;\n+ unsigned long long get_n_be () const;\n+ tools::Histogram<int> get_err_hist () const;\nfloat get_fer() const;\nfloat get_ber() const;\n@@ -120,6 +120,9 @@ public:\nMonitor_BFER<B>& operator=(const Monitor_BFER<B>& m); // not full \"copy\" call\n+\n+ virtual bool done() const;\n+\nprotected:\nvirtual int _check_errors(const B *U, const B *Y, const int frame_id);\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp", "diff": "@@ -366,6 +366,13 @@ Monitor_EXIT<B,R>& Monitor_EXIT<B,R>\nreturn *this;\n}\n+template <typename B, typename R>\n+bool Monitor_EXIT<B,R>\n+::done() const\n+{\n+ return n_trials_achieved();\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "diff": "@@ -98,12 +98,12 @@ public:\nunsigned get_n_trials_limit() const;\n- virtual bool n_trials_achieved() const;\n+ bool n_trials_achieved() const;\n- virtual R get_I_E() const;\n- virtual R get_I_A() const;\n+ R get_I_E() const;\n+ R get_I_A() const;\n- virtual unsigned long long get_n_trials() const;\n+ unsigned long long get_n_trials() const;\nvirtual void add_handler_measure(std::function<void(void)> callback);\n@@ -122,6 +122,8 @@ public:\nMonitor_EXIT<B,R>& operator=(const Monitor_EXIT<B,R>& m); // not full \"copy\" call\n+ virtual bool done() const;\n+\nprotected:\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" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/MI/Monitor_MI.cpp", "new_path": "src/Module/Monitor/MI/Monitor_MI.cpp", "diff": "@@ -162,7 +162,7 @@ void Monitor_MI<B,R>\ntemplate <typename B, typename R>\nbool Monitor_MI<B,R>\n-::n_trials_limit_achieved()\n+::n_trials_limit_achieved() const\n{\nreturn this->get_n_trials() >= this->get_n_trials_limit();\n}\n@@ -307,6 +307,13 @@ Monitor_MI<B,R>& Monitor_MI<B,R>\nreturn *this;\n}\n+template <typename B, typename R>\n+bool Monitor_MI<B,R>\n+::done() const\n+{\n+ return n_trials_limit_achieved();\n+}\n+\n// #ifdef ENABLE_MPI\n// template <typename B, typename R>\n// void Monitor_MI<B,R>\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "new_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "diff": "@@ -85,14 +85,14 @@ public:\nvirtual R get_mutual_info(const B *X, const R *Y, const int frame_id = -1);\n- virtual bool n_trials_limit_achieved();\n+ bool n_trials_limit_achieved() const;\nunsigned get_n_trials_limit() const;\n- virtual unsigned long long get_n_trials() const;\n+ unsigned long long get_n_trials() const;\n- virtual R get_MI () const;\n- virtual R get_MI_min() const;\n- virtual R get_MI_max() const;\n+ R get_MI () const;\n+ R get_MI_min() const;\n+ R get_MI_max() const;\ntools::Histogram<R> get_mutinfo_hist() const;\nvirtual void add_handler_check (std::function<void(void)> callback);\n@@ -111,6 +111,7 @@ public:\nMonitor_MI<B,R>& operator=(const Monitor_MI<B,R>& m); // not full \"copy\" call\n+ virtual bool done() const;\nprotected:\nvirtual R _get_mutual_info(const B *X, const R *Y, const int frame_id);\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor.hpp", "new_path": "src/Module/Monitor/Monitor.hpp", "diff": "@@ -72,6 +72,11 @@ public:\n*/\nvirtual void collect(const Monitor& m, bool fully = false) = 0;\n+ /*\n+ * \\brief return true if enough data have been processed and respect check conditions\n+ */\n+ virtual bool done() const = 0;\n+\n/*!\n* \\brief completely copy values of the monitor 'm' into this monitor\n*/\n" } ]
C++
MIT License
aff3ct/aff3ct
Remove some no mean virtual keywords on monitor methods and add a virtual 'done' method
8,483
20.07.2018 12:59:14
-7,200
8056de16bb91658f3696fdb002c47753ca185a0f
Fix the MPI simulation: Add a 'last' Monitor::reduce function to wait the end of all simulation loop on all nodes. Add a 'simu_is_over' MPI check on all nodes to stop the simulation if any node has done
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.cpp", "new_path": "src/Module/Monitor/Monitor_reduction.cpp", "diff": "using namespace aff3ct;\nusing namespace aff3ct::module;\n+bool aff3ct::module::Monitor_reduction::at_last_reduce = false;\nstd::vector<aff3ct::module::Monitor_reduction*> aff3ct::module::Monitor_reduction::monitors;\nstd::thread::id aff3ct::module::Monitor_reduction::master_thread_id = std::this_thread::get_id();\nstd::chrono::nanoseconds aff3ct::module::Monitor_reduction::d_reduce_frequency = std::chrono::milliseconds(1000);\n@@ -16,7 +17,6 @@ Monitor_reduction\n::Monitor_reduction()\n{\nMonitor_reduction::add_monitor(this);\n- Monitor_reduction::reset();\n}\nvoid Monitor_reduction\n@@ -26,26 +26,26 @@ void Monitor_reduction\n}\nvoid Monitor_reduction\n-::reset()\n+::reset_all()\n{\n- master_thread_id = std::this_thread::get_id();\nt_last_mpi_comm = std::chrono::steady_clock::now();\n+ at_last_reduce = false;\n+\n+ for(auto& m : monitors)\n+ m->reset_mr();\n}\nvoid Monitor_reduction\n::reduce(bool fully, bool force)\n{\n- // only the master thread can do this\n- if (force ||\n- (std::this_thread::get_id() == master_thread_id &&\n- (std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_reduce_frequency)\n- )\n- {\n- for(auto& m : monitors)\n- m->_reduce(fully);\n-\n- t_last_mpi_comm = std::chrono::steady_clock::now();\n+ __reduce__(fully, force, false);\n}\n+\n+void Monitor_reduction\n+::last_reduce(bool fully)\n+{\n+ while(!__reduce__(fully, true, true))\n+ ;\n}\nvoid Monitor_reduction\n@@ -60,3 +60,22 @@ void Monitor_reduction\nd_reduce_frequency = d;\n}\n+\n+bool Monitor_reduction\n+::__reduce__(bool fully, bool force, bool last)\n+{\n+ bool all_done = last;\n+\n+ // only the master thread can do this\n+ if (std::this_thread::get_id() == master_thread_id\n+ && (force || (std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_reduce_frequency)\n+ )\n+ {\n+ for(auto& m : monitors)\n+ all_done &= m->_reduce(fully, last);\n+\n+ t_last_mpi_comm = std::chrono::steady_clock::now();\n+ }\n+\n+ return all_done;\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.hpp", "new_path": "src/Module/Monitor/Monitor_reduction.hpp", "diff": "@@ -16,26 +16,47 @@ namespace module\nclass Monitor_reduction\n{\npublic:\n+ /*\n+ * make a reduction every 'd_reduce_frequency' except if the 'force' argument is set\n+ * the reduction can be done only by the master thread 'master_thread_id'\n+ */\nstatic void reduce(bool fully = false, bool force = false);\n+ /*\n+ * loop on a forced reduction until all '__reduce__' call return 'true'\n+ * the reduction can be done only by the master thread 'master_thread_id'\n+ */\n+ static void last_reduce(bool fully = false);\n+\n+\n+ /*\n+ * reset 't_last_mpi_comm', clear 'at_last_reduce' and call 'reset_mr' on each monitor\n+ */\n+ static void reset_all();\n+\nstatic void set_master_thread_id(std::thread::id t);\nstatic void set_reduce_frequency(std::chrono::nanoseconds d);\n+\nprotected:\nMonitor_reduction();\nvirtual ~Monitor_reduction() = default;\n- virtual void _reduce(bool fully = false) = 0;\n+ virtual bool _reduce(bool fully = false, bool last = false) = 0;\n+ virtual void reset_mr() = 0;\nprivate:\nstatic void add_monitor(Monitor_reduction*);\n- static void reset();\n+ static bool at_last_reduce;\nstatic std::vector<Monitor_reduction*> monitors;\nstatic std::thread::id master_thread_id;\nstatic std::chrono::nanoseconds d_reduce_frequency;\nstatic std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> t_last_mpi_comm;\n+\n+ static bool __reduce__(bool fully, bool force, bool last);\n+\n};\n@@ -55,7 +76,10 @@ public:\nvirtual void clear_callbacks();\nprotected:\n- virtual void _reduce(bool fully = false);\n+ virtual bool _reduce(bool fully = false, bool last = false);\n+\n+private:\n+ void reset_mr();\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.hxx", "new_path": "src/Module/Monitor/Monitor_reduction.hxx", "diff": "@@ -70,6 +70,13 @@ void Monitor_reduction_M<M>\nm->reset();\n}\n+template <class M>\n+void Monitor_reduction_M<M>\n+::reset_mr()\n+{\n+ this->reset();\n+}\n+\ntemplate <class M>\nvoid Monitor_reduction_M<M>\n::clear_callbacks()\n@@ -81,8 +88,8 @@ void Monitor_reduction_M<M>\n}\ntemplate <class M>\n-void Monitor_reduction_M<M>\n-::_reduce(bool fully)\n+bool Monitor_reduction_M<M>\n+::_reduce(bool fully, bool last)\n{\nM collecter(*this);\n@@ -90,6 +97,8 @@ void Monitor_reduction_M<M>\ncollecter.collect(*m, fully);\nM::copy(collecter, fully);\n+\n+ return last;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp", "new_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp", "diff": "@@ -14,18 +14,18 @@ namespace module\ntemplate <class M> // M is the monitor on which must be applied the reduction\nclass Monitor_reduction_MPI : public Monitor_reduction_M<M>\n{\n-private:\n- MPI_Datatype MPI_monitor_vals;\n- MPI_Op MPI_SUM_monitor_vals;\n-\npublic:\nMonitor_reduction_MPI(const std::vector<M*> &monitors);\nvirtual ~Monitor_reduction_MPI() = default;\n- void reset();\n+ virtual void reset();\nprotected:\n- virtual void _reduce(bool fully = false);\n+ virtual bool _reduce(bool fully = false, bool last = false);\n+\n+private:\n+ MPI_Datatype MPI_monitor_vals;\n+ MPI_Op MPI_SUM_monitor_vals;\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_MPI.hxx", "new_path": "src/Module/Monitor/Monitor_reduction_MPI.hxx", "diff": "@@ -87,23 +87,27 @@ Monitor_reduction_MPI<M>\n}\ntemplate <class M>\n-void Monitor_reduction_MPI<M>\n-::_reduce(bool fully)\n+bool Monitor_reduction_MPI<M>\n+::_reduce(bool fully, bool last)\n{\nfully = false;\nMonitor_reduction_M<M>::_reduce(fully);\ntypename M::Vals_mpi mvals_recv;\n-\nauto mvals_send = this->get_vals_mpi();\n- MPI_Barrier(MPI_COMM_WORLD);\n-\nMPI_Allreduce(&mvals_send, &mvals_recv, 1,\nMPI_monitor_vals, MPI_SUM_monitor_vals, MPI_COMM_WORLD);\n-\nM::copy(mvals_recv);\n+\n+\n+ char last_recv = true;\n+\n+ MPI_Allreduce(&last, &last_recv, 1,\n+ MPI_CHAR, MPI_LAND, MPI_COMM_WORLD);\n+\n+ return last_recv;\n}\ntemplate <class M>\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.cpp", "new_path": "src/Simulation/BFER/BFER.cpp", "diff": "@@ -216,6 +216,7 @@ void BFER<B,R,Q>\nthis->t_start_noise_point = std::chrono::steady_clock::now();\n+\ntry\n{\nthis->_launch();\n@@ -229,6 +230,7 @@ void BFER<B,R,Q>\nthis->simu_error = true;\n}\n+\n#ifdef ENABLE_MPI\nif (params_BFER.mpi_rank == 0)\n#endif\n@@ -306,12 +308,15 @@ void BFER<B,R,Q>\n(params_BFER.max_frame == 0 || this->monitor_er_red->get_n_analyzed_fra() >= params_BFER.max_frame))\ntools::Terminal::stop();\n+ #ifdef ENABLE_MPI\n+ if (MPI_simu_is_over())\n+ tools::Terminal::stop();\n+ #endif\n+\n+\nif (tools::Terminal::is_over())\nbreak;\n- this->monitor_er_red->reset();\n- if (this->monitor_mi_red != nullptr)\n- this->monitor_mi_red->reset();\nfor (auto &m : modules)\nfor (auto mm : m.second)\n@@ -319,7 +324,9 @@ void BFER<B,R,Q>\nfor (auto &t : mm->tasks)\nt->reset_stats();\n+ module::Monitor_reduction::reset_all();\ntools::Terminal::reset();\n+\n}\nthis->release_objects();\n@@ -412,6 +419,8 @@ void BFER<B,R,Q>\nmodule::Monitor_reduction::set_reduce_frequency(params_BFER.mpi_comm_freq);\n// #else reduction is forced for every loop with macro FORCE_REDUCE_EVERY_LOOP\n#endif\n+\n+ module::Monitor_reduction::reset_all();\n}\ntemplate <typename B, typename R, typename Q>\n@@ -454,7 +463,7 @@ bool BFER<B,R,Q>\n{\n// communication chain execution\nreturn !tools::Terminal::is_interrupt() // if user stopped the simulation\n- && !this->monitor_er_red->fe_limit_achieved() // while max frame error count has not been reached\n+ && !this->monitor_er_red->done() // while max frame error count has not been reached\n&& !this->stop_time_reached()\n&& !this->max_frame_reached();\n}\n@@ -474,6 +483,21 @@ bool BFER<B,R,Q>\nreturn params_BFER.stop_time != seconds(0) && (steady_clock::now() - this->t_start_noise_point) >= params_BFER.stop_time;\n}\n+#ifdef ENABLE_MPI\n+template <typename B, typename R, typename Q>\n+bool BFER<B,R,Q>\n+::MPI_simu_is_over()\n+{\n+ char over_send = tools::Terminal::is_over();\n+ char over_recv;\n+\n+ MPI_Allreduce(&over_send, &over_recv, 1,\n+ MPI_CHAR, MPI_LOR, MPI_COMM_WORLD);\n+\n+ return (bool)over_recv;\n+}\n+#endif\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.hpp", "new_path": "src/Simulation/BFER/BFER.hpp", "diff": "@@ -119,6 +119,9 @@ protected:\nprivate:\nstatic void start_thread_build_comm_chain(BFER<B,R,Q> *simu, const int tid);\n+#ifdef ENABLE_MPI\n+ bool MPI_simu_is_over();\n+#endif\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": "@@ -50,7 +50,7 @@ void BFER_ite_threads<B,R,Q>\nfor (auto tid = 1; tid < this->params_BFER_ite.n_threads; tid++)\nthreads[tid -1].join();\n- module::Monitor_reduction::reduce(true, true);\n+ module::Monitor_reduction::last_reduce(true);\nif (!this->prev_err_messages.empty())\nthrow std::runtime_error(this->prev_err_messages.back());\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": "@@ -50,7 +50,7 @@ void BFER_std_threads<B,R,Q>\nfor (auto tid = 1; tid < this->params_BFER_std.n_threads; tid++)\nthreads[tid -1].join();\n- module::Monitor_reduction::reduce(true, true);\n+ module::Monitor_reduction::last_reduce(true);\nif (!this->prev_err_messages_to_display.empty())\nthrow std::runtime_error(this->prev_err_messages_to_display.back());\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the MPI simulation: Add a 'last' Monitor::reduce function to wait the end of all simulation loop on all nodes. Add a 'simu_is_over' MPI check on all nodes to stop the simulation if any node has done
8,483
20.07.2018 17:17:55
-7,200
a5bd5566c137bc56809d186279e23f4c21646581
Fix MPI com: Replace the bool allreduce type in Monitor reduction MPI_LAND by a int MPI_SUM of the number of process that are at the last reduction point.
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.cpp", "new_path": "src/Module/Monitor/Monitor_reduction.cpp", "diff": "using namespace aff3ct;\nusing namespace aff3ct::module;\n-bool aff3ct::module::Monitor_reduction::at_last_reduce = false;\n+int aff3ct::module::Monitor_reduction::number_processes = 1;\n+bool aff3ct::module::Monitor_reduction::stop_loop = false;\nstd::vector<aff3ct::module::Monitor_reduction*> aff3ct::module::Monitor_reduction::monitors;\nstd::thread::id aff3ct::module::Monitor_reduction::master_thread_id = std::this_thread::get_id();\nstd::chrono::nanoseconds aff3ct::module::Monitor_reduction::d_reduce_frequency = std::chrono::milliseconds(1000);\n-std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> aff3ct::module::Monitor_reduction::t_last_mpi_comm;\n+std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> aff3ct::module::Monitor_reduction::t_last_reduction;\nMonitor_reduction\n@@ -28,8 +29,8 @@ void Monitor_reduction\nvoid Monitor_reduction\n::reset_all()\n{\n- t_last_mpi_comm = std::chrono::steady_clock::now();\n- at_last_reduce = false;\n+ t_last_reduction = std::chrono::steady_clock::now();\n+ stop_loop = false;\nfor(auto& m : monitors)\nm->reset_mr();\n@@ -38,12 +39,14 @@ void Monitor_reduction\nvoid Monitor_reduction\n::reduce(bool fully, bool force)\n{\n- __reduce__(fully, force, false);\n+ stop_loop = __reduce__(fully, force, false);\n}\nvoid Monitor_reduction\n::last_reduce(bool fully)\n{\n+ stop_loop = true;\n+\nwhile(!__reduce__(fully, true, true))\n;\n}\n@@ -54,28 +57,46 @@ void Monitor_reduction\nmaster_thread_id = t;\n}\n+void Monitor_reduction\n+::set_n_processes(int np)\n+{\n+ number_processes = np;\n+}\n+\nvoid Monitor_reduction\n::set_reduce_frequency(std::chrono::nanoseconds d)\n{\nd_reduce_frequency = d;\n}\n+bool Monitor_reduction\n+::get_stop_loop()\n+{\n+ return stop_loop;\n+}\n+\nbool Monitor_reduction\n-::__reduce__(bool fully, bool force, bool last)\n+::__reduce__(bool fully, bool force, bool stop_simu)\n{\n- bool all_done = last;\n+ bool stop = stop_simu;\n// only the master thread can do this\nif (std::this_thread::get_id() == master_thread_id\n- && (force || (std::chrono::steady_clock::now() - t_last_mpi_comm) >= d_reduce_frequency)\n+ && (force || (std::chrono::steady_clock::now() - t_last_reduction) >= d_reduce_frequency)\n)\n{\nfor(auto& m : monitors)\n- all_done &= m->_reduce(fully, last);\n+ {\n+ int n_stop = m->_reduce(fully, stop_simu);\n+ if (stop_simu)\n+ stop &= n_stop == number_processes;\n+ else\n+ stop |= n_stop != 0;\n+ }\n- t_last_mpi_comm = std::chrono::steady_clock::now();\n+ t_last_reduction = std::chrono::steady_clock::now();\n}\n- return all_done;\n+ return stop;\n}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.hpp", "new_path": "src/Module/Monitor/Monitor_reduction.hpp", "diff": "@@ -25,37 +25,43 @@ public:\n/*\n* loop on a forced reduction until all '__reduce__' call return 'true'\n* the reduction can be done only by the master thread 'master_thread_id'\n+ * set 'stop_loop' to true\n*/\nstatic void last_reduce(bool fully = false);\n/*\n- * reset 't_last_mpi_comm', clear 'at_last_reduce' and call 'reset_mr' on each monitor\n+ * reset 't_last_mpi_comm', clear 'stop_loop' and call 'reset_mr' on each monitor\n*/\nstatic void reset_all();\nstatic void set_master_thread_id(std::thread::id t);\nstatic void set_reduce_frequency(std::chrono::nanoseconds d);\n+ static void set_n_processes (int np);\n+ static bool get_stop_loop();\nprotected:\nMonitor_reduction();\nvirtual ~Monitor_reduction() = default;\n- virtual bool _reduce(bool fully = false, bool last = false) = 0;\n+ // return the number of process that asked to stop the simulation (at last_reduce)\n+ virtual int _reduce(bool fully = false, bool stop_simu = false) = 0;\n+\nvirtual void reset_mr() = 0;\nprivate:\nstatic void add_monitor(Monitor_reduction*);\n- static bool at_last_reduce;\n+ static int number_processes;\n+ static bool stop_loop;\nstatic std::vector<Monitor_reduction*> monitors;\nstatic std::thread::id master_thread_id;\nstatic std::chrono::nanoseconds d_reduce_frequency;\n- static std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> t_last_mpi_comm;\n+ static std::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> t_last_reduction;\n- static bool __reduce__(bool fully, bool force, bool last);\n+ static bool __reduce__(bool fully, bool force, bool stop_simu);\n};\n@@ -76,7 +82,7 @@ public:\nvirtual void clear_callbacks();\nprotected:\n- virtual bool _reduce(bool fully = false, bool last = false);\n+ virtual int _reduce(bool fully = false, bool stop_simu = false); // return the number of process that stopped the simu\nprivate:\nvoid reset_mr();\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.hxx", "new_path": "src/Module/Monitor/Monitor_reduction.hxx", "diff": "@@ -88,8 +88,8 @@ void Monitor_reduction_M<M>\n}\ntemplate <class M>\n-bool Monitor_reduction_M<M>\n-::_reduce(bool fully, bool last)\n+int Monitor_reduction_M<M>\n+::_reduce(bool fully, bool stop_simu)\n{\nM collecter(*this);\n@@ -98,7 +98,7 @@ bool Monitor_reduction_M<M>\nM::copy(collecter, fully);\n- return last;\n+ return stop_simu ? 1 : 0;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp", "new_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp", "diff": "@@ -21,7 +21,7 @@ public:\nvirtual void reset();\nprotected:\n- virtual bool _reduce(bool fully = false, bool last = false);\n+ virtual int _reduce(bool fully = false, bool stop_simu = false); // return the number of process that stopped the simu\nprivate:\nMPI_Datatype MPI_monitor_vals;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_MPI.hxx", "new_path": "src/Module/Monitor/Monitor_reduction_MPI.hxx", "diff": "@@ -87,8 +87,8 @@ Monitor_reduction_MPI<M>\n}\ntemplate <class M>\n-bool Monitor_reduction_MPI<M>\n-::_reduce(bool fully, bool last)\n+int Monitor_reduction_MPI<M>\n+::_reduce(bool fully, bool stop_simu)\n{\nfully = false;\n@@ -97,17 +97,17 @@ bool Monitor_reduction_MPI<M>\ntypename M::Vals_mpi mvals_recv;\nauto mvals_send = this->get_vals_mpi();\n- MPI_Allreduce(&mvals_send, &mvals_recv, 1,\n- MPI_monitor_vals, MPI_SUM_monitor_vals, MPI_COMM_WORLD);\n+ MPI_Allreduce(&mvals_send, &mvals_recv, 1, MPI_monitor_vals, MPI_SUM_monitor_vals, MPI_COMM_WORLD);\n+\nM::copy(mvals_recv);\n- char last_recv = true;\n- MPI_Allreduce(&last, &last_recv, 1,\n- MPI_CHAR, MPI_LAND, MPI_COMM_WORLD);\n+ int n_stop_recv, stop_send = stop_simu ? 1 : 0;\n+\n+ MPI_Allreduce(&stop_send, &n_stop_recv, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);\n- return last_recv;\n+ return n_stop_recv;\n}\ntemplate <class M>\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.cpp", "new_path": "src/Simulation/BFER/BFER.cpp", "diff": "@@ -417,7 +417,10 @@ void BFER<B,R,Q>\nmodule::Monitor_reduction::set_master_thread_id(std::this_thread::get_id());\n#ifdef ENABLE_MPI\nmodule::Monitor_reduction::set_reduce_frequency(params_BFER.mpi_comm_freq);\n- // #else reduction is forced for every loop with macro FORCE_REDUCE_EVERY_LOOP\n+ module::Monitor_reduction::set_n_processes (params_BFER.mpi_size );\n+ #else\n+ //reduction is forced for every loop with macro FORCE_REDUCE_EVERY_LOOP\n+ module::Monitor_reduction::set_n_processes(1);\n#endif\nmodule::Monitor_reduction::reset_all();\n@@ -462,10 +465,11 @@ bool BFER<B,R,Q>\n::keep_looping_noise_point()\n{\n// communication chain execution\n- return !tools::Terminal::is_interrupt() // if user stopped the simulation\n- && !this->monitor_er_red->done() // while max frame error count has not been reached\n- && !this->stop_time_reached()\n- && !this->max_frame_reached();\n+ return !(tools::Terminal::is_interrupt() // if user stopped the simulation\n+ || this->monitor_er_red->done() // while max frame error count has not been reached\n+ || module::Monitor_reduction::get_stop_loop()\n+ || this->stop_time_reached()\n+ || this->max_frame_reached());\n}\ntemplate <typename B, typename R, typename Q>\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix MPI com: Replace the bool allreduce type in Monitor reduction MPI_LAND by a int MPI_SUM of the number of process that are at the last reduction point.
8,488
23.07.2018 12:19:34
-7,200
525c0cf552f1f105583d32fffe157d56ce61c4f1
Rename wangliu to shortlast, add refs.
[ { "change_type": "MODIFY", "old_path": "refs", "new_path": "refs", "diff": "-Subproject commit 1eb3024b48dcde22a14269732a74e3f1479a7336\n+Subproject commit 7043a08e9f0353c808e6928e187bea7deceda0d4\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Puncturer/Polar/Puncturer_polar.cpp", "new_path": "src/Factory/Module/Puncturer/Polar/Puncturer_polar.cpp", "diff": "@@ -14,7 +14,7 @@ Puncturer_polar::parameters\n::parameters(const std::string &prefix)\n: Puncturer::parameters(Puncturer_polar_name, prefix)\n{\n- this->type = \"WANGLIU\";\n+ this->type = \"SHORTLAST\";\n}\nPuncturer_polar::parameters\n@@ -35,7 +35,7 @@ void Puncturer_polar::parameters\nauto p = this->get_prefix();\n- tools::add_options(args.at({p+\"-type\"}), 0, \"WANGLIU\");\n+ tools::add_options(args.at({p+\"-type\"}), 0, \"SHORTLAST\");\n}\nvoid Puncturer_polar::parameters\n@@ -55,16 +55,16 @@ void Puncturer_polar::parameters\n}\ntemplate <typename B, typename Q>\n-module::Puncturer_polar_wangliu<B,Q>* Puncturer_polar::parameters\n+module::Puncturer_polar_shortlast<B,Q>* Puncturer_polar::parameters\n::build(const tools::Frozenbits_generator &fb_generator) const\n{\n- if (this->type == \"WANGLIU\") return new module::Puncturer_polar_wangliu<B,Q>(this->K, this->N, fb_generator, this->n_frames);\n+ if (this->type == \"SHORTLAST\") return new module::Puncturer_polar_shortlast<B,Q>(this->K, this->N, fb_generator, this->n_frames);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\ntemplate <typename B, typename Q>\n-module::Puncturer_polar_wangliu<B,Q>* Puncturer_polar\n+module::Puncturer_polar_shortlast<B,Q>* Puncturer_polar\n::build(const parameters &params,\nconst tools::Frozenbits_generator &fb_generator)\n{\n@@ -74,16 +74,16 @@ module::Puncturer_polar_wangliu<B,Q>* Puncturer_polar\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template aff3ct::module::Puncturer_polar_wangliu<B_8 ,Q_8 >* aff3ct::factory::Puncturer_polar::parameters::build<B_8 ,Q_8 >(const aff3ct::tools::Frozenbits_generator&) const;\n-template aff3ct::module::Puncturer_polar_wangliu<B_16,Q_16>* aff3ct::factory::Puncturer_polar::parameters::build<B_16,Q_16>(const aff3ct::tools::Frozenbits_generator&) const;\n-template aff3ct::module::Puncturer_polar_wangliu<B_32,Q_32>* aff3ct::factory::Puncturer_polar::parameters::build<B_32,Q_32>(const aff3ct::tools::Frozenbits_generator&) const;\n-template aff3ct::module::Puncturer_polar_wangliu<B_64,Q_64>* aff3ct::factory::Puncturer_polar::parameters::build<B_64,Q_64>(const aff3ct::tools::Frozenbits_generator&) const;\n-template aff3ct::module::Puncturer_polar_wangliu<B_8 ,Q_8 >* aff3ct::factory::Puncturer_polar::build<B_8 ,Q_8 >(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n-template aff3ct::module::Puncturer_polar_wangliu<B_16,Q_16>* aff3ct::factory::Puncturer_polar::build<B_16,Q_16>(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n-template aff3ct::module::Puncturer_polar_wangliu<B_32,Q_32>* aff3ct::factory::Puncturer_polar::build<B_32,Q_32>(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n-template aff3ct::module::Puncturer_polar_wangliu<B_64,Q_64>* aff3ct::factory::Puncturer_polar::build<B_64,Q_64>(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n+template aff3ct::module::Puncturer_polar_shortlast<B_8 ,Q_8 >* aff3ct::factory::Puncturer_polar::parameters::build<B_8 ,Q_8 >(const aff3ct::tools::Frozenbits_generator&) const;\n+template aff3ct::module::Puncturer_polar_shortlast<B_16,Q_16>* aff3ct::factory::Puncturer_polar::parameters::build<B_16,Q_16>(const aff3ct::tools::Frozenbits_generator&) const;\n+template aff3ct::module::Puncturer_polar_shortlast<B_32,Q_32>* aff3ct::factory::Puncturer_polar::parameters::build<B_32,Q_32>(const aff3ct::tools::Frozenbits_generator&) const;\n+template aff3ct::module::Puncturer_polar_shortlast<B_64,Q_64>* aff3ct::factory::Puncturer_polar::parameters::build<B_64,Q_64>(const aff3ct::tools::Frozenbits_generator&) const;\n+template aff3ct::module::Puncturer_polar_shortlast<B_8 ,Q_8 >* aff3ct::factory::Puncturer_polar::build<B_8 ,Q_8 >(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n+template aff3ct::module::Puncturer_polar_shortlast<B_16,Q_16>* aff3ct::factory::Puncturer_polar::build<B_16,Q_16>(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n+template aff3ct::module::Puncturer_polar_shortlast<B_32,Q_32>* aff3ct::factory::Puncturer_polar::build<B_32,Q_32>(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n+template aff3ct::module::Puncturer_polar_shortlast<B_64,Q_64>* aff3ct::factory::Puncturer_polar::build<B_64,Q_64>(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n#else\n-template aff3ct::module::Puncturer_polar_wangliu<B,Q>* aff3ct::factory::Puncturer_polar::parameters::build<B,Q>(const aff3ct::tools::Frozenbits_generator&) const;\n-template aff3ct::module::Puncturer_polar_wangliu<B,Q>* aff3ct::factory::Puncturer_polar::build<B,Q>(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n+template aff3ct::module::Puncturer_polar_shortlast<B,Q>* aff3ct::factory::Puncturer_polar::parameters::build<B,Q>(const aff3ct::tools::Frozenbits_generator&) const;\n+template aff3ct::module::Puncturer_polar_shortlast<B,Q>* aff3ct::factory::Puncturer_polar::build<B,Q>(const aff3ct::factory::Puncturer_polar::parameters&, const aff3ct::tools::Frozenbits_generator&);\n#endif\n// ==================================================================================== explicit template instantiation\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Puncturer/Polar/Puncturer_polar.hpp", "new_path": "src/Factory/Module/Puncturer/Polar/Puncturer_polar.hpp", "diff": "#include \"Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator.hpp\"\n-#include \"Module/Puncturer/Polar/Puncturer_polar_wangliu.hpp\"\n+#include \"Module/Puncturer/Polar/Puncturer_polar_shortlast.hpp\"\n#include \"../Puncturer.hpp\"\n@@ -33,11 +33,11 @@ struct Puncturer_polar : public Puncturer\n// builder\ntemplate <typename B = int, typename Q = float>\n- module::Puncturer_polar_wangliu<B,Q>* build(const tools::Frozenbits_generator &fb_generator) const;\n+ module::Puncturer_polar_shortlast<B,Q>* build(const tools::Frozenbits_generator &fb_generator) const;\n};\ntemplate <typename B = int, typename Q = float>\n- static module::Puncturer_polar_wangliu<B,Q>* build(const parameters &params,\n+ static module::Puncturer_polar_shortlast<B,Q>* build(const parameters &params,\nconst tools::Frozenbits_generator &fb_generator);\n};\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Codec/Polar/Codec_polar.cpp", "new_path": "src/Module/Codec/Polar/Codec_polar.cpp", "diff": "@@ -20,7 +20,7 @@ Codec_polar<B,Q>\nfrozen_bits(fb_params.N_cw, true),\ngenerated_decoder((dec_params.implem.find(\"_SNR\") != std::string::npos)),\nfb_generator (nullptr),\n- puncturer_wangliu(nullptr),\n+ puncturer_shortlast(nullptr),\nfb_decoder (nullptr),\nfb_encoder (nullptr)\n{\n@@ -83,8 +83,8 @@ Codec_polar<B,Q>\n{\ntry\n{\n- puncturer_wangliu = factory::Puncturer_polar::build<B,Q>(*pct_params, *fb_generator);\n- this->set_puncturer(puncturer_wangliu);\n+ puncturer_shortlast = factory::Puncturer_polar::build<B,Q>(*pct_params, *fb_generator);\n+ this->set_puncturer(puncturer_shortlast);\n}\ncatch(tools::cannot_allocate const&)\n{\n@@ -155,7 +155,7 @@ void Codec_polar<B,Q>\n::notify_frozenbits_update()\n{\nif (this->N_cw != this->N)\n- puncturer_wangliu->gen_frozen_bits(frozen_bits);\n+ puncturer_shortlast->gen_frozen_bits(frozen_bits);\nif (this->fb_decoder)\nthis->fb_decoder->notify_frozenbits_update();\nif (this->fb_encoder)\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Codec/Polar/Codec_polar.hpp", "new_path": "src/Module/Codec/Polar/Codec_polar.hpp", "diff": "#include \"Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator.hpp\"\n#include \"Tools/Code/Polar/Frozenbits_notifier.hpp\"\n-#include \"Module/Puncturer/Polar/Puncturer_polar_wangliu.hpp\"\n+#include \"Module/Puncturer/Polar/Puncturer_polar_shortlast.hpp\"\n#include \"Factory/Module/Encoder/Polar/Encoder_polar.hpp\"\n#include \"Factory/Module/Decoder/Polar/Decoder_polar.hpp\"\n@@ -25,7 +25,7 @@ protected:\nstd::vector<bool> frozen_bits; // known bits (alias frozen bits) are set to true\nconst bool generated_decoder;\ntools::Frozenbits_generator *fb_generator;\n- Puncturer_polar_wangliu<B,Q> *puncturer_wangliu;\n+ Puncturer_polar_shortlast<B,Q> *puncturer_shortlast;\ntools::Frozenbits_notifier *fb_decoder;\ntools::Frozenbits_notifier *fb_encoder;\n" }, { "change_type": "RENAME", "old_path": "src/Module/Puncturer/Polar/Puncturer_polar_wangliu.cpp", "new_path": "src/Module/Puncturer/Polar/Puncturer_polar_shortlast.cpp", "diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Math/utils.h\"\n-#include \"Puncturer_polar_wangliu.hpp\"\n+#include \"Puncturer_polar_shortlast.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\ntemplate <typename B, typename Q>\n-Puncturer_polar_wangliu<B,Q>\n-::Puncturer_polar_wangliu(const int &K,\n+Puncturer_polar_shortlast<B,Q>\n+::Puncturer_polar_shortlast(const int &K,\nconst int &N,\nconst tools::Frozenbits_generator &fb_generator,\nconst int n_frames)\n: Puncturer<B,Q>(K, N, (int)std::exp2(std::ceil(std::log2(N))), n_frames),\nfb_generator(fb_generator)\n{\n- const std::string name = \"Puncturer_polar_wangliu\";\n+ const std::string name = \"Puncturer_polar_shortlast\";\nthis->set_name(name);\nif (fb_generator.get_K() != K)\n@@ -39,13 +39,13 @@ Puncturer_polar_wangliu<B,Q>\n}\ntemplate <typename B, typename Q>\n-Puncturer_polar_wangliu<B,Q>\n-::~Puncturer_polar_wangliu()\n+Puncturer_polar_shortlast<B,Q>\n+::~Puncturer_polar_shortlast()\n{\n}\ntemplate <typename B, typename Q>\n-void Puncturer_polar_wangliu<B,Q>\n+void Puncturer_polar_shortlast<B,Q>\n::gen_frozen_bits(std::vector<bool> &frozen_bits)\n{\nauto best_channels = fb_generator.get_best_channels();\n@@ -68,14 +68,14 @@ void Puncturer_polar_wangliu<B,Q>\n}\ntemplate <typename B, typename Q>\n-void Puncturer_polar_wangliu<B,Q>\n+void Puncturer_polar_shortlast<B,Q>\n::_puncture(const B *X_N1, B *X_N2, const int frame_id) const\n{\nstd::copy(X_N1, X_N1 + this->N, X_N2);\n}\ntemplate <typename B, typename Q>\n-void Puncturer_polar_wangliu<B,Q>\n+void Puncturer_polar_shortlast<B,Q>\n::_depuncture(const Q *Y_N1, Q *Y_N2, const int frame_id) const\n{\nstd::copy(Y_N1, Y_N1 + this->N, Y_N2);\n@@ -87,11 +87,11 @@ void Puncturer_polar_wangliu<B,Q>\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template class aff3ct::module::Puncturer_polar_wangliu<B_8,Q_8>;\n-template class aff3ct::module::Puncturer_polar_wangliu<B_16,Q_16>;\n-template class aff3ct::module::Puncturer_polar_wangliu<B_32,Q_32>;\n-template class aff3ct::module::Puncturer_polar_wangliu<B_64,Q_64>;\n+template class aff3ct::module::Puncturer_polar_shortlast<B_8,Q_8>;\n+template class aff3ct::module::Puncturer_polar_shortlast<B_16,Q_16>;\n+template class aff3ct::module::Puncturer_polar_shortlast<B_32,Q_32>;\n+template class aff3ct::module::Puncturer_polar_shortlast<B_64,Q_64>;\n#else\n-template class aff3ct::module::Puncturer_polar_wangliu<B,Q>;\n+template class aff3ct::module::Puncturer_polar_shortlast<B,Q>;\n#endif\n// ==================================================================================== explicit template instantiation\n" }, { "change_type": "RENAME", "old_path": "src/Module/Puncturer/Polar/Puncturer_polar_wangliu.hpp", "new_path": "src/Module/Puncturer/Polar/Puncturer_polar_shortlast.hpp", "diff": "-#ifndef PUNCTURER_POLAR_WANGLIU_HPP_\n-#define PUNCTURER_POLAR_WANGLIU_HPP_\n+#ifndef PUNCTURER_POLAR_SHORTLAST_HPP_\n+#define PUNCTURER_POLAR_SHORTLAST_HPP_\n#include \"Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator.hpp\"\n@@ -10,17 +10,17 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename B = int, typename Q = float>\n-class Puncturer_polar_wangliu : public Puncturer<B,Q>\n+class Puncturer_polar_shortlast : public Puncturer<B,Q>\n{\nprotected:\nconst tools::Frozenbits_generator &fb_generator;\npublic:\n- Puncturer_polar_wangliu(const int &K,\n+ Puncturer_polar_shortlast(const int &K,\nconst int &N,\nconst tools::Frozenbits_generator &fb_generator,\nconst int n_frames = 1);\n- virtual ~Puncturer_polar_wangliu();\n+ virtual ~Puncturer_polar_shortlast();\nvoid gen_frozen_bits(std::vector<bool> &frozen_bits);\n@@ -31,4 +31,4 @@ protected:\n}\n}\n-#endif /* PUNCTURER_POLAR_WANGLIU_HPP_ */\n+#endif /* PUNCTURER_POLAR_SHORTLAST_HPP_ */\n" }, { "change_type": "MODIFY", "old_path": "src/aff3ct.hpp", "new_path": "src/aff3ct.hpp", "diff": "#include <Module/Monitor/Monitor.hpp>\n#include <Module/Puncturer/LDPC/Puncturer_LDPC.hpp>\n#include <Module/Puncturer/NO/Puncturer_NO.hpp>\n-#include <Module/Puncturer/Polar/Puncturer_polar_wangliu.hpp>\n+#include <Module/Puncturer/Polar/Puncturer_polar_shortlast.hpp>\n#include <Module/Puncturer/Puncturer.hpp>\n#include <Module/Puncturer/Turbo/Puncturer_turbo.hpp>\n#include <Module/Puncturer/Turbo_DB/Puncturer_turbo_DB.hpp>\n" } ]
C++
MIT License
aff3ct/aff3ct
Rename wangliu to shortlast, add refs.
8,483
25.07.2018 10:30:41
-7,200
39127709b1ec398001a7c224a79884d126668dbe
Add the beta management in the TPC and add commentaries
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "new_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "diff": "@@ -98,6 +98,7 @@ void Decoder_turbo_product::parameters\nargs.erase({pi+\"-fra\", \"F\"});\ntools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"CP\");\n+ tools::add_options(args.at({p+\"-implem\" }), 0, \"FAST\");\nargs.add(\n@@ -108,9 +109,16 @@ void Decoder_turbo_product::parameters\nargs.add(\n{p+\"-alpha\"},\ntools::List<float,Real_splitter>(tools::Real(), tools::Length(1)),\n- \"extrinsic coefficients, one by half iteration (so twice more than number of iterations).\"\n+ \"weighting factor, one by half iteration (so twice more than number of iterations).\"\n\" If not enough given values, then automatically extends the last to all iterations.\");\n+ args.add(\n+ {p+\"-beta\"},\n+ tools::List<float,Real_splitter>(tools::Real(tools::Positive()), tools::Length(1)),\n+ \"reliability factor, one by half iteration (so twice more than number of iterations).\"\n+ \" If not enough given values, then automatically extends the last to all iterations.\"\n+ \" If not given, then computes beta dynamically from the least reliable position metrics.\");\n+\nargs.add(\n{p+\"-p\"},\ntools::Integer(tools::Positive(), tools::Non_zero()),\n@@ -177,6 +185,16 @@ void Decoder_turbo_product::parameters\nthis->alpha.resize(this->n_ite*2, 0.5f);\n}\n+ if(vals.exist({p+\"-beta\"}))\n+ {\n+ this->beta = vals.to_list<float>({p+\"-beta\"});\n+ this->beta.resize(this->n_ite*2, beta.back());\n+ }\n+ else\n+ {\n+ this->beta.clear();\n+ }\n+\nif(vals.exist({p+\"-cp-coef\"}))\nthis->cp_coef = vals.to_list<float>({p+\"-cp-coef\"});\n@@ -231,6 +249,17 @@ void Decoder_turbo_product::parameters\nheaders[p].push_back(std::make_pair(\"alpha\", alpha_str.str()));\n+ if (this->beta.size())\n+ {\n+ std::stringstream beta_str;\n+ beta_str << \"{\";\n+ for (unsigned i = 0; i < this->beta.size(); i++)\n+ beta_str << this->beta[i] << (i == this->beta.size()-1 ?\"\":\", \");\n+ beta_str << \"}\";\n+\n+ headers[p].push_back(std::make_pair(\"beta\", beta_str.str()));\n+ }\n+\nstd::stringstream cp_coeff_str;\ncp_coeff_str << \"{\";\nfor (unsigned i = 0; i < this->cp_coef.size(); i++)\n@@ -267,7 +296,7 @@ module::Decoder_SIHO<B,Q>* Decoder_turbo_product::parameters\nif (this->type == \"CP\")\n{\nif (this->implem == \"STD\")\n- return new module::Decoder_turbo_product<B,Q>(n_ite, alpha, itl, cp_r, cp_c, n_frames);\n+ return new module::Decoder_turbo_product<B,Q>(n_ite, alpha, itl, cp_r, cp_c, beta, n_frames);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.hpp", "new_path": "src/Factory/Module/Decoder/Turbo_product/Decoder_turbo_product.hpp", "diff": "@@ -30,6 +30,7 @@ struct Decoder_turbo_product : public Decoder\n// optional parameters\nint n_ite = 4;\nstd::vector<float> alpha;\n+ std::vector<float> beta;\nstd::vector<float> cp_coef;\nint n_least_reliable_positions = 2;\nint n_test_vectors = 0;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Codec/Turbo_product/Codec_turbo_product.cpp", "new_path": "src/Module/Codec/Turbo_product/Codec_turbo_product.cpp", "diff": "@@ -93,6 +93,10 @@ Codec_turbo_product<B,Q>\ndec_bch_rows = dynamic_cast<Decoder_BCH<B,Q>*>(factory::Decoder_BCH::build_hiho<B,Q>(*dec_params.sub, GF_poly, enc_bch_rows));\ndec_bch_cols = dynamic_cast<Decoder_BCH<B,Q>*>(factory::Decoder_BCH::build_hiho<B,Q>(*dec_params.sub, GF_poly, enc_bch_cols));\n+\n+ if (dec_params.implem == \"FAST\")\n+ {\n+\ncp_rows = new Decoder_chase_pyndiah_fast<B,Q>(dec_bch_rows->get_K(), N_cw_p, N_cw_p,\n*dec_bch_rows, *enc_bch_rows,\ndec_params.n_least_reliable_positions,\n@@ -106,7 +110,25 @@ Codec_turbo_product<B,Q>\ndec_params.n_test_vectors,\ndec_params.n_competitors,\ndec_params.cp_coef);\n+ }\n+ else\n+ {\n+ cp_rows = new Decoder_chase_pyndiah<B,Q>(dec_bch_rows->get_K(), N_cw_p, N_cw_p,\n+ *dec_bch_rows, *enc_bch_rows,\n+ dec_params.n_least_reliable_positions,\n+ dec_params.n_test_vectors,\n+ dec_params.n_competitors,\n+ dec_params.cp_coef);\n+\n+ cp_cols = new Decoder_chase_pyndiah<B,Q>(dec_bch_cols->get_K(), N_cw_p, N_cw_p,\n+ *dec_bch_cols, *enc_bch_cols,\n+ dec_params.n_least_reliable_positions,\n+ dec_params.n_test_vectors,\n+ dec_params.n_competitors,\n+ dec_params.cp_coef);\n+ }\n+ (*const_cast<std::string*>(&dec_params.implem)) = \"STD\";\nEncoder_turbo_product<B> *encoder_tpc = nullptr;\ntry\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.cpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.cpp", "diff": "@@ -45,7 +45,8 @@ Decoder_chase_pyndiah<B,R>\nhard_Y_N (this->N ),\ntest_vect (n_test_vectors * hard_Y_N.size() ),\nmetrics (n_test_vectors ),\n- is_wrong (n_test_vectors )\n+ is_wrong (n_test_vectors ),\n+ beta_is_set (false )\n{\nconst std::string name = \"Decoder_chase_pyndiah\";\nthis->set_name(name);\n@@ -111,6 +112,28 @@ const std::vector<uint32_t>& Decoder_chase_pyndiah<B,R>\nreturn enc.get_info_bits_pos();\n}\n+template <typename B, typename R>\n+void Decoder_chase_pyndiah<B,R>\n+::set_beta(R b)\n+{\n+ if (b < (R)0.)\n+ {\n+ std::stringstream message;\n+ message << \"beta value 'b' has to be positive or null ('b' = \" << b << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ beta_is_set = true;\n+ beta = b;\n+}\n+\n+template <typename B, typename R>\n+void Decoder_chase_pyndiah<B,R>\n+::clear_beta()\n+{\n+ beta_is_set = false;\n+}\n+\ntemplate <typename B, typename R>\nvoid Decoder_chase_pyndiah<B,R>\n::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n@@ -359,16 +382,22 @@ void Decoder_chase_pyndiah<B,R>\n{\nconst auto & DW = competitors.front(); // the Decided Word\n+ R beta_applied = this->beta;\n+\n+ if (!this->beta_is_set)\n+ {\n// compute beta, the sum of the least reliable position reliabilities in the decided word\n- R beta = 0;\n+ beta_applied = 0;\nint max_sum = cp_coef[4] ? std::min((int)cp_coef[4], n_least_reliable_positions) : n_least_reliable_positions;\nfor (int i = 0; i < max_sum; i++)\n- beta += least_reliable_pos[i].metric;\n+ beta_applied += least_reliable_pos[i].metric;\n+\n+ beta_applied -= cp_coef[2] * DW.metric;\n+ }\n- beta -= cp_coef[2] * DW.metric;\n#ifndef NDEBUG_TPC\n- std::cerr << \"beta = \" << beta << \", DW.metric = \" << DW.metric << std::endl;\n+ std::cerr << \"beta = \" << beta_applied << \", DW.metric = \" << DW.metric << std::endl;\n#endif\nn_good_competitors = std::min(n_good_competitors, n_competitors); // if there is less than 'n_competitors' good competitors\n@@ -393,9 +422,13 @@ void Decoder_chase_pyndiah<B,R>\n{\nreliability = competitors[j].metric;\n}\n+ else if (beta_is_set)\n+ {\n+ reliability = this->beta;\n+ }\nelse // same bits for each candidates\n{\n- reliability = beta + cp_coef[3] * std::abs(Y_N1[i]);\n+ reliability = beta_applied + cp_coef[3] * std::abs(Y_N1[i]);\nif (reliability < 0)\nreliability = 0;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah.hpp", "diff": "@@ -23,16 +23,18 @@ namespace module\n* - select the competitor with the smallest metric Dm -> get the decided word D\n* - if SIHO, return D, if SISO, compute reliabilities of each bit of D -> Pyndiah\n* Pyndiah :\n+ * - a, b, c, d and e are simulation constants changeable by the user\n* - Compute extrinsic W as\n* W = F - a * R\n* - Compute the reliability F of D as, for each bit j of the word:\n- * Fj = Dj * [Cm - Dm] * b when Cj /= Dj in the competitor with the smallest metric Cm\n- * = Dj * [beta - c * Dm + d * |Rj|] when there is no such competitor as described above\n+ * - when Cj /= Dj in the competitor with the smallest metric Cm:\n+ * Fj = Dj * [Cm - Dm] * b\n+ * - when there is no such competitor as described above\n+ * Fj = Dj * beta when set by user with 'set_beta' method, or\n+ * Fj = Dj * [slm - c * Dm + d * |Rj|] with 'slm' the sum from 0 to e of the least reliable metrics Pm\n+ * where 0 < e < p. If e == 0 then sum all Pm.\n* with Dj = 1 when Hj = 0\n* = -1 when Hj = 1\n- * with beta = sum from 0 to e of the Pm where 0 <= e < p\n-\n- * - a, b, c, d and e are simulation constants changeable by the user\n*/\ntemplate <typename B = int, typename R = float>\n@@ -67,6 +69,10 @@ protected:\nstd::vector<bool> is_wrong; // if true then the matching test vector is not a codeword\nstd::vector<std::vector<bool>> test_patterns; // the patterns of the least reliable position to flip\n+\n+ R beta;\n+ bool beta_is_set;\n+\npublic:\nDecoder_chase_pyndiah(const int K, const int N, // N with the parity bit if any\n@@ -87,6 +93,11 @@ public:\nconst std::vector<uint32_t>& get_info_bits_pos();\n+ // set the value of beta to use it in the reliability computation\n+ // when beta is clear, then compute it dynamically\n+ void set_beta(R b);\n+ void clear_beta();\n+\nprotected:\nvirtual void decode_chase (const R *Y_N, const int frame_id);\nvirtual void find_least_reliable_pos(const R* Y_N);\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.cpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.cpp", "diff": "@@ -90,13 +90,19 @@ void Decoder_chase_pyndiah_fast<B,R>\n{\nconst auto & DW = this->competitors.front(); // the Decided Word\n+ R beta_applied = this->beta;\n+\n+ if (!this->beta_is_set)\n+ {\n// compute beta, the sum of the least reliable position reliabilities in the decided word\n- R beta = 0;\n+ beta_applied = 0;\nint max_sum = this->cp_coef[4] ? std::min((int)this->cp_coef[4], this->n_least_reliable_positions) : this->n_least_reliable_positions;\nfor (int i = 0; i < max_sum; i++)\n- beta += this->least_reliable_pos[i].metric;\n+ beta_applied += this->least_reliable_pos[i].metric;\n+\n+ beta_applied -= this->cp_coef[2] * DW.metric;\n+ }\n- beta -= this->cp_coef[2] * DW.metric;\nthis->n_good_competitors = std::min(this->n_good_competitors, this->n_competitors); // if there is less than 'this->n_competitors' good this->competitors\n// then take only them for reliability calculation\n@@ -108,13 +114,41 @@ void Decoder_chase_pyndiah_fast<B,R>\nconst auto N_loop_size = (this->N / mipp::nElReg<B>()) * mipp::nElReg<B>();\nconst mipp::Reg<R> r_zero = (R)0;\n+ const mipp::Reg<R> r_beta = beta_applied;\n+\n+\n+ if (this->beta_is_set)\n+ {\n+ for (auto i = 0; i < N_loop_size; i += mipp::nElReg<R>())\n+ {\n+ const mipp::Reg<B> r_DB = &this->test_vect[DW.pos + i];\n+ const mipp::Reg<R> r_Y1 = &Y_N1[i];\n+\n+ mipp::Reg<R> r_reliability = r_beta;\n+\n+\n+ for (B j = this->n_good_competitors -1; j > 0; j--) // j = 0 == DW\n+ {\n+ const mipp::Reg<B> r_comp_bit = &this->test_vect[this->competitors[j].pos + i];\n+ const mipp::Reg<R> r_comp_met = this->competitors[j].metric;\n+\n+ r_reliability = mipp::blend(r_reliability, r_comp_met, r_comp_bit == r_DB);\n+ }\n+\n+ r_reliability = mipp::neg(r_reliability, r_DB != (B)0);\n+ r_reliability -= r_Y1 * this->cp_coef[0];\n+ r_reliability.store(&Y_N2[i]);\n+ }\n+ }\n+ else\n+ {\nfor (auto i = 0; i < N_loop_size; i += mipp::nElReg<R>())\n{\nconst mipp::Reg<B> r_DB = &this->test_vect[DW.pos + i];\nconst mipp::Reg<R> r_Y1 = &Y_N1[i];\n- mipp::Reg<R> r_reliability = mipp::abs(r_Y1) * this->cp_coef[3] + beta; // reliability when no competitor with different bit\n+ mipp::Reg<R> r_reliability = mipp::abs(r_Y1) * this->cp_coef[3] + r_beta; // reliability when no competitor with different bit\nr_reliability = mipp::blend(r_zero, r_reliability, r_reliability < (R)0);\n@@ -131,6 +165,8 @@ void Decoder_chase_pyndiah_fast<B,R>\nr_reliability.store(&Y_N2[i]);\n}\n+ }\n+\nfor (int i = N_loop_size; i < this->N; i++)\n{\n@@ -147,9 +183,13 @@ void Decoder_chase_pyndiah_fast<B,R>\n{\nreliability = this->competitors[j].metric;\n}\n+ else if (this->beta_is_set)\n+ {\n+ reliability = this->beta;\n+ }\nelse // same bits for each candidates\n{\n- reliability = beta + this->cp_coef[3] * std::abs(Y_N1[i]);\n+ reliability = beta_applied + this->cp_coef[3] * std::abs(Y_N1[i]);\nif (reliability < 0)\nreliability = 0;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.hpp", "new_path": "src/Module/Decoder/Turbo_product/Chase_pyndiah/Decoder_chase_pyndiah_fast.hpp", "diff": "@@ -10,27 +10,6 @@ namespace aff3ct\nnamespace module\n{\n-/*\n- * Chase :\n- * - take hard decision H on input R\n- * - create test vectors from test patterns after selecting the p least reliable positions -> give a p metric set Pm\n- * - hard decode with the HIHO decoder -> get the competitors C -> remove competitors that have not been corrected\n- * - compute the metrics Cm: euclidean distance of each competitor m compared to H\n- * - select the competitor with the smallest metric Dm -> get the decided word D\n- * - if SIHO, return D, if SISO, compute reliabilities of each bit of D -> Pyndiah\n- * Pyndiah :\n- * - Compute extrinsic W as\n- * W = F - a * R\n- * - Compute the reliability F of D as, for each bit j of the word:\n- * Fj = Dj * [Cm - Dm] * b when Cj /= Dj in the competitor with the smallest metric Cm\n- * = Dj * [beta - c * Dm + d * |Rj|] when there is no such competitor as described above\n- * with Dj = 1 when Hj = 0\n- * = -1 when Hj = 1\n- * with beta = sum from 0 to e of the Pm where 0 <= e < p\n-\n- * - a, b, c, d and e are simulation constants changeable by the user\n- */\n-\ntemplate <typename B = int, typename R = float>\nclass Decoder_chase_pyndiah_fast : public Decoder_chase_pyndiah<B,R>\n{\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "new_path": "src/Module/Decoder/Turbo_product/Decoder_turbo_product.cpp", "diff": "@@ -20,11 +20,13 @@ Decoder_turbo_product<B,R>\nconst Interleaver<R>& pi,\nDecoder_chase_pyndiah<B,R> &cp_r,\nDecoder_chase_pyndiah<B,R> &cp_c,\n+ const std::vector<float>& beta,\nconst int n_frames)\n: Decoder (cp_r.get_K() * cp_c.get_K(), pi.get_core().get_size(), n_frames, 1),\nDecoder_SISO_SIHO<B,R>(cp_r.get_K() * cp_c.get_K(), pi.get_core().get_size(), n_frames, 1),\nn_ite(n_ite),\nalpha(alpha),\n+ beta (beta ),\npi (pi ),\ncp_r (cp_r ),\ncp_c (cp_c ),\n@@ -53,6 +55,13 @@ Decoder_turbo_product<B,R>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ if (n_ite*2 != (int)beta.size() && beta.size() != 0)\n+ {\n+ std::stringstream message;\n+ message << \"'beta.size()' has to be twice 'n_ite' or null ('n_ite' = \" << n_ite << \" and 'beta.size()' = \" << alpha.size() << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nif (cp_r.get_n_frames() != cp_c.get_n_frames())\n{\nstd::stringstream message;\n@@ -97,6 +106,12 @@ Decoder_turbo_product<B,R>\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n+\n+ if (beta.size())\n+ {\n+ cp_r.clear_beta();\n+ cp_c.clear_beta();\n+ }\n}\ntemplate <typename B, typename R>\n@@ -181,6 +196,12 @@ void Decoder_turbo_product<B,R>\n{\npi.interleave(Y_N_i.data(), Y_N_pi.data(), 0, 1); // columns becomes rows\n+ if (beta.size())\n+ {\n+ cp_c.set_beta((R)beta[2*i+0]);\n+ cp_r.set_beta((R)beta[2*i+1]);\n+ }\n+\n// decode each col\nfor (int j = 0; j < n_cols; j++)\n{\n@@ -200,7 +221,7 @@ void Decoder_turbo_product<B,R>\npi.deinterleave(Y_N_pi.data(), Y_N_i.data(), 0, 1); // rows go back as columns\n// decode each row\n- if (i < (n_ite -1) || return_K_siso == 2)\n+ if (i < (n_ite -1) || return_K_siso >= 2)\n{\nfor (int j = 0; j < n_rows; j++)\n{\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Turbo_product/Decoder_turbo_product.hpp", "new_path": "src/Module/Decoder/Turbo_product/Decoder_turbo_product.hpp", "diff": "@@ -14,12 +14,26 @@ namespace aff3ct\nnamespace module\n{\n+/*\n+ * Iteration column by column and then row by row, calling respectively cp_c and cp_r.\n+ * Compute LLR iteration i:\n+ * - for columns:\n+ * Ri = Wi * alpha[2 * i + 0] + C\n+ * with Wi the results of the Chase Pyndiah decoder 'cp_c' on R(i-1) and C the input LLR from the demodulator\n+ * when 'beta' vector is given then set the beta value of 'cp_c' to beta[2 * i + 0]\n+ * - for rows:\n+ * Ri = Wi * alpha[2 * i + 1] + C\n+ * with Wi the results of the Chase Pyndiah decoder 'cp_r' on R(i-1) and C the input LLR from the demodulator\n+ * when 'beta' vector is given then set the beta value of 'cp_c' to beta[2 * i + 1]\n+ *\n+ */\ntemplate <typename B = int, typename R = float>\nclass Decoder_turbo_product : public Decoder_SISO_SIHO<B,R>\n{\nprotected:\nconst int n_ite; // number of iterations\nconst std::vector<float> alpha;\n+ const std::vector<float> beta;\nconst Interleaver<R> &pi;\nDecoder_chase_pyndiah<B,R> &cp_r; // row decoder\n@@ -38,6 +52,7 @@ public:\nconst Interleaver<R> &pi,\nDecoder_chase_pyndiah<B,R> &cp_r,\nDecoder_chase_pyndiah<B,R> &cp_c,\n+ const std::vector<float>& beta = {},\nconst int n_frames = 1);\nvirtual ~Decoder_turbo_product();\n@@ -46,7 +61,10 @@ protected:\nvoid _decode_siho (const R *Y_N, B *V_K, const int frame_id);\nvoid _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n- virtual void _decode(const R *Y_N, int return_K_siso); // return_K_siso = 0 then hard decode and fill V_K_i else if = 1 then hard decode and fill V_H_i else soft decode and fill Y_N_i\n+ // when return_K_siso = 0 then hard decode and fill V_K_i\n+ // else if = 1 then hard decode and fill V_H_i\n+ // else soft decode and fill Y_N_i\n+ virtual void _decode(const R *Y_N, int return_K_siso);\n};\n" } ]
C++
MIT License
aff3ct/aff3ct
Add the beta management in the TPC and add commentaries
8,483
25.07.2018 16:47:11
-7,200
d81b357cf1febee8343ca7ff44128a81d808e277
In decoder BCH std, change .at() accesses to []
[ { "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": "@@ -45,18 +45,18 @@ void Decoder_BCH_std<B, R>\n/* first form the syndromes */\nfor (i = 1; i <= t2; i++)\n{\n- s.at(i) = 0;\n+ s[i] = 0;\nfor (j = 0; j < this->N; j++)\nif (Y_N[j] != 0)\n- s.at(i) ^= alpha_to.at((i * j) % this->N_p2);\n- if (s.at(i) != 0)\n+ s[i] ^= alpha_to[(i * j) % this->N_p2];\n+ if (s[i] != 0)\nsyn_error = 1; /* set error flag if non-zero syndrome */\n/*\n* Note: If the code is used only for ERROR DETECTION, then\n* exit program here indicating the presence of errors.\n*/\n/* convert syndrome from polynomial form to index form */\n- s.at(i) = index_of.at(s.at(i));\n+ s[i] = index_of[s[i]];\n}\nthis->last_is_codeword = !syn_error;\n@@ -67,141 +67,140 @@ void Decoder_BCH_std<B, R>\n/*\n* Compute the error location polynomial via the Berlekamp\n* iterative algorithm. Following the terminology of Lin and\n- * Costello's book : d.at(u) is the 'mu'th discrepancy, where\n+ * Costello's book : d[u] is the 'mu'th discrepancy, where\n* u='mu'+1 and 'mu' (the Greek letter!) is the step number\n- * ranging from -1 to 2*this->t (see L&C), l.at(u) is the degree of\n- * the elp at that step, and u_l.at(u) is the difference between\n+ * ranging from -1 to 2*this->t (see L&C), l[u] is the degree of\n+ * the elp at that step, and u_l[u] is the difference between\n* the step number and the degree of the elp.\n*/\n/* initialise table entries */\n- discrepancy.at(0) = 0; /* index form */\n- discrepancy.at(1) = s.at(1); /* index form */\n- elp.at(0).at(0) = 0; /* index form */\n- elp.at(1).at(0) = 1; /* polynomial form */\n+ discrepancy[0] = 0; /* index form */\n+ discrepancy[1] = s[1]; /* index form */\n+ elp[0][0] = 0; /* index form */\n+ elp[1][0] = 1; /* polynomial form */\nfor (i = 1; i < t2; i++)\n{\n- elp.at(0).at(i) = -1; /* index form */\n- elp.at(1).at(i) = 0; /* polynomial form */\n+ elp[0][i] = -1; /* index form */\n+ elp[1][i] = 0; /* polynomial form */\n}\n- l.at(0) = 0;\n- l.at(1) = 0;\n- u_lu.at(0) = -1;\n- u_lu.at(1) = 0;\n+ l[0] = 0;\n+ l[1] = 0;\n+ u_lu[0] = -1;\n+ u_lu[1] = 0;\nint q, u = 0;\ndo\n{\nu++;\n- if (discrepancy.at(u) == -1)\n+ if (discrepancy[u] == -1)\n{\n- l.at(u + 1) = l.at(u);\n- for (i = 0; i <= l.at(u); i++)\n+ l[u + 1] = l[u];\n+ for (i = 0; i <= l[u]; i++)\n{\n- elp.at(u + 1).at(i) = elp.at(u).at(i);\n- elp.at(u).at(i) = index_of.at(elp.at(u).at(i));\n+ elp[u + 1][i] = elp[u][i];\n+ elp[u][i] = index_of[elp[u][i]];\n}\n}\nelse\n/*\n- * search for words with greatest u_lu.at(q) for\n- * which d.at(q)!=0\n+ * search for words with greatest u_lu[q] for\n+ * which d[q]!=0\n*/\n{\nq = u - 1;\n- while ((discrepancy.at(q) == -1) && (q > 0))\n+ while ((discrepancy[q] == -1) && (q > 0))\nq--;\n- /* have found first non-zero d.at(q) */\n+ /* have found first non-zero d[q] */\nif (q > 0)\n{\nj = q;\ndo\n{\nj--;\n- if ((discrepancy.at(j) != -1) && (u_lu.at(q) < u_lu.at(j)))\n+ if ((discrepancy[j] != -1) && (u_lu[q] < u_lu[j]))\nq = j;\n}\nwhile (j > 0);\n}\n/*\n- * have now found q such that d.at(u)!=0 and\n- * u_lu.at(q) is maximum\n+ * have now found q such that d[u]!=0 and\n+ * u_lu[q] is maximum\n*/\n/* store degree of new elp polynomial */\n- if (l.at(u) > l.at(q) + u - q)\n- l.at(u + 1) = l.at(u);\n+ if (l[u] > l[q] + u - q)\n+ l[u + 1] = l[u];\nelse\n- l.at(u + 1) = l.at(q) + u - q;\n+ l[u + 1] = l[q] + u - q;\n/* form new elp(x) */\nfor (i = 0; i < t2; i++)\n- elp.at(u + 1).at(i) = 0;\n- for (i = 0; i <= l.at(q); i++)\n- if (elp.at(q).at(i) != -1)\n- elp.at(u + 1).at(i + u - q) =\n- alpha_to.at((discrepancy.at(u) + this->N_p2 - discrepancy.at(q) + elp.at(q).at(i)) % this->N_p2);\n- for (i = 0; i <= l.at(u); i++)\n+ elp[u + 1][i] = 0;\n+ for (i = 0; i <= l[q]; i++)\n+ if (elp[q][i] != -1)\n+ elp[u + 1][i + u - q] =\n+ alpha_to[(discrepancy[u] + this->N_p2 - discrepancy[q] + elp[q][i]) % this->N_p2];\n+ for (i = 0; i <= l[u]; i++)\n{\n- elp.at(u + 1).at(i) ^= elp.at(u).at(i);\n- elp.at(u).at(i) = index_of.at(elp.at(u).at(i));\n+ elp[u + 1][i] ^= elp[u][i];\n+ elp[u][i] = index_of[elp[u][i]];\n}\n}\n- u_lu.at(u + 1) = u - l.at(u + 1);\n+ u_lu[u + 1] = u - l[u + 1];\n/* form (u+1)th discrepancy */\nif (u < t2)\n{\n/* no discrepancy computed on last iteration */\n- if (s.at(u + 1) != -1)\n- discrepancy.at(u + 1) = alpha_to.at(s.at(u + 1));\n+ if (s[u + 1] != -1)\n+ discrepancy[u + 1] = alpha_to[s[u + 1]];\nelse\n- discrepancy.at(u + 1) = 0;\n- for (i = 1; i <= l.at(u + 1); i++)\n- if ((s.at(u + 1 - i) != -1) && (elp.at(u + 1).at(i) != 0))\n- discrepancy.at(u + 1) ^= alpha_to.at((s.at(u + 1 - i) + index_of.at(elp.at(u + 1).at(i))) % this->N_p2);\n- /* put d.at(u+1) into index form */\n- discrepancy.at(u + 1) = index_of.at(discrepancy.at(u + 1));\n+ discrepancy[u + 1] = 0;\n+ for (i = 1; i <= l[u + 1]; i++)\n+ if ((s[u + 1 - i] != -1) && (elp[u + 1][i] != 0))\n+ discrepancy[u + 1] ^= alpha_to[(s[u + 1 - i] + index_of[elp[u + 1][i]]) % this->N_p2];\n+ /* put d[u+1] into index form */\n+ discrepancy[u + 1] = index_of[discrepancy[u + 1]];\n}\n}\n- while ((u < t2) && (l.at(u + 1) <= this->t));\n+ while ((u < t2) && (l[u + 1] <= this->t));\nu++;\n- if (l.at(u) <= this->t)\n+ if (l[u] <= this->t)\n{/* Can correct errors */\n/* put elp into index form */\n- for (i = 0; i <= l.at(u); i++)\n- elp.at(u).at(i) = index_of.at(elp.at(u).at(i));\n+ for (i = 0; i <= l[u]; i++)\n+ elp[u][i] = index_of[elp[u][i]];\n/* Chien search: find roots of the error location polynomial */\n- for (i = 1; i <= l.at(u); i++)\n- reg.at(i) = elp.at(u).at(i);\n-\n+ for (i = 1; i <= l[u]; i++)\n+ reg[i] = elp[u][i];\nint count = 0;\nfor (i = 1; i <= this->N_p2; i++)\n{\nq = 1;\n- for (j = 1; j <= l.at(u); j++)\n- if (reg.at(j) != -1)\n+ for (j = 1; j <= l[u]; j++)\n+ if (reg[j] != -1)\n{\n- reg.at(j) = (reg.at(j) + j) % this->N_p2;\n- q ^= alpha_to.at(reg.at(j));\n+ reg[j] = (reg[j] + j) % this->N_p2;\n+ q ^= alpha_to[reg[j]];\n}\nif (!q)\n{ /* store root and error\n* location number indices */\n- loc.at(count) = this->N_p2 - i;\n+ loc[count] = this->N_p2 - i;\ncount++;\n}\n}\n- if (count == l.at(u))\n+ if (count == l[u])\n{\nthis->last_is_codeword = true;\n/* no. roots = degree of elp hence <= this->t errors */\n- for (i = 0; i < l.at(u); i++)\n- if (loc.at(i) < this->N)\n- Y_N[loc.at(i)] ^= 1;\n+ for (i = 0; i < l[u]; i++)\n+ if (loc[i] < this->N)\n+ Y_N[loc[i]] ^= 1;\n}\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
In decoder BCH std, change .at() accesses to []
8,483
27.07.2018 09:36:23
-7,200
5c9c0775ae85a047aa7be4f003fc32dc58e5a67d
Replace BCH N_p2 variable name by N_p2_1
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Decoder_BCH.cpp", "new_path": "src/Module/Decoder/BCH/Decoder_BCH.cpp", "diff": "@@ -15,7 +15,7 @@ Decoder_BCH<B, R>\n::Decoder_BCH(const int K, const int N, const int t, const int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_SIHO_HIHO<B,R>(K, N, n_frames, 1),\n- t(t), N_p2(tools::next_power_of_2(N) -1), YH_N(N)\n+ t(t), N_p2_1(tools::next_power_of_2(N) -1), YH_N(N)\n{\nconst std::string name = \"Decoder_BCH\";\nthis->set_name(name);\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Decoder_BCH.hpp", "new_path": "src/Module/Decoder/BCH/Decoder_BCH.hpp", "diff": "@@ -16,7 +16,7 @@ class Decoder_BCH : public Decoder_SIHO_HIHO<B,R>\n{\nprotected:\nconst int t; // correction power\n- const int N_p2; // the next power 2 of N minus 1\n+ const int N_p2_1; // the next power 2 of N minus 1\nstd::vector<B> YH_N; // hard decision input vector\npublic:\n" }, { "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": "@@ -15,7 +15,7 @@ Decoder_BCH_std<B, R>\n: Decoder (K, N, n_frames, 1),\nDecoder_BCH<B,R>(K, N, GF_poly.get_t(), n_frames),\nt2(2 * this->t),\n- elp(this->N_p2+2, std::vector<int>(this->N_p2)), discrepancy(this->N_p2+2), l(this->N_p2+2), u_lu(this->N_p2+2), s(t2+1), loc(this->t +1), reg(this->t +1),\n+ elp(this->N_p2_1+2, std::vector<int>(this->N_p2_1)), discrepancy(this->N_p2_1+2), l(this->N_p2_1+2), u_lu(this->N_p2_1+2), s(t2+1), loc(this->t +1), reg(this->t +1),\nm(GF_poly.get_m()), d(GF_poly.get_d()), alpha_to(GF_poly.get_alpha_to()), index_of(GF_poly.get_index_of())\n{\nconst std::string name = \"Decoder_BCH_std\";\n@@ -48,7 +48,7 @@ void Decoder_BCH_std<B, R>\ns[i] = 0;\nfor (j = 0; j < this->N; j++)\nif (Y_N[j] != 0)\n- s[i] ^= alpha_to[(i * j) % this->N_p2];\n+ s[i] ^= alpha_to[(i * j) % this->N_p2_1];\nif (s[i] != 0)\nsyn_error = 1; /* set error flag if non-zero syndrome */\n/*\n@@ -139,7 +139,7 @@ void Decoder_BCH_std<B, R>\nfor (i = 0; i <= l[q]; i++)\nif (elp[q][i] != -1)\nelp[u + 1][i + u - q] =\n- alpha_to[(discrepancy[u] + this->N_p2 - discrepancy[q] + elp[q][i]) % this->N_p2];\n+ alpha_to[(discrepancy[u] + this->N_p2_1 - discrepancy[q] + elp[q][i]) % this->N_p2_1];\nfor (i = 0; i <= l[u]; i++)\n{\nelp[u + 1][i] ^= elp[u][i];\n@@ -158,7 +158,7 @@ void Decoder_BCH_std<B, R>\ndiscrepancy[u + 1] = 0;\nfor (i = 1; i <= l[u + 1]; i++)\nif ((s[u + 1 - i] != -1) && (elp[u + 1][i] != 0))\n- discrepancy[u + 1] ^= alpha_to[(s[u + 1 - i] + index_of[elp[u + 1][i]]) % this->N_p2];\n+ discrepancy[u + 1] ^= alpha_to[(s[u + 1 - i] + index_of[elp[u + 1][i]]) % this->N_p2_1];\n/* put d[u+1] into index form */\ndiscrepancy[u + 1] = index_of[discrepancy[u + 1]];\n}\n@@ -176,19 +176,19 @@ void Decoder_BCH_std<B, R>\nfor (i = 1; i <= l[u]; i++)\nreg[i] = elp[u][i];\nint count = 0;\n- for (i = 1; i <= this->N_p2; i++)\n+ for (i = 1; i <= this->N_p2_1; i++)\n{\nq = 1;\nfor (j = 1; j <= l[u]; j++)\nif (reg[j] != -1)\n{\n- reg[j] = (reg[j] + j) % this->N_p2;\n+ reg[j] = (reg[j] + j) % this->N_p2_1;\nq ^= alpha_to[reg[j]];\n}\nif (!q)\n{ /* store root and error\n* location number indices */\n- loc[count] = this->N_p2 - i;\n+ loc[count] = this->N_p2_1 - i;\ncount++;\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Replace BCH N_p2 variable name by N_p2_1
8,483
27.07.2018 13:28:54
-7,200
f0f3e327c625f8ec78fba8c17cac063fc7934157
Check m size in the Galois class to not be over 20
[ { "change_type": "MODIFY", "old_path": "src/Tools/Math/Galois.cpp", "new_path": "src/Tools/Math/Galois.cpp", "diff": "@@ -34,6 +34,13 @@ Galois\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ if (m > 20)\n+ {\n+ std::stringstream message;\n+ message << \"'m' is supported until 20 ('m' = \" << m << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nif (N != ((1 << m) -1))\n{\nstd::stringstream message;\n" } ]
C++
MIT License
aff3ct/aff3ct
Check m size in the Galois class to not be over 20
8,483
27.07.2018 13:29:20
-7,200
56f6cb7b7d3249b641372bdeb106affa3e86371a
Modify regression tests to ignore some files with '#CI IGNORE' as header
[ { "change_type": "MODIFY", "old_path": "refs", "new_path": "refs", "diff": "-Subproject commit 1eb3024b48dcde22a14269732a74e3f1479a7336\n+Subproject commit d93d14eaef2d54441ff10a818210d2d7e571c2cc\n" } ]
C++
MIT License
aff3ct/aff3ct
Modify regression tests to ignore some files with '#CI IGNORE' as header
8,483
27.07.2018 14:31:09
-7,200
a23890b44b9b2d33c14e996c9dbf04382b87d38a
Add management of #CI IGNORE in ci/test-build-coverage-regression.sh by reading the third line instead of the second to get the command line
[ { "change_type": "MODIFY", "old_path": "ci/test-build-coverage-regression.sh", "new_path": "ci/test-build-coverage-regression.sh", "diff": "@@ -24,6 +24,9 @@ function gen_coverage_info\nfor path in $folder/*\ndo [ -f $path ] && {\ncmd=$(cat $path | sed -n 2p)\n+ if [ cmd=='Run command:' ]; then\n+ cmd=$(cat $path | sed -n 3p)\n+ fi\necho $cmd\ncd $build\neval \"${cmd} --sim-stop-time 1 -t 1\"\n" } ]
C++
MIT License
aff3ct/aff3ct
Add management of #CI IGNORE in ci/test-build-coverage-regression.sh by reading the third line instead of the second to get the command line
8,483
27.07.2018 15:42:59
-7,200
773b774806d31f2b82b9d46d45c7ae08fee9db21
Check correcly the #CI IGNORE instruction
[ { "change_type": "MODIFY", "old_path": "ci/test-build-coverage-regression.sh", "new_path": "ci/test-build-coverage-regression.sh", "diff": "@@ -24,7 +24,7 @@ function gen_coverage_info\nfor path in $folder/*\ndo [ -f $path ] && {\ncmd=$(cat $path | sed -n 2p)\n- if [ cmd=='Run command:' ]; then\n+ if [ \"$cmd\" == 'Run command:' ]; then\ncmd=$(cat $path | sed -n 3p)\nfi\necho $cmd\n@@ -40,7 +40,7 @@ function gen_coverage_info\ndone\n}\n-compile \"${build_root}\"\n+#compile \"${build_root}\"\ncd ${WD}\ngen_coverage_info \"${build_root}\" \"refs\"\ncd ${WD}\n" } ]
C++
MIT License
aff3ct/aff3ct
Check correcly the #CI IGNORE instruction
8,483
30.07.2018 10:37:47
-7,200
96a0c736e565a9487d4f434caad81bfcdd8fda46
Use snake notation for Galois methods
[ { "change_type": "MODIFY", "old_path": "src/Tools/Math/Galois.cpp", "new_path": "src/Tools/Math/Galois.cpp", "diff": "@@ -48,8 +48,8 @@ Galois\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- Select_Polynomial();\n- Generate_GF();\n+ select_polynomial();\n+ generate_gf();\n}\nGalois\n@@ -88,7 +88,7 @@ const std::vector<int>& Galois\n}\nvoid Galois\n-::Select_Polynomial()\n+::select_polynomial()\n{\np[0] = p[m] = 1;\nif (m == 2) p[1] = 1;\n@@ -113,7 +113,7 @@ void Galois\n}\nvoid Galois\n-::Generate_GF()\n+::generate_gf()\n{\nint i, mask;\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Math/Galois.hpp", "new_path": "src/Tools/Math/Galois.hpp", "diff": "@@ -29,8 +29,8 @@ public:\nconst std::vector<int>& get_p () const;\nprivate:\n- void Select_Polynomial();\n- void Generate_GF();\n+ void select_polynomial();\n+ void generate_gf();\n};\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Use snake notation for Galois methods
8,483
30.07.2018 12:07:22
-7,200
82db6ec65e8914f09aa45ba9c06d313df065bd74
Enhance Bit packer and Frame trace Add an option in bit packer to pack/unpack different size of symbol : Number bits per symbols. Rewrite pack unpack core functions to be faster. Add a hex display function in Frame trace.
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Generic/Chase/Decoder_chase_std.cpp", "new_path": "src/Module/Decoder/Generic/Chase/Decoder_chase_std.cpp", "diff": "#include <algorithm>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Tools/Algo/Bit_packer.hpp\"\n#include \"Tools/Perf/common/hard_decide.h\"\n#include \"Decoder_chase_std.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood.hxx", "new_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood.hxx", "diff": "#include <iostream>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Tools/Algo/Bit_packer.hpp\"\n#include \"Tools/Perf/common/hard_decide.h\"\n#include \"Decoder_maximum_likelihood.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Algo/Bit_packer.hpp", "new_path": "src/Tools/Algo/Bit_packer.hpp", "diff": "#include <cmath>\n#include <sstream>\n#include <vector>\n+#include <climits>\n#include \"Tools/Exception/exception.hpp\"\n@@ -23,7 +24,7 @@ namespace tools\n*\n* \\brief Packs and unpacks bits.\n*\n- * \\tparam T: type of data to pack/unpack.\n+ * \\tparam B: type of data to pack/unpack.\n*/\ntemplate <typename B = int>\nstruct Bit_packer\n@@ -31,13 +32,14 @@ struct Bit_packer\n/*!\n* \\brief Packs bits.\n*\n- * \\param vec_in: an input vector of unpacked bits (only 1 bit per data is used to transport data).\n+ * \\param vec_in: an input vector of unpacked bits (only 1 bit per data is used to transport data) (used as size reference).\n* \\param vec_out: an output vector of packed bits.\n- * \\param rev: reverse the bitpaking storage order.\n+ * \\param msb_to_lsb: pack from MSB to LSB else from LSB to MSB\n+ * \\tparam Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n*/\ntemplate <class A = std::allocator<B>>\nstatic inline void pack(const std::vector<B,A> &vec_in, std::vector<B,A> &vec_out, const int n_frames = 1,\n- const bool rev = false)\n+ const bool msb_to_lsb = false, int Nbps = CHAR_BIT)\n{\nif (n_frames <= 0)\n{\n@@ -54,40 +56,58 @@ struct Bit_packer\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if ((int)vec_out.size() < (int)(std::ceil((float)vec_in.size() / (sizeof(B) * 8.f))))\n+ if ((vec_out.size() * sizeof(B) * Nbps) < vec_in.size())\n{\nstd::stringstream message;\n- message << \"'vec_out.size()' has to be equal or greater than ceil('vec_in.size()' / ('sizeof(B)' * 8.f)) \"\n+ message << \"('vec_out.size()' * 'sizeof(B)' * 'Nbps') has to be equal or greater than 'vec_in.size()' \"\n<< \"('vec_out.size()' = \" << vec_out.size() << \", 'vec_in.size()' = \" << vec_in.size()\n- << \", 'sizeof(B)' = \" << sizeof(B) << \").\";\n+ << \", 'sizeof(B)' = \" << sizeof(B) << \", 'Nbps' = \" << Nbps << \").\";\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- Bit_packer<B>::pack(vec_in.data(), vec_out.data(), (int)(vec_in.size() / n_frames), n_frames, rev);\n+ Bit_packer<B>::pack(vec_in.data(), vec_out.data(), (int)(vec_in.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n}\nstatic inline void pack(const B *vec_in, B *vec_out, const int n_bits_per_frame,\n- const int n_frames = 1, const bool rev = false)\n+ const int n_frames = 1, const bool msb_to_lsb = false, int Nbps = CHAR_BIT)\n{\n- const auto n_bytes_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / 8.f));\n+ if (Nbps > CHAR_BIT && Nbps <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = \" << Nbps << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (n_bits_per_frame % Nbps)\n+ {\n+ std::stringstream message;\n+ message << \"'n_bits_per_frame' has to be divisible by 'Nbps' ('n_bits_per_frame' = \" << n_bits_per_frame\n+ << \", 'Nbps' = \" << Nbps << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n- unsigned char* bytes_out = (unsigned char*)vec_out;\n+ const auto n_bytes_per_frame = n_bits_per_frame / Nbps;\n+\n+ auto bytes_out = (unsigned char*)vec_out;\nfor (auto f = 0; f < n_frames; f++)\nBit_packer<B>::_pack(vec_in + f * n_bits_per_frame,\nbytes_out + f * n_bytes_per_frame,\nn_bits_per_frame,\n- rev);\n+ msb_to_lsb,\n+ Nbps);\n}\n/*!\n* \\brief Packs bits.\n*\n* \\param vec: a vector of unpacked bits (only 1 bit per data is used to transport data).\n- * \\param rev: reverse the bitpaking storage order.\n+ * \\param msb_to_lsb: pack from MSB to LSB else from LSB to MSB\n+ * \\tparam Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n*/\ntemplate <class A = std::allocator<B>>\n- static inline void pack(std::vector<B,A> &vec, const int n_frames = 1, const bool rev = false)\n+ static inline void pack(std::vector<B,A> &vec, const int n_frames = 1, const bool msb_to_lsb = false,\n+ int Nbps = CHAR_BIT)\n{\nif (n_frames <= 0)\n{\n@@ -104,12 +124,28 @@ struct Bit_packer\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- Bit_packer<B>::pack(vec.data(), (int)(vec.size() / n_frames), n_frames, rev);\n+ Bit_packer<B>::pack(vec.data(), (int)(vec.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n}\n- static inline void pack(B *vec, const int n_bits_per_frame, const int n_frames = 1, const bool rev = false)\n+ static inline void pack(B *vec, const int n_bits_per_frame, const int n_frames = 1, const bool msb_to_lsb = false,\n+ int Nbps = CHAR_BIT)\n+ {\n+ if (Nbps > CHAR_BIT && Nbps <= 0)\n{\n- const auto n_bytes_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / 8.f));\n+ std::stringstream message;\n+ message << \"'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = \" << Nbps << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (n_bits_per_frame % Nbps)\n+ {\n+ std::stringstream message;\n+ message << \"'n_bits_per_frame' has to be divisible by 'Nbps' ('n_bits_per_frame' = \" << n_bits_per_frame\n+ << \", 'Nbps' = \" << Nbps << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ const auto n_bytes_per_frame = n_bits_per_frame / Nbps;\nunsigned char* bytes_out = (unsigned char*)vec;\n@@ -117,19 +153,21 @@ struct Bit_packer\nBit_packer<B>::_pack(vec + f * n_bits_per_frame,\nbytes_out + f * n_bytes_per_frame,\nn_bits_per_frame,\n- rev);\n+ msb_to_lsb,\n+ Nbps);\n}\n/*!\n* \\brief Unpacks bits.\n*\n* \\param vec_in: an input vector of packed bits.\n- * \\param vec_out: an output vector of unpacked bits.\n- * \\param rev: reverse the bitpaking storage order.\n+ * \\param vec_out: an output vector of unpacked bits (used as size reference)\n+ * \\param msb_to_lsb: unpack from MSB to LSB else from LSB to MSB.\n+ * \\tparam Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n*/\ntemplate <class A = std::allocator<B>>\nstatic inline void unpack(const std::vector<B,A> &vec_in, std::vector<B,A> &vec_out, const int n_frames = 1,\n- const bool rev = false)\n+ const bool msb_to_lsb = false, int Nbps = CHAR_BIT)\n{\nif (n_frames <= 0)\n{\n@@ -146,22 +184,38 @@ struct Bit_packer\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if ((int)vec_in.size() < (int)(std::ceil((float)vec_out.size() / (sizeof(B) * 8.f))))\n+\n+ if ((vec_in.size() * sizeof(B) * Nbps) < vec_out.size())\n{\nstd::stringstream message;\n- message << \"'vec_in.size()' has to be equal or greater than ceil('vec_out.size()' / ('sizeof(B)' * 8.f)) \"\n+ message << \"('vec_in.size()' * 'sizeof(B)' * 'Nbps') has to be equal or greater than 'vec_out.size()' \"\n<< \"('vec_in.size()' = \" << vec_in.size() << \", 'vec_out.size()' = \" << vec_out.size()\n- << \", 'sizeof(B)' = \" << sizeof(B) << \").\";\n+ << \", 'sizeof(B)' = \" << sizeof(B) << \", 'Nbps' = \" << Nbps << \").\";\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- Bit_packer<B>::unpack(vec_in.data(), vec_out.data(), (int)(vec_out.size() / n_frames), n_frames, rev);\n+ Bit_packer<B>::unpack(vec_in.data(), vec_out.data(), (int)(vec_out.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n}\nstatic inline void unpack(const B *vec_in, B *vec_out, const int n_bits_per_frame,\n- const int n_frames = 1, const bool rev = false)\n+ const int n_frames = 1, const bool msb_to_lsb = false, int Nbps = CHAR_BIT)\n{\n- const auto n_bytes_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / 8.f));\n+ if (Nbps > CHAR_BIT && Nbps <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = \" << Nbps << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (n_bits_per_frame % Nbps)\n+ {\n+ std::stringstream message;\n+ message << \"'n_bits_per_frame' has to be divisible by 'Nbps' ('n_bits_per_frame' = \" << n_bits_per_frame\n+ << \", 'Nbps' = \" << Nbps << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ const auto n_bytes_per_frame = n_bits_per_frame / Nbps;\nunsigned char* bytes_in = (unsigned char*)vec_in;\n@@ -169,17 +223,20 @@ struct Bit_packer\nBit_packer<B>::_unpack(bytes_in + f * n_bytes_per_frame,\nvec_out + f * n_bits_per_frame,\nn_bits_per_frame,\n- rev);\n+ msb_to_lsb,\n+ Nbps);\n}\n/*!\n* \\brief Unpacks bits.\n*\n* \\param vec: a vector of packed bits (all the bits in each element of vec are used to store bits).\n- * \\param rev: reverse the bitpaking storage order.\n+ * \\param msb_to_lsb: unpack from MSB to LSB else from LSB to MSB\n+ * \\tparam Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n*/\ntemplate <class A = std::allocator<B>>\n- static inline void unpack(std::vector<B,A> &vec, const int n_frames = 1, bool rev = false)\n+ static inline void unpack(std::vector<B,A> &vec, const int n_frames = 1, bool msb_to_lsb = false,\n+ int Nbps = CHAR_BIT)\n{\nif (n_frames <= 0)\n{\n@@ -196,12 +253,28 @@ struct Bit_packer\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- Bit_packer<B>::unpack(vec.data(), (int)(vec.size() / n_frames), n_frames, rev);\n+ Bit_packer<B>::unpack(vec.data(), (int)(vec.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n}\n- static inline void unpack(B *vec, const int n_bits_per_frame, const int n_frames = 1, bool rev = false)\n+ static inline void unpack(B *vec, const int n_bits_per_frame, const int n_frames = 1, bool msb_to_lsb = false,\n+ int Nbps = CHAR_BIT)\n{\n- const auto n_bytes_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / 8.f));\n+ if (Nbps > CHAR_BIT && Nbps <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = \" << Nbps << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (n_bits_per_frame % Nbps)\n+ {\n+ std::stringstream message;\n+ message << \"'n_bits_per_frame' has to be divisible by 'Nbps' ('n_bits_per_frame' = \" << n_bits_per_frame\n+ << \", 'Nbps' = \" << Nbps << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ const auto n_bytes_per_frame = n_bits_per_frame / Nbps;\nunsigned char* bytes = (unsigned char*)vec;\nstd::vector<unsigned char> bytes_cpy(n_bytes_per_frame); //TODO: find a way to avoid this allocation\n@@ -214,96 +287,84 @@ struct Bit_packer\nBit_packer<B>::_unpack(bytes_cpy.data() + f * n_bytes_per_frame,\nvec + f * n_bits_per_frame,\nn_bits_per_frame,\n- rev);\n+ msb_to_lsb,\n+ Nbps);\n}\n}\nprivate:\n- static inline void _pack(const B* vec_in, unsigned char* bytes_out, const int n_bits, const bool rev = false)\n+ static inline void _pack(const B* vec_in, unsigned char* bytes_out, const int n_bits, const bool msb_to_lsb, int Nbps)\n{\n- if (!rev)\n+ auto n_bytes = n_bits / Nbps;\n+ if (!msb_to_lsb) // lsb_to_msb\n{\n- for (auto i = 0; i < n_bits / 8; i++)\n+ for (auto i = 0; i < n_bytes; i++, bytes_out++)\n{\nunsigned char byte = 0;\n- for (auto j = 0; j < 8; j++)\n- byte |= ((unsigned char)(vec_in[i*8 +j] != 0)) << j;\n- bytes_out[i] = byte;\n+ for (auto j = 0; j < Nbps; j++, vec_in++)\n+ byte |= ((unsigned char)(*vec_in != 0)) << j;\n+ *bytes_out = byte;\n}\n- if (n_bits % 8 != 0)\n+ const auto rest = n_bits % Nbps;\n+ if (rest != 0)\n{\n- const auto rest = n_bits % 8;\nunsigned char byte = 0;\n- for (auto j = 0; j < rest; j++)\n- byte |= ((unsigned char)(vec_in[(n_bits / 8) * 8 +j] != 0)) << j;\n- bytes_out[n_bits / 8] = byte;\n+ for (auto j = 0; j < rest; j++, vec_in++)\n+ byte |= ((unsigned char)(*vec_in != 0)) << j;\n+ *bytes_out = byte;\n}\n}\n- else // reversed order\n+ else // msb_to_lsb\n{\n- for (auto i = 0; i < n_bits / 8; i++)\n+ for (auto i = 0; i < n_bytes; i++, bytes_out++)\n{\nunsigned char byte = 0;\n- for (auto j = 0; j < 8; j++)\n+ for (auto j = 0; j < Nbps; j++, vec_in++)\n{\nbyte <<= 1;\n- byte |= vec_in[i*8 +j] != 0;\n+ byte |= *vec_in != 0;\n}\n- bytes_out[i] = byte;\n+ *bytes_out = byte;\n}\n- if (n_bits % 8 != 0)\n+ const auto rest = n_bits % Nbps;\n+ if (rest != 0)\n{\n- const auto rest = n_bits % 8;\nunsigned char byte = 0;\n- for (auto j = 0; j < 8; j++)\n+ for (auto j = 0; j < Nbps; j++, vec_in++)\n{\nbyte <<= 1;\nif (j < rest)\n- byte |= vec_in[(n_bits / 8) * 8 +j] != 0;\n+ byte |= *vec_in != 0;\n}\n- bytes_out[n_bits / 8] = byte;\n+ *bytes_out = byte;\n}\n}\n}\n- static inline void _unpack(const unsigned char *bytes_in, B* vec_out, const int n_bits, const bool rev = false)\n- {\n- if (!rev)\n+ static inline void _unpack(const unsigned char *bytes_in, B* vec_out, const int n_bits, const bool msb_to_lsb, int Nbps)\n{\n- for (auto i = 0; i < n_bits / 8; i++)\n+ auto n_bytes = n_bits / Nbps;\n+ if (!msb_to_lsb) // lsb_to_msb\n{\n- const unsigned char byte = bytes_in[i];\n- for (auto j = 0; j < 8; j++)\n- vec_out[i * 8 +j] = (byte >> j) & 1;\n- }\n+ for (auto i = 0; i < n_bytes; i++, bytes_in++)\n+ for (auto j = 0; j < Nbps; j++, vec_out++)\n+ *vec_out = (*bytes_in >> j) & 1;\n- if (n_bits % 8 != 0)\n- {\n- const auto rest = n_bits % 8;\n- const unsigned char byte = bytes_in[n_bits / 8];\n- for (auto j = 0; j < rest; j++)\n- vec_out[(n_bits / 8) * 8 +j] = (byte >> j) & 1;\n+ const auto rest = n_bits % Nbps;\n+ for (auto j = 0; j < rest; j++, vec_out++)\n+ *vec_out = (*bytes_in >> j) & 1;\n}\n- }\n- else // reversed order\n- {\n- for (auto i = 0; i < n_bits / 8; i++)\n+ else // msb_to_lsb\n{\n- const unsigned char byte = bytes_in[i];\n- for (auto j = 0; j < 8; j++)\n- vec_out[i * 8 +j] = (byte >> (7 -j)) & 1;\n- }\n+ for (auto i = 0; i < n_bytes; i++, bytes_in++)\n+ for (auto j = 0; j < Nbps; j++, vec_out++)\n+ *vec_out = (*bytes_in >> (CHAR_BIT -1 -j)) & 1;\n- if (n_bits % 8 != 0)\n- {\n- const auto rest = n_bits % 8;\n- const unsigned char byte = bytes_in[n_bits / 8];\n- for (auto j = 0; j < 8; j++)\n- if (j < rest)\n- vec_out[(n_bits / 8) * 8 +j] = (byte >> (7 -j)) & 1;\n- }\n+ const auto rest = n_bits % Nbps;\n+ for (auto j = 0; j < rest; j++, vec_out++)\n+ *vec_out = (*bytes_in >> (CHAR_BIT -1 -j)) & 1;\n}\n}\n};\n@@ -311,3 +372,54 @@ private:\n}\n#endif\n+\n+\n+/* Test code :\n+#include <random>\n+#include <string>\n+#include <vector>\n+#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n+#include \"Tools/Algo/Bit_packer.hpp\"\n+\n+int main(int argc, char** argv)\n+{\n+ using namespace aff3ct;\n+ using B = int;\n+\n+ std::random_device rd;\n+\n+ size_t size_in = (argc >= 2) ? std::stoi(argv[1]) : 16;\n+ int Nbps = (argc >= 3) ? std::stoi(argv[2]) : CHAR_BIT;\n+ int n_frames = (argc >= 4) ? std::stoi(argv[3]) : 1;\n+ int msb_to_lsb = (argc >= 5) ? std::stoi(argv[4]) : 0;\n+ int seed = (argc >= 6) ? std::stoi(argv[5]) : rd();\n+ size_t size_out = std::ceil(1.f * size_in / Nbps / sizeof(B));\n+\n+ std::vector<B> vec_in (size_in * n_frames);\n+ std::vector<B> vec_out(size_out * n_frames);\n+\n+ std::mt19937 gen(seed);\n+ std::bernoulli_distribution d(0.5);\n+\n+ for(auto& v : vec_in)\n+ v = d(gen);\n+\n+ tools::Frame_trace<> ft;\n+\n+ std::cout << \"Vec in\" << std::endl;\n+ ft.display_bit_vector(vec_in, Nbps);\n+\n+ tools::Bit_packer<int>::pack(vec_in, vec_out, n_frames, msb_to_lsb, Nbps);\n+\n+ std::cout << \"Vec packed\" << std::endl;\n+\n+ std::vector<char> vec_char(vec_out.size() * sizeof(B));\n+ std::copy_n((char*)vec_out.data(), vec_char.size(), vec_char.data());\n+ ft.display_hex_vector(vec_char, size_out * sizeof(B));\n+\n+ tools::Bit_packer<int>::unpack(vec_out, vec_in, n_frames, msb_to_lsb, Nbps);\n+\n+ std::cout << \"Vec unpacked\" << std::endl;\n+ ft.display_bit_vector(vec_in, size_in);\n+}\n+*/\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Display/Frame_trace/Frame_trace.hpp", "new_path": "src/Tools/Display/Frame_trace/Frame_trace.hpp", "diff": "@@ -26,7 +26,7 @@ template <typename B = int>\nclass Frame_trace\n{\nprivate:\n- enum class debug_version : uint8_t { BIT, REAL };\n+ enum class debug_version : uint8_t { BIT, REAL, HEX };\nstd::ostream &stream; /*!< Stream to trace the frame(s). */\nconst int n_bits; /*!< Number of bits to display per frame (if n_bits = 0, display all the bits of the frame). */\n@@ -76,6 +76,16 @@ public:\ntemplate <typename D, class AD = std::allocator<D>, class AB = std::allocator<B>>\nvoid display_real_vector(std::vector<D,AD> vec, std::vector<B,AB> ref = {});\n+ /*!\n+ * \\brief Display a vector (= a frame) of hexadecimals.\n+ *\n+ * \\tparam D: type of the values in the input vector.\n+ *\n+ * \\param vec: a vector to display.\n+ */\n+ template <typename D, class AD = std::allocator<D>>\n+ void display_hex_vector(std::vector<D,AD> vec);\n+\n/*!\n* \\brief Display a vector (= a frame) of bits (0 or 1) in 2D.\n*\n@@ -102,6 +112,17 @@ public:\ntemplate <typename D, class AD = std::allocator<D>, class AB = std::allocator<B>>\nvoid display_real_vector(std::vector<D,AD> vec, unsigned int row_width, std::vector<B,AB> ref = {});\n+ /*!\n+ * \\brief Display a vector (= a frame) of hexadecimals in 2D.\n+ *\n+ * \\tparam D: type of the values in the input vector.\n+ *\n+ * \\param vec: a vector to display.\n+ * \\param row_width: number of values in a row (size of the x dimension).\n+ */\n+ template <typename D, class AD = std::allocator<D>>\n+ void display_hex_vector(std::vector<D,AD> vec, unsigned int row_width);\n+\nprivate:\ntemplate <typename D, class AD = std::allocator<D>, class AB = std::allocator<B>>\nvoid display_vector(std::vector<D,AD> vec, unsigned int row_width, std::vector<B,AB> ref, debug_version version);\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Display/Frame_trace/Frame_trace.hxx", "new_path": "src/Tools/Display/Frame_trace/Frame_trace.hxx", "diff": "@@ -27,6 +27,14 @@ void Frame_trace<B>\ndisplay_real_vector(vec, (int)vec.size(), ref);\n}\n+template <typename B>\n+template <typename D, class AD>\n+void Frame_trace<B>\n+::display_hex_vector(std::vector<D,AD> vec)\n+{\n+ display_hex_vector(vec, (int)vec.size());\n+}\n+\ntemplate <typename B>\ntemplate <typename D, class AD, class AB>\nvoid Frame_trace<B>\n@@ -43,11 +51,21 @@ void Frame_trace<B>\ndisplay_vector(vec, row_width, ref, debug_version::REAL);\n}\n+template <typename B>\n+template <typename D, class AD>\n+void Frame_trace<B>\n+::display_hex_vector(std::vector<D,AD> vec, unsigned int row_width)\n+{\n+ display_vector(vec, row_width, {}, debug_version::HEX);\n+}\n+\ntemplate <typename B>\ntemplate <typename D, class AD, class AB>\nvoid Frame_trace<B>\n::display_vector(std::vector<D,AD> vec, unsigned int row_width, std::vector<B,AB> ref, debug_version version)\n{\n+ std::ios_base::fmtflags f( stream.flags() );\n+\nbool enable_ref = !ref.empty();\nif (enable_ref && ref.size() != vec.size())\n@@ -70,7 +88,8 @@ void Frame_trace<B>\n// display the bits indexes\nif (this->display_indexes)\n{\n- for (auto i = 0; i < n_bits; i++)\n+ stream << std::dec;\n+ for (unsigned i = 0; i < row_width; i++)\nstream << rang::style::bold << std::setw(prec+2) << i\n<< rang::style::underline << \"|\"\n<< rang::style::reset;\n@@ -99,6 +118,8 @@ void Frame_trace<B>\nstride += row_width;\n}\n+\n+ stream.flags( f );\n}\ntemplate <typename B>\n@@ -118,6 +139,14 @@ void Frame_trace<B>\nbreak;\n+ case debug_version::HEX:\n+ if (ref != -1)\n+ stream << ( value != ref ? rang::fg::red : rang::fg::green);\n+ stream << std::setw(prec+2) << std::hex;\n+ stream << (sizeof(D) == 1 ? (unsigned short)(unsigned char)value : value);\n+\n+ break;\n+\ncase debug_version::REAL:\n{\nstd::stringstream sstream;\n" } ]
C++
MIT License
aff3ct/aff3ct
Enhance Bit packer and Frame trace Add an option in bit packer to pack/unpack different size of symbol : Number bits per symbols. Rewrite pack unpack core functions to be faster. Add a hex display function in Frame trace.
8,483
30.07.2018 15:40:27
-7,200
653b512de90825324102ca81c74dc344296aea12
Fix Bit Packer _pack msb_to_lsb and enhance it by taking into account different symbols sizes as pack output, unpack input
[ { "change_type": "MODIFY", "old_path": "src/Module/CRC/Polynomial/CRC_polynomial.cpp", "new_path": "src/Module/CRC/Polynomial/CRC_polynomial.cpp", "diff": "@@ -155,7 +155,7 @@ bool CRC_polynomial<B>\n{\nstd::vector<B> V_K_unpack(this->K + this->size);\nstd::copy(V_K, V_K + this->K + this->size, V_K_unpack.begin());\n- tools::Bit_packer<B>::unpack(V_K_unpack, this->K + this->size);\n+ tools::Bit_packer::unpack(V_K_unpack, this->K + this->size);\nreturn _check(V_K_unpack.data(), frame_id);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/CRC/Polynomial/CRC_polynomial_fast.cpp", "new_path": "src/Module/CRC/Polynomial/CRC_polynomial_fast.cpp", "diff": "@@ -49,7 +49,7 @@ void CRC_polynomial_fast<B>\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, \"The code of the fast CRC works only on little endian CPUs.\");\n#endif\n- tools::Bit_packer<B>::pack(U_K1, this->buff_crc.data(), this->K);\n+ tools::Bit_packer::pack(U_K1, this->buff_crc.data(), this->K);\nconst auto data = (unsigned char*)this->buff_crc.data();\nconst auto crc = this->compute_crc_v3((void*)data, this->K);\n@@ -63,7 +63,7 @@ template <typename B>\nbool CRC_polynomial_fast<B>\n::_check(const B *V_K, const int frame_id)\n{\n- tools::Bit_packer<B>::pack(V_K, this->buff_crc.data(), this->K + this->size);\n+ tools::Bit_packer::pack(V_K, this->buff_crc.data(), this->K + this->size);\nreturn this->_check_packed(this->buff_crc.data(), frame_id);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood_naive.cpp", "new_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood_naive.cpp", "diff": "@@ -82,7 +82,7 @@ void Decoder_maximum_likelihood_naive<B,R>\nstd::fill(this->X_N.begin(), this->X_N.end(), (B)0);\nauto data = (uint64_t*)this->X_N.data();\ndata[0] = x;\n- tools::Bit_packer<B>::unpack(this->X_N.data(), this->N);\n+ tools::Bit_packer::unpack(this->X_N.data(), this->N);\nif (this->encoder.is_codeword(this->X_N.data()))\n{\n// compute the Euclidean distance between the input LLR and the current codeword\n@@ -134,7 +134,7 @@ void Decoder_maximum_likelihood_naive<B,R>\nstd::fill(this->X_N.begin(), this->X_N.end(), (B)0);\nauto data = (uint64_t*)this->X_N.data();\ndata[0] = x;\n- tools::Bit_packer<B>::unpack(this->X_N.data(), this->N);\n+ tools::Bit_packer::unpack(this->X_N.data(), this->N);\nif (this->encoder.is_codeword(this->X_N.data()))\n{\n// compute the Hamming distance between the input bits and the current codeword\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood_std.cpp", "new_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood_std.cpp", "diff": "@@ -72,7 +72,7 @@ void Decoder_maximum_likelihood_std<B,R>\nstd::fill(this->U_K.begin(), this->U_K.end(), (B)0);\nauto data = (uint64_t*)this->U_K.data();\ndata[0] = u;\n- tools::Bit_packer<B>::unpack(this->U_K.data(), this->K);\n+ tools::Bit_packer::unpack(this->U_K.data(), this->K);\nthis->encoder.encode(this->U_K.data(), this->X_N.data(), 0);\n// compute the Euclidean distance between the input LLR and the current codeword\n@@ -114,7 +114,7 @@ void Decoder_maximum_likelihood_std<B,R>\nstd::fill(this->U_K.begin(), this->U_K.end(), (B)0);\nauto data = (uint64_t*)this->U_K.data();\ndata[0] = u;\n- tools::Bit_packer<B>::unpack(this->U_K.data(), this->K);\n+ tools::Bit_packer::unpack(this->U_K.data(), this->K);\nthis->encoder.encode(this->U_K.data(), this->X_N.data(), 0);\n// compute the Hamming distance between the input bits and the current codeword\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Polar/SC/Decoder_polar_SC_fast_sys.hxx", "new_path": "src/Module/Decoder/Polar/SC/Decoder_polar_SC_fast_sys.hxx", "diff": "@@ -423,7 +423,7 @@ void Decoder_polar_SC_fast_sys<B,R,API_polar>\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- tools::Bit_packer<B>::unpack(this->s_bis.data(), this->s.data(), this->N, n_frames);\n+ tools::Bit_packer::unpack(this->s_bis.data(), this->s.data(), this->N, n_frames);\n}\n#endif\nif (!fast_deinterleave)\n@@ -470,7 +470,7 @@ void Decoder_polar_SC_fast_sys<B,R,API_polar>\n\"To ensure the portability please do not compile with the -DENABLE_BIT_PACKING definition.\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- tools::Bit_packer<B>::unpack(this->s_bis.data(), V_N, this->N, n_frames);\n+ tools::Bit_packer::unpack(this->s_bis.data(), V_N, this->N, n_frames);\n}\n#endif\nif (!fast_deinterleave)\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Algo/Bit_packer.hpp", "new_path": "src/Tools/Algo/Bit_packer.hpp", "diff": "+\n/*!\n* \\file\n* \\brief Packs and unpacks bits.\n#include <sstream>\n#include <vector>\n#include <climits>\n+#include <iostream>\n#include \"Tools/Exception/exception.hpp\"\n@@ -22,24 +24,22 @@ namespace tools\n/*!\n* \\class Bit_packer\n*\n- * \\brief Packs and unpacks bits.\n- *\n- * \\tparam B: type of data to pack/unpack.\n+ * \\brief Packs and unpacks bits into symbols\n*/\n-template <typename B = int>\nstruct Bit_packer\n{\n/*!\n* \\brief Packs bits.\n*\n- * \\param vec_in: an input vector of unpacked bits (only 1 bit per data is used to transport data) (used as size reference).\n- * \\param vec_out: an output vector of packed bits.\n+ * \\param vec_in: an input vector of unpacked bits (only 1 bit per element is used to transport data) (used as size reference).\n+ * \\param vec_out: an output vector of packed bits in symbols\n* \\param msb_to_lsb: pack from MSB to LSB else from LSB to MSB\n- * \\tparam Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n+ * \\param pack_per_byte: pack bits in each byte (type char) of vec_out, else pack per each symbol (of type S) of vec_out\n+ * \\param Nbps: the number of bits packed in one symbol (between 1 and (sizeof(S) * CHAR_BIT)).\n*/\n- template <class A = std::allocator<B>>\n- static inline void pack(const std::vector<B,A> &vec_in, std::vector<B,A> &vec_out, const int n_frames = 1,\n- const bool msb_to_lsb = false, int Nbps = CHAR_BIT)\n+ template <typename B, class AB = std::allocator<B>, typename S, class AS = std::allocator<S>>\n+ static inline void pack(const std::vector<B,AB> &vec_in, std::vector<S,AS> &vec_out, const int n_frames = 1,\n+ const bool msb_to_lsb = false, const bool pack_per_byte = true, const int Nbps = CHAR_BIT)\n{\nif (n_frames <= 0)\n{\n@@ -56,58 +56,78 @@ struct Bit_packer\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if ((vec_out.size() * sizeof(B) * Nbps) < vec_in.size())\n+ if (pack_per_byte)\n+ {\n+\n+ if ((vec_out.size() * sizeof(S) * Nbps) < vec_in.size())\n{\nstd::stringstream message;\n- message << \"('vec_out.size()' * 'sizeof(B)' * 'Nbps') has to be equal or greater than 'vec_in.size()' \"\n+ message << \"'vec_out.size()' has to be equal or greater than ('vec_in.size()' / 'sizeof(S)' / 'Nbps') \"\n<< \"('vec_out.size()' = \" << vec_out.size() << \", 'vec_in.size()' = \" << vec_in.size()\n- << \", 'sizeof(B)' = \" << sizeof(B) << \", 'Nbps' = \" << Nbps << \").\";\n+ << \", 'sizeof(S)' = \" << sizeof(S) << \", 'Nbps' = \" << Nbps << \").\";\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- Bit_packer<B>::pack(vec_in.data(), vec_out.data(), (int)(vec_in.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n+ Bit_packer::pack(vec_in.data(), (unsigned char*)vec_out.data(), (int)(vec_in.size() / n_frames),\n+ n_frames, msb_to_lsb, Nbps);\n}\n-\n- static inline void pack(const B *vec_in, B *vec_out, const int n_bits_per_frame,\n- const int n_frames = 1, const bool msb_to_lsb = false, int Nbps = CHAR_BIT)\n+ else\n{\n- if (Nbps > CHAR_BIT && Nbps <= 0)\n+ if ((vec_out.size() * Nbps) < vec_in.size())\n{\nstd::stringstream message;\n- message << \"'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = \" << Nbps << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ message << \"'vec_out.size()' has to be equal or greater than ('vec_in.size()' / 'Nbps') \"\n+ << \"('vec_out.size()' = \" << vec_out.size() << \", 'vec_in.size()' = \" << vec_in.size()\n+ << \", 'Nbps' = \" << Nbps << \").\";\n+ throw length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ Bit_packer::pack(vec_in.data(), vec_out.data(), (int)(vec_in.size() / n_frames),\n+ n_frames, msb_to_lsb, Nbps);\n+ }\n}\n- if (n_bits_per_frame % Nbps)\n+ /*!\n+ * \\brief Packs bits into symbols of type S\n+ *\n+ * \\param vec_in: an input vector of unpacked bits (only 1 bit per element is used to transport data)\n+ * \\param vec_out: an output vector of packed bits in symbols of type S\n+ * \\param n_bits_per_frame:the number of bits that has to be extracted from vec_in and stocked in vec_out\n+ * \\param msb_to_lsb: pack from MSB to LSB else from LSB to MSB\n+ * \\param Nbps: the number of bits packed in one symbol (between 1 and (sizeof(S) * CHAR_BIT)).\n+ */\n+ template <typename B, typename S>\n+ static inline void pack(const B *vec_in, S *vec_out, const int n_bits_per_frame,\n+ const int n_frames = 1, const bool msb_to_lsb = false, const int Nbps = CHAR_BIT)\n+ {\n+ if (Nbps > (int)(sizeof(S) * CHAR_BIT) || Nbps <= 0)\n{\nstd::stringstream message;\n- message << \"'n_bits_per_frame' has to be divisible by 'Nbps' ('n_bits_per_frame' = \" << n_bits_per_frame\n- << \", 'Nbps' = \" << Nbps << \").\";\n+ message << \"'Nbps' must be between 1 and (sizeof(S) * CHAR_BIT). ('Nbps' = \" << Nbps\n+ << \", 'sizeof(S)' = \" << sizeof(S) << \", 'CHAR_BIT' = \" << CHAR_BIT << \").\";\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- const auto n_bytes_per_frame = n_bits_per_frame / Nbps;\n-\n- auto bytes_out = (unsigned char*)vec_out;\n+ const auto n_symbols_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / Nbps));\nfor (auto f = 0; f < n_frames; f++)\n- Bit_packer<B>::_pack(vec_in + f * n_bits_per_frame,\n- bytes_out + f * n_bytes_per_frame,\n+ Bit_packer::_pack(vec_in + f * n_bits_per_frame,\n+ vec_out + f * n_symbols_per_frame,\nn_bits_per_frame,\nmsb_to_lsb,\nNbps);\n}\n/*!\n- * \\brief Packs bits.\n+ * \\brief Packs bits per byte in 'vec'.\n*\n* \\param vec: a vector of unpacked bits (only 1 bit per data is used to transport data).\n* \\param msb_to_lsb: pack from MSB to LSB else from LSB to MSB\n- * \\tparam Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n+ * \\param Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n*/\n- template <class A = std::allocator<B>>\n- static inline void pack(std::vector<B,A> &vec, const int n_frames = 1, const bool msb_to_lsb = false,\n- int Nbps = CHAR_BIT)\n+ template <typename B, class AB = std::allocator<B>>\n+ static inline void pack(std::vector<B,AB> &vec, const int n_frames = 1, const bool msb_to_lsb = false,\n+ const int Nbps = CHAR_BIT)\n{\nif (n_frames <= 0)\n{\n@@ -124,50 +144,44 @@ struct Bit_packer\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- Bit_packer<B>::pack(vec.data(), (int)(vec.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n+ Bit_packer::pack(vec.data(), (int)(vec.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n}\n+ template <typename B>\nstatic inline void pack(B *vec, const int n_bits_per_frame, const int n_frames = 1, const bool msb_to_lsb = false,\n- int Nbps = CHAR_BIT)\n+ const int Nbps = CHAR_BIT)\n{\n- if (Nbps > CHAR_BIT && Nbps <= 0)\n+ if (Nbps > (int)CHAR_BIT || Nbps <= 0)\n{\nstd::stringstream message;\nmessage << \"'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = \" << Nbps << \").\";\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (n_bits_per_frame % Nbps)\n- {\n- std::stringstream message;\n- message << \"'n_bits_per_frame' has to be divisible by 'Nbps' ('n_bits_per_frame' = \" << n_bits_per_frame\n- << \", 'Nbps' = \" << Nbps << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n+ const auto n_symbs_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / Nbps));\n- const auto n_bytes_per_frame = n_bits_per_frame / Nbps;\n-\n- unsigned char* bytes_out = (unsigned char*)vec;\n+ unsigned char* symbs_out = (unsigned char*)vec;\nfor (auto f = 0; f < n_frames; f++)\n- Bit_packer<B>::_pack(vec + f * n_bits_per_frame,\n- bytes_out + f * n_bytes_per_frame,\n+ Bit_packer::_pack(vec + f * n_bits_per_frame,\n+ symbs_out + f * n_symbs_per_frame,\nn_bits_per_frame,\nmsb_to_lsb,\nNbps);\n}\n/*!\n- * \\brief Unpacks bits.\n+ * \\brief Unpacks bits from symbols.\n*\n* \\param vec_in: an input vector of packed bits.\n- * \\param vec_out: an output vector of unpacked bits (used as size reference)\n+ * \\param vec_out: an output vector of unpacked bits (1 bit per element) (used as size reference)\n* \\param msb_to_lsb: unpack from MSB to LSB else from LSB to MSB.\n- * \\tparam Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n+ * \\param unpack_per_byte: unpack symbol in each byte (type char) of vec_out, else unpack per each symbol (of type S) of vec_in\n+ * \\param Nbps: the number of bits packed in one symbol (between 1 and (sizeof(S) * CHAR_BIT)).\n*/\n- template <class A = std::allocator<B>>\n- static inline void unpack(const std::vector<B,A> &vec_in, std::vector<B,A> &vec_out, const int n_frames = 1,\n- const bool msb_to_lsb = false, int Nbps = CHAR_BIT)\n+ template <typename B, class AB = std::allocator<B>, typename S, class AS = std::allocator<S>>\n+ static inline void unpack(const std::vector<S,AS> &vec_in, std::vector<B,AB> &vec_out, const int n_frames = 1,\n+ const bool msb_to_lsb = false, const bool unpack_per_byte = true, const int Nbps = CHAR_BIT)\n{\nif (n_frames <= 0)\n{\n@@ -184,7 +198,8 @@ struct Bit_packer\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n-\n+ if (unpack_per_byte)\n+ {\nif ((vec_in.size() * sizeof(B) * Nbps) < vec_out.size())\n{\nstd::stringstream message;\n@@ -194,33 +209,50 @@ struct Bit_packer\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- Bit_packer<B>::unpack(vec_in.data(), vec_out.data(), (int)(vec_out.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n+ Bit_packer::unpack((unsigned char*)vec_in.data(), vec_out.data(), (int)(vec_out.size() / n_frames),\n+ n_frames, msb_to_lsb, Nbps);\n}\n-\n- static inline void unpack(const B *vec_in, B *vec_out, const int n_bits_per_frame,\n- const int n_frames = 1, const bool msb_to_lsb = false, int Nbps = CHAR_BIT)\n+ else\n{\n- if (Nbps > CHAR_BIT && Nbps <= 0)\n+ if ((vec_in.size() * Nbps) < vec_out.size())\n{\nstd::stringstream message;\n- message << \"'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = \" << Nbps << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ message << \"('vec_in.size()' * 'Nbps') has to be equal or greater than 'vec_out.size()' \"\n+ << \"('vec_in.size()' = \" << vec_in.size() << \", 'vec_out.size()' = \" << vec_out.size()\n+ << \", 'Nbps' = \" << Nbps << \").\";\n+ throw length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if (n_bits_per_frame % Nbps)\n+ Bit_packer::unpack(vec_in.data(), vec_out.data(), (int)(vec_out.size() / n_frames),\n+ n_frames, msb_to_lsb, Nbps);\n+ }\n+ }\n+\n+ /*!\n+ * \\brief Unpacks bits from symbols of type S.\n+ *\n+ * \\param vec_in: an input vector of packed bits in symbols S.\n+ * \\param vec_out: an output vector of unpacked bits (1 bit per element)\n+ * \\param n_bits_per_frame:the number of bits that has to be extracted from vec_in and stocked in vec_out\n+ * \\param msb_to_lsb: unpack from MSB to LSB else from LSB to MSB.\n+ * \\param Nbps: the number of bits packed in one symbol (between 1 and (sizeof(S) * CHAR_BIT)).\n+ */\n+ template <typename B, typename S>\n+ static inline void unpack(const S *vec_in, B *vec_out, const int n_bits_per_frame,\n+ const int n_frames = 1, const bool msb_to_lsb = false, const int Nbps = CHAR_BIT)\n+ {\n+ if (Nbps > (int)(sizeof(S) * CHAR_BIT) || Nbps <= 0)\n{\nstd::stringstream message;\n- message << \"'n_bits_per_frame' has to be divisible by 'Nbps' ('n_bits_per_frame' = \" << n_bits_per_frame\n- << \", 'Nbps' = \" << Nbps << \").\";\n+ message << \"'Nbps' must be between 1 and (sizeof(S) * CHAR_BIT). ('Nbps' = \" << Nbps\n+ << \", 'sizeof(S)' = \" << sizeof(S) << \", 'CHAR_BIT' = \" << CHAR_BIT << \").\";\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- const auto n_bytes_per_frame = n_bits_per_frame / Nbps;\n-\n- unsigned char* bytes_in = (unsigned char*)vec_in;\n+ const auto n_symbs_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / Nbps));\nfor (auto f = 0; f < n_frames; f++)\n- Bit_packer<B>::_unpack(bytes_in + f * n_bytes_per_frame,\n+ Bit_packer::_unpack(vec_in + f * n_symbs_per_frame,\nvec_out + f * n_bits_per_frame,\nn_bits_per_frame,\nmsb_to_lsb,\n@@ -228,15 +260,15 @@ struct Bit_packer\n}\n/*!\n- * \\brief Unpacks bits.\n+ * \\brief Unpacks bits per byte of vec\n*\n* \\param vec: a vector of packed bits (all the bits in each element of vec are used to store bits).\n* \\param msb_to_lsb: unpack from MSB to LSB else from LSB to MSB\n- * \\tparam Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n+ * \\param Nbps: the number of bits packed in one symbol (between 1 and 8 (CHAR_BIT)).\n*/\n- template <class A = std::allocator<B>>\n- static inline void unpack(std::vector<B,A> &vec, const int n_frames = 1, bool msb_to_lsb = false,\n- int Nbps = CHAR_BIT)\n+ template <typename B, class AB = std::allocator<B>>\n+ static inline void unpack(std::vector<B,AB> &vec, const int n_frames = 1, const bool msb_to_lsb = false,\n+ const int Nbps = CHAR_BIT)\n{\nif (n_frames <= 0)\n{\n@@ -253,38 +285,31 @@ struct Bit_packer\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- Bit_packer<B>::unpack(vec.data(), (int)(vec.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n+ Bit_packer::unpack(vec.data(), (int)(vec.size() / n_frames), n_frames, msb_to_lsb, Nbps);\n}\n- static inline void unpack(B *vec, const int n_bits_per_frame, const int n_frames = 1, bool msb_to_lsb = false,\n- int Nbps = CHAR_BIT)\n+ template <typename B>\n+ static inline void unpack(B *vec, const int n_bits_per_frame, const int n_frames = 1, const bool msb_to_lsb = false,\n+ const int Nbps = CHAR_BIT)\n{\n- if (Nbps > CHAR_BIT && Nbps <= 0)\n+ if (Nbps > (int)CHAR_BIT || Nbps <= 0)\n{\nstd::stringstream message;\nmessage << \"'Nbps' must be between 1 and CHAR_BIT. ('Nbps' = \" << Nbps << \").\";\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (n_bits_per_frame % Nbps)\n- {\n- std::stringstream message;\n- message << \"'n_bits_per_frame' has to be divisible by 'Nbps' ('n_bits_per_frame' = \" << n_bits_per_frame\n- << \", 'Nbps' = \" << Nbps << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- const auto n_bytes_per_frame = n_bits_per_frame / Nbps;\n+ const auto n_symbs_per_frame = static_cast<int>(std::ceil((float)n_bits_per_frame / Nbps));\nunsigned char* bytes = (unsigned char*)vec;\n- std::vector<unsigned char> bytes_cpy(n_bytes_per_frame); //TODO: find a way to avoid this allocation\n+ std::vector<unsigned char> bytes_cpy(n_symbs_per_frame); //TODO: find a way to avoid this allocation\nfor (auto f = 0; f < n_frames; f++)\n{\n//TODO: find a way to avoid this copy\n- std::copy(&bytes[f * n_bytes_per_frame], &bytes[(f +1) * n_bytes_per_frame], bytes_cpy.begin());\n+ std::copy(&bytes[f * n_symbs_per_frame], &bytes[(f +1) * n_symbs_per_frame], bytes_cpy.begin());\n- Bit_packer<B>::_unpack(bytes_cpy.data() + f * n_bytes_per_frame,\n+ Bit_packer::_unpack(bytes_cpy.data() + f * n_symbs_per_frame,\nvec + f * n_bits_per_frame,\nn_bits_per_frame,\nmsb_to_lsb,\n@@ -293,78 +318,74 @@ struct Bit_packer\n}\nprivate:\n- static inline void _pack(const B* vec_in, unsigned char* bytes_out, const int n_bits, const bool msb_to_lsb, int Nbps)\n+ template <typename B, typename S>\n+ static inline void _pack(const B* vec_in, S* symbs_out, const int n_bits, const bool msb_to_lsb, const int Nbps)\n{\n- auto n_bytes = n_bits / Nbps;\n+ const auto n_symbs = n_bits / Nbps;\n+ const auto rest = n_bits - n_symbs * Nbps;\n+\nif (!msb_to_lsb) // lsb_to_msb\n{\n- for (auto i = 0; i < n_bytes; i++, bytes_out++)\n+ for (auto i = 0; i < n_symbs; i++, symbs_out++)\n{\n- unsigned char byte = 0;\n+ S symb = 0;\nfor (auto j = 0; j < Nbps; j++, vec_in++)\n- byte |= ((unsigned char)(*vec_in != 0)) << j;\n- *bytes_out = byte;\n+ symb |= ((S)(*vec_in != 0)) << j;\n+ *symbs_out = symb;\n}\n- const auto rest = n_bits % Nbps;\nif (rest != 0)\n{\n- unsigned char byte = 0;\n+ S symb = 0;\nfor (auto j = 0; j < rest; j++, vec_in++)\n- byte |= ((unsigned char)(*vec_in != 0)) << j;\n- *bytes_out = byte;\n+ symb |= ((S)(*vec_in != 0)) << j;\n+ *symbs_out = symb;\n}\n}\nelse // msb_to_lsb\n{\n- for (auto i = 0; i < n_bytes; i++, bytes_out++)\n+ for (auto i = 0; i < n_symbs; i++, symbs_out++)\n{\n- unsigned char byte = 0;\n+ S symb = 0;\nfor (auto j = 0; j < Nbps; j++, vec_in++)\n- {\n- byte <<= 1;\n- byte |= *vec_in != 0;\n- }\n- *bytes_out = byte;\n+ symb |= (symb << 1) | (*vec_in != 0);\n+ *symbs_out = symb << (sizeof(S) * CHAR_BIT - Nbps);\n}\n- const auto rest = n_bits % Nbps;\nif (rest != 0)\n{\n- unsigned char byte = 0;\n- for (auto j = 0; j < Nbps; j++, vec_in++)\n- {\n- byte <<= 1;\n- if (j < rest)\n- byte |= *vec_in != 0;\n- }\n- *bytes_out = byte;\n+ S symb = 0;\n+ for (auto j = 0; j < rest; j++, vec_in++)\n+ symb |= (symb << 1) | (*vec_in != 0);\n+ *symbs_out = symb << (sizeof(S) * CHAR_BIT - rest);\n}\n}\n}\n- static inline void _unpack(const unsigned char *bytes_in, B* vec_out, const int n_bits, const bool msb_to_lsb, int Nbps)\n+ template <typename B, typename S>\n+ static inline void _unpack(const S *symbs_in, B* vec_out, const int n_bits, const bool msb_to_lsb, const int Nbps)\n{\n- auto n_bytes = n_bits / Nbps;\n+\n+ const auto n_symbs = n_bits / Nbps;\n+ const auto rest = n_bits - n_symbs * Nbps;\n+\nif (!msb_to_lsb) // lsb_to_msb\n{\n- for (auto i = 0; i < n_bytes; i++, bytes_in++)\n+ for (auto i = 0; i < n_symbs; i++, symbs_in++)\nfor (auto j = 0; j < Nbps; j++, vec_out++)\n- *vec_out = (*bytes_in >> j) & 1;\n+ *vec_out = (*symbs_in >> j) & (S)1;\n- const auto rest = n_bits % Nbps;\nfor (auto j = 0; j < rest; j++, vec_out++)\n- *vec_out = (*bytes_in >> j) & 1;\n+ *vec_out = (*symbs_in >> j) & (S)1;\n}\nelse // msb_to_lsb\n{\n- for (auto i = 0; i < n_bytes; i++, bytes_in++)\n+ for (auto i = 0; i < n_symbs; i++, symbs_in++)\nfor (auto j = 0; j < Nbps; j++, vec_out++)\n- *vec_out = (*bytes_in >> (CHAR_BIT -1 -j)) & 1;\n+ *vec_out = (*symbs_in >> (sizeof(S) * CHAR_BIT -1 -j)) & (S)1;\n- const auto rest = n_bits % Nbps;\nfor (auto j = 0; j < rest; j++, vec_out++)\n- *vec_out = (*bytes_in >> (CHAR_BIT -1 -j)) & 1;\n+ *vec_out = (*symbs_in >> (sizeof(S) * CHAR_BIT -1 -j)) & (S)1;\n}\n}\n};\n@@ -385,6 +406,7 @@ int main(int argc, char** argv)\n{\nusing namespace aff3ct;\nusing B = int;\n+ using S = short;\nstd::random_device rd;\n@@ -392,11 +414,14 @@ int main(int argc, char** argv)\nint Nbps = (argc >= 3) ? std::stoi(argv[2]) : CHAR_BIT;\nint n_frames = (argc >= 4) ? std::stoi(argv[3]) : 1;\nint msb_to_lsb = (argc >= 5) ? std::stoi(argv[4]) : 0;\n- int seed = (argc >= 6) ? std::stoi(argv[5]) : rd();\n- size_t size_out = std::ceil(1.f * size_in / Nbps / sizeof(B));\n+ int pack_per_byte = (argc >= 6) ? std::stoi(argv[5]) : 1;\n+ int seed = (argc >= 7) ? std::stoi(argv[6]) : rd();\n+\n+ size_t size_out = std::ceil(1.f * size_in / Nbps);\nstd::vector<B> vec_in (size_in * n_frames);\n- std::vector<B> vec_out(size_out * n_frames);\n+ std::vector<S> vec_packed (size_out * n_frames);\n+ std::vector<B> vec_unpacked(size_in * n_frames);\nstd::mt19937 gen(seed);\nstd::bernoulli_distribution d(0.5);\n@@ -409,17 +434,28 @@ int main(int argc, char** argv)\nstd::cout << \"Vec in\" << std::endl;\nft.display_bit_vector(vec_in, Nbps);\n- tools::Bit_packer<int>::pack(vec_in, vec_out, n_frames, msb_to_lsb, Nbps);\n+ tools::Bit_packer::pack(vec_in, vec_packed, n_frames, msb_to_lsb, pack_per_byte, Nbps);\nstd::cout << \"Vec packed\" << std::endl;\n- std::vector<char> vec_char(vec_out.size() * sizeof(B));\n- std::copy_n((char*)vec_out.data(), vec_char.size(), vec_char.data());\n- ft.display_hex_vector(vec_char, size_out * sizeof(B));\n+ if (pack_per_byte)\n+ {\n+ std::vector<char> vec_char(vec_packed.size() * sizeof(S));\n+ std::copy_n((char*)vec_packed.data(), vec_char.size(), vec_char.data());\n+ ft.display_hex_vector(vec_char, size_out * sizeof(S));\n+ }\n+ else\n+ ft.display_hex_vector(vec_packed, size_out);\n- tools::Bit_packer<int>::unpack(vec_out, vec_in, n_frames, msb_to_lsb, Nbps);\n+ tools::Bit_packer::unpack(vec_packed, vec_unpacked, n_frames, msb_to_lsb, pack_per_byte, Nbps);\nstd::cout << \"Vec unpacked\" << std::endl;\n- ft.display_bit_vector(vec_in, size_in);\n+ ft.display_bit_vector(vec_unpacked, Nbps);\n+\n+ bool same = true;\n+ for (unsigned i = 0; i < vec_unpacked.size(); i++)\n+ same &= vec_unpacked[i] == vec_in[i];\n+\n+ std::cout << \"Same in and unpacked = \" << same << std::endl;\n}\n*/\n\\ No newline at end of file\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix Bit Packer _pack msb_to_lsb and enhance it by taking into account different symbols sizes as pack output, unpack input
8,483
31.07.2018 15:24:19
-7,200
a1678066aaf5475e2532d07beb18850b7338644e
Fix Bit Packer and and the way it is called in decoder polar et CRC
[ { "change_type": "MODIFY", "old_path": "src/Module/CRC/Polynomial/CRC_polynomial_fast.cpp", "new_path": "src/Module/CRC/Polynomial/CRC_polynomial_fast.cpp", "diff": "@@ -49,9 +49,9 @@ void CRC_polynomial_fast<B>\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, \"The code of the fast CRC works only on little endian CPUs.\");\n#endif\n- tools::Bit_packer::pack(U_K1, this->buff_crc.data(), this->K);\n-\nconst auto data = (unsigned char*)this->buff_crc.data();\n+ tools::Bit_packer::pack(U_K1, data, this->K);\n+\nconst auto crc = this->compute_crc_v3((void*)data, this->K);\nstd::copy(U_K1, U_K1 + this->K, U_K2);\n@@ -63,7 +63,7 @@ template <typename B>\nbool CRC_polynomial_fast<B>\n::_check(const B *V_K, const int frame_id)\n{\n- tools::Bit_packer::pack(V_K, this->buff_crc.data(), this->K + this->size);\n+ tools::Bit_packer::pack(V_K, (unsigned char*)this->buff_crc.data(), this->K + this->size);\nreturn this->_check_packed(this->buff_crc.data(), frame_id);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/Polar/SC/Decoder_polar_SC_fast_sys.hxx", "new_path": "src/Module/Decoder/Polar/SC/Decoder_polar_SC_fast_sys.hxx", "diff": "@@ -423,7 +423,7 @@ void Decoder_polar_SC_fast_sys<B,R,API_polar>\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- tools::Bit_packer::unpack(this->s_bis.data(), this->s.data(), this->N, n_frames);\n+ tools::Bit_packer::unpack(this->s_bis.data(), (unsigned char*)this->s.data(), this->N, n_frames);\n}\n#endif\nif (!fast_deinterleave)\n@@ -470,7 +470,7 @@ void Decoder_polar_SC_fast_sys<B,R,API_polar>\n\"To ensure the portability please do not compile with the -DENABLE_BIT_PACKING definition.\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- tools::Bit_packer::unpack(this->s_bis.data(), V_N, this->N, n_frames);\n+ tools::Bit_packer::unpack(this->s_bis.data(), (unsigned char*)V_N, this->N, n_frames);\n}\n#endif\nif (!fast_deinterleave)\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/RS/Decoder_RS.cpp", "new_path": "src/Module/Decoder/RS/Decoder_RS.cpp", "diff": "@@ -31,13 +31,6 @@ Decoder_RS<B, R>\nconst std::string name = \"Decoder_RS\";\nthis->set_name(name);\n- if (K <= 3)\n- {\n- std::stringstream message;\n- message << \"'K' has to be greater than 3 ('K' = \" << K << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\nif ((this->N_rs - this->K_rs) != this->n_rdncy)\n{\nstd::stringstream message;\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Algo/Bit_packer.hpp", "new_path": "src/Tools/Algo/Bit_packer.hpp", "diff": "@@ -348,7 +348,7 @@ private:\n{\nS symb = 0;\nfor (auto j = 0; j < Nbps; j++, vec_in++)\n- symb |= (symb << 1) | (*vec_in != 0);\n+ symb = (symb << 1) | (*vec_in != 0);\n*symbs_out = symb << (sizeof(S) * CHAR_BIT - Nbps);\n}\n@@ -356,7 +356,7 @@ private:\n{\nS symb = 0;\nfor (auto j = 0; j < rest; j++, vec_in++)\n- symb |= (symb << 1) | (*vec_in != 0);\n+ symb = (symb << 1) | (*vec_in != 0);\n*symbs_out = symb << (sizeof(S) * CHAR_BIT - rest);\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix Bit Packer and and the way it is called in decoder polar et CRC
8,483
31.07.2018 17:01:11
-7,200
1627c032654eee7c1a822869481b094cf767dcbb
Fix in decoder RS factory the computation of T from N and K and reciprocally
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/RS/Decoder_RS.cpp", "new_path": "src/Factory/Module/Decoder/RS/Decoder_RS.cpp", "diff": "@@ -70,12 +70,12 @@ void Decoder_RS::parameters\nthis->t = vals.to_int({p + \"-corr-pow\", \"T\"});\nif (K == 0)\n{\n- this->K = this->N_cw - tools::RS_polynomial_generator(this->N_cw, this->t).get_n_rdncy();\n+ this->K = this->N_cw - this->t * 2;\nthis->R = (float) this->K / (float) this->N_cw;\n}\n}\nelse\n- this->t = (this->N_cw - this->K) / this->m;\n+ this->t = (this->N_cw - this->K) / 2;\n}\nvoid Decoder_RS::parameters\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix in decoder RS factory the computation of T from N and K and reciprocally
8,483
31.07.2018 17:01:22
-7,200
ef4e67e9e8812f597df22639c30f9dff872a5ce4
Add RS references
[ { "change_type": "MODIFY", "old_path": ".gitlab-ci.yml", "new_path": ".gitlab-ci.yml", "diff": "@@ -360,6 +360,27 @@ test-regression-polar:\n- source ./ci/tools/threads.sh\n- ./ci/test-regression.py --refs-path refs/POLAR --results-path test-regression-results-polar --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n+test-regression-rs:\n+ stage: test\n+ retry: 1\n+ dependencies:\n+ - build-linux-gcc-x64-sse4.2\n+ tags:\n+ - linux\n+ - x86\n+ - 64-bit\n+ - sse4.2\n+ - powerful\n+ - python\n+ artifacts:\n+ name: test-regression-results-rs\n+ when: always\n+ paths:\n+ - test-regression-results-rs/\n+ script:\n+ - source ./ci/tools/threads.sh\n+ - ./ci/test-regression.py --refs-path refs/RS --results-path test-regression-results-rs --build-path build_linux_gcc_x64_sse4.2 --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1 --n-threads $THREADS\n+\ntest-regression-turbo:\nstage: test\nretry: 1\n" }, { "change_type": "MODIFY", "old_path": "refs", "new_path": "refs", "diff": "-Subproject commit 208a47ec3e8c4e9b51a3d90e86d00ca621fd2f15\n+Subproject commit 0295991bc5faf444ffd2bc33c66c7af9c88fb5cb\n" } ]
C++
MIT License
aff3ct/aff3ct
Add RS references
8,490
01.08.2018 15:19:45
-7,200
9b5357d903ee628d9be71bd0eaba4cb4e0ef2a18
Replace the '--sim-pyber' param by '--sim-meta'.
[ { "change_type": "MODIFY", "old_path": "src/Factory/Simulation/Simulation.cpp", "new_path": "src/Factory/Simulation/Simulation.cpp", "diff": "@@ -45,9 +45,9 @@ void Simulation::parameters\nauto p = this->get_prefix();\nargs.add(\n- {p+\"-pyber\"},\n+ {p+\"-meta\"},\ntools::Text(),\n- \"prepare the output for the PyBER plotter tool, takes the name of the curve in PyBER.\");\n+ \"print the output with metadata, takes the simulation title.\");\nargs.add(\n{p+\"-stop-time\"},\n@@ -122,7 +122,7 @@ void Simulation::parameters\nauto p = this->get_prefix();\n- if(vals.exist({p+\"-pyber\" })) this->pyber = vals.at ({p+\"-pyber\" });\n+ if(vals.exist({p+\"-meta\" })) this->meta = vals.at ({p+\"-meta\" });\nif(vals.exist({p+\"-stop-time\" })) this->stop_time = seconds(vals.to_int({p+\"-stop-time\" }));\nif(vals.exist({p+\"-max-frame\", \"n\"})) this->max_frame = vals.to_int({p+\"-max-frame\", \"n\"});\nif(vals.exist({p+\"-seed\", \"S\"})) this->global_seed = vals.to_int({p+\"-seed\", \"S\"});\n" }, { "change_type": "MODIFY", "old_path": "src/Factory/Simulation/Simulation.hpp", "new_path": "src/Factory/Simulation/Simulation.hpp", "diff": "@@ -34,7 +34,7 @@ struct Simulation : Launcher\nint mpi_size = 1;\n#endif\nstd::chrono::seconds stop_time = std::chrono::seconds(0);\n- std::string pyber = \"\";\n+ std::string meta = \"\";\nunsigned max_frame = 0;\nbool debug = false;\nbool debug_hex = false;\n" }, { "change_type": "MODIFY", "old_path": "src/Launcher/Launcher.cpp", "new_path": "src/Launcher/Launcher.cpp", "diff": "#include <iostream>\n#include <algorithm>\n#include <functional>\n+#include <regex>\n#include <date.h>\n#include \"Tools/Display/Terminal/Terminal.hpp\"\n@@ -157,13 +158,12 @@ int Launcher::launch()\n#ifdef ENABLE_MPI\nif (this->params_common.mpi_rank == 0)\n#endif\n- if (!this->params_common.pyber.empty())\n+ if (!this->params_common.meta.empty())\n{\n- stream << \"Run command:\" << std::endl;\n- stream << cmd_line << std::endl;\n- stream << \"Curve name:\" << std::endl;\n- stream << this->params_common.pyber << std::endl;\n- stream << \"Trace:\" << std::endl;\n+ stream << \"[metadata]\" << std::endl;\n+ stream << \"command=\" << std::regex_replace(cmd_line, std::regex(\"( --sim-meta \\\"[^\\\"]*\\\")\"), \"\") << std::endl;\n+ stream << \"title=\" << this->params_common.meta << std::endl;\n+ stream << std::endl << \"[trace]\" << std::endl;\n}\nif (this->params_common.display_legend)\n" } ]
C++
MIT License
aff3ct/aff3ct
Replace the '--sim-pyber' param by '--sim-meta'.
8,483
01.08.2018 16:13:37
-7,200
0af2548d7e8ab46f9b5be677445cdfbc56ce7078
Remove pointless conversions of Y_N in index form and then back into polynom form
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/RS/Standard/Decoder_RS_std.cpp", "new_path": "src/Module/Decoder/RS/Standard/Decoder_RS_std.cpp", "diff": "@@ -36,16 +36,16 @@ void Decoder_RS_std<B,R>\n{\nbool syn_error = false;\n- for (auto j = 0; j < this->N_rs; j++)\n- Y_N[j] = this->index_of[Y_N[j]];\n-\n// first form the syndromes\nfor (auto i = 1; i <= t2; i++)\n{\ns[i] = 0;\nfor (auto j = 0; j < this->N_rs; j++)\n- if (Y_N[j] != -1)\n- s[i] ^= this->alpha_to[(Y_N[j] + i * j) % this->N_p2_1];\n+ {\n+ auto y_idx = this->index_of[Y_N[j]];\n+ if (y_idx != -1)\n+ s[i] ^= this->alpha_to[(y_idx + i * j) % this->N_p2_1];\n+ }\nsyn_error |= s[i] != 0; // set error flag if non-zero syndrome\n@@ -215,11 +215,6 @@ void Decoder_RS_std<B,R>\n// evaluate errors at locations given by error location numbers loc[i]\nstd::fill(err.begin(), err.end(), 0);\n- for (auto i = 0; i < this->N_rs; i++)\n- if (Y_N[i] != -1) // convert Y_N[] to polynomial form\n- Y_N[i] = this->alpha_to[Y_N[i]];\n- else\n- Y_N[i] = 0;\nfor (auto i = 0; i < l[u]; i++) // compute numerator of error term first\n{\n@@ -243,28 +238,13 @@ void Decoder_RS_std<B,R>\n}\n}\n}\n- else // no. roots != degree of elp => over t errors and cannot solve\n- cvt_to_polynomial(Y_N);\n- }\n- else // elp has degree has degree > t hence cannot solve\n- cvt_to_polynomial(Y_N);\n+ // else // no. roots != degree of elp => over t errors and cannot solve\n}\n- else // no non-zero syndromes => no errors: output received codeword\n- cvt_to_polynomial(Y_N);\n+ // else // elp has degree has degree > t hence cannot solve\n}\n-\n-template <typename B, typename R>\n-void Decoder_RS_std<B,R>\n-::cvt_to_polynomial(S *Y_N)\n-{\n- for (auto i = 0; i < this->N_rs; i++)\n- if (Y_N[i] != -1)\n- Y_N[i] = this->alpha_to[Y_N[i]];\n- else\n- Y_N[i] = 0;\n+ // else // no non-zero syndromes => no errors: output received codeword\n}\n-\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/RS/Standard/Decoder_RS_std.hpp", "new_path": "src/Module/Decoder/RS/Standard/Decoder_RS_std.hpp", "diff": "@@ -39,8 +39,6 @@ public:\nprotected:\nvirtual void _decode(S *Y_N, const int frame_id);\n-\n- void cvt_to_polynomial(S *Y_N);\n};\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Remove pointless conversions of Y_N in index form and then back into polynom form
8,483
01.08.2018 16:19:16
-7,200
771b14488fef61d1b6152566a2ee9fffa4060003
Make the RS Genius work
[ { "change_type": "MODIFY", "old_path": "src/Factory/Module/Decoder/RS/Decoder_RS.cpp", "new_path": "src/Factory/Module/Decoder/RS/Decoder_RS.cpp", "diff": "@@ -47,7 +47,7 @@ void Decoder_RS::parameters\nargs.add_link({p+\"-corr-pow\", \"T\"}, {p+\"-info-bits\", \"K\"});\ntools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"ALGEBRAIC\");\n- // tools::add_options(args.at({p+\"-implem\" }), 0, \"GENIUS\");\n+ tools::add_options(args.at({p+\"-implem\" }), 0, \"GENIUS\");\n}\nvoid Decoder_RS::parameters\n@@ -121,10 +121,10 @@ module::Decoder_SIHO_HIHO<B,Q>* Decoder_RS::parameters\n{\nif (this->implem == \"STD\") return new module::Decoder_RS_std<B,Q>(this->K, this->N_cw, GF, this->n_frames);\n- // if (encoder)\n- // {\n- // if (this->implem == \"GENIUS\") return new module::Decoder_RS_genius<B,Q>(this->K, this->N_cw, this->t, *encoder, this->n_frames);\n- // }\n+ if (encoder)\n+ {\n+ if (this->implem == \"GENIUS\") return new module::Decoder_RS_genius<B,Q>(this->K, this->N_cw, GF, *encoder, this->n_frames);\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/RS/Genius/Decoder_RS_genius.cpp", "new_path": "src/Module/Decoder/RS/Genius/Decoder_RS_genius.cpp", "diff": "#include \"Tools/Perf/common/hard_decide.h\"\n#include \"Tools/Perf/common/hamming_distance.h\"\n#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Algo/Bit_packer.hpp\"\n#include \"Decoder_RS_genius.hpp\"\n@@ -15,7 +16,8 @@ Decoder_RS_genius<B,R>\n::Decoder_RS_genius(const int K, const int N, const tools::RS_polynomial_generator &GF, Encoder<B> &encoder, const int n_frames)\n: Decoder (K * GF.get_m(), N * GF.get_m(), n_frames, 1),\nDecoder_RS<B,R>(K, N, GF, n_frames ),\n- encoder (encoder )\n+ encoder (encoder ),\n+ X_Ns (this->N_rs )\n{\nconst std::string name = \"Decoder_RS_genius\";\nthis->set_name(name);\n@@ -35,14 +37,29 @@ void Decoder_RS_genius<B,R>\nthrow tools::unimplemented_error(__FILE__, __LINE__, __func__);\n}\n+template <typename B, typename R>\n+int Decoder_RS_genius<B,R>\n+::hamming_distance()\n+{\n+ int n_error = 0;\n+ for (auto x = this->X_Ns.begin(), y = this->YH_N.begin(); x != this->X_Ns.end(); x++, y++)\n+ if (*x != *y)\n+ n_error ++;\n+\n+ return n_error;\n+}\n+\ntemplate <typename B, typename R>\nvoid Decoder_RS_genius<B,R>\n::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\nauto& X_N = encoder.get_X_N(frame_id);\n- int n_error = (int)tools::hamming_distance(X_N.data(), Y_N, this->N);\n+ tools::Bit_packer::pack(X_N.data(), this->X_Ns.data(), this->N, 1, false, this->m);\n+ tools::Bit_packer::pack(Y_N, this->YH_N.data(), this->N, 1, false, this->m);\n+ auto n_error = this->hamming_distance();\n+\n+ // auto n_error = (int)tools::hamming_distance(X_N.data(), Y_N, this->N);\nif (n_error <= this->t) // then copy X_N from the encoder that is Y_N corrected\nstd::copy(X_N.data() + this->N - this->K, X_N.data() + this->N, V_K);\n@@ -56,10 +73,13 @@ template <typename B, typename R>\nvoid Decoder_RS_genius<B,R>\n::_decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id)\n{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\nauto& X_N = encoder.get_X_N(frame_id);\n- int n_error = (int)tools::hamming_distance(X_N.data(), Y_N, this->N);\n+ tools::Bit_packer::pack(X_N.data(), this->X_Ns.data(), this->N, 1, false, this->m);\n+ tools::Bit_packer::pack(Y_N, this->YH_N.data(), this->N, 1, false, this->m);\n+ auto n_error = hamming_distance();\n+\n+ // int n_error = (int)tools::hamming_distance(X_N.data(), Y_N, this->N);\nif (n_error <= this->t) // then copy X_N from the encoder that is Y_N corrected\nstd::copy(X_N.data(), X_N.data() + this->N, V_N);\n@@ -73,20 +93,18 @@ template <typename B, typename R>\nvoid Decoder_RS_genius<B,R>\n::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n- tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n+ tools::hard_decide(Y_N, this->YH_Nb.data(), this->N);\n- this->_decode_hiho(this->YH_N.data(), V_K, frame_id);\n+ this->_decode_hiho(this->YH_Nb.data(), V_K, frame_id);\n}\ntemplate <typename B, typename R>\nvoid Decoder_RS_genius<B,R>\n::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n- tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n+ tools::hard_decide(Y_N, this->YH_Nb.data(), this->N);\n- this->_decode_hiho_cw(this->YH_N.data(), V_N, frame_id);\n+ this->_decode_hiho_cw(this->YH_Nb.data(), V_N, frame_id);\n}\n// ==================================================================================== explicit template instantiation\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/RS/Genius/Decoder_RS_genius.hpp", "new_path": "src/Module/Decoder/RS/Genius/Decoder_RS_genius.hpp", "diff": "@@ -18,6 +18,7 @@ public:\nprotected:\nEncoder<B> &encoder;\n+ std::vector<S> X_Ns; // packed as symbols X_N\npublic:\nDecoder_RS_genius(const int K, const int N, const tools::RS_polynomial_generator &GF, Encoder<B> &encoder, const int n_frames = 1);\n@@ -29,6 +30,9 @@ protected:\nvirtual void _decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id);\nvirtual void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\nvirtual void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n+\n+private:\n+ int hamming_distance();\n};\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Make the RS Genius work
8,490
02.08.2018 10:00:52
-7,200
5ae8c8438c381f5aa20f69bc5bd63cb95c7740b5
Fix compilation error on gcc-4.8.
[ { "change_type": "MODIFY", "old_path": "src/Launcher/Launcher.cpp", "new_path": "src/Launcher/Launcher.cpp", "diff": "@@ -160,8 +160,14 @@ int Launcher::launch()\n#endif\nif (!this->params_common.meta.empty())\n{\n+// trick to compile on the GNU compiler version 4 (where 'std::regex' is unavailable)\n+#if !defined(__clang__) && !defined(__llvm__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC__ < 5\n+ const auto cmd = cmd_line;\n+#else\n+ const auto cmd = std::regex_replace(cmd_line, std::regex(\"( --sim-meta \\\"[^\\\"]*\\\")\"), \"\");\n+#endif\nstream << \"[metadata]\" << std::endl;\n- stream << \"command=\" << std::regex_replace(cmd_line, std::regex(\"( --sim-meta \\\"[^\\\"]*\\\")\"), \"\") << std::endl;\n+ stream << \"command=\" << cmd << std::endl;\nstream << \"title=\" << this->params_common.meta << std::endl;\nstream << std::endl << \"[trace]\" << std::endl;\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix compilation error on gcc-4.8.
8,483
02.08.2018 11:24:19
-7,200
df822be653659ec24abd6f802583780dd8b63d0b
Remove \r at the end of the temp report's line
[ { "change_type": "MODIFY", "old_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp", "new_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp", "diff": "@@ -268,7 +268,7 @@ void Terminal_std\n}\nelse\n{\n- stream << rang::style::bold << rang::fg::green << (real_time_state++ < 2 ? \" *\" : \" \") << rang::style::reset << \"\\r\";\n+ stream << rang::style::bold << rang::fg::green << (real_time_state++ < 2 ? \" *\" : \" \") << rang::style::reset;\nreal_time_state %= (uint8_t)4;\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Remove \r at the end of the temp report's line
8,490
02.08.2018 16:05:15
-7,200
b495e1a194ef4b815c650d4aabddb21bf8ebf184
Update the CI to work with the new metadata in the refs.
[ { "change_type": "MODIFY", "old_path": ".gitlab-ci.yml", "new_path": ".gitlab-ci.yml", "diff": "@@ -458,6 +458,7 @@ test-build-coverage-regression:\npaths:\n- code_coverage_files/\nscript:\n+ - source ./ci/tools/threads.sh\n- ./ci/test-build-coverage-regression.sh\ncoverage-linux:\n" }, { "change_type": "MODIFY", "old_path": "ci/test-build-coverage-regression.sh", "new_path": "ci/test-build-coverage-regression.sh", "diff": "#!/bin/bash\nset -x\n-source ci/threads.sh\n+if [ -z \"$THREADS\" ]\n+then\n+ echo \"The 'THREADS' environment variable is not set, default value = 1.\"\n+ THREADS=1\n+fi\nWD=$(pwd)\nbuild_root=build_coverage_linux_x86_gcc\n@@ -24,6 +28,7 @@ function gen_coverage_info\nfor path in $folder/*\ndo [ -f $path ] && {\ncmd=$(cat $path | sed -n 2p)\n+ cmd=${cmd/command=/\"\"}\necho $cmd\ncd $build\neval \"${cmd} --sim-stop-time 1 -t 1\"\n" }, { "change_type": "MODIFY", "old_path": "ci/test-regression.py", "new_path": "ci/test-regression.py", "diff": "@@ -136,38 +136,34 @@ class simuData:\ndef dataReader(aff3ctOutput):\ndata = simuData()\n-\n+ metadata = {'command': '', 'title': '', 'ci': 'on'}\n+ startMeta = False;\n+ startTrace = False;\nfor line in aff3ctOutput:\n+ if startMeta:\n+ vals = line.split('=', 1);\n+ if len(vals) == 2:\n+ metadata[vals[0]] = vals[1];\n+ if line.startswith(\"[metadata]\"):\n+ startMeta = True;\n+\n+ if startTrace:\nif line.startswith(\"#\"):\nif len(line) > 20 and (line.find(\"FRA |\") != -1 or line.find(\"BER |\") != -1 or line.find(\"FER |\") != -1):\ndata.Legend = getLegend(line)\n-\nelse:\nif len(data.Legend) != 0:\nd = getVal(line)\nif len(d) == len(data.Legend):\ndata.All.append(d)\n+ if line.startswith(\"[trace]\"):\n+ startTrace = True;\n+ startMeta = False;\n-\n+ data.RunCommand = str(metadata['command'].strip());\n+ data.CurveName = str(metadata['title' ].strip());\ndata.All = np.array(data.All).transpose()\n- # get the command to to run to reproduce this trace\n- if len(aff3ctOutput) >= 2 and \"Run command:\" in aff3ctOutput[0]:\n- data.RunCommand = str(aff3ctOutput[1].strip())\n- elif len(aff3ctOutput) >= 4 and \"Run command:\" in aff3ctOutput[2]:\n- data.RunCommand = str(aff3ctOutput[3].strip())\n- else:\n- data.RunCommand = \"\"\n-\n- # get the curve name (if there is one)\n- if len(lines) >= 2 and \"Curve name:\" in lines[0]:\n- data.CurveName = str(lines[1].strip())\n- elif len(lines) >= 4 and \"Curve name:\" in lines[2]:\n- data.CurveName = str(lines[3].strip())\n- else:\n- data.CurveName = \"\"\n-\n-\n# find the type of noise used in this simulation\nidx = -1\nfor n in NoiseTypeList:\n@@ -218,6 +214,7 @@ def dataReader(aff3ctOutput):\nreturn data\ndef splitAsCommand(runCommand):\n+\n# split the run command\nargsList = [\"\"]\nidx = 0\n@@ -252,6 +249,7 @@ def splitAsCommand(runCommand):\nelse:\nargsList[idx] += s\n+ if argsList[idx] == \"\":\ndel argsList[idx]\nreturn argsList\n@@ -531,8 +529,8 @@ for fn in fileNames:\n# get the command line to run\nargsAFFECT = argsAFFECTcommand[:]\nargsAFFECT += splitAsCommand(simuRef.RunCommand)\n-\nargsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-no-colors\"]\n+ argsAFFECT += [\"--sim-meta\", simuRef.CurveName]\nif args.maxFE:\nargsAFFECT += [\"-e\", str(args.maxFE)]\n@@ -662,11 +660,8 @@ for fn in fileNames:\ntestId = testId + 1\n-\n- if elapsedTime < 0.5:\n- break;\n-\n-\n+ # if elapsedTime < 0.5:\n+ # break;\nif len(fileNames) - (args.startId -1) > 0:\nif nErrors == 0:\n" } ]
C++
MIT License
aff3ct/aff3ct
Update the CI to work with the new metadata in the refs.
8,490
03.08.2018 10:35:14
-7,200
2c49fecbd497d9da2aab21183dec767896b21dc0
Reinforce CI scripts.
[ { "change_type": "MODIFY", "old_path": "ci/build-linux-macos.sh", "new_path": "ci/build-linux-macos.sh", "diff": "@@ -22,6 +22,12 @@ then\nTHREADS=1\nfi\n+if [ -z \"$NAME\" ]\n+then\n+ echo \"The 'NAME' environment variable is not set, default value = 'build_linux_macos'.\"\n+ NAME=\"build_linux_macos\"\n+fi\n+\nif [ -z \"$LFLAGS\" ]\nthen\ncmake .. -G\"Unix Makefiles\" -DCMAKE_CXX_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX \\\n" }, { "change_type": "MODIFY", "old_path": "ci/deploy-builds-linux.sh", "new_path": "ci/deploy-builds-linux.sh", "diff": "#!/bin/bash\nset -x\n+if [ -z \"$GIT_BRANCH\" ]\n+then\n+ echo \"Please define the 'GIT_BRANCH' environment variable.\"\n+ exit 1\n+fi\n+\n+if [ -z \"$GIT_TAG\" ]\n+then\n+ echo \"Please define the 'GIT_TAG' environment variable.\"\n+ exit 1\n+fi\n+\n+if [ -z \"$GIT_HASH\" ]\n+then\n+ echo \"Please define the 'GIT_HASH' environment variable.\"\n+ exit 1\n+fi\n+\n+if [ -z \"$GIT_DATE\" ]\n+then\n+ echo \"Please define the 'GIT_DATE' environment variable.\"\n+ exit 1\n+fi\n+\n+if [ -z \"$GIT_MESSAGE\" ]\n+then\n+ echo \"Please define the 'GIT_MESSAGE' environment variable.\"\n+ exit 1\n+fi\n+\n+if [ -z \"$GIT_AUTHOR\" ]\n+then\n+ echo \"Please define the 'GIT_AUTHOR' environment variable.\"\n+ exit 1\n+fi\n+\nREPO_WEB=aff3ct.github.io\nREPO_RESSOURCES=ressources\ngit clone git@github.com:aff3ct/${REPO_WEB}.git\n" }, { "change_type": "MODIFY", "old_path": "ci/test-build-coverage-regression.sh", "new_path": "ci/test-build-coverage-regression.sh", "diff": "@@ -27,8 +27,7 @@ function gen_coverage_info\nlocal folder=$2\nfor path in $folder/*\ndo [ -f $path ] && {\n- cmd=$(cat $path | sed -n 2p)\n- cmd=${cmd/command=/\"\"}\n+ cmd=$(awk -F \"=\" '/command/ {print $2}' $path)\necho $cmd\ncd $build\neval \"${cmd} --sim-stop-time 1 -t 1\"\n" } ]
C++
MIT License
aff3ct/aff3ct
Reinforce CI scripts.
8,483
03.08.2018 13:17:19
-7,200
a5566ef76bc63961560df401626fd9998dd0845c
Fix Monitor MPI attributes calls: remove const variables in attributes to avoid Monitor rebuild during MPI reduce op
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "diff": "@@ -13,10 +13,10 @@ using namespace aff3ct::module;\ntemplate <typename B>\nMonitor_BFER<B>\n-::Monitor_BFER(const int K, const unsigned max_fe, const unsigned max_n_frames, const bool count_unknown_values, const int n_frames)\n-: Monitor(n_frames),\n- vals(Attributes{K, n_frames, max_fe, max_n_frames, count_unknown_values, 0, 0, 0}),\n- err_hist(0)\n+::Monitor_BFER(const int K, const unsigned max_fe, const unsigned max_n_frames,\n+ const bool count_unknown_values, const int n_frames)\n+: Monitor(n_frames), K(K), max_fe(max_fe), max_n_frames(max_n_frames),\n+ count_unknown_values(count_unknown_values), vals(Attributes{0, 0, 0}), err_hist(0)\n{\nconst std::string name = \"Monitor_BFER\";\nthis->set_name(name);\n@@ -56,15 +56,6 @@ Monitor_BFER<B>\n}\n-template <typename B>\n-Monitor_BFER<B>\n-::Monitor_BFER(const Attributes& v)\n-: Monitor(v.n_frames), vals(v)\n-{\n-}\n-\n-\n-\ntemplate <typename B>\nbool Monitor_BFER<B>\n::equivalent(const Monitor_BFER<B>& m, bool do_throw) const\n@@ -174,7 +165,7 @@ template <typename B>\nbool Monitor_BFER<B>\n::frame_limit_achieved() const\n{\n- return get_max_n_frames() != 0 && get_n_frames() >= get_max_n_frames();\n+ return get_max_n_frames() != 0 && get_n_frames() >= (int)get_max_n_frames();\n}\ntemplate <typename B>\n@@ -197,21 +188,21 @@ template <typename B>\nint Monitor_BFER<B>\n::get_K() const\n{\n- return vals.K;\n+ return K;\n}\ntemplate <typename B>\nunsigned Monitor_BFER<B>\n::get_max_n_frames() const\n{\n- return vals.max_n_frames;\n+ return max_n_frames;\n}\ntemplate <typename B>\nunsigned Monitor_BFER<B>\n::get_max_fe() const\n{\n- return vals.max_fe;\n+ return max_fe;\n}\ntemplate <typename B>\n@@ -265,7 +256,7 @@ template<typename B>\nbool Monitor_BFER<B>\n::get_count_unknown_values() const\n{\n- return vals.count_unknown_values;\n+ return count_unknown_values;\n}\ntemplate<typename B>\n@@ -346,9 +337,7 @@ template <typename B>\nvoid Monitor_BFER<B>\n::collect(const Attributes& v)\n{\n- vals.n_be += v.n_be;\n- vals.n_fe += v.n_fe;\n- vals.n_fra += v.n_fra;\n+ vals += v;\n}\ntemplate <typename B>\n@@ -384,9 +373,7 @@ template <typename B>\nvoid Monitor_BFER<B>\n::copy(const Attributes& v)\n{\n- vals.n_fra = v.n_fra;\n- vals.n_be = v.n_be;\n- vals.n_fe = v.n_fe;\n+ vals = v;\n}\ntemplate <typename B>\n@@ -396,6 +383,20 @@ Monitor_BFER<B>& Monitor_BFER<B>\ncopy(m, false);\nreturn *this;\n}\n+\n+\n+template <typename B>\n+typename Monitor_BFER<B>::Attributes& Monitor_BFER<B>::Attributes\n+::operator+=(const Attributes& a)\n+{\n+ n_be += a.n_be;\n+ n_fe += a.n_fe;\n+ n_fra += a.n_fra;\n+\n+ return *this;\n+}\n+\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "diff": "@@ -16,21 +16,22 @@ public:\ninline Task& operator[](const mnt::tsk t) { return Module::operator[]((int)t); }\ninline Socket& operator[](const mnt::sck::check_errors s) { return Module::operator[]((int)mnt::tsk::check_errors)[(int)s]; }\n-private:\n+protected:\nstruct Attributes\n{\n- const int K; // Number of source bits\n- const int n_frames; // Number of frames\n- const unsigned max_fe; // max number of wrong frames to get then fe_limit_achieved() returns true else if 0\n- const unsigned max_n_frames; // max number of frames to check then frame_limit_achieved() returns true else if 0\n- const bool count_unknown_values; // take into account or not the unknown values as wrong values in the checked frames\n-\nunsigned long long n_fra; // the number of checked frames\nunsigned long long n_be; // the number of wrong bits\nunsigned long long n_fe; // the number of wrong frames\n+\n+ Attributes& operator+=(const Attributes&);\n};\nprivate:\n+ const int K; // Number of source bits\n+ const unsigned max_fe; // max number of wrong frames to get then fe_limit_achieved() returns true else if 0\n+ const unsigned max_n_frames; // max number of frames to check then frame_limit_achieved() returns true else if 0\n+ const bool count_unknown_values; // take into account or not the unknown values as wrong values in the checked frames\n+\nAttributes vals;\ntools::Histogram<int> err_hist; // the error histogram record\n@@ -43,7 +44,6 @@ public:\nMonitor_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\nMonitor_BFER(); // construct with null and default parameters.\n- Monitor_BFER(const Attributes& v);\nvirtual ~Monitor_BFER() = default;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp", "diff": "@@ -10,8 +10,7 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nMonitor_EXIT<B,R>\n::Monitor_EXIT(const int N, const unsigned max_n_trials, const int n_frames)\n-: Monitor(n_frames),\n- vals(Attributes{N, n_frames, max_n_trials, 0, 0})\n+: Monitor(n_frames), N(N), max_n_trials(max_n_trials), vals(Attributes{0, 0})\n{\nconst std::string name = \"Monitor_EXIT\";\nthis->set_name(name);\n@@ -47,13 +46,6 @@ Monitor_EXIT<B,R>\n{\n}\n-template <typename B, typename R>\n-Monitor_EXIT<B,R>\n-::Monitor_EXIT(const Attributes& v)\n-: Monitor(v.n_frames), vals(v)\n-{\n-}\n-\ntemplate <typename B, typename R>\nbool Monitor_EXIT<B,R>\n@@ -282,14 +274,14 @@ template <typename B, typename R>\nint Monitor_EXIT<B,R>\n::get_N() const\n{\n- return vals.N;\n+ return N;\n}\ntemplate <typename B, typename R>\nunsigned Monitor_EXIT<B,R>\n::get_max_n_trials() const\n{\n- return vals.max_n_trials;\n+ return max_n_trials;\n}\ntemplate <typename B, typename R>\n@@ -360,8 +352,7 @@ template <typename B, typename R>\nvoid Monitor_EXIT<B,R>\n::collect(const Attributes& v)\n{\n- vals.n_trials += v.n_trials;\n- vals.I_A_sum += v.I_A_sum;\n+ vals += v;\n}\ntemplate <typename B, typename R>\n@@ -392,8 +383,7 @@ template <typename B, typename R>\nvoid Monitor_EXIT<B,R>\n::copy(const Attributes& v)\n{\n- vals.n_trials = v.n_trials;\n- vals.I_A_sum = v.I_A_sum;\n+ vals = v;\n}\ntemplate <typename B, typename R>\n@@ -404,6 +394,17 @@ Monitor_EXIT<B,R>& Monitor_EXIT<B,R>\nreturn *this;\n}\n+template <typename B, typename R>\n+typename Monitor_EXIT<B,R>::Attributes& Monitor_EXIT<B,R>::Attributes\n+::operator+=(const Attributes& a)\n+{\n+ n_trials += a.n_trials;\n+ I_A_sum += a.I_A_sum;\n+\n+ return *this;\n+}\n+\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "diff": "@@ -21,15 +21,16 @@ public:\nprotected:\nstruct Attributes\n{\n- const int N; // Number of frame bits\n- const int n_frames; // Number of frames\n- const unsigned max_n_trials; // max number of trials to check then n_trials_limit_achieved() returns true\n-\nunsigned long long n_trials; // Number of checked trials\nR I_A_sum; // the mutual information\n+\n+ Attributes& operator+=(const Attributes&);\n};\nprivate:\n+ const int N; // Number of frame bits\n+ const unsigned max_n_trials; // max number of trials to check then n_trials_limit_achieved() returns true\n+\nAttributes vals;\nstd::vector<std::function<void(void)>> callbacks_measure;\n@@ -42,7 +43,6 @@ public:\nMonitor_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\nMonitor_EXIT(); // construct with null and default parameters.\n- Monitor_EXIT(const Attributes& v); // init the monitor with the given values\nvirtual ~Monitor_EXIT() = default;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/MI/Monitor_MI.cpp", "new_path": "src/Module/Monitor/MI/Monitor_MI.cpp", "diff": "@@ -15,9 +15,8 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nMonitor_MI<B,R>\n::Monitor_MI(const int N, const unsigned max_n_trials, const int n_frames)\n-: Monitor(n_frames),\n- vals(Attributes{N, n_frames, max_n_trials, 0, 0, 0, 0}),\n- mutinfo_hist(1)\n+: Monitor(n_frames), N(N), max_n_trials(max_n_trials),\n+ vals(Attributes{0, 0, 0, 0}), mutinfo_hist(1)\n{\nconst std::string name = \"Monitor_MI\";\nthis->set_name(name);\n@@ -55,13 +54,6 @@ Monitor_MI<B,R>\n{\n}\n-template <typename B, typename R>\n-Monitor_MI<B,R>\n-::Monitor_MI(const Attributes& v)\n-: Monitor(v.n_frames), vals(v)\n-{\n-}\n-\ntemplate <typename B, typename R>\nbool Monitor_MI<B,R>\n@@ -193,14 +185,14 @@ template <typename B, typename R>\nint Monitor_MI<B,R>\n::get_N() const\n{\n- return vals.N;\n+ return N;\n}\ntemplate <typename B, typename R>\nunsigned Monitor_MI<B,R>\n::get_max_n_trials() const\n{\n- return vals.max_n_trials;\n+ return max_n_trials;\n}\ntemplate <typename B, typename R>\n@@ -300,11 +292,7 @@ template <typename B, typename R>\nvoid Monitor_MI<B,R>\n::collect(const Attributes& v)\n{\n- vals.n_trials += v.n_trials;\n- vals.MI += (v.MI - vals.MI) * ((R)v.n_trials / (R)vals.n_trials);\n-\n- vals.MI_max = std::max(vals.MI_max, v.MI_max);\n- vals.MI_min = std::min(vals.MI_min, v.MI_min);\n+ vals += v;\n}\ntemplate <typename B, typename R>\n@@ -348,10 +336,7 @@ template <typename B, typename R>\nvoid Monitor_MI<B,R>\n::copy(const Attributes& v)\n{\n- vals.n_trials = v.n_trials;\n- vals.MI = v.MI;\n- vals.MI_max = v.MI_max;\n- vals.MI_min = v.MI_min;\n+ vals = v;\n}\n@@ -371,6 +356,18 @@ Monitor_MI<B,R>& Monitor_MI<B,R>\nreturn *this;\n}\n+template <typename B, typename R>\n+typename Monitor_MI<B,R>::Attributes& Monitor_MI<B,R>::Attributes\n+::operator+=(const Attributes& v)\n+{\n+ n_trials += v.n_trials;\n+ MI += (v.MI - MI) * ((R)v.n_trials / (R)n_trials);\n+\n+ MI_max = std::max(MI_max, v.MI_max);\n+ MI_min = std::min(MI_min, v.MI_min);\n+ return *this;\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "new_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "diff": "@@ -19,17 +19,18 @@ public:\nprotected:\nstruct Attributes\n{\n- const int N; // Number of frame bits\n- const int n_frames; // Number of frames\n- const unsigned max_n_trials; // max number of trials to check then n_trials_limit_achieved() returns true\n-\nunsigned long long n_trials; // Number of checked trials\nR MI; // the mutual information\nR MI_max; // the maximum obtained MI\nR MI_min; // the minimum obtained MI\n+\n+ Attributes& operator+=(const Attributes&);\n};\nprivate:\n+ const int N; // Number of frame bits\n+ const unsigned max_n_trials; // max number of trials to check then n_trials_limit_achieved() returns true\n+\nAttributes vals;\ntools::Histogram<R> mutinfo_hist; // the MI histogram record\n@@ -44,7 +45,6 @@ public:\nMonitor_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\nMonitor_MI(); // construct with null and default parameters.\n- Monitor_MI(const Attributes& v); // init the monitor with the given values\nvirtual ~Monitor_MI() = default;\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.cpp", "new_path": "src/Module/Monitor/Monitor_reduction.cpp", "diff": "#include <cmath>\n#include <sstream>\n+\n+#ifdef ENABLE_MPI\n+#include <mpi.h>\n+#endif\n+\n#include \"Tools/Exception/exception.hpp\"\n#include \"Monitor_reduction.hpp\"\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp", "new_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp", "diff": "@@ -23,13 +23,13 @@ public:\nprotected:\nusing Attributes = typename M::Attributes;\n- virtual void reduce(bool fully = false, bool stop_simu = false); // return the number of process that stopped the simu\n+ virtual void _reduce(bool fully = false, bool stop_simu = false); // return the number of process that stopped the simu\nprivate:\nMPI_Datatype MPI_monitor_vals;\nMPI_Op MPI_Op_reduce_monitors;\n- static MPI_reduce_monitors(void *in, void *inout, int *len, MPI_Datatype *datatype);\n+ static void MPI_reduce_monitors(void *in, void *inout, int *len, MPI_Datatype *datatype);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction_MPI.hxx", "new_path": "src/Module/Monitor/Monitor_reduction_MPI.hxx", "diff": "@@ -24,27 +24,6 @@ Monitor_reduction_MPI<M>\nconst std::string name = \"Monitor_reduction_MPI<\" + monitors[0]->get_name() + \">\";\nthis->set_name(name);\n- // int blen [M::n_MPI_attributes];\n- // MPI_Aint displacements[M::n_MPI_attributes];\n- // MPI_Datatype oldtypes [M::n_MPI_attributes];\n-\n- // M::create_MPI_struct(blen, displacements, oldtypes);\n-\n- // MPI_Datatype MPI_monitor_vals_tmp;\n-\n- // if (auto ret = MPI_Type_create_struct(M::n_MPI_attributes, blen, displacements, oldtypes, &MPI_monitor_vals_tmp))\n- // {\n- // std::stringstream message;\n- // message << \"'MPI_Type_create_struct' returned '\" << ret << \"' error code.\";\n- // throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- // }\n-\n-\n- // MPI_Aint lb, extent;\n- // MPI_Type_get_extent( MPI_monitor_vals_tmp, &lb, &extent );\n- // extent = sizeof (M);\n- // MPI_Type_create_resized( MPI_monitor_vals_tmp, lb, extent, &MPI_monitor_vals );\n-\nint blen = sizeof(Attributes);\nMPI_Aint displacements = 0;\nMPI_Datatype oldtypes = MPI_CHAR;\n@@ -79,8 +58,7 @@ void Monitor_reduction_MPI<M>\nMonitor_reduction_M<M>::_reduce(fully);\n- // Attributes mvals_recv;\n- auto mvals_send = M::get_attributes(), mvals_recv;\n+ Attributes mvals_send = M::get_attributes(), mvals_recv;\nMPI_Allreduce(&mvals_send, &mvals_recv, 1, MPI_monitor_vals, MPI_Op_reduce_monitors, MPI_COMM_WORLD);\nM::copy(mvals_recv);\n@@ -101,12 +79,7 @@ void Monitor_reduction_MPI<M>\nauto inout_cvt = static_cast<Attributes*>(inout);\nfor (auto i = 0; i < *len; i++)\n- {\n- // M m_in (in_cvt [i]);\n- M m_inout(inout_cvt[i]);\n- m_inout.collect(in_cvt[i]);\n- inout_cvt[i] = m_inout.get_vals_mpi();\n- }\n+ inout_cvt[i] += in_cvt[i];\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Display/Terminal/Terminal.cpp", "new_path": "src/Tools/Display/Terminal/Terminal.cpp", "diff": "+\n+#ifdef ENABLE_MPI\n+#include <mpi.h>\n+#endif\n+\n#include <csignal>\n#include \"Tools/Exception/exception.hpp\"\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix Monitor MPI attributes calls: remove const variables in attributes to avoid Monitor rebuild during MPI reduce op
8,483
03.08.2018 13:51:19
-7,200
b4fa8915609e63daab754eee7c976fb29ae6d1ed
Fix terminal over call in final report with MPI compilation
[ { "change_type": "MODIFY", "old_path": "src/Tools/Display/Terminal/Terminal.cpp", "new_path": "src/Tools/Display/Terminal/Terminal.cpp", "diff": "@@ -53,7 +53,7 @@ void Terminal\nauto et = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - t_term).count();\n- if (!Terminal::is_over() || et >= 1.f)\n+ if (!Terminal::over || et >= 1.f)\nthis->report(stream, true);\nt_term = std::chrono::steady_clock::now();\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix terminal over call in final report with MPI compilation
8,490
03.08.2018 14:05:41
-7,200
576f624f2b1cf8fd6f5cc5c3c83601c1c915df64
Rm the '--sim-no-colors' argument.
[ { "change_type": "MODIFY", "old_path": "ci/test-regression.py", "new_path": "ci/test-regression.py", "diff": "@@ -529,8 +529,7 @@ for fn in fileNames:\n# get the command line to run\nargsAFFECT = argsAFFECTcommand[:]\nargsAFFECT += splitAsCommand(simuRef.RunCommand)\n- argsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-no-colors\"]\n- argsAFFECT += [\"--sim-meta\", simuRef.CurveName]\n+ argsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-meta\", simuRef.CurveName]\nif args.maxFE:\nargsAFFECT += [\"-e\", str(args.maxFE)]\n" } ]
C++
MIT License
aff3ct/aff3ct
Rm the '--sim-no-colors' argument.
8,483
03.08.2018 14:09:41
-7,200
d81d6ded820d123001be06a4127a078cf0938f90
Remove has been checked variable and auto check before each reduce call; Now need manual call after instanciations
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.cpp", "new_path": "src/Module/Monitor/Monitor_reduction.cpp", "diff": "@@ -13,7 +13,6 @@ using namespace aff3ct;\nusing namespace aff3ct::module;\nbool aff3ct::module::Monitor_reduction::stop_loop = false;\n-bool aff3ct::module::Monitor_reduction::has_been_checked = false;\nstd::vector<aff3ct::module::Monitor_reduction*> aff3ct::module::Monitor_reduction::monitors;\nstd::thread::id aff3ct::module::Monitor_reduction::master_thread_id = std::this_thread::get_id();\nstd::chrono::nanoseconds aff3ct::module::Monitor_reduction::d_reduce_frequency = std::chrono::milliseconds(1000);\n@@ -29,7 +28,6 @@ void Monitor_reduction\n::add_monitor(Monitor_reduction* m)\n{\nMonitor_reduction::monitors.push_back(m);\n- Monitor_reduction::has_been_checked = false;\n}\nvoid Monitor_reduction\n@@ -37,7 +35,6 @@ void Monitor_reduction\n{\nMonitor_reduction::t_last_reduction = std::chrono::steady_clock::now();\nMonitor_reduction::stop_loop = false;\n- Monitor_reduction::has_been_checked = false;\nfor(auto& m : Monitor_reduction::monitors)\nm->reset_mr();\n@@ -79,11 +76,7 @@ void Monitor_reduction\nvoid Monitor_reduction\n::check_reducible()\n{\n- if (Monitor_reduction::has_been_checked)\n- return;\n-\n#ifdef ENABLE_MPI\n-\nint n_monitor_send = Monitor_reduction::monitors.size(), n_monitor_recv;\nMPI_Allreduce(&n_monitor_send, &n_monitor_recv, 1, MPI_INT, MPI_PROD, MPI_COMM_WORLD);\n@@ -104,8 +97,6 @@ void Monitor_reduction\n}\n#endif\n-\n- Monitor_reduction::has_been_checked = true;\n}\nbool Monitor_reduction\n@@ -132,8 +123,6 @@ bool Monitor_reduction\nbool Monitor_reduction\n::__reduce__(bool fully, bool force)\n{\n- Monitor_reduction::check_reducible();\n-\nbool all_process_on_last = false;\n// only the master thread can do this\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/Monitor_reduction.hpp", "new_path": "src/Module/Monitor/Monitor_reduction.hpp", "diff": "@@ -36,7 +36,7 @@ public:\nstatic void last_reduce_all(bool fully = false);\n/*\n- * reset 't_last_mpi_comm', clear 'stop_loop' and 'has_been_checked' and call 'reset_mr' on each monitor\n+ * reset 't_last_mpi_comm', clear 'stop_loop' and call 'reset_mr' on each monitor\n*/\nstatic void reset_all();\n@@ -55,6 +55,11 @@ public:\n*/\nstatic void set_stop_loop();\n+ /*\n+ * \\brief throw if all process do not have the same number of monitors to reduce\n+ */\n+ static void check_reducible();\n+\nprotected:\nMonitor_reduction();\n@@ -82,11 +87,6 @@ private:\n*/\nstatic void add_monitor(Monitor_reduction*);\n- /*\n- * \\brief throw if all process do not have the same number of monitors to reduce\n- */\n- static void check_reducible();\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@@ -103,7 +103,6 @@ private:\nstatic bool __reduce__(bool fully, bool force);\nstatic bool stop_loop;\n- static bool has_been_checked;\nstatic std::vector<Monitor_reduction*> monitors;\nstatic std::thread::id master_thread_id;\nstatic std::chrono::nanoseconds d_reduce_frequency;\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.cpp", "new_path": "src/Simulation/BFER/BFER.cpp", "diff": "@@ -414,6 +414,8 @@ void BFER<B,R,Q>\n#endif\nmodule::Monitor_reduction::reset_all();\n+ module::Monitor_reduction::check_reducible();\n+\n}\ntemplate <typename B, typename R, typename Q>\n" } ]
C++
MIT License
aff3ct/aff3ct
Remove has been checked variable and auto check before each reduce call; Now need manual call after instanciations
8,483
03.08.2018 14:10:23
-7,200
e1528c09eb47f0804958314682013d014bb086aa
Add SIGUSER1 and SIGUSER2 signal handling. SIGUSR1 = SIGINT but SIGUSR2 = double SIGINT directly
[ { "change_type": "MODIFY", "old_path": "src/Tools/Display/Terminal/Terminal.cpp", "new_path": "src/Tools/Display/Terminal/Terminal.cpp", "diff": "@@ -27,11 +27,9 @@ Terminal\nTerminal::interrupt = false;\n// Install a signal handler\n-#ifdef ENABLE_MPI\nstd::signal(SIGUSR1, Terminal::signal_interrupt_handler);\n-#else\n+ std::signal(SIGUSR2, Terminal::signal_interrupt_handler);\nstd::signal(SIGINT, Terminal::signal_interrupt_handler);\n-#endif\n}\nTerminal\n@@ -134,6 +132,12 @@ void Terminal\nvoid Terminal\n::signal_interrupt_handler(int signal)\n{\n+ if (signal == SIGUSR2)\n+ {\n+ Terminal::stop();\n+ return;\n+ }\n+\nTerminal::interrupt_cnt++;\nauto t_now = std::chrono::steady_clock::now();\n" } ]
C++
MIT License
aff3ct/aff3ct
Add SIGUSER1 and SIGUSER2 signal handling. SIGUSR1 = SIGINT but SIGUSR2 = double SIGINT directly
8,483
03.08.2018 14:15:10
-7,200
aa65d2a1fa635ba0a751dedfd7da156ab8a03b05
Handle SIGTERM signal to kill cleanly
[ { "change_type": "MODIFY", "old_path": "src/Tools/Display/Terminal/Terminal.cpp", "new_path": "src/Tools/Display/Terminal/Terminal.cpp", "diff": "@@ -30,6 +30,7 @@ Terminal\nstd::signal(SIGUSR1, Terminal::signal_interrupt_handler);\nstd::signal(SIGUSR2, Terminal::signal_interrupt_handler);\nstd::signal(SIGINT, Terminal::signal_interrupt_handler);\n+ std::signal(SIGTERM, Terminal::signal_interrupt_handler);\n}\nTerminal\n@@ -132,12 +133,10 @@ void Terminal\nvoid Terminal\n::signal_interrupt_handler(int signal)\n{\n- if (signal == SIGUSR2)\n- {\n- Terminal::stop();\n- return;\n- }\n+ bool kill = false;\n+ if (signal == SIGUSR1 || signal == SIGINT)\n+ {\nTerminal::interrupt_cnt++;\nauto t_now = std::chrono::steady_clock::now();\n@@ -148,6 +147,26 @@ void Terminal\nTerminal::stop();\nif (d_delta_interrupt < std::chrono::milliseconds(2100))\n+ kill = true;\n+ else\n+ Terminal::interrupt_cnt = 1;\n+ }\n+ Terminal::t_last_interrupt = t_now;\n+\n+ Terminal::first_interrupt = false;\n+ Terminal::interrupt = true;\n+ }\n+ else if (signal == SIGUSR2)\n+ {\n+ Terminal::stop();\n+ }\n+ else if (signal == SIGTERM)\n+ {\n+ kill = true;\n+ }\n+\n+\n+ if (kill)\n{\nif (Terminal::interrupt_cnt >= 4)\n{\n@@ -157,11 +176,4 @@ void Terminal\nstd::exit(EXIT_FAILURE);\n}\n}\n- else\n- Terminal::interrupt_cnt = 1;\n- }\n- Terminal::t_last_interrupt = t_now;\n-\n- Terminal::first_interrupt = false;\n- Terminal::interrupt = true;\n}\n\\ No newline at end of file\n" } ]
C++
MIT License
aff3ct/aff3ct
Handle SIGTERM signal to kill cleanly
8,483
03.08.2018 14:50:51
-7,200
97e2089669b9c7be944cb23e21052734f1706f5a
Add constructors and reset method in Monitors' Attributes to init them correctly.
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "diff": "@@ -16,7 +16,7 @@ Monitor_BFER<B>\n::Monitor_BFER(const int K, const unsigned max_fe, const unsigned max_n_frames,\nconst bool count_unknown_values, const int n_frames)\n: Monitor(n_frames), K(K), max_fe(max_fe), max_n_frames(max_n_frames),\n- count_unknown_values(count_unknown_values), vals(Attributes{0, 0, 0}), err_hist(0)\n+ count_unknown_values(count_unknown_values), err_hist(0)\n{\nconst std::string name = \"Monitor_BFER\";\nthis->set_name(name);\n@@ -231,7 +231,7 @@ float Monitor_BFER<B>\n::get_fer() const\n{\nauto t_fer = 0.f;\n- if (this->get_n_be() != 0)\n+ if (this->get_n_fe() != 0)\nt_fer = (float)this->get_n_fe() / (float)this->get_n_analyzed_fra();\nelse\nt_fer = (1.f) / ((float)this->get_n_analyzed_fra());\n@@ -295,10 +295,7 @@ void Monitor_BFER<B>\n::reset()\n{\nMonitor::reset();\n-\n- vals.n_be = 0;\n- vals.n_fe = 0;\n- vals.n_fra = 0;\n+ vals.reset();\nthis->err_hist.reset();\n}\n@@ -396,6 +393,21 @@ typename Monitor_BFER<B>::Attributes& Monitor_BFER<B>::Attributes\nreturn *this;\n}\n+template <typename B>\n+void Monitor_BFER<B>::Attributes\n+::reset()\n+{\n+ n_be = 0;\n+ n_fe = 0;\n+ n_fra = 0;\n+}\n+\n+template <typename B>\n+Monitor_BFER<B>::Attributes\n+::Attributes()\n+{\n+ reset();\n+}\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp", "diff": "@@ -23,6 +23,8 @@ protected:\nunsigned long long n_be; // the number of wrong bits\nunsigned long long n_fe; // the number of wrong frames\n+ Attributes();\n+ void reset();\nAttributes& operator+=(const Attributes&);\n};\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.cpp", "diff": "@@ -10,7 +10,7 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nMonitor_EXIT<B,R>\n::Monitor_EXIT(const int N, const unsigned max_n_trials, const int n_frames)\n-: Monitor(n_frames), N(N), max_n_trials(max_n_trials), vals(Attributes{0, 0})\n+: Monitor(n_frames), N(N), max_n_trials(max_n_trials)\n{\nconst std::string name = \"Monitor_EXIT\";\nthis->set_name(name);\n@@ -317,9 +317,7 @@ void Monitor_EXIT<B,R>\n::reset()\n{\nMonitor::reset();\n-\n- vals.n_trials = 0;\n- vals.I_A_sum = (R)0.;\n+ vals.reset();\nbits_buff .clear();\nllrs_e_buff.clear();\n@@ -404,6 +402,21 @@ typename Monitor_EXIT<B,R>::Attributes& Monitor_EXIT<B,R>::Attributes\nreturn *this;\n}\n+template <typename B, typename R>\n+void Monitor_EXIT<B,R>::Attributes\n+::reset()\n+{\n+ n_trials = 0;\n+ I_A_sum = 0.;\n+}\n+\n+template <typename B, typename R>\n+Monitor_EXIT<B,R>::Attributes\n+::Attributes()\n+{\n+ reset();\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "new_path": "src/Module/Monitor/EXIT/Monitor_EXIT.hpp", "diff": "@@ -24,6 +24,8 @@ protected:\nunsigned long long n_trials; // Number of checked trials\nR I_A_sum; // the mutual information\n+ Attributes();\n+ void reset();\nAttributes& operator+=(const Attributes&);\n};\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/MI/Monitor_MI.cpp", "new_path": "src/Module/Monitor/MI/Monitor_MI.cpp", "diff": "@@ -16,7 +16,7 @@ template <typename B, typename R>\nMonitor_MI<B,R>\n::Monitor_MI(const int N, const unsigned max_n_trials, const int n_frames)\n: Monitor(n_frames), N(N), max_n_trials(max_n_trials),\n- vals(Attributes{0, 0, 0, 0}), mutinfo_hist(1)\n+ mutinfo_hist(1)\n{\nconst std::string name = \"Monitor_MI\";\nthis->set_name(name);\n@@ -250,11 +250,7 @@ void Monitor_MI<B,R>\n::reset()\n{\nMonitor::reset();\n-\n- vals.n_trials = 0;\n- vals.MI = 0.;\n- vals.MI_max = 0.;\n- vals.MI_min = 1.;\n+ vals.reset();\nthis->mutinfo_hist.reset();\n}\n@@ -303,14 +299,6 @@ Monitor_MI<B,R>& Monitor_MI<B,R>\nreturn *this;\n}\n-template <typename B, typename R>\n-Monitor_MI<B,R>& Monitor_MI<B,R>\n-::operator+=(const Attributes& v)\n-{\n- collect(v);\n- return *this;\n-}\n-\ntemplate <typename B, typename R>\n@@ -348,26 +336,39 @@ Monitor_MI<B,R>& Monitor_MI<B,R>\nreturn *this;\n}\n-template <typename B, typename R>\n-Monitor_MI<B,R>& Monitor_MI<B,R>\n-::operator=(const Attributes& v)\n-{\n- copy(v);\n- return *this;\n-}\n-\ntemplate <typename B, typename R>\ntypename Monitor_MI<B,R>::Attributes& Monitor_MI<B,R>::Attributes\n::operator+=(const Attributes& v)\n{\nn_trials += v.n_trials;\n+\n+ if (n_trials != 0)\nMI += (v.MI - MI) * ((R)v.n_trials / (R)n_trials);\n+ else\n+ MI = (R)0.;\nMI_max = std::max(MI_max, v.MI_max);\nMI_min = std::min(MI_min, v.MI_min);\nreturn *this;\n}\n+template <typename B, typename R>\n+void Monitor_MI<B,R>::Attributes\n+::reset()\n+{\n+ n_trials = 0;\n+ MI = 0.;\n+ MI_max = 0.;\n+ MI_min = 1.;\n+}\n+\n+template <typename B, typename R>\n+Monitor_MI<B,R>::Attributes\n+::Attributes()\n+{\n+ reset();\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "new_path": "src/Module/Monitor/MI/Monitor_MI.hpp", "diff": "@@ -24,6 +24,8 @@ protected:\nR MI_max; // the maximum obtained MI\nR MI_min; // the minimum obtained MI\n+ Attributes();\n+ void reset();\nAttributes& operator+=(const Attributes&);\n};\n@@ -111,16 +113,13 @@ public:\nvirtual void collect(const Attributes& v);\nMonitor_MI<B,R>& operator+=(const Monitor_MI<B,R>& m); // \"collect\" call with fully = false\n- Monitor_MI<B,R>& operator+=(const Attributes& v); // \"collect\" call\nvirtual void copy(const Monitor& m, bool fully = false);\nvirtual void copy(const Monitor_MI<B,R>& m, bool fully = false);\nvirtual void copy(const Attributes& v);\n-\nMonitor_MI<B,R>& operator=(const Monitor_MI<B,R>& m); // \"copy\" call with fully = false\n- Monitor_MI<B,R>& operator=(const Attributes& v); // \"copy\" call\nprotected:\n" } ]
C++
MIT License
aff3ct/aff3ct
Add constructors and reset method in Monitors' Attributes to init them correctly.
8,483
03.08.2018 15:02:57
-7,200
9acf33eefff3e3c0dd74b7ff2de81dbd79b60573
Fix Monitor BFER frame_limit_achieved computation
[ { "change_type": "MODIFY", "old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp", "diff": "@@ -165,7 +165,7 @@ template <typename B>\nbool Monitor_BFER<B>\n::frame_limit_achieved() const\n{\n- return get_max_n_frames() != 0 && get_n_frames() >= (int)get_max_n_frames();\n+ return get_max_n_frames() != 0 && get_n_analyzed_fra() >= (int)get_max_n_frames();\n}\ntemplate <typename B>\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix Monitor BFER frame_limit_achieved computation
8,483
03.08.2018 15:30:38
-7,200
f627edd82767acc7c2ef503ee6f6a59ef2d3fe91
Remove handling SIGUSR1/2 on windows
[ { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.hpp", "new_path": "src/Simulation/BFER/BFER.hpp", "diff": "@@ -112,7 +112,6 @@ protected:\nvoid build_monitors ();\nvirtual bool keep_looping_noise_point();\n- bool max_frame_reached();\nbool stop_time_reached();\nprivate:\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Display/Terminal/Terminal.cpp", "new_path": "src/Tools/Display/Terminal/Terminal.cpp", "diff": "@@ -27,8 +27,10 @@ Terminal\nTerminal::interrupt = false;\n// Install a signal handler\n+#if !defined(_WIN64) && !defined(_WIN32)\nstd::signal(SIGUSR1, Terminal::signal_interrupt_handler);\nstd::signal(SIGUSR2, Terminal::signal_interrupt_handler);\n+#endif\nstd::signal(SIGINT, Terminal::signal_interrupt_handler);\nstd::signal(SIGTERM, Terminal::signal_interrupt_handler);\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Remove handling SIGUSR1/2 on windows
8,483
03.08.2018 16:51:14
-7,200
7954689e70e8533df9ab72d748df34ec0803002e
Fix the remove handling SIGUSR1/2 on windows
[ { "change_type": "MODIFY", "old_path": "src/Tools/Display/Terminal/Terminal.cpp", "new_path": "src/Tools/Display/Terminal/Terminal.cpp", "diff": "@@ -137,7 +137,11 @@ void Terminal\n{\nbool kill = false;\n+#if !defined(_WIN64) && !defined(_WIN32)\n+ if (signal == SIGINT)\n+#else\nif (signal == SIGUSR1 || signal == SIGINT)\n+#endif\n{\nTerminal::interrupt_cnt++;\n@@ -158,10 +162,12 @@ void Terminal\nTerminal::first_interrupt = false;\nTerminal::interrupt = true;\n}\n+#if !defined(_WIN64) && !defined(_WIN32)\nelse if (signal == SIGUSR2)\n{\nTerminal::stop();\n}\n+#endif\nelse if (signal == SIGTERM)\n{\nkill = true;\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the remove handling SIGUSR1/2 on windows
8,483
03.08.2018 16:54:43
-7,200
cda367bf1dff3952ec628b8a48926c39540efd2b
Add by default 'ci=on' in metadata
[ { "change_type": "MODIFY", "old_path": "src/Launcher/Launcher.cpp", "new_path": "src/Launcher/Launcher.cpp", "diff": "@@ -169,6 +169,7 @@ int Launcher::launch()\nstream << \"[metadata]\" << std::endl;\nstream << \"command=\" << cmd << std::endl;\nstream << \"title=\" << this->params_common.meta << std::endl;\n+ stream << \"ci=on\" << std::endl;\nstream << std::endl << \"[trace]\" << std::endl;\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Add by default 'ci=on' in metadata
8,490
06.08.2018 10:12:30
-7,200
e055d8cd414ddc719e3ec1a64363c6cc1c11af58
Rm ci option in meta.
[ { "change_type": "MODIFY", "old_path": "src/Launcher/Launcher.cpp", "new_path": "src/Launcher/Launcher.cpp", "diff": "@@ -169,7 +169,6 @@ int Launcher::launch()\nstream << \"[metadata]\" << std::endl;\nstream << \"command=\" << cmd << std::endl;\nstream << \"title=\" << this->params_common.meta << std::endl;\n- stream << \"ci=on\" << std::endl;\nstream << std::endl << \"[trace]\" << std::endl;\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Rm ci option in meta.
8,490
06.08.2018 10:12:57
-7,200
3a48bfcf1eeec4202e3549f694c734b9849b1277
Disable the code coverage for untested refs.
[ { "change_type": "MODIFY", "old_path": "ci/test-build-coverage-regression.sh", "new_path": "ci/test-build-coverage-regression.sh", "diff": "@@ -29,10 +29,15 @@ function gen_coverage_info\ndo [ -f $path ] && {\ncmd=$(awk -F \"=\" '/command/ {print $2}' $path)\necho $cmd\n+ ci=$(awk -F \"=\" '/ci/ {print $2}' $path)\n+ if [ \"$ci\" != \"off\" ]; then\ncd $build\neval \"${cmd} --sim-stop-time 1 -t 1\"\nrc=$?; if [[ $rc != 0 ]]; then exit $rc; fi\ncd ..\n+ else\n+ echo \"The code coverage is skipped because this test is disabled in the CI.\"\n+ fi\n} || {\n[ -d $path ] && {\ngen_coverage_info $build $path\n" } ]
C++
MIT License
aff3ct/aff3ct
Disable the code coverage for untested refs.
8,483
06.08.2018 14:08:09
-7,200
ef1c0dcfffcbea5d23531d6bba5608d722cb956d
Update test regression to use the aff3ct's refs reader python script.
[ { "change_type": "MODIFY", "old_path": "refs", "new_path": "refs", "diff": "-Subproject commit e907b57acb49631795d405e99483279581e1254a\n+Subproject commit 517da7579a7c632f5f2581619dc5cccfc1e4c423\n" } ]
C++
MIT License
aff3ct/aff3ct
Update test regression to use the aff3ct's refs reader python script.
8,483
06.08.2018 15:59:04
-7,200
ff6f8018e535b6df233b9763848898dc48fb341a
Manage correctly the remove of sim-meta to work whatever the compiler
[ { "change_type": "MODIFY", "old_path": "src/Launcher/Launcher.cpp", "new_path": "src/Launcher/Launcher.cpp", "diff": "@@ -130,6 +130,20 @@ void Launcher::print_header()\nthis->stream << rang::tag::comment << std::endl;\n}\n+std::string remove_sim_meta(const std::string& cmd)\n+{\n+ const std::string simmeta = \" --sim-meta \";\n+ auto pos_arg = cmd.find(simmeta);\n+\n+ if (pos_arg == std::string::npos)\n+ return cmd;\n+\n+ auto pos_start = cmd.find(\"\\\"\", pos_arg + simmeta.size());\n+ auto pos_end = cmd.find(\"\\\"\", pos_start + 1);\n+\n+ return cmd.substr(0, pos_arg) + cmd.substr(pos_end + 1);\n+}\n+\nint Launcher::launch()\n{\nint exit_code = EXIT_SUCCESS;\n@@ -160,14 +174,8 @@ int Launcher::launch()\n#endif\nif (!this->params_common.meta.empty())\n{\n-// trick to compile on the GNU compiler version 4 (where 'std::regex' is unavailable)\n-#if !defined(__clang__) && !defined(__llvm__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC__ < 5\n- const auto cmd = cmd_line;\n-#else\n- const auto cmd = std::regex_replace(cmd_line, std::regex(\"( --sim-meta \\\"[^\\\"]*\\\")\"), \"\");\n-#endif\nstream << \"[metadata]\" << std::endl;\n- stream << \"command=\" << cmd << std::endl;\n+ stream << \"command=\" << remove_sim_meta(cmd_line) << std::endl;\nstream << \"title=\" << this->params_common.meta << std::endl;\nstream << std::endl << \"[trace]\" << std::endl;\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Manage correctly the remove of sim-meta to work whatever the compiler
8,483
06.08.2018 16:26:51
-7,200
d61222740c41d9656ff145fd5e969651f59931a2
Fix the stop criteria condition to stop simu
[ { "change_type": "MODIFY", "old_path": "refs", "new_path": "refs", "diff": "-Subproject commit e907b57acb49631795d405e99483279581e1254a\n+Subproject commit e838d9b1679dcc2868a501b8a58a762b34a8a544\n" }, { "change_type": "MODIFY", "old_path": "src/Simulation/BFER/BFER.cpp", "new_path": "src/Simulation/BFER/BFER.cpp", "diff": "@@ -214,16 +214,15 @@ void BFER<B,R,Q>\nthis->t_start_noise_point = std::chrono::steady_clock::now();\n- bool monitor_criteria;\ntry\n{\nthis->_launch();\n- monitor_criteria = module::Monitor_reduction::is_done_all(true, true); // final reduction\n+ module::Monitor_reduction::is_done_all(true, true); // final reduction\n}\ncatch (std::exception const& e)\n{\ntools::Terminal::stop();\n- monitor_criteria = module::Monitor_reduction::is_done_all(true, true); // final reduction\n+ module::Monitor_reduction::is_done_all(true, true); // final reduction\nterminal->final_report(std::cout); // display final report to not lost last line overwritten by the error messages\n@@ -232,9 +231,9 @@ void BFER<B,R,Q>\n}\n- if (!params_BFER.crit_nostop && !params_BFER.err_track_revert &&\n- !tools::Terminal::is_interrupt() && !monitor_criteria &&\n- (params_BFER.max_frame == 0 || this->monitor_er_red->get_n_analyzed_fra() >= params_BFER.max_frame))\n+ if (!params_BFER.crit_nostop && !params_BFER.err_track_revert && !tools::Terminal::is_interrupt() &&\n+ !this->monitor_er_red->fe_limit_achieved() &&\n+ (this->monitor_er_red->frame_limit_achieved() || this->stop_time_reached()))\ntools::Terminal::stop();\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the stop criteria condition to stop simu
8,483
07.08.2018 09:33:58
-7,200
f39f673d90928b2f52af279c8da18b896eb60c13
Fix the check that $path is a python script
[ { "change_type": "MODIFY", "old_path": "ci/test-build-coverage-regression.sh", "new_path": "ci/test-build-coverage-regression.sh", "diff": "@@ -27,7 +27,7 @@ function gen_coverage_info\nlocal folder=$2\nfor path in $folder/*\ndo [ -f $path ] && {\n- if [ ${file: -3} == \".py\" ]; then\n+ if [ ${path: -3} == \".py\" ]; then\ncontinue\nfi\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the check that $path is a python script
8,483
07.08.2018 10:20:20
-7,200
84f5b9d5c9b205dfbfba9c2febc8eb44d92c9e19
Add sim no colors argument when test regression are made with MPI and set hostfile with absolute path
[ { "change_type": "MODIFY", "old_path": "ci/test-regression.py", "new_path": "ci/test-regression.py", "diff": "@@ -494,15 +494,16 @@ else:\nargsAFFECTcommand = []\n-\n+activateMPI = False\nif args.mpinp > 0 or args.mpihost != \"\":\n+ activateMPI = True\nargsAFFECTcommand += [\"mpirun\", \"--map-by\", \"socket\"]\nif args.mpinp > 0:\nargsAFFECTcommand += [\"-np\", str(args.mpinp)]\nif args.mpihost != \"\":\n- argsAFFECTcommand += [\"--hostfile\", str(args.mpihost)]\n+ argsAFFECTcommand += [\"--hostfile\", str(os.path.abspath(args.mpihost))]\nfailIds = []\n@@ -551,6 +552,9 @@ for fn in fileNames:\nif args.maxSNRTime:\nargsAFFECT += [\"--sim-stop-time\", str(args.maxSNRTime)]\n+ if activateMPI:\n+ argsAFFECT += [\"--sim-no-colors\"]\n+\nnoiseVals = \"\"\nfor n in range(len(simuRef.Noise)):\n@@ -640,7 +644,6 @@ for fn in fileNames:\nfRes.flush()\n- # validate (or not) the BER/FER/MI performance\nprint(\" - %.2f\" %elapsedTime, \"sec\", end=\"\")\npassRate = comp.passRate()\n" } ]
C++
MIT License
aff3ct/aff3ct
Add sim no colors argument when test regression are made with MPI and set hostfile with absolute path
8,483
08.08.2018 15:21:25
-7,200
fce9649d18da34f1bfb2ed318dbe971640b1a97f
Cosmetics and implement a correct modulo on mipp registers
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "new_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "diff": "@@ -76,6 +76,12 @@ void write_array(std::vector<mipp::Reg<B>,A>& array, const mipp::Reg<B>& r_idx,\n}\n}\n+template <typename B>\n+mipp::Reg<B> operator%(const mipp::Reg<B>& r, int mod)\n+{\n+ return r & (B)mod; // works only with mod == 2^n -1\n+}\n+\ntemplate <typename B, typename R>\nvoid Decoder_BCH_fast<B, R>\n::_decode(B *Y_N, const int frame_id)\n@@ -92,10 +98,11 @@ void Decoder_BCH_fast<B, R>\nconst auto r_zero = mipp::Reg<B>((B)0);\nconst auto r_one = mipp::Reg<B>((B)1);\n+ const auto r_mone = mipp::Reg<B>((B)-1);\nfor (auto i = 1; i <= t2; i++)\n{\n- s[i] = (B)0;\n+ s[i] = r_zero;\nfor (auto j = 0; j < this->N; j++)\n{\nconst mipp::Reg<B> r_alpha = alpha_to[(i * j) % this->N_p2];\n@@ -110,19 +117,19 @@ void Decoder_BCH_fast<B, R>\nif (!mipp::testz(syn_error))\n{\n// initialise table entries\n- discrepancy[0] = (B)0; // index form\n+ discrepancy[0] = r_zero; // index form\ndiscrepancy[1] = s[1]; // index form\n- elp[0][0] = (B)0; // index form\n- elp[1][0] = (B)1; // polynomial form\n+ elp[0][0] = r_zero; // index form\n+ elp[1][0] = r_one; // polynomial form\nfor (auto i = 1; i < t2; i++)\n{\n- elp[0][i] = (B)-1; // index form\n- elp[1][i] = (B)0; // polynomial form\n+ elp[0][i] = r_mone; // index form\n+ elp[1][i] = r_zero; // polynomial form\n}\n- l[0] = (B)0;\n- l[1] = (B)0;\n- u_lu[0] = (B)-1;\n- u_lu[1] = (B)0;\n+ l[0] = r_zero;\n+ l[1] = r_zero;\n+ u_lu[0] = r_mone;\n+ u_lu[1] = r_zero;\nauto u = 0;\nauto m_process = syn_error;\n@@ -132,8 +139,8 @@ void Decoder_BCH_fast<B, R>\nu++;\nmipp::Reg<B> r_u = (B)u;\n- const auto m_disc = (discrepancy[u] == (B)-1) & m_process;\n- const auto m_not_disc = (discrepancy[u] != (B)-1) & m_process;\n+ const auto m_disc = (discrepancy[u] == r_mone) & m_process;\n+ const auto m_not_disc = (discrepancy[u] != r_mone) & m_process;\n//***** part if (discrepancy[u] == -1)\nif (!mipp::testz(m_disc))\n@@ -161,7 +168,7 @@ void Decoder_BCH_fast<B, R>\nfor (auto q = u_1 - 1; q >= 0; q--)\n{\n- auto m_ok = m_not_disc & (discrepancy[q] != (B)-1) & (r_u_lu_q > u_lu[q]);\n+ auto m_ok = m_not_disc & (discrepancy[q] != r_mone) & (r_u_lu_q > u_lu[q]);\nr_q = mipp::blend(mipp::Reg<B>(q), r_q, m_ok);\nr_disc_q = mipp::blend( discrepancy[q], r_disc_q, m_ok);\n@@ -181,23 +188,23 @@ void Decoder_BCH_fast<B, R>\nfor (auto i = 0; i < t2; i++)\nelp[u + 1][i] = mipp::blend(r_zero, elp[u + 1][i], m_not_disc);\n- auto l_max = mipp::hmax(r_l_q);\n+ auto l_max = mipp::hmax(mipp::blend(r_l_q, r_zero, m_not_disc));\nfor (auto i = 0; i <= l_max; i++)\n{\n- auto m_ok = m_not_disc & (r_elp_q[i] != (B)-1) & (r_l_q >= i);\n+ auto m_ok = m_not_disc & (r_elp_q[i] != r_mone) & (r_l_q >= i);\nif (mipp::testz(m_ok))\ncontinue;\n- auto r_aplha_idx = r_elp_q[i] - r_disc_q + discrepancy[u] + this->N_p2;\n- r_aplha_idx = mipp::blend(r_aplha_idx, r_aplha_idx - this->N_p2, r_aplha_idx < this->N_p2);\n+ auto r_alpha_idx = r_elp_q[i] - r_disc_q + discrepancy[u] + this->N_p2;\n+ r_alpha_idx = r_alpha_idx % this->N_p2;\nauto r_idx = mipp::Reg<B>(i) + r_u - r_q;\n- write_array(elp[u + 1], r_idx, m_ok, read_array(alpha_to, r_aplha_idx));\n+ write_array(elp[u + 1], r_idx, m_ok, read_array(alpha_to, r_alpha_idx));\n}\n- l_max = mipp::hmax(l[u]);\n+ l_max = mipp::hmax(mipp::blend(l[u], r_zero, m_not_disc));\nfor (auto i = 0; i <= l_max; i++)\n{\nauto m_ok = m_not_disc & (l[u] >= i);\n@@ -222,15 +229,15 @@ void Decoder_BCH_fast<B, R>\nauto l_max = mipp::hmax(l[u+1]);\nfor (auto i = 0; i <= l_max; i++)\n{\n- auto m_ok = m_process & (s[u + 1 - i] != (B)-1) & (elp[u + 1][i] != (B)0) & (l[u+1] >= i);\n+ auto m_ok = m_process & (s[u + 1 - i] != r_mone) & (elp[u + 1][i] != r_zero) & (l[u + 1] >= i);\nif (mipp::testz(m_ok))\ncontinue;\n- auto r_aplha_idx = s[u + 1 - i] + read_array(index_of, elp[u + 1][i]);\n- r_aplha_idx = mipp::blend(r_aplha_idx, r_aplha_idx - this->N_p2, r_aplha_idx < this->N_p2);\n+ auto r_alpha_idx = s[u + 1 - i] + read_array(index_of, elp[u + 1][i]);\n+ r_alpha_idx = r_alpha_idx % this->N_p2;\n- auto r_alpha = read_array(alpha_to, r_aplha_idx);\n+ auto r_alpha = read_array(alpha_to, r_alpha_idx);\nauto r_disc = discrepancy[u + 1] ^ r_alpha;\ndiscrepancy[u + 1] = mipp::blend(r_disc, discrepancy[u + 1], m_ok);\n@@ -256,7 +263,7 @@ void Decoder_BCH_fast<B, R>\n{\nauto r_idx = mipp::blend(elp[u][i], r_zero, l[u] >= i);\nr_idx = read_array(index_of, elp[u][i]) + i; // min 0 even if index_of == -1\n- r_idx = mipp::blend(r_idx, r_idx - this->N_p2, r_idx < this->N_p2);\n+ r_idx = r_idx % this->N_p2;\nreg[i] = read_array(alpha_to, r_idx);\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Cosmetics and implement a correct modulo on mipp registers
8,483
08.08.2018 16:18:48
-7,200
30c52509179aa85625f2c075973d047a94aa5065
Cosmetics in BCH fast and fix RS galois call
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "new_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "diff": "@@ -18,10 +18,10 @@ Decoder_BCH_fast<B, R>\nDecoder_BCH<B,R>(K, N, GF_poly.get_t(), n_frames ),\nt2 (2 * this->t ),\nY_N_reorderered (this->N ),\n- elp (this->N_p2+2, mipp::vector<mipp::Reg<B>>(this->N_p2)),\n- discrepancy (this->N_p2+2 ),\n- l (this->N_p2+2 ),\n- u_lu (this->N_p2+2 ),\n+ elp (this->N_p2_1+2, mipp::vector<mipp::Reg<B>>(this->N_p2_1)),\n+ discrepancy (this->N_p2_1+2 ),\n+ l (this->N_p2_1+2 ),\n+ u_lu (this->N_p2_1+2 ),\ns (t2+1 ),\nreg (this->t +1 ),\nm (GF_poly.get_m() ),\n@@ -40,11 +40,11 @@ Decoder_BCH_fast<B, R>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (this->N_p2 >= std::numeric_limits<B>::max() && std::is_unsigned<B>::value)\n+ if (this->N_p2_1 >= std::numeric_limits<B>::max() && std::is_unsigned<B>::value)\n{\nstd::stringstream message;\n- message << \"'N_p2' must be less than 'std::numeric_limits<B>::max()' and 'B' must be signed ('N_p2' = \"\n- << this->N_p2 << \", 'std::numeric_limits<B>::max()' = \" << std::numeric_limits<B>::max() << \").\";\n+ message << \"'N_p2_1' must be less than 'std::numeric_limits<B>::max()' and 'B' must be signed ('N_p2_1' = \"\n+ << this->N_p2_1 << \", 'std::numeric_limits<B>::max()' = \" << std::numeric_limits<B>::max() << \").\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n}\n@@ -86,26 +86,26 @@ template <typename B, typename R>\nvoid Decoder_BCH_fast<B, R>\n::_decode(B *Y_N, const int frame_id)\n{\n+ const auto r_zero = mipp::Reg<B>((B)0);\n+ const auto r_one = mipp::Reg<B>((B)1);\n+ const auto r_mone = mipp::Reg<B>((B)-1);\n+\n+\n// reorder data into mipp registers\nstd::vector<const B*> frames(mipp::N<B>());\nfor (auto f = 0; f < mipp::N<B>(); f++) frames[f] = Y_N + f * this->N;\ntools::Reorderer_static<B,mipp::N<B>()>::apply(frames, (B*)this->Y_N_reorderered.data(), this->N);\n-\n// form the syndromes\n- mipp::Msk<mipp::N<B>()> syn_error;\n- syn_error.set1(false);\n+ auto syn_error = r_zero != r_zero; // init to false\n- const auto r_zero = mipp::Reg<B>((B)0);\n- const auto r_one = mipp::Reg<B>((B)1);\n- const auto r_mone = mipp::Reg<B>((B)-1);\n+ std::fill(s.begin(), s.end(), r_zero);\nfor (auto i = 1; i <= t2; i++)\n{\n- s[i] = r_zero;\nfor (auto j = 0; j < this->N; j++)\n{\n- const mipp::Reg<B> r_alpha = alpha_to[(i * j) % this->N_p2];\n+ const mipp::Reg<B> r_alpha = alpha_to[(i * j) % this->N_p2_1];\ns[i] ^= mipp::blend(r_alpha, r_zero, Y_N_reorderered[j] != r_zero);\n}\n@@ -138,6 +138,8 @@ void Decoder_BCH_fast<B, R>\n{\nu++;\nmipp::Reg<B> r_u = (B)u;\n+ const auto u_m1 = u - 1;\n+ const auto u_p1 = u + 1;\nconst auto m_disc = (discrepancy[u] == r_mone) & m_process;\nconst auto m_not_disc = (discrepancy[u] != r_mone) & m_process;\n@@ -145,13 +147,13 @@ void Decoder_BCH_fast<B, R>\n//***** part if (discrepancy[u] == -1)\nif (!mipp::testz(m_disc))\n{\n- l[u+1] = mipp::blend(l[u], l[u+1], m_disc);\n+ l[u_p1] = mipp::blend(l[u], l[u_p1], m_disc);\nB i = 0;\nauto m_lu = (l[u] >= i) & m_disc;\nwhile(!mipp::testz(m_lu))\n{\n- elp[u + 1][i] = mipp::blend(elp[u][i], elp[u + 1][i], m_lu);\n- elp[u + 0][i] = mipp::blend(read_array(index_of, elp[u][i]), elp[u][i], m_lu);\n+ elp[u_p1][i] = mipp::blend(elp[u][i], elp[u_p1][i], m_lu);\n+ elp[u ][i] = mipp::blend(read_array(index_of, elp[u][i] % this->N_p2_1), elp[u][i], m_lu);\ni++;\nm_lu = (l[u] >= i) & m_disc;\n@@ -162,11 +164,10 @@ void Decoder_BCH_fast<B, R>\nif (!mipp::testz(m_not_disc))\n{\n// search for words with greatest u_lu[q] for which d[q] != -1\n- const auto u_1 = u - 1;\n- mipp::Reg<B> r_disc_q, r_l_q = l[u_1], r_u_lu_q = u_lu[u_1], r_q = u_1;\n- mipp::vector<mipp::Reg<B>> r_elp_q = elp[u_1];\n+ mipp::Reg<B> r_disc_q, r_l_q = l[u_m1], r_u_lu_q = u_lu[u_m1], r_q = u_m1;\n+ mipp::vector<mipp::Reg<B>> r_elp_q = elp[u_m1];\n- for (auto q = u_1 - 1; q >= 0; q--)\n+ for (auto q = u_m1 - 1; q >= 0; q--)\n{\nauto m_ok = m_not_disc & (discrepancy[q] != r_mone) & (r_u_lu_q > u_lu[q]);\n@@ -182,11 +183,11 @@ void Decoder_BCH_fast<B, R>\n// store degree of new elp polynomial\nauto l_u_q = r_l_q + r_u - r_q;\nl_u_q = mipp::blend(l_u_q, l[u ], l[u] <= l_u_q);\n- l[u + 1] = mipp::blend(l_u_q, l[u + 1], m_not_disc);\n+ l[u_p1] = mipp::blend(l_u_q, l[u_p1], m_not_disc);\n// form new elp(x)\nfor (auto i = 0; i < t2; i++)\n- elp[u + 1][i] = mipp::blend(r_zero, elp[u + 1][i], m_not_disc);\n+ elp[u_p1][i] = mipp::blend(r_zero, elp[u_p1][i], m_not_disc);\nauto l_max = mipp::hmax(mipp::blend(r_l_q, r_zero, m_not_disc));\nfor (auto i = 0; i <= l_max; i++)\n@@ -196,58 +197,52 @@ void Decoder_BCH_fast<B, R>\nif (mipp::testz(m_ok))\ncontinue;\n- auto r_alpha_idx = r_elp_q[i] - r_disc_q + discrepancy[u] + this->N_p2;\n- r_alpha_idx = r_alpha_idx % this->N_p2;\n-\n- auto r_idx = mipp::Reg<B>(i) + r_u - r_q;\n-\n- write_array(elp[u + 1], r_idx, m_ok, read_array(alpha_to, r_alpha_idx));\n+ const auto r_alpha_idx = (r_elp_q[i] - r_disc_q + discrepancy[u] + this->N_p2_1) % this->N_p2_1;\n+ const auto r_idx = mipp::Reg<B>(i) + r_u - r_q;\n+ write_array(elp[u_p1], r_idx, m_ok, read_array(alpha_to, r_alpha_idx));\n}\nl_max = mipp::hmax(mipp::blend(l[u], r_zero, m_not_disc));\nfor (auto i = 0; i <= l_max; i++)\n{\nauto m_ok = m_not_disc & (l[u] >= i);\n- elp[u + 1][i] = mipp::blend(elp[u][i] ^ elp[u + 1][i], elp[u + 1][i], m_ok);\n- elp[u][i] = read_array(index_of, elp[u][i]);\n+ elp[u_p1][i] = mipp::blend(elp[u][i] ^ elp[u_p1][i], elp[u_p1][i], m_ok);\n+ elp[u ][i] = read_array(index_of, elp[u][i] % this->N_p2_1);\n}\n}\n- u_lu[u + 1] = r_u - l[u + 1];\n+ u_lu[u_p1] = r_u - l[u_p1];\n- // form (u+1)th discrepancy\n+ // form (u_p1)th discrepancy\nif (u < t2)\n{\n// no discrepancy computed on last iteration\n- auto m_s = s[u + 1] != -1;\n- auto r_alpha_idx = mipp::blend(s[u + 1], r_zero, m_s);\n-\n- auto r_read = mipp::blend(read_array(alpha_to, r_alpha_idx), r_zero, m_s);\n- discrepancy[u + 1] = mipp::blend(r_read, discrepancy[u + 1], m_process);\n+ const auto m_s = s[u_p1] != -1;\n+ const auto r_alpha_idx = mipp::blend(s[u_p1], r_zero, m_s) % this->N_p2_1;\n+ const auto r_read = mipp::blend(read_array(alpha_to, r_alpha_idx), r_zero, m_s);\n+ discrepancy[u_p1] = mipp::blend(r_read, discrepancy[u_p1], m_process);\n- auto l_max = mipp::hmax(l[u+1]);\n+ auto l_max = mipp::hmax(l[u_p1]);\nfor (auto i = 0; i <= l_max; i++)\n{\n- auto m_ok = m_process & (s[u + 1 - i] != r_mone) & (elp[u + 1][i] != r_zero) & (l[u + 1] >= i);\n+ auto m_ok = m_process & (s[u_p1 - i] != r_mone) & (elp[u_p1][i] != r_zero) & (l[u_p1] >= i);\nif (mipp::testz(m_ok))\ncontinue;\n- auto r_alpha_idx = s[u + 1 - i] + read_array(index_of, elp[u + 1][i]);\n- r_alpha_idx = r_alpha_idx % this->N_p2;\n-\n- auto r_alpha = read_array(alpha_to, r_alpha_idx);\n- auto r_disc = discrepancy[u + 1] ^ r_alpha;\n+ const auto r_alpha_idx = s[u_p1 - i] + read_array(index_of, elp[u_p1][i] % this->N_p2_1) % this->N_p2_1;\n+ const auto r_alpha = read_array(alpha_to, r_alpha_idx);\n+ const auto r_disc = discrepancy[u_p1] ^ r_alpha;\n- discrepancy[u + 1] = mipp::blend(r_disc, discrepancy[u + 1], m_ok);\n+ discrepancy[u_p1] = mipp::blend(r_disc, discrepancy[u_p1], m_ok);\n}\n- /* put d.at(u+1) into index form */\n- discrepancy[u + 1] = mipp::blend(read_array(index_of, discrepancy[u + 1]), discrepancy[u + 1], m_process);\n+ /* put d.at(u_p1) into index form */\n+ discrepancy[u_p1] = mipp::blend(read_array(index_of, discrepancy[u_p1] % this->N_p2_1), discrepancy[u_p1], m_process);\n}\n- m_process &= l[u + 1] <= this->t;\n+ m_process &= l[u_p1] <= this->t;\n} while (u < t2 && !mipp::testz(m_process));\n@@ -261,14 +256,13 @@ void Decoder_BCH_fast<B, R>\nauto l_max = mipp::hmax(l[u]);\nfor (auto i = 1; i <= l_max; i++)\n{\n- auto r_idx = mipp::blend(elp[u][i], r_zero, l[u] >= i);\n- r_idx = read_array(index_of, elp[u][i]) + i; // min 0 even if index_of == -1\n- r_idx = r_idx % this->N_p2;\n+ auto r_idx = mipp::blend(elp[u][i], r_zero, l[u] >= i) % this->N_p2_1;\n+ r_idx = (read_array(index_of, r_idx) + i) % this->N_p2_1; // min 0 even if index_of == -1\nreg[i] = read_array(alpha_to, r_idx);\n}\nmipp::Reg<B> count = r_zero;\n- for (auto i = 1; i <= this->N_p2; i++)\n+ for (auto i = 1; i <= this->N_p2_1; i++)\n{\nmipp::Reg<B> q = r_one;\nfor (auto j = 1; j <= l_max; j++)\n@@ -277,7 +271,7 @@ void Decoder_BCH_fast<B, R>\nauto m_flip = (q == r_zero) & m_corr;\ncount += mipp::blend(r_one, r_zero, m_flip);\n- auto idx = this->N_p2 - i;\n+ auto idx = this->N_p2_1 - i;\nY_N_reorderered[idx] = mipp::blend(Y_N_reorderered[idx] ^ r_one, Y_N_reorderered[idx], m_flip);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/RS/RS_polynomial_generator.cpp", "new_path": "src/Tools/Code/RS/RS_polynomial_generator.cpp", "diff": "@@ -9,7 +9,7 @@ using namespace aff3ct::tools;\nRS_polynomial_generator\n::RS_polynomial_generator(const int& N, const int& t)\n- : Galois(N), t(t), d(2 * t + 1), g(d, 0)\n+ : Galois<int>(N), t(t), d(2 * t + 1), g(d, 0)\n{\nif (t < 1)\n{\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/RS/RS_polynomial_generator.hpp", "new_path": "src/Tools/Code/RS/RS_polynomial_generator.hpp", "diff": "@@ -11,7 +11,7 @@ namespace aff3ct\n{\nnamespace tools\n{\n-class RS_polynomial_generator : public Galois\n+class RS_polynomial_generator : public Galois<int>\n{\nprotected:\nconst int t;\n" } ]
C++
MIT License
aff3ct/aff3ct
Cosmetics in BCH fast and fix RS galois call
8,483
08.08.2018 16:32:31
-7,200
b931193cfc2924f7e5217a588d56973890026e36
Fix BCH fast index over range
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "new_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "diff": "@@ -231,7 +231,7 @@ void Decoder_BCH_fast<B, R>\nif (mipp::testz(m_ok))\ncontinue;\n- const auto r_alpha_idx = s[u_p1 - i] + read_array(index_of, elp[u_p1][i] % this->N_p2_1) % this->N_p2_1;\n+ const auto r_alpha_idx = (s[u_p1 - i] + read_array(index_of, elp[u_p1][i] % this->N_p2_1)) % this->N_p2_1;\nconst auto r_alpha = read_array(alpha_to, r_alpha_idx);\nconst auto r_disc = discrepancy[u_p1] ^ r_alpha;\n@@ -253,7 +253,7 @@ void Decoder_BCH_fast<B, R>\nif (!mipp::testz(m_corr))\n{\n// Chien search: find roots of the error location polynomial\n- auto l_max = mipp::hmax(l[u]);\n+ auto l_max = mipp::hmax(mipp::blend(l[u], r_zero, m_corr));\nfor (auto i = 1; i <= l_max; i++)\n{\nauto r_idx = mipp::blend(elp[u][i], r_zero, l[u] >= i) % this->N_p2_1;\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix BCH fast index over range
8,483
08.08.2018 17:16:57
-7,200
7754de0c7c4a0e3fa6663a0ea12377c7617ddfa0
Fix the l_max computation and secure array index
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "new_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "diff": "@@ -223,15 +223,16 @@ void Decoder_BCH_fast<B, R>\ndiscrepancy[u_p1] = mipp::blend(r_read, discrepancy[u_p1], m_process);\n- auto l_max = mipp::hmax(l[u_p1]);\n- for (auto i = 0; i <= l_max; i++)\n+ auto l_max = mipp::hmax(mipp::blend(l[u_p1], r_zero, m_not_disc));\n+ for (auto i = 1; i <= l_max; i++)\n{\n- auto m_ok = m_process & (s[u_p1 - i] != r_mone) & (elp[u_p1][i] != r_zero) & (l[u_p1] >= i);\n+ auto u_p1_i = ((u_p1 - i) < 0) ? 0 : (u_p1 - i);\n+ auto m_ok = m_process & (s[u_p1_i] != r_mone) & (elp[u_p1][i] != r_zero) & (l[u_p1] >= i);\nif (mipp::testz(m_ok))\ncontinue;\n- const auto r_alpha_idx = (s[u_p1 - i] + read_array(index_of, elp[u_p1][i] % this->N_p2_1)) % this->N_p2_1;\n+ const auto r_alpha_idx = (s[u_p1_i] + read_array(index_of, elp[u_p1][i] % this->N_p2_1)) % this->N_p2_1;\nconst auto r_alpha = read_array(alpha_to, r_alpha_idx);\nconst auto r_disc = discrepancy[u_p1] ^ r_alpha;\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the l_max computation and secure array index
8,483
08.08.2018 18:09:22
-7,200
ec3e085aaffac87602b0244d03962af4f4d09e4d
Set _decode_siho/hiho/cw in each different implem of BCH and not anymore only in the mother class
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Decoder_BCH.cpp", "new_path": "src/Module/Decoder/BCH/Decoder_BCH.cpp", "diff": "@@ -15,7 +15,7 @@ Decoder_BCH<B, R>\n::Decoder_BCH(const int K, const int N, const int t, const int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_SIHO_HIHO<B,R>(K, N, n_frames, 1),\n- t(t), N_p2_1(tools::next_power_of_2(N) -1), YH_N(N), last_is_codeword(n_frames)\n+ t(t), N_p2_1(tools::next_power_of_2(N) -1), last_is_codeword(n_frames)\n{\nconst std::string name = \"Decoder_BCH\";\nthis->set_name(name);\n@@ -40,91 +40,6 @@ bool Decoder_BCH<B, R>\n{\nreturn last_is_codeword[frame_id < 0 ? 0 : frame_id];\n}\n-\n-template <typename B, typename R>\n-void Decoder_BCH<B, R>\n-::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n-{\n-// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n- std::copy(Y_N, Y_N + this->N, YH_N.begin());\n-// auto d_load = std::chrono::steady_clock::now() - t_load;\n-\n-// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n- this->_decode(YH_N.data(), frame_id);\n-// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n-\n-// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n- std::copy(YH_N.data() + this->N - this->K, YH_N.data() + this->N, V_K);\n-// auto d_store = std::chrono::steady_clock::now() - t_store;\n-\n-// (*this)[dec::tsk::decode_hiho].update_timer(dec::tm::decode_hiho::load, d_load);\n-// (*this)[dec::tsk::decode_hiho].update_timer(dec::tm::decode_hiho::decode, d_decod);\n-// (*this)[dec::tsk::decode_hiho].update_timer(dec::tm::decode_hiho::store, d_store);\n-}\n-\n-template <typename B, typename R>\n-void Decoder_BCH<B, R>\n-::_decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id)\n-{\n-// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n- std::copy(Y_N, Y_N + this->N, YH_N.begin());\n-// auto d_load = std::chrono::steady_clock::now() - t_load;\n-\n-// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n- this->_decode(YH_N.data(), frame_id);\n-// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n-\n-// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n- std::copy(YH_N.data(), YH_N.data() + this->N, V_N);\n-// auto d_store = std::chrono::steady_clock::now() - t_store;\n-\n-// (*this)[dec::tsk::decode_hiho_cw].update_timer(dec::tm::decode_hiho_cw::load, d_load);\n-// (*this)[dec::tsk::decode_hiho_cw].update_timer(dec::tm::decode_hiho_cw::decode, d_decod);\n-// (*this)[dec::tsk::decode_hiho_cw].update_timer(dec::tm::decode_hiho_cw::store, d_store);\n-}\n-\n-template <typename B, typename R>\n-void Decoder_BCH<B, R>\n-::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n-{\n-// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n- tools::hard_decide(Y_N, YH_N.data(), this->N);\n-// auto d_load = std::chrono::steady_clock::now() - t_load;\n-\n-// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n- this->_decode(YH_N.data(), frame_id);\n-// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n-\n-// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n- std::copy(YH_N.data() + this->N - this->K, YH_N.data() + this->N, V_K);\n-// auto d_store = std::chrono::steady_clock::now() - t_store;\n-\n-// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::load, d_load);\n-// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::decode, d_decod);\n-// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::store, d_store);\n-}\n-\n-template <typename B, typename R>\n-void Decoder_BCH<B, R>\n-::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n-{\n-// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n- tools::hard_decide(Y_N, YH_N.data(), this->N);\n-// auto d_load = std::chrono::steady_clock::now() - t_load;\n-\n-// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n- this->_decode(YH_N.data(), frame_id);\n-// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n-\n-// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n- std::copy(YH_N.data(), YH_N.data() + this->N, V_N);\n-// auto d_store = std::chrono::steady_clock::now() - t_store;\n-\n-// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::load, d_load);\n-// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::decode, d_decod);\n-// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::store, d_store);\n-}\n-\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Decoder_BCH.hpp", "new_path": "src/Module/Decoder/BCH/Decoder_BCH.hpp", "diff": "@@ -17,7 +17,6 @@ class Decoder_BCH : public Decoder_SIHO_HIHO<B,R>\nprotected:\nconst int t; // correction power\nconst int N_p2_1; // the next power 2 of N minus 1\n- std::vector<B> YH_N; // hard decision input vector\nstd::vector<B> last_is_codeword; // a value per frame\npublic:\n@@ -26,13 +25,6 @@ public:\nvirtual ~Decoder_BCH();\nbool get_last_is_codeword(const int frame_id = -1) const;\n-\n-protected:\n- virtual void _decode ( B *Y_N, const int frame_id) = 0;\n- virtual void _decode_hiho (const B *Y_N, B *V_K, const int frame_id);\n- virtual void _decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id);\n- virtual void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n- virtual void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "new_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "diff": "#include <numeric>\n#include <type_traits>\n+#include \"Tools/Perf/common/hard_decide.h\"\n#include \"Tools/Perf/Reorderer/Reorderer.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n@@ -16,6 +17,7 @@ Decoder_BCH_fast<B, R>\n::Decoder_BCH_fast(const int& K, const int& N, const tools::BCH_polynomial_generator<B> &GF_poly, const int n_frames)\n: Decoder (K, N, n_frames, mipp::N<B>() ),\nDecoder_BCH<B,R>(K, N, GF_poly.get_t(), n_frames ),\n+ YH_N (this->N * mipp::N<B>() ),\nt2 (2 * this->t ),\nY_N_reorderered (this->N ),\nelp (this->N_p2_1+2, mipp::vector<mipp::Reg<B>>(this->N_p2_1)),\n@@ -84,18 +86,13 @@ mipp::Reg<B> operator%(const mipp::Reg<B>& r, int mod)\ntemplate <typename B, typename R>\nvoid Decoder_BCH_fast<B,R>\n-::_decode(B *Y_N, const int frame_id)\n+::_decode(const int frame_id)\n{\nconst auto r_zero = mipp::Reg<B>((B)0);\nconst auto r_one = mipp::Reg<B>((B)1);\nconst auto r_mone = mipp::Reg<B>((B)-1);\n- // reorder data into mipp registers\n- std::vector<const B*> frames(mipp::N<B>());\n- for (auto f = 0; f < mipp::N<B>(); f++) frames[f] = Y_N + f * this->N;\n- tools::Reorderer_static<B,mipp::N<B>()>::apply(frames, (B*)this->Y_N_reorderered.data(), this->N);\n-\n// form the syndromes\nauto syn_error = r_zero != r_zero; // init to false\n@@ -281,14 +278,68 @@ void Decoder_BCH_fast<B, R>\n}\nmipp::toReg<B>(~syn_error).store(this->last_is_codeword.data() + frame_id);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_fast<B,R>\n+::_load(const B *Y_N, const int frame_id)\n+{\n+ // reorder data into mipp registers\n+ std::vector<const B*> frames(mipp::N<B>());\n+ for (auto f = 0; f < mipp::N<B>(); f++)\n+ frames[f] = Y_N + f * this->N;\n+\n+ tools::Reorderer_static<B,mipp::N<B>()>::apply(frames, (B*)this->Y_N_reorderered.data(), this->N);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_fast<B,R>\n+::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n+{\n+ _load(Y_N, frame_id);\n+ this->_decode(frame_id);\n// reorder data into standard registers\nstd::vector<B*> frames_rev(mipp::N<B>());\n- for (auto f = 0; f < mipp::N<B>(); f++) frames_rev[f] = Y_N + f * this->N;\n+ for (auto f = 0; f < mipp::N<B>(); f++)\n+ frames_rev[f] = V_K + f * this->K;\n+ tools::Reorderer_static<B,mipp::N<B>()>::apply_rev((B*)(this->Y_N_reorderered.data() + this->N - this->K), frames_rev, this->K);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_fast<B,R>\n+::_decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id)\n+{\n+ _load(Y_N, frame_id);\n+\n+ this->_decode(frame_id);\n+\n+ // reorder data into standard registers\n+ std::vector<B*> frames_rev(mipp::N<B>());\n+ for (auto f = 0; f < mipp::N<B>(); f++)\n+ frames_rev[f] = V_N + f * this->N;\ntools::Reorderer_static<B,mipp::N<B>()>::apply_rev((B*)this->Y_N_reorderered.data(), frames_rev, this->N);\n}\n+template <typename B, typename R>\n+void Decoder_BCH_fast<B,R>\n+::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n+{\n+ tools::hard_decide(Y_N, this->YH_N.data(), this->N * mipp::N<B>());\n+\n+ this->_decode_hiho(this->YH_N.data(), V_K, frame_id);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_fast<B,R>\n+::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n+{\n+ tools::hard_decide(Y_N, this->YH_N.data(), this->N * mipp::N<B>());\n+\n+ this->_decode_hiho_cw(this->YH_N.data(), V_N, frame_id);\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.hpp", "new_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.hpp", "diff": "@@ -19,6 +19,7 @@ private :\nconst int t2;\nprotected:\n+ std::vector<B> YH_N; // hard decision input vector\nmipp::vector<mipp::Reg<B>> Y_N_reorderered;\nstd::vector<mipp::vector<mipp::Reg<B>>> elp;\nmipp::vector<mipp::Reg<B>> discrepancy;\n@@ -39,7 +40,12 @@ public:\nvirtual ~Decoder_BCH_fast() = default;\nprotected:\n- virtual void _decode(B *Y_N, const int frame_id);\n+ virtual void _decode ( const int frame_id);\n+ virtual void _load (const B *Y_N, const int frame_id);\n+ virtual void _decode_hiho (const B *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id);\n+ virtual void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.cpp", "new_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.cpp", "diff": "@@ -15,7 +15,7 @@ Decoder_BCH_genius<B,R>\n::Decoder_BCH_genius(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_BCH<B,R>(K, N, t, n_frames),\n- encoder(encoder)\n+ encoder(encoder), YH_N(N)\n{\nconst std::string name = \"Decoder_BCH_genius\";\nthis->set_name(name);\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.hpp", "new_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.hpp", "diff": "@@ -15,6 +15,7 @@ class Decoder_BCH_genius : public Decoder_BCH<B,R>\n{\nprotected:\nEncoder<B> &encoder;\n+ std::vector<B> YH_N; // hard decision input vector\npublic:\nDecoder_BCH_genius(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames = 1);\n" }, { "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": "@@ -14,7 +14,7 @@ Decoder_BCH_std<B, R>\n::Decoder_BCH_std(const int& K, const int& N, const tools::BCH_polynomial_generator<B> &GF_poly, const int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_BCH<B,R>(K, N, GF_poly.get_t(), n_frames),\n- t2(2 * this->t),\n+ YH_N(N), t2(2 * this->t),\nelp(this->N_p2_1+2, std::vector<int>(this->N_p2_1)), discrepancy(this->N_p2_1+2), l(this->N_p2_1+2), u_lu(this->N_p2_1+2), s(t2+1), loc(this->t +1), reg(this->t +1),\nm(GF_poly.get_m()), d(GF_poly.get_d()), alpha_to(GF_poly.get_alpha_to()), index_of(GF_poly.get_index_of())\n{\n@@ -198,6 +198,51 @@ void Decoder_BCH_std<B, R>\n}\n}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_std<B, R>\n+::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n+{\n+ std::copy(Y_N, Y_N + this->N, this->YH_N.begin());\n+\n+ this->_decode(this->YH_N.data(), frame_id);\n+\n+ std::copy(this->YH_N.data() + this->N - this->K, this->YH_N.data() + this->N, V_K);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_std<B, R>\n+::_decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id)\n+{\n+ std::copy(Y_N, Y_N + this->N, this->YH_N.begin());\n+\n+ this->_decode(this->YH_N.data(), frame_id);\n+\n+ std::copy(this->YH_N.data(), this->YH_N.data() + this->N, V_N);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_std<B, R>\n+::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n+{\n+ tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n+\n+ this->_decode(this->YH_N.data(), frame_id);\n+\n+ std::copy(this->YH_N.data() + this->N - this->K, this->YH_N.data() + this->N, V_K);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_std<B, R>\n+::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n+{\n+ tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n+\n+ this->_decode(this->YH_N.data(), frame_id);\n+\n+ std::copy(this->YH_N.data(), this->YH_N.data() + this->N, V_N);\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n" }, { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Standard/Decoder_BCH_std.hpp", "new_path": "src/Module/Decoder/BCH/Standard/Decoder_BCH_std.hpp", "diff": "@@ -18,6 +18,7 @@ private :\nconst int t2;\nprotected:\n+ std::vector<B> YH_N; // hard decision input vector\nstd::vector<std::vector<int>> elp;\nstd::vector<int> discrepancy;\nstd::vector<int> l;\n@@ -39,6 +40,10 @@ public:\nprotected:\nvirtual void _decode ( B *Y_N, const int frame_id);\n+ virtual void _decode_hiho (const B *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id);\n+ virtual void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n};\n}\n}\n" } ]
C++
MIT License
aff3ct/aff3ct
Set _decode_siho/hiho/cw in each different implem of BCH and not anymore only in the mother class
8,483
09.08.2018 08:24:42
-7,200
b93054a1010558d314d527803e3e6c8a5ab233c0
Fix compilation warnings and linker errors in 8 bits
[ { "change_type": "MODIFY", "old_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "new_path": "src/Module/Decoder/BCH/Fast/Decoder_BCH_fast.cpp", "diff": "@@ -17,8 +17,8 @@ Decoder_BCH_fast<B,R>\n::Decoder_BCH_fast(const int& K, const int& N, const tools::BCH_polynomial_generator<B> &GF_poly, const int n_frames)\n: Decoder (K, N, n_frames, mipp::N<B>() ),\nDecoder_BCH<B,R>(K, N, GF_poly.get_t(), n_frames ),\n- YH_N (this->N * mipp::N<B>() ),\nt2 (2 * this->t ),\n+ YH_N (this->N * mipp::N<B>() ),\nY_N_reorderered (this->N ),\nelp (this->N_p2_1+2, mipp::vector<mipp::Reg<B>>(this->N_p2_1)),\ndiscrepancy (this->N_p2_1+2 ),\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Code/BCH/BCH_polynomial_generator.cpp", "new_path": "src/Tools/Code/BCH/BCH_polynomial_generator.cpp", "diff": "@@ -152,13 +152,8 @@ void BCH_polynomial_generator<I>\n}\n// ==================================================================================== explicit template instantiation\n-#include \"Tools/types.h\"\n-#ifdef MULTI_PREC\n-template class aff3ct::tools::BCH_polynomial_generator<B_8>;\n-template class aff3ct::tools::BCH_polynomial_generator<B_16>;\n-template class aff3ct::tools::BCH_polynomial_generator<B_32>;\n-template class aff3ct::tools::BCH_polynomial_generator<B_64>;\n-#else\n-template class aff3ct::tools::BCH_polynomial_generator<B>;\n-#endif\n+template class aff3ct::tools::BCH_polynomial_generator<signed char>;\n+template class aff3ct::tools::BCH_polynomial_generator<short>;\n+template class aff3ct::tools::BCH_polynomial_generator<int >;\n+template class aff3ct::tools::BCH_polynomial_generator<long >;\n// ==================================================================================== explicit template instantiation\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Math/Galois.cpp", "new_path": "src/Tools/Math/Galois.cpp", "diff": "@@ -145,13 +145,7 @@ void Galois<I>\n}\n// ==================================================================================== explicit template instantiation\n-#include \"Tools/types.h\"\n-#ifdef MULTI_PREC\n-template class aff3ct::tools::Galois<B_8>;\n-template class aff3ct::tools::Galois<B_16>;\n-template class aff3ct::tools::Galois<B_32>;\n-template class aff3ct::tools::Galois<B_64>;\n-#else\n-template class aff3ct::tools::Galois<B>;\n-#endif\n-// ==================================================================================== explicit template instantiation\n+template class aff3ct::tools::Galois<signed char>;\n+template class aff3ct::tools::Galois<short>;\n+template class aff3ct::tools::Galois<int >;\n+template class aff3ct::tools::Galois<long >;\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix compilation warnings and linker errors in 8 bits
8,483
09.08.2018 09:37:43
-7,200
38cf63e5bc3f897c425f79793adb44d427c6e17a
Fix the exmplicit template instantiation for Galois and BCH_polynomial_generator
[ { "change_type": "MODIFY", "old_path": "src/Tools/Code/BCH/BCH_polynomial_generator.cpp", "new_path": "src/Tools/Code/BCH/BCH_polynomial_generator.cpp", "diff": "@@ -152,8 +152,9 @@ void BCH_polynomial_generator<I>\n}\n// ==================================================================================== explicit template instantiation\n-template class aff3ct::tools::BCH_polynomial_generator<signed char>;\n-template class aff3ct::tools::BCH_polynomial_generator<short>;\n-template class aff3ct::tools::BCH_polynomial_generator<int >;\n-template class aff3ct::tools::BCH_polynomial_generator<long >;\n+#include \"Tools/types.h\"\n+template class aff3ct::tools::BCH_polynomial_generator<B_8 >;\n+template class aff3ct::tools::BCH_polynomial_generator<B_16>;\n+template class aff3ct::tools::BCH_polynomial_generator<B_32>;\n+template class aff3ct::tools::BCH_polynomial_generator<B_64>;\n// ==================================================================================== explicit template instantiation\n" }, { "change_type": "MODIFY", "old_path": "src/Tools/Math/Galois.cpp", "new_path": "src/Tools/Math/Galois.cpp", "diff": "@@ -145,7 +145,8 @@ void Galois<I>\n}\n// ==================================================================================== explicit template instantiation\n-template class aff3ct::tools::Galois<signed char>;\n-template class aff3ct::tools::Galois<short>;\n-template class aff3ct::tools::Galois<int >;\n-template class aff3ct::tools::Galois<long >;\n+#include \"Tools/types.h\"\n+template class aff3ct::tools::Galois<B_8 >;\n+template class aff3ct::tools::Galois<B_16>;\n+template class aff3ct::tools::Galois<B_32>;\n+template class aff3ct::tools::Galois<B_64>;\n\\ No newline at end of file\n" } ]
C++
MIT License
aff3ct/aff3ct
Fix the exmplicit template instantiation for Galois and BCH_polynomial_generator
8,490
09.08.2018 10:05:33
-7,200
ea800d3b19a6f707dcf6f6c4037ac6c613ac0767
Put back regex if the compiler support it.
[ { "change_type": "MODIFY", "old_path": "src/Launcher/Launcher.cpp", "new_path": "src/Launcher/Launcher.cpp", "diff": "@@ -132,6 +132,7 @@ void Launcher::print_header()\nstd::string remove_sim_meta(const std::string& cmd)\n{\n+#if !defined(__clang__) && !defined(__llvm__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC__ < 5\nconst std::string simmeta = \" --sim-meta \";\nauto pos_arg = cmd.find(simmeta);\n@@ -142,6 +143,9 @@ std::string remove_sim_meta(const std::string& cmd)\nauto pos_end = cmd.find(\"\\\"\", pos_start + 1);\nreturn cmd.substr(0, pos_arg) + cmd.substr(pos_end + 1);\n+#else\n+ return std::regex_replace(cmd, std::regex(\"( --sim-meta \\\"[^\\\"]*\\\")\"), \"\");\n+#endif\n}\nint Launcher::launch()\n" } ]
C++
MIT License
aff3ct/aff3ct
Put back regex if the compiler support it.