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,483 |
10.08.2018 13:26:49
| -7,200 |
dac26b261b9f50380de3485856d2eaa13b9c3874
|
Fix BCH fast
|
[
{
"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": "@@ -49,12 +49,17 @@ Decoder_BCH_fast<B,R>\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+ this->last_is_codeword.resize(n_frames + mipp::N<B>()); // in case where only the last frame_id is called to prevent memory leak\n}\ntemplate <typename B, class A = std::allocator<B>>\n-mipp::Reg<B> read_array(const std::vector<B,A>& array, const mipp::Reg<B>& r_idx)\n+mipp::Reg<B> read_array(const std::vector<B,A>& array, mipp::Reg<B> r_idx, const mipp::Msk<mipp::N<B>()>& m_idx = true)\n{\nB idx[mipp::N<B>()], val[mipp::N<B>()];\n+\n+ const auto r_zero = mipp::Reg<B>((B)0);\n+ r_idx = mipp::blend(r_idx, r_zero, m_idx);\nr_idx.store(idx);\nfor (auto j = 0; j < mipp::N<B>(); j++)\n@@ -71,17 +76,18 @@ void write_array(std::vector<mipp::Reg<B>,A>& array, const mipp::Reg<B>& r_idx,\nstd::iota(v_iota.begin(), v_iota.end(), 0);\nmipp::Reg<B> r_iota = v_iota.data();\n+ B idx[mipp::N<B>()];\n+ r_idx.store(idx);\n+\nfor (auto j = 0; j < mipp::N<B>(); j++)\n- {\n- auto idx = r_idx[j];\n- array[idx] = mipp::blend(r_values, array[idx], m_idx & (r_iota == j));\n- }\n+ array[idx[j]] = mipp::blend(r_values, array[idx[j]], m_idx & (r_iota == j));\n}\ntemplate <typename B>\n-mipp::Reg<B> operator%(const mipp::Reg<B>& r, int mod)\n+mipp::Reg<B> operator%(mipp::Reg<B> r, int mod)\n{\n- return r & (B)mod; // works only with mod == 2^n -1\n+ r = mipp::blend(r - (B)mod, r, r >= (B)mod);\n+ return mipp::blend(r + (B)mod, r, r < (B)0 );\n}\ntemplate <typename B, typename R>\n@@ -93,7 +99,7 @@ void Decoder_BCH_fast<B,R>\nconst auto r_mone = mipp::Reg<B>((B)-1);\n- // form the syndromes\n+ // form the syndrome\nauto syn_error = r_zero != r_zero; // init to false\nstd::fill(s.begin(), s.end(), r_zero);\n@@ -111,6 +117,7 @@ void Decoder_BCH_fast<B,R>\ns[i] = read_array(index_of, s[i]);\n}\n+\nif (!mipp::testz(syn_error))\n{\n// initialise table entries\n@@ -141,42 +148,43 @@ void Decoder_BCH_fast<B,R>\nconst auto m_disc = (discrepancy[u] == r_mone) & m_process;\nconst auto m_not_disc = (discrepancy[u] != r_mone) & m_process;\n+\n+\n//***** part if (discrepancy[u] == -1)\nif (!mipp::testz(m_disc))\n{\nl[u_p1] = mipp::blend(l[u], l[u_p1], m_disc);\n- B i = 0;\n- auto m_lu = (l[u] >= i) & m_disc;\n- while(!mipp::testz(m_lu))\n- {\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);\n- i++;\n- m_lu = (l[u] >= i) & m_disc;\n+ auto l_max = mipp::hmax(mipp::blend(l[u], r_zero, m_disc));\n+ for (auto i = 0; i <= l_max; i++)\n+ {\n+ auto m_ok = m_disc & (l[u] >= (B)i);\n+ elp[u_p1][i] = mipp::blend(elp[u][i], elp[u_p1][i], m_ok);\n+ elp[u ][i] = mipp::blend(read_array(index_of, elp[u][i], m_ok), elp[u][i], m_ok);\n}\n}\n//**** part if (discrepancy[u] != -1)\nif (!mipp::testz(m_not_disc))\n{\n- // search for words with greatest u_lu[q] for which d[q] != -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+ // search for words with greatest u_lu[q] for which discrepancy[q] != -1\n+ mipp::Reg<B> r_disc_q = discrepancy[0], r_l_q = l[0], r_u_lu_q = u_lu[0], r_q = r_zero;\n+ mipp::vector<mipp::Reg<B>> r_elp_q = elp[0];\n- for (auto q = u_m1 - 1; q >= 0; q--)\n+ for (auto j = u_m1; j >= 0; j--)\n{\n- auto m_ok = m_not_disc & (discrepancy[q] != r_mone) & (r_u_lu_q > u_lu[q]);\n+ auto m_ok = m_not_disc & (discrepancy[j] != r_mone) & (r_u_lu_q < u_lu[j]);\n- r_q = mipp::blend(mipp::Reg<B>(q), r_q, m_ok);\n- r_disc_q = mipp::blend( discrepancy[q], r_disc_q, m_ok);\n- r_l_q = mipp::blend( l[q], r_l_q, m_ok);\n- r_u_lu_q = mipp::blend( u_lu[q], r_u_lu_q, m_ok);\n+ r_q = mipp::blend(mipp::Reg<B>(j), r_q, m_ok);\n+ r_disc_q = mipp::blend( discrepancy[j], r_disc_q, m_ok);\n+ r_l_q = mipp::blend( l[j], r_l_q, m_ok);\n+ r_u_lu_q = mipp::blend( u_lu[j], r_u_lu_q, m_ok);\nfor (unsigned i = 0; i < r_elp_q.size(); i++)\n- r_elp_q[i] = mipp::blend(elp[q][i], r_elp_q[i], m_ok);\n+ r_elp_q[i] = mipp::blend(elp[j][i], r_elp_q[i], m_ok);\n}\n+\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@@ -194,9 +202,10 @@ void Decoder_BCH_fast<B,R>\nif (mipp::testz(m_ok))\ncontinue;\n- const auto r_alpha_idx = (r_elp_q[i] - r_disc_q + discrepancy[u] + this->N_p2_1) % this->N_p2_1;\n+\n+ const auto r_alpha_idx = ((r_elp_q[i] - r_disc_q) % this->N_p2_1 + discrepancy[u]) % this->N_p2_1;\nconst 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+ write_array(elp[u_p1], r_idx, m_ok, read_array(alpha_to, r_alpha_idx, m_ok));\n}\nl_max = mipp::hmax(mipp::blend(l[u], r_zero, m_not_disc));\n@@ -204,23 +213,25 @@ void Decoder_BCH_fast<B,R>\n{\nauto m_ok = m_not_disc & (l[u] >= i);\nelp[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+ elp[u ][i] = mipp::blend(read_array(index_of, elp[u][i], m_ok), elp[u][i], m_ok);\n}\n}\nu_lu[u_p1] = r_u - l[u_p1];\n+\n// form (u_p1)th discrepancy\nif (u < t2)\n{\n// no discrepancy computed on last iteration\n+ {\nconst 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+ const auto r_alpha_idx = s[u_p1] % this->N_p2_1;\n+ const auto r_read = mipp::blend(read_array(alpha_to, r_alpha_idx, m_s), r_zero, m_s);\ndiscrepancy[u_p1] = mipp::blend(r_read, discrepancy[u_p1], m_process);\n+ }\n-\n- auto l_max = mipp::hmax(mipp::blend(l[u_p1], r_zero, m_not_disc));\n+ auto l_max = mipp::hmax(mipp::blend(l[u_p1], r_zero, m_process));\nfor (auto i = 1; i <= l_max; i++)\n{\nauto u_p1_i = ((u_p1 - i) < 0) ? 0 : (u_p1 - i);\n@@ -229,15 +240,15 @@ 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 = read_array(alpha_to, r_alpha_idx);\n+ const auto r_alpha_idx = (s[u_p1_i] + read_array(index_of, elp[u_p1][i], m_ok)) % this->N_p2_1;\n+ const auto r_alpha = read_array(alpha_to, r_alpha_idx, m_ok);\nconst auto r_disc = discrepancy[u_p1] ^ r_alpha;\ndiscrepancy[u_p1] = mipp::blend(r_disc, discrepancy[u_p1], m_ok);\n}\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+ discrepancy[u_p1] = mipp::blend(read_array(index_of, discrepancy[u_p1], m_process), discrepancy[u_p1], m_process);\n}\nm_process &= l[u_p1] <= this->t;\n@@ -246,7 +257,7 @@ void Decoder_BCH_fast<B,R>\nu++;\n// Correct errors\n- const auto m_corr = l[u] <= this->t;\n+ const auto m_corr = (l[u] <= this->t) & syn_error;\nif (!mipp::testz(m_corr))\n{\n@@ -254,9 +265,8 @@ void Decoder_BCH_fast<B,R>\nauto l_max = mipp::hmax(mipp::blend(l[u], r_zero, m_corr));\nfor (auto i = 1; i <= l_max; i++)\n{\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\n- reg[i] = read_array(alpha_to, r_idx);\n+ auto r_idx = mipp::blend(elp[u][i], r_zero, l[u] >= i);\n+ reg[i] = read_array(index_of, r_idx, m_corr);\n}\nmipp::Reg<B> count = r_zero;\n@@ -264,11 +274,16 @@ void Decoder_BCH_fast<B,R>\n{\nmipp::Reg<B> q = r_one;\nfor (auto j = 1; j <= l_max; j++)\n- q = mipp::blend(q ^ reg[j], r_one, l[u] >= i);\n+ {\n+ auto m_ok = (l[u] >= j) & (reg[j] != r_mone) & m_corr;\n+ reg[j] = mipp::blend((reg[j] + j) % this->N_p2_1, reg[j], m_ok);\n+ q = mipp::blend(q ^ read_array(alpha_to, reg[j], m_ok), q, m_ok);\n+ }\nauto m_flip = (q == r_zero) & m_corr;\ncount += mipp::blend(r_one, r_zero, m_flip);\n+\nauto 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/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- YH_N(N), t2(2 * this->t),\n+ t2(2 * this->t), YH_N(N),\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@@ -88,6 +88,7 @@ void Decoder_BCH_std<B, R>\ndo\n{\nu++;\n+\nif (discrepancy[u] == -1)\n{\nl[u + 1] = l[u];\n@@ -148,6 +149,7 @@ void Decoder_BCH_std<B, R>\ndiscrepancy[u + 1] = alpha_to[s[u + 1]];\nelse\ndiscrepancy[u + 1] = 0;\n+\nfor (i = 1; i <= l[u + 1]; i++)\nif ((s[u + 1 - i] != -1) && (elp[u + 1][i] != 0))\ndiscrepancy[u + 1] ^= alpha_to[(s[u + 1 - i] + index_of[elp[u + 1][i]]) % this->N_p2_1];\n@@ -167,6 +169,7 @@ void Decoder_BCH_std<B, R>\n/* Chien search: find roots of the error location polynomial */\nfor (i = 1; i <= l[u]; i++)\nreg[i] = elp[u][i];\n+\nint count = 0;\nfor (i = 1; i <= this->N_p2_1; i++)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix BCH fast
|
8,483 |
10.08.2018 13:56:02
| -7,200 |
d0f26d03aa98dc269f6ae01364ca5925f94eb968
|
Fix B,N sizes conditions to run
|
[
{
"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": "@@ -42,11 +42,11 @@ Decoder_BCH_fast<B,R>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (this->N_p2_1 >= std::numeric_limits<B>::max() && std::is_unsigned<B>::value)\n+ if (this->N_p2_1*2 >= std::numeric_limits<B>::max() || std::is_unsigned<B>::value)\n{\nstd::stringstream message;\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() << \").\";\n+ message << \"'N_p2_1'*2 must be less than 'std::numeric_limits<B>::max()' and 'B' must be signed ('N_p2_1'*2 = \"\n+ << this->N_p2_1*2 << \", 'std::numeric_limits<B>::max()' = \" << std::numeric_limits<B>::max() << \").\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix B,N sizes conditions to run
|
8,483 |
10.08.2018 18:42:54
| -7,200 |
9c5345b80dd5102183dab6292b2357aee3c548d7
|
Add update_refs_header.py script. Update test-regression with last aff3ct refs reader version
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -14,7 +14,7 @@ import subprocess\nimport numpy as np\nsys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), \"../refs\")))\n-from aff3ct_refs_reader import aff3ctRefsReader\n+import aff3ct_refs_reader as arr\n# ==================================================================== PACKAGES\n# =============================================================================\n@@ -86,45 +86,6 @@ def getFileNames(currentPath, fileNames):\nelse:\nprint(\"# (WW) The path '\", currentPath, \"' does not exist.\")\n-def splitAsCommand(runCommand):\n- argsList = [\"\"]\n- idx = 0\n- new = 0\n- found_dashes = 0\n-\n- for s in runCommand:\n- if found_dashes == 0:\n- if s == ' ':\n- if new == 0:\n- argsList.append(\"\")\n- idx = idx + 1\n- new = 1\n-\n- elif s == '\\\"':\n- if new == 0:\n- argsList.append(\"\")\n- idx = idx + 1\n- new = 1\n- found_dashes = 1\n-\n- else:\n- argsList[idx] += s\n- new = 0\n-\n- else: # between dashes\n- if s == '\\\"':\n- argsList.append(\"\")\n- idx = idx + 1\n- found_dashes = 0\n-\n- else:\n- argsList[idx] += s\n-\n- if argsList[idx] == \"\":\n- del argsList[idx]\n-\n- return argsList\n-\nclass tableStats:\ndef __init__(self, tableCur, tableRef, sensibility, name, nData = 0):\nif len(tableCur) > len(tableRef) : # can't have less ref than checked points\n@@ -394,7 +355,7 @@ for fn in fileNames:\n\" - \" + fn, end=\"\", flush=True);\n# parse the reference file\n- simuRef = aff3ctRefsReader(args.refsPath + \"/\" + fn)\n+ simuRef = arr.aff3ctRefsReader(args.refsPath + \"/\" + fn)\nif simuRef.getMetadata(\"ci\") == \"off\":\nprint(\" - IGNORED.\", end=\"\\n\");\n@@ -406,7 +367,7 @@ for fn in fileNames:\n# get the command line to run\nargsAFFECT = argsAFFECTcommand[:] # hard copy\n- argsAFFECT += splitAsCommand(simuRef.getMetadata(\"command\"))\n+ argsAFFECT += simuRef.getSplitCommand()\nargsAFFECT += [\"--ter-freq\", \"0\", \"-t\", str(args.nThreads), \"--sim-meta\", simuRef.getMetadata(\"title\")]\nif args.maxFE:\nargsAFFECT += [\"-e\", str(args.maxFE)]\n@@ -437,8 +398,7 @@ for fn in fileNames:\nos.chdir(args.buildPath)\nstartTime = time.time()\ntry:\n- processAFFECT = subprocess.Popen(argsAFFECT, stdout=subprocess.PIPE,\n- stderr=subprocess.PIPE)\n+ processAFFECT = subprocess.Popen(argsAFFECT, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n(stdoutAFFECT, stderrAFFECT) = processAFFECT.communicate()\nexcept KeyboardInterrupt:\nos.kill(processAFFECT.pid, signal.SIGINT)\n@@ -456,7 +416,7 @@ for fn in fileNames:\n# get the results\nstdOutput = stdoutAFFECT.decode(encoding='UTF-8').split(\"\\n\")\n- simuCur = aff3ctRefsReader(stdOutput)\n+ simuCur = arr.aff3ctRefsReader(stdOutput)\n# result file\nfRes = open(args.resultsPath + \"/\" + fn, 'w+')\n"
},
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit b43e8be4052b5eb5b989c245fd166473f0196f95\n+Subproject commit abddbf9539500fa82c5ff90623d52e7e39a4d5b8\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add update_refs_header.py script. Update test-regression with last aff3ct refs reader version
|
8,483 |
10.08.2018 19:00:34
| -7,200 |
6b9bb84260097f3908f41506a4f6ca3a85ecb1b4
|
Remove also argument -t in the metadata command line
|
[
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Launcher.cpp",
"new_path": "src/Launcher/Launcher.cpp",
"diff": "@@ -130,21 +130,23 @@ void Launcher::print_header()\nthis->stream << rang::tag::comment << std::endl;\n}\n-std::string remove_sim_meta(const std::string& cmd)\n+std::string remove_argument(const std::string& cmd, std::string arg)\n{\n#if !defined(__clang__) && !defined(__llvm__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC__ < 5\n- const std::string simmeta = \" --sim-meta \";\n- auto pos_arg = cmd.find(simmeta);\n+\n+ if (arg.front() != ' ')\n+ arg = \" \" + arg;\n+ auto pos_arg = cmd.find(arg);\nif (pos_arg == std::string::npos)\nreturn cmd;\n- auto pos_start = cmd.find(\"\\\"\", pos_arg + simmeta.size());\n+ auto pos_start = cmd.find(\"\\\"\", pos_arg + arg.size());\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+ return std::regex_replace(cmd, std::regex(\"( \" + arg + \" \\\"[^\\\"]*\\\")\"), \"\");\n#endif\n}\n@@ -179,7 +181,7 @@ int Launcher::launch()\nif (!this->params_common.meta.empty())\n{\nstream << \"[metadata]\" << std::endl;\n- stream << \"command=\" << remove_sim_meta(cmd_line) << std::endl;\n+ stream << \"command=\" << remove_argument(remove_argument(cmd_line, \"--sim-meta\"), \"-t\") << std::endl;\nstream << \"title=\" << this->params_common.meta << std::endl;\nstream << std::endl << \"[trace]\" << std::endl;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove also argument -t in the metadata command line
|
8,483 |
10.08.2018 19:15:28
| -7,200 |
210bdb2aaed0c768263a9e1b2552cf35ac530510
|
Enhance remove_argument function in Launcher to remove also ter-freq and rewrite correcly the Terminal end of line display
|
[
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Launcher.cpp",
"new_path": "src/Launcher/Launcher.cpp",
"diff": "@@ -133,7 +133,6 @@ void Launcher::print_header()\nstd::string remove_argument(const std::string& cmd, std::string arg)\n{\n#if !defined(__clang__) && !defined(__llvm__) && defined(__GNUC__) && defined(__cplusplus) && __GNUC__ < 5\n-\nif (arg.front() != ' ')\narg = \" \" + arg;\nauto pos_arg = cmd.find(arg);\n@@ -150,6 +149,13 @@ std::string remove_argument(const std::string& cmd, std::string arg)\n#endif\n}\n+std::string remove_argument(std::string cmd, const std::vector<std::string>& args)\n+{\n+ for (auto& a : args)\n+ cmd = remove_argument(cmd, a);\n+ return cmd;\n+}\n+\nint Launcher::launch()\n{\nint exit_code = EXIT_SUCCESS;\n@@ -181,7 +187,7 @@ int Launcher::launch()\nif (!this->params_common.meta.empty())\n{\nstream << \"[metadata]\" << std::endl;\n- stream << \"command=\" << remove_argument(remove_argument(cmd_line, \"--sim-meta\"), \"-t\") << std::endl;\n+ stream << \"command=\" << remove_argument(cmd_line, {\"--sim-meta\", \"-t\", \"--ter-freq\"}) << std::endl;\nstream << \"title=\" << this->params_common.meta << std::endl;\nstream << std::endl << \"[trace]\" << std::endl;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"new_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"diff": "@@ -218,7 +218,7 @@ void Terminal_std\n{\nstd::ios::fmtflags f(stream.flags());\n- stream << \"\\r\" << data_tag;\n+ stream << data_tag;\nfor (unsigned r = 0; r < this->reporters.size(); r++)\n@@ -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;\n+ stream << rang::style::bold << rang::fg::green << (real_time_state++ < 2 ? \" *\" : \" \") << rang::style::reset << \"\\r\";\nreal_time_state %= (uint8_t)4;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Enhance remove_argument function in Launcher to remove also ter-freq and rewrite correcly the Terminal end of line display
|
8,490 |
14.08.2018 09:07:10
| -7,200 |
1a48b80ca511e7fca0691634e96e0f8f6857f2fc
|
Improve the carrier return character management.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"new_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"diff": "@@ -218,8 +218,11 @@ void Terminal_std\n{\nstd::ios::fmtflags f(stream.flags());\n- stream << \"\\r\" << data_tag;\n+ // Ugly hack to manage correctly the interruption by the user\n+ if (Terminal::is_interrupt())\n+ std::clog << \"\\r\";\n+ stream << data_tag;\nfor (unsigned r = 0; r < this->reporters.size(); r++)\nif (this->reporters[r] != nullptr)\n@@ -269,6 +272,7 @@ void Terminal_std\nelse\n{\nstream << rang::style::bold << rang::fg::green << (real_time_state++ < 2 ? \" *\" : \" \") << rang::style::reset;\n+ stream << \"\\r\"; // put the carrier return character only on temporary reports\nreal_time_state %= (uint8_t)4;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve the carrier return character management.
|
8,483 |
20.08.2018 12:19:15
| -7,200 |
476d73962b74f988d0026c229872be65f56dd946
|
Fix test regression and the update ref headers scripts
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -165,7 +165,7 @@ class tableStats:\nclass compStats:\ndef __init__(self, dataCur, dataRef, sensibility, asked_n_fe):\n- if not isinstance(dataCur, aff3ctRefsReader) or not isinstance(dataRef, aff3ctRefsReader) :\n+ if not isinstance(dataCur, arr.aff3ctRefsReader) or not isinstance(dataRef, arr.aff3ctRefsReader) :\nraise TypeError\nself.nValidData = len(dataCur.getTrace(\"n_fe\"))\n"
},
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit abddbf9539500fa82c5ff90623d52e7e39a4d5b8\n+Subproject commit 2b2fe7396391919b648f3f8ac9b604ba2f80102e\n"
},
{
"change_type": "MODIFY",
"old_path": "scripts/update_refs_headers.py",
"new_path": "scripts/update_refs_headers.py",
"diff": "@@ -22,8 +22,8 @@ import aff3ct_refs_reader as arr\n# ================================================================== PARAMETERS\nparser = argparse.ArgumentParser(prog='aff3ct-test-regression', formatter_class=argparse.ArgumentDefaultsHelpFormatter)\n-parser.add_argument('--refs-path', action='store', dest='refsPath', type=str, default=\"refs\", help='Path to the references to re-simulate.')\n-parser.add_argument('--results-path', action='store', dest='resultsPath', type=str, default=\"test-regression-results\", help='Path to the simulated results.')\n+parser.add_argument('--refs-path', action='store', dest='refsPath', type=str, default=\"refs\", help='Path to the references to update.')\n+parser.add_argument('--results-path', action='store', dest='resultsPath', type=str, default=\"update-refs-results\", help='Path to the updated results.')\nparser.add_argument('--build-path', action='store', dest='buildPath', type=str, default=\"build\", help='Path to the AFF3CT build.')\nparser.add_argument('--start-id', action='store', dest='startId', type=int, default=1, help='Starting id to avoid computing results one again.') # choices=xrange(1, +inf)\nparser.add_argument('--recursive-scan', action='store', dest='recursiveScan', type=bool, default=True, help='If enabled, scan the path of refs recursively.')\n@@ -65,6 +65,15 @@ def getFileNames(currentPath, fileNames):\nelse:\nprint(\"# (WW) The path '\", currentPath, \"' does not exist.\")\n+\n+def setBackOldParameters(ref, new):\n+ ValuesToSetBack = [\"Date (UTC)\", \"Git version\", \"Multi-threading\"]\n+\n+ for v in ValuesToSetBack:\n+ refVal = ref.getSimuHeader(v)\n+ if refVal != \"\":\n+ new.setSimuHeader(v,refVal)\n+\n# =================================================================== FUNCTIONS\n# =============================================================================\n@@ -153,6 +162,8 @@ for fn in fileNames:\nnewFile = stdoutAFFECT.decode(encoding='UTF-8').split(\"\\n\")\nnewData = arr.aff3ctRefsReader(newFile)\n+ # set back multi-threading or git version or data values of the reference\n+ setBackOldParameters(refData, newData)\n# result file\nfRes = open(args.resultsPath + \"/\" + fn, 'w+')\n@@ -173,20 +184,16 @@ for fn in fileNames:\nelse:\nfRes.write(refData.getMetadataAsString ())\n+ fRes.write(newData.getSimuTitleAsString ())\n+ fRes.write(newData.getSimuHeaderAsString ())\n+ fRes.write(refData.getLegendTitleAsString())\n- i = 0\n- while( i < len(newFile)):\n- l = newFile[i]\n- if l.startswith(\"# The simulation is running...\"):\n- break\n- fRes.write(l + \"\\n\")\n- i += 1 # to next line\n-\n+ # write ref trace\ni = 0\ndump = False\nwhile( i < len(refFile)):\nl = refFile[i]\n- if dump:\n+ if dump and (not l.startswith(\"#\") or l.startswith(\"# End of the simulation\")):\nfRes.write(l + \"\\n\")\nelif l.startswith(\"# The simulation is running...\"):\ndump = True\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix test regression and the update ref headers scripts
|
8,483 |
20.08.2018 18:50:06
| -7,200 |
e3c2a717e2c814256ae06ba558fcd35f289bc2c6
|
read info bits positions at the end of the file in encoder USER; Adapt Codec LDPC to handle this
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "@@ -91,16 +91,7 @@ Codec_LDPC<B,Q>\nif (info_bits_pos.empty())\n{\nif (enc_params.type == \"LDPC_H\")\n- {\nthis->set_encoder(factory::Encoder_LDPC::build<B>(enc_params, G, H));\n- info_bits_pos = this->get_encoder()->get_info_bits_pos();\n- }\n- else\n- {\n- // generate a default vector [0, 1, 2, 3, ..., K-1]\n- info_bits_pos.resize(enc_params.K);\n- std::iota(info_bits_pos.begin(), info_bits_pos.end(), 0);\n- }\n}\nelse\n{\n@@ -148,6 +139,19 @@ Codec_LDPC<B,Q>\n}\n}\n+ if (info_bits_pos.empty())\n+ {\n+ try\n+ {\n+ info_bits_pos = this->get_encoder()->get_info_bits_pos();\n+ }\n+ catch(tools::unimplemented_error const&)\n+ {\n+ // generate a default vector [0, 1, 2, 3, ..., K-1]\n+ info_bits_pos.resize(enc_params.K);\n+ std::iota(info_bits_pos.begin(), info_bits_pos.end(), 0);\n+ }\n+ }\ntry\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/User/Encoder_user.cpp",
"new_path": "src/Module/Encoder/User/Encoder_user.cpp",
"diff": "#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/general_utils.h\"\n#include \"Encoder_user.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\n+\n+std::vector<uint32_t> read_info_bits_pos(std::istream &stream)\n+{\n+ std::string line;\n+\n+ // look for the position in the file where the info bits begin\n+ while (std::getline(stream, line))\n+ if (line == \"# Positions of the information bits in the codewords:\" || stream.eof() || stream.fail() || stream.bad())\n+ break;\n+\n+ getline(stream, line);\n+ auto values = tools::split(line);\n+ if (values.size() != 1)\n+ {\n+ std::stringstream message;\n+ message << \"'values.size()' has to be equal to 1 ('values.size()' = \" << values.size() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ const uint32_t size = std::stoi(values[0]);\n+\n+ getline(stream, line);\n+ values = tools::split(line);\n+ if (values.size() != size)\n+ {\n+ std::stringstream message;\n+ message << \"'values.size()' has to be equal to 'size' ('values.size()' = \" << values.size()\n+ << \", 'size' = \" << size << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ std::vector<uint32_t> info_bits_pos;\n+ for (auto v : values)\n+ {\n+ const uint32_t pos = std::stoi(v);\n+\n+ if (std::find(info_bits_pos.begin(), info_bits_pos.end(), pos) != info_bits_pos.end())\n+ {\n+ std::stringstream message;\n+ message << \"'pos' already exists in the 'info_bits_pos' vector ('pos' = \" << pos << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ info_bits_pos.push_back(pos);\n+ }\n+\n+ return info_bits_pos;\n+}\n+\n+\n+\ntemplate <typename B>\nEncoder_user<B>\n::Encoder_user(const int K, const int N, const std::string &filename, const int n_frames, const int start_idx)\n@@ -61,8 +113,6 @@ Encoder_user<B>\n}\nelse\n{\n- file.close();\n-\nstd::stringstream message;\nmessage << \"The number of information bits or the codeword size is wrong \"\n<< \"(read: {\" << src_size << \",\" << cw_size << \"}, \"\n@@ -70,7 +120,22 @@ Encoder_user<B>\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- file.close();\n+ try\n+ {\n+ this->info_bits_pos = read_info_bits_pos(file);\n+ }\n+ catch (std::exception const&)\n+ {\n+ // information bits positions are not in the matrix file\n+ }\n+\n+ if ((int)this->info_bits_pos.size() != this->K)\n+ {\n+ std::stringstream message;\n+ message << \"'this->info_bits_pos.size()' has to be equal to 'this->K' ('this->info_bits_pos.size()' = \"\n+ << this->info_bits_pos.size() << \", 'this->K' = \" << this->K << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n}\nelse\n{\n@@ -82,12 +147,6 @@ Encoder_user<B>\ncw_counter %= (int)codewords.size();\n}\n-template <typename B>\n-Encoder_user<B>\n-::~Encoder_user()\n-{\n-}\n-\ntemplate <typename B>\nvoid Encoder_user<B>\n::_encode(const B *U_K, B *X_N, const int frame_id)\n@@ -99,13 +158,6 @@ void Encoder_user<B>\nthis->cw_counter = (this->cw_counter +1) % (int)this->codewords.size();\n}\n-template <typename B>\n-const std::vector<uint32_t>& Encoder_user<B>\n-::get_info_bits_pos() const\n-{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n-}\n-\ntemplate <typename B>\nbool Encoder_user<B>\n::is_sys() const\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/User/Encoder_user.hpp",
"new_path": "src/Module/Encoder/User/Encoder_user.hpp",
"diff": "@@ -18,9 +18,7 @@ private:\npublic:\nEncoder_user(const int K, const int N, const std::string &filename, const int n_frames = 1, const int start_idx = 0);\n- virtual ~Encoder_user();\n-\n- const std::vector<uint32_t>& get_info_bits_pos() const;\n+ virtual ~Encoder_user() = default;\nbool is_sys() const;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
read info bits positions at the end of the file in encoder USER; Adapt Codec LDPC to handle this
|
8,483 |
21.08.2018 11:57:59
| -7,200 |
7929d98252541f1dae720d819612e0131bb3d1d0
|
Add default stream for terminal legend calls and fix the SC simulation end of the loop condition
|
[
{
"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": "@@ -51,7 +51,7 @@ void SC_BFER_ite<B,R,Q>\nthis->monitor_er[tid]->add_handler_check([&]() -> void\n{\n- if (this->monitor_er_red->fe_limit_achieved()) // will make the MPI communication\n+ if (!this->keep_looping_noise_point()) // will make the MPI communication\nsc_core::sc_stop();\n});\n}\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": "@@ -39,7 +39,7 @@ void SC_BFER_std<B,R,Q>\nthis->monitor_er[tid]->add_handler_check([&]() -> void\n{\n- if (this->monitor_er_red->fe_limit_achieved()) // will make the MPI communication\n+ if (!this->keep_looping_noise_point()) // will make the MPI communication\nsc_core::sc_stop();\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"new_path": "src/Tools/Display/Terminal/Standard/Terminal_std.cpp",
"diff": "@@ -218,8 +218,13 @@ void Terminal_std\n{\nstd::ios::fmtflags f(stream.flags());\n+ // Ugly hack to manage correctly the interruption by the user and to remove the ^C from the screen\n+ if (Terminal::is_interrupt())\n+ std::clog << \"\\r\";\n+\nstream << data_tag;\n+\nfor (unsigned r = 0; r < this->reporters.size(); r++)\nif (this->reporters[r] != nullptr)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Standard/Terminal_std.hpp",
"new_path": "src/Tools/Display/Terminal/Standard/Terminal_std.hpp",
"diff": "@@ -60,7 +60,7 @@ public:\n*\n* \\param stream: the stream to print the legend.\n*/\n- void legend(std::ostream &stream) const;\n+ void legend(std::ostream &stream = std::cout) const;\nprotected:\nvirtual void report(std::ostream &stream = std::cout, bool final = false);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.hpp",
"new_path": "src/Tools/Display/Terminal/Terminal.hpp",
"diff": "@@ -61,21 +61,21 @@ public:\n*\n* \\param stream: the stream to print the legend.\n*/\n- virtual void legend(std::ostream &stream) const = 0;\n+ virtual void legend(std::ostream &stream = std::cout) const = 0;\n/*!\n* \\brief Temporary report.\n*\n* \\param stream: the stream to print the report.\n*/\n- void temp_report(std::ostream &stream);\n+ void temp_report(std::ostream &stream = std::cout);\n/*!\n* \\brief Final report.\n*\n* \\param stream: the stream to print the report.\n*/\n- void final_report(std::ostream &stream);\n+ void final_report(std::ostream &stream = std::cout);\nvoid start_temp_report(const std::chrono::milliseconds freq = std::chrono::milliseconds(500));\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add default stream for terminal legend calls and fix the SC simulation end of the loop condition
|
8,483 |
21.08.2018 16:21:59
| -7,200 |
aac2306d5199d486dcc776957d284ee3152459b0
|
Arrange Terminal::stop call order to display the results except if the user has interrupt the simulation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -221,21 +221,15 @@ void BFER<B,R,Q>\n}\ncatch (std::exception const& e)\n{\n- tools::Terminal::stop();\nmodule::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\nrang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::tag::error);\nthis->simu_error = true;\n- }\n-\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-\n+ }\n#ifdef ENABLE_MPI\n@@ -265,6 +259,12 @@ void BFER<B,R,Q>\n}\n}\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()))\n+ tools::Terminal::stop();\n+\n+\nif (params_BFER.mnt_er->err_hist != -1)\n{\nauto err_hist = monitor_er_red->get_err_hist();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Arrange Terminal::stop call order to display the results except if the user has interrupt the simulation
|
8,483 |
21.08.2018 16:23:04
| -7,200 |
059c639fc99664e5a3a2f08a887a36654351b3bb
|
Enhance SC_Duplicator for any number of output; Update consequently SC_BFER_ite and std; Use a vector of duplicators instead of a table in the lasts
|
[
{
"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": "@@ -16,8 +16,7 @@ SC_BFER_ite<B,R,Q>\n: BFER_ite<B,R,Q>(params_BFER_ite),\ncoset_real_i(nullptr),\n-\n- duplicator {nullptr, nullptr, nullptr, nullptr, nullptr},\n+ duplicator(7, nullptr),\nrouter (nullptr),\npredicate (nullptr)\n{\n@@ -36,6 +35,12 @@ template <typename B, typename R, typename Q>\nSC_BFER_ite<B,R,Q>\n::~SC_BFER_ite()\n{\n+ for (auto& d : this->duplicator)\n+ if (d != nullptr)\n+ {\n+ delete d;\n+ d = nullptr;\n+ }\n}\ntemplate <typename B, typename R, typename Q>\n@@ -140,11 +145,11 @@ void SC_BFER_ite<B,R,Q>\nsc_core::sc_report_handler::set_actions(sc_core::SC_INFO, sc_core::SC_DO_NOTHING);\nsc_core::sc_start(); // start simulation\n- for (auto i = 0; i < 7; i++)\n- if (this->duplicator[i] != nullptr)\n+ for (auto& d : this->duplicator)\n+ if (d != nullptr)\n{\n- delete this->duplicator[i];\n- this->duplicator[i] = nullptr;\n+ delete d;\n+ d = nullptr;\n}\ndelete this->router; this->router = nullptr;\n@@ -193,35 +198,35 @@ void SC_BFER_ite<B,R,Q>\nif (this->params_BFER_ite.coset)\n{\nsrc.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp0 .s_in );\n- dp0 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::U ]);\n- dp0 .s_out2 (crc.sc[+crc::tsk::build ].s_in [+crc::sck::build ::U_K1]);\n+ dp0 [0] (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::U ]);\n+ dp0 [1] (crc.sc[+crc::tsk::build ].s_in [+crc::sck::build ::U_K1]);\ncrc.sc [+crc::tsk::build ].s_out [+crc::sck::build ::U_K2](dp2 .s_in );\n- dp2 .s_out1 (csb.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n- dp2 .s_out2 (enc.sc[+enc::tsk::encode ].s_in [+enc::sck::encode ::U_K ]);\n+ dp2 [0] (csb.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n+ dp2 [1] (enc.sc[+enc::tsk::encode ].s_in [+enc::sck::encode ::U_K ]);\nenc.sc [+enc::tsk::encode ].s_out [+enc::sck::encode ::X_N ](dp3 .s_in );\n- dp3 .s_out1 (dp4 .s_in );\n- dp4 .s_out1 (csr.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n- dp4 .s_out2 (csi.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n- dp3 .s_out2 (itb.sc[+itl::tsk::interleave ].s_in [+itl::sck::interleave ::nat ]);\n+ dp3 [0] (dp4 .s_in );\n+ dp4 [0] (csr.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n+ dp4 [1] (csi.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n+ dp3 [1] (itb.sc[+itl::tsk::interleave ].s_in [+itl::sck::interleave ::nat ]);\nitb.sc [+itl::tsk::interleave ].s_out [+itl::sck::interleave ::itl ](mdm.sc[+mdm::tsk::modulate ].s_in [+mdm::sck::modulate ::X_N1]);\nif (this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos) {\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise_wg ].s_in [+chn::sck::add_noise_wg ::X_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::H_N ](dp6 .s_in );\n- dp6 .s_out1 (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::H_N ]);\n- dp6 .s_out2 (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::H_N ]);\n+ dp6 [0] (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::H_N ]);\n+ dp6 [1] (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::H_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in [+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in [+qnt::sck::process ::Y_N1]);\nqnt.sc[+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](dp5 .s_in );\n- dp5 .s_out1 (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::Y_N1]);\n- dp5 .s_out2 (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::Y_N1]);\n+ dp5 [0] (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::Y_N1]);\n+ dp5 [1] (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::Y_N1]);\nmdm.sc[+mdm::tsk::demodulate_wg ].s_out [+mdm::sck::demodulate_wg ::Y_N2](fnl .s_in1 );\n} else {\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise ].s_in [+chn::sck::add_noise ::X_N ]);\nchn.sc[+chn::tsk::add_noise ].s_out [+chn::sck::add_noise ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in [+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in [+qnt::sck::process ::Y_N1]);\nqnt.sc[+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](dp5 .s_in );\n- dp5 .s_out1 (mdm.sc[+mdm::tsk::tdemodulate ].s_in [+mdm::sck::tdemodulate ::Y_N1]);\n- dp5 .s_out2 (mdm.sc[+mdm::tsk::demodulate ].s_in [+mdm::sck::demodulate ::Y_N1]);\n+ dp5 [0] (mdm.sc[+mdm::tsk::tdemodulate ].s_in [+mdm::sck::tdemodulate ::Y_N1]);\n+ dp5 [1] (mdm.sc[+mdm::tsk::demodulate ].s_in [+mdm::sck::demodulate ::Y_N1]);\nmdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](fnl .s_in1 );\n}\nfnl .s_out (itl.sc[+itl::tsk::deinterleave ].s_in [+itl::sck::deinterleave ::itl ]);\n@@ -241,35 +246,35 @@ void SC_BFER_ite<B,R,Q>\ndch.sc [+dec::tsk::decode_siho ].s_out [+dec::sck::decode_siho ::V_K ](csb.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::in ]);\ncsb.sc [+cst::tsk::apply ].s_out [+cst::sck::apply ::out ](crc.sc[+crc::tsk::extract ].s_in [+crc::sck::extract ::V_K1]);\ncrc.sc [+crc::tsk::extract ].s_out [+crc::sck::extract ::V_K2](dp1 .s_in );\n- dp1 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::V ]);\n- dp1 .s_out2 (prd .s_in );\n+ dp1 [0] (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::V ]);\n+ dp1 [1] (prd .s_in );\n}\nelse // standard simulation\n{\nsrc.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp0 .s_in );\n- dp0 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::U ]);\n- dp0 .s_out2 (crc.sc[+crc::tsk::build ].s_in [+crc::sck::build ::U_K1]);\n+ dp0 [0] (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::U ]);\n+ dp0 [1] (crc.sc[+crc::tsk::build ].s_in [+crc::sck::build ::U_K1]);\ncrc.sc [+crc::tsk::build ].s_out [+crc::sck::build ::U_K2](enc.sc[+enc::tsk::encode ].s_in [+enc::sck::encode ::U_K ]);\nenc.sc [+enc::tsk::encode ].s_out [+enc::sck::encode ::X_N ](itb.sc[+itl::tsk::interleave ].s_in [+itl::sck::interleave ::nat ]);\nitb.sc [+itl::tsk::interleave ].s_out [+itl::sck::interleave ::itl ](mdm.sc[+mdm::tsk::modulate ].s_in [+mdm::sck::modulate ::X_N1]);\nif (this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos) {\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise_wg ].s_in [+chn::sck::add_noise_wg ::X_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::H_N ](dp6 .s_in );\n- dp6 .s_out1 (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::H_N ]);\n- dp6 .s_out2 (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::H_N ]);\n+ dp6 [0] (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::H_N ]);\n+ dp6 [1] (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::H_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in [+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in [+qnt::sck::process ::Y_N1]);\nqnt.sc[+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](dp5 .s_in );\n- dp5 .s_out1 (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::Y_N1]);\n- dp5 .s_out2 (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::Y_N1]);\n+ dp5 [0] (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::Y_N1]);\n+ dp5 [1] (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::Y_N1]);\nmdm.sc[+mdm::tsk::demodulate_wg ].s_out [+mdm::sck::demodulate_wg ::Y_N2](fnl .s_in1 );\n} else {\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise ].s_in [+chn::sck::add_noise ::X_N ]);\nchn.sc[+chn::tsk::add_noise ].s_out [+chn::sck::add_noise ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in [+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in [+qnt::sck::process ::Y_N1]);\nqnt.sc[+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](dp5 .s_in );\n- dp5 .s_out1 (mdm.sc[+mdm::tsk::tdemodulate ].s_in [+mdm::sck::tdemodulate ::Y_N1]);\n- dp5 .s_out2 (mdm.sc[+mdm::tsk::demodulate ].s_in [+mdm::sck::demodulate ::Y_N1]);\n+ dp5 [0] (mdm.sc[+mdm::tsk::tdemodulate ].s_in [+mdm::sck::tdemodulate ::Y_N1]);\n+ dp5 [1] (mdm.sc[+mdm::tsk::demodulate ].s_in [+mdm::sck::demodulate ::Y_N1]);\nmdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](fnl .s_in1 );\n}\nfnl .s_out (itl.sc[+itl::tsk::deinterleave ].s_in [+itl::sck::deinterleave ::itl ]);\n@@ -286,8 +291,8 @@ void SC_BFER_ite<B,R,Q>\n}\ndch.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](dp1 .s_in );\n- dp1 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::V ]);\n- dp1 .s_out2 (prd .s_in );\n+ dp1 [0] (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::V ]);\n+ dp1 [1] (prd .s_in );\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.hpp",
"new_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.hpp",
"diff": "@@ -22,7 +22,7 @@ class SC_BFER_ite : public BFER_ite<B,R,Q>\nprotected:\nmodule::Coset<B,Q> *coset_real_i;\n- tools::SC_Duplicator *duplicator[7];\n+ std::vector<tools::SC_Duplicator*> duplicator;\ntools::SC_Router *router;\ntools::SC_Funnel *funnel;\ntools::SC_Predicate *predicate;\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": "@@ -13,8 +13,7 @@ template <typename B, typename R, typename Q>\nSC_BFER_std<B,R,Q>\n::SC_BFER_std(const factory::BFER_std::parameters ¶ms_BFER_std)\n: BFER_std<B,R,Q>(params_BFER_std),\n-\n- duplicator{nullptr, nullptr, nullptr}\n+ duplicator(5, nullptr)\n{\nif (this->params_BFER_std.n_threads > 1)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"SystemC simulation does not support \"\n@@ -29,6 +28,12 @@ template <typename B, typename R, typename Q>\nSC_BFER_std<B,R,Q>\n::~SC_BFER_std()\n{\n+ for (auto& d : this->duplicator)\n+ if (d != nullptr)\n+ {\n+ delete d;\n+ d = nullptr;\n+ }\n}\ntemplate <typename B, typename R, typename Q>\n@@ -73,6 +78,7 @@ void SC_BFER_std<B,R,Q>\nthis->quantizer [tid] ->sc.create_module(+qnt::tsk::process );\nthis->codec [tid]->get_decoder_siho()->sc.create_module(+dec::tsk::decode_siho );\nthis->monitor_er[tid] ->sc.create_module(+mnt::tsk::check_errors );\n+ if (this->params_BFER_std.mutinfo) // this->monitor_mi[tid] != nullptr\nthis->monitor_mi[tid] ->sc.create_module(+mnt::tsk::get_mutual_info);\nif (this->params_BFER_std.coset)\n{\n@@ -90,22 +96,24 @@ void SC_BFER_std<B,R,Q>\nthis->create_sc_modules();\n- this->duplicator[0] = new tools::SC_Duplicator(\"Duplicator0\");\n+ this->duplicator[0] = new tools::SC_Duplicator(\"Duplicator_src\");\nif (this->params_BFER_std.coset)\n{\nthis->duplicator[1] = new tools::SC_Duplicator(\"Duplicator1\");\nthis->duplicator[2] = new tools::SC_Duplicator(\"Duplicator2\");\n}\n+ this->duplicator[3] = new tools::SC_Duplicator(\"Duplicator_pct\", this->params_BFER_std.mutinfo ? 2 : 1);\n+ this->duplicator[4] = new tools::SC_Duplicator(\"Duplicator_dmd\", this->params_BFER_std.mutinfo ? 2 : 1);\nthis->bind_sockets();\nsc_core::sc_report_handler::set_actions(sc_core::SC_INFO, sc_core::SC_DO_NOTHING);\nsc_core::sc_start(); // start simulation\n- for (auto i = 0; i < 3; i++)\n- if (this->duplicator[i] != nullptr)\n+ for (auto& d : this->duplicator)\n+ if (d != nullptr)\n{\n- delete this->duplicator[i];\n- this->duplicator[i] = nullptr;\n+ delete d;\n+ d = nullptr;\n}\n//////////////////////////////////////////////////////////////////////////////////////////////////////////////\n@@ -121,9 +129,11 @@ void SC_BFER_std<B,R,Q>\n{\nusing namespace module;\n- auto &dp0 = *this->duplicator[0];\n+ auto &dp_src = *this->duplicator[0];\nauto &dp1 = *this->duplicator[1];\nauto &dp2 = *this->duplicator[2];\n+ auto &dp_pct = *this->duplicator[3];\n+ auto &dp_dmd = *this->duplicator[4];\nauto &src = *this->source [0];\nauto &crc = *this->crc [0];\n@@ -139,28 +149,30 @@ void SC_BFER_std<B,R,Q>\nif (this->params_BFER_std.coset)\n{\n- src.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp0 .s_in );\n- dp0 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in[+mnt::sck::check_errors ::U ]);\n- dp0 .s_out2 (crc.sc[+crc::tsk::build ].s_in[+crc::sck::build ::U_K1]);\n+ src.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp_src .s_in );\n+ dp_src [0] (mnt.sc[+mnt::tsk::check_errors ].s_in[+mnt::sck::check_errors ::U ]);\n+ dp_src [1] (crc.sc[+crc::tsk::build ].s_in[+crc::sck::build ::U_K1]);\ncrc.sc [+crc::tsk::build ].s_out [+crc::sck::build ::U_K2](dp1 .s_in );\n- dp1 .s_out1 (csb.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::ref ]);\n- dp1 .s_out2 (enc.sc[+enc::tsk::encode ].s_in[+enc::sck::encode ::U_K ]);\n+ dp1 [0] (csb.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::ref ]);\n+ dp1 [1] (enc.sc[+enc::tsk::encode ].s_in[+enc::sck::encode ::U_K ]);\nenc.sc [+enc::tsk::encode ].s_out [+enc::sck::encode ::X_N ](dp2 .s_in );\n- dp2 .s_out1 (csr.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::ref ]);\n- dp2 .s_out2 (pct.sc[+pct::tsk::puncture ].s_in[+pct::sck::puncture ::X_N1]);\n- pct.sc [+pct::tsk::puncture ].s_out [+pct::sck::puncture ::X_N2](mdm.sc[+mdm::tsk::modulate ].s_in[+mdm::sck::modulate ::X_N1]);\n+ dp2 [0] (csr.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::ref ]);\n+ dp2 [1] (pct.sc[+pct::tsk::puncture ].s_in[+pct::sck::puncture ::X_N1]);\n+ pct.sc [+pct::tsk::puncture ].s_out [+pct::sck::puncture ::X_N2](dp_pct .s_in );\n+ dp_pct [0] (mdm.sc[+mdm::tsk::modulate ].s_in[+mdm::sck::modulate ::X_N1]);\nif (this->params_BFER_std.chn->type.find(\"RAYLEIGH\") != std::string::npos) { // Rayleigh chn\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise_wg ].s_in[+chn::sck::add_noise_wg ::X_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::H_N ](mdm.sc[+mdm::tsk::demodulate_wg].s_in[+mdm::sck::demodulate_wg::H_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in[+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](mdm.sc[+mdm::tsk::demodulate_wg].s_in[+mdm::sck::demodulate_wg::Y_N1]);\n- mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate_wg::Y_N2](qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\n+ mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate_wg::Y_N2](dp_dmd .s_in );\n} else { // additive channel (AWGN, USER, NO)\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise ].s_in[+chn::sck::add_noise ::X_N ]);\nchn.sc[+chn::tsk::add_noise ].s_out [+chn::sck::add_noise ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in[+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](mdm.sc[+mdm::tsk::demodulate ].s_in[+mdm::sck::demodulate ::Y_N1]);\n- mdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\n+ mdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](dp_dmd .s_in );\n}\n+ dp_dmd [0] (qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\nqnt.sc [+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](pct.sc[+pct::tsk::depuncture ].s_in[+pct::sck::depuncture ::Y_N1]);\npct.sc [+pct::tsk::depuncture ].s_out [+pct::sck::depuncture ::Y_N2](csr.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::in ]);\ncsr.sc [+cst::tsk::apply ].s_out [+cst::sck::apply ::out ](dec.sc[+dec::tsk::decode_siho ].s_in[+dec::sck::decode_siho ::Y_N ]);\n@@ -170,24 +182,26 @@ void SC_BFER_std<B,R,Q>\n}\nelse // standard simulation\n{\n- src.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp0 .s_in );\n- dp0 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in[+mnt::sck::check_errors ::U ]);\n- dp0 .s_out2 (crc.sc[+crc::tsk::build ].s_in[+crc::sck::build ::U_K1]);\n+ src.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp_src .s_in );\n+ dp_src [0] (mnt.sc[+mnt::tsk::check_errors ].s_in[+mnt::sck::check_errors ::U ]);\n+ dp_src [1] (crc.sc[+crc::tsk::build ].s_in[+crc::sck::build ::U_K1]);\ncrc.sc [+crc::tsk::build ].s_out [+crc::sck::build ::U_K2](enc.sc[+enc::tsk::encode ].s_in[+enc::sck::encode ::U_K ]);\nenc.sc [+enc::tsk::encode ].s_out [+enc::sck::encode ::X_N ](pct.sc[+pct::tsk::puncture ].s_in[+pct::sck::puncture ::X_N1]);\n- pct.sc [+pct::tsk::puncture ].s_out [+pct::sck::puncture ::X_N2](mdm.sc[+mdm::tsk::modulate ].s_in[+mdm::sck::modulate ::X_N1]);\n+ pct.sc [+pct::tsk::puncture ].s_out [+pct::sck::puncture ::X_N2](dp_pct .s_in );\n+ dp_pct [0] (mdm.sc[+mdm::tsk::modulate ].s_in[+mdm::sck::modulate ::X_N1]);\nif (this->params_BFER_std.chn->type.find(\"RAYLEIGH\") != std::string::npos) { // Rayleigh chn\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise_wg ].s_in[+chn::sck::add_noise_wg ::X_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::H_N ](mdm.sc[+mdm::tsk::demodulate_wg].s_in[+mdm::sck::demodulate_wg::H_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in[+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](mdm.sc[+mdm::tsk::demodulate_wg].s_in[+mdm::sck::demodulate_wg::Y_N1]);\n- mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate_wg::Y_N2](qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\n+ mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate_wg::Y_N2](dp_dmd .s_in );\n} else { // additive channel (AWGN, USER, NO)\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise ].s_in[+chn::sck::add_noise ::X_N ]);\nchn.sc[+chn::tsk::add_noise ].s_out [+chn::sck::add_noise ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in[+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](mdm.sc[+mdm::tsk::demodulate ].s_in[+mdm::sck::demodulate ::Y_N1]);\n- mdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\n+ mdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](dp_dmd .s_in );\n}\n+ dp_dmd [0] (qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\nqnt.sc [+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](pct.sc[+pct::tsk::depuncture ].s_in[+pct::sck::depuncture ::Y_N1]);\npct.sc [+pct::tsk::depuncture ].s_out [+pct::sck::depuncture ::Y_N2](dec.sc[+dec::tsk::decode_siho ].s_in[+dec::sck::decode_siho ::Y_N ]);\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]);\n@@ -196,13 +210,9 @@ void SC_BFER_std<B,R,Q>\nif (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+ auto &mnt_mi = *this->monitor_mi[0];\n+ dp_pct[1](mnt_mi.sc[+mnt::tsk::get_mutual_info].s_in[+mnt::sck::get_mutual_info::X]);\n+ dp_dmd[1](mnt_mi.sc[+mnt::tsk::get_mutual_info].s_in[+mnt::sck::get_mutual_info::Y]);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/SystemC/SC_BFER_std.hpp",
"new_path": "src/Simulation/BFER/Standard/SystemC/SC_BFER_std.hpp",
"diff": "@@ -15,7 +15,7 @@ template <typename B = int, typename R = float, typename Q = R>\nclass SC_BFER_std : public BFER_std<B,R,Q>\n{\nprotected:\n- tools::SC_Duplicator *duplicator[3];\n+ std::vector<tools::SC_Duplicator*> duplicator;\npublic:\nexplicit SC_BFER_std(const factory::BFER_std::parameters ¶ms_BFER_std);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/SystemC/SC_Duplicator.hpp",
"new_path": "src/Tools/SystemC/SC_Duplicator.hpp",
"diff": "@@ -19,23 +19,40 @@ class SC_Duplicator : sc_core::sc_module\nSC_HAS_PROCESS(SC_Duplicator);\npublic:\n- tlm_utils::simple_target_socket <SC_Duplicator> s_in;\n- tlm_utils::simple_initiator_socket<SC_Duplicator> s_out1;\n- tlm_utils::simple_initiator_socket<SC_Duplicator> s_out2;\n+ using SI_t = tlm_utils::simple_target_socket <SC_Duplicator>;\n+ using SO_t = tlm_utils::simple_initiator_socket<SC_Duplicator>;\n+\n+ SI s_in;\n+ std::vector<SO_t*> s_out;\npublic:\n- explicit SC_Duplicator(sc_core::sc_module_name name = \"SC_Duplicator\")\n- : sc_module(name), s_in(\"s_in\"), s_out1(\"s_out1\"), s_out2(\"s_out2\")\n+ explicit SC_Duplicator(sc_core::sc_module_name name = \"SC_Duplicator\", unsigned n_output = 2)\n+ : sc_module(name), s_in(\"s_in\"), s_out(n_output, nullptr)\n{\ns_in.register_b_transport(this, &SC_Duplicator::b_transport);\n+\n+ for (unsigned i = 0; i < n_output ; i++)\n+ s_out[i] = new SO_t((std::string(\"s_out\") + std::to_string(i)).c_str());\n+ }\n+\n+ ~SC_Duplicator()\n+ {\n+ for(auto& so: s_out)\n+ if (so != nullptr)\n+ delete so;\n+ }\n+\n+ SO_t& operator[](size_t idx)\n+ {\n+ return *s_out[idx];\n}\nprivate:\nvoid b_transport(tlm::tlm_generic_payload& trans, sc_core::sc_time& t)\n{\nsc_core::sc_time zero_time(sc_core::SC_ZERO_TIME);\n- s_out1->b_transport(trans, zero_time);\n- s_out2->b_transport(trans, zero_time);\n+ for (auto& so : s_out)\n+ (*so)->b_transport(trans, zero_time);\n}\n};\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Enhance SC_Duplicator for any number of output; Update consequently SC_BFER_ite and std; Use a vector of duplicators instead of a table in the lasts
|
8,483 |
21.08.2018 16:40:16
| -7,200 |
875baaf8817e8837ca8b44e3eb468337b7c617e3
|
Fiw SC_Duplicator::SI_t instantiation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/SystemC/SC_Duplicator.hpp",
"new_path": "src/Tools/SystemC/SC_Duplicator.hpp",
"diff": "@@ -22,7 +22,7 @@ public:\nusing SI_t = tlm_utils::simple_target_socket <SC_Duplicator>;\nusing SO_t = tlm_utils::simple_initiator_socket<SC_Duplicator>;\n- SI s_in;\n+ SI_t s_in;\nstd::vector<SO_t*> s_out;\npublic:\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fiw SC_Duplicator::SI_t instantiation
|
8,483 |
22.08.2018 10:50:15
| -7,200 |
04438e4e4554a30d82bc14af3af553c9fbb862ee
|
Fix the Monitor MPI reduction by setting correctly the virtual method signature
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp",
"new_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp",
"diff": "@@ -23,7 +23,7 @@ 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);\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": "@@ -52,7 +52,7 @@ Monitor_reduction_MPI<M>\ntemplate <class M>\nvoid Monitor_reduction_MPI<M>\n-::_reduce(bool fully, bool stop_simu)\n+::_reduce(bool fully)\n{\nfully = false;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the Monitor MPI reduction by setting correctly the virtual method signature
|
8,483 |
22.08.2018 14:06:07
| -7,200 |
c0afd6022cefb53a98838d12da43ed91614c2a34
|
Add to mutual_sort a new parameter that is the called function to compare and sort vectors.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.h",
"new_path": "src/Tools/general_utils.h",
"diff": "@@ -57,6 +57,15 @@ inline void mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<To>& vec_ordi\ntemplate <typename Ta, typename To>\ninline void mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<std::vector<To>>& vec_ordinate);\n+/*\n+ * Sort 'vec_abscissa' in function of the comp function and move the matching ordinate of 'vec_ordinate' by the same time.\n+ */\n+template <typename Ta, typename To, class Compare>\n+inline void mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<To>& vec_ordinate, Compare comp);\n+\n+template <typename Ta, typename To, class Compare>\n+inline void mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<std::vector<To>>& vec_ordinate, Compare comp);\n+\n/*\n* Eliminates all but the first element from every consecutive group of equivalent elements from the 'vec_abscissa' vector\n* and remove the matching ordinate of 'vec_ordinate' by the same time.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.hxx",
"new_path": "src/Tools/general_utils.hxx",
"diff": "@@ -35,19 +35,31 @@ std::size_t get_closest_index(BidirectionalIterator first, BidirectionalIterator\ntemplate <typename Ta, typename To>\nvoid mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<To>& vec_ordinate)\n+{\n+ mutual_sort(vec_abscissa, vec_ordinate, [](const Ta& a, const Ta& b){ return a < b; });\n+}\n+\n+template <typename Ta, typename To>\n+void mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<std::vector<To>>& vec_ordinate)\n+{\n+ mutual_sort(vec_abscissa, vec_ordinate, [](const Ta& a, const Ta& b){ return a < b; });\n+}\n+\n+template <typename Ta, typename To, class Compare>\n+void mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<To>& vec_ordinate, Compare comp)\n{\nassert(vec_abscissa.size() == vec_ordinate.size());\nfor (unsigned i = 1; i < vec_abscissa.size(); i++)\n- for (unsigned j = i; j > 0 && vec_abscissa[j] < vec_abscissa[j-1]; j--)\n+ for (unsigned j = i; j > 0 && comp(vec_abscissa[j], vec_abscissa[j-1]); j--)\n{\nstd::swap(vec_abscissa[j], vec_abscissa[j-1]); // order the x position\nstd::swap(vec_ordinate[j], vec_ordinate[j-1]); // the y follow their x, moving the same way\n}\n}\n-template <typename Ta, typename To>\n-void mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<std::vector<To>>& vec_ordinate)\n+template <typename Ta, typename To, class Compare>\n+void mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<std::vector<To>>& vec_ordinate, Compare comp)\n{\n#ifndef NDEBUG\nbool good = true;\n@@ -57,7 +69,7 @@ void mutual_sort(std::vector<Ta>& vec_abscissa, std::vector<std::vector<To>>& ve\n#endif\nfor (unsigned i = 1; i < vec_abscissa.size(); i++)\n- for (unsigned j = i; j > 0 && vec_abscissa[j] < vec_abscissa[j-1]; j--)\n+ for (unsigned j = i; j > 0 && comp(vec_abscissa[j], vec_abscissa[j-1]); j--)\n{\nstd::swap(vec_abscissa[j], vec_abscissa[j-1]); // order the x position\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add to mutual_sort a new parameter that is the called function to compare and sort vectors.
|
8,483 |
22.08.2018 14:06:38
| -7,200 |
64535339cd66e68bbd4f0424f6f2973148c69262
|
Add functionalities to Matrix and Full matrix and clean Sparse Matrix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.cpp",
"new_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.cpp",
"diff": "#include <algorithm>\n#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/general_utils.h\"\n#include \"Full_matrix.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::tools;\n-Full_matrix\n+template <typename T>\n+Full_matrix<T>\n::Full_matrix(const unsigned n_rows, const unsigned n_cols)\n: Matrix(n_rows, n_cols),\n- values(n_rows, std::vector<unsigned>(n_cols,0)),\n+ values(n_rows, std::vector<T>(n_cols,0)),\nrows_degrees(n_rows,0),\ncols_degrees(n_cols,0)\n{\n}\n-bool Full_matrix\n+template <typename T>\n+bool Full_matrix<T>\n::at(const size_t row_index, const size_t col_index) const\n{\ncheck_indexes(row_index, col_index);\n@@ -27,7 +30,8 @@ bool Full_matrix\nreturn values[row_index][col_index] != 0;\n}\n-void Full_matrix\n+template <typename T>\n+void Full_matrix<T>\n::add_connection(const size_t row_index, const size_t col_index)\n{\nif (at(row_index, col_index))\n@@ -48,7 +52,9 @@ void Full_matrix\nthis->n_connections++;\n}\n-void Full_matrix::rm_connection(const size_t row_index, const size_t col_index)\n+template <typename T>\n+void Full_matrix<T>\n+::rm_connection(const size_t row_index, const size_t col_index)\n{\nif(!at(row_index, col_index))\nreturn;\n@@ -66,7 +72,29 @@ void Full_matrix::rm_connection(const size_t row_index, const size_t col_index)\ncols_max_degree = *std::max_element(cols_degrees.begin(), cols_degrees.end());\n}\n-Full_matrix Full_matrix\n+template <typename T>\n+void Full_matrix<T>\n+::parse_connections()\n+{\n+ std::fill(rows_degrees.begin(), rows_degrees.end(), 0);\n+ std::fill(cols_degrees.begin(), cols_degrees.end(), 0);\n+ this->n_connections = 0;\n+\n+ for (size_t r = 0; r < get_n_rows(); r++)\n+ for (size_t c = 0; c < get_n_cols(); c++)\n+ if (values[r][c])\n+ {\n+ rows_degrees[r]++;\n+ cols_degrees[c]++;\n+ this->n_connections++;\n+ }\n+\n+ rows_max_degree = *std::max_element(rows_degrees.begin(), rows_degrees.end());\n+ cols_max_degree = *std::max_element(cols_degrees.begin(), cols_degrees.end());\n+}\n+\n+template <typename T>\n+Full_matrix<T> Full_matrix<T>\n::transpose() const\n{\nFull_matrix trans(*this);\n@@ -76,15 +104,51 @@ Full_matrix Full_matrix\nreturn trans;\n}\n-void Full_matrix\n+template <typename T>\n+void Full_matrix<T>\n::self_transpose()\n{\n- Matrix::self_transpose();\n+ // extend the vector to allow the swap of values and then resize it to the new transposed size\n+ switch(get_way())\n+ {\n+ case Way::HORIZONTAL:\n+ values.resize(get_n_cols(), std::vector<T>(get_n_rows()));\n+\n+ for (size_t r = 0; r < get_n_rows(); r++)\n+ for (size_t c = r + 1; c < get_n_rows(); c++)\n+ std::swap(values[r][c], values[c][r]);\n+\n+ for (size_t r = get_n_rows(); r < get_n_cols(); r++)\n+ for (size_t c = 0; c < get_n_rows(); c++)\n+ values[r][c] = values[c][r];\n+\n+ for (size_t r = 0; r < get_n_rows(); r++)\n+ values[r].resize(get_n_rows());\n+ break;\n+ case Way::VERTICAL:\n+ for (size_t r = 0; r < get_n_cols(); r++)\n+ values[r].resize(get_n_rows());\n+\n+ for (size_t r = 0; r < get_n_cols(); r++)\n+ for (size_t c = r + 1; c < get_n_cols(); c++)\n+ std::swap(values[r][c], values[c][r]);\n+\n+ for (size_t r = get_n_cols(); r < get_n_rows(); r++)\n+ for (size_t c = 0; c < get_n_cols(); c++)\n+ values[c][r] = values[r][c];\n+\n+ values.resize(get_n_cols());\n+ break;\n+ }\n+\n+ Matrix::self_transpose(); // transpose the matrix size and degrees\nstd::swap(cols_degrees, rows_degrees);\n+\n}\n-Full_matrix Full_matrix\n+template <typename T>\n+Full_matrix<T> Full_matrix<T>\n::turn(Way w) const\n{\nFull_matrix turned(*this);\n@@ -94,68 +158,48 @@ Full_matrix Full_matrix\nreturn turned;\n}\n-void Full_matrix\n-::sort_cols_per_density(Sort s)\n+template <typename T>\n+void Full_matrix<T>\n+::sort_cols_per_density(Sort order)\n{\n- // if (order == Sort::ASCENDING)\n- // {\n- // std::sort(this->col_to_rows.begin(), this->col_to_rows.end(),\n- // [](const std::vector<unsigned> &i1, const std::vector<unsigned> &i2) { return i1.size() < i2.size(); });\n- // }\n- // else // order == \"DSC\"\n- // {\n- // std::sort(this->col_to_rows.begin(), this->col_to_rows.end(),\n- // [](const std::vector<unsigned> &i1, const std::vector<unsigned> &i2) { return i1.size() > i2.size(); });\n- // }\n-\n- // for (auto &r : this->row_to_cols)\n- // r.clear();\n- // for (size_t i = 0; i < this->col_to_rows.size(); i++)\n- // for (size_t j = 0; j < this->col_to_rows[i].size(); j++)\n- // this->row_to_cols[this->col_to_rows[i][j]].push_back((unsigned)i);\n+ switch(order)\n+ {\n+ case Sort::ASCENDING:\n+ tools::mutual_sort(cols_degrees, values, [](size_t i1, size_t i2) { return i1 < i2; });\n+ break;\n+ case Sort::DESCENDING:\n+ tools::mutual_sort(cols_degrees, values, [](size_t i1, size_t i2) { return i1 > i2; });\n+ break;\n+ }\n}\n-void Full_matrix\n+template <typename T>\n+void Full_matrix<T>\n::print(bool transpose, std::ostream& os) const\n{\n- // if (transpose)\n- // {\n- // std::vector<unsigned> rows(this->n_rows, 0);\n-\n- // for (auto& col : this->col_to_rows)\n- // {\n- // // set the ones\n- // for (auto& row : col)\n- // rows[row] = 1;\n-\n- // for (auto& row : rows)\n- // os << row << \" \";\n-\n- // os << std::endl;\n-\n- // // reset the ones\n- // for (auto& row : col)\n- // rows[row] = 0;\n- // }\n- // }\n- // else\n- // {\n- // std::vector<unsigned> columns(this->n_cols, 0);\n-\n- // for (auto& row : this->row_to_cols)\n- // {\n- // // set the ones\n- // for (auto& col : row)\n- // columns[col] = 1;\n-\n- // for (auto& col : columns)\n- // os << col << \" \";\n-\n- // os << std::endl;\n-\n- // // reset the ones\n- // for (auto& col : row)\n- // columns[col] = 0;\n- // }\n- // }\n+ if (transpose)\n+ {\n+ for (size_t c = 0; c < get_n_cols(); c++)\n+ {\n+ for (size_t r = 0; r < get_n_rows(); r++)\n+ os << +values[r][c] << \" \";\n+ os << std::endl;\n+ }\n+ }\n+ else\n+ {\n+ for (size_t r = 0; r < get_n_rows(); r++)\n+ {\n+ for (size_t c = 0; c < get_n_cols(); c++)\n+ os << +values[r][c] << \" \";\n+ os << std::endl;\n+ }\n}\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+template class aff3ct::tools::Full_matrix< uint8_t>;\n+template class aff3ct::tools::Full_matrix<uint16_t>;\n+template class aff3ct::tools::Full_matrix<uint32_t>;\n+template class aff3ct::tools::Full_matrix<uint64_t>;\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.hpp",
"new_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.hpp",
"diff": "@@ -12,45 +12,59 @@ namespace aff3ct\n{\nnamespace tools\n{\n+/*\n+ * \\param T must be uint8_t or uint16_t or uint32_t or uint64_t\n+ */\n+\n+template <typename T = uint32_t>\nclass Full_matrix : public Matrix\n{\n-private:\n- std::vector<std::vector<unsigned>> values;\n-\n- std::vector<unsigned> rows_degrees;\n- std::vector<unsigned> cols_degrees;\n-\npublic:\n-\nFull_matrix(const unsigned n_rows = 0, const unsigned n_cols = 1);\nvirtual ~Full_matrix() = default;\n- inline const std::vector<unsigned>& get_cols_from_row(const size_t row_index) const\n+ inline const std::vector<T>& get_cols_from_row(const size_t row_index) const\n{\nreturn values[row_index];\n}\n- inline const std::vector<unsigned>& operator[](const size_t row_index) const\n+ inline const std::vector<T>& operator[](const size_t row_index) const\n+ {\n+ return get_cols_from_row(row_index);\n+ }\n+\n+ inline std::vector<T>& get_cols_from_row(const size_t row_index)\n+ {\n+ return values[row_index];\n+ }\n+\n+ inline std::vector<T>& operator[](const size_t row_index)\n{\nreturn get_cols_from_row(row_index);\n}\n/*\n- * return true if there is a connexion there\n+ * return true if there is a connection there\n*/\nbool at(const size_t row_index, const size_t col_index) const;\n/*\n- * Add a connection\n+ * Add a connection and update the rows and cols degrees values\n*/\nvoid add_connection(const size_t row_index, const size_t col_index);\n/*\n- * Remove the connection\n+ * Remove the connection and update the rows and cols degrees values\n*/\nvoid rm_connection(const size_t row_index, const size_t col_index);\n+ /*\n+ * Compute the rows and cols degrees values when the matrix values have been modified\n+ * without the use of 'add_connection' and 'rm_connection' interface\n+ */\n+ void parse_connections();\n+\n/*\n* Return the transposed matrix of this matrix\n*/\n@@ -69,13 +83,19 @@ public:\n/*\n* Sort the matrix per density of lines in ascending or descending order\n*/\n- void sort_cols_per_density(Sort s);\n+ void sort_cols_per_density(Sort order);\n/*\n* Print the matrix in its full view with 0s and 1s.\n* 'transpose' allow the print in its transposed view\n*/\nvoid print(bool transpose = false, std::ostream& os = std::cout) const;\n+\n+private:\n+ std::vector<std::vector<T>> values;\n+\n+ std::vector<size_t> rows_degrees;\n+ std::vector<size_t> cols_degrees;\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Matrix.cpp",
"new_path": "src/Tools/Algo/Matrix/Matrix.cpp",
"diff": "@@ -10,7 +10,7 @@ using namespace aff3ct;\nusing namespace aff3ct::tools;\nMatrix\n-::Matrix(const unsigned n_rows, const unsigned n_cols)\n+::Matrix(const size_t n_rows, const size_t n_cols)\n: n_rows (n_rows),\nn_cols (n_cols),\nrows_max_degree(0 ),\n@@ -41,6 +41,12 @@ void Matrix\n}\n}\n+Matrix::Way Matrix\n+::get_way() const\n+{\n+ return (get_n_cols() >= get_n_rows()) ? Way::HORIZONTAL : Way::VERTICAL;\n+}\n+\nfloat Matrix\n::compute_density() const\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Matrix.hpp",
"new_path": "src/Tools/Algo/Matrix/Matrix.hpp",
"diff": "@@ -12,15 +12,6 @@ namespace tools\n{\nclass Matrix\n{\n-private:\n- unsigned n_rows;\n- unsigned n_cols;\n-\n-protected:\n- unsigned rows_max_degree;\n- unsigned cols_max_degree;\n- unsigned n_connections;\n-\npublic:\nenum class Way\n{\n@@ -34,37 +25,37 @@ public:\nDESCENDING // meaning longest side depicts rows\n};\n- Matrix(const unsigned n_rows = 0, const unsigned n_cols = 1);\n+ Matrix(const size_t n_rows = 0, const size_t n_cols = 1);\nvirtual ~Matrix() = default;\n- inline unsigned get_n_rows() const\n+ inline size_t get_n_rows() const\n{\nreturn this->n_rows;\n}\n- inline unsigned get_n_cols() const\n+ inline size_t get_n_cols() const\n{\nreturn this->n_cols;\n}\n- inline unsigned get_rows_max_degree() const\n+ inline size_t get_rows_max_degree() const\n{\nreturn this->rows_max_degree;\n}\n- inline unsigned get_cols_max_degree() const\n+ inline size_t get_cols_max_degree() const\n{\nreturn this->cols_max_degree;\n}\n- inline unsigned get_n_connections() const\n+ inline size_t get_n_connections() const\n{\nreturn this->n_connections;\n}\n/*\n- * return true if there is a connexion there\n+ * return true if there is a connection there\n*/\nvirtual bool at(const size_t row_index, const size_t col_index) const = 0;\n@@ -89,7 +80,13 @@ public:\nvirtual void self_transpose();\n/*\n- * Return turn the matrix in horizontal or vertical way\n+ * \\return the way the matrix is : horizontal or vertical\n+ * if scaren then it is horizontal\n+ */\n+ Way get_way() const;\n+\n+ /*\n+ * \\brief turn the matrix in horizontal or vertical way, when square do nothing\n*/\nvoid self_turn(Way w);\n@@ -108,6 +105,16 @@ public:\n* 'transpose' allow the print in its transposed view\n*/\nvirtual void print(bool transpose = false, std::ostream& os = std::cout) const = 0;\n+\n+private:\n+ size_t n_rows;\n+ size_t n_cols;\n+\n+protected:\n+ size_t rows_max_degree;\n+ size_t cols_max_degree;\n+ size_t n_connections;\n+\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.cpp",
"new_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.cpp",
"diff": "@@ -10,7 +10,7 @@ using namespace aff3ct;\nusing namespace aff3ct::tools;\nSparse_matrix\n-::Sparse_matrix(const unsigned n_rows, const unsigned n_cols)\n+::Sparse_matrix(const size_t n_rows, const size_t n_cols)\n: Matrix(n_rows, n_cols),\nrow_to_cols(n_rows),\ncol_to_rows(n_cols)\n@@ -20,8 +20,6 @@ Sparse_matrix\nbool Sparse_matrix\n::at(const size_t row_index, const size_t col_index) const\n{\n- check_indexes(row_index, col_index);\n-\nauto it = std::find(this->row_to_cols[row_index].begin(), this->row_to_cols[row_index].end(), col_index);\nreturn (it != this->row_to_cols[row_index].end());\n}\n@@ -29,6 +27,8 @@ bool Sparse_matrix\nvoid Sparse_matrix\n::add_connection(const size_t row_index, const size_t col_index)\n{\n+ check_indexes(row_index, col_index);\n+\nif (at(row_index, col_index))\n{\nstd::stringstream message;\n@@ -37,16 +37,17 @@ void Sparse_matrix\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- this->row_to_cols[row_index].push_back((unsigned)col_index);\n- this->col_to_rows[col_index].push_back((unsigned)row_index);\n+ this->row_to_cols[row_index].push_back(col_index);\n+ this->col_to_rows[col_index].push_back(row_index);\n- this->rows_max_degree = std::max(get_rows_max_degree(), (unsigned)row_to_cols[row_index].size());\n- this->cols_max_degree = std::max(get_cols_max_degree(), (unsigned)col_to_rows[col_index].size());\n+ this->rows_max_degree = std::max(get_rows_max_degree(), row_to_cols[row_index].size());\n+ this->cols_max_degree = std::max(get_cols_max_degree(), col_to_rows[col_index].size());\nthis->n_connections++;\n}\n-void Sparse_matrix::rm_connection(const size_t row_index, const size_t col_index)\n+void Sparse_matrix\n+::rm_connection(const size_t row_index, const size_t col_index)\n{\ncheck_indexes(row_index, col_index);\n@@ -143,22 +144,23 @@ Sparse_matrix Sparse_matrix\nvoid Sparse_matrix\n::sort_cols_per_density(Sort order)\n{\n- if (order == Sort::ASCENDING)\n+ switch(order)\n{\n+ case Sort::ASCENDING:\nstd::sort(this->col_to_rows.begin(), this->col_to_rows.end(),\n- [](const std::vector<unsigned> &i1, const std::vector<unsigned> &i2) { return i1.size() < i2.size(); });\n- }\n- else // order == \"DSC\"\n- {\n+ [](const std::vector<size_t> &i1, const std::vector<size_t> &i2) { return i1.size() < i2.size(); });\n+ break;\n+ case Sort::DESCENDING:\nstd::sort(this->col_to_rows.begin(), this->col_to_rows.end(),\n- [](const std::vector<unsigned> &i1, const std::vector<unsigned> &i2) { return i1.size() > i2.size(); });\n+ [](const std::vector<size_t> &i1, const std::vector<size_t> &i2) { return i1.size() > i2.size(); });\n+ break;\n}\nfor (auto &r : this->row_to_cols)\nr.clear();\nfor (size_t i = 0; i < this->col_to_rows.size(); i++)\nfor (size_t j = 0; j < this->col_to_rows[i].size(); j++)\n- this->row_to_cols[this->col_to_rows[i][j]].push_back((unsigned)i);\n+ this->row_to_cols[this->col_to_rows[i][j]].push_back(i);\n}\nvoid Sparse_matrix\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.hpp",
"new_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.hpp",
"diff": "@@ -14,43 +14,39 @@ namespace tools\n{\nclass Sparse_matrix : public Matrix\n{\n-private:\n- std::vector<std::vector<unsigned>> row_to_cols;\n- std::vector<std::vector<unsigned>> col_to_rows;\n-\npublic:\n- Sparse_matrix(const unsigned n_rows = 0, const unsigned n_cols = 1);\n+ Sparse_matrix(const size_t n_rows = 0, const size_t n_cols = 1);\nvirtual ~Sparse_matrix() = default;\n- inline const std::vector<unsigned>& get_cols_from_row(const size_t row_index) const\n+ inline const std::vector<size_t>& get_cols_from_row(const size_t row_index) const\n{\nreturn this->row_to_cols[row_index];\n}\n- inline const std::vector<unsigned>& get_rows_from_col(const size_t col_index) const\n+ inline const std::vector<size_t>& get_rows_from_col(const size_t col_index) const\n{\nreturn this->col_to_rows[col_index];\n}\n- inline const std::vector<unsigned>& operator[](const size_t col_index) const\n+ inline const std::vector<size_t>& operator[](const size_t col_index) const\n{\nreturn this->get_rows_from_col(col_index);\n}\n- inline const std::vector<std::vector<unsigned>>& get_row_to_cols() const\n+ inline const std::vector<std::vector<size_t>>& get_row_to_cols() const\n{\nreturn this->row_to_cols;\n}\n- inline const std::vector<std::vector<unsigned>>& get_col_to_rows() const\n+ inline const std::vector<std::vector<size_t>>& get_col_to_rows() const\n{\nreturn this->col_to_rows;\n}\n/*\n- * return true if there is a connexion there\n+ * return true if there is a connection there\n*/\nbool at(const size_t row_index, const size_t col_index) const;\n@@ -83,13 +79,17 @@ public:\n* Sort the sparse matrix per density of lines\n* The \"order\" parameter can be \"ASC\" for ascending or \"DSC\" for descending\n*/\n- void sort_cols_per_density(Sort s);\n+ void sort_cols_per_density(Sort order);\n/*\n* Print the sparsed matrix in its full view with 0s and 1s.\n* 'transpose' allow the print in its transposed view\n*/\nvoid print(bool transpose = false, std::ostream& os = std::cout) const;\n+\n+private:\n+ std::vector<std::vector<size_t>> row_to_cols;\n+ std::vector<std::vector<size_t>> col_to_rows;\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add functionalities to Matrix and Full matrix and clean Sparse Matrix
|
8,483 |
23.08.2018 08:58:07
| -7,200 |
5288ca760f5fc6a0d7ad0649273d44b0362c2449
|
Add a check_GH function that return if G*H == 0. Add the matrix_utils files.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Matrix/matrix_utils.h",
"diff": "+#ifndef MATRIX_UTILS_H__\n+#define MATRIX_UTILS_H__\n+\n+#include \"Sparse_matrix/Sparse_matrix.hpp\"\n+#include \"Full_matrix/Full_matrix.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+/*\n+ * convert a binary sparse matrix to a binary full matrix\n+ */\n+template <typename T>\n+Full_matrix<T> sparse_to_full(const Sparse_matrix&);\n+\n+/*\n+ * convert a binary full matrix to a binary sparse matrix\n+ */\n+template <typename T>\n+Sparse_matrix full_to_sparse(const Full_matrix<T>&);\n+\n+/*\n+ * real general matrix multiplication: C = A * B\n+ * \\param A must be of size L * M\n+ * \\param B must be of size M * N\n+ * \\return C of size L * N\n+ */\n+template <typename T>\n+Full_matrix<T> rgemm(const Full_matrix<T>& A, const Full_matrix<T>& B);\n+\n+/*\n+ * real general matrix multiplication: C = A * B\n+ * \\param A must be of size L * M\n+ * \\param B must be of size M * N\n+ * \\return C of size L * N\n+ */\n+template <typename T>\n+Full_matrix<T> operator*(const Full_matrix<T>& A, const Full_matrix<T>& B);\n+\n+/*\n+ * real general matrix multiplication with B transposed: tC = A * tB, tB is B transposed, tC is C transposed\n+ * \\param A must be of size L * M\n+ * \\param tB must be of size N * M\n+ * \\return C of size L * N\n+ */\n+template <typename T>\n+Full_matrix<T> rgemmt(const Full_matrix<T>& A, const Full_matrix<T>& tB);\n+\n+/*\n+ * \\brief apply a modulo 2 on each element of the matrix\n+ */\n+template <typename T>\n+void modulo2(Full_matrix<T>&);\n+\n+/*\n+ * \\brief check if all elements of the matrix are zero\n+ */\n+template <typename T>\n+bool all_zero(const Full_matrix<T>&);\n+\n+\n+\n+}\n+}\n+\n+#include \"matrix_utils.hxx\"\n+\n+#endif // MATRIX_UTILS_H__\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Matrix/matrix_utils.hxx",
"diff": "+#ifndef MATRIX_UTILS_HXX__\n+#define MATRIX_UTILS_HXX__\n+\n+#include <sstream>\n+\n+#include \"matrix_utils.h\"\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+template <typename T>\n+Full_matrix<T> sparse_to_full(const Sparse_matrix& sparse)\n+{\n+ auto full = Full_matrix<T>::zero(sparse.get_n_rows(), sparse.get_n_cols());\n+\n+ for (unsigned i = 0; i < sparse.get_n_rows(); i++)\n+ for (unsigned j = 0; j < sparse.get_cols_from_row(i).size(); j++)\n+ full.add_connection(i,sparse.get_cols_from_row(i)[j]);\n+\n+ return full;\n+}\n+\n+template <typename T>\n+static Sparse_matrix full_to_sparse(const Full_matrix<T>& full)\n+{\n+ auto sparse = Sparse_matrix::zero(full.get_n_rows(), full.get_n_cols());\n+\n+ for (unsigned i = 0; i < full.get_n_rows(); i++)\n+ for (unsigned j = 0; j < full.get_n_cols(); j++)\n+ if (full[i][j])\n+ sparse.add_connection(i,j);\n+\n+ return sparse;\n+}\n+\n+template <typename T>\n+Full_matrix<T> rgemm(const Full_matrix<T>& A, const Full_matrix<T>& B)\n+{\n+ if (A.get_n_cols() != B.get_n_rows())\n+ {\n+ std::stringstream message;\n+ message << \"'A.get_n_cols()' is different to 'B.get_n_rows()' ('A.get_n_cols()' = \" << A.get_n_cols()\n+ << \", 'B.get_n_rows()' = \" << B.get_n_rows() << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto L = A.get_n_rows();\n+ auto M = B.get_n_rows();\n+ auto N = B.get_n_cols();\n+\n+ Full_matrix<T> C(L, N);\n+\n+ for (size_t l = 0; l < L; l++)\n+ for (size_t n = 0; n < N; n++)\n+ {\n+ T sum = 0;\n+ for (size_t m = 0; m < M; m++)\n+ sum += A[l][m] * B[m][n];\n+\n+ C[l][n] = sum;\n+ }\n+}\n+\n+template <typename T>\n+Full_matrix<T> operator*(const Full_matrix<T>& A, const Full_matrix<T>& B)\n+{\n+ return rgemm(A,B);\n+}\n+\n+template <typename T>\n+Full_matrix<T> rgemmt(const Full_matrix<T>& A, const Full_matrix<T>& tB)\n+{\n+ if (A.get_n_cols() != tB.get_n_cols())\n+ {\n+ std::stringstream message;\n+ message << \"'A.get_n_cols()' is different to 'tB.get_n_cols()' ('A.get_n_cols()' = \" << A.get_n_cols()\n+ << \", 'tB.get_n_cols()' = \" << tB.get_n_cols() << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto L = A.get_n_rows();\n+ auto N = tB.get_n_rows();\n+ auto M = tB.get_n_cols();\n+\n+ Full_matrix<T> C(L, N);\n+\n+ for (size_t l = 0; l < L; l++)\n+ for (size_t n = 0; n < N; n++)\n+ {\n+ T sum = 0;\n+ for (size_t m = 0; m < M; m++)\n+ sum += A[l][m] * tB[n][m];\n+\n+ C[l][n] = sum;\n+ }\n+\n+ return C;\n+}\n+\n+template <typename T>\n+void modulo2(Full_matrix<T>& M)\n+{\n+ for (size_t r = 0; r < M.get_n_rows(); r++)\n+ for (size_t c = 0; c < M.get_n_cols(); c++)\n+ M[r][c] &= (T)1;\n+}\n+\n+template <typename T>\n+bool all_zero(const Full_matrix<T>& M)\n+{\n+ bool all_z = true;\n+\n+ for (size_t r = 0; r < M.get_n_rows(); r++)\n+ for (size_t c = 0; c < M.get_n_cols(); c++)\n+ all_z &= M[r][c] == 0;\n+\n+ return all_z;\n+}\n+\n+}\n+}\n+\n+\n+#endif // MATRIX_UTILS_HXX__\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -194,17 +194,6 @@ void LDPC_matrix_handler\nLDPC_matrix_handler::form_diagonal(mat, swapped_cols);\nLDPC_matrix_handler::form_identity(mat);\n-\n- // for (size_t i = 0; i < M; i++) // erase the just created identity in the left part of H\n- // mat[i].erase( mat[i].begin(), mat[i].begin() + M );\n-\n- // // mat dimension is now N*M (above it was M*N)\n- // mat.resize(N, std::vector<bool>(N - M, 0));\n- // for (auto i = M; i < N; i++) // Add identity at the end\n- // mat[i][i-M] = 1;\n-\n-\n-\n// erase the just created M*M identity in the left part of H and add the K*K identity below\nmat.self_resize(N, K, Matrix::Origin::TOP_RIGHT);\nfor (auto i = M; i < N; i++) // Add rising diagonal identity at the end\n@@ -459,3 +448,20 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\nreturn MatriceCalcul;\n}\n+\n+bool LDPC_matrix_handler\n+::check_GH(Sparse_matrix H, Sparse_matrix G)\n+{\n+ G.self_turn(Matrix::Way::HORIZONTAL);\n+ H.self_turn(Matrix::Way::HORIZONTAL);\n+\n+ auto Gf = sparse_to_full<uint8_t>(G);\n+ auto Hf = sparse_to_full<uint8_t>(H);\n+ auto GH = rgemmt(Gf, Hf);\n+\n+ assert(GH.get_n_rows() == G.get_n_rows());\n+ assert(GH.get_n_cols() == H.get_n_rows());\n+\n+ modulo2(GH);\n+ return all_zeros(GH);\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "@@ -94,6 +94,13 @@ public:\n*/\nstatic LDPC_matrix invert_H2(const Sparse_matrix& H);\n+\n+ /*\n+ * \\brief Compute a G.H to check if result is a null vector\n+ * \\return true if G.H == 0\n+ */\n+ static bool check_GH(Sparse_matrix H, Sparse_matrix G);\n+\nprotected :\nstatic void transform_H_to_G(LDPC_matrix& mat, Positions_vector& info_bits_pos);\n};\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a check_GH function that return if G*H == 0. Add the matrix_utils files.
|
8,483 |
23.08.2018 08:59:29
| -7,200 |
b3c458cdff657d7e45eafab9bb1504645f7c05a7
|
Fix all_zeros call name
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/matrix_utils.h",
"new_path": "src/Tools/Algo/Matrix/matrix_utils.h",
"diff": "@@ -57,7 +57,7 @@ void modulo2(Full_matrix<T>&);\n* \\brief check if all elements of the matrix are zero\n*/\ntemplate <typename T>\n-bool all_zero(const Full_matrix<T>&);\n+bool all_zeros(const Full_matrix<T>&);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/matrix_utils.hxx",
"new_path": "src/Tools/Algo/Matrix/matrix_utils.hxx",
"diff": "@@ -109,7 +109,7 @@ void modulo2(Full_matrix<T>& M)\n}\ntemplate <typename T>\n-bool all_zero(const Full_matrix<T>& M)\n+bool all_zeros(const Full_matrix<T>& M)\n{\nbool all_z = true;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix all_zeros call name
|
8,483 |
23.08.2018 10:44:08
| -7,200 |
da967a467dcfe6bb9fc1bd64c7008f0a5389f8e2
|
transform_H_to_G return G instead of modifying H. Force the way of the input matrixes to not loose time by turning them
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Matrix.cpp",
"new_path": "src/Tools/Algo/Matrix/Matrix.cpp",
"diff": "@@ -81,9 +81,59 @@ void Matrix\n}\n+\n+bool Matrix\n+::is_of_way(Way w) const noexcept\n+{\n+ return get_way() == w;\n+}\n+\n+void Matrix\n+::is_of_way_throw(Way w) const\n+{\n+ if (!is_of_way(w))\n+ {\n+ std::stringstream message;\n+ message << \"This matrix way ('\" << way_to_str(get_way()) << \"') is not same as the given checked one ('\"\n+ << way_to_str(w) << \"').\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n+\n+\n+std::string Matrix\n+::way_to_str(Way w)\n+{\n+ std::string str;\n+\n+ switch(w)\n+ {\n+ case Way::HORIZONTAL:\n+ str = \"HORIZONTAL\";\n+ break;\n+ case Way::VERTICAL:\n+ str = \"VERTICAL\";\n+ break;\n+ }\n+\n+ if (str.empty()) // this 'if' is a test outside the switch case (instead of default) to keep the compiler check that all\n+ // cases of 'Way' are well represented.\n+ {\n+ std::stringstream message;\n+ message << \"The way 'w' does not represent a matrix way ('w' = \" << (short)w << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return str;\n+}\n+\n+\n+\n+\n+\nstd::ostream& operator<<(std::ostream& os, const Matrix& sm)\n{\nsm.print(0, os);\nreturn os;\n}\n\\ No newline at end of file\n-\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Matrix.hpp",
"new_path": "src/Tools/Algo/Matrix/Matrix.hpp",
"diff": "@@ -18,6 +18,7 @@ public:\nHORIZONTAL, // meaning longest side depicts columns,\nVERTICAL // meaning longest side depicts rows\n};\n+ static std::string way_to_str(Way w);\nenum class Sort\n{\n@@ -120,6 +121,11 @@ public:\n*/\nvirtual void print(bool transpose = false, std::ostream& os = std::cout) const = 0;\n+\n+ bool is_of_way (Way w) const noexcept;\n+ void is_of_way_throw(Way w) const;\n+\n+\nprivate:\nsize_t n_rows;\nsize_t n_cols;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/matrix_utils.hxx",
"new_path": "src/Tools/Algo/Matrix/matrix_utils.hxx",
"diff": "@@ -24,7 +24,7 @@ Full_matrix<T> sparse_to_full(const Sparse_matrix& sparse)\n}\ntemplate <typename T>\n-static Sparse_matrix full_to_sparse(const Full_matrix<T>& full)\n+Sparse_matrix full_to_sparse(const Full_matrix<T>& full)\n{\nauto sparse = Sparse_matrix::zero(full.get_n_rows(), full.get_n_cols());\n@@ -62,6 +62,8 @@ Full_matrix<T> rgemm(const Full_matrix<T>& A, const Full_matrix<T>& B)\nC[l][n] = sum;\n}\n+\n+ return C;\n}\ntemplate <typename T>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -173,37 +173,38 @@ bool LDPC_matrix_handler\nSparse_matrix LDPC_matrix_handler\n::transform_H_to_G(const Sparse_matrix& H, Positions_vector& info_bits_pos)\n{\n- auto Ht = H.turn(Matrix::Way::HORIZONTAL);\n- LDPC_matrix mat = sparse_to_full<LDPC_matrix::value_type>(Ht);\n+ H.is_of_way_throw(Matrix::Way::HORIZONTAL);\n+ LDPC_matrix Hf = sparse_to_full<LDPC_matrix::value_type>(H);\n- LDPC_matrix_handler::transform_H_to_G(mat, info_bits_pos);\n+ auto Gf = LDPC_matrix_handler::transform_H_to_G(Hf, info_bits_pos);\n- return full_to_sparse(mat);\n+ return full_to_sparse(Gf);\n}\n-void LDPC_matrix_handler\n-::transform_H_to_G(LDPC_matrix& mat, Positions_vector& info_bits_pos)\n+LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n+::transform_H_to_G(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n{\n- mat.self_turn(Matrix::Way::HORIZONTAL);\n+ H.is_of_way_throw(Matrix::Way::HORIZONTAL);\n+ auto G = H;\n- auto M = mat.get_n_rows();\n- auto N = mat.get_n_cols();\n+ auto M = G.get_n_rows();\n+ auto N = G.get_n_cols();\nauto K = N - M;\nPositions_vector swapped_cols;\n- LDPC_matrix_handler::form_diagonal(mat, swapped_cols);\n- LDPC_matrix_handler::form_identity(mat);\n+ LDPC_matrix_handler::form_diagonal(G, swapped_cols);\n+ LDPC_matrix_handler::form_identity(G);\n// erase the just created M*M identity in the left part of H and add the K*K identity below\n- mat.self_resize(N, K, Matrix::Origin::TOP_RIGHT);\n+ G.self_resize(N, K, Matrix::Origin::TOP_RIGHT);\nfor (auto i = M; i < N; i++) // Add rising diagonal identity at the end\n- mat[i][i - M] = 1;\n+ G[i][i - M] = 1;\n// G is now VERTICAL\n// Re-organization: get G\nfor (auto l = (swapped_cols.size() / 2); l > 0; l--)\n- std::swap(mat[swapped_cols[l*2-2]], mat[swapped_cols[l*2-1]]);\n+ std::swap(G[swapped_cols[l*2-2]], G[swapped_cols[l*2-1]]);\n// return info bits positions\ninfo_bits_pos.resize(K);\n@@ -215,6 +216,11 @@ void LDPC_matrix_handler\nstd::swap(bits_pos[swapped_cols[l*2-2]], bits_pos[swapped_cols[l*2-1]]);\nstd::copy(bits_pos.begin() + M, bits_pos.end(), info_bits_pos.begin());\n+\n+ if (!check_GH(H, G))\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"G and H do not fit (G*H != 0).\");\n+\n+ return G;\n}\nvoid LDPC_matrix_handler\n@@ -358,7 +364,6 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n{\nusing V = LDPC_matrix::value_type;\n-\nauto H = _H.turn(Matrix::Way::HORIZONTAL);\nauto M = H.get_n_rows();\n@@ -450,18 +455,46 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n}\nbool LDPC_matrix_handler\n-::check_GH(Sparse_matrix H, Sparse_matrix G)\n+::check_GH(const Sparse_matrix& H, const Sparse_matrix& G)\n{\n- G.self_turn(Matrix::Way::HORIZONTAL);\n- H.self_turn(Matrix::Way::HORIZONTAL);\n-\nauto Gf = sparse_to_full<uint8_t>(G);\nauto Hf = sparse_to_full<uint8_t>(H);\n- auto GH = rgemmt(Gf, Hf);\n- assert(GH.get_n_rows() == G.get_n_rows());\n- assert(GH.get_n_cols() == H.get_n_rows());\n+ return check_GH(Hf, Gf);\n+}\n+\n+bool LDPC_matrix_handler\n+::check_GH(const LDPC_matrix& H, const LDPC_matrix& G)\n+{\n+ LDPC_matrix GH;\n+\n+ switch(H.get_way())\n+ {\n+ case Matrix::Way::HORIZONTAL:\n+ switch(G.get_way())\n+ {\n+ case Matrix::Way::HORIZONTAL:\n+ GH = rgemmt(H, G);\n+ break;\n+ case Matrix::Way::VERTICAL:\n+ GH = rgemm(H, G);\n+ break;\n+ }\n+ break;\n+ case Matrix::Way::VERTICAL:\n+ switch(G.get_way())\n+ {\n+ case Matrix::Way::HORIZONTAL:\n+ GH = rgemm(G, H);\n+ break;\n+ case Matrix::Way::VERTICAL:\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"G and H can't be both in VERTICAL way.\");\n+ break;\n+ }\n+ break;\n+ }\nmodulo2(GH);\n+\nreturn all_zeros(GH);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "@@ -72,6 +72,7 @@ public:\n* Return also the information bits positions in the returned G matrix.\n*/\nstatic Sparse_matrix transform_H_to_G(const Sparse_matrix& H, Positions_vector& info_bits_pos);\n+ static LDPC_matrix transform_H_to_G(const LDPC_matrix& H, Positions_vector& info_bits_pos);\n/*\n* integrate an interleaver inside the matrix to avoid this step.\n@@ -97,12 +98,11 @@ public:\n/*\n* \\brief Compute a G.H to check if result is a null vector\n+ * H and G can be permuted, the function handle their order\n* \\return true if G.H == 0\n*/\n- static bool check_GH(Sparse_matrix H, Sparse_matrix G);\n-\n-protected :\n- static void transform_H_to_G(LDPC_matrix& mat, Positions_vector& info_bits_pos);\n+ static bool check_GH(const Sparse_matrix& H, const Sparse_matrix& G);\n+ static bool check_GH(const LDPC_matrix& H, const LDPC_matrix& G);\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
transform_H_to_G return G instead of modifying H. Force the way of the input matrixes to not loose time by turning them
|
8,483 |
23.08.2018 13:27:45
| -7,200 |
3dd07f589f82a109e3245cef5c0b06578b91011a
|
Come back to original SC_Duplicator; Move some duplicator call in bindings to avoid seg fault
|
[
{
"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": "@@ -169,11 +169,7 @@ void SC_BFER_ite<B,R,Q>\n{\nauto &dp0 = *this->duplicator[0];\nauto &dp1 = *this->duplicator[1];\n- auto &dp2 = *this->duplicator[2];\n- auto &dp3 = *this->duplicator[3];\n- auto &dp4 = *this->duplicator[4];\nauto &dp5 = *this->duplicator[5];\n- auto &dp6 = *this->duplicator[6];\nauto &rtr = *this->router;\nauto &fnl = *this->funnel;\n@@ -197,36 +193,41 @@ void SC_BFER_ite<B,R,Q>\nusing namespace module;\nif (this->params_BFER_ite.coset)\n{\n+ auto &dp2 = *this->duplicator[2];\n+ auto &dp3 = *this->duplicator[3];\n+ auto &dp4 = *this->duplicator[4];\n+\nsrc.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp0 .s_in );\n- dp0 [0] (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::U ]);\n- dp0 [1] (crc.sc[+crc::tsk::build ].s_in [+crc::sck::build ::U_K1]);\n+ dp0 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::U ]);\n+ dp0 .s_out2 (crc.sc[+crc::tsk::build ].s_in [+crc::sck::build ::U_K1]);\ncrc.sc [+crc::tsk::build ].s_out [+crc::sck::build ::U_K2](dp2 .s_in );\n- dp2 [0] (csb.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n- dp2 [1] (enc.sc[+enc::tsk::encode ].s_in [+enc::sck::encode ::U_K ]);\n+ dp2 .s_out1 (csb.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n+ dp2 .s_out2 (enc.sc[+enc::tsk::encode ].s_in [+enc::sck::encode ::U_K ]);\nenc.sc [+enc::tsk::encode ].s_out [+enc::sck::encode ::X_N ](dp3 .s_in );\n- dp3 [0] (dp4 .s_in );\n- dp4 [0] (csr.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n- dp4 [1] (csi.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n- dp3 [1] (itb.sc[+itl::tsk::interleave ].s_in [+itl::sck::interleave ::nat ]);\n+ dp3 .s_out1 (dp4 .s_in );\n+ dp4 .s_out1 (csr.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n+ dp4 .s_out2 (csi.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::ref ]);\n+ dp3 .s_out2 (itb.sc[+itl::tsk::interleave ].s_in [+itl::sck::interleave ::nat ]);\nitb.sc [+itl::tsk::interleave ].s_out [+itl::sck::interleave ::itl ](mdm.sc[+mdm::tsk::modulate ].s_in [+mdm::sck::modulate ::X_N1]);\nif (this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos) {\n+ auto &dp6 = *this->duplicator[6];\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise_wg ].s_in [+chn::sck::add_noise_wg ::X_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::H_N ](dp6 .s_in );\n- dp6 [0] (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::H_N ]);\n- dp6 [1] (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::H_N ]);\n+ dp6 .s_out1 (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::H_N ]);\n+ dp6 .s_out2 (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::H_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in [+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in [+qnt::sck::process ::Y_N1]);\nqnt.sc[+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](dp5 .s_in );\n- dp5 [0] (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::Y_N1]);\n- dp5 [1] (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::Y_N1]);\n+ dp5 .s_out1 (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::Y_N1]);\n+ dp5 .s_out2 (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::Y_N1]);\nmdm.sc[+mdm::tsk::demodulate_wg ].s_out [+mdm::sck::demodulate_wg ::Y_N2](fnl .s_in1 );\n} else {\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise ].s_in [+chn::sck::add_noise ::X_N ]);\nchn.sc[+chn::tsk::add_noise ].s_out [+chn::sck::add_noise ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in [+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in [+qnt::sck::process ::Y_N1]);\nqnt.sc[+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](dp5 .s_in );\n- dp5 [0] (mdm.sc[+mdm::tsk::tdemodulate ].s_in [+mdm::sck::tdemodulate ::Y_N1]);\n- dp5 [1] (mdm.sc[+mdm::tsk::demodulate ].s_in [+mdm::sck::demodulate ::Y_N1]);\n+ dp5 .s_out1 (mdm.sc[+mdm::tsk::tdemodulate ].s_in [+mdm::sck::tdemodulate ::Y_N1]);\n+ dp5 .s_out2 (mdm.sc[+mdm::tsk::demodulate ].s_in [+mdm::sck::demodulate ::Y_N1]);\nmdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](fnl .s_in1 );\n}\nfnl .s_out (itl.sc[+itl::tsk::deinterleave ].s_in [+itl::sck::deinterleave ::itl ]);\n@@ -246,35 +247,36 @@ void SC_BFER_ite<B,R,Q>\ndch.sc [+dec::tsk::decode_siho ].s_out [+dec::sck::decode_siho ::V_K ](csb.sc[+cst::tsk::apply ].s_in [+cst::sck::apply ::in ]);\ncsb.sc [+cst::tsk::apply ].s_out [+cst::sck::apply ::out ](crc.sc[+crc::tsk::extract ].s_in [+crc::sck::extract ::V_K1]);\ncrc.sc [+crc::tsk::extract ].s_out [+crc::sck::extract ::V_K2](dp1 .s_in );\n- dp1 [0] (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::V ]);\n- dp1 [1] (prd .s_in );\n+ dp1 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::V ]);\n+ dp1 .s_out2 (prd .s_in );\n}\nelse // standard simulation\n{\nsrc.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp0 .s_in );\n- dp0 [0] (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::U ]);\n- dp0 [1] (crc.sc[+crc::tsk::build ].s_in [+crc::sck::build ::U_K1]);\n+ dp0 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::U ]);\n+ dp0 .s_out2 (crc.sc[+crc::tsk::build ].s_in [+crc::sck::build ::U_K1]);\ncrc.sc [+crc::tsk::build ].s_out [+crc::sck::build ::U_K2](enc.sc[+enc::tsk::encode ].s_in [+enc::sck::encode ::U_K ]);\nenc.sc [+enc::tsk::encode ].s_out [+enc::sck::encode ::X_N ](itb.sc[+itl::tsk::interleave ].s_in [+itl::sck::interleave ::nat ]);\nitb.sc [+itl::tsk::interleave ].s_out [+itl::sck::interleave ::itl ](mdm.sc[+mdm::tsk::modulate ].s_in [+mdm::sck::modulate ::X_N1]);\nif (this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos) {\n+ auto &dp6 = *this->duplicator[6];\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise_wg ].s_in [+chn::sck::add_noise_wg ::X_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::H_N ](dp6 .s_in );\n- dp6 [0] (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::H_N ]);\n- dp6 [1] (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::H_N ]);\n+ dp6 .s_out1 (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::H_N ]);\n+ dp6 .s_out2 (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::H_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in [+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in [+qnt::sck::process ::Y_N1]);\nqnt.sc[+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](dp5 .s_in );\n- dp5 [0] (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::Y_N1]);\n- dp5 [1] (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::Y_N1]);\n+ dp5 .s_out1 (mdm.sc[+mdm::tsk::tdemodulate_wg].s_in [+mdm::sck::tdemodulate_wg::Y_N1]);\n+ dp5 .s_out2 (mdm.sc[+mdm::tsk::demodulate_wg ].s_in [+mdm::sck::demodulate_wg ::Y_N1]);\nmdm.sc[+mdm::tsk::demodulate_wg ].s_out [+mdm::sck::demodulate_wg ::Y_N2](fnl .s_in1 );\n} else {\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise ].s_in [+chn::sck::add_noise ::X_N ]);\nchn.sc[+chn::tsk::add_noise ].s_out [+chn::sck::add_noise ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in [+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in [+qnt::sck::process ::Y_N1]);\nqnt.sc[+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](dp5 .s_in );\n- dp5 [0] (mdm.sc[+mdm::tsk::tdemodulate ].s_in [+mdm::sck::tdemodulate ::Y_N1]);\n- dp5 [1] (mdm.sc[+mdm::tsk::demodulate ].s_in [+mdm::sck::demodulate ::Y_N1]);\n+ dp5 .s_out1 (mdm.sc[+mdm::tsk::tdemodulate ].s_in [+mdm::sck::tdemodulate ::Y_N1]);\n+ dp5 .s_out2 (mdm.sc[+mdm::tsk::demodulate ].s_in [+mdm::sck::demodulate ::Y_N1]);\nmdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](fnl .s_in1 );\n}\nfnl .s_out (itl.sc[+itl::tsk::deinterleave ].s_in [+itl::sck::deinterleave ::itl ]);\n@@ -291,8 +293,8 @@ void SC_BFER_ite<B,R,Q>\n}\ndch.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](dp1 .s_in );\n- dp1 [0] (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::V ]);\n- dp1 [1] (prd .s_in );\n+ dp1 .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in [+mnt::sck::check_errors ::V ]);\n+ dp1 .s_out2 (prd .s_in );\n}\n}\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": "@@ -13,15 +13,19 @@ template <typename B, typename R, typename Q>\nSC_BFER_std<B,R,Q>\n::SC_BFER_std(const factory::BFER_std::parameters ¶ms_BFER_std)\n: BFER_std<B,R,Q>(params_BFER_std),\n- duplicator(5, nullptr)\n+ duplicator(3, nullptr)\n{\nif (this->params_BFER_std.n_threads > 1)\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"SystemC simulation does not support \"\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"BFER SystemC simulation does not support \"\n\"multi-threading.\");\nif (params_BFER_std.coded_monitoring)\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"SystemC simulation does not support the coded \"\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"BFER SystemC simulation does not support the coded \"\n\"monitoring.\");\n+\n+ if (params_BFER_std.mutinfo)\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"BFER SystemC simulation does not support the mututal\n+ information computation.\");\n}\ntemplate <typename B, typename R, typename Q>\n@@ -86,6 +90,13 @@ void SC_BFER_std<B,R,Q>\nthis->coset_bit [tid]->sc.create_module(+cst::tsk::apply);\n}\nthis->crc[tid]->sc.create_module(+crc::tsk::extract);\n+\n+ this->duplicator[0] = new tools::SC_Duplicator(\"Duplicator_src\");\n+ if (this->params_BFER_std.coset)\n+ {\n+ this->duplicator[1] = new tools::SC_Duplicator(\"Duplicator1\");\n+ this->duplicator[2] = new tools::SC_Duplicator(\"Duplicator2\");\n+ }\n}\ntemplate <typename B, typename R, typename Q>\n@@ -96,15 +107,6 @@ void SC_BFER_std<B,R,Q>\nthis->create_sc_modules();\n- this->duplicator[0] = new tools::SC_Duplicator(\"Duplicator_src\");\n- if (this->params_BFER_std.coset)\n- {\n- this->duplicator[1] = new tools::SC_Duplicator(\"Duplicator1\");\n- this->duplicator[2] = new tools::SC_Duplicator(\"Duplicator2\");\n- }\n- this->duplicator[3] = new tools::SC_Duplicator(\"Duplicator_pct\", this->params_BFER_std.mutinfo ? 2 : 1);\n- this->duplicator[4] = new tools::SC_Duplicator(\"Duplicator_dmd\", this->params_BFER_std.mutinfo ? 2 : 1);\n-\nthis->bind_sockets();\nsc_core::sc_report_handler::set_actions(sc_core::SC_INFO, sc_core::SC_DO_NOTHING);\nsc_core::sc_start(); // start simulation\n@@ -130,10 +132,6 @@ void SC_BFER_std<B,R,Q>\nusing namespace module;\nauto &dp_src = *this->duplicator[0];\n- auto &dp1 = *this->duplicator[1];\n- auto &dp2 = *this->duplicator[2];\n- auto &dp_pct = *this->duplicator[3];\n- auto &dp_dmd = *this->duplicator[4];\nauto &src = *this->source [0];\nauto &crc = *this->crc [0];\n@@ -149,30 +147,31 @@ void SC_BFER_std<B,R,Q>\nif (this->params_BFER_std.coset)\n{\n+ auto &dp1 = *this->duplicator[1];\n+ auto &dp2 = *this->duplicator[2];\n+\nsrc.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp_src .s_in );\n- dp_src [0] (mnt.sc[+mnt::tsk::check_errors ].s_in[+mnt::sck::check_errors ::U ]);\n- dp_src [1] (crc.sc[+crc::tsk::build ].s_in[+crc::sck::build ::U_K1]);\n+ dp_src .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in[+mnt::sck::check_errors ::U ]);\n+ dp_src .s_out2 (crc.sc[+crc::tsk::build ].s_in[+crc::sck::build ::U_K1]);\ncrc.sc [+crc::tsk::build ].s_out [+crc::sck::build ::U_K2](dp1 .s_in );\n- dp1 [0] (csb.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::ref ]);\n- dp1 [1] (enc.sc[+enc::tsk::encode ].s_in[+enc::sck::encode ::U_K ]);\n+ dp1 .s_out1 (csb.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::ref ]);\n+ dp1 .s_out2 (enc.sc[+enc::tsk::encode ].s_in[+enc::sck::encode ::U_K ]);\nenc.sc [+enc::tsk::encode ].s_out [+enc::sck::encode ::X_N ](dp2 .s_in );\n- dp2 [0] (csr.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::ref ]);\n- dp2 [1] (pct.sc[+pct::tsk::puncture ].s_in[+pct::sck::puncture ::X_N1]);\n- pct.sc [+pct::tsk::puncture ].s_out [+pct::sck::puncture ::X_N2](dp_pct .s_in );\n- dp_pct [0] (mdm.sc[+mdm::tsk::modulate ].s_in[+mdm::sck::modulate ::X_N1]);\n+ dp2 .s_out1 (csr.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::ref ]);\n+ dp2 .s_out2 (pct.sc[+pct::tsk::puncture ].s_in[+pct::sck::puncture ::X_N1]);\n+ pct.sc [+pct::tsk::puncture ].s_out [+pct::sck::puncture ::X_N2](mdm.sc[+mdm::tsk::modulate ].s_in[+mdm::sck::modulate ::X_N1]);\nif (this->params_BFER_std.chn->type.find(\"RAYLEIGH\") != std::string::npos) { // Rayleigh chn\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise_wg ].s_in[+chn::sck::add_noise_wg ::X_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::H_N ](mdm.sc[+mdm::tsk::demodulate_wg].s_in[+mdm::sck::demodulate_wg::H_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in[+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](mdm.sc[+mdm::tsk::demodulate_wg].s_in[+mdm::sck::demodulate_wg::Y_N1]);\n- mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate_wg::Y_N2](dp_dmd .s_in );\n+ mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate_wg::Y_N2](qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\n} else { // additive channel (AWGN, USER, NO)\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise ].s_in[+chn::sck::add_noise ::X_N ]);\nchn.sc[+chn::tsk::add_noise ].s_out [+chn::sck::add_noise ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in[+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](mdm.sc[+mdm::tsk::demodulate ].s_in[+mdm::sck::demodulate ::Y_N1]);\n- mdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](dp_dmd .s_in );\n+ mdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\n}\n- dp_dmd [0] (qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\nqnt.sc [+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](pct.sc[+pct::tsk::depuncture ].s_in[+pct::sck::depuncture ::Y_N1]);\npct.sc [+pct::tsk::depuncture ].s_out [+pct::sck::depuncture ::Y_N2](csr.sc[+cst::tsk::apply ].s_in[+cst::sck::apply ::in ]);\ncsr.sc [+cst::tsk::apply ].s_out [+cst::sck::apply ::out ](dec.sc[+dec::tsk::decode_siho ].s_in[+dec::sck::decode_siho ::Y_N ]);\n@@ -183,37 +182,28 @@ void SC_BFER_std<B,R,Q>\nelse // standard simulation\n{\nsrc.sc [+src::tsk::generate ].s_out [+src::sck::generate ::U_K ](dp_src .s_in );\n- dp_src [0] (mnt.sc[+mnt::tsk::check_errors ].s_in[+mnt::sck::check_errors ::U ]);\n- dp_src [1] (crc.sc[+crc::tsk::build ].s_in[+crc::sck::build ::U_K1]);\n+ dp_src .s_out1 (mnt.sc[+mnt::tsk::check_errors ].s_in[+mnt::sck::check_errors ::U ]);\n+ dp_src .s_out2 (crc.sc[+crc::tsk::build ].s_in[+crc::sck::build ::U_K1]);\ncrc.sc [+crc::tsk::build ].s_out [+crc::sck::build ::U_K2](enc.sc[+enc::tsk::encode ].s_in[+enc::sck::encode ::U_K ]);\nenc.sc [+enc::tsk::encode ].s_out [+enc::sck::encode ::X_N ](pct.sc[+pct::tsk::puncture ].s_in[+pct::sck::puncture ::X_N1]);\n- pct.sc [+pct::tsk::puncture ].s_out [+pct::sck::puncture ::X_N2](dp_pct .s_in );\n- dp_pct [0] (mdm.sc[+mdm::tsk::modulate ].s_in[+mdm::sck::modulate ::X_N1]);\n+ pct.sc [+pct::tsk::puncture ].s_out [+pct::sck::puncture ::X_N2](mdm.sc[+mdm::tsk::modulate ].s_in[+mdm::sck::modulate ::X_N1]);\nif (this->params_BFER_std.chn->type.find(\"RAYLEIGH\") != std::string::npos) { // Rayleigh chn\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise_wg ].s_in[+chn::sck::add_noise_wg ::X_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::H_N ](mdm.sc[+mdm::tsk::demodulate_wg].s_in[+mdm::sck::demodulate_wg::H_N ]);\nchn.sc[+chn::tsk::add_noise_wg ].s_out [+chn::sck::add_noise_wg ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in[+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](mdm.sc[+mdm::tsk::demodulate_wg].s_in[+mdm::sck::demodulate_wg::Y_N1]);\n- mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate_wg::Y_N2](dp_dmd .s_in );\n+ mdm.sc[+mdm::tsk::demodulate_wg].s_out [+mdm::sck::demodulate_wg::Y_N2](qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\n} else { // additive channel (AWGN, USER, NO)\nmdm.sc[+mdm::tsk::modulate ].s_out [+mdm::sck::modulate ::X_N2](chn.sc[+chn::tsk::add_noise ].s_in[+chn::sck::add_noise ::X_N ]);\nchn.sc[+chn::tsk::add_noise ].s_out [+chn::sck::add_noise ::Y_N ](mdm.sc[+mdm::tsk::filter ].s_in[+mdm::sck::filter ::Y_N1]);\nmdm.sc[+mdm::tsk::filter ].s_out [+mdm::sck::filter ::Y_N2](mdm.sc[+mdm::tsk::demodulate ].s_in[+mdm::sck::demodulate ::Y_N1]);\n- mdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](dp_dmd .s_in );\n+ mdm.sc[+mdm::tsk::demodulate ].s_out [+mdm::sck::demodulate ::Y_N2](qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\n}\n- dp_dmd [0] (qnt.sc[+qnt::tsk::process ].s_in[+qnt::sck::process ::Y_N1]);\nqnt.sc [+qnt::tsk::process ].s_out [+qnt::sck::process ::Y_N2](pct.sc[+pct::tsk::depuncture ].s_in[+pct::sck::depuncture ::Y_N1]);\npct.sc [+pct::tsk::depuncture ].s_out [+pct::sck::depuncture ::Y_N2](dec.sc[+dec::tsk::decode_siho ].s_in[+dec::sck::decode_siho ::Y_N ]);\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_mi = *this->monitor_mi[0];\n- dp_pct[1](mnt_mi.sc[+mnt::tsk::get_mutual_info].s_in[+mnt::sck::get_mutual_info::X]);\n- dp_dmd[1](mnt_mi.sc[+mnt::tsk::get_mutual_info].s_in[+mnt::sck::get_mutual_info::Y]);\n- }\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/SystemC/SC_Duplicator.hpp",
"new_path": "src/Tools/SystemC/SC_Duplicator.hpp",
"diff": "@@ -23,38 +23,25 @@ public:\nusing SO_t = tlm_utils::simple_initiator_socket<SC_Duplicator>;\nSI_t s_in;\n- std::vector<SO_t*> s_out;\n+ SO_t s_out1;\n+ SO_t s_out2;\n-public:\n- explicit SC_Duplicator(sc_core::sc_module_name name = \"SC_Duplicator\", unsigned n_output = 2)\n- : sc_module(name), s_in(\"s_in\"), s_out(n_output, nullptr)\n+ explicit SC_Duplicator(sc_core::sc_module_name name = \"SC_Duplicator\")\n+ : sc_module(name), s_in(\"s_in\"), s_out1(\"s_out1\"), s_out2(\"s_out2\")\n{\ns_in.register_b_transport(this, &SC_Duplicator::b_transport);\n-\n- for (unsigned i = 0; i < n_output ; i++)\n- s_out[i] = new SO_t((std::string(\"s_out\") + std::to_string(i)).c_str());\n- }\n-\n- ~SC_Duplicator()\n- {\n- for(auto& so: s_out)\n- if (so != nullptr)\n- delete so;\n- }\n-\n- SO_t& operator[](size_t idx)\n- {\n- return *s_out[idx];\n}\nprivate:\nvoid b_transport(tlm::tlm_generic_payload& trans, sc_core::sc_time& t)\n{\nsc_core::sc_time zero_time(sc_core::SC_ZERO_TIME);\n- for (auto& so : s_out)\n- (*so)->b_transport(trans, zero_time);\n+ s_out1->b_transport(trans, zero_time);\n+ s_out2->b_transport(trans, zero_time);\n}\n+\n};\n+\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Come back to original SC_Duplicator; Move some duplicator call in bindings to avoid seg fault
|
8,483 |
23.08.2018 13:37:12
| -7,200 |
adf2ebcf36649acdb4ac90d079f53d9c88433529
|
Fix string error on two lines
|
[
{
"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": "@@ -24,8 +24,8 @@ SC_BFER_std<B,R,Q>\n\"monitoring.\");\nif (params_BFER_std.mutinfo)\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"BFER SystemC simulation does not support the mututal\n- information computation.\");\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"BFER SystemC simulation does not support the mututal\"\n+ \"information computation.\");\n}\ntemplate <typename B, typename R, typename Q>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix string error on two lines
|
8,483 |
23.08.2018 16:04:48
| -7,200 |
ebb8b3aae90d29fe64d33bfafeee799c0537ca97
|
Add sparse matrixes multiplation functions and rename functions 'real gemm' into 'binary gemmm' that assure a modulo 2 result; Make then check_GH with sparse matrix directly
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"new_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"diff": "#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Tools/Math/matrix.h\"\n#include \"Encoder_LDPC_from_H.hpp\"\n@@ -20,7 +19,7 @@ Encoder_LDPC_from_H<B>\nconst std::string name = \"Encoder_LDPC_from_H\";\nthis->set_name(name);\n- this->G = tools::LDPC_matrix_handler::transform_H_to_G(H, this->info_bits_pos);\n+ this->G = tools::LDPC_matrix_handler::transform_H_to_G(H.turn(tools::Matrix::Way::HORIZONTAL), this->info_bits_pos);\nthis->H = H;\nthis->check_G_dimensions();\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Matrix/matrix_utils.cpp",
"diff": "+#include <sstream>\n+\n+#include \"matrix_utils.h\"\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+using namespace aff3ct::tools;\n+\n+Sparse_matrix aff3ct::tools::bgemm(const Sparse_matrix& A, const Sparse_matrix& B)\n+{\n+ if (A.get_n_cols() != B.get_n_rows())\n+ {\n+ std::stringstream message;\n+ message << \"'A.get_n_cols()' is different to 'B.get_n_rows()' ('A.get_n_cols()' = \" << A.get_n_cols()\n+ << \", 'B.get_n_rows()' = \" << B.get_n_rows() << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto L = A.get_n_rows();\n+ auto N = B.get_n_cols();\n+\n+ Sparse_matrix C(L, N);\n+\n+ for (size_t l = 0; l < L; l++)\n+ for (size_t n = 0; n < N; n++)\n+ {\n+ size_t sum = 0; // number of common bits\n+ for (auto& c : A.get_cols_from_row(l))\n+ sum += B.at(c,n) ? 1 : 0;\n+\n+ if (sum & (size_t)1) // modulo 2\n+ C.add_connection(l, n);\n+ }\n+\n+ return C;\n+}\n+\n+Sparse_matrix aff3ct::tools::operator*(const Sparse_matrix& A, const Sparse_matrix& B)\n+{\n+ return bgemm(A,B);\n+}\n+\n+Sparse_matrix aff3ct::tools::bgemmt(const Sparse_matrix& A, const Sparse_matrix& tB)\n+{\n+ if (A.get_n_cols() != tB.get_n_cols())\n+ {\n+ std::stringstream message;\n+ message << \"'A.get_n_cols()' is different to 'tB.get_n_cols()' ('A.get_n_cols()' = \" << A.get_n_cols()\n+ << \", 'tB.get_n_cols()' = \" << tB.get_n_cols() << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto L = A.get_n_rows();\n+ auto N = tB.get_n_rows();\n+\n+ Sparse_matrix C(L, N);\n+\n+ for (size_t l = 0; l < L; l++)\n+ for (size_t n = 0; n < N; n++)\n+ {\n+ size_t sum = 0; // number of common bits\n+ for (auto& c : A.get_cols_from_row(l))\n+ sum += tB.at(n,c) ? 1 : 0;\n+\n+ if (sum & (size_t)1) // modulo 2\n+ C.add_connection(l, n);\n+ }\n+\n+ return C;\n+}\n+\n+bool aff3ct::tools::all_zeros(const Sparse_matrix& M)\n+{\n+ return M.get_n_connections() == 0;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/matrix_utils.h",
"new_path": "src/Tools/Algo/Matrix/matrix_utils.h",
"diff": "@@ -21,45 +21,42 @@ template <typename T>\nSparse_matrix full_to_sparse(const Full_matrix<T>&);\n/*\n- * real general matrix multiplication: C = A * B\n+ * binary general matrix multiplication: C = A * B\n* \\param A must be of size L * M\n* \\param B must be of size M * N\n* \\return C of size L * N\n*/\ntemplate <typename T>\n-Full_matrix<T> rgemm(const Full_matrix<T>& A, const Full_matrix<T>& B);\n+Full_matrix<T> bgemm(const Full_matrix<T>& A, const Full_matrix<T>& B);\n+Sparse_matrix bgemm(const Sparse_matrix& A, const Sparse_matrix& B);\n+\n/*\n- * real general matrix multiplication: C = A * B\n+ * binary general matrix multiplication: C = A * B\n* \\param A must be of size L * M\n* \\param B must be of size M * N\n* \\return C of size L * N\n*/\ntemplate <typename T>\nFull_matrix<T> operator*(const Full_matrix<T>& A, const Full_matrix<T>& B);\n+Sparse_matrix operator*(const Sparse_matrix& A, const Sparse_matrix& B);\n/*\n- * real general matrix multiplication with B transposed: tC = A * tB, tB is B transposed, tC is C transposed\n+ * binary general matrix multiplication with B transposed: tC = A * tB, tB is B transposed, tC is C transposed\n* \\param A must be of size L * M\n* \\param tB must be of size N * M\n* \\return C of size L * N\n*/\ntemplate <typename T>\n-Full_matrix<T> rgemmt(const Full_matrix<T>& A, const Full_matrix<T>& tB);\n-\n-/*\n- * \\brief apply a modulo 2 on each element of the matrix\n- */\n-template <typename T>\n-void modulo2(Full_matrix<T>&);\n+Full_matrix<T> bgemmt(const Full_matrix<T>& A, const Full_matrix<T>& tB);\n+Sparse_matrix bgemmt(const Sparse_matrix& A, const Sparse_matrix& tB);\n/*\n* \\brief check if all elements of the matrix are zero\n*/\ntemplate <typename T>\nbool all_zeros(const Full_matrix<T>&);\n-\n-\n+bool all_zeros(const Sparse_matrix& );\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/matrix_utils.hxx",
"new_path": "src/Tools/Algo/Matrix/matrix_utils.hxx",
"diff": "@@ -37,7 +37,7 @@ Sparse_matrix full_to_sparse(const Full_matrix<T>& full)\n}\ntemplate <typename T>\n-Full_matrix<T> rgemm(const Full_matrix<T>& A, const Full_matrix<T>& B)\n+Full_matrix<T> bgemm(const Full_matrix<T>& A, const Full_matrix<T>& B)\n{\nif (A.get_n_cols() != B.get_n_rows())\n{\n@@ -60,20 +60,20 @@ Full_matrix<T> rgemm(const Full_matrix<T>& A, const Full_matrix<T>& B)\nfor (size_t m = 0; m < M; m++)\nsum += A[l][m] * B[m][n];\n- C[l][n] = sum;\n+ C[l][n] = sum & (T)1; // modulo 2\n}\nreturn C;\n}\ntemplate <typename T>\n-Full_matrix<T> operator*(const Full_matrix<T>& A, const Full_matrix<T>& B)\n+inline Full_matrix<T> operator*(const Full_matrix<T>& A, const Full_matrix<T>& B)\n{\n- return rgemm(A,B);\n+ return bgemm(A,B);\n}\ntemplate <typename T>\n-Full_matrix<T> rgemmt(const Full_matrix<T>& A, const Full_matrix<T>& tB)\n+Full_matrix<T> bgemmt(const Full_matrix<T>& A, const Full_matrix<T>& tB)\n{\nif (A.get_n_cols() != tB.get_n_cols())\n{\n@@ -96,20 +96,12 @@ Full_matrix<T> rgemmt(const Full_matrix<T>& A, const Full_matrix<T>& tB)\nfor (size_t m = 0; m < M; m++)\nsum += A[l][m] * tB[n][m];\n- C[l][n] = sum;\n+ C[l][n] = sum & (T)1; // modulo 2\n}\nreturn C;\n}\n-template <typename T>\n-void modulo2(Full_matrix<T>& M)\n-{\n- for (size_t r = 0; r < M.get_n_rows(); r++)\n- for (size_t c = 0; c < M.get_n_cols(); c++)\n- M[r][c] &= (T)1;\n-}\n-\ntemplate <typename T>\nbool all_zeros(const Full_matrix<T>& M)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -217,9 +217,6 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\nstd::copy(bits_pos.begin() + M, bits_pos.end(), info_bits_pos.begin());\n- if (!check_GH(H, G))\n- throw runtime_error(__FILE__, __LINE__, __func__, \"G and H do not fit (G*H != 0).\");\n-\nreturn G;\n}\n@@ -298,7 +295,6 @@ void LDPC_matrix_handler\nstd::not_equal_to<LDPC_matrix::value_type>());\n}\n-\nSparse_matrix LDPC_matrix_handler\n::interleave_matrix(const Sparse_matrix& mat, Positions_vector& old_cols_pos)\n{\n@@ -457,10 +453,35 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\nbool LDPC_matrix_handler\n::check_GH(const Sparse_matrix& H, const Sparse_matrix& G)\n{\n- auto Gf = sparse_to_full<uint8_t>(G);\n- auto Hf = sparse_to_full<uint8_t>(H);\n+ Sparse_matrix GH;\n- return check_GH(Hf, Gf);\n+ switch (H.get_way())\n+ {\n+ case Matrix::Way::HORIZONTAL:\n+ switch (G.get_way())\n+ {\n+ case Matrix::Way::HORIZONTAL:\n+ GH = bgemmt(H, G);\n+ break;\n+ case Matrix::Way::VERTICAL:\n+ GH = bgemm(H, G);\n+ break;\n+ }\n+ break;\n+ case Matrix::Way::VERTICAL:\n+ switch (G.get_way())\n+ {\n+ case Matrix::Way::HORIZONTAL:\n+ GH = bgemm(G, H);\n+ break;\n+ case Matrix::Way::VERTICAL:\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"G and H can't be both in VERTICAL way.\");\n+ break;\n+ }\n+ break;\n+ }\n+\n+ return all_zeros(GH);\n}\nbool LDPC_matrix_handler\n@@ -474,10 +495,10 @@ bool LDPC_matrix_handler\nswitch (G.get_way())\n{\ncase Matrix::Way::HORIZONTAL:\n- GH = rgemmt(H, G);\n+ GH = bgemmt(H, G);\nbreak;\ncase Matrix::Way::VERTICAL:\n- GH = rgemm(H, G);\n+ GH = bgemm(H, G);\nbreak;\n}\nbreak;\n@@ -485,7 +506,7 @@ bool LDPC_matrix_handler\nswitch (G.get_way())\n{\ncase Matrix::Way::HORIZONTAL:\n- GH = rgemm(G, H);\n+ GH = bgemm(G, H);\nbreak;\ncase Matrix::Way::VERTICAL:\nthrow runtime_error(__FILE__, __LINE__, __func__, \"G and H can't be both in VERTICAL way.\");\n@@ -494,7 +515,5 @@ bool LDPC_matrix_handler\nbreak;\n}\n- modulo2(GH);\n-\nreturn all_zeros(GH);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "@@ -98,10 +98,19 @@ public:\n/*\n* \\brief Compute a G.H to check if result is a null vector\n- * H and G can be permuted, the function handle their order\n+ * H and G can be permuted except both vertical, the function handle their order\n+ * Best performance check is when do not have the same way\n* \\return true if G.H == 0\n*/\nstatic bool check_GH(const Sparse_matrix& H, const Sparse_matrix& G);\n+\n+\n+ /*\n+ * \\brief Compute a G.H to check if result is a null vector\n+ * H and G can be permuted except both vertical, the function handle their order\n+ * Best performance check is when both are horizontal\n+ * \\return true if G.H == 0\n+ */\nstatic bool check_GH(const LDPC_matrix& H, const LDPC_matrix& G);\n};\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add sparse matrixes multiplation functions and rename functions 'real gemm' into 'binary gemmm' that assure a modulo 2 result; Make then check_GH with sparse matrix directly
|
8,483 |
24.08.2018 10:25:15
| -7,200 |
6a459b4f30b9d00a8000ed6f867de3d066717b2f
|
Change support of unsigned integer value for FullMatrix into signed integers because MIPP does not support unsigned
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.cpp",
"new_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.cpp",
"diff": "@@ -354,8 +354,8 @@ void Full_matrix<T>\n}\n// ==================================================================================== explicit template instantiation\n-template class aff3ct::tools::Full_matrix< uint8_t>;\n-template class aff3ct::tools::Full_matrix<uint16_t>;\n-template class aff3ct::tools::Full_matrix<uint32_t>;\n-template class aff3ct::tools::Full_matrix<uint64_t>;\n+template class aff3ct::tools::Full_matrix< int8_t>;\n+template class aff3ct::tools::Full_matrix<int16_t>;\n+template class aff3ct::tools::Full_matrix<int32_t>;\n+template class aff3ct::tools::Full_matrix<int64_t>;\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.hpp",
"new_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.hpp",
"diff": "@@ -13,12 +13,12 @@ namespace aff3ct\nnamespace tools\n{\n/*\n- * \\param T must be uint8_t or uint16_t or uint32_t or uint64_t\n+ * \\param T must be int8_t or int16_t or int32_t or int64_t\n* Warning ! Never call modification methods (resize, erase, push_back and so on), on the second dimension of the Full_matrix\n* always pass through Full_matrix methods, else you may obtain runtime errors\n*/\n-template <typename T = uint32_t>\n+template <typename T = int32_t>\nclass Full_matrix : public Matrix, public std::vector<std::vector<T>>\n{\npublic:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "@@ -16,7 +16,7 @@ namespace tools\nstruct LDPC_matrix_handler\n{\npublic:\n- using LDPC_matrix = Full_matrix<uint8_t>;\n+ using LDPC_matrix = Full_matrix<int8_t>;\nusing Positions_vector = std::vector<uint32_t>;\nenum class Matrix_format : int8_t {ALIST, QC};\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change support of unsigned integer value for FullMatrix into signed integers because MIPP does not support unsigned
|
8,483 |
24.08.2018 10:35:25
| -7,200 |
119743e3935cd0ddf606491d82cae44a83ff8b90
|
Add a method to activate or not the histogram use in Monitor BFER and MI
|
[
{
"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), err_hist(0)\n+ count_unknown_values(count_unknown_values), err_hist(0), err_hist_activated(false)\n{\nconst std::string name = \"Monitor_BFER\";\nthis->set_name(name);\n@@ -143,6 +143,7 @@ int Monitor_BFER<B>\nvals.n_be += bit_errors_count;\nvals.n_fe ++;\n+ if (err_hist_activated)\nerr_hist.add_value(bit_errors_count);\nfor (auto& c : this->callbacks_fe)\n@@ -265,6 +266,13 @@ tools::Histogram<int> Monitor_BFER<B>::get_err_hist() const\nreturn err_hist;\n}\n+template<typename B>\n+void Monitor_BFER<B>\n+::activate_err_histogram(bool val)\n+{\n+ err_hist_activated = val;\n+}\n+\ntemplate <typename B>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"diff": "@@ -36,6 +36,7 @@ private:\nAttributes vals;\ntools::Histogram<int> err_hist; // the error histogram record\n+ bool err_hist_activated;\nstd::vector<std::function<void(unsigned, int )>> callbacks_fe;\nstd::vector<std::function<void( void)>> callbacks_check;\n@@ -107,7 +108,9 @@ public:\nunsigned long long get_n_be () const;\nfloat get_fer () const;\nfloat get_ber () const;\n+\ntools::Histogram<int> get_err_hist () const;\n+ void activate_err_histogram(bool val);\nvirtual void add_handler_fe (std::function<void(unsigned, int )> callback);\nvirtual void add_handler_check (std::function<void( void)> callback);\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- mutinfo_hist(1)\n+ mutinfo_hist(1), mutinfo_hist_activated(false)\n{\nconst std::string name = \"Monitor_MI\";\nthis->set_name(name);\n@@ -152,6 +152,7 @@ void Monitor_MI<B,R>\nvals.MI_max = std::max(vals.MI_max, mi);\nvals.MI_min = std::min(vals.MI_min, mi);\n+ if (mutinfo_hist_activated)\nthis->mutinfo_hist.add_value(mi);\n}\n@@ -223,14 +224,21 @@ R Monitor_MI<B,R>\nreturn vals.MI_max;\n}\n-\n-\ntemplate<typename B, typename R>\n-tools::Histogram<R> Monitor_MI<B,R>::get_mutinfo_hist() const\n+tools::Histogram<R> Monitor_MI<B,R>\n+::get_mutinfo_hist() const\n{\nreturn this->mutinfo_hist;\n}\n+template<typename B, typename R>\n+void Monitor_MI<B,R>\n+::activate_mutinfo_histogram(bool val)\n+{\n+ mutinfo_hist_activated = val;\n+}\n+\n+\ntemplate <typename B, typename R>\nvoid Monitor_MI<B,R>\n::add_handler_check(std::function<void(void)> callback)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/MI/Monitor_MI.hpp",
"new_path": "src/Module/Monitor/MI/Monitor_MI.hpp",
"diff": "@@ -35,6 +35,7 @@ private:\nAttributes vals;\ntools::Histogram<R> mutinfo_hist; // the MI histogram record\n+ bool mutinfo_hist_activated;\nstd::vector<std::function<void(void)>> callbacks_check;\nstd::vector<std::function<void(void)>> callbacks_n_trials_limit_achieved;\n@@ -99,8 +100,9 @@ public:\nR get_MI () const;\nR get_MI_min () const;\nR get_MI_max () const;\n- tools::Histogram<R> get_mutinfo_hist() const;\n+ tools::Histogram<R> get_mutinfo_hist() const;\n+ void activate_mutinfo_histogram(bool val);\nvirtual void add_handler_check (std::function<void(void)> callback);\nvirtual void add_handler_n_trials_limit_achieved(std::function<void(void)> callback);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -344,7 +344,10 @@ module::Monitor_BFER<B>* BFER<B,R,Q>\n{\nbool count_unknown_values = params_BFER.noise->type == \"EP\";\n- return params_BFER.mnt_er->build<B>(count_unknown_values);\n+ auto mnt = params_BFER.mnt_er->build<B>(count_unknown_values);\n+ mnt->activate_err_histogram(params_BFER.mnt_er->err_hist != -1);\n+\n+ return mnt;\n}\ntemplate <typename B, typename R, typename Q>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a method to activate or not the histogram use in Monitor BFER and MI
|
8,483 |
24.08.2018 16:47:02
| -7,200 |
23cb8a29a1d546b38111774d320faf0c6e64be64
|
Enhance from_diagonal and from identity to create them from any corner of the matrix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -191,9 +191,9 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\nauto N = G.get_n_cols();\nauto K = N - M;\n- Positions_vector swapped_cols;\n- LDPC_matrix_handler::form_diagonal(G, swapped_cols);\n- LDPC_matrix_handler::form_identity(G);\n+ auto swapped_cols = LDPC_matrix_handler::form_diagonal(G, Matrix::Origin::TOP_LEFT);\n+ LDPC_matrix_handler::form_identity(G, Matrix::Origin::TOP_LEFT);\n+\n// erase the just created M*M identity in the left part of H and add the K*K identity below\nG.self_resize(N, K, Matrix::Origin::TOP_RIGHT);\n@@ -203,8 +203,8 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n// G is now VERTICAL\n// Re-organization: get G\n- for (auto l = (swapped_cols.size() / 2); l > 0; l--)\n- std::swap(G[swapped_cols[l*2-2]], G[swapped_cols[l*2-1]]);\n+ for (auto l = swapped_cols.size(); l > 0; l--)\n+ std::swap(G[swapped_cols[l-1].first], G[swapped_cols[l-1].second]);\n// return info bits positions\ninfo_bits_pos.resize(K);\n@@ -212,88 +212,361 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\nPositions_vector bits_pos(N);\nstd::iota(bits_pos.begin(), bits_pos.end(), 0);\n- for (size_t l = 1; l <= (swapped_cols.size() / 2); l++)\n- std::swap(bits_pos[swapped_cols[l*2-2]], bits_pos[swapped_cols[l*2-1]]);\n+ for (auto& p : swapped_cols)\n+ std::swap(bits_pos[p.first], bits_pos[p.second]);\nstd::copy(bits_pos.begin() + M, bits_pos.end(), info_bits_pos.begin());\nreturn G;\n+\n+\n+\n+\n+ // // erase the just created M*M identity in the right part of H\n+ // G.self_resize(M, K, Matrix::Origin::TOP_LEFT);\n+\n+ // // transpose G\n+ // G.self_transpose();\n+\n+ // // add the K*K falling diagonal identity on the left\n+ // G.self_resize(K, N, Matrix::Origin::TOP_RIGHT);\n+ // for (size_t i = 0; i < K; i++)\n+ // G[i][i] = 1;\n+\n+ // // G is now HORIZONTAL\n+\n+ // // Re-organization: get G\n+ // // TODO: transpose G\n+ // // for (auto& p : swapped_cols)\n+ // // std::swap(G[p.first], G[p.second]);\n+\n+ // // return info bits positions\n+ // info_bits_pos.resize(K);\n+\n+ // // Positions_vector bits_pos(N);\n+ // // std::iota(bits_pos.begin(), bits_pos.end(), 0);\n+\n+ // // for (size_t l = 1; l <= (swapped_cols.size() / 2); l++)\n+ // // std::swap(bits_pos[swapped_cols[l*2-2]], bits_pos[swapped_cols[l*2-1]]);\n+\n+ // // std::copy(bits_pos.begin() + M, bits_pos.end(), info_bits_pos.begin());\n+ // std::iota(info_bits_pos.begin(), info_bits_pos.end(), 0);\n+\n+ // return G;\n}\n-void LDPC_matrix_handler\n-::form_diagonal(LDPC_matrix& mat, Positions_vector& swapped_cols)\n+void swap_columns(LDPC_matrix_handler::LDPC_matrix& mat, size_t idx1, size_t idx2)\n+{\n+ auto n_row = mat.get_n_rows();\n+ std::vector<LDPC_matrix_handler::LDPC_matrix::value_type> tmp(n_row);\n+ for (size_t l = 0; l < n_row; l++) tmp[l] = mat[l][idx1];\n+ for (size_t l = 0; l < n_row; l++) mat[l][idx1] = mat[l][idx2];\n+ for (size_t l = 0; l < n_row; l++) mat[l][idx2] = tmp[l];\n+}\n+\n+LDPC_matrix_handler::Positions_pair_vector LDPC_matrix_handler\n+::form_diagonal(LDPC_matrix& mat, Matrix::Origin o)\n{\nmat.self_turn(Matrix::Way::HORIZONTAL);\nauto n_row = mat.get_n_rows();\nauto n_col = mat.get_n_cols();\n- size_t i = 0;\n- bool found = false;\n+ Positions_pair_vector swapped_cols;\n- while (i < n_row)\n+ switch (o)\n+ {\n+ case Matrix::Origin::TOP_LEFT:\n+ for (size_t i = 0; i < n_row; i++)\n{\n- if (mat[i][i])\n+ bool found = mat[i][i];\n+\n+ if (!found)\n+ {\n+ // try to find an other row which as a 1 in column i\n+ for (auto j = i +1; j < n_row; j++)\n+ if (mat[j][i])\n+ {\n+ std::swap(mat[i], mat[j]);\n+ found = true;\n+ break;\n+ }\n+\n+\n+ if (!found) // no other row after (i+1) of the same column i with a 1\n+ {\n+ for (auto j = i +1; j < n_col; j++) // find an other column which is good on row i\n+ {\n+ if (mat[i][j])\n+ {\n+ swapped_cols.push_back(std::make_pair(i,j));\n+\n+ swap_columns(mat, i, j);\n+\n+ found = true;\n+ break;\n+ }\n+ }\n+ }\n+ }\n+\n+ if (found)\n{\n+ // there is a 1 on row i of the column i\n+ // then remove any 1 of the column i from the row (i+1)\nfor (auto j = i +1; j < n_row; j++)\nif (mat[j][i])\n- std::transform(mat[j].begin(), mat[j].end(),\n- mat[i].begin(), mat[j].begin(),\n+ std::transform(mat[i].begin() + i, mat[i].end(), //ref\n+ mat[j].begin() + i, mat[j].begin() + i,\nstd::not_equal_to<LDPC_matrix::value_type>());\n}\nelse\n{\n- for (auto j = i +1; j < n_row; j++) // find an other row which is good\n- if (mat[j][i])\n+ // the row is the null vector then delete it\n+ mat.erase_row(i);\n+ i--;\n+ n_row--;\n+ }\n+ }\n+ break;\n+ case Matrix::Origin::TOP_RIGHT:\n+ for (size_t i = 0; i < n_row; i++)\n+ {\n+ auto ref_col = n_col - i - 1;\n+ bool found = mat[i][ref_col];\n+\n+ if (!found)\n+ {\n+ // try to find an other row which as a 1 in column ref_col\n+ for (auto j = i +1; j < n_row; j++)\n+ if (mat[j][ref_col])\n{\nstd::swap(mat[i], mat[j]);\n- i--;\nfound = true;\nbreak;\n}\n- if (!found) // if does not found\n- for (auto j = i +1; j < n_col; j++) // find an other column which is good\n- if (mat[i][j])\n+\n+ if (!found) // no other row after (i+1) of the same column ref_col with a 1\n+ {\n+ for (auto j = ref_col; j > 0; j--) // find an other column which is good on row i\n{\n- swapped_cols.push_back(i);\n- swapped_cols.push_back(j);\n+ auto c = j -1;\n+ if (mat[i][c])\n+ {\n+ swapped_cols.push_back(std::make_pair(i,c));\n- // swap the columns\n- std::vector<int8_t> column_save(n_row);\n- for (size_t l = 0; l < n_row; l++) column_save[l] = (mat[l][i]);\n- for (size_t l = 0; l < n_row; l++) mat[l][i] = mat[l][j];\n- for (size_t l = 0; l < n_row; l++) mat[l][j] = column_save[l];\n+ swap_columns(mat, i, c);\n- i--;\nfound = true;\nbreak;\n}\n+ }\n+ }\n+ }\n- if (!found) // if does not found again this mean that the row is the null vector\n+ if (found)\n+ {\n+ // there is a 1 on row i of the column ref_col\n+ // then remove any 1 of the column ref_col from the row (i+1)\n+ for (auto j = i +1; j < n_row; j++)\n+ if (mat[j][ref_col])\n+ std::transform(mat[i].begin(), mat[i].begin() + ref_col + 1, //ref\n+ mat[j].begin(), mat[j].begin(),\n+ std::not_equal_to<LDPC_matrix::value_type>());\n+ }\n+ else\n{\n+ // the row is the null vector then delete it\nmat.erase_row(i);\ni--;\nn_row--;\n}\n- found = false;\n}\n- i++;\n+ break;\n+ case Matrix::Origin::BOTTOM_LEFT:\n+ for (auto i = n_row; i > 0; i--)\n+ {\n+ auto ref_row = i - 1;\n+ auto ref_col = n_row - ref_row - 1;\n+ bool found = mat[ref_row][ref_col];\n+\n+ if (!found)\n+ {\n+ // try to find an other row which as a 1 in column ref_col\n+ for (auto j = ref_row; j > 0; j--)\n+ {\n+ auto tested_row = j - 1;\n+ if (mat[tested_row][ref_col])\n+ {\n+ std::swap(mat[ref_row], mat[tested_row]);\n+ found = true;\n+ break;\n+ }\n+ }\n+\n+\n+ if (!found) // no other row before (ref_row-1) of the same column ref_col with a 1\n+ {\n+ for (auto j = ref_col +1; j < n_col; j++) // find an other column which is good on row ref_row\n+ {\n+ if (mat[ref_row][j])\n+ {\n+ swapped_cols.push_back(std::make_pair(ref_col,j));\n+\n+ swap_columns(mat, ref_col, j);\n+\n+ found = true;\n+ break;\n+ }\n+ }\n+ }\n+ }\n+\n+ if (found)\n+ {\n+ // there is a 1 on row ref_row of the column ref_col\n+ // then remove any 1 of the column ref_col from the row (ref_row-1)\n+ for (auto j = ref_row; j > 0; j--)\n+ {\n+ auto tested_row = j - 1;\n+ if (mat[tested_row][ref_col])\n+ std::transform(mat[ref_row ].begin() + ref_col, mat[ref_row ].end(), //ref\n+ mat[tested_row].begin() + ref_col, mat[tested_row].begin() + ref_col,\n+ std::not_equal_to<LDPC_matrix::value_type>());\n+ }\n+ }\n+ else\n+ {\n+ // the row is the null vector then delete it\n+ mat.erase_row(ref_row);\n+ n_row--;\n+ }\n+ }\n+ break;\n+ case Matrix::Origin::BOTTOM_RIGHT:\n+ for (auto i = n_row; i > 0; i--)\n+ {\n+ auto ref_row = i - 1;\n+ auto ref_col = n_col - n_row + ref_row;\n+ bool found = mat[ref_row][ref_col];\n+\n+ if (!found)\n+ {\n+ // try to find an other row which as a 1 in column ref_col\n+ for (auto j = ref_row; j > 0; j--)\n+ {\n+ auto tested_row = j - 1;\n+ if (mat[tested_row][ref_col])\n+ {\n+ std::swap(mat[ref_row], mat[tested_row]);\n+ found = true;\n+ break;\n+ }\n+ }\n+\n+\n+ if (!found) // no other row before (ref_row-1) of the same column ref_col with a 1\n+ {\n+ for (auto j = ref_col; j > 0; j--) // find an other column which is good on row ref_row\n+ {\n+ auto tested_col = j - 1;\n+ if (mat[ref_row][tested_col])\n+ {\n+ swapped_cols.push_back(std::make_pair(ref_col,tested_col));\n+\n+ swap_columns(mat, ref_col, tested_col);\n+\n+ found = true;\n+ break;\n+ }\n+ }\n+ }\n+ }\n+\n+ if (found)\n+ {\n+ // there is a 1 on row ref_row of the column ref_col\n+ // then remove any 1 of the column ref_col from the row (ref_row-1)\n+ for (auto j = ref_row; j > 0; j--)\n+ {\n+ auto tested_row = j - 1;\n+ if (mat[tested_row][ref_col])\n+ std::transform(mat[ref_row ].begin() + ref_col, mat[ref_row ].end(), //ref\n+ mat[tested_row].begin() + ref_col, mat[tested_row].begin() + ref_col,\n+ std::not_equal_to<LDPC_matrix::value_type>());\n+ }\n+ }\n+ else\n+ {\n+ // the row is the null vector then delete it\n+ mat.erase_row(ref_row);\n+ n_row--;\n+ }\n+ }\n+ break;\n}\n+\n+ return swapped_cols;\n}\nvoid LDPC_matrix_handler\n-::form_identity(LDPC_matrix& mat)\n+::form_identity(LDPC_matrix& mat, Matrix::Origin o)\n{\nmat.self_turn(Matrix::Way::HORIZONTAL);\n- for (auto i = mat.get_n_rows() - 1 ; i > 0; i--)\n- for (auto j = i; j > 0; j--)\n- if (mat[j-1][i])\n- std::transform (mat[j-1].begin(), mat[j-1].end(),\n- mat[i ].begin(), mat[j-1].begin(),\n+ auto n_row = mat.get_n_rows();\n+ auto n_col = mat.get_n_cols();\n+ auto diff = n_col - n_row;\n+\n+ switch (o)\n+ {\n+ case Matrix::Origin::TOP_LEFT:\n+ for (auto c = n_row - 1; c > 0; c--)\n+ {\n+ auto ref_row = c;\n+ for (auto r = c; r > 0; r--)\n+ if (mat[r - 1][c])\n+ std::transform (mat[ref_row].begin() + c, mat[ref_row].end(), // ref\n+ mat[r - 1 ].begin() + c, mat[r - 1 ].begin() + c,\n+ std::not_equal_to<LDPC_matrix::value_type>());\n+ }\n+ break;\n+ case Matrix::Origin::TOP_RIGHT:\n+ for (auto c = diff; c < (n_col - 1); c++)\n+ {\n+ auto ref_row = n_row - c + diff - 1;\n+ for (auto r = ref_row; r > 0; r--)\n+ if (mat[r - 1][c])\n+ std::transform (mat[ref_row].begin(), mat[ref_row].begin() + c + 1, // ref\n+ mat[r - 1 ].begin(), mat[r - 1 ].begin(),\nstd::not_equal_to<LDPC_matrix::value_type>());\n}\n+ break;\n+ case Matrix::Origin::BOTTOM_LEFT:\n+ for (auto c = n_row - 1; c > 0; c--)\n+ {\n+ auto ref_row = n_row - c - 1;\n+ for (auto r = ref_row + 1; r < n_row; r++)\n+ if (mat[r][c])\n+ std::transform (mat[ref_row].begin() + c, mat[ref_row].end(), // ref\n+ mat[r ].begin() + c, mat[r ].begin() + c,\n+ std::not_equal_to<LDPC_matrix::value_type>());\n+ }\n+ break;\n+ case Matrix::Origin::BOTTOM_RIGHT:\n+ for (auto c = diff; c < (n_col - 1); c++)\n+ {\n+ auto ref_row = c - diff;\n+ for (auto r = ref_row + 1; r < n_row; r++)\n+ if (mat[r][c])\n+ std::transform (mat[ref_row].begin(), mat[ref_row].begin() + c + 1, // ref\n+ mat[r ].begin(), mat[r ].begin(),\n+ std::not_equal_to<LDPC_matrix::value_type>());\n+ }\n+ break;\n+ }\n+}\nSparse_matrix LDPC_matrix_handler\n::interleave_matrix(const Sparse_matrix& mat, Positions_vector& old_cols_pos)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "#include <vector>\n#include <algorithm>\n+#include <functional>\n#include <numeric>\n#include <string>\n#include <mipp.h>\n@@ -18,6 +19,7 @@ struct LDPC_matrix_handler\npublic:\nusing LDPC_matrix = Full_matrix<int8_t>;\nusing Positions_vector = std::vector<uint32_t>;\n+ using Positions_pair_vector = std::vector<std::pair<size_t,size_t>>;\nenum class Matrix_format : int8_t {ALIST, QC};\n@@ -52,19 +54,17 @@ public:\nstatic bool check_info_pos(const Positions_vector& info_bits_pos, int K, int N, bool throw_when_wrong = true);\n/*\n- * Reorder rows and columns to create a diagonal of binary ones on the left part of the matrix.\n+ * \\brief Reorder rows and columns to create a diagonal of binary ones from the given origin of the matrix.\n* Matrix is turned in Horizontal way\n- * At the end, the left part of the matrix does not necessary form the identity, but includes it.\n- * swapped_cols is completed each time with couple of positions of the two swapped columns.\n- * A column might be swapped several times.\n+ * \\return swapped columns positions pairs. Warning, a column might be swapped several times.\n*/\n- static void form_diagonal(LDPC_matrix& mat, Positions_vector& swapped_cols);\n+ static Positions_pair_vector form_diagonal(LDPC_matrix& mat, Matrix::Origin o = Matrix::Origin::TOP_LEFT);\n/*\n* Reorder rows and columns to create an identity of binary ones on the left part of the matrix.\n- * Matrix is turned in Horizontal way\n+ * This function need you call first form_diagonal().\n*/\n- static void form_identity(LDPC_matrix& mat);\n+ static void form_identity(LDPC_matrix& mat, Matrix::Origin o = Matrix::Origin::TOP_LEFT);\n/*\n* Compute a G matrix related to the given H matrix.\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Enhance from_diagonal and from identity to create them from any corner of the matrix
|
8,483 |
28.08.2018 10:24:10
| -7,200 |
2ef4091cc73a2609ef5921c58dabd4d958c1f5ff
|
Add 'positive' tag that is an info tag in green
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/rang_format/rang_format.cpp",
"new_path": "src/Tools/Display/rang_format/rang_format.cpp",
"diff": "@@ -27,6 +27,12 @@ std::ostream& format_comment(std::ostream& os)\nreturn os;\n}\n+std::ostream& format_positive(std::ostream& os)\n+{\n+ os << rang::style::bold << rang::fg::green << \"(II) \" << rang::style::reset;\n+ return os;\n+}\n+\nstd::ostream& rang::operator<<(std::ostream& os, tag f)\n{\nswitch (f)\n@@ -35,6 +41,7 @@ std::ostream& rang::operator<<(std::ostream& os, tag f)\ncase rang::tag::warning: return format_warning (os);\ncase rang::tag::info: return format_info (os);\ncase rang::tag::comment: return format_comment (os);\n+ case rang::tag::positive: return format_positive(os);\n}\nreturn os;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/rang_format/rang_format.h",
"new_path": "src/Tools/Display/rang_format/rang_format.h",
"diff": "@@ -12,7 +12,8 @@ enum class tag {\nerror = 0,\nwarning,\ninfo,\n- comment\n+ comment,\n+ positive\n};\nstd::ostream& operator<<(std::ostream& os, tag f);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add 'positive' tag that is an info tag in green
|
8,483 |
28.08.2018 10:25:11
| -7,200 |
c3020e4afec34da72abbf97a363017243a230e82
|
Add a zero padding option argument to not zero pad by default the written AList files because it takes memory space.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"new_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/general_utils.h\"\n+#include \"Tools/Display/rang_format/rang_format.h\"\n#include \"AList.hpp\"\n@@ -63,7 +64,7 @@ Sparse_matrix AList\n}\nvoid AList\n-::write(const Sparse_matrix &matrix, std::ostream &stream)\n+::write(const Sparse_matrix &matrix, std::ostream &stream, bool zero_padding)\n{\nstream << matrix.get_n_rows() << \" \" << matrix.get_n_cols() << std::endl << std::endl;\nstream << matrix.get_rows_max_degree() << \" \" << matrix.get_cols_max_degree() << std::endl << std::endl;\n@@ -81,6 +82,7 @@ void AList\nunsigned i;\nfor (i = 0; i < r.size(); i++)\nstream << (r[i] +1) << \" \";\n+ if (zero_padding)\nfor (; i < matrix.get_rows_max_degree(); i++)\nstream << 0 << \" \";\nstream << std::endl;\n@@ -92,6 +94,7 @@ void AList\nunsigned i;\nfor (i = 0; i < c.size(); i++)\nstream << (c[i] +1) << \" \";\n+ if (zero_padding)\nfor (; i < matrix.get_cols_max_degree(); i++)\nstream << 0 << \" \";\nstream << std::endl;\n@@ -323,8 +326,9 @@ Sparse_matrix AList\n::read_format2(std::istream &stream)\n{\nstd::string line;\n+ bool warning_message_displayed = false;\n- getline(stream, line);\n+ tools::getline(stream, line);\nauto values = split(line);\nif (values.size() < 2)\n{\n@@ -348,7 +352,7 @@ Sparse_matrix AList\nSparse_matrix matrix(n_rows, n_cols);\n- getline(stream, line);\n+ tools::getline(stream, line);\nvalues = split(line);\nif (values.size() < 2)\n{\n@@ -368,7 +372,7 @@ Sparse_matrix AList\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- getline(stream, line);\n+ tools::getline(stream, line);\nvalues = split(line);\nif (values.size() < n_rows)\n{\n@@ -382,18 +386,24 @@ Sparse_matrix AList\nfor (unsigned i = 0; i < n_rows; i++)\n{\nunsigned n_connections = std::stoi(values[i]);\n- if (n_connections > 0 && n_connections <= rows_max_degree)\n+ if (!warning_message_displayed && n_connections == 0)\n+ {\n+ std::clog << rang::tag::warning << \"Found in Alist file connections of degree 0!\" << std::endl;\n+ warning_message_displayed = true;\n+ }\n+\n+ if (n_connections <= rows_max_degree)\nrows_degree[i] = n_connections;\nelse\n{\nstd::stringstream message;\n- message << \"'n_connections' has to be greater than 0 and smaller than 'rows_max_degree' \"\n+ message << \"'n_connections' has to be smaller than 'rows_max_degree' \"\n<< \"('n_connections' = \" << n_connections << \", 'rows_max_degree' = \" << rows_max_degree << \").\";\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n}\n- getline(stream, line);\n+ tools::getline(stream, line);\nvalues = split(line);\nif (values.size() < n_cols)\n{\n@@ -407,10 +417,10 @@ Sparse_matrix AList\nfor (unsigned i = 0; i < n_cols; i++)\n{\nunsigned n_connections = std::stoi(values[i]);\n- if (!(n_connections > 0 && n_connections <= cols_max_degree))\n+ if (!(n_connections <= cols_max_degree))\n{\nstd::stringstream message;\n- message << \"'n_connections' has to be greater than 0 and smaller than 'cols_max_degree' \"\n+ message << \"'n_connections' has to be smaller than 'cols_max_degree' \"\n<< \"('n_connections' = \" << n_connections << \", 'cols_max_degree' = \" << cols_max_degree << \").\";\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n@@ -420,7 +430,7 @@ Sparse_matrix AList\nfor (unsigned i = 0; i < n_rows; i++)\n{\n- getline(stream, line);\n+ tools::getline(stream, line);\nvalues = split(line);\nif (values.size() < rows_degree[i])\n@@ -452,7 +462,7 @@ Sparse_matrix AList\n// TODO: this verif. is time consuming\n// for (unsigned i = 0; i < n_cols; i++)\n// {\n-// getline(stream, line);\n+// tools::getline(stream, line);\n// values = split(line);\n//\n// if (values.size() < cols_degree[i])\n@@ -500,7 +510,7 @@ Sparse_matrix AList\n{\nstd::string line;\n- getline(stream, line);\n+ tools::getline(stream, line);\nauto values = split(line);\nif (values.size() < 2)\n{\n@@ -524,7 +534,7 @@ Sparse_matrix AList\nSparse_matrix matrix(n_rows, n_cols);\n- getline(stream, line);\n+ tools::getline(stream, line);\nvalues = split(line);\nif (values.size() < n_rows)\n{\n@@ -551,7 +561,7 @@ Sparse_matrix AList\nfor (unsigned i = 0; i < n_cols; i++)\n{\n- getline(stream, line);\n+ tools::getline(stream, line);\nvalues = split(line);\nif (values.size() < cols_degree[i])\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/AList/AList.hpp",
"new_path": "src/Tools/Code/LDPC/AList/AList.hpp",
"diff": "@@ -13,7 +13,7 @@ struct AList\n{\npublic:\nstatic Sparse_matrix read ( std::istream &stream);\n- static void write(const Sparse_matrix &matrix, std::ostream &stream);\n+ static void write(const Sparse_matrix &matrix, std::ostream &stream, bool zero_padding = false);\n/*\n* get the matrix dimensions H and N from the input stream\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a zero padding option argument to not zero pad by default the written AList files because it takes memory space.
|
8,483 |
28.08.2018 10:27:02
| -7,200 |
fd42b5a6733112786d15ceffd9ab046290b67d18
|
add comments and optimize with MIPP bgemmt for full matrix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/matrix_utils.cpp",
"new_path": "src/Tools/Algo/Matrix/matrix_utils.cpp",
"diff": "@@ -26,7 +26,7 @@ Sparse_matrix aff3ct::tools::bgemm(const Sparse_matrix& A, const Sparse_matrix&\n{\nsize_t sum = 0; // number of common bits\nfor (auto& c : A.get_cols_from_row(l))\n- sum += B.at(c,n) ? 1 : 0;\n+ sum += B.at(c,n);\nif (sum & (size_t)1) // modulo 2\nC.add_connection(l, n);\n@@ -60,7 +60,7 @@ Sparse_matrix aff3ct::tools::bgemmt(const Sparse_matrix& A, const Sparse_matrix&\n{\nsize_t sum = 0; // number of common bits\nfor (auto& c : A.get_cols_from_row(l))\n- sum += tB.at(n,c) ? 1 : 0;\n+ sum += tB.at(n,c);\nif (sum & (size_t)1) // modulo 2\nC.add_connection(l, n);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/matrix_utils.h",
"new_path": "src/Tools/Algo/Matrix/matrix_utils.h",
"diff": "@@ -9,19 +9,19 @@ namespace aff3ct\nnamespace tools\n{\n/*\n- * convert a binary sparse matrix to a binary full matrix\n+ * \\brief convert a binary sparse matrix to a binary full matrix\n*/\ntemplate <typename T>\nFull_matrix<T> sparse_to_full(const Sparse_matrix&);\n/*\n- * convert a binary full matrix to a binary sparse matrix\n+ * \\brief convert a binary full matrix to a binary sparse matrix\n*/\ntemplate <typename T>\nSparse_matrix full_to_sparse(const Full_matrix<T>&);\n/*\n- * binary general matrix multiplication: C = A * B\n+ * \\brief binary general matrix multiplication: C = A * B\n* \\param A must be of size L * M\n* \\param B must be of size M * N\n* \\return C of size L * N\n@@ -32,7 +32,7 @@ Sparse_matrix bgemm(const Sparse_matrix& A, const Sparse_matrix& B);\n/*\n- * binary general matrix multiplication: C = A * B\n+ * \\brief binary general matrix multiplication: C = A * B\n* \\param A must be of size L * M\n* \\param B must be of size M * N\n* \\return C of size L * N\n@@ -42,13 +42,21 @@ Full_matrix<T> operator*(const Full_matrix<T>& A, const Full_matrix<T>& B);\nSparse_matrix operator*(const Sparse_matrix& A, const Sparse_matrix& B);\n/*\n- * binary general matrix multiplication with B transposed: tC = A * tB, tB is B transposed, tC is C transposed\n+ * \\brief binary general matrix multiplication with B transposed: tC = A * tB, tB is B transposed, tC is C transposed\n+ * Operations are optimized with MIPP\n* \\param A must be of size L * M\n* \\param tB must be of size N * M\n* \\return C of size L * N\n*/\ntemplate <typename T>\nFull_matrix<T> bgemmt(const Full_matrix<T>& A, const Full_matrix<T>& tB);\n+\n+/*\n+ * \\brief binary general matrix multiplication with B transposed: tC = A * tB, tB is B transposed, tC is C transposed\n+ * \\param A must be of size L * M\n+ * \\param tB must be of size N * M\n+ * \\return C of size L * N\n+ */\nSparse_matrix bgemmt(const Sparse_matrix& A, const Sparse_matrix& tB);\n/*\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/matrix_utils.hxx",
"new_path": "src/Tools/Algo/Matrix/matrix_utils.hxx",
"diff": "#define MATRIX_UTILS_HXX__\n#include <sstream>\n+#include <mipp.h>\n#include \"matrix_utils.h\"\n@@ -56,11 +57,11 @@ Full_matrix<T> bgemm(const Full_matrix<T>& A, const Full_matrix<T>& B)\nfor (size_t l = 0; l < L; l++)\nfor (size_t n = 0; n < N; n++)\n{\n- T sum = 0;\n+ T res = 0;\nfor (size_t m = 0; m < M; m++)\n- sum += A[l][m] * B[m][n];\n+ res = res != ((A[l][m] != (T)0) && (B[m][n] != (T)0));\n- C[l][n] = sum & (T)1; // modulo 2\n+ C[l][n] = res;\n}\nreturn C;\n@@ -89,14 +90,29 @@ Full_matrix<T> bgemmt(const Full_matrix<T>& A, const Full_matrix<T>& tB)\nFull_matrix<T> C(L, N);\n+ const auto M_loop_size = (M / (size_t)mipp::nElReg<T>()) * (size_t)mipp::nElReg<T>();\n+\nfor (size_t l = 0; l < L; l++)\nfor (size_t n = 0; n < N; n++)\n{\n- T sum = 0;\n- for (size_t m = 0; m < M; m++)\n- sum += A[l][m] * tB[n][m];\n+ mipp::Msk<mipp::N<T>()> m_res = false;\n+ const mipp::Reg<T> r_zero = (T)0;\n+ const mipp::Reg<T> r_one = (T)1;\n+ for (size_t m = 0; m < M_loop_size; m += mipp::nElReg<T>())\n+ {\n+ const auto a_in = mipp::Reg<T>(& A[l][m]);\n+ const auto b_in = mipp::Reg<T>(&tB[n][m]);\n+\n+ m_res ^= ((a_in != r_zero) & (b_in != r_zero));\n+ }\n+\n+ auto r_res = mipp::blend(r_one, r_zero, m_res);\n+\n+ T res = mipp::hadd(r_res) & (T)1; // modulo 2\n+ for (size_t m = M_loop_size; m < M; m++)\n+ res = res != ((A[l][m] != (T)0) && (tB[n][m] != (T)0));\n- C[l][n] = sum & (T)1; // modulo 2\n+ C[l][n] = res;\n}\nreturn C;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
add comments and optimize with MIPP bgemmt for full matrix
|
8,483 |
28.08.2018 10:28:16
| -7,200 |
e07c30311962a1518f937d52617d47f2a9d8fff6
|
Add a G from H build function with a sparsing method (from ADS)
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -171,24 +171,218 @@ bool LDPC_matrix_handler\n}\nSparse_matrix LDPC_matrix_handler\n-::transform_H_to_G(const Sparse_matrix& H, Positions_vector& info_bits_pos)\n+::transform_H_to_G_sparse(const Sparse_matrix& H, Positions_vector& info_bits_pos)\n{\nH.is_of_way_throw(Matrix::Way::HORIZONTAL);\nLDPC_matrix Hf = sparse_to_full<LDPC_matrix::value_type>(H);\n- auto Gf = LDPC_matrix_handler::transform_H_to_G(Hf, info_bits_pos);\n+ auto Gf = LDPC_matrix_handler::transform_H_to_G_sparse(Hf, info_bits_pos);\nreturn full_to_sparse(Gf);\n}\n+Sparse_matrix LDPC_matrix_handler\n+::transform_H_to_G_fast(const Sparse_matrix& H, Positions_vector& info_bits_pos)\n+{\n+ H.is_of_way_throw(Matrix::Way::HORIZONTAL);\n+ LDPC_matrix Hf = sparse_to_full<LDPC_matrix::value_type>(H);\n+\n+ auto Gf = LDPC_matrix_handler::transform_H_to_G_fast(Hf, info_bits_pos);\n+\n+ return full_to_sparse(Gf);\n+}\n+\n+void swap_columns(LDPC_matrix_handler::LDPC_matrix& mat, size_t idx1, size_t idx2)\n+{\n+ auto n_row = mat.get_n_rows();\n+ std::vector<LDPC_matrix_handler::LDPC_matrix::value_type> tmp(n_row);\n+ for (size_t l = 0; l < n_row; l++) tmp[l] = mat[l][idx1];\n+ for (size_t l = 0; l < n_row; l++) mat[l][idx1] = mat[l][idx2];\n+ for (size_t l = 0; l < n_row; l++) mat[l][idx2] = tmp[l];\n+}\n+\n+template<bool allow_rank_deficient = true>\n+LDPC_matrix_handler::LDPC_matrix gauss_decomposition(const LDPC_matrix_handler::LDPC_matrix& Hp)\n+{\n+ using V = LDPC_matrix_handler::LDPC_matrix::value_type;\n+\n+ auto mat = Hp;\n+\n+ auto n_rows = mat.get_n_rows();\n+ auto n_cols = mat.get_n_cols();\n+\n+ auto n_min = std::min(n_rows, n_cols);\n+ bool rank_deficient = false;\n+ LDPC_matrix_handler::Positions_vector null_rows;\n+\n+\n+ // add an identity to the right part\n+ mat.self_resize(n_rows, n_cols + n_rows, Matrix::Origin::TOP_LEFT);\n+ for (size_t i = 0; i < n_rows; i++) // Add falling diagonal identity at the end\n+ mat[i][i + n_cols] = true;\n+\n+ LDPC_matrix_handler::Positions_vector pos_rows(n_rows), pos_cols(n_cols);\n+ std::iota(pos_rows.begin(), pos_rows.end(), 0);\n+ std::iota(pos_cols.begin(), pos_cols.end(), 0);\n+\n+ // try to generate an identity diagonal in the left part\n+ for (size_t d = 0; d < n_min; d++)\n+ {\n+ // permutation step\n+ bool found = false;\n+ for (size_t c = d; c < n_cols; c++)\n+ {\n+ for (size_t r = d; r < n_rows; r++)\n+ if (mat[r][c])\n+ {\n+ if (r != d)\n+ {\n+ // row permutation\n+ std::swap(pos_rows[d], pos_rows[r]);\n+ std::swap(mat [d], mat [r]);\n+ }\n+\n+ if (c != d)\n+ {\n+ // col permutation\n+ std::swap(pos_cols[d], pos_cols[c]);\n+ swap_columns(mat, d, c);\n+ }\n+\n+ found = true;\n+ break;\n+ }\n+\n+ if (found)\n+ break;\n+ }\n+\n+ if (!found)\n+ {\n+ // throw (d - 1);\n+ n_min = d;\n+ rank_deficient = true;\n+ break;\n+ }\n+\n+ // elimination step\n+ for (size_t r = d + 1; r < n_rows; r++)\n+ if (mat[r][d])\n+ std::transform(mat[d].begin() + d + 1, mat[d].end(), //ref\n+ mat[r].begin() + d + 1, mat[r].begin() + d + 1,\n+ std::not_equal_to<V>());\n+ }\n+\n+\n+ // keep the right part of the initial identity and add zeros below to find back original mat size\n+ auto X = mat.resize(n_min, n_rows, Matrix::Origin::TOP_RIGHT); // delete rows below n_min\n+ X.self_resize(n_cols, n_rows, Matrix::Origin::TOP_LEFT); // add null rows below part if n_cols != n_min\n+\n+\n+ // back substitution\n+ X.self_transpose(); // X is now HORIZONTAL\n+ for (size_t r = 0; r < X.get_n_rows(); r++)\n+ for (size_t d = n_min - 1; d > 0; d--)\n+ for (size_t c = d; c < n_min; c++)\n+ X[r][d - 1] = X[r][d - 1] != ((mat[d - 1][c] != (V)0) && (X[r][c] != (V)0)); // row of 'mat' * row of 'X'\n+\n+\n+ if (allow_rank_deficient && rank_deficient)\n+ {\n+ auto Hp2 = Hp;\n+ // find null rows of X and delete them in Hp2\n+ for (auto r = X.get_n_rows(); r > 0; r--)\n+ {\n+ auto r_test = r - 1;\n+ if (std::find(X[r_test].begin(), X[r_test].end(), (V)true) == X[r_test].end())\n+ Hp2.erase_row(r_test);\n+ }\n+\n+ X.self_transpose(); // X is now VERTICAL\n+\n+ // permute rows of \"X\" according to permuted cols of \"mat\"\n+ for (size_t i = 0; i < n_cols; i++)\n+ std::swap(X[i], X[pos_cols[i]]);\n+\n+ // find null cols of X and delete them in Hp2\n+ for (auto r = X.get_n_rows(); r > 0; r--)\n+ {\n+ auto r_test = r - 1;\n+ if (std::find(X[r_test].begin(), X[r_test].end(), (V)true) == X[r_test].end())\n+ Hp2.erase_col(r_test);\n+ }\n+\n+ return gauss_decomposition<false>(Hp2);\n+ }\n+ else\n+ {\n+ X.self_transpose(); // X is now VERTICAL\n+\n+ // permute rows of \"X\" according to permuted cols of \"mat\"\n+ for (size_t i = 0; i < n_cols; i++)\n+ std::swap(X[i], X[pos_cols[i]]);\n+\n+ return X;\n+ }\n+}\n+\n+// Benjamin's version\nLDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n-::transform_H_to_G(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n+::transform_H_to_G_sparse(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n+{\n+ H.is_of_way_throw(Matrix::Way::HORIZONTAL);\n+\n+ auto M = H.get_n_rows();\n+ auto N = H.get_n_cols();\n+ auto K = N - M;\n+\n+ auto Hp = H.resize(M, M, Matrix::Origin::TOP_RIGHT); // parity part of H -> Horizontal M * M\n+\n+ LDPC_matrix Gp;\n+\n+ Gp = gauss_decomposition(Hp); // Gp is VERTICAL -> M * M\n+\n+ auto Hs = H.resize(M, K, Matrix::Origin::TOP_LEFT); // systematic part of H\n+ Hs.self_transpose();\n+ auto GH = bgemmt(Gp, Hs); // Gp * Hs -> horizontal M * K\n+ // GH.self_resize(GH.get_n_rows(), GH.get_n_cols() - M, Matrix::Origin::TOP_LEFT); // remove right part\n+ GH.self_transpose(); // now vertical K * M\n+\n+ // add identity on the left part\n+ GH.self_resize(K, N, Matrix::Origin::TOP_RIGHT);\n+ for (size_t r = 0; r < K; r++)\n+ GH[r][r] = 1;\n+\n+ // GH is now G -> K * N\n+\n+\n+ // // check that G is good\n+ // Hp.self_transpose(); // now vertical M*M\n+ // auto GHp = bgemmt(Gp, Hp); // Gp * Hp\n+\n+ // // remove the identy\n+ // auto min_size = std::min(GHp.get_n_rows(), GHp.get_n_cols());\n+ // for (size_t r = 0; r < min_size; r++)\n+ // GHp[r][r] = !GHp[r][r];\n+\n+ // if (!all_zeros(GHp))\n+ // throw runtime_error(__FILE__, __LINE__, __func__, \"Generated Gp from H is not good (Gp * Hp != Identity).\");\n+\n+ info_bits_pos.resize(K);\n+ std::iota(info_bits_pos.begin(), info_bits_pos.end(), 0);\n+\n+ return GH;\n+}\n+\n+// Valentin's version\n+LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n+::transform_H_to_G_fast(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n{\nH.is_of_way_throw(Matrix::Way::HORIZONTAL);\nauto G = H;\n- auto M = G.get_n_rows();\n- auto N = G.get_n_cols();\n+ auto M = H.get_n_rows();\n+ auto N = H.get_n_cols();\nauto K = N - M;\nauto swapped_cols = LDPC_matrix_handler::form_diagonal(G, Matrix::Origin::TOP_LEFT);\n@@ -218,51 +412,45 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\nstd::copy(bits_pos.begin() + M, bits_pos.end(), info_bits_pos.begin());\nreturn G;\n+}\n+// Olivier's version\n+/*LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n+::transform_H_to_G(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n+{\n+ H.is_of_way_throw(Matrix::Way::HORIZONTAL);\n+ auto G = H;\n+ auto M = H.get_n_rows();\n+ auto N = H.get_n_cols();\n+ auto K = N - M;\n- // // erase the just created M*M identity in the right part of H\n- // G.self_resize(M, K, Matrix::Origin::TOP_LEFT);\n-\n- // // transpose G\n- // G.self_transpose();\n-\n- // // add the K*K falling diagonal identity on the left\n- // G.self_resize(K, N, Matrix::Origin::TOP_RIGHT);\n- // for (size_t i = 0; i < K; i++)\n- // G[i][i] = 1;\n+ auto swapped_cols = LDPC_matrix_handler::form_diagonal(G, Matrix::Origin::BOTTOM_RIGHT);\n+ LDPC_matrix_handler::form_identity(G, Matrix::Origin::BOTTOM_RIGHT);\n- // // G is now HORIZONTAL\n- // // Re-organization: get G\n- // // TODO: transpose G\n- // // for (auto& p : swapped_cols)\n- // // std::swap(G[p.first], G[p.second]);\n+ G.self_resize(N, K, Matrix::Origin::BOTTOM_LEFT); // G is now VERTICAL N*K\n+ for (size_t i = 0; i < K; i++) // Add falling diagonal identity above\n+ G[i][i] = 1;\n- // // return info bits positions\n- // info_bits_pos.resize(K);\n+ // Re-organization: get G\n+ for (auto l = swapped_cols.size(); l > 0; l--)\n+ std::swap(G[swapped_cols[l-1].first], G[swapped_cols[l-1].second]);\n- // // Positions_vector bits_pos(N);\n- // // std::iota(bits_pos.begin(), bits_pos.end(), 0);\n+ // return info bits positions\n+ info_bits_pos.resize(K);\n- // // for (size_t l = 1; l <= (swapped_cols.size() / 2); l++)\n- // // std::swap(bits_pos[swapped_cols[l*2-2]], bits_pos[swapped_cols[l*2-1]]);\n+ Positions_vector bits_pos(N);\n+ std::iota(bits_pos.begin(), bits_pos.end(), 0);\n- // // std::copy(bits_pos.begin() + M, bits_pos.end(), info_bits_pos.begin());\n- // std::iota(info_bits_pos.begin(), info_bits_pos.end(), 0);\n+ for (auto& p : swapped_cols)\n+ std::swap(bits_pos[p.first], bits_pos[p.second]);\n- // return G;\n-}\n+ std::copy(bits_pos.begin() + M, bits_pos.end(), info_bits_pos.begin());\n-void swap_columns(LDPC_matrix_handler::LDPC_matrix& mat, size_t idx1, size_t idx2)\n-{\n- auto n_row = mat.get_n_rows();\n- std::vector<LDPC_matrix_handler::LDPC_matrix::value_type> tmp(n_row);\n- for (size_t l = 0; l < n_row; l++) tmp[l] = mat[l][idx1];\n- for (size_t l = 0; l < n_row; l++) mat[l][idx1] = mat[l][idx2];\n- for (size_t l = 0; l < n_row; l++) mat[l][idx2] = tmp[l];\n-}\n+ return G;\n+}*/\nLDPC_matrix_handler::Positions_pair_vector LDPC_matrix_handler\n::form_diagonal(LDPC_matrix& mat, Matrix::Origin o)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "@@ -67,12 +67,24 @@ public:\nstatic void form_identity(LDPC_matrix& mat, Matrix::Origin o = Matrix::Origin::TOP_LEFT);\n/*\n- * Compute a G matrix related to the given H matrix.\n- * G is returned vertical.\n- * Return also the information bits positions in the returned G matrix.\n+ * \\brief Compute a G matrix related to the given H matrix. This method favors a sparse generator matrix build\n+ * but it may take more time. Warning do not work yet with irregular matrices.\n+ * \\return G horizontal with a guarantee to have the identity on the left part.\n+ * \\param info_bits_pos is filled with the positions (that are 0 to K-1) of the information bits.\n+ * \\param H (in Horizontal way) is the parity matrix from which G is built.\n*/\n- static Sparse_matrix transform_H_to_G(const Sparse_matrix& H, Positions_vector& info_bits_pos);\n- static LDPC_matrix transform_H_to_G(const LDPC_matrix& H, Positions_vector& info_bits_pos);\n+ static Sparse_matrix transform_H_to_G_sparse(const Sparse_matrix& H, Positions_vector& info_bits_pos);\n+ static LDPC_matrix transform_H_to_G_sparse(const LDPC_matrix& H, Positions_vector& info_bits_pos);\n+\n+ /*\n+ * \\brief Compute a G matrix related to the given H matrix. This method is quite fast and build a matrix that is not\n+ * necessary the hollowest.\n+ * \\return G vertical with not necessary an identity.\n+ * \\param info_bits_pos is filled with the positions (between 0 to N-1) of the information bits in G.\n+ * \\param H (in Horizontal way) is the parity matrix from which G is built.\n+ */\n+ static Sparse_matrix transform_H_to_G_fast(const Sparse_matrix& H, Positions_vector& info_bits_pos);\n+ static LDPC_matrix transform_H_to_G_fast(const LDPC_matrix& H, Positions_vector& info_bits_pos);\n/*\n* integrate an interleaver inside the matrix to avoid this step.\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a G from H build function with a sparsing method (from ADS)
|
8,483 |
28.08.2018 10:29:19
| -7,200 |
42dd98d87af5621c2360723559422d0c82ca410e
|
Remove overload of is_sys and get_info_bit_pos in encoder LDPC. Add for encoder LDPC_H a new G from H generation method in option in factory and allow the save of the generated matrix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "@@ -50,8 +50,6 @@ void Encoder_LDPC::parameters\nargs.add_link({p+\"-h-path\"}, {p+\"-cw-size\", \"N\"}); // N_cw is H width\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-\n-\nargs.add(\n{p+\"-g-path\"},\ntools::File(tools::openmode::read),\n@@ -65,6 +63,18 @@ void Encoder_LDPC::parameters\ntools::Text(tools::Including_set(\"NONE\", \"ASC\", \"DSC\")),\n\"specify if the check nodes (CNs) from H have to be reordered, 'NONE': do nothing (default), 'ASC': from the \"\n\"smallest to the biggest CNs, 'DSC': from the biggest to the smallest CNs.\");\n+\n+ args.add(\n+ {p+\"-g-method\"},\n+ tools::Text(tools::Including_set(\"FAST\", \"SPARSE\")),\n+ \"The method used to generate G from H when using 'LDPC_H' encoder type. 'SPARSE' method generates a hollow G \"\n+ \"with a guarantee to have the systematic identity (do not work with irregular matrices) when the 'FAST' method \"\n+ \"favors a fastest way to create it.\");\n+\n+ args.add(\n+ {p+\"-save-g\"},\n+ tools::File(tools::openmode::write),\n+ \"path where the generated G matrix with the 'LDPC_H' encoder type will be saved.\");\n}\nvoid Encoder_LDPC::parameters\n@@ -75,6 +85,8 @@ void Encoder_LDPC::parameters\nif(vals.exist({p+\"-h-path\" })) this->H_path = vals.at({p+\"-h-path\" });\nif(vals.exist({p+\"-g-path\" })) this->G_path = vals.at({p+\"-g-path\" });\nif(vals.exist({p+\"-h-reorder\"})) this->H_reorder = vals.at({p+\"-h-reorder\"});\n+ if(vals.exist({p+\"-g-method\" })) this->G_method = vals.at({p+\"-g-method\" });\n+ if(vals.exist({p+\"-save-g\" })) this->G_save = vals.at({p+\"-save-g\" });\nif (!this->G_path.empty())\ntools::LDPC_matrix_handler::read_matrix_size(this->G_path, this->K, this->N_cw);\n@@ -104,6 +116,13 @@ void Encoder_LDPC::parameters\nheaders[p].push_back(std::make_pair(\"H matrix path\", this->H_path));\nheaders[p].push_back(std::make_pair(\"H matrix reordering\", this->H_reorder));\n}\n+\n+ if (this->type == \"LDPC_H\")\n+ {\n+ headers[p].push_back(std::make_pair(\"G build method\", this->G_method));\n+ if (this->G_save != \"\")\n+ headers[p].push_back(std::make_pair(\"G save path\", this->G_save));\n+ }\n}\ntemplate <typename B>\n@@ -111,7 +130,7 @@ module::Encoder_LDPC<B>* Encoder_LDPC::parameters\n::build(const tools::Sparse_matrix &G, const tools::Sparse_matrix &H, const tools::dvbs2_values* dvbs2) const\n{\nif (this->type == \"LDPC\" ) return new module::Encoder_LDPC <B>(this->K, this->N_cw, G, this->n_frames);\n- else if (this->type == \"LDPC_H\" ) return new module::Encoder_LDPC_from_H <B>(this->K, this->N_cw, H, this->n_frames);\n+ else if (this->type == \"LDPC_H\" ) return new module::Encoder_LDPC_from_H <B>(this->K, this->N_cw, H, this->G_method, this->G_save, this->n_frames);\nelse if (this->type == \"LDPC_QC\" ) return new module::Encoder_LDPC_from_QC <B>(this->K, this->N_cw, H, this->n_frames);\nelse if (this->type == \"LDPC_IRA\") return new module::Encoder_LDPC_from_IRA<B>(this->K, this->N_cw, H, this->n_frames);\nelse if (this->type == \"LDPC_DVBS2\" && dvbs2 != nullptr)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"diff": "@@ -21,13 +21,17 @@ struct Encoder_LDPC : public Encoder\n{\npublic:\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n- // optional\n+ // matrices\nstd::string H_path = \"\";\nstd::string G_path = \"\";\n// optional parameters\nstd::string H_reorder = \"NONE\";\n+ // G generator method\n+ std::string G_method = \"FAST\";\n+ std::string G_save = \"\";\n+\n// ---------------------------------------------------------------------------------------------------- METHODS\nexplicit parameters(const std::string &p = Encoder_LDPC_prefix);\nvirtual ~parameters();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/DVBS2/Encoder_LDPC_DVBS2.cpp",
"new_path": "src/Module/Encoder/LDPC/DVBS2/Encoder_LDPC_DVBS2.cpp",
"diff": "@@ -53,20 +53,6 @@ void Encoder_LDPC_DVBS2<B>\nPx[i] = Px[i] ^ Px[i-1];\n}\n-template <typename B>\n-const std::vector<uint32_t>& Encoder_LDPC_DVBS2<B>\n-::get_info_bits_pos() const\n-{\n- return Encoder<B>::get_info_bits_pos();\n-}\n-\n-template <typename B>\n-bool Encoder_LDPC_DVBS2<B>\n-::is_sys() const\n-{\n- return Encoder<B>::is_sys();\n-}\n-\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/DVBS2/Encoder_LDPC_DVBS2.hpp",
"new_path": "src/Module/Encoder/LDPC/DVBS2/Encoder_LDPC_DVBS2.hpp",
"diff": "@@ -21,10 +21,6 @@ public:\nEncoder_LDPC_DVBS2(const tools::dvbs2_values& dvbs2, const int n_frames = 1);\nvirtual ~Encoder_LDPC_DVBS2() = default;\n- const std::vector<uint32_t>& get_info_bits_pos() const;\n-\n- bool is_sys() const;\n-\nprotected:\nvoid _encode(const B *U_K, B *X_N, const int frame_id);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "@@ -107,20 +107,6 @@ void Encoder_LDPC<B>\n}\n}\n-template <typename B>\n-const std::vector<uint32_t>& Encoder_LDPC<B>\n-::get_info_bits_pos() const\n-{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n-}\n-\n-template <typename B>\n-bool Encoder_LDPC<B>\n-::is_sys() const\n-{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n-}\n-\ntemplate <typename B>\nbool Encoder_LDPC<B>\n::is_codeword(const B *X_N)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"new_path": "src/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"diff": "@@ -33,8 +33,6 @@ public:\nEncoder_LDPC(const int K, const int N, const tools::Sparse_matrix &G, const tools::Sparse_matrix &H, const int n_frames = 1);\nvirtual ~Encoder_LDPC() = default;\n- virtual const std::vector<uint32_t>& get_info_bits_pos() const;\n- virtual bool is_sys() const;\nvirtual bool is_codeword(const B *X_N);\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"new_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"diff": "#include <numeric>\n#include <functional>\n#include <sstream>\n+#include <fstream>\n#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Code/LDPC/AList/AList.hpp\"\n#include \"Encoder_LDPC_from_H.hpp\"\n@@ -13,31 +15,42 @@ using namespace aff3ct::module;\ntemplate <typename B>\nEncoder_LDPC_from_H<B>\n-::Encoder_LDPC_from_H(const int K, const int N, const tools::Sparse_matrix &H, const int n_frames)\n+::Encoder_LDPC_from_H(const int K, const int N, const tools::Sparse_matrix &_H, const std::string& G_method,\n+ const std::string& G_save_path, const int n_frames)\n: Encoder_LDPC<B>(K, N, n_frames)\n{\nconst std::string name = \"Encoder_LDPC_from_H\";\nthis->set_name(name);\n- this->G = tools::LDPC_matrix_handler::transform_H_to_G(H.turn(tools::Matrix::Way::HORIZONTAL), this->info_bits_pos);\n- this->H = H;\n+ this->H = _H.turn(tools::Matrix::Way::HORIZONTAL);\n- this->check_G_dimensions();\n- this->check_H_dimensions();\n+ if (G_method == \"FAST\")\n+ this->G = tools::LDPC_matrix_handler::transform_H_to_G_fast(this->H, this->info_bits_pos);\n+ else if (G_method == \"SPARSE\")\n+ this->G = tools::LDPC_matrix_handler::transform_H_to_G_sparse(this->H, this->info_bits_pos);\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"Generation method of G 'G_method' is unknown ('G_method' = \\\"\" << G_method << \"\\\").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n-template <typename B>\n-bool Encoder_LDPC_from_H<B>\n-::is_sys() const\n+ if (G_save_path != \"\")\n+ {\n+ std::ofstream file(G_save_path);\n+ if (!file.is_open())\n{\n- return Encoder<B>::is_sys();\n+ std::stringstream message;\n+ message << \"'G_save_path' could not be opened ('G_save_path' = \\\"\" << G_save_path << \"\\\").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n-template <typename B>\n-const std::vector<uint32_t>& Encoder_LDPC_from_H<B>\n-::get_info_bits_pos() const\n-{\n- return Encoder<B>::get_info_bits_pos();\n+ tools::AList::write(this->G, file);\n+ tools::AList::write_info_bits_pos(this->info_bits_pos, file);\n+ }\n+\n+ this->check_G_dimensions();\n+ this->check_H_dimensions();\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.hpp",
"new_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.hpp",
"diff": "@@ -16,12 +16,9 @@ template <typename B = int>\nclass Encoder_LDPC_from_H : public Encoder_LDPC<B>\n{\npublic:\n- Encoder_LDPC_from_H(const int K, const int N, const tools::Sparse_matrix &H, const int n_frames = 1);\n+ Encoder_LDPC_from_H(const int K, const int N, const tools::Sparse_matrix &H, const std::string& G_method = \"FAST\",\n+ const std::string& G_save_path = \"\", const int n_frames = 1);\nvirtual ~Encoder_LDPC_from_H() = default;\n-\n- const std::vector<uint32_t>& get_info_bits_pos() const;\n-\n- bool is_sys() const;\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_IRA/Encoder_LDPC_from_IRA.cpp",
"new_path": "src/Module/Encoder/LDPC/From_IRA/Encoder_LDPC_from_IRA.cpp",
"diff": "@@ -54,20 +54,6 @@ void Encoder_LDPC_from_IRA<B>\n}\n}\n-template <typename B>\n-const std::vector<uint32_t>& Encoder_LDPC_from_IRA<B>\n-::get_info_bits_pos() const\n-{\n- return Encoder<B>::get_info_bits_pos();\n-}\n-\n-template <typename B>\n-bool Encoder_LDPC_from_IRA<B>\n-::is_sys() const\n-{\n- return Encoder<B>::is_sys();\n-}\n-\ntemplate <typename B>\nvoid Encoder_LDPC_from_IRA<B>\n::_check_H_dimensions()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_IRA/Encoder_LDPC_from_IRA.hpp",
"new_path": "src/Module/Encoder/LDPC/From_IRA/Encoder_LDPC_from_IRA.hpp",
"diff": "@@ -19,10 +19,6 @@ public:\nEncoder_LDPC_from_IRA(const int K, const int N, const tools::Sparse_matrix &H, const int n_frames = 1);\nvirtual ~Encoder_LDPC_from_IRA() = default;\n- const std::vector<uint32_t>& get_info_bits_pos() const;\n-\n- bool is_sys() const;\n-\nprotected:\nvoid _encode(const B *U_K, B *X_N, const int frame_id);\nvoid _check_H_dimensions();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"new_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"diff": "@@ -52,20 +52,6 @@ void Encoder_LDPC_from_QC<B>\n}\n}\n-template <typename B>\n-const std::vector<uint32_t>& Encoder_LDPC_from_QC<B>\n-::get_info_bits_pos() const\n-{\n- return Encoder<B>::get_info_bits_pos();\n-}\n-\n-template <typename B>\n-bool Encoder_LDPC_from_QC<B>\n-::is_sys() const\n-{\n- return Encoder<B>::is_sys();\n-}\n-\ntemplate <typename B>\nvoid Encoder_LDPC_from_QC<B>\n::_check_H_dimensions()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.hpp",
"new_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.hpp",
"diff": "@@ -22,10 +22,6 @@ public:\nEncoder_LDPC_from_QC(const int K, const int N, const tools::Sparse_matrix &H, const int n_frames = 1);\nvirtual ~Encoder_LDPC_from_QC() = default;\n- const std::vector<uint32_t>& get_info_bits_pos() const;\n-\n- bool is_sys() const;\n-\nprotected:\nvoid _encode(const B *U_K, B *X_N, const int frame_id);\nvoid _check_H_dimensions();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove overload of is_sys and get_info_bit_pos in encoder LDPC. Add for encoder LDPC_H a new G from H generation method in option in factory and allow the save of the generated matrix
|
8,483 |
28.08.2018 10:38:36
| -7,200 |
e4f95632af15d281f6483d6a2d4a988b304e1f95
|
Add a exception throw when in SPARSE HtoG function if H is rank deficient.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -289,6 +289,7 @@ LDPC_matrix_handler::LDPC_matrix gauss_decomposition(const LDPC_matrix_handler::\nif (allow_rank_deficient && rank_deficient)\n{\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"The matrix H is rank deficient, the SPARSE method can't handle it for now.\");\nauto Hp2 = Hp;\n// find null rows of X and delete them in Hp2\nfor (auto r = X.get_n_rows(); r > 0; r--)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a exception throw when in SPARSE HtoG function if H is rank deficient.
|
8,483 |
28.08.2018 12:06:03
| -7,200 |
6bf5dd57659da086f30a2fc7cd275699d0c36805
|
Rename HtoG SPARSE method into IDENTITY method that is more explicit.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "@@ -66,10 +66,10 @@ void Encoder_LDPC::parameters\nargs.add(\n{p+\"-g-method\"},\n- tools::Text(tools::Including_set(\"FAST\", \"SPARSE\")),\n- \"The method used to generate G from H when using 'LDPC_H' encoder type. 'SPARSE' method generates a hollow G \"\n- \"with a guarantee to have the systematic identity (do not work with irregular matrices) when the 'FAST' method \"\n- \"favors a fastest way to create it.\");\n+ tools::Text(tools::Including_set(\"FAST\", \"IDENTITY\")),\n+ \"The method used to generate G from H when using 'LDPC_H' encoder type. 'IDENTITY' method generates an hollow G \"\n+ \"with a guarantee to have the systematic identity (do not work with irregular matrices and may take a lot of \"\n+ \"time for large matrices) when the 'FAST' method favors a fastest way to create it.\");\nargs.add(\n{p+\"-save-g\"},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"new_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"diff": "@@ -26,8 +26,8 @@ Encoder_LDPC_from_H<B>\nif (G_method == \"FAST\")\nthis->G = tools::LDPC_matrix_handler::transform_H_to_G_fast(this->H, this->info_bits_pos);\n- else if (G_method == \"SPARSE\")\n- this->G = tools::LDPC_matrix_handler::transform_H_to_G_sparse(this->H, this->info_bits_pos);\n+ else if (G_method == \"IDENTITY\")\n+ this->G = tools::LDPC_matrix_handler::transform_H_to_G_identity(this->H, this->info_bits_pos);\nelse\n{\nstd::stringstream message;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -171,12 +171,12 @@ bool LDPC_matrix_handler\n}\nSparse_matrix LDPC_matrix_handler\n-::transform_H_to_G_sparse(const Sparse_matrix& H, Positions_vector& info_bits_pos)\n+::transform_H_to_G_identity(const Sparse_matrix& H, Positions_vector& info_bits_pos)\n{\nH.is_of_way_throw(Matrix::Way::HORIZONTAL);\nLDPC_matrix Hf = sparse_to_full<LDPC_matrix::value_type>(H);\n- auto Gf = LDPC_matrix_handler::transform_H_to_G_sparse(Hf, info_bits_pos);\n+ auto Gf = LDPC_matrix_handler::transform_H_to_G_identity(Hf, info_bits_pos);\nreturn full_to_sparse(Gf);\n}\n@@ -329,7 +329,7 @@ LDPC_matrix_handler::LDPC_matrix gauss_decomposition(const LDPC_matrix_handler::\n// Benjamin's version\nLDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n-::transform_H_to_G_sparse(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n+::transform_H_to_G_identity(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n{\nH.is_of_way_throw(Matrix::Way::HORIZONTAL);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "@@ -67,14 +67,14 @@ public:\nstatic void form_identity(LDPC_matrix& mat, Matrix::Origin o = Matrix::Origin::TOP_LEFT);\n/*\n- * \\brief Compute a G matrix related to the given H matrix. This method favors a sparse generator matrix build\n- * but it may take more time. Warning do not work yet with irregular matrices.\n+ * \\brief Compute a G matrix related to the given H matrix. This method favors a hallowed generator matrix build\n+ * but it may take long time. Warning do not work yet with irregular matrices.\n* \\return G horizontal with a guarantee to have the identity on the left part.\n* \\param info_bits_pos is filled with the positions (that are 0 to K-1) of the information bits.\n* \\param H (in Horizontal way) is the parity matrix from which G is built.\n*/\n- static Sparse_matrix transform_H_to_G_sparse(const Sparse_matrix& H, Positions_vector& info_bits_pos);\n- static LDPC_matrix transform_H_to_G_sparse(const LDPC_matrix& H, Positions_vector& info_bits_pos);\n+ static Sparse_matrix transform_H_to_G_identity(const Sparse_matrix& H, Positions_vector& info_bits_pos);\n+ static LDPC_matrix transform_H_to_G_identity(const LDPC_matrix& H, Positions_vector& info_bits_pos);\n/*\n* \\brief Compute a G matrix related to the given H matrix. This method is quite fast and build a matrix that is not\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rename HtoG SPARSE method into IDENTITY method that is more explicit.
|
8,483 |
28.08.2018 12:22:20
| -7,200 |
57b290d72fa407a023c07b0e01e197317c45ba99
|
Renaming of variables in LDPC_matrix_handler::invert_H2
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -828,88 +828,88 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\nauto N = H.get_n_cols();\nauto K = N - M;\n- LDPC_matrix MatriceCalcul(M, 2 * M);\n+ LDPC_matrix Hinv(M, 2 * M);\n//Copy H2 on left\nfor (size_t i = 0; i < M; i++)\nfor (size_t j = 0; j < H.get_cols_from_row(i).size(); j++)\nif (H.get_cols_from_row(i)[j] >= K)\n- MatriceCalcul[i][H.get_cols_from_row(i)[j] - K] = 1;\n+ Hinv[i][H.get_cols_from_row(i)[j] - K] = 1;\n//Create identity on right\nfor (size_t i = 0; i < M; i++)\n- MatriceCalcul[i][M + i] = 1;\n+ Hinv[i][M + i] = 1;\n- //Pivot de Gauss (Forward)\n- for (size_t indLgn = 0; indLgn < M; indLgn++)\n+ // Gaussian elimination (Forward)\n+ for (size_t r = 0; r < M; r++)\n{\n- if (MatriceCalcul[indLgn][indLgn] == 0)\n+ if (Hinv[r][r] == 0)\n{\n- size_t indLgnSwap = 0;\n- for (auto indLgn2 = indLgn + 1; indLgn2 < M; indLgn2++)\n+ size_t r_swap = 0;\n+ for (auto r2 = r + 1; r2 < M; r2++)\n{\n- if (MatriceCalcul[indLgn2][indLgn] != 0)\n+ if (Hinv[r2][r] != 0)\n{\n- indLgnSwap = indLgn2;\n+ r_swap = r2;\nbreak;\n}\n}\n- if (indLgnSwap == 0)\n+ if (r_swap == 0)\n{\nstd::stringstream message;\nmessage << \"Matrix H2 (H = [H1 H2]) is not invertible\";\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- std::swap(MatriceCalcul[indLgn], MatriceCalcul[indLgnSwap]);\n+ std::swap(Hinv[r], Hinv[r_swap]);\n}\n- //XOR des lignes\n- for (auto indLgn2 = indLgn + 1; indLgn2 < M; indLgn2++)\n+ //XOR on lines\n+ for (auto r2 = r + 1; r2 < M; r2++)\n{\n- if (MatriceCalcul[indLgn2][indLgn] != 0)\n+ if (Hinv[r2][r] != 0)\n{\nconst auto loop_size1 = (size_t)(2 * M / mipp::nElReg<V>());\nfor (size_t i = 0; i < loop_size1; i++)\n{\n- const auto rLgn = mipp::Reg<V>(&MatriceCalcul[indLgn ][i * mipp::nElReg<V>()]);\n- const auto rLgn2 = mipp::Reg<V>(&MatriceCalcul[indLgn2][i * mipp::nElReg<V>()]);\n+ const auto rLgn = mipp::Reg<V>(&Hinv[r ][i * mipp::nElReg<V>()]);\n+ const auto rLgn2 = mipp::Reg<V>(&Hinv[r2][i * mipp::nElReg<V>()]);\nauto rLgn3 = rLgn2 ^ rLgn;\n- rLgn3.store(&MatriceCalcul[indLgn2][i * mipp::nElReg<V>()]);\n+ rLgn3.store(&Hinv[r2][i * mipp::nElReg<V>()]);\n}\nfor (unsigned i = loop_size1 * mipp::nElReg<V>(); i < 2 * M; i++)\n- MatriceCalcul[indLgn2][i] = MatriceCalcul[indLgn2][i] ^ MatriceCalcul[indLgn][i];\n+ Hinv[r2][i] = Hinv[r2][i] ^ Hinv[r][i];\n}\n}\n}\n- //Pivot de Gauss (Backward)\n- for (auto indLgn = M - 1; indLgn > 0; indLgn--)\n+ // Gaussian elimination (Backward)\n+ for (auto r = M - 1; r > 0; r--)\n{\n- //XOR des lignes\n- for (auto indLgn2 = indLgn - 1; indLgn2 > 0; indLgn2--)\n+ //XOR on lines\n+ for (auto r2 = r - 1; r2 > 0; r2--)\n{\n- if (MatriceCalcul[indLgn2][indLgn] != 0)\n+ if (Hinv[r2][r] != 0)\n{\nconst auto loop_size1 = (size_t)(2 * M / mipp::nElReg<V>());\nfor (size_t i = 0; i < loop_size1; i++)\n{\n- const auto rLgn = mipp::Reg<V>(&MatriceCalcul[indLgn][i * mipp::nElReg<V>()]);\n- const auto rLgn2 = mipp::Reg<V>(&MatriceCalcul[indLgn2][i * mipp::nElReg<V>()]);\n+ const auto rLgn = mipp::Reg<V>(&Hinv[r ][i * mipp::nElReg<V>()]);\n+ const auto rLgn2 = mipp::Reg<V>(&Hinv[r2][i * mipp::nElReg<V>()]);\nauto rLgn3 = rLgn2 ^ rLgn;\n- rLgn3.store(&MatriceCalcul[indLgn2][i * mipp::nElReg<V>()]);\n+ rLgn3.store(&Hinv[r2][i * mipp::nElReg<V>()]);\n}\nfor (auto i = loop_size1 * mipp::nElReg<V>(); i < 2 * M; i++)\n- MatriceCalcul[indLgn2][i] = MatriceCalcul[indLgn2][i] ^ MatriceCalcul[indLgn][i];\n+ Hinv[r2][i] = Hinv[r2][i] ^ Hinv[r][i];\n}\n}\n}\n- MatriceCalcul.resize(M, M, Matrix::Origin::TOP_RIGHT);\n+ Hinv.resize(M, M, Matrix::Origin::TOP_RIGHT);\n- return MatriceCalcul;\n+ return Hinv;\n}\nbool LDPC_matrix_handler\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Renaming of variables in LDPC_matrix_handler::invert_H2
|
8,483 |
28.08.2018 15:59:58
| -7,200 |
0fd2bb3ffe73fca2a328511a0c0a9ed229a75879
|
Add a 0 on a null degree row or col
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"new_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"diff": "@@ -85,6 +85,9 @@ void AList\nif (zero_padding)\nfor (; i < matrix.get_rows_max_degree(); i++)\nstream << 0 << \" \";\n+ else if (r.size() == 0)\n+ stream << 0 << \" \";\n+\nstream << std::endl;\n}\nstream << std::endl;\n@@ -97,6 +100,8 @@ void AList\nif (zero_padding)\nfor (; i < matrix.get_cols_max_degree(); i++)\nstream << 0 << \" \";\n+ else if (c.size() == 0)\n+ stream << 0 << \" \";\nstream << std::endl;\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a 0 on a null degree row or col
|
8,483 |
28.08.2018 16:00:23
| -7,200 |
ad322f502fc07bc987eafaf31b2066b7757a20a1
|
Add resize / self_resize methods to Sparse_Matrix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.cpp",
"new_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.cpp",
"diff": "@@ -113,110 +113,103 @@ void Sparse_matrix\n// else the connection has not been found\n}\n+void Sparse_matrix\n+::parse_connections()\n+{\n+ this->n_connections = std::accumulate(row_to_cols.begin(), row_to_cols.end(), (size_t)0,\n+ [](size_t init, const std::vector<size_t>& a){ return init + a.size();});\n+\n+ this->rows_max_degree = std::max_element(row_to_cols.begin(), row_to_cols.end(),\n+ [](const std::vector<size_t>& a, const std::vector<size_t>& b){ return a.size() < b.size();})\n+ ->size();\n+ this->cols_max_degree = std::max_element(col_to_rows.begin(), col_to_rows.end(),\n+ [](const std::vector<size_t>& a, const std::vector<size_t>& b){ return a.size() < b.size();})\n+ ->size();\n+}\n+\nvoid Sparse_matrix\n::self_resize(const size_t n_rows, const size_t n_cols, Origin o)\n{\n- // const auto min_r = std::min(n_rows, get_n_rows());\n-\n- // switch(o)\n- // {\n- // case Origin::TOP_LEFT:\n- // {\n- // values.resize(n_rows, std::vector<T>(n_cols, 0));\n- // for (size_t r = 0; r < min_r; r++)\n- // values[r].resize(n_cols, 0);\n- // }\n- // break;\n- // case Origin::TOP_RIGHT:\n- // {\n- // values.resize(n_rows, std::vector<T>(n_cols, 0));\n- // if (n_cols < get_n_cols())\n- // {\n- // auto n_erase = get_n_cols() - n_cols;\n- // for (size_t r = 0; r < n_rows; r++)\n- // values[r].erase(values[r].begin(), values[r].begin() + n_erase);\n- // }\n- // else\n- // {\n- // auto n_insert = n_cols - get_n_cols();\n- // for (size_t r = 0; r < min_r; r++)\n- // values[r].insert(values[r].begin(), n_insert, 0);\n- // }\n- // }\n- // break;\n- // case Origin::BOTTOM_LEFT:\n- // {\n- // if (n_rows < get_n_rows())\n- // {\n- // auto n_erase = get_n_rows() - n_rows;\n- // values.erase(values.begin(), values.begin() + n_erase);\n-\n- // for (size_t r = 0; r < min_r; r++)\n- // values[r].resize(n_cols, 0);\n- // }\n- // else\n- // {\n- // auto n_insert = n_rows - get_n_rows();\n- // values.insert(values.begin(), n_insert, std::vector<T>(n_cols, 0));\n-\n- // for (size_t r = n_insert; r < n_rows; r++)\n- // values[r].resize(n_cols, 0);\n- // }\n- // }\n- // break;\n- // case Origin::BOTTOM_RIGHT:\n- // {\n- // if (n_rows < get_n_rows())\n- // {\n- // auto n_erase = get_n_rows() - n_rows;\n- // values.erase(values.begin(), values.begin() + n_erase);\n-\n- // if (n_cols < get_n_cols())\n- // {\n- // auto n_erase = get_n_cols() - n_cols;\n- // for (size_t r = 0; r < n_rows; r++)\n- // values[r].erase(values[r].begin(), values[r].begin() + n_erase);\n- // }\n- // else\n- // {\n- // auto n_insert = n_cols - get_n_cols();\n- // for (size_t r = 0; r < min_r; r++)\n- // values[r].insert(values[r].begin(), n_insert, 0);\n- // }\n- // }\n- // else\n- // {\n- // auto n_insert = n_rows - get_n_rows();\n- // values.insert(values.begin(), n_insert, std::vector<T>(n_cols, 0));\n-\n- // if (n_cols < get_n_cols())\n- // {\n- // auto n_erase = get_n_cols() - n_cols;\n- // for (size_t r = n_insert; r < n_rows; r++)\n- // values[r].erase(values[r].begin(), values[r].begin() + n_erase);\n- // }\n- // else\n- // {\n- // auto n_insert = n_cols - get_n_cols();\n- // for (size_t r = n_insert; r < min_r; r++)\n- // values[r].insert(values[r].begin(), n_insert, 0);\n- // }\n- // }\n- // }\n- // break;\n- // }\n-\n- // Matrix::self_resize(n_rows, n_cols);\n-\n- // parse_connections();\n+ *this = this->resize(n_rows, n_rows, o);\n}\nSparse_matrix Sparse_matrix\n::resize(const size_t n_rows, const size_t n_cols, Origin o) const\n{\n- Sparse_matrix resized(*this);\n+ Sparse_matrix resized(n_rows, n_cols);\n+\n+ const auto min_r = std::min(n_rows, get_n_rows());\n+ const auto min_c = std::min(n_cols, get_n_cols());\n+ const auto diff_r = get_n_rows() - min_r;\n+ const auto diff_c = get_n_cols() - min_c;\n+ const auto diff_n_rows = (int)n_rows - (int)get_n_rows();\n+ const auto diff_n_cols = (int)n_cols - (int)get_n_cols();\n+\n+ switch(o)\n+ {\n+ case Origin::TOP_LEFT:\n+ {\n+ for (size_t c = 0; c < min_c; c++)\n+ for (size_t r = 0; r < col_to_rows[c].size(); r++)\n+ {\n+ const auto col_index = c;\n+ const auto row_index = col_to_rows[c][r];\n+ if (row_index < n_rows)\n+ {\n+ resized.row_to_cols[row_index].push_back(col_index);\n+ resized.col_to_rows[col_index].push_back(row_index);\n+ }\n+ }\n+ }\n+ break;\n+ case Origin::TOP_RIGHT:\n+ {\n+ for (size_t c = diff_c; c < get_n_cols(); c++)\n+ for (size_t r = 0; r < col_to_rows[c].size(); r++)\n+ {\n+ const auto col_index = diff_n_cols + c;\n+ const auto row_index = col_to_rows[c][r];\n+ if (row_index < n_rows)\n+ {\n+ resized.row_to_cols[row_index].push_back(col_index);\n+ resized.col_to_rows[col_index].push_back(row_index);\n+ }\n+ }\n+ }\n+ break;\n+ case Origin::BOTTOM_LEFT:\n+ {\n+ for (size_t c = 0; c < min_c; c++)\n+ for (size_t r = 0; r < col_to_rows[c].size(); r++)\n+ {\n+ const auto col_index = c;\n+ const auto row_index = diff_n_rows + (int)col_to_rows[c][r];\n+ if (row_index >= 0)\n+ {\n+ resized.row_to_cols[row_index].push_back(col_index);\n+ resized.col_to_rows[col_index].push_back(row_index);\n+ }\n+ }\n+ }\n+ break;\n+ case Origin::BOTTOM_RIGHT:\n+ {\n+ for (size_t c = diff_c; c < get_n_cols(); c++)\n+ for (size_t r = 0; r < col_to_rows[c].size(); r++)\n+ {\n+ const auto col_index = diff_n_cols + c;\n+ const auto row_index = diff_n_rows + (int)col_to_rows[c][r];\n+ if (row_index >= 0)\n+ {\n+ resized.row_to_cols[row_index].push_back(col_index);\n+ resized.col_to_rows[col_index].push_back(row_index);\n+ }\n+ }\n+ }\n+ break;\n+ }\n- resized.self_resize(n_rows, n_cols, o);\n+ resized.parse_connections();\nreturn resized;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.hpp",
"new_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.hpp",
"diff": "@@ -113,6 +113,14 @@ public:\nprivate:\nstd::vector<std::vector<size_t>> row_to_cols;\nstd::vector<std::vector<size_t>> col_to_rows;\n+\n+\n+ /*\n+ * Compute the rows and cols degrees values when the matrix values have been modified\n+ * without the use of 'add_connection' and 'rm_connection' interface, so after any modification\n+ * call this function if you need degrees information\n+ */\n+ void parse_connections();\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add resize / self_resize methods to Sparse_Matrix
|
8,483 |
28.08.2018 17:19:17
| -7,200 |
b4ec02cd36d8708ac0c28f4414dd9be9c4242e77
|
Change name method HtoG FAST into Identity
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "@@ -66,10 +66,10 @@ void Encoder_LDPC::parameters\nargs.add(\n{p+\"-g-method\"},\n- tools::Text(tools::Including_set(\"FAST\", \"LU_DEC\")),\n+ tools::Text(tools::Including_set(\"IDENTITY\", \"LU_DEC\")),\n\"The method used to generate G from H when using 'LDPC_H' encoder type. 'LU_DEC' method generates a hollow G \"\n\"thanks to the LU decomposition with a guarantee to have the systematic identity (do not work with irregular \"\n- \"matrices) when the 'FAST' method favors a fastest way to create it.\");\n+ \"matrices) when the 'IDENTITY' method generate an identity on H to get the parity part.\");\nargs.add(\n{p+\"-save-g\"},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"diff": "@@ -29,7 +29,7 @@ struct Encoder_LDPC : public Encoder\nstd::string H_reorder = \"NONE\";\n// G generator method\n- std::string G_method = \"FAST\";\n+ std::string G_method = \"IDENTITY\";\nstd::string G_save = \"\";\n// ---------------------------------------------------------------------------------------------------- METHODS\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"new_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"diff": "@@ -24,8 +24,8 @@ Encoder_LDPC_from_H<B>\nthis->H = _H.turn(tools::Matrix::Way::HORIZONTAL);\n- if (G_method == \"FAST\")\n- this->G = tools::LDPC_matrix_handler::transform_H_to_G_fast(this->H, this->info_bits_pos);\n+ if (G_method == \"IDENTITY\")\n+ this->G = tools::LDPC_matrix_handler::transform_H_to_G_identity(this->H, this->info_bits_pos);\nelse if (G_method == \"LU_DEC\")\nthis->G = tools::LDPC_matrix_handler::transform_H_to_G_decomp_LU(this->H, this->info_bits_pos);\nelse\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -182,12 +182,12 @@ Sparse_matrix LDPC_matrix_handler\n}\nSparse_matrix LDPC_matrix_handler\n-::transform_H_to_G_fast(const Sparse_matrix& H, Positions_vector& info_bits_pos)\n+::transform_H_to_G_identity(const Sparse_matrix& H, Positions_vector& info_bits_pos)\n{\nH.is_of_way_throw(Matrix::Way::HORIZONTAL);\nLDPC_matrix Hf = sparse_to_full<LDPC_matrix::value_type>(H);\n- auto Gf = LDPC_matrix_handler::transform_H_to_G_fast(Hf, info_bits_pos);\n+ auto Gf = LDPC_matrix_handler::transform_H_to_G_identity(Hf, info_bits_pos);\nreturn full_to_sparse(Gf);\n}\n@@ -486,7 +486,7 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n// Valentin's version\nLDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n-::transform_H_to_G_fast(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n+::transform_H_to_G_identity(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n{\nH.is_of_way_throw(Matrix::Way::HORIZONTAL);\nauto G = H;\n@@ -528,7 +528,7 @@ LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n// Olivier's version = Valentin's version with identity formed on the right part but does not work, why ?\n// This may be as fast as the Valentin's version but more hollow\n/*LDPC_matrix_handler::LDPC_matrix LDPC_matrix_handler\n-::transform_H_to_G(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n+::transform_H_to_G_identity(const LDPC_matrix& H, Positions_vector& info_bits_pos)\n{\nH.is_of_way_throw(Matrix::Way::HORIZONTAL);\nauto G = H;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "@@ -67,8 +67,8 @@ public:\nstatic void form_identity(LDPC_matrix& mat, Matrix::Origin o = Matrix::Origin::TOP_LEFT);\n/*\n- * \\brief Compute a G matrix related to the given H matrix. This method favors a hallowed generator matrix build\n- * but it may take long time. Warning do not work yet with irregular matrices.\n+ * \\brief Compute a G matrix related to the given H matrix. This method favors a hallowed generator matrix build.\n+ * It uses the LU decomposition. Warning do not work yet with irregular matrices.\n* \\return G horizontal with a guarantee to have the identity on the left part.\n* \\param info_bits_pos is filled with the positions (that are 0 to K-1) of the information bits.\n* \\param H (in Horizontal way) is the parity matrix from which G is built.\n@@ -77,14 +77,14 @@ public:\nstatic LDPC_matrix transform_H_to_G_decomp_LU(const LDPC_matrix& H, Positions_vector& info_bits_pos);\n/*\n- * \\brief Compute a G matrix related to the given H matrix. This method is quite fast and build a matrix that is not\n- * necessary the hollowest.\n+ * \\brief Compute a G matrix related to the given H matrix. This method builds a matrix by creating an identity on\n+ * the left part of H then taking the parity part to create G.\n* \\return G vertical with not necessary an identity.\n* \\param info_bits_pos is filled with the positions (between 0 to N-1) of the information bits in G.\n* \\param H (in Horizontal way) is the parity matrix from which G is built.\n*/\n- static Sparse_matrix transform_H_to_G_fast(const Sparse_matrix& H, Positions_vector& info_bits_pos);\n- static LDPC_matrix transform_H_to_G_fast(const LDPC_matrix& H, Positions_vector& info_bits_pos);\n+ static Sparse_matrix transform_H_to_G_identity(const Sparse_matrix& H, Positions_vector& info_bits_pos);\n+ static LDPC_matrix transform_H_to_G_identity(const LDPC_matrix& H, Positions_vector& info_bits_pos);\n/*\n* integrate an interleaver inside the matrix to avoid this step.\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change name method HtoG FAST into Identity
|
8,483 |
29.08.2018 10:00:34
| -7,200 |
8f7c2c4cdabba940290a681713e91cba8636aa9b
|
Change the use of size_t index for connection into uint32_t
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.cpp",
"new_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.cpp",
"diff": "@@ -118,13 +118,13 @@ void Sparse_matrix\n::parse_connections()\n{\nthis->n_connections = std::accumulate(row_to_cols.begin(), row_to_cols.end(), (size_t)0,\n- [](size_t init, const std::vector<size_t>& a){ return init + a.size();});\n+ [](size_t init, const std::vector<Idx_t>& a){ return init + a.size();});\nthis->rows_max_degree = std::max_element(row_to_cols.begin(), row_to_cols.end(),\n- [](const std::vector<size_t>& a, const std::vector<size_t>& b){ return a.size() < b.size();})\n+ [](const std::vector<Idx_t>& a, const std::vector<Idx_t>& b){ return a.size() < b.size();})\n->size();\nthis->cols_max_degree = std::max_element(col_to_rows.begin(), col_to_rows.end(),\n- [](const std::vector<size_t>& a, const std::vector<size_t>& b){ return a.size() < b.size();})\n+ [](const std::vector<Idx_t>& a, const std::vector<Idx_t>& b){ return a.size() < b.size();})\n->size();\n}\n@@ -250,11 +250,11 @@ void Sparse_matrix\n{\ncase Sort::ASCENDING:\nstd::sort(this->col_to_rows.begin(), this->col_to_rows.end(),\n- [](const std::vector<size_t> &i1, const std::vector<size_t> &i2) { return i1.size() < i2.size(); });\n+ [](const std::vector<Idx_t> &i1, const std::vector<Idx_t> &i2) { return i1.size() < i2.size(); });\nbreak;\ncase Sort::DESCENDING:\nstd::sort(this->col_to_rows.begin(), this->col_to_rows.end(),\n- [](const std::vector<size_t> &i1, const std::vector<size_t> &i2) { return i1.size() > i2.size(); });\n+ [](const std::vector<Idx_t> &i1, const std::vector<Idx_t> &i2) { return i1.size() > i2.size(); });\nbreak;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.hpp",
"new_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.hpp",
"diff": "@@ -15,32 +15,33 @@ namespace tools\nclass Sparse_matrix : public Matrix\n{\npublic:\n+ using Idx_t = uint32_t;\nSparse_matrix(const size_t n_rows = 0, const size_t n_cols = 1);\nvirtual ~Sparse_matrix() = default;\n- inline const std::vector<size_t>& get_cols_from_row(const size_t row_index) const\n+ inline const std::vector<Idx_t>& get_cols_from_row(const size_t row_index) const\n{\nreturn this->row_to_cols[row_index];\n}\n- inline const std::vector<size_t>& get_rows_from_col(const size_t col_index) const\n+ inline const std::vector<Idx_t>& get_rows_from_col(const size_t col_index) const\n{\nreturn this->col_to_rows[col_index];\n}\n- inline const std::vector<size_t>& operator[](const size_t col_index) const\n+ inline const std::vector<Idx_t>& operator[](const size_t col_index) const\n{\nreturn this->get_rows_from_col(col_index);\n}\n- inline const std::vector<std::vector<size_t>>& get_row_to_cols() const\n+ inline const std::vector<std::vector<Idx_t>>& get_row_to_cols() const\n{\nreturn this->row_to_cols;\n}\n- inline const std::vector<std::vector<size_t>>& get_col_to_rows() const\n+ inline const std::vector<std::vector<Idx_t>>& get_col_to_rows() const\n{\nreturn this->col_to_rows;\n}\n@@ -111,8 +112,8 @@ public:\nstatic Sparse_matrix zero(const size_t n_rows, const size_t n_cols);\nprivate:\n- std::vector<std::vector<size_t>> row_to_cols;\n- std::vector<std::vector<size_t>> col_to_rows;\n+ std::vector<std::vector<Idx_t>> row_to_cols;\n+ std::vector<std::vector<Idx_t>> col_to_rows;\n/*\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change the use of size_t index for connection into uint32_t
|
8,483 |
29.08.2018 10:21:29
| -7,200 |
cef77e81ac180f6ec212df969abb0df90ea60528
|
Check the returned sizes of G and H in encoder/decoder LDPC factories and swap them if necessary to have the good proportions
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"diff": "@@ -140,6 +140,10 @@ void Decoder_LDPC::parameters\n{\nint M;\ntools::LDPC_matrix_handler::read_matrix_size(this->H_path, M, this->N_cw);\n+\n+ if (M > this->N_cw)\n+ std::swap(M, this->N_cw);\n+\nthis->K = this->N_cw - M; // considered as regular so M = N - K\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "@@ -89,12 +89,20 @@ void Encoder_LDPC::parameters\nif(vals.exist({p+\"-save-g\" })) this->G_save = vals.at({p+\"-save-g\" });\nif (!this->G_path.empty())\n+ {\ntools::LDPC_matrix_handler::read_matrix_size(this->G_path, this->K, this->N_cw);\n+ if (this->K > this->N_cw)\n+ std::swap(this->K, this->N_cw);\n+ }\nelse if (!this->H_path.empty())\n{\nint M;\ntools::LDPC_matrix_handler::read_matrix_size(this->H_path, M, this->N_cw);\n+\n+ if (M > this->N_cw)\n+ std::swap(M, this->N_cw);\n+\nthis->K = this->N_cw - M; // considered as regular so M = N - K\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "@@ -77,7 +77,7 @@ Sparse_matrix LDPC_matrix_handler\n{\ncase Matrix_format::QC:\n{\n- S = tools::QC::read(file);\n+ S = std::move(tools::QC::read(file));\nif (pct_pattern != nullptr)\n*pct_pattern = tools::QC::read_pct_pattern(file);\n@@ -86,7 +86,7 @@ Sparse_matrix LDPC_matrix_handler\n}\ncase Matrix_format::ALIST:\n{\n- S = tools::AList::read(file);\n+ S = std::move(tools::AList::read(file));\nif (info_bits_pos != nullptr)\ntry\n@@ -98,7 +98,6 @@ Sparse_matrix LDPC_matrix_handler\ninfo_bits_pos->clear();\n// information bits positions are not in the matrix file\n}\n-\nbreak;\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Check the returned sizes of G and H in encoder/decoder LDPC factories and swap them if necessary to have the good proportions
|
8,494 |
06.09.2018 17:19:33
| -7,200 |
e25da7ac7c4494c209f1258f74a42e00644aa104
|
Add WBF and MWBF fit flipping decoders for LDPC codes
|
[
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit 03c3e0c82039d9e0f81537f27f7c5dbdc24d3dde\n+Subproject commit 5899187811258b8c85613994a511849654e59741\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/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+#include \"Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp\"\n+\n+\n#include \"Decoder_LDPC.hpp\"\n@@ -73,11 +76,11 @@ 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_VERTICAL_LAYERED\", \"BP_PEELING\");\n+ tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_FLOODING\", \"BP_HORIZONTAL_LAYERED\", \"BP_VERTICAL_LAYERED\", \"BP_PEELING\", \"BIT_FLIPPING\");\n#ifdef __cpp_aligned_new\ntools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_HORIZONTAL_LAYERED_LEGACY\");\n#endif\n- tools::add_options(args.at({p+\"-implem\" }), 0, \"SPA\", \"LSPA\", \"MS\", \"OMS\", \"NMS\", \"AMS\", \"GALA\");\n+ tools::add_options(args.at({p+\"-implem\" }), 0, \"SPA\", \"LSPA\", \"MS\", \"OMS\", \"NMS\", \"AMS\", \"GALA\", \"WBF\");\nargs.add(\n{p+\"-ite\", \"i\"},\n@@ -89,6 +92,11 @@ void Decoder_LDPC::parameters\ntools::Real(),\n\"offset used in the offset min-sum BP algorithm (works only with \\\"--dec-implem NMS\\\").\");\n+ args.add(\n+ {p+\"-mwbf\"},\n+ tools::Real(),\n+ \"factor used in the modified WBF algorithm (works only with \\\"--dec-implem WBF\\\"). Set 0 for basic WBF\");\n+\nargs.add(\n{p+\"-norm\"},\ntools::Real(tools::Positive()),\n@@ -133,6 +141,7 @@ void Decoder_LDPC::parameters\nif(vals.exist({p+\"-ite\", \"i\"})) this->n_ite = vals.to_int ({p+\"-ite\", \"i\"});\nif(vals.exist({p+\"-synd-depth\"})) this->syndrome_depth = vals.to_int ({p+\"-synd-depth\"});\nif(vals.exist({p+\"-off\" })) this->offset = vals.to_float({p+\"-off\" });\n+ if(vals.exist({p+\"-mwbf\" })) this->mwbf_factor = vals.to_float({p+\"-mwbf\" });\nif(vals.exist({p+\"-norm\" })) this->norm_factor = vals.to_float({p+\"-norm\" });\nif(vals.exist({p+\"-no-synd\" })) this->enable_syndrome = false;\n@@ -240,6 +249,10 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\nelse 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+ else if (this->type == \"BIT_FLIPPING\")\n+ {\n+ if (this->implem == \"WBF\") return new module::Decoder_LDPC_bit_flipping_OMWBF<B,Q>( this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->mwbf_factor, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ }\n#ifdef __cpp_aligned_new\nelse if (this->type == \"BP_HORIZONTAL_LAYERED\" && this->simd_strategy == \"INTER\")\n{\n@@ -354,6 +367,7 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\nelse if (this->min == \"MINS\") return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_AMS_simd<Q,tools::min_star_i <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS_simd<Q,tools::min_star_i <Q>>(), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n}\n+\n#endif\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.hpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.hpp",
"diff": "@@ -32,6 +32,7 @@ struct Decoder_LDPC : public Decoder\nstd::string simd_strategy = \"\";\nfloat norm_factor = 1.f;\nfloat offset = 0.f;\n+ float mwbf_factor = 0.f;\nbool enable_syndrome = true;\nint syndrome_depth = 1;\nint n_ite = 10;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.cpp",
"diff": "+#include <chrono>\n+#include <limits>\n+#include <sstream>\n+\n+#include \"Tools/Perf/common/hard_decide.h\"\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Math/utils.h\"\n+\n+#include \"Decoder_LDPC_bit_flipping.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+// constexpr int C_to_V_max = 15; // saturation value for the LLRs/extrinsics\n+\n+template <typename B, typename R>\n+Decoder_LDPC_bit_flipping<B,R>\n+::Decoder_LDPC_bit_flipping(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 R mwbf_factor,\n+ const bool enable_syndrome,\n+ const int syndrome_depth,\n+ const int n_frames,\n+ const std::string name)\n+: Decoder (K, N, n_frames, 1 ),\n+ Decoder_SISO_SIHO<B,R>(K, N, n_frames, 1 ),\n+ n_ite (n_ite ),\n+ n_V_nodes (N ), // same as N but more explicit\n+ n_C_nodes ((int)H.get_n_cols() ),\n+ n_branches ((int)H.get_n_connections() ),\n+ mwbf_factor (mwbf_factor ),\n+ enable_syndrome (enable_syndrome ),\n+ syndrome_depth (syndrome_depth ),\n+ H (H ),\n+ init_flag (true ),\n+ info_bits_pos (info_bits_pos ),\n+ Lp_N (N, -1), // -1 in order to fail when AZCW\n+ C_to_V (n_frames, std::vector<R>(this->n_branches)),\n+ V_to_C (n_frames, std::vector<R>(this->n_branches))\n+{\n+ /*if (n_ite <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'n_ite' has to be greater than 0 ('n_ite' = \" << n_ite << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }*/\n+\n+ if (syndrome_depth <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'syndrome_depth' has to be greater than 0 ('syndrome_depth' = \" << syndrome_depth << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (N != (int)H.get_n_rows())\n+ {\n+ std::stringstream message;\n+ message << \"'N' is not compatible with the H matrix ('N' = \" << N << \", 'H.get_n_rows()' = \"\n+ << H.get_n_rows() << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ transpose.resize(this->n_branches);\n+ mipp::vector<unsigned char> connections(H.get_n_rows(), 0);\n+\n+ const auto &CN_to_VN = H.get_col_to_rows();\n+ const auto &VN_to_CN = H.get_row_to_cols();\n+\n+ auto k = 0;\n+ for (auto i = 0; i < (int)CN_to_VN.size(); i++)\n+ {\n+ for (auto j = 0; j < (int)CN_to_VN[i].size(); j++)\n+ {\n+ auto id_V = CN_to_VN[i][j];\n+\n+ auto branch_id = 0;\n+ for (auto ii = 0; ii < (int)id_V; ii++)\n+ branch_id += (int)VN_to_CN[ii].size();\n+ branch_id += connections[id_V];\n+ connections[id_V]++;\n+\n+ if (connections[id_V] > (int)VN_to_CN[id_V].size())\n+ {\n+ std::stringstream message;\n+ message << \"'connections[id_V]' has to be equal or smaller than 'VN_to_CN[id_V].size()' ('id_V' = \"\n+ << id_V << \", 'connections[id_V]' = \" << connections[id_V] << \", 'VN_to_CN[id_V].size()' = \"\n+ << VN_to_CN[id_V].size() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ transpose[k] = branch_id;\n+ k++;\n+ }\n+ }\n+\n+ n_variables_per_parity.resize(H.get_n_cols());\n+ for (auto i = 0; i < (int)H.get_n_cols(); i++)\n+ n_variables_per_parity[i] = (unsigned char)CN_to_VN[i].size();\n+\n+ n_parities_per_variable.resize(H.get_n_rows());\n+ for (auto i = 0; i < (int)H.get_n_rows(); i++)\n+ n_parities_per_variable[i] = (unsigned char)VN_to_CN[i].size();\n+}\n+\n+template <typename B, typename R>\n+Decoder_LDPC_bit_flipping<B,R>\n+::~Decoder_LDPC_bit_flipping()\n+{\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_bit_flipping<B,R>\n+::reset()\n+{\n+ this->init_flag = true;\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_bit_flipping<B,R>\n+::_decode_siso(const R *Y_N1, R *Y_N2, const int frame_id)\n+{\n+ printf(\"Je suis dans decode_siso\\n\");\n+ // memory zones initialization\n+ if (this->init_flag)\n+ {\n+ std::fill(this->C_to_V[frame_id].begin(), this->C_to_V[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+ // actual decoding\n+ this->BF_decode(Y_N1,frame_id);\n+\n+ // prepare for next round by processing extrinsic information\n+ for (auto i = 0; i < this->N; i++)\n+ Y_N2[i] = this->Lp_N[i] - Y_N1[i];\n+\n+ // saturate<R>(Y_N2, (R)-C_to_V_max, (R)C_to_V_max);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_bit_flipping<B,R>\n+::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n+{\n+ //printf(\"Je suis dans decode_siho\\n\");\n+// auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n+ // memory zones initialization\n+ if (this->init_flag)\n+ {\n+ std::fill(this->C_to_V[frame_id].begin(), this->C_to_V[frame_id].end(), (R)0);\n+\n+ if (frame_id == Decoder_SIHO<B,R>::n_frames -1)\n+ this->init_flag = false;\n+ }\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->BF_decode(Y_N, 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->Lp_N[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>\n+void Decoder_LDPC_bit_flipping<B,R>\n+::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n+{\n+ // printf(\"Je suis dans decode_siho_cw\\n\");\n+ // auto t_load = std::chrono::steady_clock::now(); // ----------------------------------------------------------- LOAD\n+ // memory zones initialization\n+ if (this->init_flag)\n+ {\n+ std::fill(this->C_to_V[frame_id].begin(), this->C_to_V[frame_id].end(), (R)0);\n+\n+ if (frame_id == Decoder_SIHO<B,R>::n_frames -1)\n+ this->init_flag = false;\n+ }\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->BF_decode(Y_N, 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->Lp_N.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+// BP algorithm\n+template <typename B, typename R>\n+void Decoder_LDPC_bit_flipping<B,R>\n+::BF_decode(const R *Y_N, const int frame_id)\n+{\n+ //printf(\"Je suis dans BF_decode1\\n\");\n+ auto cur_syndrome_depth = 0;\n+ R Y_min[this->n_C_nodes];\n+\n+ short decis[this->n_V_nodes];\n+\n+ //compute y_min,m for n in N(m)\n+ //printf(\"-----\\n\");\n+ for (auto imin = 0; imin < this->n_C_nodes; imin++)\n+ {\n+// printf(\"*****\\n\");\n+ const auto length = this->n_variables_per_parity[imin];\n+ auto minVal = std::numeric_limits<R>::max();\n+ for (auto mmin = 0; mmin < length; ++mmin)\n+ {\n+ auto comp = (R)std::abs(Y_N[this->H.get_rows_from_col(imin)[mmin]]);\n+ minVal = (minVal > comp)?comp:minVal;\n+// std::cout << comp << std::endl;\n+ }\n+ Y_min[imin] = minVal;\n+// std::cout << \"Min : \" << minVal << std::endl;\n+ }\n+// printf(\"-----\\n\");\n+\n+ // compute init Zn\n+ for (int i = 0; i < this->n_V_nodes; ++i)\n+ {\n+// printf(\"%f\\n\", Y_N[i]);\n+ decis[i] = (Y_N[i]<0)?1:0;\n+ }\n+\n+ // actual decoding\n+ for (auto ite = 0; ite < this->n_ite; ite++)\n+ {\n+ // specific inner code depending on the selected implementation (WBF for example)\n+ auto syndrome = this->BF_process(Y_N, this->V_to_C[frame_id], this->C_to_V[frame_id], Y_min, decis);\n+\n+ // stop criterion\n+ if (this->enable_syndrome && syndrome)\n+ {\n+ // cur_syndrome_depth++;\n+ // if (cur_syndrome_depth == this->syndrome_depth)\n+ break;\n+ }\n+ //else\n+ // cur_syndrome_depth = 0;\n+ }\n+\n+ //output\n+ for (auto i = 0; i < this->n_V_nodes; i++)\n+ {\n+ // filling the output\n+ this->Lp_N[i] = (decis[i] == 0)?1:-1;\n+ }\n+\n+ //printf(\"-----\\n\");\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::module::Decoder_LDPC_bit_flipping<B_8,Q_8>;\n+template class aff3ct::module::Decoder_LDPC_bit_flipping<B_16,Q_16>;\n+template class aff3ct::module::Decoder_LDPC_bit_flipping<B_32,Q_32>;\n+template class aff3ct::module::Decoder_LDPC_bit_flipping<B_64,Q_64>;\n+#else\n+template class aff3ct::module::Decoder_LDPC_bit_flipping<B,Q>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.hpp",
"diff": "+#ifndef DECODER_LDPC_BIT_FLIPPING_HPP_\n+#define DECODER_LDPC_BIT_FLIPPING_HPP_\n+\n+#include \"../../Decoder_SISO_SIHO.hpp\"\n+#include \"Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int, typename R = float>\n+class Decoder_LDPC_bit_flipping : public Decoder_SISO_SIHO<B,R>\n+{\n+public:\n+ void reset();\n+\n+protected:\n+ const int n_ite; // number of iterations to perform\n+ const int n_V_nodes; // number of variable nodes (= N)\n+ const int n_C_nodes; // number of check nodes (= N - K)\n+ const int n_branches; // number of branched in the bi-partite graph (connexions between the V and C nodes)\n+ const R mwbf_factor;\n+ const bool enable_syndrome;\n+ const int syndrome_depth;\n+\n+ // reset so C_to_V and V_to_C structures can be cleared only at the begining of the loop in iterative decoding\n+ bool init_flag;\n+\n+ const std::vector<unsigned> &info_bits_pos;\n+\n+ const tools::Sparse_matrix &H;\n+\n+ std::vector<unsigned char> n_variables_per_parity;\n+ std::vector<unsigned char> n_parities_per_variable;\n+ std::vector<unsigned int > transpose;\n+\n+ // data structures for iterative decoding\n+ std::vector<R> Lp_N; // a posteriori information\n+ std::vector<std::vector<R>> C_to_V; // check nodes to variable nodes messages\n+ std::vector<std::vector<R>> V_to_C; // variable nodes to check nodes messages\n+\n+ Decoder_LDPC_bit_flipping(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 R mwbf_factor = 0.0f,\n+ const bool enable_syndrome = true,\n+ const int syndrome_depth = 1,\n+ const int n_frames = 1,\n+ const std::string name = \"Decoder_LDPC_bit_flipping\");\n+ virtual ~Decoder_LDPC_bit_flipping();\n+\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+ // BP functions for decoding\n+ void BF_decode(const R *Y_N, const int frame_id);\n+\n+ virtual bool BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V, const R *Y_min, short *decis) = 0;\n+};\n+}\n+}\n+\n+#endif /* DECODER_LDPC_BIT_FLIPPING_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.cpp",
"diff": "+#include <limits>\n+#include <sstream>\n+#include <typeinfo>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Math/utils.h\"\n+\n+#include \"Decoder_LDPC_bit_flipping_OMWBF.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+template <typename B, typename R>\n+Decoder_LDPC_bit_flipping_OMWBF<B,R>\n+::Decoder_LDPC_bit_flipping_OMWBF(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 float normalize_factor,\n+ const R mwbf_factor,\n+ const bool enable_syndrome,\n+ const int syndrome_depth,\n+ const int n_frames,\n+ const std::string name)\n+: Decoder(K, N, n_frames, 1),\n+ Decoder_LDPC_bit_flipping<B,R>(K, N, n_ite, H, info_bits_pos,mwbf_factor , enable_syndrome, syndrome_depth, n_frames, name)\n+{\n+ if (typeid(R) == typeid(signed char))\n+ {\n+ std::stringstream message;\n+ message << \"This decoder does not work in 8-bit fixed-point (try in 16-bit).\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n+template <typename B, typename R>\n+Decoder_LDPC_bit_flipping_OMWBF<B,R>\n+::~Decoder_LDPC_bit_flipping_OMWBF()\n+{\n+}\n+\n+template <typename B, typename R>\n+bool Decoder_LDPC_bit_flipping_OMWBF<B,R>\n+::BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V, const R *Y_min, short *decis)\n+{\n+ short synd[this->n_C_nodes];\n+ bool syndrome = 0;\n+ R energy[this->n_V_nodes];\n+\n+ R alpha = 0.4;\n+\n+ for (auto i = 0; i < this->n_C_nodes; ++i)\n+ {\n+ synd[i] = 0;\n+\n+ for (auto j = 0; j < this->n_variables_per_parity[i]; ++j)\n+ synd[i] ^= decis[this->H.get_rows_from_col(i).at(j)];\n+\n+ syndrome |= synd[i];\n+ }\n+\n+ for (auto i = 0; i < this->n_V_nodes; ++i)\n+ {\n+ energy[i] = 0;\n+ for (auto j = 0; j < this->n_parities_per_variable[i]; ++j)\n+ {\n+ auto m = this->H.get_cols_from_row(i)[j];\n+ energy[i] += (2 * synd[m] - 1) * Y_min[m];\n+ }\n+ energy[i] -= this->mwbf_factor * (R)std::abs(Y_N[i]);\n+ }\n+\n+ auto indMax = 0;\n+ R valMax = energy[0];\n+\n+ for (auto i = 1; i < this->n_V_nodes; ++i)\n+ {\n+ if (valMax < energy[i])\n+ {\n+ valMax = energy[i];\n+ indMax = i;\n+ }\n+ }\n+ if (syndrome == 1)\n+ decis[indMax] = (decis[indMax] == 0)?1:0;\n+ return !syndrome;\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::module::Decoder_LDPC_bit_flipping_OMWBF<B_8,Q_8>;\n+template class aff3ct::module::Decoder_LDPC_bit_flipping_OMWBF<B_16,Q_16>;\n+template class aff3ct::module::Decoder_LDPC_bit_flipping_OMWBF<B_32,Q_32>;\n+template class aff3ct::module::Decoder_LDPC_bit_flipping_OMWBF<B_64,Q_64>;\n+#else\n+template class aff3ct::module::Decoder_LDPC_bit_flipping_OMWBF<B,Q>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n+\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp",
"diff": "+#ifndef DECODER_LDPC_BIT_FLIPPING_OMWBF_HPP_\n+#define DECODER_LDPC_BIT_FLIPPING_OMWBF_HPP_\n+\n+#include \"../Decoder_LDPC_bit_flipping.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int, typename R = float>\n+class Decoder_LDPC_bit_flipping_OMWBF : public Decoder_LDPC_bit_flipping<B,R>\n+{\n+//private:\n+// const float normalize_factor;\n+// const R offset;\n+\n+public:\n+ Decoder_LDPC_bit_flipping_OMWBF(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 float normalize_factor = 1.f,\n+ const R mwbf_factor = (R)0,\n+ const bool enable_syndrome = true,\n+ const int syndrome_depth = 1,\n+ const int n_frames = 1,\n+ const std::string name = \"Decoder_LDPC_bit_flipping_OMWBF\");\n+ virtual ~Decoder_LDPC_bit_flipping_OMWBF();\n+\n+protected:\n+ // BF functions for decoding\n+ virtual bool BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V, const R *Y_min, short *decis);\n+};\n+\n+template <typename B = int, typename R = float>\n+using Decoder_LDPC_bit_flipping_OMWBF = Decoder_LDPC_bit_flipping_OMWBF<B,R>;\n+}\n+}\n+\n+#endif /* DECODER_LDPC_BIT_FLIPPING_OMWBF_HPP_ */\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add WBF and MWBF fit flipping decoders for LDPC codes
|
8,494 |
07.09.2018 10:27:47
| -7,200 |
67cc4f6e79da13912714273f8fc07614873b9900
|
Remove useless things for compilation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.cpp",
"new_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.cpp",
"diff": "@@ -46,8 +46,6 @@ bool Decoder_LDPC_bit_flipping_OMWBF<B,R>\nbool syndrome = 0;\nR energy[this->n_V_nodes];\n- R alpha = 0.4;\n-\nfor (auto i = 0; i < this->n_C_nodes; ++i)\n{\nsynd[i] = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp",
"new_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp",
"diff": "@@ -31,9 +31,5 @@ protected:\nvirtual bool BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V, const R *Y_min, short *decis);\n};\n-template <typename B = int, typename R = float>\n-using Decoder_LDPC_bit_flipping_OMWBF = Decoder_LDPC_bit_flipping_OMWBF<B,R>;\n-}\n-}\n#endif /* DECODER_LDPC_BIT_FLIPPING_OMWBF_HPP_ */\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove useless things for compilation
|
8,494 |
07.09.2018 10:37:12
| -7,200 |
d2efc0215ef9a3df7c84c0db8d9f8d3ad8dd4747
|
Fix namespace closing
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp",
"new_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp",
"diff": "@@ -30,6 +30,7 @@ protected:\n// BF functions for decoding\nvirtual bool BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V, const R *Y_min, short *decis);\n};\n-\n+}\n+}\n#endif /* DECODER_LDPC_BIT_FLIPPING_OMWBF_HPP_ */\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix namespace closing
|
8,494 |
07.09.2018 11:02:16
| -7,200 |
60e0dbe622aeccd2169d10afb6bef869b156595e
|
Change local arrays into class vector attributes
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.cpp",
"new_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.cpp",
"diff": "@@ -21,8 +21,7 @@ Decoder_LDPC_bit_flipping<B,R>\nconst R mwbf_factor,\nconst bool enable_syndrome,\nconst int syndrome_depth,\n- const int n_frames,\n- const std::string name)\n+ const int n_frames)\n: Decoder (K, N, n_frames, 1 ),\nDecoder_SISO_SIHO<B,R>(K, N, n_frames, 1 ),\nn_ite (n_ite ),\n@@ -37,8 +36,13 @@ Decoder_LDPC_bit_flipping<B,R>\ninfo_bits_pos (info_bits_pos ),\nLp_N (N, -1), // -1 in order to fail when AZCW\nC_to_V (n_frames, std::vector<R>(this->n_branches)),\n- V_to_C (n_frames, std::vector<R>(this->n_branches))\n+ V_to_C (n_frames, std::vector<R>(this->n_branches)),\n+ Y_min (this->n_C_nodes ),\n+ decis (this->n_V_nodes )\n{\n+ const std::string name = \"Decoder_LDPC_bit_flipping\";\n+ this->set_name(name);\n+\n/*if (n_ite <= 0)\n{\nstd::stringstream message;\n@@ -212,9 +216,6 @@ void Decoder_LDPC_bit_flipping<B,R>\n{\n//printf(\"Je suis dans BF_decode1\\n\");\nauto cur_syndrome_depth = 0;\n- R Y_min[this->n_C_nodes];\n-\n- short decis[this->n_V_nodes];\n//compute y_min,m for n in N(m)\n//printf(\"-----\\n\");\n@@ -245,7 +246,7 @@ void Decoder_LDPC_bit_flipping<B,R>\nfor (auto ite = 0; ite < this->n_ite; ite++)\n{\n// specific inner code depending on the selected implementation (WBF for example)\n- auto syndrome = this->BF_process(Y_N, this->V_to_C[frame_id], this->C_to_V[frame_id], Y_min, decis);\n+ auto syndrome = this->BF_process(Y_N, this->V_to_C[frame_id], this->C_to_V[frame_id]);\n// stop criterion\nif (this->enable_syndrome && syndrome)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.hpp",
"new_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.hpp",
"diff": "@@ -45,8 +45,7 @@ protected:\nconst R mwbf_factor = 0.0f,\nconst bool enable_syndrome = true,\nconst int syndrome_depth = 1,\n- const int n_frames = 1,\n- const std::string name = \"Decoder_LDPC_bit_flipping\");\n+ const int n_frames = 1);\nvirtual ~Decoder_LDPC_bit_flipping();\nvoid _decode_siso (const R *Y_N1, R *Y_N2, const int frame_id);\n@@ -56,7 +55,11 @@ protected:\n// BP functions for decoding\nvoid BF_decode(const R *Y_N, const int frame_id);\n- virtual bool BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V, const R *Y_min, short *decis) = 0;\n+ virtual bool BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V) = 0;\n+\n+\n+ std::vector<R> Y_min;\n+ std::vector<short> decis;\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.cpp",
"new_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.cpp",
"diff": "@@ -19,11 +19,15 @@ Decoder_LDPC_bit_flipping_OMWBF<B,R>\nconst R mwbf_factor,\nconst bool enable_syndrome,\nconst int syndrome_depth,\n- const int n_frames,\n- const std::string name)\n+ const int n_frames)\n: Decoder(K, N, n_frames, 1),\n- Decoder_LDPC_bit_flipping<B,R>(K, N, n_ite, H, info_bits_pos,mwbf_factor , enable_syndrome, syndrome_depth, n_frames, name)\n+ Decoder_LDPC_bit_flipping<B,R>(K, N, n_ite, H, info_bits_pos,mwbf_factor , enable_syndrome, syndrome_depth, n_frames),\n+ synd (this->n_C_nodes),\n+ energy(this->n_V_nodes)\n{\n+ const std::string name = \"Decoder_LDPC_bit_flipping_OMWBF\";\n+ this->set_name(name);\n+\nif (typeid(R) == typeid(signed char))\n{\nstd::stringstream message;\n@@ -40,18 +44,16 @@ Decoder_LDPC_bit_flipping_OMWBF<B,R>\ntemplate <typename B, typename R>\nbool Decoder_LDPC_bit_flipping_OMWBF<B,R>\n-::BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V, const R *Y_min, short *decis)\n+::BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V)\n{\n- short synd[this->n_C_nodes];\nbool syndrome = 0;\n- R energy[this->n_V_nodes];\nfor (auto i = 0; i < this->n_C_nodes; ++i)\n{\nsynd[i] = 0;\nfor (auto j = 0; j < this->n_variables_per_parity[i]; ++j)\n- synd[i] ^= decis[this->H.get_rows_from_col(i).at(j)];\n+ synd[i] ^= this->decis[this->H.get_rows_from_col(i).at(j)];\nsyndrome |= synd[i];\n}\n@@ -62,7 +64,7 @@ bool Decoder_LDPC_bit_flipping_OMWBF<B,R>\nfor (auto j = 0; j < this->n_parities_per_variable[i]; ++j)\n{\nauto m = this->H.get_cols_from_row(i)[j];\n- energy[i] += (2 * synd[m] - 1) * Y_min[m];\n+ energy[i] += (2 * synd[m] - 1) * this->Y_min[m];\n}\nenergy[i] -= this->mwbf_factor * (R)std::abs(Y_N[i]);\n}\n@@ -79,7 +81,7 @@ bool Decoder_LDPC_bit_flipping_OMWBF<B,R>\n}\n}\nif (syndrome == 1)\n- decis[indMax] = (decis[indMax] == 0)?1:0;\n+ this->decis[indMax] = (this->decis[indMax] == 0)?1:0;\nreturn !syndrome;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp",
"new_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp",
"diff": "@@ -22,13 +22,16 @@ public:\nconst R mwbf_factor = (R)0,\nconst bool enable_syndrome = true,\nconst int syndrome_depth = 1,\n- const int n_frames = 1,\n- const std::string name = \"Decoder_LDPC_bit_flipping_OMWBF\");\n+ const int n_frames = 1);\nvirtual ~Decoder_LDPC_bit_flipping_OMWBF();\nprotected:\n// BF functions for decoding\n- virtual bool BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V, const R *Y_min, short *decis);\n+ virtual bool BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V);\n+\n+\n+ std::vector<short> synd ;\n+ std::vector<R> energy;\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change local arrays into class vector attributes
|
8,483 |
07.09.2018 12:39:08
| -7,200 |
a6c2da5ca1f04d0ae7c56a83cc56a0ac977f1752
|
Add explicit to constructors
|
[
{
"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": "@@ -100,11 +100,10 @@ void Decoder_RS_std<B,R>\nwhile ((discrepancy[q] == -1) && (q > 0))\nq--;\n- int j;\n// have found first non-zero discrepancy[q]\nif (q > 0)\n{\n- j = q;\n+ int j = q;\ndo\n{\nj--;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/Monitor.hpp",
"new_path": "src/Module/Monitor/Monitor.hpp",
"diff": "@@ -53,7 +53,7 @@ public:\n* \\param K: number of bits of information\n* \\param N: number of coded bits\n*/\n- Monitor(int n_frames = 1);\n+ explicit Monitor(int n_frames = 1);\n/*!\n* \\brief Destructor.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp",
"new_path": "src/Module/Monitor/Monitor_reduction_MPI.hpp",
"diff": "@@ -15,7 +15,7 @@ template <class M> // M is the monitor on which must be applied the reduction\nclass Monitor_reduction_MPI : public Monitor_reduction_M<M>\n{\npublic:\n- Monitor_reduction_MPI(const std::vector<M*> &monitors);\n+ explicit Monitor_reduction_MPI(const std::vector<M*> &monitors);\nvirtual ~Monitor_reduction_MPI() = default;\nvirtual void reset();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Update_rule/LSPA/Update_rule_LSPA_simd.hpp",
"new_path": "src/Tools/Code/LDPC/Update_rule/LSPA/Update_rule_LSPA_simd.hpp",
"diff": "@@ -33,7 +33,7 @@ protected:\nint ite;\npublic:\n- Update_rule_LSPA_simd(const unsigned max_chk_node_degree)\n+ explicit Update_rule_LSPA_simd(const unsigned max_chk_node_degree)\n: name(\"LSPA\"), false_msk(false), zero((R)0), half((R)0.5), two((R)2), min(std::numeric_limits<R>::min()),\nepsilon1m((R)1.0 - std::numeric_limits<R>::epsilon()), values(max_chk_node_degree), sign(false), sum(zero),\nn_ite(0), ite(0)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA_simd.hpp",
"new_path": "src/Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA_simd.hpp",
"diff": "@@ -32,7 +32,7 @@ protected:\nint ite;\npublic:\n- Update_rule_SPA_simd(const unsigned max_chk_node_degree)\n+ explicit Update_rule_SPA_simd(const unsigned max_chk_node_degree)\n: name(\"SPA\"), false_msk(false), one((R)1), half((R)0.5), two((R)2),\nepsilon1m((R)1.0 - std::numeric_limits<R>::epsilon()), values(max_chk_node_degree), sign(false), product(one),\nn_ite(0), ite(0)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/Polar/Pattern_polar_parser.hpp",
"new_path": "src/Tools/Code/Polar/Pattern_polar_parser.hpp",
"diff": "@@ -156,6 +156,9 @@ private:\nvoid recursive_allocate_nodes_patterns ( Binary_node<Pattern_polar_i>* node_curr);\nvoid generate_nodes_indexes (const Binary_node<Pattern_polar_i>* node_curr);\nvoid recursive_deallocate_nodes_patterns( Binary_node<Pattern_polar_i>* node_curr);\n+\n+ void operator=(Pattern_polar_parser&) = delete;\n+ Pattern_polar_parser(Pattern_polar_parser&) = delete;\n};\n}\n}\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": "@@ -27,9 +27,9 @@ public:\nprivate:\nstruct 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+ explicit Noise_ptr(const Noise<R>* const* n) : noise(nullptr), noise_ptr(n) {}\n+ explicit Noise_ptr(const Noise<R>* n) : noise(n), noise_ptr(&noise) {}\n+ explicit Noise_ptr(const Noise<R>& n) : noise(&n), noise_ptr(&noise) {}\nconst Noise<R>* get_noise_ptr() const\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Standard/Terminal_std.hpp",
"new_path": "src/Tools/Display/Terminal/Standard/Terminal_std.hpp",
"diff": "@@ -48,7 +48,7 @@ public:\n/*!\n* \\brief Constructor.\n*/\n- Terminal_std(std::vector<Reporter*>& reporters);\n+ explicit Terminal_std(std::vector<Reporter*>& reporters);\n/*!\n* \\brief Destructor.\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add explicit to constructors
|
8,494 |
07.09.2018 14:34:28
| -7,200 |
c47b0676d9d620d8f11607529cb94209331d6e73
|
Case cosmetics and add the matrix in conf doc
|
[
{
"change_type": "MODIFY",
"old_path": "conf",
"new_path": "conf",
"diff": "-Subproject commit d36d091f421b4d30ce28de4edf29f052c1da3b90\n+Subproject commit 190d0263bc579df42468024c2a6bbdadb18b7d83\n"
},
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit 5899187811258b8c85613994a511849654e59741\n+Subproject commit 5367a56c34ca8dd419d475188211adb468936e49\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.cpp",
"new_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.cpp",
"diff": "@@ -223,15 +223,15 @@ void Decoder_LDPC_bit_flipping<B,R>\n{\n// printf(\"*****\\n\");\nconst auto length = this->n_variables_per_parity[imin];\n- auto minVal = std::numeric_limits<R>::max();\n+ auto min_val = std::numeric_limits<R>::max();\nfor (auto mmin = 0; mmin < length; ++mmin)\n{\nauto comp = (R)std::abs(Y_N[this->H.get_rows_from_col(imin)[mmin]]);\n- minVal = (minVal > comp)?comp:minVal;\n+ min_val = (min_val > comp)?comp:min_val;\n// std::cout << comp << std::endl;\n}\n- Y_min[imin] = minVal;\n-// std::cout << \"Min : \" << minVal << std::endl;\n+ Y_min[imin] = min_val;\n+// std::cout << \"Min : \" << min_val << std::endl;\n}\n// printf(\"-----\\n\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.hpp",
"new_path": "src/Module/Decoder/LDPC/BF/Decoder_LDPC_bit_flipping.hpp",
"diff": "@@ -59,7 +59,7 @@ protected:\nstd::vector<R> Y_min;\n- std::vector<short> decis;\n+ std::vector<B> decis;\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.cpp",
"new_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.cpp",
"diff": "@@ -55,7 +55,7 @@ bool Decoder_LDPC_bit_flipping_OMWBF<B,R>\nfor (auto j = 0; j < this->n_variables_per_parity[i]; ++j)\nsynd[i] ^= this->decis[this->H.get_rows_from_col(i).at(j)];\n- syndrome |= synd[i];\n+ syndrome |= (synd[i] != 0);\n}\nfor (auto i = 0; i < this->n_V_nodes; ++i)\n@@ -69,19 +69,20 @@ bool Decoder_LDPC_bit_flipping_OMWBF<B,R>\nenergy[i] -= this->mwbf_factor * (R)std::abs(Y_N[i]);\n}\n- auto indMax = 0;\n- R valMax = energy[0];\n+ auto ind_max = 0;\n+ R val_max = energy[0];\nfor (auto i = 1; i < this->n_V_nodes; ++i)\n{\n- if (valMax < energy[i])\n+ if (val_max < energy[i])\n{\n- valMax = energy[i];\n- indMax = i;\n+ val_max = energy[i];\n+ ind_max = i;\n}\n}\n- if (syndrome == 1)\n- this->decis[indMax] = (this->decis[indMax] == 0)?1:0;\n+ if (syndrome)\n+ this->decis[ind_max] = (this->decis[ind_max] == 0)?1:0;\n+\nreturn !syndrome;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp",
"new_path": "src/Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp",
"diff": "@@ -30,7 +30,7 @@ protected:\nvirtual bool BF_process(const R *Y_N, std::vector<R> &V_to_C, std::vector<R> &C_to_V);\n- std::vector<short> synd ;\n+ std::vector<B> synd ;\nstd::vector<R> energy;\n};\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Case cosmetics and add the matrix in conf doc
|
8,483 |
07.09.2018 14:59:02
| -7,200 |
563354c1d422e14f262e3d22664e65984c9dd5db
|
Set the inheritance of the Full_matrix container as private and use as public only size() and operator[]
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.hpp",
"new_path": "src/Tools/Algo/Matrix/Full_matrix/Full_matrix.hpp",
"diff": "@@ -19,13 +19,13 @@ namespace tools\n*/\ntemplate <typename T = int32_t>\n-class Full_matrix : public Matrix, public std::vector<std::vector<T>>\n+class Full_matrix : public Matrix, private std::vector<std::vector<T>>\n{\npublic:\nusing Container = std::vector<std::vector<T>>;\nusing value_type = T;\n- Full_matrix(const unsigned n_rows = 0, const unsigned n_cols = 1);\n+ explicit Full_matrix(const unsigned n_rows = 0, const unsigned n_cols = 1);\nvirtual ~Full_matrix() = default;\n@@ -67,8 +67,8 @@ public:\nvoid erase_col(const size_t col_index, const size_t n_cols = 1);\n- void erase(); // never use 'erase' methods, use instead erase_col or erase_row\n-\n+ using Container::size;\n+ using Container::operator[];\n/*\n* Compute the rows and cols degrees values when the matrix values have been modified\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set the inheritance of the Full_matrix container as private and use as public only size() and operator[]
|
8,483 |
10.09.2018 09:43:37
| -7,200 |
9b75f3417b5429f24b82f59958078cb07a7adcbf
|
Use shared pointers in the SC simulations, too
|
[
{
"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": "@@ -14,11 +14,7 @@ template <typename B, typename R, typename Q>\nSC_BFER_ite<B,R,Q>\n::SC_BFER_ite(const factory::BFER_ite::parameters ¶ms_BFER_ite)\n: BFER_ite<B,R,Q>(params_BFER_ite),\n-\n- coset_real_i(nullptr),\n- duplicator(7, nullptr),\n- router (nullptr),\n- predicate (nullptr)\n+ duplicator(7)\n{\nif (this->params_BFER_ite.n_threads > 1)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"SystemC simulation does not support \"\n@@ -28,19 +24,13 @@ SC_BFER_ite<B,R,Q>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"SystemC simulation does not support the coded \"\n\"monitoring.\");\n- this->modules[\"coset_real_i\"] = std::vector<module::Module*>(params_BFER_ite.n_threads, nullptr);\n+ this->add_module(\"coset_real_i\", params_BFER_ite.n_threads);\n}\ntemplate <typename B, typename R, typename Q>\nSC_BFER_ite<B,R,Q>\n::~SC_BFER_ite()\n{\n- for (auto& d : this->duplicator)\n- if (d != nullptr)\n- {\n- delete d;\n- d = nullptr;\n- }\n}\ntemplate <typename B, typename R, typename Q>\n@@ -49,7 +39,7 @@ void SC_BFER_ite<B,R,Q>\n{\nBFER_ite<B,R,Q>::__build_communication_chain(tid);\n- this->modules[\"coset_real_i\"][tid] = coset_real_i;\n+ this->set_module(\"coset_real_i\", tid, coset_real_i);\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@@ -122,39 +112,29 @@ void SC_BFER_ite<B,R,Q>\ntools::Predicate_ite p(this->params_BFER_ite.n_ite);\n- this->duplicator[0] = new tools::SC_Duplicator(\"Duplicator0\");\n- this->duplicator[1] = new tools::SC_Duplicator(\"Duplicator1\");\n- this->duplicator[5] = new tools::SC_Duplicator(\"Duplicator5\");\n+ this->duplicator[0] = std::make_shared<tools::SC_Duplicator>(\"Duplicator0\");\n+ this->duplicator[1] = std::make_shared<tools::SC_Duplicator>(\"Duplicator1\");\n+ this->duplicator[5] = std::make_shared<tools::SC_Duplicator>(\"Duplicator5\");\nif (this->params_BFER_ite.coset)\n{\n- this->duplicator[2] = new tools::SC_Duplicator(\"Duplicator2\");\n- this->duplicator[3] = new tools::SC_Duplicator(\"Duplicator3\");\n- this->duplicator[4] = new tools::SC_Duplicator(\"Duplicator4\");\n+ this->duplicator[2] = std::make_shared<tools::SC_Duplicator>(\"Duplicator2\");\n+ this->duplicator[3] = std::make_shared<tools::SC_Duplicator>(\"Duplicator3\");\n+ this->duplicator[4] = std::make_shared<tools::SC_Duplicator>(\"Duplicator4\");\n}\nif (this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos)\n{\n- this->duplicator[6] = new tools::SC_Duplicator(\"Duplicator6\");\n+ this->duplicator[6] = std::make_shared<tools::SC_Duplicator>(\"Duplicator6\");\n}\n- this->router = new tools::SC_Router (p, \"Router\" );\n- this->funnel = new tools::SC_Funnel ( \"Funnel\" );\n- this->predicate = new tools::SC_Predicate(p, \"Predicate\");\n+ this->router = std::make_shared<tools::SC_Router> (p, \"Router\" );\n+ this->funnel = std::make_shared<tools::SC_Funnel> ( \"Funnel\" );\n+ this->predicate = std::make_shared<tools::SC_Predicate>(p, \"Predicate\");\nthis->bind_sockets();\nsc_core::sc_report_handler::set_actions(sc_core::SC_INFO, sc_core::SC_DO_NOTHING);\nsc_core::sc_start(); // start simulation\n- for (auto& d : this->duplicator)\n- if (d != nullptr)\n- {\n- delete d;\n- d = nullptr;\n- }\n-\n- delete this->router; this->router = nullptr;\n- delete this->funnel; this->funnel = nullptr;\n- delete this->predicate; this->predicate = nullptr;\n//////////////////////////////////////////////////////////////////////////////////////////////////////////////\n// /!\\ VERY DIRTY WAY TO CREATE A NEW SIMULATION CONTEXT IN SYSTEMC, BE CAREFUL THIS IS NOT IN THE STD! /!\\ //\n@@ -299,7 +279,7 @@ void SC_BFER_ite<B,R,Q>\n}\ntemplate <typename B, typename R, typename Q>\n-module::Coset<B,Q>* SC_BFER_ite<B,R,Q>\n+std::shared_ptr<module::Coset<B,Q>> SC_BFER_ite<B,R,Q>\n::build_coset_real(const int tid)\n{\nfactory::Coset::parameters cst_params;\n@@ -309,7 +289,7 @@ module::Coset<B,Q>* SC_BFER_ite<B,R,Q>\nthis->coset_real_i = cst_params.template build_real<B,Q>();\nthis->coset_real_i->set_name(\"Coset_real_i\");\n- return cst_params.template build_real<B,Q>();\n+ return std::shared_ptr<module::Coset<B,Q>>(cst_params.template build_real<B,Q>());\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.hpp",
"new_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.hpp",
"diff": "@@ -20,12 +20,11 @@ template <typename B = int, typename R = float, typename Q = R>\nclass SC_BFER_ite : public BFER_ite<B,R,Q>\n{\nprotected:\n- module::Coset<B,Q> *coset_real_i;\n-\n- std::vector<tools::SC_Duplicator*> duplicator;\n- tools::SC_Router *router;\n- tools::SC_Funnel *funnel;\n- tools::SC_Predicate *predicate;\n+ std::vector<std::shared_ptr<tools::SC_Duplicator>> duplicator;\n+ std::shared_ptr<module::Coset<B,Q>> coset_real_i;\n+ std::shared_ptr<tools::SC_Router > router;\n+ std::shared_ptr<tools::SC_Funnel > funnel;\n+ std::shared_ptr<tools::SC_Predicate> predicate;\npublic:\nexplicit SC_BFER_ite(const factory::BFER_ite::parameters ¶ms_BFER_ite);\n@@ -38,7 +37,7 @@ protected:\nvirtual void release_objects();\nvirtual void _launch();\n- virtual module::Coset<B,Q>* build_coset_real(const int tid = 0);\n+ virtual std::shared_ptr<module::Coset<B,Q>> build_coset_real(const int tid = 0);\nprivate:\nvoid bind_sockets ();\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": "@@ -13,7 +13,7 @@ template <typename B, typename R, typename Q>\nSC_BFER_std<B,R,Q>\n::SC_BFER_std(const factory::BFER_std::parameters ¶ms_BFER_std)\n: BFER_std<B,R,Q>(params_BFER_std),\n- duplicator(3, nullptr)\n+ duplicator(3)\n{\nif (this->params_BFER_std.n_threads > 1)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"BFER SystemC simulation does not support \"\n@@ -32,12 +32,6 @@ template <typename B, typename R, typename Q>\nSC_BFER_std<B,R,Q>\n::~SC_BFER_std()\n{\n- for (auto& d : this->duplicator)\n- if (d != nullptr)\n- {\n- delete d;\n- d = nullptr;\n- }\n}\ntemplate <typename B, typename R, typename Q>\n@@ -91,11 +85,11 @@ void SC_BFER_std<B,R,Q>\n}\nthis->crc[tid]->sc.create_module(+crc::tsk::extract);\n- this->duplicator[0] = new tools::SC_Duplicator(\"Duplicator_src\");\n+ this->duplicator[0] = std::make_shared<tools::SC_Duplicator>(\"Duplicator_src\");\nif (this->params_BFER_std.coset)\n{\n- this->duplicator[1] = new tools::SC_Duplicator(\"Duplicator1\");\n- this->duplicator[2] = new tools::SC_Duplicator(\"Duplicator2\");\n+ this->duplicator[1] = std::make_shared<tools::SC_Duplicator>(\"Duplicator1\");\n+ this->duplicator[2] = std::make_shared<tools::SC_Duplicator>(\"Duplicator2\");\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/SystemC/SC_BFER_std.hpp",
"new_path": "src/Simulation/BFER/Standard/SystemC/SC_BFER_std.hpp",
"diff": "@@ -15,7 +15,7 @@ template <typename B = int, typename R = float, typename Q = R>\nclass SC_BFER_std : public BFER_std<B,R,Q>\n{\nprotected:\n- std::vector<tools::SC_Duplicator*> duplicator;\n+ std::vector<std::shared_ptr<tools::SC_Duplicator>> duplicator;\npublic:\nexplicit SC_BFER_std(const factory::BFER_std::parameters ¶ms_BFER_std);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use shared pointers in the SC simulations, too
|
8,483 |
10.09.2018 10:02:56
| -7,200 |
2a98a45d9a92c3ff2140ea90cf781eba15845170
|
Fix SC ite simu
|
[
{
"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": "@@ -31,6 +31,7 @@ template <typename B, typename R, typename Q>\nSC_BFER_ite<B,R,Q>\n::~SC_BFER_ite()\n{\n+ release_objects()\n}\ntemplate <typename B, typename R, typename Q>\n@@ -97,8 +98,6 @@ template <typename B, typename R, typename Q>\nvoid SC_BFER_ite<B,R,Q>\n::release_objects()\n{\n- if (coset_real_i != nullptr) { delete coset_real_i; coset_real_i = nullptr; }\n-\nBFER_ite<B,R,Q>::release_objects();\n}\n@@ -286,7 +285,7 @@ std::shared_ptr<module::Coset<B,Q>> SC_BFER_ite<B,R,Q>\ncst_params.size = this->params_BFER_ite.cdc->N_cw;\ncst_params.n_frames = this->params_BFER_ite.src->n_frames;\n- this->coset_real_i = cst_params.template build_real<B,Q>();\n+ this->coset_real_i.reset(cst_params.template build_real<B,Q>());\nthis->coset_real_i->set_name(\"Coset_real_i\");\nreturn std::shared_ptr<module::Coset<B,Q>>(cst_params.template build_real<B,Q>());\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": "@@ -105,13 +105,6 @@ void SC_BFER_std<B,R,Q>\nsc_core::sc_report_handler::set_actions(sc_core::SC_INFO, sc_core::SC_DO_NOTHING);\nsc_core::sc_start(); // start simulation\n- for (auto& d : this->duplicator)\n- if (d != nullptr)\n- {\n- delete d;\n- d = nullptr;\n- }\n-\n//////////////////////////////////////////////////////////////////////////////////////////////////////////////\n// /!\\ VERY DIRTY WAY TO CREATE A NEW SIMULATION CONTEXT IN SYSTEMC, BE CAREFUL THIS IS NOT IN THE STD! /!\\ //\n//////////////////////////////////////////////////////////////////////////////////////////////////////////////\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix SC ite simu
|
8,483 |
10.09.2018 10:30:36
| -7,200 |
db4a6100ad15096d62f6ddca7c53478297a3de66
|
Use a shared pointer for managing the Noise in BFER simu
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -28,7 +28,6 @@ BFER<B,R,Q>\nbarrier(params_BFER.n_threads),\nbit_rate((float)params_BFER.src->K / (float)params_BFER.cdc->N),\n- noise(nullptr),\nmonitor_mi(params_BFER.n_threads),\nmonitor_er(params_BFER.n_threads),\n@@ -63,8 +62,6 @@ BFER<B,R,Q>\n::~BFER()\n{\nrelease_objects();\n-\n- if (noise != nullptr) { delete noise; noise = nullptr; }\n}\ntemplate <typename B, typename R, typename Q>\n@@ -111,10 +108,8 @@ void BFER<B,R,Q>\n// for each NOISE to be simulated\nfor (auto noise_idx = noise_begin; noise_idx != noise_end; noise_idx += noise_step)\n{\n- if (this->noise != nullptr) delete noise;\n-\n- this->noise = params_BFER.noise->template build<R>(params_BFER.noise->range[noise_idx], bit_rate,\n- params_BFER.mdm->bps, params_BFER.mdm->upf);\n+ this->noise.reset(params_BFER.noise->template build<R>(params_BFER.noise->range[noise_idx], bit_rate,\n+ params_BFER.mdm->bps, params_BFER.mdm->upf));\n// manage noise distributions to be sure it exists\nif (this->distributions != nullptr)\n@@ -242,9 +237,9 @@ void BFER<B,R,Q>\n{\ncase tools::Noise_type::SIGMA:\nif (params_BFER.noise->type == \"EBN0\")\n- noise_value = std::to_string(dynamic_cast<tools::Sigma<>*>(this->noise)->get_ebn0());\n+ noise_value = std::to_string(std::dynamic_pointer_cast<tools::Sigma<>>(this->noise)->get_ebn0());\nelse //(params_BFER.noise_type == \"ESN0\")\n- noise_value = std::to_string(dynamic_cast<tools::Sigma<>*>(this->noise)->get_esn0());\n+ noise_value = std::to_string(std::dynamic_pointer_cast<tools::Sigma<>>(this->noise)->get_esn0());\nbreak;\ncase tools::Noise_type::ROP:\ncase tools::Noise_type::EP:\n@@ -327,7 +322,7 @@ template <typename B, typename R, typename Q>\nvoid BFER<B,R,Q>\n::build_reporters()\n{\n- this->noise = params_BFER.noise->template build<R>(0);\n+ this->noise.reset(params_BFER.noise->template build<R>(0));\nthis->reporters.push_back(std::make_shared<tools::Reporter_noise<R>>(&this->noise));\nif (params_BFER.mutinfo)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.hpp",
"new_path": "src/Simulation/BFER/BFER.hpp",
"diff": "@@ -54,7 +54,7 @@ protected:\n// code specifications\nconst float bit_rate;\n- tools::Noise<R>* noise; // current noise simulated\n+ std::shared_ptr<tools::Noise<R>> noise; // current noise simulated\n// the monitors of the the BFER simulation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.cpp",
"new_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n+\n+template <typename R>\n+struct Reporter_noise<R>::Noise_ptr\n+{\n+ explicit Noise_ptr(const Noise<R>* const* n) : noise(nullptr), noise_ptr(n), sh_ptr(nullptr) {}\n+ explicit Noise_ptr(const Noise<R>* n) : noise(n), noise_ptr(&noise), sh_ptr(nullptr) {}\n+ explicit Noise_ptr(const Noise<R>& n) : noise(&n), noise_ptr(&noise), sh_ptr(nullptr) {}\n+\n+ explicit Noise_ptr(const std::shared_ptr<Noise<R>>* noise) : noise(nullptr), noise_ptr(nullptr), sh_ptr( noise) {}\n+ explicit Noise_ptr(const std::shared_ptr<Noise<R>>& noise) : noise(nullptr), noise_ptr(nullptr), sh_ptr(&noise) {}\n+\n+ const Noise<R>* get_noise_ptr() const\n+ {\n+ return noise_ptr != nullptr ? *noise_ptr : (sh_ptr != nullptr ? sh_ptr->get() : nullptr);\n+ }\n+\n+private:\n+ const Noise<R>* noise;\n+ const Noise<R>* const* noise_ptr;\n+ const std::shared_ptr<Noise<R>>* sh_ptr;\n+};\n+\n+\ntemplate <typename R>\nReporter_noise<R>\n::Reporter_noise(const Noise<R>* const* _noise)\n@@ -33,6 +56,28 @@ Reporter_noise<R>\n{\n}\n+template <typename R>\n+Reporter_noise<R>\n+::Reporter_noise(const std::shared_ptr<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 std::shared_ptr<Noise<R>>& _noise)\n+: Reporter_noise(new Noise_ptr(_noise))\n+{\n+}\n+\n+template <typename R>\n+Reporter_noise<R>\n+::~Reporter_noise()\n+{\n+ if (noise_ptr != nullptr) delete noise_ptr;\n+}\n+\n+\ntemplate <typename R>\nReporter_noise<R>\n::Reporter_noise(Noise_ptr* noise_ptr)\n@@ -67,13 +112,6 @@ 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"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.hpp",
"new_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.hpp",
"diff": "#include <string>\n#include <chrono>\n+#include <memory>\n#include \"Tools/Noise/noise_utils.h\"\n@@ -20,27 +21,15 @@ public:\nexplicit Reporter_noise(const Noise<R>* noise);\nexplicit Reporter_noise(const Noise<R>& noise);\n+ explicit Reporter_noise(const std::shared_ptr<Noise<R>>* noise);\n+ explicit Reporter_noise(const std::shared_ptr<Noise<R>>& noise);\n+\nvirtual ~Reporter_noise();\nreport_t report(bool final = false);\nprivate:\n- struct Noise_ptr\n- {\n- explicit Noise_ptr(const Noise<R>* const* n) : noise(nullptr), noise_ptr(n) {}\n- explicit Noise_ptr(const Noise<R>* n) : noise(n), noise_ptr(&noise) {}\n- explicit 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+ struct Noise_ptr;\nexplicit Reporter_noise(Noise_ptr* noise_ptr);\nNoise_ptr* noise_ptr;\n@@ -51,7 +40,6 @@ protected:\nprotected:\nconst Noise<R>* get_noise_ptr() const;\n-\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use a shared pointer for managing the Noise in BFER simu
|
8,483 |
10.09.2018 11:42:15
| -7,200 |
ca240fe9f93a951716fe436d77f1e112e5ad983b
|
Add set_decoder_siho_hiho set_decoder_siso_siho functions to manage the case that pointers to decoder SISO and SIHO can be same; Do the same with SIHO/HIHO
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/BCH/Codec_BCH.cpp",
"new_path": "src/Module/Codec/BCH/Codec_BCH.cpp",
"diff": "@@ -68,9 +68,7 @@ Codec_BCH<B,Q>\nif (dec_params.implem == \"GENIUS\")\nthis->get_encoder()->set_memorizing(true);\n- auto dec = factory::Decoder_BCH::build_hiho<B,Q>(dec_params, GF_poly, this->get_encoder());\n- this->set_decoder_siho(dec);\n- this->set_decoder_hiho(dec);\n+ this->set_decoder_siho_hiho(factory::Decoder_BCH::build_hiho<B,Q>(dec_params, GF_poly, this->get_encoder()));\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec_SIHO_HIHO.hpp",
"new_path": "src/Module/Codec/Codec_SIHO_HIHO.hpp",
"diff": "#ifndef CODEC_SIHO_HIHO_HPP_\n#define CODEC_SIHO_HIHO_HPP_\n-#include \"Module/Decoder/Decoder_SISO.hpp\"\n+#include \"Module/Decoder/Decoder_SIHO_HIHO.hpp\"\n#include \"Codec_HIHO.hpp\"\n#include \"Codec_SIHO.hpp\"\n@@ -19,6 +19,9 @@ public:\nvirtual ~Codec_SIHO_HIHO() = default;\nvirtual void reset();\n+\n+ virtual void set_decoder_siho_hiho(std::shared_ptr<Decoder_SIHO_HIHO<B,Q>> dec);\n+ virtual void set_decoder_siho_hiho(Decoder_SIHO_HIHO<B,Q>* dec);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec_SIHO_HIHO.hxx",
"new_path": "src/Module/Codec/Codec_SIHO_HIHO.hxx",
"diff": "@@ -26,6 +26,21 @@ reset()\nthis->get_decoder_siho()->reset();\n}\n+template <typename B, typename Q>\n+void Codec_SIHO_HIHO<B,Q>::\n+set_decoder_siho_hiho(std::shared_ptr<Decoder_SIHO_HIHO<B,Q>> dec)\n+{\n+ this->set_decoder_siho(dec);\n+ this->set_decoder_hiho(dec);\n+}\n+\n+template <typename B, typename Q>\n+void Codec_SIHO_HIHO<B,Q>::\n+set_decoder_siho_hiho(Decoder_SIHO_HIHO<B,Q>* dec)\n+{\n+ this->set_decoder_siho_hiho(std::shared_ptr<Decoder_SIHO_HIHO<B,Q>>(dec));\n+}\n+\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec_SISO_SIHO.hpp",
"new_path": "src/Module/Codec/Codec_SISO_SIHO.hpp",
"diff": "#ifndef CODEC_SISO_SIHO_HPP_\n#define CODEC_SISO_SIHO_HPP_\n-#include \"Module/Decoder/Decoder_SISO.hpp\"\n+#include \"Module/Decoder/Decoder_SISO_SIHO.hpp\"\n#include \"Codec_SISO.hpp\"\n#include \"Codec_SIHO.hpp\"\n@@ -19,6 +19,11 @@ public:\nvirtual ~Codec_SISO_SIHO() = default;\nvirtual void reset();\n+\n+ virtual void set_decoder_siso_siho(std::shared_ptr<Decoder_SISO_SIHO<B,Q>> dec);\n+ virtual void set_decoder_siso_siho(Decoder_SISO_SIHO<B,Q>* dec);\n+\n+\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec_SISO_SIHO.hxx",
"new_path": "src/Module/Codec/Codec_SISO_SIHO.hxx",
"diff": "@@ -25,6 +25,21 @@ reset()\nthis->get_decoder_siho()->reset();\n}\n+template <typename B, typename Q>\n+void Codec_SISO_SIHO<B,Q>::\n+set_decoder_siso_siho(std::shared_ptr<Decoder_SISO_SIHO<B,Q>> dec)\n+{\n+ this->set_decoder_siso(dec);\n+ this->set_decoder_siho(dec);\n+}\n+\n+template <typename B, typename Q>\n+void Codec_SISO_SIHO<B,Q>::\n+set_decoder_siso_siho(Decoder_SISO_SIHO<B,Q>* dec)\n+{\n+ this->set_decoder_siso_siho(std::shared_ptr<Decoder_SISO_SIHO<B,Q>>(dec));\n+}\n+\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "@@ -154,14 +154,11 @@ Codec_LDPC<B,Q>\ntry\n{\n- auto dec = factory::Decoder_LDPC::build_siso<B,Q>(dec_params, H, info_bits_pos, this->get_encoder());\n- this->set_decoder_siho(dec);\n- this->set_decoder_siso(dec);\n+ this->set_decoder_siso_siho(factory::Decoder_LDPC::build_siso<B,Q>(dec_params, H, info_bits_pos, this->get_encoder()));\n}\ncatch (const std::exception&)\n{\n- auto dec = factory::Decoder_LDPC::build<B,Q>(dec_params, H, info_bits_pos, this->get_encoder());\n- this->set_decoder_siho(dec);\n+ this->set_decoder_siho(factory::Decoder_LDPC::build<B,Q>(dec_params, H, info_bits_pos, this->get_encoder()));\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": "@@ -100,9 +100,7 @@ Codec_polar<B,Q>\ntry\n{\n- auto dec = factory::Decoder_polar::build_siso<B,Q>(dec_params, frozen_bits, this->get_encoder());\n- this->set_decoder_siho(dec);\n- this->set_decoder_siso(dec);\n+ this->set_decoder_siso_siho(factory::Decoder_polar::build_siso<B,Q>(dec_params, frozen_bits, this->get_encoder()));\n}\ncatch (const std::exception&)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/RS/Codec_RS.cpp",
"new_path": "src/Module/Codec/RS/Codec_RS.cpp",
"diff": "@@ -68,9 +68,7 @@ Codec_RS<B,Q>\nif (dec_params.implem == \"GENIUS\")\nthis->get_encoder()->set_memorizing(true);\n- auto dec = factory::Decoder_RS::build_hiho<B,Q>(dec_params, GF_poly, this->get_encoder());\n- this->set_decoder_siho(dec);\n- this->set_decoder_hiho(dec);\n+ this->set_decoder_siho_hiho(factory::Decoder_RS::build_hiho<B,Q>(dec_params, GF_poly, this->get_encoder()));\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/RSC/Codec_RSC.cpp",
"new_path": "src/Module/Codec/RSC/Codec_RSC.cpp",
"diff": "@@ -73,9 +73,7 @@ Codec_RSC<B,Q>\ntry\n{\n- auto dec = factory::Decoder_RSC::build_siso<B,Q>(dec_params, trellis, std::cout, 1, this->get_encoder());\n- this->set_decoder_siho(dec);\n- this->set_decoder_siso(dec);\n+ this->set_decoder_siso_siho(factory::Decoder_RSC::build_siso<B,Q>(dec_params, trellis, std::cout, 1, this->get_encoder()));\n}\ncatch (tools::cannot_allocate const&)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/RSC_DB/Codec_RSC_DB.cpp",
"new_path": "src/Module/Codec/RSC_DB/Codec_RSC_DB.cpp",
"diff": "@@ -73,9 +73,7 @@ Codec_RSC_DB<B,Q>\ntry\n{\n- auto dec = factory::Decoder_RSC_DB::build_siso<B,Q>(dec_params, trellis, this->get_encoder());\n- this->set_decoder_siho(dec);\n- this->set_decoder_siso(dec);\n+ this->set_decoder_siso_siho(factory::Decoder_RSC_DB::build_siso<B,Q>(dec_params, trellis, this->get_encoder()));\n}\ncatch (tools::cannot_allocate const&)\n{\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": "@@ -133,9 +133,7 @@ Codec_turbo_product<B,Q>\ntry\n{\n- auto dec = factory::Decoder_turbo_product::build_siso<B,Q>(dec_params, this->get_interleaver_llr(), *cp_rows, *cp_cols);\n- this->set_decoder_siho(dec);\n- this->set_decoder_siso(dec);\n+ this->set_decoder_siso_siho(factory::Decoder_turbo_product::build_siso<B,Q>(dec_params, this->get_interleaver_llr(), *cp_rows, *cp_cols));\n}\ncatch (tools::cannot_allocate const&)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Uncoded/Codec_uncoded.cpp",
"new_path": "src/Module/Codec/Uncoded/Codec_uncoded.cpp",
"diff": "@@ -67,9 +67,7 @@ Codec_uncoded<B,Q>\ntry\n{\n- auto dec = factory::Decoder_NO::build_siso<B,Q>(dec_params, this->get_encoder());\n- this->set_decoder_siho(dec);\n- this->set_decoder_siso(dec);\n+ this->set_decoder_siso_siho(factory::Decoder_NO::build_siso<B,Q>(dec_params, this->get_encoder()));\n}\ncatch (const std::exception&)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add set_decoder_siho_hiho set_decoder_siso_siho functions to manage the case that pointers to decoder SISO and SIHO can be same; Do the same with SIHO/HIHO
|
8,483 |
10.09.2018 15:36:23
| -7,200 |
270dc5a275e4aa7bc05a4f55ec10dbf14bce8b78
|
Differentiate to builder for factory channel, with or without a reference to a distribution.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "@@ -222,19 +222,16 @@ module::Channel<R>* Channel::parameters\ntemplate <typename R>\nmodule::Channel<R>* Channel::parameters\n-::build_userpdf(std::shared_ptr<const tools::Distributions<R>> dist) const\n+::build_userpdf(const tools::Distributions<R>& dist) const\n{\n- if (dist == nullptr)\n- throw tools::cannot_allocate(__FILE__, __LINE__, __func__);\n-\ntools::User_pdf_noise_generator<R>* n = nullptr;\n- if (implem == \"STD\" ) n = new tools::User_pdf_noise_generator_std <R>(*dist, seed);\n- else if (implem == \"FAST\") n = new tools::User_pdf_noise_generator_fast<R>(*dist, seed);\n+ if (implem == \"STD\" ) n = new tools::User_pdf_noise_generator_std <R>(dist, seed);\n+ else if (implem == \"FAST\") n = new tools::User_pdf_noise_generator_fast<R>(dist, seed);\n#ifdef CHANNEL_MKL\n- else if (implem == \"MKL\" ) n = new tools::User_pdf_noise_generator_MKL <R>(*dist, seed);\n+ else if (implem == \"MKL\" ) n = new tools::User_pdf_noise_generator_MKL <R>(dist, seed);\n#endif\n#ifdef CHANNEL_GSL\n- else if (implem == \"GSL\" ) n = new tools::User_pdf_noise_generator_GSL <R>(*dist, seed);\n+ else if (implem == \"GSL\" ) n = new tools::User_pdf_noise_generator_GSL <R>(dist, seed);\n#endif\nelse\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n@@ -248,7 +245,7 @@ module::Channel<R>* Channel::parameters\ntemplate <typename R>\nmodule::Channel<R>* Channel::parameters\n-::build(std::shared_ptr<const tools::Distributions<R>> dist) const\n+::build() const\n{\ntry {\nreturn build_gaussian<R>();\n@@ -258,10 +255,6 @@ module::Channel<R>* Channel::parameters\nreturn build_event<R>();\n} catch (tools::cannot_allocate&) {}\n- try {\n- return build_userpdf<R>(dist);\n- } catch (tools::cannot_allocate&) {}\n-\nif (type == \"USER\" ) return new module::Channel_user<R>(N, path, add_users, false, n_frames);\nif (type == \"USER_ADD\") return new module::Channel_user<R>(N, path, add_users, true, n_frames);\nif (type == \"NO\" ) return new module::Channel_NO <R>(N, add_users, n_frames);\n@@ -269,9 +262,27 @@ module::Channel<R>* Channel::parameters\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n+template <typename R>\n+module::Channel<R>* Channel::parameters\n+::build(const tools::Distributions<R>& dist) const\n+{\n+ try {\n+ return build_userpdf<R>(dist);\n+ } catch (tools::cannot_allocate&) {}\n+\n+ return build<R>();\n+}\n+\n+template <typename R>\n+module::Channel<R>* Channel\n+::build(const parameters ¶ms)\n+{\n+ return params.template build<R>();\n+}\n+\ntemplate <typename R>\nmodule::Channel<R>* Channel\n-::build(const parameters ¶ms, std::shared_ptr<const tools::Distributions<R>> dist)\n+::build(const parameters ¶ms, const tools::Distributions<R>& dist)\n{\nreturn params.template build<R>(dist);\n}\n@@ -279,12 +290,20 @@ module::Channel<R>* Channel\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template aff3ct::module::Channel<R_32>* aff3ct::factory::Channel::parameters::build<R_32>(std::shared_ptr<const tools::Distributions<R_32>>) const;\n-template aff3ct::module::Channel<R_64>* aff3ct::factory::Channel::parameters::build<R_64>(std::shared_ptr<const tools::Distributions<R_64>>) const;\n-template aff3ct::module::Channel<R_32>* aff3ct::factory::Channel::build<R_32>(const aff3ct::factory::Channel::parameters&, std::shared_ptr<const tools::Distributions<R_32>>);\n-template aff3ct::module::Channel<R_64>* aff3ct::factory::Channel::build<R_64>(const aff3ct::factory::Channel::parameters&, std::shared_ptr<const tools::Distributions<R_64>>);\n+template aff3ct::module::Channel<R_32>* aff3ct::factory::Channel::parameters::build<R_32>() const;\n+template aff3ct::module::Channel<R_64>* aff3ct::factory::Channel::parameters::build<R_64>() const;\n+template aff3ct::module::Channel<R_32>* aff3ct::factory::Channel::build<R_32>(const aff3ct::factory::Channel::parameters&);\n+template aff3ct::module::Channel<R_64>* aff3ct::factory::Channel::build<R_64>(const aff3ct::factory::Channel::parameters&);\n+\n+template aff3ct::module::Channel<R_32>* aff3ct::factory::Channel::parameters::build<R_32>(const tools::Distributions<R_32>&) const;\n+template aff3ct::module::Channel<R_64>* aff3ct::factory::Channel::parameters::build<R_64>(const tools::Distributions<R_64>&) const;\n+template aff3ct::module::Channel<R_32>* aff3ct::factory::Channel::build<R_32>(const aff3ct::factory::Channel::parameters&, const tools::Distributions<R_32>&);\n+template aff3ct::module::Channel<R_64>* aff3ct::factory::Channel::build<R_64>(const aff3ct::factory::Channel::parameters&, const tools::Distributions<R_64>&);\n#else\n-template aff3ct::module::Channel<R>* aff3ct::factory::Channel::parameters::build<R>(std::shared_ptr<const tools::Distributions<R>>) const;\n-template aff3ct::module::Channel<R>* aff3ct::factory::Channel::build<R>(const aff3ct::factory::Channel::parameters&, std::shared_ptr<const tools::Distributions<R>>);\n+template aff3ct::module::Channel<R>* aff3ct::factory::Channel::parameters::build<R>() const;\n+template aff3ct::module::Channel<R>* aff3ct::factory::Channel::build<R>(const aff3ct::factory::Channel::parameters&);\n+\n+template aff3ct::module::Channel<R>* aff3ct::factory::Channel::parameters::build<R>(const tools::Distributions<R>&) const;\n+template aff3ct::module::Channel<R>* aff3ct::factory::Channel::build<R>(const aff3ct::factory::Channel::parameters&, const tools::Distributions<R>&);\n#endif\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.hpp",
"new_path": "src/Factory/Module/Channel/Channel.hpp",
"diff": "@@ -52,13 +52,17 @@ struct Channel : public Factory\ntemplate <typename R = float>\nmodule::Channel<R>* build_event() const;\ntemplate <typename R = float>\n- module::Channel<R>* build_userpdf(std::shared_ptr<const tools::Distributions<R>> dist) const;\n+ module::Channel<R>* build_userpdf(const tools::Distributions<R>& dist) const;\ntemplate <typename R = float>\n- module::Channel<R>* build(std::shared_ptr<const tools::Distributions<R>> dist = nullptr) const;\n+ module::Channel<R>* build() const;\n+ template <typename R = float>\n+ module::Channel<R>* build(const tools::Distributions<R>& dist) const;\n};\ntemplate <typename R = float>\n- static module::Channel<R>* build(const parameters ¶ms, std::shared_ptr<const tools::Distributions<R>> dist = nullptr);\n+ static module::Channel<R>* build(const parameters ¶ms);\n+ template <typename R = float>\n+ static module::Channel<R>* build(const parameters ¶ms, const tools::Distributions<R>& dist);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/BFER_ite.cpp",
"new_path": "src/Simulation/BFER/Iterative/BFER_ite.cpp",
"diff": "@@ -205,7 +205,11 @@ std::shared_ptr<module::Channel<R>> BFER_ite<B,R,Q>\nstd::unique_ptr<factory::Channel::parameters> params_chn(params_BFER_ite.chn->clone());\nparams_chn->seed = seed_chn;\n- return std::shared_ptr<module::Channel<R>>(params_chn->template build<R>(this->distributions));\n+\n+ if (this->distributions != nullptr)\n+ return std::shared_ptr<module::Channel<R>>(params_chn->template build<R>(*this->distributions));\n+ else\n+ return std::shared_ptr<module::Channel<R>>(params_chn->template build<R>());\n}\ntemplate <typename B, typename R, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/BFER_std.cpp",
"new_path": "src/Simulation/BFER/Standard/BFER_std.cpp",
"diff": "@@ -195,7 +195,10 @@ std::shared_ptr<module::Channel<R>> BFER_std<B,R,Q>\nstd::unique_ptr<factory::Channel::parameters> params_chn(this->params_BFER_std.chn->clone());\nparams_chn->seed = seed_chn;\n- return std::shared_ptr<module::Channel<R>>(params_chn->template build<R>(this->distributions));\n+ if (this->distributions != nullptr)\n+ return std::shared_ptr<module::Channel<R>>(params_chn->template build<R>(*this->distributions));\n+ else\n+ return std::shared_ptr<module::Channel<R>>(params_chn->template build<R>());\n}\ntemplate <typename B, typename R, typename Q>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Differentiate to builder for factory channel, with or without a reference to a distribution.
|
8,483 |
10.09.2018 15:38:03
| -7,200 |
8072a8ed5d4c886131ee7919e4cdfe7e2648c499
|
Differentiate the builder for factory encoder ldpc, with or without a reference to a dvbs2 object
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "@@ -135,24 +135,40 @@ void Encoder_LDPC::parameters\ntemplate <typename B>\nmodule::Encoder_LDPC<B>* Encoder_LDPC::parameters\n-::build(const tools::Sparse_matrix &G, const tools::Sparse_matrix &H, std::shared_ptr<const tools::dvbs2_values> dvbs2) const\n+::build(const tools::Sparse_matrix &G, const tools::Sparse_matrix &H) const\n{\nif (this->type == \"LDPC\" ) return new module::Encoder_LDPC <B>(this->K, this->N_cw, G, this->n_frames);\nelse if (this->type == \"LDPC_H\" ) return new module::Encoder_LDPC_from_H <B>(this->K, this->N_cw, H, this->G_method, this->G_save, this->n_frames);\nelse if (this->type == \"LDPC_QC\" ) return new module::Encoder_LDPC_from_QC <B>(this->K, this->N_cw, H, this->n_frames);\nelse if (this->type == \"LDPC_IRA\") return new module::Encoder_LDPC_from_IRA<B>(this->K, this->N_cw, H, this->n_frames);\n- else if (this->type == \"LDPC_DVBS2\" && dvbs2 != nullptr)\n- return new module::Encoder_LDPC_DVBS2 <B>(*dvbs2, this->n_frames);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n+template <typename B>\n+module::Encoder_LDPC<B>* Encoder_LDPC::parameters\n+::build(const tools::Sparse_matrix &G, const tools::Sparse_matrix &H, const tools::dvbs2_values& dvbs2) const\n+{\n+ if (this->type == \"LDPC_DVBS2\") return new module::Encoder_LDPC_DVBS2<B>(dvbs2, this->n_frames);\n+\n+ return build<B>(G, H);\n+}\n+\n+template <typename B>\n+module::Encoder_LDPC<B>* Encoder_LDPC\n+::build(const parameters ¶ms,\n+ const tools::Sparse_matrix &G,\n+ const tools::Sparse_matrix &H)\n+{\n+ return params.template build<B>(G, H);\n+}\n+\ntemplate <typename B>\nmodule::Encoder_LDPC<B>* Encoder_LDPC\n::build(const parameters ¶ms,\nconst tools::Sparse_matrix &G,\nconst tools::Sparse_matrix &H,\n- std::shared_ptr<const tools::dvbs2_values> dvbs2)\n+ const tools::dvbs2_values& dvbs2)\n{\nreturn params.template build<B>(G, H, dvbs2);\n}\n@@ -160,16 +176,28 @@ module::Encoder_LDPC<B>* Encoder_LDPC\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template aff3ct::module::Encoder_LDPC<B_8 >* aff3ct::factory::Encoder_LDPC::parameters::build<B_8 >(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>) const;\n-template aff3ct::module::Encoder_LDPC<B_16>* aff3ct::factory::Encoder_LDPC::parameters::build<B_16>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>) const;\n-template aff3ct::module::Encoder_LDPC<B_32>* aff3ct::factory::Encoder_LDPC::parameters::build<B_32>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>) const;\n-template aff3ct::module::Encoder_LDPC<B_64>* aff3ct::factory::Encoder_LDPC::parameters::build<B_64>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>) const;\n-template aff3ct::module::Encoder_LDPC<B_8 >* aff3ct::factory::Encoder_LDPC::build<B_8 >(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>);\n-template aff3ct::module::Encoder_LDPC<B_16>* aff3ct::factory::Encoder_LDPC::build<B_16>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>);\n-template aff3ct::module::Encoder_LDPC<B_32>* aff3ct::factory::Encoder_LDPC::build<B_32>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>);\n-template aff3ct::module::Encoder_LDPC<B_64>* aff3ct::factory::Encoder_LDPC::build<B_64>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>);\n+template aff3ct::module::Encoder_LDPC<B_8 >* aff3ct::factory::Encoder_LDPC::parameters::build<B_8 >(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&) const;\n+template aff3ct::module::Encoder_LDPC<B_16>* aff3ct::factory::Encoder_LDPC::parameters::build<B_16>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&) const;\n+template aff3ct::module::Encoder_LDPC<B_32>* aff3ct::factory::Encoder_LDPC::parameters::build<B_32>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&) const;\n+template aff3ct::module::Encoder_LDPC<B_64>* aff3ct::factory::Encoder_LDPC::parameters::build<B_64>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&) const;\n+template aff3ct::module::Encoder_LDPC<B_8 >* aff3ct::factory::Encoder_LDPC::build<B_8 >(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&);\n+template aff3ct::module::Encoder_LDPC<B_16>* aff3ct::factory::Encoder_LDPC::build<B_16>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&);\n+template aff3ct::module::Encoder_LDPC<B_32>* aff3ct::factory::Encoder_LDPC::build<B_32>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&);\n+template aff3ct::module::Encoder_LDPC<B_64>* aff3ct::factory::Encoder_LDPC::build<B_64>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&);\n+\n+template aff3ct::module::Encoder_LDPC<B_8 >* aff3ct::factory::Encoder_LDPC::parameters::build<B_8 >(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&) const;\n+template aff3ct::module::Encoder_LDPC<B_16>* aff3ct::factory::Encoder_LDPC::parameters::build<B_16>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&) const;\n+template aff3ct::module::Encoder_LDPC<B_32>* aff3ct::factory::Encoder_LDPC::parameters::build<B_32>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&) const;\n+template aff3ct::module::Encoder_LDPC<B_64>* aff3ct::factory::Encoder_LDPC::parameters::build<B_64>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&) const;\n+template aff3ct::module::Encoder_LDPC<B_8 >* aff3ct::factory::Encoder_LDPC::build<B_8 >(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&);\n+template aff3ct::module::Encoder_LDPC<B_16>* aff3ct::factory::Encoder_LDPC::build<B_16>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&);\n+template aff3ct::module::Encoder_LDPC<B_32>* aff3ct::factory::Encoder_LDPC::build<B_32>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&);\n+template aff3ct::module::Encoder_LDPC<B_64>* aff3ct::factory::Encoder_LDPC::build<B_64>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&);\n#else\n-template aff3ct::module::Encoder_LDPC<B>* aff3ct::factory::Encoder_LDPC::parameters::build<B>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>) const;\n-template aff3ct::module::Encoder_LDPC<B>* aff3ct::factory::Encoder_LDPC::build<B>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, std::shared_ptr<const tools::dvbs2_values>);\n+template aff3ct::module::Encoder_LDPC<B>* aff3ct::factory::Encoder_LDPC::parameters::build<B>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&) const;\n+template aff3ct::module::Encoder_LDPC<B>* aff3ct::factory::Encoder_LDPC::build<B>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&);\n+\n+template aff3ct::module::Encoder_LDPC<B>* aff3ct::factory::Encoder_LDPC::parameters::build<B>(const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&) const;\n+template aff3ct::module::Encoder_LDPC<B>* aff3ct::factory::Encoder_LDPC::build<B>(const aff3ct::factory::Encoder_LDPC::parameters&, const aff3ct::tools::Sparse_matrix&, const aff3ct::tools::Sparse_matrix&, const tools::dvbs2_values&);\n#endif\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"diff": "@@ -45,14 +45,19 @@ struct Encoder_LDPC : public Encoder\n// builder\ntemplate <typename B = int>\n+ module::Encoder_LDPC<B>* build(const tools::Sparse_matrix &G, const tools::Sparse_matrix &H) const;\n+ template <typename B = int>\nmodule::Encoder_LDPC<B>* build(const tools::Sparse_matrix &G, const tools::Sparse_matrix &H,\n- std::shared_ptr<const tools::dvbs2_values> dvbs2 = nullptr) const;\n+ const tools::dvbs2_values& dvbs2) const;\n};\n+ template <typename B = int>\n+ static module::Encoder_LDPC<B>* build(const parameters ¶ms, const tools::Sparse_matrix &G,\n+ const tools::Sparse_matrix &H);\ntemplate <typename B = int>\nstatic module::Encoder_LDPC<B>* build(const parameters ¶ms, const tools::Sparse_matrix &G,\nconst tools::Sparse_matrix &H,\n- std::shared_ptr<const tools::dvbs2_values> dvbs2 = nullptr);\n+ const tools::dvbs2_values& dvbs2);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "@@ -130,7 +130,7 @@ Codec_LDPC<B,Q>\n{ // encoder not set when building encoder LDPC_H\ntry\n{\n- this->set_encoder(factory::Encoder_LDPC::build<B>(enc_params, G, H, dvbs2));\n+ this->set_encoder(factory::Encoder_LDPC::build<B>(enc_params, G, H, *dvbs2));\n}\ncatch(tools::cannot_allocate const&)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.hpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.hpp",
"diff": "@@ -25,7 +25,7 @@ protected:\ntools::Sparse_matrix G;\ntools::LDPC_matrix_handler::Positions_vector info_bits_pos;\nstd::vector<bool> pctPattern;\n- std::shared_ptr<const tools::dvbs2_values> dvbs2;\n+ std::unique_ptr<const tools::dvbs2_values> dvbs2;\npublic:\nCodec_LDPC(const factory::Encoder_LDPC::parameters &enc_params,\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Differentiate the builder for factory encoder ldpc, with or without a reference to a dvbs2 object
|
8,483 |
11.09.2018 08:17:20
| -7,200 |
3e924bfc6cf68a85317a6fd8775d572c09b35b91
|
Update aff3ct with aff3ct trace readers scripts
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-build-coverage-regression.sh",
"new_path": "ci/test-build-coverage-regression.sh",
"diff": "@@ -27,10 +27,6 @@ function gen_coverage_info\nlocal folder=$2\nfor path in $folder/*\ndo [ -f $path ] && {\n- if [ ${path: -3} == \".py\" ]; then\n- continue\n- fi\n-\ncmd=$(awk -F \"=\" '/command/ {print $2}' $path)\necho $cmd\nci=$(awk -F \"=\" '/ci/ {print $2}' $path)\n@@ -44,7 +40,7 @@ function gen_coverage_info\nfi\n} || {\n[ -d $path ] && {\n- if [ ${path: -11} == \"__pycache__\" ]; then\n+ if [ ${path: -11} == \"readers\" ]; then\ncontinue\nfi\ngen_coverage_info $build $path\n"
},
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -13,8 +13,8 @@ import argparse\nimport subprocess\nimport numpy as np\n-sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), \"../refs\")))\n-import aff3ct_refs_reader as arr\n+sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), \"../refs/readers/\")))\n+import aff3ct_trace_reader as atr\n# ==================================================================== PACKAGES\n# =============================================================================\n@@ -165,7 +165,7 @@ class tableStats:\nclass compStats:\ndef __init__(self, dataCur, dataRef, sensibility, asked_n_fe):\n- if not isinstance(dataCur, arr.aff3ctRefsReader) or not isinstance(dataRef, arr.aff3ctRefsReader) :\n+ if not isinstance(dataCur, atr.aff3ctTraceReader) or not isinstance(dataRef, atr.aff3ctTraceReader) :\nraise TypeError\nself.nValidData = len(dataCur.getTrace(\"n_fe\"))\n@@ -355,7 +355,7 @@ for fn in fileNames:\n\" - \" + fn, end=\"\", flush=True);\n# parse the reference file\n- simuRef = arr.aff3ctRefsReader(args.refsPath + \"/\" + fn)\n+ simuRef = atr.aff3ctTraceReader(args.refsPath + \"/\" + fn)\nif simuRef.getMetadata(\"ci\") == \"off\":\nprint(\" - IGNORED.\", end=\"\\n\");\n@@ -416,7 +416,7 @@ for fn in fileNames:\n# get the results\nstdOutput = stdoutAFFECT.decode(encoding='UTF-8').split(\"\\n\")\n- simuCur = arr.aff3ctRefsReader(stdOutput)\n+ simuCur = atr.aff3ctTraceReader(stdOutput)\n# result file\nfRes = open(args.resultsPath + \"/\" + fn, 'w+')\n"
},
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit 03c3e0c82039d9e0f81537f27f7c5dbdc24d3dde\n+Subproject commit 1cbf1086773fbfb885bcf876f708cd29708da3bf\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Update aff3ct with aff3ct trace readers scripts
|
8,483 |
11.09.2018 09:39:31
| -7,200 |
6f38ae90c3512a06f55f56328cde05a17913c6c4
|
Fix refs and tests build coverage
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-build-coverage-regression.sh",
"new_path": "ci/test-build-coverage-regression.sh",
"diff": "@@ -40,7 +40,7 @@ function gen_coverage_info\nfi\n} || {\n[ -d $path ] && {\n- if [ ${path: -11} == \"readers\" ]; then\n+ if [ ${path: -7} == \"readers\" ]; then\ncontinue\nfi\ngen_coverage_info $build $path\n"
},
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit 1cbf1086773fbfb885bcf876f708cd29708da3bf\n+Subproject commit c88b6c228750bef7627cd393b4c3310282e3d8ec\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix refs and tests build coverage
|
8,483 |
11.09.2018 18:59:00
| -7,200 |
f0aaa9d83d0ba7c7564786e9e838bc39f21b0be7
|
Use unique ptr in SC simu too
|
[
{
"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": "@@ -111,24 +111,24 @@ void SC_BFER_ite<B,R,Q>\ntools::Predicate_ite p(this->params_BFER_ite.n_ite);\n- this->duplicator[0] = std::make_shared<tools::SC_Duplicator>(\"Duplicator0\");\n- this->duplicator[1] = std::make_shared<tools::SC_Duplicator>(\"Duplicator1\");\n- this->duplicator[5] = std::make_shared<tools::SC_Duplicator>(\"Duplicator5\");\n+ this->duplicator[0].reset( new tools::SC_Duplicator(\"Duplicator0\"));\n+ this->duplicator[1].reset( new tools::SC_Duplicator(\"Duplicator1\"));\n+ this->duplicator[5].reset( new tools::SC_Duplicator(\"Duplicator5\"));\nif (this->params_BFER_ite.coset)\n{\n- this->duplicator[2] = std::make_shared<tools::SC_Duplicator>(\"Duplicator2\");\n- this->duplicator[3] = std::make_shared<tools::SC_Duplicator>(\"Duplicator3\");\n- this->duplicator[4] = std::make_shared<tools::SC_Duplicator>(\"Duplicator4\");\n+ this->duplicator[2].reset( new tools::SC_Duplicator(\"Duplicator2\"));\n+ this->duplicator[3].reset( new tools::SC_Duplicator(\"Duplicator3\"));\n+ this->duplicator[4].reset( new tools::SC_Duplicator(\"Duplicator4\"));\n}\nif (this->params_BFER_ite.chn->type.find(\"RAYLEIGH\") != std::string::npos)\n{\n- this->duplicator[6] = std::make_shared<tools::SC_Duplicator>(\"Duplicator6\");\n+ this->duplicator[6].reset( new tools::SC_Duplicator(\"Duplicator6\"));\n}\n- this->router = std::make_shared<tools::SC_Router> (p, \"Router\" );\n- this->funnel = std::make_shared<tools::SC_Funnel> ( \"Funnel\" );\n- this->predicate = std::make_shared<tools::SC_Predicate>(p, \"Predicate\");\n+ this->router .reset( new tools::SC_Router (p, \"Router\" ));\n+ this->funnel .reset( new tools::SC_Funnel ( \"Funnel\" ));\n+ this->predicate.reset( new tools::SC_Predicate(p, \"Predicate\"));\nthis->bind_sockets();\nsc_core::sc_report_handler::set_actions(sc_core::SC_INFO, sc_core::SC_DO_NOTHING);\n@@ -278,7 +278,7 @@ void SC_BFER_ite<B,R,Q>\n}\ntemplate <typename B, typename R, typename Q>\n-std::shared_ptr<module::Coset<B,Q>> SC_BFER_ite<B,R,Q>\n+std::unique_ptr<module::Coset<B,Q>> SC_BFER_ite<B,R,Q>\n::build_coset_real(const int tid)\n{\nfactory::Coset::parameters cst_params;\n@@ -288,7 +288,7 @@ std::shared_ptr<module::Coset<B,Q>> SC_BFER_ite<B,R,Q>\nthis->coset_real_i.reset(cst_params.template build_real<B,Q>());\nthis->coset_real_i->set_name(\"Coset_real_i\");\n- return std::shared_ptr<module::Coset<B,Q>>(cst_params.template build_real<B,Q>());\n+ return std::unique_ptr<module::Coset<B,Q>>(cst_params.template build_real<B,Q>());\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.hpp",
"new_path": "src/Simulation/BFER/Iterative/SystemC/SC_BFER_ite.hpp",
"diff": "@@ -20,11 +20,11 @@ template <typename B = int, typename R = float, typename Q = R>\nclass SC_BFER_ite : public BFER_ite<B,R,Q>\n{\nprotected:\n- std::vector<std::shared_ptr<tools::SC_Duplicator>> duplicator;\n- std::shared_ptr<module::Coset<B,Q>> coset_real_i;\n- std::shared_ptr<tools::SC_Router > router;\n- std::shared_ptr<tools::SC_Funnel > funnel;\n- std::shared_ptr<tools::SC_Predicate> predicate;\n+ std::vector<std::unique_ptr<tools::SC_Duplicator>> duplicator;\n+ std::unique_ptr<module::Coset<B,Q>> coset_real_i;\n+ std::unique_ptr<tools::SC_Router > router;\n+ std::unique_ptr<tools::SC_Funnel > funnel;\n+ std::unique_ptr<tools::SC_Predicate> predicate;\npublic:\nexplicit SC_BFER_ite(const factory::BFER_ite::parameters ¶ms_BFER_ite);\n@@ -37,7 +37,7 @@ protected:\nvirtual void release_objects();\nvirtual void _launch();\n- virtual std::shared_ptr<module::Coset<B,Q>> build_coset_real(const int tid = 0);\n+ virtual std::unique_ptr<module::Coset<B,Q>> build_coset_real(const int tid = 0);\nprivate:\nvoid bind_sockets ();\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": "@@ -85,11 +85,11 @@ void SC_BFER_std<B,R,Q>\n}\nthis->crc[tid]->sc.create_module(+crc::tsk::extract);\n- this->duplicator[0] = std::make_shared<tools::SC_Duplicator>(\"Duplicator_src\");\n+ this->duplicator[0].reset(new tools::SC_Duplicator(\"Duplicator_src\"));\nif (this->params_BFER_std.coset)\n{\n- this->duplicator[1] = std::make_shared<tools::SC_Duplicator>(\"Duplicator1\");\n- this->duplicator[2] = std::make_shared<tools::SC_Duplicator>(\"Duplicator2\");\n+ this->duplicator[1].reset(new tools::SC_Duplicator(\"Duplicator1\"));\n+ this->duplicator[2].reset(new tools::SC_Duplicator(\"Duplicator2\"));\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/SystemC/SC_BFER_std.hpp",
"new_path": "src/Simulation/BFER/Standard/SystemC/SC_BFER_std.hpp",
"diff": "@@ -15,7 +15,7 @@ template <typename B = int, typename R = float, typename Q = R>\nclass SC_BFER_std : public BFER_std<B,R,Q>\n{\nprotected:\n- std::vector<std::shared_ptr<tools::SC_Duplicator>> duplicator;\n+ std::vector<std::unique_ptr<tools::SC_Duplicator>> duplicator;\npublic:\nexplicit SC_BFER_std(const factory::BFER_std::parameters ¶ms_BFER_std);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use unique ptr in SC simu too
|
8,483 |
13.09.2018 11:41:11
| -7,200 |
58260b95ab6dbadcdb16bc9c3f99b1a225615bfd
|
Add __pycache__ in the ignored folders of the refs submodule
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-build-coverage-regression.sh",
"new_path": "ci/test-build-coverage-regression.sh",
"diff": "@@ -40,7 +40,7 @@ function gen_coverage_info\nfi\n} || {\n[ -d $path ] && {\n- if [ ${path: -7} == \"readers\" ]; then\n+ if [ ${path: -7} == \"readers\" || ${path: -11} == \"__pycache__\"]; then\ncontinue\nfi\ngen_coverage_info $build $path\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add __pycache__ in the ignored folders of the refs submodule
|
8,483 |
13.09.2018 11:53:14
| -7,200 |
3339ee25d0e3e0189637b7a52caf15a9c1b0c808
|
Use unique pointer to manage GSL ressources in draw generators
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.cpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.cpp",
"diff": "@@ -10,23 +10,16 @@ using namespace aff3ct::tools;\ntemplate <typename R, typename E>\nEvent_generator_GSL<R,E>\n::Event_generator_GSL(const int seed)\n-: Event_generator<R,E>(), rng(gsl_rng_alloc(gsl_rng_mt19937))\n+: Event_generator<R,E>(), rng(gsl_rng_alloc(gsl_rng_mt19937), gsl_rng_free)\n{\nthis->set_seed(seed);\n}\n-template <typename R, typename E>\n-Event_generator_GSL<R,E>\n-::~Event_generator_GSL()\n-{\n- gsl_rng_free(rng);\n-}\n-\ntemplate <typename R, typename E>\nvoid Event_generator_GSL<R,E>\n::set_seed(const int seed)\n{\n- gsl_rng_set(rng, seed);\n+ gsl_rng_set(rng.get(), seed);\n}\ntemplate <typename R, typename E>\n@@ -34,7 +27,7 @@ void Event_generator_GSL<R,E>\n::generate(E *draw, const unsigned length, const R event_probability)\n{\nfor (unsigned i = 0; i < length; i++)\n- draw[i] = (E)gsl_ran_bernoulli(rng, (double)event_probability);\n+ draw[i] = (E)gsl_ran_bernoulli(rng.get(), (double)event_probability);\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.hpp",
"diff": "#include <gsl/gsl_randist.h>\n#include <gsl/gsl_rng.h>\n+#include <memory>\n#include \"../Event_generator.hpp\"\n@@ -17,12 +18,12 @@ template <typename R = float, typename E = typename tools::matching_types<R>::B>\nclass Event_generator_GSL : public Event_generator<R,E>\n{\nprivate:\n- gsl_rng *rng;\n+ std::unique_ptr<gsl_rng,decltype(&gsl_rng_free)> rng;\npublic:\nexplicit Event_generator_GSL(const int seed = 0);\n- virtual ~Event_generator_GSL();\n+ virtual ~Event_generator_GSL() = default;\nvirtual void set_seed(const int seed);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Gaussian_noise_generator/GSL/Gaussian_noise_generator_GSL.cpp",
"new_path": "src/Tools/Algo/Draw_generator/Gaussian_noise_generator/GSL/Gaussian_noise_generator_GSL.cpp",
"diff": "@@ -10,7 +10,7 @@ template <typename R>\nGaussian_noise_generator_GSL<R>\n::Gaussian_noise_generator_GSL(const int seed)\n: Gaussian_noise_generator<R>(),\n- rng(gsl_rng_alloc(gsl_rng_mt19937))\n+ rng(gsl_rng_alloc(gsl_rng_mt19937), gsl_rng_free)\n{\nif (rng == nullptr)\nthrow runtime_error(__FILE__, __LINE__, __func__, \"'rng' can't be null.\");\n@@ -22,14 +22,7 @@ template <typename R>\nvoid Gaussian_noise_generator_GSL<R>\n::set_seed(const int seed)\n{\n- gsl_rng_set(rng, seed);\n-}\n-\n-template <typename R>\n-Gaussian_noise_generator_GSL<R>\n-::~Gaussian_noise_generator_GSL()\n-{\n- gsl_rng_free(rng);\n+ gsl_rng_set(rng.get(), seed);\n}\ntemplate <typename R>\n@@ -37,7 +30,7 @@ void Gaussian_noise_generator_GSL<R>\n::generate(R *noise, const unsigned length, const R sigma, const R mu)\n{\nfor (unsigned i = 0; i < length; i++)\n- noise[i] = (R)gsl_ran_gaussian(rng, sigma) + mu;\n+ noise[i] = (R)gsl_ran_gaussian(rng.get(), sigma) + mu;\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Gaussian_noise_generator/GSL/Gaussian_noise_generator_GSL.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Gaussian_noise_generator/GSL/Gaussian_noise_generator_GSL.hpp",
"diff": "#include <gsl/gsl_randist.h>\n#include <gsl/gsl_rng.h>\n+#include <memory>\n#include \"../Gaussian_noise_generator.hpp\"\n@@ -16,11 +17,11 @@ template <typename R = float>\nclass Gaussian_noise_generator_GSL : public Gaussian_noise_generator<R>\n{\nprivate:\n- gsl_rng *rng;\n+ std::unique_ptr<gsl_rng,decltype(&gsl_rng_free)> rng;\npublic:\nexplicit Gaussian_noise_generator_GSL(const int seed = 0);\n- virtual ~Gaussian_noise_generator_GSL();\n+ virtual ~Gaussian_noise_generator_GSL() = default;\nvirtual void set_seed(const int seed);\nvirtual void generate(R *noise, const unsigned length, const R sigma, const R mu = 0.0);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/GSL/User_pdf_noise_generator_GSL.cpp",
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/GSL/User_pdf_noise_generator_GSL.cpp",
"diff": "@@ -11,7 +11,7 @@ using namespace aff3ct::tools;\ntemplate <typename R>\nUser_pdf_noise_generator_GSL<R>\n::User_pdf_noise_generator_GSL(const tools::Distributions<R>& dists, const int seed, Interpolation_type inter_type)\n-: User_pdf_noise_generator<R>(dists), rng(gsl_rng_alloc(gsl_rng_mt19937)), interp_function(nullptr)\n+: User_pdf_noise_generator<R>(dists), rng(gsl_rng_alloc(gsl_rng_mt19937), gsl_rng_free), interp_function(nullptr)\n{\nthis->set_seed(seed);\n@@ -27,18 +27,11 @@ User_pdf_noise_generator_GSL<R>\n}\n}\n-template <typename R>\n-User_pdf_noise_generator_GSL<R>\n-::~User_pdf_noise_generator_GSL()\n-{\n- gsl_rng_free(rng);\n-}\n-\ntemplate <typename R>\nvoid User_pdf_noise_generator_GSL<R>\n::set_seed(const int seed)\n{\n- gsl_rng_set(rng, seed);\n+ gsl_rng_set(rng.get(), seed);\n}\ntemplate <typename R>\n@@ -51,7 +44,7 @@ void User_pdf_noise_generator_GSL<R>\n{\nconst auto& cdf_y = signal[i] ? dis.get_cdf_y()[1] : dis.get_cdf_y()[0];\nconst auto& cdf_x = signal[i] ? dis.get_cdf_x()[1] : dis.get_cdf_x()[0];\n- const auto uni_draw = gsl_ran_flat(rng, (R)0, (R)1);\n+ const auto uni_draw = gsl_ran_flat(rng.get(), (R)0, (R)1);\ndraw[i] = interp_function(cdf_y.data(), cdf_x.data(), cdf_x.size(), uni_draw);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/GSL/User_pdf_noise_generator_GSL.hpp",
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/GSL/User_pdf_noise_generator_GSL.hpp",
"diff": "#include <gsl/gsl_randist.h>\n#include <gsl/gsl_rng.h>\n+#include <memory>\n#include \"Tools/Math/interpolation.h\"\n@@ -19,13 +20,13 @@ template <typename R = float>\nclass User_pdf_noise_generator_GSL : public User_pdf_noise_generator<R>\n{\nprivate:\n- gsl_rng *rng;\n+ std::unique_ptr<gsl_rng,decltype(&gsl_rng_free)> rng;\nR (*interp_function)(const R*, const R*, const unsigned, const R);\npublic:\nexplicit User_pdf_noise_generator_GSL(const tools::Distributions<R>& dists, const int seed = 0, Interpolation_type inter_type = Interpolation_type::NEAREST);\n- virtual ~User_pdf_noise_generator_GSL();\n+ virtual ~User_pdf_noise_generator_GSL() = default;\nvirtual void set_seed(const int seed);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use unique pointer to manage GSL ressources in draw generators
|
8,483 |
13.09.2018 12:01:24
| -7,200 |
b3d9934feed67be1cf2a273eda77e68f03d05401
|
Use unique_ptr in the generation of the LDPC DVBS2 standard.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "@@ -61,8 +61,7 @@ Codec_LDPC<B,Q>\n}\nelse if (enc_params.type == \"LDPC_DVBS2\")\n{\n- dvbs2.reset(tools::build_dvbs2(this->K, this->N));\n-\n+ dvbs2 = tools::build_dvbs2(this->K, this->N);\nH = tools::build_H(*dvbs2);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.hpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.hpp",
"diff": "@@ -25,7 +25,7 @@ protected:\ntools::Sparse_matrix G;\ntools::LDPC_matrix_handler::Positions_vector info_bits_pos;\nstd::vector<bool> pctPattern;\n- std::unique_ptr<const tools::dvbs2_values> dvbs2;\n+ std::unique_ptr<tools::dvbs2_values> dvbs2;\npublic:\nCodec_LDPC(const factory::Encoder_LDPC::parameters &enc_params,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Standard/DVBS2/DVBS2_constants.cpp",
"new_path": "src/Tools/Code/LDPC/Standard/DVBS2/DVBS2_constants.cpp",
"diff": "@@ -53,9 +53,9 @@ Sparse_matrix aff3ct::tools::build_H(const dvbs2_values& dvbs2)\nreturn H;\n}\n-dvbs2_values* aff3ct::tools::build_dvbs2(const int K, const int N)\n+std::unique_ptr<dvbs2_values> aff3ct::tools::build_dvbs2(const int K, const int N)\n{\n- dvbs2_values* dvbs2 = nullptr;\n+ std::unique_ptr<dvbs2_values> dvbs2;\nauto NmK = N - K;\n@@ -65,38 +65,17 @@ dvbs2_values* aff3ct::tools::build_dvbs2(const int K, const int N)\n{\nswitch (NmK)\n{\n- case 1800 :\n- dvbs2 = new tools::dvbs2_values_16200_1800();\n- break;\n- case 2880 :\n- dvbs2 = new tools::dvbs2_values_16200_2880();\n- break;\n- case 3600 :\n- dvbs2 = new tools::dvbs2_values_16200_3600();\n- break;\n- case 4320 :\n- dvbs2 = new tools::dvbs2_values_16200_4320();\n- break;\n- case 5400 :\n- dvbs2 = new tools::dvbs2_values_16200_5400();\n- break;\n- case 6480 :\n- dvbs2 = new tools::dvbs2_values_16200_6480();\n- break;\n- case 9000 :\n- dvbs2 = new tools::dvbs2_values_16200_9000();\n- break;\n- case 9720 :\n- dvbs2 = new tools::dvbs2_values_16200_9720();\n- break;\n- case 10800 :\n- dvbs2 = new tools::dvbs2_values_16200_10800();\n- break;\n- case 12960 :\n- dvbs2 = new tools::dvbs2_values_16200_12960();\n- break;\n- default :\n- break;\n+ case 1800 : dvbs2.reset(new tools::dvbs2_values_16200_1800 ()); break;\n+ case 2880 : dvbs2.reset(new tools::dvbs2_values_16200_2880 ()); break;\n+ case 3600 : dvbs2.reset(new tools::dvbs2_values_16200_3600 ()); break;\n+ case 4320 : dvbs2.reset(new tools::dvbs2_values_16200_4320 ()); break;\n+ case 5400 : dvbs2.reset(new tools::dvbs2_values_16200_5400 ()); break;\n+ case 6480 : dvbs2.reset(new tools::dvbs2_values_16200_6480 ()); break;\n+ case 9000 : dvbs2.reset(new tools::dvbs2_values_16200_9000 ()); break;\n+ case 9720 : dvbs2.reset(new tools::dvbs2_values_16200_9720 ()); break;\n+ case 10800: dvbs2.reset(new tools::dvbs2_values_16200_10800()); break;\n+ case 12960: dvbs2.reset(new tools::dvbs2_values_16200_12960()); break;\n+ default : break;\n}\nbreak;\n}\n@@ -104,41 +83,18 @@ dvbs2_values* aff3ct::tools::build_dvbs2(const int K, const int N)\n{\nswitch (NmK)\n{\n- case 6480 :\n- dvbs2 = new tools::dvbs2_values_64800_6480();\n- break;\n- case 7200 :\n- dvbs2 = new tools::dvbs2_values_64800_7200();\n- break;\n- case 10800 :\n- dvbs2 = new tools::dvbs2_values_64800_10800();\n- break;\n- case 12960 :\n- dvbs2 = new tools::dvbs2_values_64800_12960();\n- break;\n- case 16200 :\n- dvbs2 = new tools::dvbs2_values_64800_16200();\n- break;\n- case 21600 :\n- dvbs2 = new tools::dvbs2_values_64800_21600();\n- break;\n- case 25920 :\n- dvbs2 = new tools::dvbs2_values_64800_25920();\n- break;\n- case 32400 :\n- dvbs2 = new tools::dvbs2_values_64800_32400();\n- break;\n- case 38880 :\n- dvbs2 = new tools::dvbs2_values_64800_38880();\n- break;\n- case 43200 :\n- dvbs2 = new tools::dvbs2_values_64800_43200();\n- break;\n- case 48600 :\n- dvbs2 = new tools::dvbs2_values_64800_48600();\n- break;\n- default :\n- break;\n+ case 6480 : dvbs2.reset(new tools::dvbs2_values_64800_6480 ()); break;\n+ case 7200 : dvbs2.reset(new tools::dvbs2_values_64800_7200 ()); break;\n+ case 10800: dvbs2.reset(new tools::dvbs2_values_64800_10800()); break;\n+ case 12960: dvbs2.reset(new tools::dvbs2_values_64800_12960()); break;\n+ case 16200: dvbs2.reset(new tools::dvbs2_values_64800_16200()); break;\n+ case 21600: dvbs2.reset(new tools::dvbs2_values_64800_21600()); break;\n+ case 25920: dvbs2.reset(new tools::dvbs2_values_64800_25920()); break;\n+ case 32400: dvbs2.reset(new tools::dvbs2_values_64800_32400()); break;\n+ case 38880: dvbs2.reset(new tools::dvbs2_values_64800_38880()); break;\n+ case 43200: dvbs2.reset(new tools::dvbs2_values_64800_43200()); break;\n+ case 48600: dvbs2.reset(new tools::dvbs2_values_64800_48600()); break;\n+ default : break;\n}\nbreak;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Standard/DVBS2/DVBS2_constants.hpp",
"new_path": "src/Tools/Code/LDPC/Standard/DVBS2/DVBS2_constants.hpp",
"diff": "#define DVBS2_CONSTANTS_HPP_\n#include <vector>\n+#include <memory>\n#include \"Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.hpp\"\n@@ -21,7 +22,7 @@ struct dvbs2_values\nint N_LINES;\n};\n-dvbs2_values* build_dvbs2(const int K, const int N);\n+std::unique_ptr<dvbs2_values> build_dvbs2(const int K, const int N);\ntools::Sparse_matrix build_H(const dvbs2_values& dvbs2);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use unique_ptr in the generation of the LDPC DVBS2 standard.
|
8,483 |
13.09.2018 12:58:23
| -7,200 |
a7d54fa0592866ecd4014de92d4b52b68c63b85c
|
fix if statement with double bracket [[ ]]
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-build-coverage-regression.sh",
"new_path": "ci/test-build-coverage-regression.sh",
"diff": "@@ -40,7 +40,7 @@ function gen_coverage_info\nfi\n} || {\n[ -d $path ] && {\n- if [ ${path: -7} == \"readers\" || ${path: -11} == \"__pycache__\"]; then\n+ if [[ ${path: -7} == \"readers\" || ${path: -11} == \"__pycache__\" ]]; then\ncontinue\nfi\ngen_coverage_info $build $path\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
fix if statement with double bracket [[ ]]
|
8,483 |
13.09.2018 13:57:49
| -7,200 |
59ce89d65e47ea88f8e7c0f4b237754262d96942
|
Set back noise inline functions in header
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/Noise.cpp",
"new_path": "src/Tools/Noise/Noise.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n-Noise_type str_to_type(const std::string& str)\n-{\n- Noise_type t;\n-\n- if (str == \"SIGMA\")\n- t = Noise_type::SIGMA;\n- else if (str == \"ROP\")\n- t = Noise_type::ROP;\n- else if (str == \"EP\")\n- t = Noise_type::EP;\n- else\n- {\n- std::stringstream message;\n- message << \"The string 'str' does not represent a noise type ('str' = \" << str << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- return t;\n-}\n-\n-std::string type_to_str(Noise_type t)\n-{\n- std::string str;\n-\n- switch(t)\n- {\n- case Noise_type::SIGMA:\n- str = \"SIGMA\";\n- break;\n- case Noise_type::EP:\n- str = \"EP\";\n- break;\n- case Noise_type::ROP:\n- str = \"ROP\";\n- break;\n- }\n-\n- if (str.empty()) // this 'if' is a test outside the switch case (instead of default) to keep the compiler check that all\n- // cases of 'Noise_type' are well represented.\n- {\n- std::stringstream message;\n- message << \"The type 't' does not represent a noise type ('t' = \" << (int8_t)t << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- return str;\n-}\n-\ntemplate <typename R>\nNoise<R>::\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/Noise.hpp",
"new_path": "src/Tools/Noise/Noise.hpp",
"diff": "@@ -15,9 +15,53 @@ namespace tools\nenum class Noise_type {SIGMA, ROP, EP};\n-Noise_type str_to_type(const std::string& str);\n+inline Noise_type str_to_type(const std::string& str)\n+{\n+ Noise_type t;\n+\n+ if (str == \"SIGMA\")\n+ t = Noise_type::SIGMA;\n+ else if (str == \"ROP\")\n+ t = Noise_type::ROP;\n+ else if (str == \"EP\")\n+ t = Noise_type::EP;\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"The string 'str' does not represent a noise type ('str' = \" << str << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return t;\n+}\n+\n+inline std::string type_to_str(Noise_type t)\n+{\n+ std::string str;\n-std::string type_to_str(Noise_type t);\n+ switch(t)\n+ {\n+ case Noise_type::SIGMA:\n+ str = \"SIGMA\";\n+ break;\n+ case Noise_type::EP:\n+ str = \"EP\";\n+ break;\n+ case Noise_type::ROP:\n+ str = \"ROP\";\n+ break;\n+ }\n+\n+ if (str.empty()) // this 'if' is a test outside the switch case (instead of default) to keep the compiler check that all\n+ // cases of 'Noise_type' are well represented.\n+ {\n+ std::stringstream message;\n+ message << \"The type 't' does not represent a noise type ('t' = \" << (int8_t)t << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return str;\n+}\ntemplate <typename R = float>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set back noise inline functions in header
|
8,483 |
13.09.2018 14:10:39
| -7,200 |
1f2488b71bfd841fdffc19493d846f7fa6e48c24
|
Use unique_ptr in Distributions
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.cpp",
"new_path": "src/Tools/Math/Distribution/Distributions.cpp",
"diff": "@@ -31,15 +31,6 @@ Distributions(const std::string& filename, Distribution_mode mode, bool read_all\nread_distribution_from_file(i);\n}\n-template<typename R>\n-Distributions<R>::\n-~Distributions()\n-{\n- for (auto& d : distributions)\n- if (d.second != nullptr)\n- delete d.second;\n-}\n-\ntemplate<typename R>\nconst std::vector<R>& Distributions<R>::\nget_noise_range() const\n@@ -159,7 +150,7 @@ get_distribution(R noise) const\ntemplate<typename R>\nvoid Distributions<R>::\n-add_distribution(R noise, Distribution<R>* new_distribution)\n+add_distribution(R noise, std::unique_ptr<Distribution<R>>&& new_distribution)\n{\nif (new_distribution == nullptr)\n{\n@@ -177,7 +168,7 @@ add_distribution(R noise, Distribution<R>* new_distribution)\n}\ncatch (const tools::invalid_argument&)\n{\n- this->distributions[calibrated_noise(noise)] = new_distribution;\n+ this->distributions[calibrated_noise(noise)] = std::move(new_distribution);\n}\n}\n@@ -308,7 +299,7 @@ read_distribution_from_file(unsigned index)\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- add_distribution(ROP_R, new Distribution<R>(std::move(v_x_R), std::move(v_y_R)));\n+ add_distribution(ROP_R, std::unique_ptr<Distribution<R>>(new Distribution<R>(std::move(v_x_R), std::move(v_y_R))));\n}\ntemplate<typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.hpp",
"new_path": "src/Tools/Math/Distribution/Distributions.hpp",
"diff": "#include <fstream>\n#include <string>\n#include <map>\n+#include <memory>\n#include <vector>\n#include \"Distribution.hpp\"\n@@ -22,7 +23,7 @@ public:\nstatic const int saved_noise_precision;\nprotected:\n- std::map<int, Distribution<R>*> distributions; // distributions in function of the noise power\n+ std::map<int, std::unique_ptr<Distribution<R>>> distributions; // distributions in function of the noise power\nstd::ifstream f_distributions;\nDistribution_mode mode;\n@@ -41,7 +42,7 @@ protected:\npublic:\nexplicit Distributions(const std::string& filename, Distribution_mode mode = Distribution_mode::SUMMATION, bool read_all_at_init = false);\n- virtual ~Distributions();\n+ virtual ~Distributions() = default;\nbool has_distribution(R noise) const;\nconst Distribution<R>& get_distribution(R noise) const;\n@@ -53,7 +54,7 @@ protected:\n/*\n* Add a distribution 'new_distribution' associated with the noise power 'noise_power'.\n*/\n- void add_distribution(R noise, Distribution<R>* new_distribution);\n+ void add_distribution(R noise, std::unique_ptr<Distribution<R>>&& new_distribution);\nvoid read_noise_range();\nvoid read_distribution_from_file(unsigned index);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use unique_ptr in Distributions
|
8,483 |
13.09.2018 15:01:18
| -7,200 |
2c70d5ef4a5c774a77e6ce955848c43c0377de9d
|
Add an optical channel with ROP distribution examples and references.
|
[
{
"change_type": "MODIFY",
"old_path": "conf",
"new_path": "conf",
"diff": "-Subproject commit 02ccd31f7bbebad6240ddd63632ad8fcb98af96b\n+Subproject commit b53be8355eeff5abc8e528c52a1d6ead685d1f74\n"
},
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit d9d38be688b10ad69156290afa792e30bc80d79e\n+Subproject commit b7acfb171ebcd2a7418f6c9557baed81f578ca46\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add an optical channel with ROP distribution examples and references.
|
8,483 |
14.09.2018 08:48:29
| -7,200 |
69055e3284e5bccbfaefd5f1ee6027433214744e
|
Use smart pointers in Modules, Tasks and Sockets.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Decoder.cpp",
"new_path": "src/Module/Decoder/Decoder.cpp",
"diff": "@@ -50,7 +50,7 @@ Decoder(const int K, const int N, const int n_frames, const int simd_inter_frame\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- this->tasks_with_nullptr.resize((size_t)dec::tsk::SIZE, nullptr);\n+ this->tasks_with_nullptr.resize((size_t)dec::tsk::SIZE);\n}\nint Decoder::\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Module.cpp",
"new_path": "src/Module/Module.cpp",
"diff": "@@ -22,12 +22,6 @@ Module(const int n_frames)\n}\n}\n-Module::\n-~Module()\n-{\n- for (auto t : tasks) delete t;\n-}\n-\nint Module::\nget_n_frames() const\n{\n@@ -68,23 +62,18 @@ Task& Module::\ncreate_task(const std::string &name, const int id)\n{\nbool autoalloc = false, autoexec = false, stats = false, fast = false, debug = false;\n- auto t = new Task(*this, name, autoalloc, autoexec, stats, fast, debug);\n+ auto t = std::make_shared<Task>(*this, name, autoalloc, autoexec, stats, fast, debug);\n+\nif (id < 0)\n{\n- tasks.push_back(t);\ntasks_with_nullptr.push_back(t);\n}\n- else\n- {\n- if (tasks_with_nullptr.size() > (size_t)id && tasks_with_nullptr[id] == nullptr)\n+ else if (tasks_with_nullptr.size() > (size_t)id && tasks_with_nullptr[id] == nullptr)\n{\n- tasks.push_back(t);\ntasks_with_nullptr[id] = t;\n-\n- }else\n+ }\n+ else\n{\n- delete t;\n-\nstd::stringstream message;\nmessage << \"Impossible to create the task ('task.name' = \" << name\n<< \", 'task.id' = \" << id\n@@ -92,8 +81,9 @@ create_task(const std::string &name, const int id)\n<< \", 'module.name' = \" << this->get_name() << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- }\n- return *t;\n+\n+ tasks.push_back(std::move(t));\n+ return *tasks.back();\n}\nvoid Module::\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Module.hpp",
"new_path": "src/Module/Module.hpp",
"diff": "#include <unordered_map>\n#include <map>\n#include <functional>\n+#include <memory>\n#include \"Task.hpp\"\n#include \"Socket.hpp\"\n@@ -43,10 +44,10 @@ protected:\nint n_frames; /*!< Number of frames to process in this Module */\nstd::string name; /*!< Name of the Module. */\nstd::string short_name; /*!< Short name of the Module. */\n- std::vector<Task*> tasks_with_nullptr;\n+ std::vector<std::shared_ptr<Task>> tasks_with_nullptr;\npublic:\n- std::vector<Task*> tasks;\n+ std::vector<std::shared_ptr<Task>> tasks;\n#ifdef SYSTEMC_MODULE\nfriend SC_Module_container;\nSC_Module_container sc;\n@@ -63,7 +64,7 @@ public:\n/*!\n* \\brief Destructor.\n*/\n- virtual ~Module();\n+ virtual ~Module() = default;\n/*!\n* \\brief Get the number of frames.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/Monitor.cpp",
"new_path": "src/Module/Monitor/Monitor.cpp",
"diff": "@@ -13,7 +13,7 @@ Monitor\nthis->set_name(name);\nthis->set_short_name(name);\n- this->tasks_with_nullptr.resize((size_t)mnt::tsk::SIZE, nullptr);\n+ this->tasks_with_nullptr.resize((size_t)mnt::tsk::SIZE);\n}\nvoid Monitor\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/SC_Module.cpp",
"new_path": "src/Module/SC_Module.cpp",
"diff": "@@ -20,7 +20,7 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\ntask.set_autoalloc(true );\nauto is_inputs = false;\n- for (auto *s : task.sockets)\n+ for (auto& s : task.sockets)\nif (task.get_socket_type(*s) == socket_t::SIN || task.get_socket_type(*s) == socket_t::SIN_SOUT)\n{\nis_inputs = true;\n@@ -29,7 +29,7 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\nfor (size_t i = 0; i < task.sockets.size(); i++)\n{\n- auto *s = task.sockets[i];\n+ auto& s = task.sockets[i];\nauto name = s->get_name();\nconst auto id_in = (int)sockets_in.size();\n@@ -96,12 +96,6 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\n}\n}\n-SC_Module::~SC_Module()\n-{\n- for (auto *s : sockets_in ) delete s;\n- for (auto *s : sockets_out) delete s;\n-}\n-\nvoid SC_Module::b_transport(tlm::tlm_generic_payload& trans, sc_core::sc_time& t, Socket &socket)\n{\nif (trans.get_data_length() != socket.get_databytes())\n@@ -230,18 +224,13 @@ void SC_Module::start_sc_thread()\n}\n}\n+\n+\nSC_Module_container::SC_Module_container(Module &module)\n: module(module), sc_modules()\n{\n}\n-SC_Module_container::~SC_Module_container()\n-{\n- for (auto *m : sc_modules)\n- if (m != nullptr)\n- delete m;\n-}\n-\nvoid SC_Module_container::create_module(const int id)\n{\nif (module.tasks_with_nullptr.size() != sc_modules.size())\n@@ -255,7 +244,7 @@ void SC_Module_container::create_module(const int id)\nif (sc_modules[id] != nullptr)\nerase_module(id);\n- sc_modules[id] = new SC_Module(module[id], (module.get_name() + \"::\" + module[id].get_name()).c_str());\n+ sc_modules[id] = std::unique_ptr<SC_Module>(new SC_Module(module[id], (module.get_name() + \"::\" + module[id].get_name()).c_str()));\n}\nelse\n{\n@@ -269,7 +258,6 @@ void SC_Module_container::erase_module(const int id)\n{\nif ((size_t)id < sc_modules.size() && sc_modules[id] != nullptr)\n{\n- delete sc_modules[id];\nsc_modules[id] = nullptr;\n}\nelse\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/SC_Module.hpp",
"new_path": "src/Module/SC_Module.hpp",
"diff": "@@ -65,10 +65,10 @@ class SC_Module : public sc_core::sc_module\nprotected:\nTask &task;\n- std::vector<tlm_utils::simple_target_socket <SC_Module>*> sockets_in;\n- std::vector<tlm_utils::simple_initiator_socket<SC_Module>*> sockets_out;\n+ std::vector<std::unique_ptr<tlm_utils::simple_target_socket <SC_Module>>> sockets_in;\n+ std::vector<std::unique_ptr<tlm_utils::simple_initiator_socket<SC_Module>>> sockets_out;\n- std::vector<Socket*> ptr_input_sockets;\n+ std::vector<std::shared_ptr<Socket>> ptr_input_sockets;\nstd::vector<int> indirect_sockets_in;\nstd::vector<int> indirect_sockets_out;\n@@ -81,7 +81,7 @@ public:\nSC_Socket_out<SC_Module> s_out;\nSC_Module(Task &task, sc_core::sc_module_name sc_name);\n- virtual ~SC_Module();\n+ virtual ~SC_Module() = default;\nprotected:\nvoid b_transport (tlm::tlm_generic_payload& trans, sc_core::sc_time& t, Socket &socket);\n@@ -102,11 +102,11 @@ class SC_Module_container\n{\nprotected:\nModule &module;\n- std::vector<SC_Module*> sc_modules;\n+ std::vector<std::unique_ptr<SC_Module>> sc_modules;\npublic:\nexplicit SC_Module_container(Module &module);\n- virtual ~SC_Module_container();\n+ virtual ~SC_Module_container() = default;\nvoid create_module(const int id);\nvoid erase_module(const int id);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Socket.hpp",
"new_path": "src/Module/Socket.hpp",
"diff": "@@ -30,7 +30,6 @@ static std::unordered_map<std::type_index,uint8_t> type_to_size = {{typeid(int8_\nclass Socket\n{\nfriend Task;\n-\nprotected:\nTask &task;\n@@ -40,17 +39,13 @@ protected:\nbool fast;\nvoid* dataptr;\n+public:\nSocket(Task &task, const std::string &name, const std::type_index datatype, const size_t databytes,\nconst bool fast = false, void *dataptr = nullptr)\n: task(task), name(name), datatype(datatype), databytes(databytes), fast(fast), dataptr(dataptr)\n{\n}\n- ~Socket()\n- {\n- }\n-\n-public:\ninline std::string get_name () const { return name; }\ninline std::type_index get_datatype () const { return datatype; }\ninline std::string get_datatype_string() const { return type_to_string[datatype]; }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "@@ -32,16 +32,6 @@ Task::Task(const Module &module, const std::string &name, const bool autoalloc,\n{\n}\n-Task::~Task()\n-{\n- for (size_t i = 0; i < sockets.size(); i++)\n- if (sockets[i] != nullptr)\n- {\n- delete sockets[i];\n- sockets[i] = nullptr;\n- }\n-}\n-\nvoid Task::set_autoalloc(const bool autoalloc)\n{\nif (autoalloc != this->autoalloc)\n@@ -51,13 +41,13 @@ void Task::set_autoalloc(const bool autoalloc)\nif (!autoalloc)\n{\nthis->out_buffers.clear();\n- for (auto *s : sockets)\n+ for (auto& s : sockets)\nif (get_socket_type(*s) == socket_t::SOUT)\ns->dataptr = nullptr;\n}\nelse\n{\n- for (auto *s : sockets)\n+ for (auto& s : sockets)\nif (get_socket_type(*s) == socket_t::SOUT)\n{\nout_buffers.push_back(mipp::vector<uint8_t>(s->databytes));\n@@ -214,7 +204,7 @@ int Task::exec()\n}\nstd::cout << \")\" << std::endl;\n- for (auto *s : sockets)\n+ for (auto& s : sockets)\n{\nauto s_type = get_socket_type(*s);\nif (s_type == socket_t::SIN || s_type == socket_t::SIN_SOUT)\n@@ -264,7 +254,7 @@ int Task::exec()\nif (debug)\n{\nauto n_fra = (size_t)this->module.get_n_frames();\n- for (auto *s : sockets)\n+ for (auto& s : sockets)\n{\nauto s_type = get_socket_type(*s);\nif (s_type == socket_t::SOUT || s_type == socket_t::SIN_SOUT)\n@@ -322,11 +312,11 @@ Socket& Task::create_socket(const std::string &name, const size_t n_elmts)\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- auto *s = new Socket(*this, name, typeid(T), n_elmts * sizeof(T), this->is_fast());\n+ auto s = std::make_shared<Socket>(*this, name, typeid(T), n_elmts * sizeof(T), this->is_fast());\n- sockets.push_back(s);\n+ sockets.push_back(std::move(s));\n- return *s;\n+ return *sockets.back();\n}\ntemplate <typename T>\n@@ -361,7 +351,7 @@ Socket& Task::create_socket_out(const std::string &name, const size_t n_elmts)\n// memory allocation\nif (is_autoalloc())\n{\n- out_buffers.push_back(mipp::vector<uint8_t>(s.databytes));\n+ out_buffers.push_back(mipp::vector<uint8_t>(s.get_databytes()));\ns.dataptr = out_buffers.back().data();\n}\n@@ -429,11 +419,11 @@ const std::vector<std::chrono::nanoseconds>& Task::get_timers_max() const\nsocket_t Task::get_socket_type(const Socket &s) const\n{\nfor (size_t i = 0; i < sockets.size(); i++)\n- if (sockets[i] == &s)\n+ if (sockets[i].get() == &s)\nreturn socket_type[i];\nstd::stringstream message;\n- message << \"The socket does not exist ('s.name' = \" << s.name << \", 'task.name' = \" << this->get_name()\n+ message << \"The socket does not exist ('s.name' = \" << s.get_name() << \", 'task.name' = \" << this->get_name()\n<< \", 'module.name' = \" << module.get_name() << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.hpp",
"new_path": "src/Module/Task.hpp",
"diff": "#include <string>\n#include <sstream>\n+#include <memory>\n#include <map>\n#include <chrono>\n@@ -61,7 +62,7 @@ protected:\nstd::vector<socket_t> socket_type;\npublic:\n- std::vector<Socket*> sockets;\n+ std::vector<std::shared_ptr<Socket>> sockets;\nTask(const Module &module,\nconst std::string &name,\n@@ -71,7 +72,7 @@ public:\nconst bool fast = false,\nconst bool debug = false);\n- virtual ~Task();\n+ virtual ~Task() = default;\nvoid reset_stats();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -260,7 +260,7 @@ void BFER<B,R,Q>\nbreak;\nfor (auto &m : modules)\n- for (auto mm : m.second)\n+ for (auto& mm : m.second)\nif (mm != nullptr)\nfor (auto &t : mm->tasks)\nt->reset_stats();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/EXIT/EXIT.cpp",
"new_path": "src/Simulation/EXIT/EXIT.cpp",
"diff": "@@ -193,7 +193,7 @@ void EXIT<B,R>\nthis->monitor->reset();\nfor (auto &m : modules)\n- for (auto mm : m.second)\n+ for (auto& mm : m.second)\nif (mm != nullptr)\nfor (auto &t : mm->tasks)\nt->reset_stats();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/Simulation.cpp",
"new_path": "src/Simulation/Simulation.cpp",
"diff": "@@ -24,7 +24,7 @@ void Simulation\n_build_communication_chain();\nfor (auto &m : modules)\n- for (auto mm : m.second)\n+ for (auto& mm : m.second)\nif (mm != nullptr)\nfor (auto &t : mm->tasks)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Statistics/Statistics.cpp",
"new_path": "src/Tools/Display/Statistics/Statistics.cpp",
"diff": "@@ -181,9 +181,9 @@ void Statistics\nstd::vector<const module::Task*> tasks;\nfor (auto& m : modules)\nif (m != nullptr)\n- for (auto *t : m->tasks)\n+ for (auto& t : m->tasks)\nif (t->get_n_calls())\n- tasks.push_back(t);\n+ tasks.push_back(t.get());\nStatistics::show(tasks, ordered, stream);\n}\n@@ -296,7 +296,7 @@ void Statistics\n{\nstd::vector<const module::Task*> tsk;\nfor (auto& m : vm)\n- tsk.push_back(m->tasks[t]);\n+ tsk.push_back(m->tasks[t].get());\ntasks.push_back(tsk);\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use smart pointers in Modules, Tasks and Sockets.
|
8,483 |
14.09.2018 09:59:42
| -7,200 |
95a94d7f118d430b1038a288400799a23cb3b7fe
|
Fix memory leak in polar parser. Initialize codec_polar pointers.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"new_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"diff": "@@ -18,7 +18,10 @@ Codec_polar<B,Q>\nCodec_SISO_SIHO<B,Q>(enc_params.K, enc_params.N_cw, pct_params ? pct_params->N : enc_params.N_cw, enc_params.tail_length, enc_params.n_frames),\nadaptive_fb(fb_params.sigma == -1.f),\nfrozen_bits(fb_params.N_cw, true),\n- generated_decoder((dec_params.implem.find(\"_SNR\") != std::string::npos))\n+ generated_decoder((dec_params.implem.find(\"_SNR\") != std::string::npos)),\n+ puncturer_shortlast(nullptr),\n+ fb_decoder(nullptr),\n+ fb_encoder(nullptr)\n{\nconst std::string name = \"Codec_polar\";\nthis->set_name(name);\n@@ -142,7 +145,7 @@ template <typename B, typename Q>\nvoid Codec_polar<B,Q>\n::notify_frozenbits_update()\n{\n- if (this->N_cw != this->N)\n+ if (this->N_cw != this->N && puncturer_shortlast)\npuncturer_shortlast->gen_frozen_bits(frozen_bits);\nif (this->fb_decoder)\nthis->fb_decoder->notify_frozenbits_update();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Polar/SCL/Decoder_polar_SCL_MEM_fast_sys.hxx",
"new_path": "src/Module/Decoder/Polar/SCL/Decoder_polar_SCL_MEM_fast_sys.hxx",
"diff": "@@ -211,7 +211,6 @@ template <typename B, typename R, class API_polar>\nDecoder_polar_SCL_MEM_fast_sys<B,R,API_polar>\n::~Decoder_polar_SCL_MEM_fast_sys()\n{\n- polar_patterns.release_patterns();\n}\ntemplate <typename B, typename R, class API_polar>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Polar/SCL/Decoder_polar_SCL_fast_sys.hxx",
"new_path": "src/Module/Decoder/Polar/SCL/Decoder_polar_SCL_fast_sys.hxx",
"diff": "@@ -234,7 +234,6 @@ template <typename B, typename R, class API_polar>\nDecoder_polar_SCL_fast_sys<B,R,API_polar>\n::~Decoder_polar_SCL_fast_sys()\n{\n- polar_patterns.release_patterns();\n}\ntemplate <typename B, typename R, class API_polar>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/Polar/Pattern_polar_parser.cpp",
"new_path": "src/Tools/Code/Polar/Pattern_polar_parser.cpp",
"diff": "@@ -37,23 +37,14 @@ Pattern_polar_parser\nconst std::vector<Pattern_polar_i*> &patterns,\nconst int pattern_rate0_id,\nconst int pattern_rate1_id)\n-: N(N),\n- m((int)std::log2(N)),\n- frozen_bits(frozen_bits),\n- patterns(patterns),\n- pattern_rate0(patterns[pattern_rate0_id]),\n- pattern_rate1(patterns[pattern_rate1_id]),\n- polar_tree(new Binary_tree<Pattern_polar_i>(m +1)),\n- pattern_types(),\n- leaves_pattern_types()\n+: Pattern_polar_parser(N, frozen_bits, patterns, patterns[pattern_rate0_id], patterns[pattern_rate1_id])\n{\n- this->recursive_allocate_nodes_patterns(this->polar_tree->get_root());\n- this->generate_nodes_indexes (this->polar_tree->get_root());\n}\nPattern_polar_parser\n::~Pattern_polar_parser()\n{\n+ release_patterns();\nthis->recursive_deallocate_nodes_patterns(this->polar_tree->get_root());\ndelete polar_tree;\n}\n@@ -167,7 +158,7 @@ void Pattern_polar_parser\n::release_patterns() const\n{\nfor (auto i = 0; i < (int)patterns.size(); i++)\n- if (patterns[i] != pattern_rate0 && patterns[i] != pattern_rate1)\n+ if (patterns[i] != nullptr && patterns[i] != pattern_rate0 && patterns[i] != pattern_rate1)\ndelete patterns[i];\ndelete pattern_rate0;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/Polar/Pattern_polar_parser.hpp",
"new_path": "src/Tools/Code/Polar/Pattern_polar_parser.hpp",
"diff": "@@ -72,7 +72,7 @@ public:\nconst int pattern_rate1_id);\n/*!\n- * \\brief Destructor.\n+ * \\brief Destructor. call release_patterns()\n*/\nvirtual ~Pattern_polar_parser();\n@@ -147,11 +147,6 @@ public:\nreturn false;\n}\n- /*!\n- * \\brief Release the polar patterns given in the constructor.\n- */\n- void release_patterns() const;\n-\nprivate:\nvoid recursive_allocate_nodes_patterns ( Binary_node<Pattern_polar_i>* node_curr);\nvoid generate_nodes_indexes (const Binary_node<Pattern_polar_i>* node_curr);\n@@ -159,6 +154,11 @@ private:\nvoid operator=(Pattern_polar_parser&) = delete;\nPattern_polar_parser(Pattern_polar_parser&) = delete;\n+\n+ /*!\n+ * \\brief Release the polar patterns given in the constructor.\n+ */\n+ void release_patterns() const;\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix memory leak in polar parser. Initialize codec_polar pointers.
|
8,483 |
14.09.2018 09:59:59
| -7,200 |
3e5e70dcdc05b67dfff0e59cb913faf23983dbfb
|
Add valgrind tests in CI
|
[
{
"change_type": "MODIFY",
"old_path": ".gitlab-ci.yml",
"new_path": ".gitlab-ci.yml",
"diff": "@@ -482,6 +482,23 @@ test-build-coverage-regression:\n- source ./ci/tools/threads.sh\n- ./ci/test-build-coverage-regression.sh\n+test-valgrind:\n+ stage: test\n+ tags:\n+ - linux\n+ - gcc\n+ - valgrind\n+ - sse4.2\n+ - powerful\n+ artifacts:\n+ name: valgrind-result\n+ when: always\n+ paths:\n+ - valgrind_result/\n+ script:\n+ - source ./ci/tools/threads.sh\n+ - ./ci/test-valgrind.sh\n+\ncoverage-linux:\nstage: coverage\ndependencies:\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "ci/test-valgrind.sh",
"diff": "+#!/bin/bash\n+set -x\n+\n+if [ -z \"$THREADS\" ]\n+then\n+ echo \"The 'THREADS' environment variable is not set, default value = 1.\"\n+ THREADS=1\n+fi\n+\n+WD=$(pwd)\n+build_root=build_coverage_linux_x86_gcc\n+\n+output_folder=\"valgrind\";\n+mkdir -p ${output_folder}\n+\n+log_file=\"${output_folder}/valgrind_error.log\";\n+touch ${log_file}\n+\n+function compile {\n+ build=$1\n+ mkdir $build\n+ cd $build\n+ cmake .. -G\"Unix Makefiles\" -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG=\"-O0\" -DCMAKE_CXX_FLAGS=\"-Wall -funroll-loops -msse4.2 -DMULTI_PREC -DENABLE_COOL_BASH\" -DCMAKE_EXE_LINKER_FLAGS=\"\"\n+ rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi\n+ make -j $THREADS\n+ rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi\n+ cd ..\n+}\n+\n+function check_valgrind\n+{\n+ build=$1\n+ local folder=$2\n+ for path in $folder/*\n+ do [ -f $path ] && {\n+ cmd=$(awk -F \"=\" '/command/ {print $2}' $path)\n+ echo $cmd\n+ ci=$(awk -F \"=\" '/ci/ {print $2}' $path)\n+ if [ \"$ci\" != \"off\" ]; then\n+ cd $build\n+ eval \"valgrind -q --error-exitcode=1 --leak-check=full ${cmd} --sim-stop-time 1 -t 1 -e 10000\"\n+ rc=$?;\n+ if [[ $rc != 0 ]]; then\n+ echo \"MEMCHECK ERROR\";\n+ echo \"valgrind --leak-check=full ${cmd}\" >> ${log_file}\n+ fi\n+ cd ..\n+ else\n+ echo \"The valgrind check is skipped because this test is disabled in the CI.\"\n+ fi\n+ } || {\n+ [ -d $path ] && {\n+ if [[ ${path: -7} == \"readers\" || ${path: -11} == \"__pycache__\" ]]; then\n+ continue\n+ fi\n+ check_valgrind $build $path\n+ }\n+ }\n+ done\n+}\n+\n+compile \"${build_root}\"\n+cd ${WD}\n+check_valgrind \"${build_root}\" \"refs/POLAR/AWGN/BPSK/SCL\"\n+\n+COUNT=$(wc -l < ${log_file} )\n+\n+if [ $COUNT -gt 0 ]; then\n+ echo \"Error count is $COUNT! Memory check run failed :-(.\";\n+ echo \"Search for 'MEMCHECK ERROR'.\"\n+ echo \"\"\n+ echo \"Errors list:\"\n+ cat ${log_file}\n+ exit 1;\n+else\n+ echo \"There is no error :-).\"\n+fi\n+\n+exit 0;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add valgrind tests in CI
|
8,483 |
14.09.2018 10:08:19
| -7,200 |
99b974b97bac668549e8cb0bacf5e107a2af3566
|
Change ROP noise display with 4 digits after comma
|
[
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit b7acfb171ebcd2a7418f6c9557baed81f578ca46\n+Subproject commit 7f32c432d86f7b11f49e396415865a814d0aac3d\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.cpp",
"new_path": "src/Tools/Display/Reporter/Noise/Reporter_noise.cpp",
"diff": "@@ -168,7 +168,7 @@ Reporter::report_t Reporter_noise<R>\n}\ncase Noise_type::ROP :\n{\n- stream << std::setprecision(2) << std::fixed << get_noise_ptr()->get_noise();\n+ stream << std::setprecision(4) << std::fixed << get_noise_ptr()->get_noise();\nbreak;\n}\ncase Noise_type::EP :\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change ROP noise display with 4 digits after comma
|
8,483 |
14.09.2018 10:40:01
| -7,200 |
8f7085bd4db5e485f45eacd9b655b4b06e9f7af1
|
Fix SC_Module
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/SC_Module.cpp",
"new_path": "src/Module/SC_Module.cpp",
"diff": "@@ -39,7 +39,8 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\ncase socket_t::SIN:\nindirect_sockets_in[i] = id_in;\nindirect_sockets_in_rev.push_back(i);\n- sockets_in.push_back(new tlm_utils::simple_target_socket<SC_Module>(name.c_str()));\n+ sockets_in.push_back(std::unique_ptr<tlm_utils::simple_target_socket<SC_Module>>(\n+ new tlm_utils::simple_target_socket<SC_Module>(name.c_str())));\nptr_input_sockets.push_back(s);\nswitch (ptr_input_sockets.size())\n{\n@@ -60,7 +61,8 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\ncase socket_t::SOUT:\nindirect_sockets_out[i] = id_out;\nindirect_sockets_out_rev.push_back(i);\n- sockets_out.push_back(new tlm_utils::simple_initiator_socket<SC_Module>(name.c_str()));\n+ sockets_out.push_back(std::unique_ptr<tlm_utils::simple_initiator_socket<SC_Module>>(\n+ new tlm_utils::simple_initiator_socket<SC_Module>(name.c_str())));\nif (!is_inputs)\nSC_THREAD(start_sc_thread);\nbreak;\n@@ -68,7 +70,8 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\ncase socket_t::SIN_SOUT:\nindirect_sockets_in[i] = id_in;\nindirect_sockets_in_rev.push_back(i);\n- sockets_in.push_back(new tlm_utils::simple_target_socket<SC_Module>(name.c_str()));\n+ sockets_in.push_back(std::unique_ptr<tlm_utils::simple_target_socket<SC_Module>>(\n+ new tlm_utils::simple_target_socket<SC_Module>(name.c_str())));\nptr_input_sockets.push_back(s);\nswitch (ptr_input_sockets.size())\n{\n@@ -86,7 +89,8 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\n}\nindirect_sockets_out[i] = id_out;\nindirect_sockets_out_rev.push_back(i);\n- sockets_out.push_back(new tlm_utils::simple_initiator_socket<SC_Module>(name.c_str()));\n+ sockets_out.push_back(std::unique_ptr<tlm_utils::simple_initiator_socket<SC_Module>>(\n+ new tlm_utils::simple_initiator_socket<SC_Module>(name.c_str())));\nbreak;\ndefault:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/SC_Module.hpp",
"new_path": "src/Module/SC_Module.hpp",
"diff": "@@ -25,10 +25,10 @@ class SC_Socket_in\n{\nfriend SC_Module;\nprotected:\n- std::vector<tlm_utils::simple_target_socket<C>*> &sockets;\n+ std::vector<std::unique_ptr<tlm_utils::simple_target_socket<C>>> &sockets;\nconst Task &task;\nconst std::vector<int> &indirect_sockets;\n- SC_Socket_in(std::vector<tlm_utils::simple_target_socket<C>*> &sockets,\n+ SC_Socket_in(std::vector<std::unique_ptr<tlm_utils::simple_target_socket<C>>> &sockets,\nconst Task &task, const std::vector<int> &indirect_sockets)\n: sockets(sockets), task(task), indirect_sockets(indirect_sockets) {}\npublic:\n@@ -44,10 +44,10 @@ class SC_Socket_out\n{\nfriend SC_Module;\nprotected:\n- std::vector<tlm_utils::simple_initiator_socket<C>*> &sockets;\n+ std::vector<std::unique_ptr<tlm_utils::simple_initiator_socket<C>>> &sockets;\nconst Task &task;\nconst std::vector<int> &indirect_sockets;\n- SC_Socket_out(std::vector<tlm_utils::simple_initiator_socket<C>*> &sockets,\n+ SC_Socket_out(std::vector<std::unique_ptr<tlm_utils::simple_initiator_socket<C>>> &sockets,\nconst Task &task, const std::vector<int> &indirect_sockets)\n: sockets(sockets), task(task), indirect_sockets(indirect_sockets) {}\npublic:\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix SC_Module
|
8,483 |
14.09.2018 14:23:28
| -7,200 |
ceeb49b955c95b267c2a60d9900052c9d4937361
|
Fix test valgrind path to the whole refs folder
|
[
{
"change_type": "MODIFY",
"old_path": ".gitlab-ci.yml",
"new_path": ".gitlab-ci.yml",
"diff": "@@ -297,6 +297,23 @@ build-macos-clang-x64-sse4.2:\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n+test-valgrind:\n+ stage: test\n+ tags:\n+ - linux\n+ - gcc\n+ - valgrind\n+ - sse4.2\n+ - powerful\n+ artifacts:\n+ name: valgrind-result\n+ when: always\n+ paths:\n+ - valgrind_result/\n+ script:\n+ - source ./ci/tools/threads.sh\n+ - ./ci/test-valgrind.sh\n+\ntest-regression-bch:\nstage: test\nretry: 1\n@@ -482,23 +499,6 @@ test-build-coverage-regression:\n- source ./ci/tools/threads.sh\n- ./ci/test-build-coverage-regression.sh\n-test-valgrind:\n- stage: test\n- tags:\n- - linux\n- - gcc\n- - valgrind\n- - sse4.2\n- - powerful\n- artifacts:\n- name: valgrind-result\n- when: always\n- paths:\n- - valgrind_result/\n- script:\n- - source ./ci/tools/threads.sh\n- - ./ci/test-valgrind.sh\n-\ncoverage-linux:\nstage: coverage\ndependencies:\n"
},
{
"change_type": "MODIFY",
"old_path": "ci/test-valgrind.sh",
"new_path": "ci/test-valgrind.sh",
"diff": "@@ -61,7 +61,7 @@ function check_valgrind\ncompile \"${build_root}\"\ncd ${WD}\n-check_valgrind \"${build_root}\" \"refs/POLAR/AWGN/BPSK/SCL\"\n+check_valgrind \"${build_root}\" \"refs\"\nCOUNT=$(wc -l < ${log_file} )\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix test valgrind path to the whole refs folder
|
8,483 |
14.09.2018 17:15:07
| -7,200 |
206a8b7118531324bcf7b7a5b724878ad65dbb06
|
Remove valgrind tests because it's too long. Set it as a simple script to run manually.
|
[
{
"change_type": "MODIFY",
"old_path": ".gitlab-ci.yml",
"new_path": ".gitlab-ci.yml",
"diff": "@@ -297,23 +297,6 @@ build-macos-clang-x64-sse4.2:\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n-test-valgrind:\n- stage: test\n- tags:\n- - linux\n- - gcc\n- - valgrind\n- - sse4.2\n- - powerful\n- artifacts:\n- name: valgrind-result\n- when: always\n- paths:\n- - valgrind_result/\n- script:\n- - source ./ci/tools/threads.sh\n- - ./ci/test-valgrind.sh\n-\ntest-regression-bch:\nstage: test\nretry: 1\n"
},
{
"change_type": "RENAME",
"old_path": "ci/test-valgrind.sh",
"new_path": "scripts/test-valgrind.sh",
"diff": "#!/bin/bash\n-set -x\n-if [ -z \"$THREADS\" ]\n+if [ -z \"$2\" ]\nthen\n- echo \"The 'THREADS' environment variable is not set, default value = 1.\"\n- THREADS=1\n+ echo \"Usage $0 build_path refs_path [result_file]\"\n+ exit 1\nfi\n-WD=$(pwd)\n-build_root=build_coverage_linux_x86_gcc\n+build_root=$1\n+refs_root=$2\n-output_folder=\"valgrind\";\n-mkdir -p ${output_folder}\n+log_file=\"valgrind_error.log\"\n+if [ ! -z \"$3\" ]\n+then\n+ log_file=\"$3\"\n+fi\n-log_file=\"${output_folder}/valgrind_error.log\";\ntouch ${log_file}\n-function compile {\n- build=$1\n- mkdir $build\n- cd $build\n- cmake .. -G\"Unix Makefiles\" -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG=\"-O0\" -DCMAKE_CXX_FLAGS=\"-Wall -funroll-loops -msse4.2 -DMULTI_PREC -DENABLE_COOL_BASH\" -DCMAKE_EXE_LINKER_FLAGS=\"\"\n- rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi\n- make -j $THREADS\n- rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi\n- cd ..\n-}\n-\nfunction check_valgrind\n{\nbuild=$1\n@@ -59,9 +49,7 @@ function check_valgrind\ndone\n}\n-compile \"${build_root}\"\n-cd ${WD}\n-check_valgrind \"${build_root}\" \"refs\"\n+check_valgrind ${build_root} ${refs_root}\nCOUNT=$(wc -l < ${log_file} )\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": "@@ -19,13 +19,13 @@ Decoder_BCH_fast<B,R>\nDecoder_BCH<B,R>(K, N, GF_poly.get_t(), n_frames ),\nt2 (2 * this->t ),\nYH_N (this->N * mipp::N<B>() ),\n- Y_N_reorderered (this->N ),\n+ Y_N_reorderered (this->N, mipp::Reg<B>((B)0)),\nelp (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 ),\n- s (t2+1 ),\n- reg (this->t +1 ),\n+ discrepancy (this->N_p2_1+2, mipp::Reg<B>((B)0)),\n+ l (this->N_p2_1+2, mipp::Reg<B>((B)0)),\n+ u_lu (this->N_p2_1+2, mipp::Reg<B>((B)0)),\n+ s (t2+1, mipp::Reg<B>((B)0)),\n+ reg (this->t +1, mipp::Reg<B>((B)0)),\nm (GF_poly.get_m() ),\nd (GF_poly.get_d() ),\nalpha_to (GF_poly.get_alpha_to() ),\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove valgrind tests because it's too long. Set it as a simple script to run manually.
|
8,483 |
17.09.2018 16:54:33
| -7,200 |
7834f13d1abc9696119564589ab35c96f9f38f09
|
Fix test valgrind script
|
[
{
"change_type": "MODIFY",
"old_path": "scripts/test-valgrind.sh",
"new_path": "scripts/test-valgrind.sh",
"diff": "@@ -30,11 +30,11 @@ function check_valgrind\ncd $build\neval \"valgrind -q --error-exitcode=1 --leak-check=full ${cmd} --sim-stop-time 1 -t 1 -e 10000\"\nrc=$?;\n+ cd ..\nif [[ $rc != 0 ]]; then\n- echo \"MEMCHECK ERROR\";\n+ echo \"MEMCHECK ERROR\"\necho \"valgrind --leak-check=full ${cmd}\" >> ${log_file}\nfi\n- cd ..\nelse\necho \"The valgrind check is skipped because this test is disabled in the CI.\"\nfi\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix test valgrind script
|
8,483 |
18.09.2018 08:13:08
| -7,200 |
dcd4da8e854fe46df367f6a680365a4b6fbaafc8
|
Create a function to transform an initialization list of pointers to a vector of unique_ptr in pattern polar parser.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/Polar/Pattern_polar_parser.cpp",
"new_path": "src/Tools/Code/Polar/Pattern_polar_parser.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n+std::vector<std::unique_ptr<tools::Pattern_polar_i>> convert_initlist_to_vecuniptr(std::initializer_list<tools::Pattern_polar_i*> patterns)\n+{\n+ std::vector<std::unique_ptr<tools::Pattern_polar_i>> v;\n+\n+ for (auto& p : patterns)\n+ v.push_back(std::unique_ptr<tools::Pattern_polar_i>(p));\n+\n+ return v;\n+}\n+\n+\nPattern_polar_parser\n::Pattern_polar_parser(const int& N,\nconst std::vector<bool> &frozen_bits,\n@@ -43,9 +54,7 @@ Pattern_polar_parser\nstd::initializer_list<tools::Pattern_polar_i*> patterns,\nconst std::unique_ptr<tools::Pattern_polar_i> &pattern_rate0,\nconst std::unique_ptr<tools::Pattern_polar_i> &pattern_rate1)\n-: Pattern_polar_parser(N, frozen_bits,\n- std::vector<std::unique_ptr<tools::Pattern_polar_i>>(std::make_move_iterator(patterns.begin()), std::make_move_iterator(patterns.end())),\n- pattern_rate0, pattern_rate1)\n+: Pattern_polar_parser(N, frozen_bits, convert_initlist_to_vecuniptr(patterns), pattern_rate0, pattern_rate1)\n{\n}\n@@ -55,9 +64,7 @@ Pattern_polar_parser\nstd::initializer_list<tools::Pattern_polar_i*> patterns,\nconst int pattern_rate0_id,\nconst int pattern_rate1_id)\n-: Pattern_polar_parser(N, frozen_bits,\n- std::vector<std::unique_ptr<tools::Pattern_polar_i>>(std::make_move_iterator(patterns.begin()), std::make_move_iterator(patterns.end())),\n- pattern_rate0_id, pattern_rate1_id)\n+: Pattern_polar_parser(N, frozen_bits, convert_initlist_to_vecuniptr(patterns), pattern_rate0_id, pattern_rate1_id)\n{\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Create a function to transform an initialization list of pointers to a vector of unique_ptr in pattern polar parser.
|
8,482 |
19.09.2018 23:58:16
| -10,800 |
1ac3c40784b3e72cca8df8cde9ed8839d3f8f4cd
|
Fix typo in codebook3
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"diff": "@@ -29,7 +29,7 @@ const std::complex<float> Modem_SCMA<B,R,Q,PSI>::CB[6][4][4] =\n{ { -0.6351f, 0.4615f }, { 0.1815f, -0.1318f }, { -0.1815f, 0.1318f }, { 0.6351f, -0.4615f } },\n{ { 0.1392f, -0.1759f }, { 0.4873f, -0.6156f }, { -0.4873f, 0.6156f }, { -0.1392f, 0.1759f } },\n{ { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { 0.0000f, 0.0000f }, { 00000.f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } }\n+ { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } }\n},\n{ // codebook4 (code layer 4)\n{ { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix typo in codebook3
|
8,483 |
27.09.2018 08:30:06
| -7,200 |
df66a6080d305ca0694658af2370c414c4719dff
|
Add to the Modem SCMA a file path argument to get the codebook from a file. Add a Codebook class to read and stock it. Use the --mdm-codebook command line argument to give the path.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "codebook_basic.cb",
"diff": "+6 4 4\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+-0.1815 -0.1318 -0.6351 -0.4615 0.6351 0.4615 0.1815 0.1318\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+ 0.7851 0.0000 -0.2243 0.0000 0.2243 0.0000 -0.7851 0.0000\n+ 0.7851 0.0000 -0.2243 0.0000 0.2243 0.0000 -0.7851 0.0000\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+-0.1815 -0.1318 -0.6351 -0.4615 0.6351 0.4615 0.1815 0.1318\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+-0.6351 0.4615 0.1815 -0.1318 -0.1815 0.1318 0.6351 -0.4615\n+ 0.1392 -0.1759 0.4873 -0.6156 -0.4873 0.6156 -0.1392 0.1759\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+ 0.7851 0.0000 -0.2243 0.0000 0.2243 0.0000 -0.7851 0.0000\n+-0.0055 -0.2242 -0.0193 -0.7848 0.0193 0.7848 0.0055 0.2242\n+-0.0055 -0.2242 -0.0193 -0.7848 0.0193 0.7848 0.0055 0.2242\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+-0.6351 0.4615 0.1815 -0.1318 -0.1815 0.1318 0.6351 -0.4615\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n+ 0.7851 0.0000 -0.2243 0.0000 0.2243 0.0000 -0.7851 0.0000\n+ 0.1392 -0.1759 0.4873 -0.6156 -0.4873 0.6156 -0.1392 0.1759\n+ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Modem/Modem.cpp",
"new_path": "src/Factory/Module/Modem/Modem.cpp",
"diff": "@@ -76,6 +76,11 @@ void Modem::parameters\ntools::File(tools::openmode::read_write),\n\"path to the ordered modulation symbols (constellation), to use with \\\"--mod-type USER\\\".\");\n+ args.add(\n+ {p+\"-codebook\"},\n+ tools::File(tools::openmode::read),\n+ \"path to the codebook, to use with \\\"--mod-type SCMA\\\".\");\n+\nargs.add(\n{p+\"-cpm-std\"},\ntools::Text(tools::Including_set(\"GSM\")),\n@@ -173,6 +178,7 @@ void Modem::parameters\nif(vals.exist({p+\"-bps\" })) this->bps = vals.to_int({p+\"-bps\" });\nif(vals.exist({p+\"-ups\" })) this->upf = vals.to_int({p+\"-ups\" });\nif(vals.exist({p+\"-const-path\" })) this->const_path = vals.at ({p+\"-const-path\" });\n+ if(vals.exist({p+\"-codebook\" })) this->codebook = vals.at ({p+\"-codebook\" });\nif(vals.exist({p+\"-cpm-L\" })) this->cpm_L = vals.to_int({p+\"-cpm-L\" });\nif(vals.exist({p+\"-cpm-p\" })) this->cpm_p = vals.to_int({p+\"-cpm-p\" });\nif(vals.exist({p+\"-cpm-k\" })) this->cpm_k = vals.to_int({p+\"-cpm-k\" });\n@@ -274,10 +280,10 @@ template <typename B, typename R, typename Q>\nmodule::Modem<B,R,Q>* Modem::parameters\n::_build_scma() const\n{\n- if (this->psi == \"PSI0\") return new module::Modem_SCMA <B,R,Q,tools::psi_0<Q>>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n- if (this->psi == \"PSI1\") return new module::Modem_SCMA <B,R,Q,tools::psi_1<Q>>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n- if (this->psi == \"PSI2\") return new module::Modem_SCMA <B,R,Q,tools::psi_2<Q>>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n- if (this->psi == \"PSI3\") return new module::Modem_SCMA <B,R,Q,tools::psi_3<Q>>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n+ if (this->psi == \"PSI0\") return new module::Modem_SCMA <B,R,Q,tools::psi_0<Q>>(this->N, this->codebook, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n+ if (this->psi == \"PSI1\") return new module::Modem_SCMA <B,R,Q,tools::psi_1<Q>>(this->N, this->codebook, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n+ if (this->psi == \"PSI2\") return new module::Modem_SCMA <B,R,Q,tools::psi_2<Q>>(this->N, this->codebook, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n+ if (this->psi == \"PSI3\") return new module::Modem_SCMA <B,R,Q,tools::psi_3<Q>>(this->N, this->codebook, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Modem/Modem.hpp",
"new_path": "src/Factory/Module/Modem/Modem.hpp",
"diff": "@@ -31,6 +31,7 @@ struct Modem : public Factory\nstd::string type = \"BPSK\"; // modulation type (PAM, QAM, ...)\nstd::string implem = \"STD\";\nstd::string const_path = \"\"; // PATH to constellation file (CSV file)\n+ std::string codebook = \"\"; // PATH to codebook file\nbool complex = true; // true if the modulated signal is complex\nint bps = 1; // bits per symbol\nint upf = 1; // samples per symbol\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hpp",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hpp",
"diff": "#include <complex>\n#include <vector>\n+#include <string>\n#include \"Tools/Code/SCMA/modem_SCMA_functions.hpp\"\n+#include \"Tools/Code/SCMA/Codebook.hpp\"\n#include \"../Modem.hpp\"\n@@ -12,19 +14,21 @@ namespace aff3ct\n{\nnamespace module\n{\n+\ntemplate <typename B = int, typename R = float, typename Q = R, tools::proto_psi<Q> PSI = tools::psi_0>\nclass Modem_SCMA : public Modem<B,R,Q>\n{\nprivate:\n- const static std::complex<float> CB[6][4][4];\n+ const tools::Codebook<R> CB;\nconst int re_user[4][3] = {{1,2,4},{0,2,5},{1,3,5},{0,3,4}};\nQ arr_phi[4][4][4][4] = {}; // probability functions\nconst bool disable_sig2;\nR n0; // 1 / n0 = 179.856115108\nconst int n_ite;\n+ const int bps;\npublic:\n- Modem_SCMA(const int N, const tools::Noise<R>& noise = tools::Sigma<R>(), const int bps = 3, const bool disable_sig2 = false,\n+ Modem_SCMA(const int N, const std::string& codebook_path, const tools::Noise<R>& noise = tools::Sigma<R>(), const int bps = 3, const bool disable_sig2 = false,\nconst int n_ite = 1, const int n_frames = 6);\nvirtual ~Modem_SCMA() = default;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"diff": "@@ -11,70 +11,74 @@ namespace aff3ct\n{\nnamespace module\n{\n-template <typename B, typename R, typename Q, tools::proto_psi<Q> PSI>\n-const std::complex<float> Modem_SCMA<B,R,Q,PSI>::CB[6][4][4] =\n-{\n- { // codebook1 (code layer 1)\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { -0.1815f, -0.1318f }, { -0.6351f, -0.4615f }, { 0.6351f, 0.4615f }, { 0.1815f, 0.1318f } },\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { 0.7851f, 0.0000f }, { -0.2243f, 0.0000f }, { 0.2243f, 0.0000f }, { -0.7851f, 0.0000f } }\n- },\n- { // codebook2 (code layer 2)\n- { { 0.7851f, 0.0000f }, { -0.2243f, 0.0000f }, { 0.2243f, 0.0000f }, { -0.7851f, 0.0000f } },\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { -0.1815f, -0.1318f }, { -0.6351f, -0.4615f }, { 0.6351f, 0.4615f }, { 0.1815f, 0.1318f } },\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } }\n- },\n- { // codebook3 (code layer 3)\n- { { -0.6351f, 0.4615f }, { 0.1815f, -0.1318f }, { -0.1815f, 0.1318f }, { 0.6351f, -0.4615f } },\n- { { 0.1392f, -0.1759f }, { 0.4873f, -0.6156f }, { -0.4873f, 0.6156f }, { -0.1392f, 0.1759f } },\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } }\n- },\n- { // codebook4 (code layer 4)\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { 0.7851f, 0.0000f }, { -0.2243f, 0.0000f }, { 0.2243f, 0.0000f }, { -0.7851f, 0.0000f } },\n- { { -0.0055f, -0.2242f }, { -0.0193f, -0.7848f }, { 0.0193f, 0.7848f }, { 0.0055f, 0.2242f } }\n- },\n- { // codebook5 (code layer 5)\n- { { -0.0055f, -0.2242f }, { -0.0193f, -0.7848f }, { 0.0193f, 0.7848f }, { 0.0055f, 0.2242f } },\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { -0.6351f, 0.4615f }, { 0.1815f, -0.1318f }, { -0.1815f, 0.1318f }, { 0.6351f, -0.4615f } }\n- },\n- { // codebook6 (code layer 6)\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n- { { 0.7851f, 0.0000f }, { -0.2243f, 0.0000f }, { 0.2243f, 0.0000f }, { -0.7851f, 0.0000f } },\n- { { 0.1392f, -0.1759f }, { 0.4873f, -0.6156f }, { -0.4873f, 0.6156f }, { -0.1392f, 0.1759f } },\n- { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } }\n- },\n-};\n+// template <typename B, typename R, typename Q, tools::proto_psi<Q> PSI>\n+// const std::complex<float> Modem_SCMA<B,R,Q,PSI>::CB[6][4][4] =\n+// {\n+// { // codebook1 (code layer 1)\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n+// { { -0.1815f, -0.1318f }, { -0.6351f, -0.4615f }, { 0.6351f, 0.4615f }, { 0.1815f, 0.1318f } },\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n+// { { 0.7851f, 0.0000f }, { -0.2243f, 0.0000f }, { 0.2243f, 0.0000f }, { -0.7851f, 0.0000f } }\n+// },\n+// { // codebook2 (code layer 2)\n+// { { 0.7851f, 0.0000f }, { -0.2243f, 0.0000f }, { 0.2243f, 0.0000f }, { -0.7851f, 0.0000f } },\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n+// { { -0.1815f, -0.1318f }, { -0.6351f, -0.4615f }, { 0.6351f, 0.4615f }, { 0.1815f, 0.1318f } },\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } }\n+// },\n+// { // codebook3 (code layer 3)\n+// { { -0.6351f, 0.4615f }, { 0.1815f, -0.1318f }, { -0.1815f, 0.1318f }, { 0.6351f, -0.4615f } },\n+// { { 0.1392f, -0.1759f }, { 0.4873f, -0.6156f }, { -0.4873f, 0.6156f }, { -0.1392f, 0.1759f } },\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } }\n+// },\n+// { // codebook4 (code layer 4)\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n+// { { 0.7851f, 0.0000f }, { -0.2243f, 0.0000f }, { 0.2243f, 0.0000f }, { -0.7851f, 0.0000f } },\n+// { { -0.0055f, -0.2242f }, { -0.0193f, -0.7848f }, { 0.0193f, 0.7848f }, { 0.0055f, 0.2242f } }\n+// },\n+// { // codebook5 (code layer 5)\n+// { { -0.0055f, -0.2242f }, { -0.0193f, -0.7848f }, { 0.0193f, 0.7848f }, { 0.0055f, 0.2242f } },\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n+// { { -0.6351f, 0.4615f }, { 0.1815f, -0.1318f }, { -0.1815f, 0.1318f }, { 0.6351f, -0.4615f } }\n+// },\n+// { // codebook6 (code layer 6)\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } },\n+// { { 0.7851f, 0.0000f }, { -0.2243f, 0.0000f }, { 0.2243f, 0.0000f }, { -0.7851f, 0.0000f } },\n+// { { 0.1392f, -0.1759f }, { 0.4873f, -0.6156f }, { -0.4873f, 0.6156f }, { -0.1392f, 0.1759f } },\n+// { { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f }, { 0.0000f, 0.0000f } }\n+// },\n+// };\ntemplate <typename B, typename R, typename Q, tools::proto_psi<Q> PSI>\nModem_SCMA<B,R,Q,PSI>\n-::Modem_SCMA(const int N, const tools::Noise<R>& noise, const int bps, const bool disable_sig2, const int n_ite,\n- const int n_frames)\n+::Modem_SCMA(const int N, const std::string& codebook_path, const tools::Noise<R>& noise, const int bps,\n+ const bool disable_sig2, const int n_ite, const int n_frames)\n: Modem<B,R,Q>(N,\nModem_SCMA<B,R,Q,PSI>::size_mod(N, bps),\nModem_SCMA<B,R,Q,PSI>::size_fil(N, bps),\nnoise,\nn_frames),\n+ CB (codebook_path),\ndisable_sig2(disable_sig2 ),\n- n_ite (n_ite )\n+ n_ite (n_ite ),\n+ bps (bps )\n{\nconst std::string name = \"Modem_SCMA\";\nthis->set_name(name);\n- if (n_frames != 6)\n+ if (n_frames != CB.get_number_of_users())\n{\nstd::stringstream message;\n- message << \"'n_frames' has to be equal to 6 ('n_frames' = \" << n_frames << \").\";\n+ message << \"'n_frames' has to be equal to CB.get_number_of_users() ('n_frames' = \" << n_frames\n+ << \", 'CB.get_number_of_users()' = \" << CB.get_number_of_users() << \").\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (bps != 3)\n+ if (bps != 3) // TODO: With what should \"3\" be replaced ? -> have added \"bps\" attribute to the class, maybe you'll\n+ // need to use it in the code to have it generic\n{\nstd::stringstream message;\nmessage << \"'bps' has to be equal to 3 ('bps' = \" << bps << \").\";\n@@ -113,7 +117,7 @@ void Modem_SCMA<B,R,Q,PSI>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- const auto N_mod = 8 * ((this->N + 1) / 2);\n+ const auto N_mod = 8 * ((this->N + 1) / 2); // TODO: With what should \"8\" be replaced ?\nfor (auto f = 0 ; f < this->n_frames ; f++)\n{\n@@ -121,13 +125,13 @@ void Modem_SCMA<B,R,Q,PSI>\n{\nunsigned idx = 0;\n- for (unsigned i = 0 ; i < 2 ; i++)\n+ for (unsigned i = 0 ; i < 2 ; i++) // TODO: With what should \"2\" be replaced ?\nidx += (1 << i) * (unsigned)X_N1[f * this->N + 2 * j + i];\n- for (auto i = 0 ; i < 4 ; i++)\n+ for (auto i = 0 ; i < CB.get_number_of_orthogonal_resources() ; i++)\n{\n- X_N2[f * N_mod + 8 * j + 2 * i ] = CB[f][i][idx].real();\n- X_N2[f * N_mod + 8 * j + 2 * i +1] = CB[f][i][idx].imag();\n+ X_N2[f * N_mod + 8 * j + 2 * i ] = CB(f, i, idx).real();\n+ X_N2[f * N_mod + 8 * j + 2 * i +1] = CB(f, i, idx).imag();\n}\n}\n}\n@@ -138,10 +142,10 @@ void Modem_SCMA<B,R,Q,PSI>\n{\nunsigned idx = (unsigned)X_N1[f * this->N + this->N - 1];\n- for (auto i = 0 ; i < 4 ; i++)\n+ for (auto i = 0 ; i < CB.get_number_of_orthogonal_resources() ; i++)\n{\n- X_N2[f * N_mod + 8 * (this->N / 2) + 2 * i ] = CB[f][i][idx].real();\n- X_N2[f * N_mod + 8 * (this->N / 2) + 2 * i +1] = CB[f][i][idx].imag();\n+ X_N2[f * N_mod + 8 * (this->N / 2) + 2 * i ] = CB(f, i, idx).real(); // TODO: With what should \"8\" be replaced ?\n+ X_N2[f * N_mod + 8 * (this->N / 2) + 2 * i +1] = CB(f, i, idx).imag(); // TODO: With what should \"2\" be replaced ?\n}\n}\n}\n@@ -170,10 +174,10 @@ void Modem_SCMA<B,R,Q,PSI>\nfor (auto batch = 0 ; batch < (this->N +1) / 2 ; batch++)\n{\n// filling array_phi luts\n- for (auto i = 0; i < 4; i++)\n- for (auto j = 0; j < 4; j++)\n- for (auto k = 0; k < 4; k++)\n- for (auto re = 0; re < 4; re++)\n+ for (auto i = 0; i < CB.get_codebook_size(); i++)\n+ for (auto j = 0; j < CB.get_codebook_size(); j++)\n+ for (auto k = 0; k < CB.get_codebook_size(); k++)\n+ for (auto re = 0; re < CB.get_number_of_orthogonal_resources(); re++)\narr_phi[re][i][j][k] = phi(Y_N1, i, j, k, re, batch, H_N);\ndemodulate_batch(Y_N1,Y_N2,batch);\n@@ -203,10 +207,10 @@ void Modem_SCMA<B,R,Q,PSI>\nfor (auto batch = 0 ; batch < (this->N +1) / 2 ; batch++)\n{\n// filling array_phi luts\n- for (auto i = 0; i < 4; i++)\n- for (auto j = 0; j < 4; j++)\n- for (auto k = 0; k < 4; k++)\n- for (auto re = 0; re < 4; re++)\n+ for (auto i = 0; i < CB.get_codebook_size(); i++)\n+ for (auto j = 0; j < CB.get_codebook_size(); j++)\n+ for (auto k = 0; k < CB.get_codebook_size(); k++)\n+ for (auto re = 0; re < CB.get_number_of_orthogonal_resources(); re++)\narr_phi[re][i][j][k] = phi(Y_N1, i, j, k, re, batch);\ndemodulate_batch(Y_N1,Y_N2,batch);\n@@ -358,9 +362,9 @@ Q Modem_SCMA<B,R,Q,PSI>\nauto Y_N = std::complex<Q>(Y_N1[batch *8 + 2*re], Y_N1[batch*8 + 2*re +1]);\n- const auto CB0 = std::complex<Q>((Q)CB[re_user[re][0]][re][i].real(), (Q)CB[re_user[re][0]][re][i].imag());\n- const auto CB1 = std::complex<Q>((Q)CB[re_user[re][1]][re][j].real(), (Q)CB[re_user[re][1]][re][j].imag());\n- const auto CB2 = std::complex<Q>((Q)CB[re_user[re][2]][re][k].real(), (Q)CB[re_user[re][2]][re][k].imag());\n+ const auto CB0 = std::complex<Q>((Q)CB(re_user[re][0], re, i).real(), (Q)CB(re_user[re][0], re, i).imag());\n+ const auto CB1 = std::complex<Q>((Q)CB(re_user[re][1], re, j).real(), (Q)CB(re_user[re][1], re, j).imag());\n+ const auto CB2 = std::complex<Q>((Q)CB(re_user[re][2], re, k).real(), (Q)CB(re_user[re][2], re, k).imag());\ntmp = Y_N - (CB0 + CB1 + CB2);\n@@ -386,9 +390,9 @@ Q Modem_SCMA<B,R,Q,PSI>\nconst auto H_N2 = std::complex<Q>((Q)H_N[re_user[re][2] * Nmod + 8 * batch + 2 * re ],\n(Q)H_N[re_user[re][2] * Nmod + 8 * batch + 2 * re +1]);\n- const auto CB0 = std::complex<Q>((Q)CB[re_user[re][0]][re][i].real(), (Q)CB[re_user[re][0]][re][i].imag());\n- const auto CB1 = std::complex<Q>((Q)CB[re_user[re][1]][re][j].real(), (Q)CB[re_user[re][1]][re][j].imag());\n- const auto CB2 = std::complex<Q>((Q)CB[re_user[re][2]][re][k].real(), (Q)CB[re_user[re][2]][re][k].imag());\n+ const auto CB0 = std::complex<Q>((Q)CB(re_user[re][0], re, i).real(), (Q)CB(re_user[re][0], re, i).imag());\n+ const auto CB1 = std::complex<Q>((Q)CB(re_user[re][1], re, j).real(), (Q)CB(re_user[re][1], re, j).imag());\n+ const auto CB2 = std::complex<Q>((Q)CB(re_user[re][2], re, k).real(), (Q)CB(re_user[re][2], re, k).imag());\ntmp = Y_N - (H_N0 * CB0 + H_N1 * CB1 + H_N2 * CB2);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Code/SCMA/Codebook.hpp",
"diff": "+#ifndef CODEBOOK_HPP_\n+#define CODEBOOK_HPP_\n+\n+#include <string>\n+#include <complex>\n+#include <vector>\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename R>\n+class Codebook\n+{\n+public:\n+ explicit Codebook(const std::string& codebook_path);\n+ ~Codebook() = default;\n+\n+ const std::complex<R>& operator() (int u, int o, int c) const;\n+\n+ int get_number_of_users() const;\n+ int get_number_of_orthogonal_resources() const;\n+ int get_codebook_size() const;\n+\n+private:\n+ std::vector<std::vector<std::vector<std::complex<R>>>> data;\n+\n+ int number_of_users;\n+ int number_of_orthogonal_resources;\n+ int codebook_size;\n+\n+ void read_codebook(const std::string& codebook_path);\n+};\n+\n+}\n+}\n+\n+#include \"Codebook.hxx\"\n+\n+#endif // CODEBOOK_HPP_\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Code/SCMA/Codebook.hxx",
"diff": "+#ifndef CODEBOOK_HXX_\n+#define CODEBOOK_HXX_\n+\n+#include <sstream>\n+#include <fstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+#include \"Codebook.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+template <typename R>\n+Codebook<R>\n+::Codebook(const std::string& codebook_path)\n+{\n+ read_codebook(codebook_path);\n+\n+ if (number_of_users <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'number_of_users' has to be strictly positive ('number_of_users' = \" << number_of_users << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (number_of_orthogonal_resources <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'number_of_orthogonal_resources' has to be strictly positive ('number_of_orthogonal_resources' = \" << number_of_orthogonal_resources << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (codebook_size <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'number_of_users' has to be strictly positive ('codebook_size' = \" << codebook_size << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n+template <typename R>\n+void Codebook<R>\n+::read_codebook(const std::string& codebook_path)\n+{\n+ std::ifstream file(codebook_path);\n+\n+ file >> number_of_users >> number_of_orthogonal_resources >> codebook_size;\n+\n+ data.resize(number_of_users);\n+\n+ for (int u = 0; u < number_of_users; ++u)\n+ {\n+ data[u].resize(number_of_orthogonal_resources);\n+ for (int r = 0; r < number_of_orthogonal_resources; ++r)\n+ {\n+ data[u][r].resize(codebook_size);\n+ for (int c = 0; c < codebook_size; ++c)\n+ {\n+ if (file.fail())\n+ {\n+ std::stringstream message;\n+ message << \"There is not enough data in codebook file 'codebook_path' ( = \\\"\" << codebook_path << \"\\\").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ float real, imag;\n+ file >> real >> imag;\n+\n+ data[u][r][c].real(real);\n+ data[u][r][c].imag(imag);\n+ }\n+ }\n+ }\n+}\n+\n+\n+\n+template <typename R>\n+inline const std::complex<R>& Codebook<R>\n+::operator() (int u, int o, int c) const\n+{\n+ return data[u][o][c];\n+}\n+\n+template <typename R>\n+inline int Codebook<R>\n+::get_number_of_users() const\n+{\n+ return number_of_users;\n+}\n+\n+template <typename R>\n+inline int Codebook<R>\n+::get_number_of_orthogonal_resources() const\n+{\n+ return number_of_orthogonal_resources;\n+}\n+\n+template <typename R>\n+inline int Codebook<R>\n+::get_codebook_size() const\n+{\n+ return codebook_size;\n+}\n+\n+}\n+}\n+\n+#endif // CODEBOOK_HXX_\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add to the Modem SCMA a file path argument to get the codebook from a file. Add a Codebook class to read and stock it. Use the --mdm-codebook command line argument to give the path.
|
8,482 |
27.09.2018 15:59:52
| -10,800 |
999b43285e36c55b83150dfe141f6d329f283a4e
|
Move re_user from Modem_SCMA to Codebook
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hpp",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hpp",
"diff": "@@ -20,7 +20,6 @@ class Modem_SCMA : public Modem<B,R,Q>\n{\nprivate:\nconst tools::Codebook<R> CB;\n- const int re_user[4][3] = {{1,2,4},{0,2,5},{1,3,5},{0,3,4}};\nQ arr_phi[4][4][4][4] = {}; // probability functions\nconst bool disable_sig2;\nR n0; // 1 / n0 = 179.856115108\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"diff": "@@ -278,18 +278,18 @@ void Modem_SCMA<B,R,Q,PSI>\nfor (auto k = 0; k < 4; k++)\nfor(auto re = 0 ; re < 4 ; re++)\n{\n- msg_res_user[re][re_user[re][0]][i] = msg_res_user[re][re_user[re][0]][i]\n+ msg_res_user[re][CB.get_re_user(re,0)][i] = msg_res_user[re][CB.get_re_user(re,0)][i]\n+ arr_phi[re][i][j][k]\n- * msg_user_res[re_user[re][1]][re][j]\n- * msg_user_res[re_user[re][2]][re][k];\n- msg_res_user[re][re_user[re][1]][i] = msg_res_user[re][re_user[re][1]][i]\n+ * msg_user_res[CB.get_re_user(re,1)][re][j]\n+ * msg_user_res[CB.get_re_user(re,2)][re][k];\n+ msg_res_user[re][CB.get_re_user(re,1)][i] = msg_res_user[re][CB.get_re_user(re,1)][i]\n+ arr_phi[re][j][i][k]\n- * msg_user_res[re_user[re][0]][re][j]\n- * msg_user_res[re_user[re][2]][re][k];\n- msg_res_user[re][re_user[re][2]][i] = msg_res_user[re][re_user[re][2]][i]\n+ * msg_user_res[CB.get_re_user(re,0)][re][j]\n+ * msg_user_res[CB.get_re_user(re,2)][re][k];\n+ msg_res_user[re][CB.get_re_user(re,2)][i] = msg_res_user[re][CB.get_re_user(re,2)][i]\n+ arr_phi[re][j][k][i]\n- * msg_user_res[re_user[re][0]][re][j]\n- * msg_user_res[re_user[re][1]][re][k];\n+ * msg_user_res[CB.get_re_user(re,0)][re][j]\n+ * msg_user_res[CB.get_re_user(re,1)][re][k];\n}\n// user to resource messaging\n@@ -362,9 +362,9 @@ Q Modem_SCMA<B,R,Q,PSI>\nauto Y_N = std::complex<Q>(Y_N1[batch *8 + 2*re], Y_N1[batch*8 + 2*re +1]);\n- const auto CB0 = std::complex<Q>((Q)CB(re_user[re][0], re, i).real(), (Q)CB(re_user[re][0], re, i).imag());\n- const auto CB1 = std::complex<Q>((Q)CB(re_user[re][1], re, j).real(), (Q)CB(re_user[re][1], re, j).imag());\n- const auto CB2 = std::complex<Q>((Q)CB(re_user[re][2], re, k).real(), (Q)CB(re_user[re][2], re, k).imag());\n+ const auto CB0 = std::complex<Q>((Q)CB(CB.get_re_user(re,0), re, i).real(), (Q)CB(CB.get_re_user(re,0), re, i).imag());\n+ const auto CB1 = std::complex<Q>((Q)CB(CB.get_re_user(re,1), re, j).real(), (Q)CB(CB.get_re_user(re,1), re, j).imag());\n+ const auto CB2 = std::complex<Q>((Q)CB(CB.get_re_user(re,2), re, k).real(), (Q)CB(CB.get_re_user(re,2), re, k).imag());\ntmp = Y_N - (CB0 + CB1 + CB2);\n@@ -383,16 +383,16 @@ Q Modem_SCMA<B,R,Q,PSI>\nconst auto Y_N = std::complex<Q>(Y_N1[batch *8 + 2*re], Y_N1[batch*8 + 2*re +1]);\n- const auto H_N0 = std::complex<Q>((Q)H_N[re_user[re][0] * Nmod + 8 * batch + 2 * re ],\n- (Q)H_N[re_user[re][0] * Nmod + 8 * batch + 2 * re +1]);\n- const auto H_N1 = std::complex<Q>((Q)H_N[re_user[re][1] * Nmod + 8 * batch + 2 * re ],\n- (Q)H_N[re_user[re][1] * Nmod + 8 * batch + 2 * re +1]);\n- const auto H_N2 = std::complex<Q>((Q)H_N[re_user[re][2] * Nmod + 8 * batch + 2 * re ],\n- (Q)H_N[re_user[re][2] * Nmod + 8 * batch + 2 * re +1]);\n+ const auto H_N0 = std::complex<Q>((Q)H_N[CB.get_re_user(re,0) * Nmod + 8 * batch + 2 * re ],\n+ (Q)H_N[CB.get_re_user(re,0) * Nmod + 8 * batch + 2 * re +1]);\n+ const auto H_N1 = std::complex<Q>((Q)H_N[CB.get_re_user(re,1) * Nmod + 8 * batch + 2 * re ],\n+ (Q)H_N[CB.get_re_user(re,1) * Nmod + 8 * batch + 2 * re +1]);\n+ const auto H_N2 = std::complex<Q>((Q)H_N[CB.get_re_user(re,2) * Nmod + 8 * batch + 2 * re ],\n+ (Q)H_N[CB.get_re_user(re,2) * Nmod + 8 * batch + 2 * re +1]);\n- const auto CB0 = std::complex<Q>((Q)CB(re_user[re][0], re, i).real(), (Q)CB(re_user[re][0], re, i).imag());\n- const auto CB1 = std::complex<Q>((Q)CB(re_user[re][1], re, j).real(), (Q)CB(re_user[re][1], re, j).imag());\n- const auto CB2 = std::complex<Q>((Q)CB(re_user[re][2], re, k).real(), (Q)CB(re_user[re][2], re, k).imag());\n+ const auto CB0 = std::complex<Q>((Q)CB(CB.get_re_user(re,0), re, i).real(), (Q)CB(CB.get_re_user(re,0), re, i).imag());\n+ const auto CB1 = std::complex<Q>((Q)CB(CB.get_re_user(re,1), re, j).real(), (Q)CB(CB.get_re_user(re,1), re, j).imag());\n+ const auto CB2 = std::complex<Q>((Q)CB(CB.get_re_user(re,2), re, k).real(), (Q)CB(CB.get_re_user(re,2), re, k).imag());\ntmp = Y_N - (H_N0 * CB0 + H_N1 * CB1 + H_N2 * CB2);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/SCMA/Codebook.hpp",
"new_path": "src/Tools/Code/SCMA/Codebook.hpp",
"diff": "@@ -22,6 +22,7 @@ public:\nint get_number_of_users() const;\nint get_number_of_orthogonal_resources() const;\nint get_codebook_size() const;\n+ int get_re_user(int r, int df) const;\nprivate:\nstd::vector<std::vector<std::vector<std::complex<R>>>> data;\n@@ -30,6 +31,8 @@ private:\nint number_of_orthogonal_resources;\nint codebook_size;\n+ int re_user[4][3];\n+\nvoid read_codebook(const std::string& codebook_path);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/SCMA/Codebook.hxx",
"new_path": "src/Tools/Code/SCMA/Codebook.hxx",
"diff": "@@ -72,6 +72,37 @@ void Codebook<R>\n}\n}\n}\n+\n+ // Factor graph calculation TODO: Now constants and fixed size (-> dynamic allocation later)\n+ int F[4][6] = {};\n+\n+ for (int u = 0; u < number_of_users; ++u)\n+ {\n+ for (int r = 0; r < number_of_orthogonal_resources; ++r)\n+ {\n+ for (int c = 0; c < codebook_size; ++c)\n+ {\n+ if ((data[u][r][c].real() != 0.0) || (data[u][r][c].imag() != 0.0))\n+ {\n+ F[r][u] = 1;\n+ break;\n+ }\n+ }\n+ }\n+ }\n+\n+ for (int r = 0; r < number_of_orthogonal_resources; ++r)\n+ {\n+ int idx = 0;\n+ for (int u = 0; u < number_of_users; ++u)\n+ {\n+ if (F[r][u] == 1)\n+ {\n+ re_user[r][idx] = u;\n+ idx++;\n+ }\n+ }\n+ }\n}\n@@ -104,6 +135,15 @@ inline int Codebook<R>\nreturn codebook_size;\n}\n+\n+template <typename R>\n+inline int Codebook<R>\n+::get_re_user(int r, int df) const\n+{\n+ return re_user[r][df];\n+}\n+\n+\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Move re_user from Modem_SCMA to Codebook
|
8,482 |
27.09.2018 19:43:21
| -10,800 |
546f6f80f3e834de5f56930a6e80e6a12a9205b6
|
Add user_re array and small refactor
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"diff": "@@ -236,20 +236,20 @@ void Modem_SCMA<B,R,Q,PSI>\nQ guess[6][4] = {};\n// initial probability of each codeword/user\n- for (auto i = 0; i < 4; i++)\n- {\n- msg_user_res[0][1][i] = (Q)0.25;\n- msg_user_res[0][3][i] = (Q)0.25;\n- msg_user_res[1][0][i] = (Q)0.25;\n- msg_user_res[1][2][i] = (Q)0.25;\n- msg_user_res[2][0][i] = (Q)0.25;\n- msg_user_res[2][1][i] = (Q)0.25;\n- msg_user_res[3][2][i] = (Q)0.25;\n- msg_user_res[3][3][i] = (Q)0.25;\n- msg_user_res[4][0][i] = (Q)0.25;\n- msg_user_res[4][3][i] = (Q)0.25;\n- msg_user_res[5][1][i] = (Q)0.25;\n- msg_user_res[5][2][i] = (Q)0.25;\n+ for (auto i = 0; i < CB.get_codebook_size(); i++)\n+ {\n+ msg_user_res[0][CB.get_user_re(0,0)][i] = (Q)0.25;\n+ msg_user_res[0][CB.get_user_re(0,1)][i] = (Q)0.25;\n+ msg_user_res[1][CB.get_user_re(1,0)][i] = (Q)0.25;\n+ msg_user_res[1][CB.get_user_re(1,1)][i] = (Q)0.25;\n+ msg_user_res[2][CB.get_user_re(2,0)][i] = (Q)0.25;\n+ msg_user_res[2][CB.get_user_re(2,1)][i] = (Q)0.25;\n+ msg_user_res[3][CB.get_user_re(3,0)][i] = (Q)0.25;\n+ msg_user_res[3][CB.get_user_re(3,1)][i] = (Q)0.25;\n+ msg_user_res[4][CB.get_user_re(4,0)][i] = (Q)0.25;\n+ msg_user_res[4][CB.get_user_re(4,1)][i] = (Q)0.25;\n+ msg_user_res[5][CB.get_user_re(5,0)][i] = (Q)0.25;\n+ msg_user_res[5][CB.get_user_re(5,1)][i] = (Q)0.25;\n}\n// starting iteration\n@@ -257,26 +257,26 @@ void Modem_SCMA<B,R,Q,PSI>\n{\n// resource to user messaging\n// initialization\n- for (auto i = 0; i < 4; i++)\n- {\n- msg_res_user[0][1][i] = (Q)0;\n- msg_res_user[0][2][i] = (Q)0;\n- msg_res_user[0][4][i] = (Q)0;\n- msg_res_user[1][0][i] = (Q)0;\n- msg_res_user[1][2][i] = (Q)0;\n- msg_res_user[1][5][i] = (Q)0;\n- msg_res_user[2][1][i] = (Q)0;\n- msg_res_user[2][3][i] = (Q)0;\n- msg_res_user[2][5][i] = (Q)0;\n- msg_res_user[3][0][i] = (Q)0;\n- msg_res_user[3][3][i] = (Q)0;\n- msg_res_user[3][4][i] = (Q)0;\n- }\n-\n- for (auto i = 0; i < 4; i++) // codeword index\n- for (auto j = 0; j < 4; j++)\n- for (auto k = 0; k < 4; k++)\n- for(auto re = 0 ; re < 4 ; re++)\n+ for (auto i = 0; i < CB.get_number_of_orthogonal_resources(); i++)\n+ {\n+ msg_res_user[0][CB.get_re_user(0,0)][i] = (Q)0;\n+ msg_res_user[0][CB.get_re_user(0,1)][i] = (Q)0;\n+ msg_res_user[0][CB.get_re_user(0,2)][i] = (Q)0;\n+ msg_res_user[1][CB.get_re_user(1,0)][i] = (Q)0;\n+ msg_res_user[1][CB.get_re_user(1,1)][i] = (Q)0;\n+ msg_res_user[1][CB.get_re_user(1,2)][i] = (Q)0;\n+ msg_res_user[2][CB.get_re_user(2,0)][i] = (Q)0;\n+ msg_res_user[2][CB.get_re_user(2,1)][i] = (Q)0;\n+ msg_res_user[2][CB.get_re_user(2,2)][i] = (Q)0;\n+ msg_res_user[3][CB.get_re_user(3,0)][i] = (Q)0;\n+ msg_res_user[3][CB.get_re_user(3,1)][i] = (Q)0;\n+ msg_res_user[3][CB.get_re_user(3,2)][i] = (Q)0;\n+ }\n+\n+ for (auto i = 0; i < CB.get_codebook_size(); i++) // codeword index\n+ for (auto j = 0; j < CB.get_codebook_size(); j++)\n+ for (auto k = 0; k < CB.get_codebook_size(); k++)\n+ for(auto re = 0; re < CB.get_number_of_orthogonal_resources(); re++)\n{\nmsg_res_user[re][CB.get_re_user(re,0)][i] = msg_res_user[re][CB.get_re_user(re,0)][i]\n+ arr_phi[re][i][j][k]\n@@ -293,45 +293,81 @@ void Modem_SCMA<B,R,Q,PSI>\n}\n// user to resource messaging\n- for (auto i = 0 ; i < 4 ; i++)\n- {\n- msg_user_res[0][1][i] = msg_res_user[3][0][i] / (msg_res_user[3][0][0] + msg_res_user[3][0][1] +\n- msg_res_user[3][0][2] + msg_res_user[3][0][3]);\n- msg_user_res[0][3][i] = msg_res_user[1][0][i] / (msg_res_user[1][0][0] + msg_res_user[1][0][1] +\n- msg_res_user[1][0][2] + msg_res_user[1][0][3]);\n- msg_user_res[1][0][i] = msg_res_user[2][1][i] / (msg_res_user[2][1][0] + msg_res_user[2][1][1] +\n- msg_res_user[2][1][2] + msg_res_user[2][1][3]);\n- msg_user_res[1][2][i] = msg_res_user[0][1][i] / (msg_res_user[0][1][0] + msg_res_user[0][1][1] +\n- msg_res_user[0][1][2] + msg_res_user[0][1][3]);\n- msg_user_res[2][0][i] = msg_res_user[1][2][i] / (msg_res_user[1][2][0] + msg_res_user[1][2][1] +\n- msg_res_user[1][2][2] + msg_res_user[1][2][3]);\n- msg_user_res[2][1][i] = msg_res_user[0][2][i] / (msg_res_user[0][2][0] + msg_res_user[0][2][1] +\n- msg_res_user[0][2][2] + msg_res_user[0][2][3]);\n- msg_user_res[3][2][i] = msg_res_user[3][3][i] / (msg_res_user[3][3][0] + msg_res_user[3][3][1] +\n- msg_res_user[3][3][2] + msg_res_user[3][3][3]);\n- msg_user_res[3][3][i] = msg_res_user[2][3][i] / (msg_res_user[2][3][0] + msg_res_user[2][3][1] +\n- msg_res_user[2][3][2] + msg_res_user[2][3][3]);\n- msg_user_res[4][0][i] = msg_res_user[3][4][i] / (msg_res_user[3][4][0] + msg_res_user[3][4][1] +\n- msg_res_user[3][4][2] + msg_res_user[3][4][3]);\n- msg_user_res[4][3][i] = msg_res_user[0][4][i] / (msg_res_user[0][4][0] + msg_res_user[0][4][1] +\n- msg_res_user[0][4][2] + msg_res_user[0][4][3]);\n- msg_user_res[5][1][i] = msg_res_user[2][5][i] / (msg_res_user[2][5][0] + msg_res_user[2][5][1] +\n- msg_res_user[2][5][2] + msg_res_user[2][5][3]);\n- msg_user_res[5][2][i] = msg_res_user[1][5][i] / (msg_res_user[1][5][0] + msg_res_user[1][5][1] +\n- msg_res_user[1][5][2] + msg_res_user[1][5][3]);\n+ for (auto i = 0; i < CB.get_number_of_orthogonal_resources(); i++)\n+ {\n+ msg_user_res[0][CB.get_user_re(0,0)][i] = msg_res_user[CB.get_user_re(0,1)][0][i] /\n+ (msg_res_user[CB.get_user_re(0,1)][0][0] +\n+ msg_res_user[CB.get_user_re(0,1)][0][1] +\n+ msg_res_user[CB.get_user_re(0,1)][0][2] +\n+ msg_res_user[CB.get_user_re(0,1)][0][3]);\n+ msg_user_res[0][CB.get_user_re(0,1)][i] = msg_res_user[CB.get_user_re(0,0)][0][i] /\n+ (msg_res_user[CB.get_user_re(0,0)][0][0] +\n+ msg_res_user[CB.get_user_re(0,0)][0][1] +\n+ msg_res_user[CB.get_user_re(0,0)][0][2] +\n+ msg_res_user[CB.get_user_re(0,0)][0][3]);\n+ msg_user_res[1][CB.get_user_re(1,0)][i] = msg_res_user[CB.get_user_re(1,1)][1][i] /\n+ (msg_res_user[CB.get_user_re(1,1)][1][0] +\n+ msg_res_user[CB.get_user_re(1,1)][1][1] +\n+ msg_res_user[CB.get_user_re(1,1)][1][2] +\n+ msg_res_user[CB.get_user_re(1,1)][1][3]);\n+ msg_user_res[1][CB.get_user_re(1,1)][i] = msg_res_user[CB.get_user_re(1,0)][1][i] /\n+ (msg_res_user[CB.get_user_re(1,0)][1][0] +\n+ msg_res_user[CB.get_user_re(1,0)][1][1] +\n+ msg_res_user[CB.get_user_re(1,0)][1][2] +\n+ msg_res_user[CB.get_user_re(1,0)][1][3]);\n+ msg_user_res[2][CB.get_user_re(2,0)][i] = msg_res_user[CB.get_user_re(2,1)][2][i] /\n+ (msg_res_user[CB.get_user_re(2,1)][2][0] +\n+ msg_res_user[CB.get_user_re(2,1)][2][1] +\n+ msg_res_user[CB.get_user_re(2,1)][2][2] +\n+ msg_res_user[CB.get_user_re(2,1)][2][3]);\n+ msg_user_res[2][CB.get_user_re(2,1)][i] = msg_res_user[CB.get_user_re(2,0)][2][i] /\n+ (msg_res_user[CB.get_user_re(2,0)][2][0] +\n+ msg_res_user[CB.get_user_re(2,0)][2][1] +\n+ msg_res_user[CB.get_user_re(2,0)][2][2] +\n+ msg_res_user[CB.get_user_re(2,0)][2][3]);\n+ msg_user_res[3][CB.get_user_re(3,0)][i] = msg_res_user[CB.get_user_re(3,1)][3][i] /\n+ (msg_res_user[CB.get_user_re(3,1)][3][0] +\n+ msg_res_user[CB.get_user_re(3,1)][3][1] +\n+ msg_res_user[CB.get_user_re(3,1)][3][2] +\n+ msg_res_user[CB.get_user_re(3,1)][3][3]);\n+ msg_user_res[3][CB.get_user_re(3,1)][i] = msg_res_user[CB.get_user_re(3,0)][3][i] /\n+ (msg_res_user[CB.get_user_re(3,0)][3][0] +\n+ msg_res_user[CB.get_user_re(3,0)][3][1] +\n+ msg_res_user[CB.get_user_re(3,0)][3][2] +\n+ msg_res_user[CB.get_user_re(3,0)][3][3]);\n+ msg_user_res[4][CB.get_user_re(4,0)][i] = msg_res_user[CB.get_user_re(4,1)][4][i] /\n+ (msg_res_user[CB.get_user_re(4,1)][4][0] +\n+ msg_res_user[CB.get_user_re(4,1)][4][1] +\n+ msg_res_user[CB.get_user_re(4,1)][4][2] +\n+ msg_res_user[CB.get_user_re(4,1)][4][3]);\n+ msg_user_res[4][CB.get_user_re(4,1)][i] = msg_res_user[CB.get_user_re(4,0)][4][i] /\n+ (msg_res_user[CB.get_user_re(4,0)][4][0] +\n+ msg_res_user[CB.get_user_re(4,0)][4][1] +\n+ msg_res_user[CB.get_user_re(4,0)][4][2] +\n+ msg_res_user[CB.get_user_re(4,0)][4][3]);\n+ msg_user_res[5][CB.get_user_re(5,0)][i] = msg_res_user[CB.get_user_re(5,1)][5][i] /\n+ (msg_res_user[CB.get_user_re(5,1)][5][0] +\n+ msg_res_user[CB.get_user_re(5,1)][5][1] +\n+ msg_res_user[CB.get_user_re(5,1)][5][2] +\n+ msg_res_user[CB.get_user_re(5,1)][5][3]);\n+ msg_user_res[5][CB.get_user_re(5,1)][i] = msg_res_user[CB.get_user_re(5,0)][5][i] /\n+ (msg_res_user[CB.get_user_re(5,0)][5][0] +\n+ msg_res_user[CB.get_user_re(5,0)][5][1] +\n+ msg_res_user[CB.get_user_re(5,0)][5][2] +\n+ msg_res_user[CB.get_user_re(5,0)][5][3]);\n}\n}\n// end of iterations\n// guess at each user\n- for (auto i = 0; i < 4; i++) //codeword index\n- {\n- guess[0][i] = msg_res_user[3][0][i] * msg_res_user[1][0][i];\n- guess[1][i] = msg_res_user[2][1][i] * msg_res_user[0][1][i];\n- guess[2][i] = msg_res_user[0][2][i] * msg_res_user[1][2][i];\n- guess[3][i] = msg_res_user[2][3][i] * msg_res_user[3][3][i];\n- guess[4][i] = msg_res_user[3][4][i] * msg_res_user[0][4][i];\n- guess[5][i] = msg_res_user[1][5][i] * msg_res_user[2][5][i];\n+ for (auto i = 0; i < CB.get_codebook_size(); i++) //codeword index\n+ {\n+ guess[0][i] = msg_res_user[CB.get_user_re(0,0)][0][i] * msg_res_user[CB.get_user_re(0,1)][0][i];\n+ guess[1][i] = msg_res_user[CB.get_user_re(1,0)][1][i] * msg_res_user[CB.get_user_re(1,1)][1][i];\n+ guess[2][i] = msg_res_user[CB.get_user_re(2,0)][2][i] * msg_res_user[CB.get_user_re(2,1)][2][i];\n+ guess[3][i] = msg_res_user[CB.get_user_re(3,0)][3][i] * msg_res_user[CB.get_user_re(3,1)][3][i];\n+ guess[4][i] = msg_res_user[CB.get_user_re(4,0)][4][i] * msg_res_user[CB.get_user_re(4,1)][4][i];\n+ guess[5][i] = msg_res_user[CB.get_user_re(5,0)][5][i] * msg_res_user[CB.get_user_re(5,1)][5][i];\n}\n// LLRs computation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/SCMA/Codebook.hpp",
"new_path": "src/Tools/Code/SCMA/Codebook.hpp",
"diff": "@@ -22,7 +22,8 @@ public:\nint get_number_of_users() const;\nint get_number_of_orthogonal_resources() const;\nint get_codebook_size() const;\n- int get_re_user(int r, int df) const;\n+ int get_re_user(int r, int u) const;\n+ int get_user_re(int u, int r) const;\nprivate:\nstd::vector<std::vector<std::vector<std::complex<R>>>> data;\n@@ -32,6 +33,7 @@ private:\nint codebook_size;\nint re_user[4][3];\n+ int user_re[6][2];\nvoid read_codebook(const std::string& codebook_path);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/SCMA/Codebook.hxx",
"new_path": "src/Tools/Code/SCMA/Codebook.hxx",
"diff": "@@ -103,6 +103,19 @@ void Codebook<R>\n}\n}\n}\n+\n+ for (int u = 0; u < number_of_users; ++u)\n+ {\n+ int idx = 0;\n+ for (int r = 0; r < number_of_orthogonal_resources; ++r)\n+ {\n+ if (F[r][u] == 1)\n+ {\n+ user_re[u][idx] = r;\n+ idx++;\n+ }\n+ }\n+ }\n}\n@@ -135,14 +148,19 @@ inline int Codebook<R>\nreturn codebook_size;\n}\n-\ntemplate <typename R>\ninline int Codebook<R>\n-::get_re_user(int r, int df) const\n+::get_re_user(int r, int u) const\n{\n- return re_user[r][df];\n+ return re_user[r][u];\n}\n+template <typename R>\n+inline int Codebook<R>\n+::get_user_re(int u, int r) const\n+{\n+ return user_re[u][r];\n+}\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add user_re array and small refactor
|
8,490 |
12.10.2018 11:14:24
| -7,200 |
af850462d1dd0f1c3396102e2e7a59494fb06863
|
LDPC BP flooding SPA with intra SIMD from cs0x7f.
|
[
{
"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/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/Flooding/SPA/Decoder_LDPC_BP_flooding_SPA.hpp\"\n#include \"Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.hpp\"\n#include \"Module/Decoder/LDPC/BF/OMWBF/Decoder_LDPC_bit_flipping_OMWBF.hpp\"\n@@ -109,7 +110,7 @@ void Decoder_LDPC::parameters\nargs.add(\n{p+\"-simd\"},\n- tools::Text(tools::Including_set(\"INTER\")),\n+ tools::Text(tools::Including_set(\"INTER\", \"INTRA\")),\n\"the SIMD strategy you want to use.\");\nargs.add(\n@@ -362,8 +363,11 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\nif (this->min == \"MINS\") return new module::Decoder_LDPC_BP_vertical_layered_inter<B,Q,tools::Update_rule_AMS_simd<Q,tools::min_star_i <Q>>>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, tools::Update_rule_AMS_simd<Q,tools::min_star_i <Q>>(), this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n}\n-\n#endif\n+ else if (this->type == \"BP_FLOODING\" && this->simd_strategy == \"INTRA\")\n+ {\n+ if (this->implem == \"SPA\" ) return new module::Decoder_LDPC_BP_flooding_SPA<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ }\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"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": "@@ -43,7 +43,7 @@ protected:\nvoid _decode (const R *Y_N, const int frame_id);\nvoid _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+ virtual void _decode_single_ite ( const std::vector<R> &msg_var_to_chk, std::vector<R> &msg_chk_to_var);\nvoid _compute_post (const R *Y_N, const std::vector<R> &msg_chk_to_var, std::vector<R> &post);\n};\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/SPA/Decoder_LDPC_BP_flooding_SPA.hpp",
"diff": "+#ifndef DECODER_LDPC_BP_FLOODING_SPA_HPP_\n+#define DECODER_LDPC_BP_FLOODING_SPA_HPP_\n+\n+#include \"Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp\"\n+\n+#include \"../Decoder_LDPC_BP_flooding.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int, typename R = float>\n+class Decoder_LDPC_BP_flooding_SPA : public Decoder_LDPC_BP_flooding<B,R,tools::Update_rule_SPA<R>>\n+{\n+protected:\n+ std::vector<R> values;\n+\n+public:\n+ Decoder_LDPC_BP_flooding_SPA(const int K, const int N, const int n_ite,\n+ const tools::Sparse_matrix &H,\n+ const std::vector<uint32_t> &info_bits_pos,\n+ const bool enable_syndrome = true,\n+ const int syndrome_depth = 1,\n+ const int n_frames = 1);\n+ virtual ~Decoder_LDPC_BP_flooding_SPA() = default;\n+\n+protected:\n+ void _decode_single_ite(const std::vector<R> &msg_var_to_chk, std::vector<R> &msg_chk_to_var);\n+};\n+}\n+}\n+\n+#include \"Decoder_LDPC_BP_flooding_SPA.hxx\"\n+\n+#endif /* DECODER_LDPC_BP_FLOODING_SPA_HPP_ */\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/SPA/Decoder_LDPC_BP_flooding_SPA.hxx",
"diff": "+#include <chrono>\n+#include <limits>\n+#include <sstream>\n+#include <mipp.h>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Perf/common/hard_decide.h\"\n+#include \"Tools/Math/utils.h\"\n+\n+#include \"Decoder_LDPC_BP_flooding_SPA.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B, typename R>\n+Decoder_LDPC_BP_flooding_SPA<B,R>\n+::Decoder_LDPC_BP_flooding_SPA(const int K, const int N, const int n_ite,\n+ const tools::Sparse_matrix &_H,\n+ const std::vector<uint32_t> &info_bits_pos,\n+ const bool enable_syndrome,\n+ const int syndrome_depth,\n+ const int n_frames)\n+: Decoder(K, N, n_frames, 1),\n+ Decoder_LDPC_BP_flooding<B,R,tools::Update_rule_SPA<R>>(K, N, n_ite, _H, info_bits_pos,\n+ tools::Update_rule_SPA<R>(_H.get_cols_max_degree()),\n+ enable_syndrome, syndrome_depth, n_frames),\n+ values(_H.get_cols_max_degree())\n+{\n+ const std::string name = \"Decoder_LDPC_BP_flooding_SPA\";\n+ this->set_name(name);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_flooding_SPA<B,R>\n+::_decode_single_ite(const std::vector<R> &msg_var_to_chk, std::vector<R> &msg_chk_to_var)\n+{\n+ const auto n_branches = (int)this->H.get_n_connections();\n+ auto transpose_ptr = this->transpose.data();\n+\n+ mipp::Reg<R> r_tmp;\n+ const mipp::Reg<R> r_1 = (R)1.0;\n+ const auto vec_loop_size = (n_branches / mipp::N<R>()) * mipp::N<R>();\n+ for (auto b = 0; b < vec_loop_size; b += mipp::N<R>())\n+ {\n+ r_tmp = &msg_var_to_chk[b];\n+ // tanh(1/2 * t) = (exp(t) - 1) / (exp(t) + 1)\n+ r_tmp = mipp::exp(r_tmp);\n+ r_tmp = (r_tmp - r_1) / (r_tmp + r_1);\n+ r_tmp.storeu(&msg_chk_to_var[b]);\n+ }\n+ // tail loop to compute the remaining elements\n+ for (auto b = vec_loop_size; b < n_branches; b++)\n+ msg_chk_to_var[b] = (R) std::tanh((R)0.5 * msg_var_to_chk[b]);\n+\n+ // flooding scheduling\n+ const auto n_chk_nodes = (int)this->H.get_n_cols();\n+ for (auto c = 0; c < n_chk_nodes; c++)\n+ {\n+ const auto chk_degree = (int)this->H.get_col_to_rows()[c].size();\n+\n+ auto prod = (R)1;\n+ for (auto v = 0; v < chk_degree; v++)\n+ {\n+ this->values[v] = msg_chk_to_var[transpose_ptr[v]];\n+ prod *= this->values[v];\n+ }\n+\n+ for (auto v = 0; v < chk_degree; v++)\n+ {\n+ auto val = prod / this->values[v];\n+ val = (std::abs(val) < (R)1.0) ? val : ((R)1.0 - std::numeric_limits<R>::epsilon()) * (val > 0 ? 1 : -1);\n+ msg_chk_to_var[transpose_ptr[v]] = (R)val;\n+ }\n+\n+ transpose_ptr += chk_degree;\n+ }\n+\n+ for (auto b = 0; b < vec_loop_size; b += mipp::N<R>())\n+ {\n+ r_tmp = &msg_chk_to_var[b];\n+ // 2 * atanh(t) = log((1 + t) / (1 - t)\n+ r_tmp = mipp::log((r_1 + r_tmp) / (r_1 - r_tmp));\n+ r_tmp.storeu(&msg_chk_to_var[b]);\n+ }\n+ // tail loop to compute the remaining elements\n+ for (auto b = vec_loop_size; b < n_branches; b++)\n+ msg_chk_to_var[b] = (R)2.0 * std::atanh(msg_chk_to_var[b]);\n+}\n+}\n+}\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
LDPC BP flooding SPA with intra SIMD from cs0x7f.
|
8,490 |
19.10.2018 17:15:47
| -7,200 |
d4abe8a8d0ed5849aa99c9a2ef6c073085d6b4b0
|
Add a more generic encoder for polar code: it is capable to encode all powers and not only powers of two.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "@@ -52,7 +52,8 @@ module::Encoder_polar_MK<B>* Encoder_polar_MK::parameters\n{\nif (this->type == \"POLAR\" && !this->systematic)\n{\n- return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, this->n_frames);\n+ return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, {{1,0},{1,1}}, this->n_frames);\n+ // return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, {{1,1,1},{1,0,1},{0,1,1}}, this->n_frames);\n}\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Tools/Code/Polar_MK/Frozenbits_generator_MK.hpp",
"new_path": "src/Factory/Tools/Code/Polar_MK/Frozenbits_generator_MK.hpp",
"diff": "@@ -23,7 +23,7 @@ struct Frozenbits_generator_MK : public Factory\n// optional parameters\nstd::string type = \"FILE\";\n- std::string path_fb = \"../conf/cde/awgn_polar_mk_codes/\";\n+ std::string path_fb = \"../conf/cde/awgn_polar_codes/TV\";\nfloat sigma = -1.f;\n// ---------------------------------------------------------------------------------------------------- METHODS\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Math/utils.h\"\n#include \"Encoder_polar_MK.hpp\"\n+using namespace aff3ct;\nusing namespace aff3ct::module;\n+// DEBUG\n+template <typename T = int32_t>\n+void display_matrix(const std::vector<std::vector<T>>& M)\n+{\n+ for (auto row = 0; row < (int)M.size(); row++)\n+ {\n+ for (auto col = 0; col < (int)M[0].size(); col++)\n+ {\n+ std::cout << M[row][col] << \"\\t\";\n+ }\n+ std::cout << std::endl;\n+ }\n+}\n+\n+template <typename T = int32_t>\n+void kronecker_product(const std::vector<std::vector<T>>& A,\n+ const std::vector<std::vector<T>>& B,\n+ std::vector<std::vector<T>>& C)\n+{\n+ for (auto row_A = 0; row_A < (int)A.size(); row_A++)\n+ for (auto col_A = 0; col_A < (int)A[0].size(); col_A++)\n+ for (auto row_B = 0; row_B < (int)B.size(); row_B++)\n+ for (auto col_B = 0; col_B < (int)B[0].size(); col_B++)\n+ C[row_A * B.size() + row_B][col_A * B[0].size() + col_B] = A[row_A][col_A] * B[row_B][col_B];\n+}\n+\n+template <typename T = int32_t>\n+std::vector<std::vector<T>> kronecker_product(const std::vector<std::vector<T>>& A,\n+ const std::vector<std::vector<T>>& B)\n+{\n+ // verifications --------------------------------------------------------------------------------------------------\n+ if (A.size() == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'A.size()' should be higher than 0 ('A.size()' = \" << A.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (B.size() == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'B.size()' should be higher than 0 ('B.size()' = \" << B.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ for (auto l = 0; l < (int)A.size(); l++)\n+ {\n+ if (A[l].size() != A.size())\n+ {\n+ std::stringstream message;\n+ message << \"'A[l].size()' has to be equal to 'A.size()' ('l' = \" << l\n+ << \", 'A[l].size()' = \" << A[l].size()\n+ << \", 'A.size()' = \" << A.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+\n+ for (auto l = 0; l < (int)B.size(); l++)\n+ {\n+ if (B[l].size() != B.size())\n+ {\n+ std::stringstream message;\n+ message << \"'B[l].size()' has to be equal to 'B.size()' ('l' = \" << l\n+ << \", 'B[l].size()' = \" << B[l].size()\n+ << \", 'B.size()' = \" << B.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ // ----------------------------------------------------------------------------------------------------------------\n+\n+ std::vector<std::vector<T>> C(A.size() * B.size(), std::vector<T>(A[0].size() * B[0].size()));\n+ kronecker_product(A, B, C);\n+ return C;\n+}\n+\ntemplate <typename B>\nEncoder_polar_MK<B>\n-::Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits, const int n_frames)\n-: Encoder<B>(K, N, n_frames), m((int)std::log2(N)), frozen_bits(frozen_bits), X_N_tmp(this->N)\n+::Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n+ const std::vector<std::vector<bool>>& kernel_matrix, const int n_frames)\n+: Encoder<B>(K, N, n_frames),\n+ b(kernel_matrix.size()),\n+ m((int)(std::log(N)/std::log(b))),\n+ frozen_bits(frozen_bits),\n+ kernel_matrix(kernel_matrix),\n+ X_N_tmp(this->N),\n+ tmp1(this->N),\n+ tmp2(this->N),\n+ Ke(kernel_matrix.size() * kernel_matrix.size())\n{\nconst std::string name = \"Encoder_polar_MK\";\nthis->set_name(name);\n@@ -34,66 +120,153 @@ Encoder_polar_MK<B>\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- this->notify_frozenbits_update();\n+ if (!tools::is_power((int)kernel_matrix.size(), N))\n+ {\n+ std::stringstream message;\n+ message << \"'kernel_matrix.size()' has to be a power of 'N' ('kernel_matrix.size()' = \" << kernel_matrix.size()\n+ << \", 'N' = \" << N << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n-template <typename B>\n-void Encoder_polar_MK<B>\n-::_encode(const B *U_K, B *X_N, const int frame_id)\n+ for (auto l = 0; l < (int)kernel_matrix.size(); l++)\n+ {\n+ if (kernel_matrix[l].size() != kernel_matrix.size())\n+ {\n+ std::stringstream message;\n+ message << \"'kernel_matrix[l].size()' has to be equal to 'kernel_matrix.size()' ('l' = \" << l\n+ << \", 'kernel_matrix[l].size()' = \" << kernel_matrix[l].size()\n+ << \", 'kernel_matrix.size()' = \" << kernel_matrix.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+\n+ // std::cout << \"kernel_matrix: \" << std::endl;\n+ // display_matrix(this->kernel_matrix);\n+ // std::cout << std::endl;\n+\n+ // generate the \"G\" matrix from the \"kernel_matrix\"\n+ this->G = this->kernel_matrix;\n+ for (auto mm = 0; mm < m-1; mm++)\n{\n- this->convert(U_K, X_N);\n- this->light_encode(X_N);\n+ this->G = kronecker_product<bool>(this->G, this->kernel_matrix);\n+ // if (mm < 3)\n+ // {\n+ // std::cout << \"G: \" << std::endl;\n+ // display_matrix(this->G);\n+ // std::cout << std::endl;\n+ // }\n+ }\n+\n+ this->G_trans.resize(this->G[0].size(), std::vector<int8_t>(this->G.size()));\n+ for (auto i = 0; i < this->G[0].size(); i++)\n+ for (auto j = 0; j < this->G.size(); j++)\n+ this->G_trans[i][j] = (int8_t)this->G[j][i];\n+\n+ // for (auto i = 0; i < (int)this->kernel_matrix.size(); i++)\n+ // for (auto j = 0; j < (int)this->kernel_matrix.size(); j++)\n+ // this->K[i * (int)this->kernel_matrix.size() +j] = (int8_t)this->kernel_matrix[j][i];\n+\n+ this->notify_frozenbits_update();\n}\ntemplate <typename B>\nvoid Encoder_polar_MK<B>\n-::light_encode(B *bits)\n+::_encode(const B *U_K, B *X_N, const int frame_id)\n{\n- for (auto k = (this->N >> 1); k > 0; k >>= 1)\n- for (auto j = 0; j < this->N; j += 2 * k)\n- for (auto i = 0; i < k; i++)\n- bits[j + i] = bits[j + i] ^ bits[k + j + i];\n+ this->convert(U_K, this->tmp1.data());\n+ this->light_encode(this->tmp1.data(), this->tmp2.data());\n+\n+ for (auto n = 0; n < this->N; n++)\n+ X_N[n] = (int8_t)this->tmp2[n];\n}\n+// void small_product(const int8_t *u, const int8_t *Ke, int8_t *x, const int size)\n+// {\n+// for (auto i = 0; i < size; i++)\n+// {\n+// const auto stride = i * size;\n+// auto sum = 0;\n+// for (auto j = 0; j < size; j++)\n+// sum += u[j] & Ke[stride +j];\n+// x[i] = sum & (int8_t)1;\n+// }\n+// }\n+\ntemplate <typename B>\nvoid Encoder_polar_MK<B>\n-::convert(const B *U_K, B *U_N)\n+::light_encode(const int8_t *in, int8_t *out)\n{\n- if (U_K == U_N)\n+ for (auto i = 0; i < this->N; i++)\n{\n- std::vector<B> U_K_tmp(this->K);\n- std::copy(U_K, U_K + this->K, U_K_tmp.begin());\n+ auto sum = 0;\n+ for (auto j = 0; j < this->N; j++)\n+ sum += in[j] & this->G_trans[i][j];\n+ out[i] = sum & (B)1;\n+ }\n- auto j = 0;\n- for (unsigned i = 0; i < frozen_bits.size(); i++)\n- U_N[i] = (frozen_bits[i]) ? (B)0 : U_K_tmp[j++];\n+ // const int n_kernels_per_stage = this->N / (int)this->Ke.size();\n+ // std::vector<int8_t> u(this->Ke.size());\n+ // std::vector<int8_t> x(this->Ke.size());\n+ // for (auto s = 0; s < this->m; s++)\n+ // {\n+ // for (auto k = 0; k < n_kernels_per_stage; k++)\n+ // {\n+ // for (auto i = 0; i < (int)this->Ke.size(); i++)\n+ // u[i] = in[k * (int)this->Ke.size() +i];\n+\n+ // small_product(u, this->Ke.data(), x, (int)this->Ke.size());\n+\n+ // for (auto i = 0; i < (int)this->Ke.size(); i++)\n+ // u[i] = in[k * (int)this->Ke.size() +i];\n+ // }\n+ // }\n+\n+ // for (auto k = (this->N >> 1); k > 0; k >>= 1)\n+ // for (auto j = 0; j < this->N; j += 2 * k)\n+ // for (auto i = 0; i < k; i++)\n+ // bits[j + i] = bits[j + i] ^ bits[k + j + i];\n}\n- else\n+\n+// template <typename B>\n+// void Encoder_polar_MK<B>\n+// ::light_encode_fast(const B *in, B *out)\n+// {\n+// for (auto i = 0; i < this->N; i++)\n+// {\n+// auto sum = 0;\n+// for (auto j = 0; j < this->N; j++)\n+// sum += in[j] & this->G_trans[i][j];\n+// out[i] = sum & (B)1;\n+// }\n+// }\n+\n+template <typename B>\n+void Encoder_polar_MK<B>\n+::convert(const B *U_K, int8_t *U_N)\n{\nauto j = 0;\nfor (unsigned i = 0; i < frozen_bits.size(); i++)\n- U_N[i] = (frozen_bits[i]) ? (B)0 : U_K[j++];\n- }\n+ U_N[i] = (frozen_bits[i]) ? (int8_t)0 : (int8_t)U_K[j++];\n}\n-template <typename B>\n-bool Encoder_polar_MK<B>\n-::is_codeword(const B *X_N)\n-{\n- std::copy(X_N, X_N + this->N, this->X_N_tmp.data());\n+// template <typename B>\n+// bool Encoder_polar_MK<B>\n+// ::is_codeword(const B *X_N)\n+// {\n+// std::copy(X_N, X_N + this->N, this->X_N_tmp.data());\n- for (auto k = (this->N >> 1); k > 0; k >>= 1)\n- for (auto j = 0; j < this->N; j += 2 * k)\n- {\n- for (auto i = 0; i < k; i++)\n- this->X_N_tmp[j + i] = this->X_N_tmp[j + i] ^ this->X_N_tmp[k + j + i];\n+// for (auto k = (this->N >> 1); k > 0; k >>= 1)\n+// for (auto j = 0; j < this->N; j += 2 * k)\n+// {\n+// for (auto i = 0; i < k; i++)\n+// this->X_N_tmp[j + i] = this->X_N_tmp[j + i] ^ this->X_N_tmp[k + j + i];\n- if (this->frozen_bits[j + k -1] && this->X_N_tmp[j + k -1])\n- return false;\n- }\n+// if (this->frozen_bits[j + k -1] && this->X_N_tmp[j + k -1])\n+// return false;\n+// }\n- return true;\n-}\n+// return true;\n+// }\ntemplate <typename B>\nvoid Encoder_polar_MK<B>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"diff": "#include <vector>\n#include \"Tools/Code/Polar/Frozenbits_notifier.hpp\"\n+#include \"Tools/Algo/Matrix/Full_matrix/Full_matrix.hpp\"\n#include \"../Encoder.hpp\"\n@@ -15,23 +16,30 @@ template <typename B = int>\nclass Encoder_polar_MK : public Encoder<B>, public tools::Frozenbits_notifier\n{\nprotected:\n- const int m; // log_2 of code length\n+ const int b; // base power\n+ const int m; // log_b of code length\nconst std::vector<bool>& frozen_bits; // true means frozen, false means set to 0/1\n+ const std::vector<std::vector<bool>> kernel_matrix;\nstd::vector<B> X_N_tmp;\n+ std::vector<std::vector<bool>> G;\n+ std::vector<std::vector<int8_t>> G_trans;\n+ std::vector<int8_t> tmp1;\n+ std::vector<int8_t> tmp2;\n+ std::vector<int8_t> Ke;\npublic:\n- Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits, const int n_frames = 1);\n+ Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n+ const std::vector<std::vector<bool>>& kernel_matrix = {{1,0},{1,1}}, const int n_frames = 1);\nvirtual ~Encoder_polar_MK() = default;\n- void light_encode(B *bits);\n-\n- bool is_codeword(const B *X_N);\n+ // bool is_codeword(const B *X_N);\nvirtual void notify_frozenbits_update();\nprotected:\nvirtual void _encode(const B *U_K, B *X_N, const int frame_id);\n- void convert(const B *U_K, B *U_N);\n+ void convert(const B *U_K, int8_t *U_N);\n+ void light_encode(const int8_t *in, int8_t *out);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/utils.h",
"new_path": "src/Tools/Math/utils.h",
"diff": "@@ -93,6 +93,23 @@ inline T next_power_of_2(T x)\nreturn n;\n}\n+/* Returns 'true' if 'y' is a power of 'x' */\n+template <typename T>\n+bool is_power(T x, T y)\n+{\n+ // The only power of 1 is 1 itself\n+ if (x == 1)\n+ return (y == 1);\n+\n+ // Repeatedly comput power of x\n+ T pow = 1;\n+ while (pow < y)\n+ pow *= x;\n+\n+ // Check if power of x becomes y\n+ return (pow == y);\n+}\n+\ntemplate <typename T>\nT greatest_common_divisor(T a, T b)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a more generic encoder for polar code: it is capable to encode all powers and not only powers of two.
|
8,490 |
23.10.2018 15:25:41
| -7,200 |
f680cf1a21037d4cc0abc0b30365dc44c54e2e3c
|
Speedup the POLAR_MK encoder.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "@@ -90,14 +90,13 @@ Encoder_polar_MK<B>\n::Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\nconst std::vector<std::vector<bool>>& kernel_matrix, const int n_frames)\n: Encoder<B>(K, N, n_frames),\n- b(kernel_matrix.size()),\n- m((int)(std::log(N)/std::log(b))),\n+ bp(kernel_matrix.size()),\n+ m((int)(std::log(N)/std::log(bp))),\nfrozen_bits(frozen_bits),\nkernel_matrix(kernel_matrix),\nX_N_tmp(this->N),\n- tmp1(this->N),\n- tmp2(this->N),\n- Ke(kernel_matrix.size() * kernel_matrix.size())\n+ Ke(kernel_matrix.size() * kernel_matrix.size()),\n+ idx(kernel_matrix.size())\n{\nconst std::string name = \"Encoder_polar_MK\";\nthis->set_name(name);\n@@ -140,31 +139,9 @@ Encoder_polar_MK<B>\n}\n}\n- // std::cout << \"kernel_matrix: \" << std::endl;\n- // display_matrix(this->kernel_matrix);\n- // std::cout << std::endl;\n-\n- // generate the \"G\" matrix from the \"kernel_matrix\"\n- this->G = this->kernel_matrix;\n- for (auto mm = 0; mm < m-1; mm++)\n- {\n- this->G = kronecker_product<bool>(this->G, this->kernel_matrix);\n- // if (mm < 3)\n- // {\n- // std::cout << \"G: \" << std::endl;\n- // display_matrix(this->G);\n- // std::cout << std::endl;\n- // }\n- }\n-\n- this->G_trans.resize(this->G[0].size(), std::vector<int8_t>(this->G.size()));\n- for (auto i = 0; i < this->G[0].size(); i++)\n- for (auto j = 0; j < this->G.size(); j++)\n- this->G_trans[i][j] = (int8_t)this->G[j][i];\n-\n- // for (auto i = 0; i < (int)this->kernel_matrix.size(); i++)\n- // for (auto j = 0; j < (int)this->kernel_matrix.size(); j++)\n- // this->K[i * (int)this->kernel_matrix.size() +j] = (int8_t)this->kernel_matrix[j][i];\n+ for (auto i = 0; i < (int)this->kernel_matrix.size(); i++)\n+ for (auto j = 0; j < (int)this->kernel_matrix.size(); j++)\n+ this->Ke[i * (int)this->kernel_matrix.size() +j] = (int8_t)this->kernel_matrix[j][i];\nthis->notify_frozenbits_update();\n}\n@@ -173,80 +150,68 @@ template <typename B>\nvoid Encoder_polar_MK<B>\n::_encode(const B *U_K, B *X_N, const int frame_id)\n{\n- this->convert(U_K, this->tmp1.data());\n- this->light_encode(this->tmp1.data(), this->tmp2.data());\n-\n- for (auto n = 0; n < this->N; n++)\n- X_N[n] = (int8_t)this->tmp2[n];\n+ this->convert(U_K, X_N);\n+ this->light_encode(X_N);\n}\n-// void small_product(const int8_t *u, const int8_t *Ke, int8_t *x, const int size)\n-// {\n-// for (auto i = 0; i < size; i++)\n-// {\n-// const auto stride = i * size;\n-// auto sum = 0;\n-// for (auto j = 0; j < size; j++)\n-// sum += u[j] & Ke[stride +j];\n-// x[i] = sum & (int8_t)1;\n-// }\n-// }\n-\ntemplate <typename B>\n-void Encoder_polar_MK<B>\n-::light_encode(const int8_t *in, int8_t *out)\n+void kernel(const B *u, const uint32_t *idx, const int8_t *Ke, B *x, const int size)\n{\n- for (auto i = 0; i < this->N; i++)\n+ for (auto i = 0; i < size; i++)\n{\n+ const auto stride = i * size;\nauto sum = 0;\n- for (auto j = 0; j < this->N; j++)\n- sum += in[j] & this->G_trans[i][j];\n- out[i] = sum & (B)1;\n+ for (auto j = 0; j < size; j++)\n+ sum += u[idx[j]] & Ke[stride +j];\n+ x[idx[i]] = sum & (int8_t)1;\n+ }\n}\n- // const int n_kernels_per_stage = this->N / (int)this->Ke.size();\n- // std::vector<int8_t> u(this->Ke.size());\n- // std::vector<int8_t> x(this->Ke.size());\n- // for (auto s = 0; s < this->m; s++)\n- // {\n- // for (auto k = 0; k < n_kernels_per_stage; k++)\n- // {\n- // for (auto i = 0; i < (int)this->Ke.size(); i++)\n- // u[i] = in[k * (int)this->Ke.size() +i];\n+template <typename B>\n+void Encoder_polar_MK<B>\n+::light_encode(B *X_N)\n+{\n+ const auto kernel_size = (int)this->kernel_matrix.size();\n- // small_product(u, this->Ke.data(), x, (int)this->Ke.size());\n+ for (auto s = 0; s < this->m; s++)\n+ {\n+ const auto block_size = (int)std::pow((float)kernel_size, s);\n+ const auto n_blocks = this->N / (block_size * kernel_size);\n- // for (auto i = 0; i < (int)this->Ke.size(); i++)\n- // u[i] = in[k * (int)this->Ke.size() +i];\n- // }\n- // }\n+ for (auto b = 0; b < n_blocks; b++)\n+ {\n+ const auto n_kernels = block_size;\n+ for (auto k = 0; k < n_kernels; k++)\n+ {\n+ for (auto i = 0; i < kernel_size; i++)\n+ this->idx[i] = (uint32_t)(b * block_size * kernel_size + block_size * i +k);\n- // for (auto k = (this->N >> 1); k > 0; k >>= 1)\n- // for (auto j = 0; j < this->N; j += 2 * k)\n- // for (auto i = 0; i < k; i++)\n- // bits[j + i] = bits[j + i] ^ bits[k + j + i];\n+ const auto off_out = b * block_size * kernel_size + k * kernel_size;\n+ kernel(X_N, this->idx.data(), this->Ke.data(), X_N, kernel_size);\n+ }\n+ }\n+ }\n}\n-\n-// template <typename B>\n-// void Encoder_polar_MK<B>\n-// ::light_encode_fast(const B *in, B *out)\n-// {\n-// for (auto i = 0; i < this->N; i++)\n-// {\n-// auto sum = 0;\n-// for (auto j = 0; j < this->N; j++)\n-// sum += in[j] & this->G_trans[i][j];\n-// out[i] = sum & (B)1;\n-// }\n-// }\ntemplate <typename B>\nvoid Encoder_polar_MK<B>\n-::convert(const B *U_K, int8_t *U_N)\n+::convert(const B *U_K, B *U_N)\n+{\n+ if (U_K == U_N)\n{\n+ std::vector<B> U_K_tmp(this->K);\n+ std::copy(U_K, U_K + this->K, U_K_tmp.begin());\n+\nauto j = 0;\nfor (unsigned i = 0; i < frozen_bits.size(); i++)\n- U_N[i] = (frozen_bits[i]) ? (int8_t)0 : (int8_t)U_K[j++];\n+ U_N[i] = (frozen_bits[i]) ? (B)0 : U_K_tmp[j++];\n+ }\n+ else\n+ {\n+ auto j = 0;\n+ for (unsigned i = 0; i < frozen_bits.size(); i++)\n+ U_N[i] = (frozen_bits[i]) ? (B)0 : U_K[j++];\n+ }\n}\n// template <typename B>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"diff": "@@ -16,16 +16,13 @@ template <typename B = int>\nclass Encoder_polar_MK : public Encoder<B>, public tools::Frozenbits_notifier\n{\nprotected:\n- const int b; // base power\n+ const int bp; // base power\nconst int m; // log_b of code length\nconst std::vector<bool>& frozen_bits; // true means frozen, false means set to 0/1\nconst std::vector<std::vector<bool>> kernel_matrix;\nstd::vector<B> X_N_tmp;\n- std::vector<std::vector<bool>> G;\n- std::vector<std::vector<int8_t>> G_trans;\n- std::vector<int8_t> tmp1;\n- std::vector<int8_t> tmp2;\nstd::vector<int8_t> Ke;\n+ std::vector<uint32_t> idx;\npublic:\nEncoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n@@ -38,8 +35,8 @@ public:\nprotected:\nvirtual void _encode(const B *U_K, B *X_N, const int frame_id);\n- void convert(const B *U_K, int8_t *U_N);\n- void light_encode(const int8_t *in, int8_t *out);\n+ void convert(const B *U_K, B *U_N);\n+ void light_encode(B *X_N);\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Speedup the POLAR_MK encoder.
|
8,490 |
24.10.2018 11:07:48
| -7,200 |
9f22f8fb6ad1ebaf2c6fe86df4b3f6b4ffef7215
|
Fix errors management in frozen bit generator from file.
|
[
{
"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": "@@ -44,16 +44,20 @@ bool Frozenbits_generator_file\ntry\n{\n- if (std::stoi(trash) != this->N)\n+ std::stoi(trash);\n+ }\n+ catch(std::exception&)\n{\nstd::stringstream message;\n- message << \"'trash' has to be equal to 'N' ('trash' = \" << trash << \", 'N' = \" << this->N << \").\";\n+ message << \"'std::stoi' did not work, something went wrong when reading the file.\";\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- }\n- catch(std::exception&)\n+\n+ if (std::stoi(trash) != this->N)\n{\n- return false;\n+ std::stringstream message;\n+ message << \"'trash' has to be equal to 'N' ('trash' = \" << trash << \", 'N' = \" << this->N << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\nin_code >> trash; // type\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix errors management in frozen bit generator from file.
|
8,490 |
24.10.2018 14:38:44
| -7,200 |
6568e73b48c7599de65aec60eae39da41985b0a3
|
Enable generics decoders.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/Polar_MK/Decoder_polar_MK.cpp",
"new_path": "src/Factory/Module/Decoder/Polar_MK/Decoder_polar_MK.cpp",
"diff": "@@ -60,6 +60,12 @@ template <typename B, typename Q>\nmodule::Decoder_SIHO<B,Q>* Decoder_polar_MK::parameters\n::build(const std::vector<bool> &frozen_bits, module::CRC<B> *crc,\nconst std::unique_ptr<module::Encoder<B>>& encoder) const\n+{\n+ try\n+ {\n+ return Decoder::parameters::build<B,Q>(encoder);\n+ }\n+ catch (tools::cannot_allocate const&)\n{\nif (!this->systematic) // non-systematic encoding\n{\n@@ -71,6 +77,7 @@ module::Decoder_SIHO<B,Q>* Decoder_polar_MK::parameters\n}\n}\n}\n+ }\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Enable generics decoders.
|
8,490 |
24.10.2018 14:39:33
| -7,200 |
4c580699e43263fad6627aaa112cd8073dd8c108
|
Fix the POLAR_MK encoder for bases higher than 2.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::factory;\n-const std::string aff3ct::factory::Encoder_polar_MK_name = \"Encoder Polar\";\n+const std::string aff3ct::factory::Encoder_polar_MK_name = \"Encoder Polar MK\";\nconst std::string aff3ct::factory::Encoder_polar_MK_prefix = \"enc\";\nEncoder_polar_MK::parameters\n::parameters(const std::string &prefix)\n: Encoder::parameters(Encoder_polar_MK_name, prefix)\n{\n- this->type = \"POLAR\";\n+ this->type = \"POLAR_MK\";\nthis->systematic = false;\n}\n@@ -31,7 +31,7 @@ void Encoder_polar_MK::parameters\nauto p = this->get_prefix();\n- tools::add_options(args.at({p+\"-type\"}), 0, \"POLAR\");\n+ tools::add_options(args.at({p+\"-type\"}), 0, \"POLAR_MK\");\n}\nvoid Encoder_polar_MK::parameters\n@@ -50,10 +50,11 @@ template <typename B>\nmodule::Encoder_polar_MK<B>* Encoder_polar_MK::parameters\n::build(const std::vector<bool> &frozen_bits) const\n{\n- if (this->type == \"POLAR\" && !this->systematic)\n+ if (this->type == \"POLAR_MK\" && !this->systematic)\n{\nreturn new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, {{1,0},{1,1}}, this->n_frames);\n// return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, {{1,1,1},{1,0,1},{0,1,1}}, this->n_frames);\n+ // return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,1,1}}, this->n_frames);\n}\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::module;\n-// DEBUG\n+// // DEBUG\n+// template <typename T = int32_t>\n+// void display_matrix(const std::vector<std::vector<T>>& M)\n+// {\n+// for (auto row = 0; row < (int)M.size(); row++)\n+// {\n+// for (auto col = 0; col < (int)M[0].size(); col++)\n+// {\n+// std::cout << M[row][col] << \"\\t\";\n+// }\n+// std::cout << std::endl;\n+// }\n+// }\n+\n+// template <typename T = int32_t>\n+// void kronecker_product(const std::vector<std::vector<T>>& A,\n+// const std::vector<std::vector<T>>& B,\n+// std::vector<std::vector<T>>& C)\n+// {\n+// for (auto row_A = 0; row_A < (int)A.size(); row_A++)\n+// for (auto col_A = 0; col_A < (int)A[0].size(); col_A++)\n+// for (auto row_B = 0; row_B < (int)B.size(); row_B++)\n+// for (auto col_B = 0; col_B < (int)B[0].size(); col_B++)\n+// C[row_A * B.size() + row_B][col_A * B[0].size() + col_B] = A[row_A][col_A] * B[row_B][col_B];\n+// }\n+\n+// Function to get cofactor of mat[p][q] in tmp[][]. n is current\n+// dimension of mat[][]\ntemplate <typename T = int32_t>\n-void display_matrix(const std::vector<std::vector<T>>& M)\n+void get_cofactor(const std::vector<std::vector<T>> &mat, std::vector<std::vector<T>> &tmp,\n+ const int p, const int q, const int n)\n+{\n+ int i = 0, j = 0;\n+\n+ // Looping for each element of the matrix\n+ for (int row = 0; row < n; row++)\n{\n- for (auto row = 0; row < (int)M.size(); row++)\n+ for (int col = 0; col < n; col++)\n{\n- for (auto col = 0; col < (int)M[0].size(); col++)\n+ // Copying into temporary matrix only those element\n+ // which are not in given row and column\n+ if (row != p && col != q)\n+ {\n+ tmp[i][j++] = mat[row][col];\n+\n+ // Row is filled, so increase row index and\n+ // reset col index\n+ if (j == n - 1)\n{\n- std::cout << M[row][col] << \"\\t\";\n+ j = 0;\n+ i++;\n+ }\n+ }\n}\n- std::cout << std::endl;\n}\n}\n+/* Recursive function for finding determinant of matrix.\n+n is current dimension of mat[][]. */\ntemplate <typename T = int32_t>\n-void kronecker_product(const std::vector<std::vector<T>>& A,\n- const std::vector<std::vector<T>>& B,\n- std::vector<std::vector<T>>& C)\n+int determinant_of_matrix(const std::vector<std::vector<T>> &mat, const int n)\n{\n- for (auto row_A = 0; row_A < (int)A.size(); row_A++)\n- for (auto col_A = 0; col_A < (int)A[0].size(); col_A++)\n- for (auto row_B = 0; row_B < (int)B.size(); row_B++)\n- for (auto col_B = 0; col_B < (int)B[0].size(); col_B++)\n- C[row_A * B.size() + row_B][col_A * B[0].size() + col_B] = A[row_A][col_A] * B[row_B][col_B];\n+ int D = 0; // Initialize result\n+\n+ // Base case : if matrix contains single element\n+ if (n == 1)\n+ return mat[0][0];\n+\n+ std::vector<std::vector<T>> tmp(mat.size(), std::vector<T>(mat.size())); // To store cofactors\n+\n+ int sign = 1; // To store sign multiplier\n+\n+ // Iterate for each element of first row\n+ for (int f = 0; f < n; f++)\n+ {\n+ // Getting Cofactor of mat[0][f]\n+ get_cofactor(mat, tmp, 0, f, n);\n+ D += sign * mat[0][f] * determinant_of_matrix(tmp, n - 1);\n+\n+ // terms are to be added with alternate sign\n+ sign = -sign;\n+ }\n+\n+ return D;\n+}\n+\n+template <typename T>\n+bool is_invertible(const std::vector<std::vector<T>> &mat)\n+{\n+ return determinant_of_matrix(mat, (int)mat.size()) != 0;\n}\ntemplate <typename T = int32_t>\n@@ -94,9 +160,10 @@ Encoder_polar_MK<B>\nm((int)(std::log(N)/std::log(bp))),\nfrozen_bits(frozen_bits),\nkernel_matrix(kernel_matrix),\n- X_N_tmp(this->N),\n+ // X_N_tmp(this->N),\nKe(kernel_matrix.size() * kernel_matrix.size()),\n- idx(kernel_matrix.size())\n+ idx(kernel_matrix.size()),\n+ u(kernel_matrix.size())\n{\nconst std::string name = \"Encoder_polar_MK\";\nthis->set_name(name);\n@@ -127,6 +194,13 @@ Encoder_polar_MK<B>\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n+ if (!is_invertible<bool>(kernel_matrix))\n+ {\n+ std::stringstream message;\n+ message << \"'kernel_matrix' has to be invertible.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nfor (auto l = 0; l < (int)kernel_matrix.size(); l++)\n{\nif (kernel_matrix[l].size() != kernel_matrix.size())\n@@ -155,14 +229,14 @@ void Encoder_polar_MK<B>\n}\ntemplate <typename B>\n-void kernel(const B *u, const uint32_t *idx, const int8_t *Ke, B *x, const int size)\n+void polar_kernel(const B *u, const uint32_t *idx, const int8_t *Ke, B *x, const int size)\n{\nfor (auto i = 0; i < size; i++)\n{\nconst auto stride = i * size;\nauto sum = 0;\nfor (auto j = 0; j < size; j++)\n- sum += u[idx[j]] & Ke[stride +j];\n+ sum += u[j] & Ke[stride +j];\nx[idx[i]] = sum & (int8_t)1;\n}\n}\n@@ -172,7 +246,6 @@ void Encoder_polar_MK<B>\n::light_encode(B *X_N)\n{\nconst auto kernel_size = (int)this->kernel_matrix.size();\n-\nfor (auto s = 0; s < this->m; s++)\n{\nconst auto block_size = (int)std::pow((float)kernel_size, s);\n@@ -184,10 +257,13 @@ void Encoder_polar_MK<B>\nfor (auto k = 0; k < n_kernels; k++)\n{\nfor (auto i = 0; i < kernel_size; i++)\n+ {\nthis->idx[i] = (uint32_t)(b * block_size * kernel_size + block_size * i +k);\n+ this->u[i] = X_N[this->idx[i]];\n+ }\nconst auto off_out = b * block_size * kernel_size + k * kernel_size;\n- kernel(X_N, this->idx.data(), this->Ke.data(), X_N, kernel_size);\n+ polar_kernel(this->u.data(), this->idx.data(), this->Ke.data(), X_N, kernel_size);\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"diff": "@@ -20,9 +20,10 @@ protected:\nconst int m; // log_b of code length\nconst std::vector<bool>& frozen_bits; // true means frozen, false means set to 0/1\nconst std::vector<std::vector<bool>> kernel_matrix;\n- std::vector<B> X_N_tmp;\n+// std::vector<B> X_N_tmp;\nstd::vector<int8_t> Ke;\nstd::vector<uint32_t> idx;\n+ std::vector<B> u;\npublic:\nEncoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the POLAR_MK encoder for bases higher than 2.
|
8,490 |
24.10.2018 17:53:07
| -7,200 |
232a407f75fc0cb5c35c4ce8fd32a27311018d17
|
Add the possibility to select the polar kernel from the cmd line.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "@@ -24,6 +24,17 @@ Encoder_polar_MK::parameters* Encoder_polar_MK::parameters\nreturn new Encoder_polar_MK::parameters(*this);\n}\n+struct sub_same_length\n+{\n+ template <typename T>\n+ static void check(const std::vector<T>& v)\n+ {\n+ for(unsigned i = 0; i < v.size(); i++)\n+ if (v[i].size() != v[0].size())\n+ throw std::runtime_error(\"all elements do not have the same length\");\n+ }\n+};\n+\nvoid Encoder_polar_MK::parameters\n::get_description(tools::Argument_map_info &args) const\n{\n@@ -32,18 +43,51 @@ void Encoder_polar_MK::parameters\nauto p = this->get_prefix();\ntools::add_options(args.at({p+\"-type\"}), 0, \"POLAR_MK\");\n+\n+ args.add(\n+ {p+\"-kernel\"},\n+ tools::List2D<bool>(tools::Boolean(),\n+ std::make_tuple(tools::Length(1), tools::Function<sub_same_length>(\"elements of same length\")),\n+ std::make_tuple(tools::Length(1))),\n+ \"kernel of the polar code (squared matrix only) (ex: \\\"111,101,011\\\").\");\n}\nvoid Encoder_polar_MK::parameters\n::store(const tools::Argument_map_value &vals)\n{\nEncoder::parameters::store(vals);\n+\n+ auto p = this->get_prefix();\n+\n+ if(vals.exist({p+\"-kernel\"})) this->kernel_matrix = vals.to_list<std::vector<bool>>({p+\"-kernel\"});\n+}\n+\n+std::string display_kernel(const std::vector<std::vector<bool>>& pattern_bits)\n+{\n+ std::string m;\n+\n+ for(auto &v : pattern_bits)\n+ {\n+ for(const auto &vb : v)\n+ m += std::to_string(vb);\n+\n+ m += \",\";\n+ }\n+\n+ if (m.size())\n+ m.erase(m.size() -1);\n+\n+ return m;\n}\nvoid Encoder_polar_MK::parameters\n::get_headers(std::map<std::string,header_list>& headers, const bool full) const\n{\nEncoder::parameters::get_headers(headers, full);\n+\n+ auto p = this->get_prefix();\n+\n+ headers[p].push_back(std::make_pair(std::string(\"Kernel\"), std::string(\"{\" + display_kernel(this->kernel_matrix) + \"}\")));\n}\ntemplate <typename B>\n@@ -52,9 +96,7 @@ module::Encoder_polar_MK<B>* Encoder_polar_MK::parameters\n{\nif (this->type == \"POLAR_MK\" && !this->systematic)\n{\n- return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, {{1,0},{1,1}}, this->n_frames);\n- // return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, {{1,1,1},{1,0,1},{0,1,1}}, this->n_frames);\n- // return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,1,1}}, this->n_frames);\n+ return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, kernel_matrix, this->n_frames);\n}\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"new_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"diff": "@@ -20,7 +20,8 @@ struct Encoder_polar_MK : public Encoder\n{\npublic:\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n- // empty\n+ // optional\n+ std::vector<std::vector<bool>> kernel_matrix = {{1,0},{1,1}};\n// ---------------------------------------------------------------------------------------------------- METHODS\nexplicit parameters(const std::string &p = Encoder_polar_MK_prefix);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the possibility to select the polar kernel from the cmd line.
|
8,483 |
24.10.2018 18:48:48
| -7,200 |
4fc9656a0c0799b32223f3bc6d25cc0388aeadca
|
Add a read order from any of the 4 corners for ROW_COL and COL_ROW interleavers.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Tools/Interleaver/Interleaver_core.cpp",
"new_path": "src/Factory/Tools/Interleaver/Interleaver_core.cpp",
"diff": "@@ -72,6 +72,12 @@ void Interleaver_core::parameters\n{p+\"-seed\", \"S\"},\ntools::Integer(tools::Positive()),\n\"seed used to initialize the pseudo random generators.\");\n+\n+ args.add(\n+ {p+\"-read-order\"},\n+ tools::Text(tools::Including_set(\"TOP_LEFT\", \"TOP_RIGHT\", \"BOTTOM_LEFT\", \"BOTTOM_RIGHT\")),\n+ \"Read order of the COL_ROW and ROW_COL interleavers.\");\n+\n}\nvoid Interleaver_core::parameters\n@@ -86,6 +92,7 @@ void Interleaver_core::parameters\nif(vals.exist({p+\"-cols\" })) this->n_cols = vals.to_int({p+\"-cols\" });\nif(vals.exist({p+\"-seed\", \"S\"})) this->seed = vals.to_int({p+\"-seed\", \"S\"});\nif(vals.exist({p+\"-uni\" })) this->uniform = true;\n+ if(vals.exist({p+\"-read-order\"})) this->read_order = vals.at({p+\"-read-order\"});\n}\nvoid Interleaver_core::parameters\n@@ -117,8 +124,8 @@ tools::Interleaver_core<T>* Interleaver_core::parameters\nif (this->type == \"DVB-RCS2\") return new tools::Interleaver_core_ARP_DVB_RCS2 <T>(this->size, this->n_frames);\nif (this->type == \"RANDOM\" ) return new tools::Interleaver_core_random <T>(this->size, this->seed, this->uniform, this->n_frames);\nif (this->type == \"RAND_COL\") return new tools::Interleaver_core_random_column<T>(this->size, this->n_cols, this->seed, this->uniform, this->n_frames);\n- if (this->type == \"ROW_COL\" ) return new tools::Interleaver_core_row_column <T>(this->size, this->n_cols, this->n_frames);\n- if (this->type == \"COL_ROW\" ) return new tools::Interleaver_core_column_row <T>(this->size, this->n_cols, this->n_frames);\n+ if (this->type == \"ROW_COL\" ) return new tools::Interleaver_core_row_column <T>(this->size, this->n_cols, this->read_order, this->n_frames);\n+ if (this->type == \"COL_ROW\" ) return new tools::Interleaver_core_column_row <T>(this->size, this->n_cols, this->read_order, this->n_frames);\nif (this->type == \"GOLDEN\" ) return new tools::Interleaver_core_golden <T>(this->size, this->seed, this->uniform, this->n_frames);\nif (this->type == \"USER\" ) return new tools::Interleaver_core_user <T>(this->size, this->path, this->n_frames);\nif (this->type == \"NO\" ) return new tools::Interleaver_core_NO <T>(this->size, this->n_frames);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Tools/Interleaver/Interleaver_core.hpp",
"new_path": "src/Factory/Tools/Interleaver/Interleaver_core.hpp",
"diff": "@@ -25,6 +25,7 @@ struct Interleaver_core : public Factory\n// optional parameters\nstd::string type = \"RANDOM\";\nstd::string path = \"\";\n+ std::string read_order = \"TOP_LEFT\";\nint n_cols = 4; // number of columns of the columns interleaver\nint n_frames = 1;\nint seed = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Interleaver/Column_row/Interleaver_core_column_row.cpp",
"new_path": "src/Tools/Interleaver/Column_row/Interleaver_core_column_row.cpp",
"diff": "#include \"Interleaver_core_column_row.hpp\"\n#include <sstream>\n+#include <iostream>\n#include \"Tools/Exception/exception.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::tools;\n+template <typename T>\n+static typename Interleaver_core_column_row<T>::READ_ORDER read_order_cvt(const std::string& read_order)\n+{\n+ if (read_order == \"TOP_LEFT\")\n+ return Interleaver_core_column_row<T>::READ_ORDER::TOP_LEFT;\n+ if (read_order == \"TOP_RIGHT\")\n+ return Interleaver_core_column_row<T>::READ_ORDER::TOP_RIGHT;\n+ if (read_order == \"BOTTOM_LEFT\")\n+ return Interleaver_core_column_row<T>::READ_ORDER::BOTTOM_LEFT;\n+ if (read_order == \"BOTTOM_RIGHT\")\n+ return Interleaver_core_column_row<T>::READ_ORDER::BOTTOM_RIGHT;\n+\n+ std::stringstream message;\n+ message << \"Unknown 'read_order' ( = \" << read_order << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+}\n+\ntemplate <typename T>\nInterleaver_core_column_row<T>\n-::Interleaver_core_column_row(const int size, const int n_cols, const int n_frames)\n-: Interleaver_core<T>(size, \"row_column\", false, n_frames), n_cols(n_cols), n_rows(size / n_cols)\n+::Interleaver_core_column_row(const int size, const int n_cols, const std::string& read_order, const int n_frames)\n+: Interleaver_core_column_row<T>(size, n_cols, read_order_cvt<T>(read_order), n_frames)\n+{\n+}\n+\n+template <typename T>\n+Interleaver_core_column_row<T>\n+::Interleaver_core_column_row(const int size, const int n_cols, const READ_ORDER read_order, const int n_frames)\n+: Interleaver_core<T>(size, \"row_column\", false, n_frames), n_cols(n_cols), n_rows(size / n_cols), read_order(read_order)\n{\nif (n_rows * n_cols != size)\n{\n@@ -26,9 +51,30 @@ template <typename T>\nvoid Interleaver_core_column_row<T>\n::gen_lut(T *lut, const int frame_id)\n{\n+ T idx = 0;\n+ switch (read_order)\n+ {\n+ case READ_ORDER::TOP_LEFT:\nfor (auto i = 0; i < n_cols; i++)\nfor (auto j = 0; j < n_rows; j++)\n- lut[j * n_cols +i] = i * n_rows +j;\n+ lut[j * n_cols +i] = idx++;\n+ break;\n+ case READ_ORDER::TOP_RIGHT:\n+ for (auto i = n_cols - 1; i >= 0; i--)\n+ for (auto j = 0; j < n_rows; j++)\n+ lut[j * n_cols +i] = idx++;\n+ break;\n+ case READ_ORDER::BOTTOM_LEFT:\n+ for (auto i = 0; i < n_cols; i++)\n+ for (auto j = n_rows -1; j >= 0; j--)\n+ lut[j * n_cols +i] = idx++;\n+ break;\n+ case READ_ORDER::BOTTOM_RIGHT:\n+ for (auto i = n_cols - 1; i >= 0; i--)\n+ for (auto j = n_rows -1; j >= 0; j--)\n+ lut[j * n_cols +i] = idx++;\n+ break;\n+ };\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Interleaver/Column_row/Interleaver_core_column_row.hpp",
"new_path": "src/Tools/Interleaver/Column_row/Interleaver_core_column_row.hpp",
"diff": "#ifndef INTERLEAVER_CORE_COLUMN_ROW_HPP\n#define INTERLEAVER_CORE_COLUMN_ROW_HPP\n+#include <string>\n#include \"Tools/Exception/exception.hpp\"\n#include \"../Interleaver_core.hpp\"\n@@ -15,12 +16,23 @@ namespace tools\ntemplate <typename T = uint32_t>\nclass Interleaver_core_column_row : public Interleaver_core<T>\n{\n+public:\n+ enum class READ_ORDER : int8_t\n+ {\n+ TOP_LEFT, // read from the top row by row from left to right\n+ TOP_RIGHT, // read from the top row by row from right to left\n+ BOTTOM_LEFT, // read from the bottom row by row from left to right\n+ BOTTOM_RIGHT // read from the bottom row by row from right to left\n+ };\n+\nprivate:\nconst int n_cols;\nconst int n_rows;\n+ const READ_ORDER read_order;\npublic:\n- Interleaver_core_column_row(const int size, const int n_cols, const int n_frames = 1);\n+ Interleaver_core_column_row(const int size, const int n_cols, const std::string& read_order, const int n_frames = 1);\n+ Interleaver_core_column_row(const int size, const int n_cols, const READ_ORDER read_order, const int n_frames = 1);\nvirtual ~Interleaver_core_column_row() = default;\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Interleaver/Interleaver_core.hpp",
"new_path": "src/Tools/Interleaver/Interleaver_core.hpp",
"diff": "@@ -23,7 +23,8 @@ protected:\nconst int n_frames;\nbool uniform;\nbool initialized;\n- std::vector<T> pi; /*!< Lookup table for the interleaving process */\n+ std::vector<T> pi; /*!< Lookup table for the interleaving process :\n+ the interleaving output position i can be found in the source at the position 'pi[i]' */\nstd::vector<T> pi_inv; /*!< Lookup table for the deinterleaving process */\npublic:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Interleaver/Row_column/Interleaver_core_row_column.cpp",
"new_path": "src/Tools/Interleaver/Row_column/Interleaver_core_row_column.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n+template <typename T>\n+static typename Interleaver_core_row_column<T>::READ_ORDER read_order_cvt(const std::string& read_order)\n+{\n+ if (read_order == \"TOP_LEFT\")\n+ return Interleaver_core_row_column<T>::READ_ORDER::TOP_LEFT;\n+ if (read_order == \"TOP_RIGHT\")\n+ return Interleaver_core_row_column<T>::READ_ORDER::TOP_RIGHT;\n+ if (read_order == \"BOTTOM_LEFT\")\n+ return Interleaver_core_row_column<T>::READ_ORDER::BOTTOM_LEFT;\n+ if (read_order == \"BOTTOM_RIGHT\")\n+ return Interleaver_core_row_column<T>::READ_ORDER::BOTTOM_RIGHT;\n+\n+ std::stringstream message;\n+ message << \"Unknown 'read_order' ( = \" << read_order << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+}\n+\ntemplate <typename T>\nInterleaver_core_row_column<T>\n-::Interleaver_core_row_column(const int size, const int n_cols, const int n_frames)\n-: Interleaver_core<T>(size, \"row_column\", false, n_frames), n_cols(n_cols), n_rows(size / n_cols)\n+::Interleaver_core_row_column(const int size, const int n_cols, const std::string& read_order, const int n_frames)\n+: Interleaver_core_row_column<T>(size, n_cols, read_order_cvt<T>(read_order), n_frames)\n+{\n+}\n+\n+template <typename T>\n+Interleaver_core_row_column<T>\n+::Interleaver_core_row_column(const int size, const int n_cols, const READ_ORDER read_order, const int n_frames)\n+: Interleaver_core<T>(size, \"row_column\", false, n_frames), n_cols(n_cols), n_rows(size / n_cols), read_order(read_order)\n{\nif (n_rows * n_cols != size)\n{\n@@ -25,9 +49,30 @@ template <typename T>\nvoid Interleaver_core_row_column<T>\n::gen_lut(T *lut, const int frame_id)\n{\n+ T idx = 0;\n+ switch (read_order)\n+ {\n+ case READ_ORDER::TOP_LEFT:\nfor (auto i = 0; i < n_cols; i++)\nfor (auto j = 0; j < n_rows; j++)\n- lut[i * n_rows +j] = j * n_cols +i;\n+ lut[idx++] = j * n_cols +i;\n+ break;\n+ case READ_ORDER::TOP_RIGHT:\n+ for (auto i = n_cols - 1; i >= 0; i--)\n+ for (auto j = 0; j < n_rows; j++)\n+ lut[idx++] = j * n_cols +i;\n+ break;\n+ case READ_ORDER::BOTTOM_LEFT:\n+ for (auto i = 0; i < n_cols; i++)\n+ for (auto j = n_rows -1; j >= 0; j--)\n+ lut[idx++] = j * n_cols +i;\n+ break;\n+ case READ_ORDER::BOTTOM_RIGHT:\n+ for (auto i = n_cols - 1; i >= 0; i--)\n+ for (auto j = n_rows -1; j >= 0; j--)\n+ lut[idx++] = j * n_cols +i;\n+ break;\n+ };\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Interleaver/Row_column/Interleaver_core_row_column.hpp",
"new_path": "src/Tools/Interleaver/Row_column/Interleaver_core_row_column.hpp",
"diff": "#ifndef INTERLEAVER_CORE_ROW_COLUMN_HPP\n#define INTERLEAVER_CORE_ROW_COLUMN_HPP\n+#include <string>\n#include \"Tools/Exception/exception.hpp\"\n#include \"../Interleaver_core.hpp\"\n@@ -15,12 +16,23 @@ namespace tools\ntemplate <typename T = uint32_t>\nclass Interleaver_core_row_column : public Interleaver_core<T>\n{\n+public:\n+ enum class READ_ORDER : int8_t\n+ {\n+ TOP_LEFT, // read from the top row by row from left to right\n+ TOP_RIGHT, // read from the top row by row from right to left\n+ BOTTOM_LEFT, // read from the bottom row by row from left to right\n+ BOTTOM_RIGHT // read from the bottom row by row from right to left\n+ };\n+\nprivate:\nconst int n_cols;\nconst int n_rows;\n+ const READ_ORDER read_order;\npublic:\n- Interleaver_core_row_column(const int size, const int n_cols, const int n_frames = 1);\n+ Interleaver_core_row_column(const int size, const int n_cols, const std::string& read_order, const int n_frames = 1);\n+ Interleaver_core_row_column(const int size, const int n_cols, const READ_ORDER read_order, const int n_frames = 1);\nvirtual ~Interleaver_core_row_column() = default;\nprotected:\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a read order from any of the 4 corners for ROW_COL and COL_ROW interleavers.
|
8,490 |
25.10.2018 16:49:08
| -7,200 |
6cc3b4c427b1b0b30a77d93cc7020ff50692036b
|
Improve the checks in the POLAR_MK encoder.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "@@ -62,24 +62,6 @@ void Encoder_polar_MK::parameters\nif(vals.exist({p+\"-kernel\"})) this->kernel_matrix = vals.to_list<std::vector<bool>>({p+\"-kernel\"});\n}\n-std::string display_kernel(const std::vector<std::vector<bool>>& pattern_bits)\n-{\n- std::string m;\n-\n- for(auto &v : pattern_bits)\n- {\n- for(const auto &vb : v)\n- m += std::to_string(vb);\n-\n- m += \",\";\n- }\n-\n- if (m.size())\n- m.erase(m.size() -1);\n-\n- return m;\n-}\n-\nvoid Encoder_polar_MK::parameters\n::get_headers(std::map<std::string,header_list>& headers, const bool full) const\n{\n@@ -87,7 +69,7 @@ void Encoder_polar_MK::parameters\nauto p = this->get_prefix();\n- headers[p].push_back(std::make_pair(std::string(\"Kernel\"), std::string(\"{\" + display_kernel(this->kernel_matrix) + \"}\")));\n+ headers[p].push_back(std::make_pair(std::string(\"Kernel\"), std::string(tools::display_kernel(this->kernel_matrix))));\n}\ntemplate <typename B>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "#include <vector>\n#include <cmath>\n+#include <map>\n#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n@@ -36,6 +37,75 @@ using namespace aff3ct::module;\n// C[row_A * B.size() + row_B][col_A * B[0].size() + col_B] = A[row_A][col_A] * B[row_B][col_B];\n// }\n+// template <typename T = int32_t>\n+// std::vector<std::vector<T>> kronecker_product(const std::vector<std::vector<T>>& A,\n+// const std::vector<std::vector<T>>& B)\n+// {\n+// // verifications --------------------------------------------------------------------------------------------------\n+// if (A.size() == 0)\n+// {\n+// std::stringstream message;\n+// message << \"'A.size()' should be higher than 0 ('A.size()' = \" << A.size() << \").\";\n+// throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+// }\n+\n+// if (B.size() == 0)\n+// {\n+// std::stringstream message;\n+// message << \"'B.size()' should be higher than 0 ('B.size()' = \" << B.size() << \").\";\n+// throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+// }\n+\n+// for (auto l = 0; l < (int)A.size(); l++)\n+// {\n+// if (A[l].size() != A.size())\n+// {\n+// std::stringstream message;\n+// message << \"'A[l].size()' has to be equal to 'A.size()' ('l' = \" << l\n+// << \", 'A[l].size()' = \" << A[l].size()\n+// << \", 'A.size()' = \" << A.size() << \").\";\n+// throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+// }\n+// }\n+\n+// for (auto l = 0; l < (int)B.size(); l++)\n+// {\n+// if (B[l].size() != B.size())\n+// {\n+// std::stringstream message;\n+// message << \"'B[l].size()' has to be equal to 'B.size()' ('l' = \" << l\n+// << \", 'B[l].size()' = \" << B[l].size()\n+// << \", 'B.size()' = \" << B.size() << \").\";\n+// throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+// }\n+// }\n+// // ----------------------------------------------------------------------------------------------------------------\n+\n+// std::vector<std::vector<T>> C(A.size() * B.size(), std::vector<T>(A[0].size() * B[0].size()));\n+// kronecker_product(A, B, C);\n+// return C;\n+// }\n+\n+std::string aff3ct::tools::display_kernel(const std::vector<std::vector<bool>>& pattern_bits)\n+{\n+ std::string m = \"{\";\n+\n+ for(auto &v : pattern_bits)\n+ {\n+ for(const auto &vb : v)\n+ m += std::to_string(vb);\n+\n+ m += \",\";\n+ }\n+\n+ if (m.size())\n+ m.erase(m.size() -1);\n+\n+ m += \"}\";\n+\n+ return m;\n+}\n+\n// Function to get cofactor of mat[p][q] in tmp[][]. n is current\n// dimension of mat[][]\ntemplate <typename T = int32_t>\n@@ -96,126 +166,147 @@ int determinant_of_matrix(const std::vector<std::vector<T>> &mat, const int n)\nreturn D;\n}\n-template <typename T>\n+template <typename T = int32_t>\nbool is_invertible(const std::vector<std::vector<T>> &mat)\n{\nreturn determinant_of_matrix(mat, (int)mat.size()) != 0;\n}\n-template <typename T = int32_t>\n-std::vector<std::vector<T>> kronecker_product(const std::vector<std::vector<T>>& A,\n- const std::vector<std::vector<T>>& B)\n-{\n- // verifications --------------------------------------------------------------------------------------------------\n- if (A.size() == 0)\n+template <typename B>\n+Encoder_polar_MK<B>\n+::Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n+ const std::vector<std::vector<bool>>& kernel_matrix, const int n_frames)\n+: Encoder<B>(K, N, n_frames),\n+ frozen_bits(frozen_bits),\n+ kernel_matrices(1, kernel_matrix),\n+ stages((int)(std::log(N)/std::log(kernel_matrix.size())), 0),\n+ // X_N_tmp(this->N),\n+ Ke(1, std::vector<int8_t>(kernel_matrix.size() * kernel_matrix.size())),\n+ idx(kernel_matrix.size()),\n+ u(kernel_matrix.size())\n{\n- std::stringstream message;\n- message << \"'A.size()' should be higher than 0 ('A.size()' = \" << A.size() << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n+ const std::string name = \"Encoder_polar_MK\";\n+ this->set_name(name);\n+ this->set_sys(false);\n- if (B.size() == 0)\n- {\n- std::stringstream message;\n- message << \"'B.size()' should be higher than 0 ('B.size()' = \" << B.size() << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ this->init();\n}\n- for (auto l = 0; l < (int)A.size(); l++)\n+template <typename B>\n+Encoder_polar_MK<B>\n+::Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n+ const std::vector<std::vector<std::vector<bool>>>& kernel_matrices,\n+ const std::vector<uint32_t> &stages, const int n_frames)\n+: Encoder<B>(K, N, n_frames),\n+ frozen_bits(frozen_bits),\n+ kernel_matrices(kernel_matrices),\n+ stages(stages),\n+ // X_N_tmp(this->N),\n+ Ke(kernel_matrices.size()),\n+ idx(),\n+ u()\n{\n- if (A[l].size() != A.size())\n+ const std::string name = \"Encoder_polar_MK\";\n+ this->set_name(name);\n+ this->set_sys(false);\n+\n+ size_t biggest_kernel_size = 0;\n+ for (auto ke = 0; ke < (int)kernel_matrices.size(); ke++)\n{\n- std::stringstream message;\n- message << \"'A[l].size()' has to be equal to 'A.size()' ('l' = \" << l\n- << \", 'A[l].size()' = \" << A[l].size()\n- << \", 'A.size()' = \" << A.size() << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n+ Ke[ke].resize(kernel_matrices[ke].size() * kernel_matrices[ke].size());\n+ biggest_kernel_size = std::max(biggest_kernel_size, kernel_matrices[ke].size());\n}\n- for (auto l = 0; l < (int)B.size(); l++)\n- {\n- if (B[l].size() != B.size())\n+ idx.resize(biggest_kernel_size);\n+ u.resize(biggest_kernel_size);\n+\n+ for (auto s : stages)\n+ if(s >= kernel_matrices.size())\n{\nstd::stringstream message;\n- message << \"'B[l].size()' has to be equal to 'B.size()' ('l' = \" << l\n- << \", 'B[l].size()' = \" << B[l].size()\n- << \", 'B.size()' = \" << B.size() << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n+ message << \"'s' should not be higher than 'kernel_matrices.size()' (\"\n+ << \"'s' = \" << s << \", \"\n+ << \"'kernel_matrices.size()' = \" << kernel_matrices.size() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- // ----------------------------------------------------------------------------------------------------------------\n- std::vector<std::vector<T>> C(A.size() * B.size(), std::vector<T>(A[0].size() * B[0].size()));\n- kronecker_product(A, B, C);\n- return C;\n+ this->init();\n}\ntemplate <typename B>\n-Encoder_polar_MK<B>\n-::Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n- const std::vector<std::vector<bool>>& kernel_matrix, const int n_frames)\n-: Encoder<B>(K, N, n_frames),\n- bp(kernel_matrix.size()),\n- m((int)(std::log(N)/std::log(bp))),\n- frozen_bits(frozen_bits),\n- kernel_matrix(kernel_matrix),\n- // X_N_tmp(this->N),\n- Ke(kernel_matrix.size() * kernel_matrix.size()),\n- idx(kernel_matrix.size()),\n- u(kernel_matrix.size())\n+void Encoder_polar_MK<B>\n+::init()\n{\n- const std::string name = \"Encoder_polar_MK\";\n- this->set_name(name);\n- this->set_sys(false);\n-\n- if (this->N != (int)frozen_bits.size())\n+ if (this->N != (int)this->frozen_bits.size())\n{\nstd::stringstream message;\n- message << \"'frozen_bits.size()' has to be equal to 'N' ('frozen_bits.size()' = \" << frozen_bits.size()\n- << \", 'N' = \" << N << \").\";\n+ message << \"'frozen_bits.size()' has to be equal to 'N' (\"\n+ << \"'frozen_bits.size()' = \" << this->frozen_bits.size() << \", \"\n+ << \"'N' = \" << this->N << \").\";\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- auto k = 0; for (auto i = 0; i < this->N; i++) if (frozen_bits[i] == 0) k++;\n+ auto k = 0; for (auto i = 0; i < this->N; i++) if (this->frozen_bits[i] == 0) k++;\nif (this->K != k)\n{\nstd::stringstream message;\n- message << \"The number of information bits in the frozen_bits is invalid ('K' = \" << K << \", 'k' = \"\n- << k << \").\";\n+ message << \"The number of information bits in the frozen_bits is invalid (\"\n+ << \"'K' = \" << this->K << \", \"\n+ << \"'k' = \" << k << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if (!tools::is_power((int)kernel_matrix.size(), N))\n+ for (auto ke = 0; ke < (int)this->kernel_matrices.size(); ke++)\n+ for (auto l = 0; l < (int)this->kernel_matrices[ke].size(); l++)\n+ if (this->kernel_matrices[ke][l].size() != this->kernel_matrices[ke].size())\n{\nstd::stringstream message;\n- message << \"'kernel_matrix.size()' has to be a power of 'N' ('kernel_matrix.size()' = \" << kernel_matrix.size()\n- << \", 'N' = \" << N << \").\";\n+ message << \"Square matrices are required for the polar kernels: 'kernel_matrices[ke][l].size()' has to \"\n+ << \"be equal to 'kernel_matrices[ke].size()' (\"\n+ << \"'ke' = \" << ke << \", \"\n+ << \"'l' = \" << l << \", \"\n+ << \"'kernel_matrices[ke][l].size()' = \" << this->kernel_matrices[ke][l].size() << \", \"\n+ << \"'kernel_matrices[ke].size()' = \" << this->kernel_matrices[ke].size() << \").\";\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- if (!is_invertible<bool>(kernel_matrix))\n+ for (auto ke = 0; ke < (int)this->kernel_matrices.size(); ke++)\n+ if (!is_invertible(this->kernel_matrices[ke]))\n{\nstd::stringstream message;\n- message << \"'kernel_matrix' has to be invertible.\";\n+ message << \"'kernel_matrices[ke]' has to be invertible (\"\n+ << \"'ke' = \" << ke << \", \"\n+ << \"'kernel_matrices[ke]' = \" << tools::display_kernel(this->kernel_matrices[ke]) << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- for (auto l = 0; l < (int)kernel_matrix.size(); l++)\n+ std::map<int,int> n_kernels_per_type;\n+ for (auto s : stages)\n{\n- if (kernel_matrix[l].size() != kernel_matrix.size())\n+ if (n_kernels_per_type.find(s) != n_kernels_per_type.end())\n+ n_kernels_per_type[s]++;\n+ else\n+ n_kernels_per_type[s] = 1;\n+ }\n+ auto expected_N = (int)1;\n+ for (auto kt : n_kernels_per_type)\n+ expected_N *= (int)std::pow((float)kernel_matrices[stages[kt.first]].size(), (int)kt.second);\n+ if (expected_N != this->N)\n{\nstd::stringstream message;\n- message << \"'kernel_matrix[l].size()' has to be equal to 'kernel_matrix.size()' ('l' = \" << l\n- << \", 'kernel_matrix[l].size()' = \" << kernel_matrix[l].size()\n- << \", 'kernel_matrix.size()' = \" << kernel_matrix.size() << \").\";\n+ message << \"'expected_N' should be equal to 'N' (\"\n+ << \"'expected_N' = \" << expected_N << \", \"\n+ << \"'N' = \" << this->N << \").\";\nthrow tools::length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- }\n- for (auto i = 0; i < (int)this->kernel_matrix.size(); i++)\n- for (auto j = 0; j < (int)this->kernel_matrix.size(); j++)\n- this->Ke[i * (int)this->kernel_matrix.size() +j] = (int8_t)this->kernel_matrix[j][i];\n+ for (auto ke = 0; ke < (int)this->kernel_matrices.size(); ke++)\n+ {\n+ const auto kernel_size = (int)this->kernel_matrices[ke].size();\n+ for (auto i = 0; i < kernel_size; i++)\n+ for (auto j = 0; j < kernel_size; j++)\n+ this->Ke[ke][i * kernel_size +j] = (int8_t)this->kernel_matrices[ke][j][i];\n+ }\nthis->notify_frozenbits_update();\n}\n@@ -245,9 +336,9 @@ template <typename B>\nvoid Encoder_polar_MK<B>\n::light_encode(B *X_N)\n{\n- const auto kernel_size = (int)this->kernel_matrix.size();\n- for (auto s = 0; s < this->m; s++)\n+ for (auto s = 0; s < (int)this->stages.size(); s++)\n{\n+ const auto kernel_size = (int)this->kernel_matrices[stages[s]].size();\nconst auto block_size = (int)std::pow((float)kernel_size, s);\nconst auto n_blocks = this->N / (block_size * kernel_size);\n@@ -263,7 +354,7 @@ void Encoder_polar_MK<B>\n}\nconst auto off_out = b * block_size * kernel_size + k * kernel_size;\n- polar_kernel(this->u.data(), this->idx.data(), this->Ke.data(), X_N, kernel_size);\n+ polar_kernel(this->u.data(), this->idx.data(), this->Ke[stages[s]].data(), X_N, kernel_size);\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"diff": "#include \"../Encoder.hpp\"\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+std::string display_kernel(const std::vector<std::vector<bool>>& pattern_bits);\n+}\n+}\n+\nnamespace aff3ct\n{\nnamespace module\n@@ -16,20 +24,26 @@ template <typename B = int>\nclass Encoder_polar_MK : public Encoder<B>, public tools::Frozenbits_notifier\n{\nprotected:\n- const int bp; // base power\n- const int m; // log_b of code length\nconst std::vector<bool>& frozen_bits; // true means frozen, false means set to 0/1\n- const std::vector<std::vector<bool>> kernel_matrix;\n+ const std::vector<std::vector<std::vector<bool>>> kernel_matrices;\n+ const std::vector<uint32_t> stages;\n// std::vector<B> X_N_tmp;\n- std::vector<int8_t> Ke;\n+ std::vector<std::vector<int8_t>> Ke;\nstd::vector<uint32_t> idx;\nstd::vector<B> u;\npublic:\nEncoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\nconst std::vector<std::vector<bool>>& kernel_matrix = {{1,0},{1,1}}, const int n_frames = 1);\n+\n+ Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n+ const std::vector<std::vector<std::vector<bool>>>& kernel_matrices,\n+ const std::vector<uint32_t> &stages, const int n_frames = 1);\n+\nvirtual ~Encoder_polar_MK() = default;\n+ void init();\n+\n// bool is_codeword(const B *X_N);\nvirtual void notify_frozenbits_update();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve the checks in the POLAR_MK encoder.
|
8,490 |
29.10.2018 09:30:35
| -3,600 |
2271e184d0bebb9ce91d827fb7b538276bbec1d1
|
Fix the POLAR_MK encoder to work on multi kernel polar codes.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "@@ -181,7 +181,7 @@ Encoder_polar_MK<B>\nkernel_matrices(1, kernel_matrix),\nstages((int)(std::log(N)/std::log(kernel_matrix.size())), 0),\n// X_N_tmp(this->N),\n- Ke(1, std::vector<int8_t>(kernel_matrix.size() * kernel_matrix.size())),\n+ Ke(1, std::vector<B>(kernel_matrix.size() * kernel_matrix.size())),\nidx(kernel_matrix.size()),\nu(kernel_matrix.size())\n{\n@@ -290,7 +290,7 @@ void Encoder_polar_MK<B>\n}\nauto expected_N = (int)1;\nfor (auto kt : n_kernels_per_type)\n- expected_N *= (int)std::pow((float)kernel_matrices[stages[kt.first]].size(), (int)kt.second);\n+ expected_N *= (int)std::pow((float)kernel_matrices[kt.first].size(), (int)kt.second);\nif (expected_N != this->N)\n{\nstd::stringstream message;\n@@ -305,7 +305,7 @@ void Encoder_polar_MK<B>\nconst auto kernel_size = (int)this->kernel_matrices[ke].size();\nfor (auto i = 0; i < kernel_size; i++)\nfor (auto j = 0; j < kernel_size; j++)\n- this->Ke[ke][i * kernel_size +j] = (int8_t)this->kernel_matrices[ke][j][i];\n+ this->Ke[ke][i * kernel_size +j] = (B)this->kernel_matrices[ke][j][i];\n}\nthis->notify_frozenbits_update();\n@@ -320,7 +320,7 @@ void Encoder_polar_MK<B>\n}\ntemplate <typename B>\n-void polar_kernel(const B *u, const uint32_t *idx, const int8_t *Ke, B *x, const int size)\n+void polar_kernel(const B *u, const uint32_t *idx, const B *Ke, B *x, const int size)\n{\nfor (auto i = 0; i < size; i++)\n{\n@@ -328,7 +328,7 @@ void polar_kernel(const B *u, const uint32_t *idx, const int8_t *Ke, B *x, const\nauto sum = 0;\nfor (auto j = 0; j < size; j++)\nsum += u[j] & Ke[stride +j];\n- x[idx[i]] = sum & (int8_t)1;\n+ x[idx[i]] = sum & (B)1;\n}\n}\n@@ -336,27 +336,27 @@ template <typename B>\nvoid Encoder_polar_MK<B>\n::light_encode(B *X_N)\n{\n+ auto n_kernels = (int)1;\nfor (auto s = 0; s < (int)this->stages.size(); s++)\n{\nconst auto kernel_size = (int)this->kernel_matrices[stages[s]].size();\n- const auto block_size = (int)std::pow((float)kernel_size, s);\n- const auto n_blocks = this->N / (block_size * kernel_size);\n+ const auto n_blocks = this->N / (n_kernels * kernel_size);\nfor (auto b = 0; b < n_blocks; b++)\n{\n- const auto n_kernels = block_size;\nfor (auto k = 0; k < n_kernels; k++)\n{\nfor (auto i = 0; i < kernel_size; i++)\n{\n- this->idx[i] = (uint32_t)(b * block_size * kernel_size + block_size * i +k);\n+ this->idx[i] = (uint32_t)(b * n_kernels * kernel_size + n_kernels * i +k);\nthis->u[i] = X_N[this->idx[i]];\n}\n- const auto off_out = b * block_size * kernel_size + k * kernel_size;\npolar_kernel(this->u.data(), this->idx.data(), this->Ke[stages[s]].data(), X_N, kernel_size);\n}\n}\n+\n+ n_kernels *= kernel_size;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"diff": "@@ -28,7 +28,7 @@ protected:\nconst std::vector<std::vector<std::vector<bool>>> kernel_matrices;\nconst std::vector<uint32_t> stages;\n// std::vector<B> X_N_tmp;\n- std::vector<std::vector<int8_t>> Ke;\n+ std::vector<std::vector<B>> Ke;\nstd::vector<uint32_t> idx;\nstd::vector<B> u;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the POLAR_MK encoder to work on multi kernel polar codes.
|
8,483 |
30.10.2018 08:46:08
| -3,600 |
3aa1a47008338bae09b16f5dade4631e5db0c4a4
|
Fix sparse matrix self_resize function. Thanks to Elie Janin.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.cpp",
"new_path": "src/Tools/Algo/Matrix/Sparse_matrix/Sparse_matrix.cpp",
"diff": "@@ -131,7 +131,7 @@ void Sparse_matrix\nvoid Sparse_matrix\n::self_resize(const size_t n_rows, const size_t n_cols, Origin o)\n{\n- *this = this->resize(n_rows, n_rows, o);\n+ *this = this->resize(n_rows, n_cols, o);\n}\nSparse_matrix Sparse_matrix\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix sparse matrix self_resize function. Thanks to Elie Janin.
|
8,490 |
31.10.2018 14:20:20
| -3,600 |
23f09dad38b9f189149da1e08b89c04a41cd0214
|
Add a systematic encoder for Polar_ML codes.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Encoder/Polar_MK/Encoder_polar_MK.hpp\"\n+#include \"Module/Encoder/Polar_MK/Encoder_polar_MK_sys.hpp\"\n#include \"Encoder_polar_MK.hpp\"\n@@ -44,12 +45,22 @@ void Encoder_polar_MK::parameters\ntools::add_options(args.at({p+\"-type\"}), 0, \"POLAR_MK\");\n+ args.add(\n+ {p+\"-sys\"},\n+ tools::None(),\n+ \"enable the systematic encoding.\");\n+\nargs.add(\n{p+\"-kernel\"},\ntools::List2D<bool>(tools::Boolean(),\nstd::make_tuple(tools::Length(1), tools::Function<sub_same_length>(\"elements of same length\")),\nstd::make_tuple(tools::Length(1))),\n\"kernel of the polar code (squared matrix only) (ex: \\\"111,101,011\\\").\");\n+\n+ args.add(\n+ {p+\"-code-path\"},\n+ tools::File(tools::openmode::read),\n+ \"path to a file containing the polar code description (kernels definition and stages).\");\n}\nvoid Encoder_polar_MK::parameters\n@@ -60,6 +71,8 @@ void Encoder_polar_MK::parameters\nauto p = this->get_prefix();\nif(vals.exist({p+\"-kernel\" })) this->kernel_matrix = vals.to_list<std::vector<bool>>({p+\"-kernel\"});\n+ if(vals.exist({p+\"-code-path\"})) this->code_path = vals.at({p+\"-code-path\"});\n+ if(vals.exist({p+\"-sys\" })) this->systematic = true;\n}\nvoid Encoder_polar_MK::parameters\n@@ -69,16 +82,54 @@ void Encoder_polar_MK::parameters\nauto p = this->get_prefix();\n- headers[p].push_back(std::make_pair(std::string(\"Kernel\"), std::string(tools::display_kernel(this->kernel_matrix))));\n+ if (this->code_path.empty())\n+ {\n+ headers[p].push_back(std::make_pair(std::string(\"Kernel\"), tools::display_kernel(this->kernel_matrix)));\n+ }\n+ else\n+ {\n+ std::vector<std::vector<std::vector<bool>>> kernel_matrices;\n+ std::vector<uint32_t> stages;\n+ tools::read_polar_MK_code(this->code_path, kernel_matrices, stages);\n+ if (kernel_matrices.size() > 0)\n+ {\n+ std::string kernels_str = \"{\" + tools::display_kernel(kernel_matrices[0]);\n+ for (auto k = 1; k < kernel_matrices.size(); k++)\n+ kernels_str += \",\" + tools::display_kernel(kernel_matrices[k]);\n+ kernels_str += \"}\";\n+ headers[p].push_back(std::make_pair(std::string(\"Kernels\"), kernels_str));\n+ }\n+ if (stages.size() > 0)\n+ {\n+ std::string stages_str = \"{\" + std::to_string(stages[0]);\n+ for (auto s = 1; s < stages.size(); s++)\n+ stages_str += \",\" + std::to_string(stages[s]);\n+ stages_str += \"}\";\n+ headers[p].push_back(std::make_pair(std::string(\"Stages\"), stages_str));\n+ }\n+ }\n}\ntemplate <typename B>\nmodule::Encoder_polar_MK<B>* Encoder_polar_MK::parameters\n::build(const std::vector<bool> &frozen_bits) const\n{\n- if (this->type == \"POLAR_MK\" && !this->systematic)\n+ if (this->type == \"POLAR_MK\")\n{\n+ if (this->systematic)\n+ {\n+ if (this->code_path.empty())\n+ return new module::Encoder_polar_MK_sys<B>(this->K, this->N_cw, frozen_bits, kernel_matrix, this->n_frames);\n+ else\n+ return new module::Encoder_polar_MK_sys<B>(this->K, this->N_cw, frozen_bits, this->code_path, this->n_frames);\n+ }\n+ else\n+ {\n+ if (this->code_path.empty())\nreturn new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, kernel_matrix, this->n_frames);\n+ else\n+ return new module::Encoder_polar_MK<B>(this->K, this->N_cw, frozen_bits, this->code_path, this->n_frames);\n+ }\n}\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"new_path": "src/Factory/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"diff": "@@ -22,6 +22,7 @@ struct Encoder_polar_MK : public Encoder\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n// optional\nstd::vector<std::vector<bool>> kernel_matrix = {{1,0},{1,1}};\n+ std::string code_path;\n// ---------------------------------------------------------------------------------------------------- METHODS\nexplicit parameters(const std::string &p = Encoder_polar_MK_prefix);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.cpp",
"diff": "#include <cmath>\n#include <map>\n#include <sstream>\n+#include <fstream>\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Math/utils.h\"\n+#include \"Tools/general_utils.h\"\n#include \"Encoder_polar_MK.hpp\"\n@@ -25,67 +27,6 @@ using namespace aff3ct::module;\n// }\n// }\n-// template <typename T = int32_t>\n-// void kronecker_product(const std::vector<std::vector<T>>& A,\n-// const std::vector<std::vector<T>>& B,\n-// std::vector<std::vector<T>>& C)\n-// {\n-// for (auto row_A = 0; row_A < (int)A.size(); row_A++)\n-// for (auto col_A = 0; col_A < (int)A[0].size(); col_A++)\n-// for (auto row_B = 0; row_B < (int)B.size(); row_B++)\n-// for (auto col_B = 0; col_B < (int)B[0].size(); col_B++)\n-// C[row_A * B.size() + row_B][col_A * B[0].size() + col_B] = A[row_A][col_A] * B[row_B][col_B];\n-// }\n-\n-// template <typename T = int32_t>\n-// std::vector<std::vector<T>> kronecker_product(const std::vector<std::vector<T>>& A,\n-// const std::vector<std::vector<T>>& B)\n-// {\n-// // verifications --------------------------------------------------------------------------------------------------\n-// if (A.size() == 0)\n-// {\n-// std::stringstream message;\n-// message << \"'A.size()' should be higher than 0 ('A.size()' = \" << A.size() << \").\";\n-// throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n-// }\n-\n-// if (B.size() == 0)\n-// {\n-// std::stringstream message;\n-// message << \"'B.size()' should be higher than 0 ('B.size()' = \" << B.size() << \").\";\n-// throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n-// }\n-\n-// for (auto l = 0; l < (int)A.size(); l++)\n-// {\n-// if (A[l].size() != A.size())\n-// {\n-// std::stringstream message;\n-// message << \"'A[l].size()' has to be equal to 'A.size()' ('l' = \" << l\n-// << \", 'A[l].size()' = \" << A[l].size()\n-// << \", 'A.size()' = \" << A.size() << \").\";\n-// throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n-// }\n-// }\n-\n-// for (auto l = 0; l < (int)B.size(); l++)\n-// {\n-// if (B[l].size() != B.size())\n-// {\n-// std::stringstream message;\n-// message << \"'B[l].size()' has to be equal to 'B.size()' ('l' = \" << l\n-// << \", 'B[l].size()' = \" << B[l].size()\n-// << \", 'B.size()' = \" << B.size() << \").\";\n-// throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n-// }\n-// }\n-// // ----------------------------------------------------------------------------------------------------------------\n-\n-// std::vector<std::vector<T>> C(A.size() * B.size(), std::vector<T>(A[0].size() * B[0].size()));\n-// kronecker_product(A, B, C);\n-// return C;\n-// }\n-\nstd::string aff3ct::tools::display_kernel(const std::vector<std::vector<bool>>& pattern_bits)\n{\nstd::string m = \"{\";\n@@ -106,6 +47,154 @@ std::string aff3ct::tools::display_kernel(const std::vector<std::vector<bool>>&\nreturn m;\n}\n+void aff3ct::tools::read_polar_MK_code(const std::string &code_path,\n+ std::vector<std::vector<std::vector<bool>>> &kernel_matrices,\n+ std::vector<uint32_t> &stages)\n+{\n+ std::ifstream file(code_path.c_str(), std::ios::in);\n+ std::string line;\n+\n+ if (file.is_open())\n+ {\n+ tools::getline(file, line);\n+ auto values = tools::split(line);\n+\n+ if (values.size() > 0)\n+ {\n+ auto n_kernels = std::stoi(values[0]);\n+ if (n_kernels > 0)\n+ {\n+ kernel_matrices.resize(n_kernels);\n+\n+ for (auto k = 0; k < n_kernels; k++)\n+ {\n+ tools::getline(file, line);\n+ auto values = tools::split(line);\n+\n+ if (values.size() > 0)\n+ {\n+ auto kernel_size = std::stoi(values[0]);\n+ std::vector<std::vector<bool>> kernel(kernel_size, std::vector<bool>(kernel_size));\n+\n+ if (kernel_size > 1)\n+ {\n+ for (auto i = 0; i < kernel_size; i++)\n+ {\n+ tools::getline(file, line);\n+ auto values = tools::split(line);\n+\n+ if (values.size() == kernel_size)\n+ {\n+ for (auto j = 0; j < kernel_size; j++)\n+ kernel[i][j] = (bool)std::stoi(values[j]);\n+ }\n+ else\n+ {\n+ file.close();\n+\n+ std::stringstream message;\n+ message << \"'values.size()' should be equal to 'kernel_size' ('values.size()' = \"\n+ << values.size() << \", 'kernel_size' = \" << kernel_size << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ }\n+ else\n+ {\n+ file.close();\n+\n+ std::stringstream message;\n+ message << \"'kernel_size' should be greater than 1 ('kernel_size' = \"\n+ << kernel_size << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ kernel_matrices[k] = kernel;\n+ }\n+ else\n+ {\n+ file.close();\n+\n+ std::stringstream message;\n+ message << \"'values.size()' should be greater than 0 ('values.size()' = \"\n+ << values.size() << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ }\n+ else\n+ {\n+ file.close();\n+\n+ std::stringstream message;\n+ message << \"'n_kernels' should be greater than 0 ('n_kernels' = \" << n_kernels << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ tools::getline(file, line);\n+ auto values = tools::split(line);\n+\n+ if (values.size() > 0)\n+ {\n+ auto n_stages = std::stoi(values[0]);\n+ if (n_stages > 0)\n+ {\n+ stages.resize(n_stages);\n+\n+ tools::getline(file, line);\n+ auto values = tools::split(line);\n+\n+ if (values.size() == n_stages)\n+ {\n+ for (auto s = 0; s < n_stages; s++)\n+ stages[s] = (uint32_t)std::stoi(values[s]);\n+ }\n+ else\n+ {\n+ file.close();\n+\n+ std::stringstream message;\n+ message << \"'values.size()' should be equal to 'n_stages' ('values.size()' = \"\n+ << values.size() << \", 'n_stages' = \" << n_stages << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ else\n+ {\n+ file.close();\n+\n+ std::stringstream message;\n+ message << \"'n_stages' should be greater than 0 ('n_stages' = \" << n_stages << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ else\n+ {\n+ file.close();\n+\n+ std::stringstream message;\n+ message << \"'values.size()' should be greater than 0 ('values.size()' = \"\n+ << values.size() << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ else\n+ {\n+ file.close();\n+\n+ std::stringstream message;\n+ message << \"'values.size()' should be greater than 0 ('values.size()' = \" << values.size() << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"Can't open '\" + code_path + \"' file.\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n// Function to get cofactor of mat[p][q] in tmp[][]. n is current\n// dimension of mat[][]\ntemplate <typename T = int32_t>\n@@ -210,23 +299,73 @@ Encoder_polar_MK<B>\nthis->set_name(name);\nthis->set_sys(false);\n+ this->init_MK();\n+}\n+\n+template <typename B>\n+Encoder_polar_MK<B>\n+::Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits, const std::string &code_path,\n+ const int n_frames)\n+: Encoder<B>(K, N, n_frames),\n+ frozen_bits(frozen_bits),\n+ kernel_matrices(),\n+ stages(),\n+ // X_N_tmp(this->N),\n+ Ke(),\n+ idx(),\n+ u()\n+{\n+ const std::string name = \"Encoder_polar_MK\";\n+ this->set_name(name);\n+ this->set_sys(false);\n+\n+ // dark cpp but I know what I'm doing... I suppose...\n+ auto kernel_matrices_bis = const_cast<std::vector<std::vector<std::vector<bool>>>*>(&this->kernel_matrices);\n+ auto stages_bis = const_cast<std::vector<uint32_t>*>(&this->stages);\n+ tools::read_polar_MK_code(code_path, *kernel_matrices_bis, *stages_bis);\n+\n+ this->Ke.resize(this->kernel_matrices.size());\n+ this->init_MK();\n+}\n+\n+template <typename B>\n+void Encoder_polar_MK<B>\n+::init_MK()\n+{\nsize_t biggest_kernel_size = 0;\n- for (auto ke = 0; ke < (int)kernel_matrices.size(); ke++)\n+ for (auto ke = 0; ke < (int)this->kernel_matrices.size(); ke++)\n{\n- Ke[ke].resize(kernel_matrices[ke].size() * kernel_matrices[ke].size());\n- biggest_kernel_size = std::max(biggest_kernel_size, kernel_matrices[ke].size());\n+ Ke[ke].resize(this->kernel_matrices[ke].size() * this->kernel_matrices[ke].size());\n+ biggest_kernel_size = std::max(biggest_kernel_size, this->kernel_matrices[ke].size());\n}\nidx.resize(biggest_kernel_size);\nu.resize(biggest_kernel_size);\n- for (auto s : stages)\n- if(s >= kernel_matrices.size())\n+ if (this->stages.size() == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'stages.size()' has to be higher than 0 (\"\n+ << \"'stages.size()' = \" << this->stages.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (this->stages.size() < this->kernel_matrices.size())\n+ {\n+ std::stringstream message;\n+ message << \"'stages.size()' has to be higher or equal to 'kernel_matrices.size()' (\"\n+ << \"'stages.size()' = \" << this->stages.size() << \", \"\n+ << \"'kernel_matrices.size()' = \" << this->kernel_matrices.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ for (auto s : this->stages)\n+ if(s >= this->kernel_matrices.size())\n{\nstd::stringstream message;\nmessage << \"'s' should not be higher than 'kernel_matrices.size()' (\"\n<< \"'s' = \" << s << \", \"\n- << \"'kernel_matrices.size()' = \" << kernel_matrices.size() << \").\";\n+ << \"'kernel_matrices.size()' = \" << this->kernel_matrices.size() << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n@@ -381,6 +520,7 @@ void Encoder_polar_MK<B>\n}\n}\n+\n// template <typename B>\n// bool Encoder_polar_MK<B>\n// ::is_codeword(const B *X_N)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK.hpp",
"diff": "#define ENCODER_POLAR_MK_HPP_\n#include <vector>\n+#include <string>\n#include \"Tools/Code/Polar/Frozenbits_notifier.hpp\"\n#include \"Tools/Algo/Matrix/Full_matrix/Full_matrix.hpp\"\n@@ -13,6 +14,9 @@ namespace aff3ct\nnamespace tools\n{\nstd::string display_kernel(const std::vector<std::vector<bool>>& pattern_bits);\n+void read_polar_MK_code(const std::string &code_path,\n+ std::vector<std::vector<std::vector<bool>>> &kernel_matrices,\n+ std::vector<uint32_t> &stages);\n}\n}\n@@ -40,8 +44,12 @@ public:\nconst std::vector<std::vector<std::vector<bool>>>& kernel_matrices,\nconst std::vector<uint32_t> &stages, const int n_frames = 1);\n+ Encoder_polar_MK(const int& K, const int& N, const std::vector<bool>& frozen_bits, const std::string &code_path,\n+ const int n_frames = 1);\n+\nvirtual ~Encoder_polar_MK() = default;\n+ void init_MK();\nvoid init();\n// bool is_codeword(const B *X_N);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK_sys.cpp",
"diff": "+#include <vector>\n+#include <cmath>\n+#include <map>\n+#include <sstream>\n+#include <fstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Math/utils.h\"\n+#include \"Tools/general_utils.h\"\n+\n+#include \"Encoder_polar_MK_sys.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+template <typename T = int32_t>\n+void kronecker_product(const std::vector<std::vector<T>>& A,\n+ const std::vector<std::vector<T>>& B,\n+ std::vector<std::vector<T>>& C)\n+{\n+ for (auto row_A = 0; row_A < (int)A.size(); row_A++)\n+ for (auto col_A = 0; col_A < (int)A[0].size(); col_A++)\n+ for (auto row_B = 0; row_B < (int)B.size(); row_B++)\n+ for (auto col_B = 0; col_B < (int)B[0].size(); col_B++)\n+ C[row_A * B.size() + row_B][col_A * B[0].size() + col_B] = A[row_A][col_A] * B[row_B][col_B];\n+}\n+\n+template <typename T = int32_t>\n+std::vector<std::vector<T>> kronecker_product(const std::vector<std::vector<T>>& A,\n+ const std::vector<std::vector<T>>& B)\n+{\n+ // verifications --------------------------------------------------------------------------------------------------\n+ if (A.size() == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'A.size()' should be higher than 0 ('A.size()' = \" << A.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (B.size() == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'B.size()' should be higher than 0 ('B.size()' = \" << B.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ for (auto l = 0; l < (int)A.size(); l++)\n+ {\n+ if (A[l].size() != A.size())\n+ {\n+ std::stringstream message;\n+ message << \"'A[l].size()' has to be equal to 'A.size()' ('l' = \" << l\n+ << \", 'A[l].size()' = \" << A[l].size()\n+ << \", 'A.size()' = \" << A.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+\n+ for (auto l = 0; l < (int)B.size(); l++)\n+ {\n+ if (B[l].size() != B.size())\n+ {\n+ std::stringstream message;\n+ message << \"'B[l].size()' has to be equal to 'B.size()' ('l' = \" << l\n+ << \", 'B[l].size()' = \" << B[l].size()\n+ << \", 'B.size()' = \" << B.size() << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ // ----------------------------------------------------------------------------------------------------------------\n+\n+ std::vector<std::vector<T>> C(A.size() * B.size(), std::vector<T>(A[0].size() * B[0].size()));\n+ kronecker_product(A, B, C);\n+ return C;\n+}\n+\n+template <typename B>\n+Encoder_polar_MK_sys<B>\n+::Encoder_polar_MK_sys(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n+ const std::vector<std::vector<bool>>& kernel_matrix, const int n_frames)\n+: Encoder_polar_MK<B>(K, N, frozen_bits, kernel_matrix, n_frames)\n+{\n+ const std::string name = \"Encoder_polar_MK_sys\";\n+ this->set_name(name);\n+ this->set_sys(true);\n+\n+ this->init();\n+}\n+\n+template <typename B>\n+Encoder_polar_MK_sys<B>\n+::Encoder_polar_MK_sys(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n+ const std::vector<std::vector<std::vector<bool>>>& kernel_matrices,\n+ const std::vector<uint32_t> &stages, const int n_frames)\n+: Encoder_polar_MK<B>(K, N, frozen_bits, kernel_matrices, stages, n_frames)\n+{\n+ const std::string name = \"Encoder_polar_MK_sys\";\n+ this->set_name(name);\n+ this->set_sys(true);\n+\n+ this->init();\n+}\n+\n+template <typename B>\n+Encoder_polar_MK_sys<B>\n+::Encoder_polar_MK_sys(const int& K, const int& N, const std::vector<bool>& frozen_bits, const std::string &code_path,\n+ const int n_frames)\n+: Encoder_polar_MK<B>(K, N, frozen_bits, code_path, n_frames)\n+{\n+ const std::string name = \"Encoder_polar_MK_sys\";\n+ this->set_name(name);\n+ this->set_sys(true);\n+\n+ this->init();\n+}\n+\n+template <typename B>\n+void Encoder_polar_MK_sys<B>\n+::init()\n+{\n+ // generate the \"G\" matrix from the \"kernel_matrices\"\n+ auto G = this->kernel_matrices[this->stages[0]];\n+ for (auto s = 1; s < (int)this->stages.size(); s++)\n+ G = kronecker_product<bool>(G, this->kernel_matrices[this->stages[s]]);\n+\n+ // compute the \"G x G\" product\n+ auto G_x_G = G;\n+ for (auto i = 0; i < (int)G.size(); i++)\n+ for (auto j = 0; j < (int)G.size(); j++)\n+ {\n+ uint32_t sum_r = 0;\n+ for (auto k = 0; k < (int)G.size(); k++)\n+ sum_r += (uint32_t)(G[i][k] & G[k][j]);\n+ G_x_G[i][j] = (bool)(sum_r & (B)1);\n+ }\n+\n+ // check if \"G x G\" is the identity matrix\n+ for (auto i = 0; i < (int)G_x_G.size(); i++)\n+ for (auto j = 0; j < (int)G_x_G.size(); j++)\n+ if (i == j && G_x_G[i][j] != true)\n+ {\n+ std::stringstream message;\n+ message << \"'G_x_G' has to be the identity matrix (\"\n+ << \"'i' = \" << i << \", \"\n+ << \"'j' = \" << j << \", \"\n+ << \"'G_x_G[i][j]' = \" << G_x_G[i][j] << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ else if (i != j && G_x_G[i][j] != false)\n+ {\n+ std::stringstream message;\n+ message << \"'G_x_G' has to be the identity matrix (\"\n+ << \"'i' = \" << i << \", \"\n+ << \"'j' = \" << j << \", \"\n+ << \"'G_x_G[i][j]' = \" << G_x_G[i][j] << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n+template <typename B>\n+void Encoder_polar_MK_sys<B>\n+::_encode(const B *U_K, B *X_N, const int frame_id)\n+{\n+ this->convert(U_K, X_N);\n+\n+ // first time encode\n+ this->light_encode(X_N);\n+\n+ for (auto i = 0; i < this->N; i++)\n+ X_N[i] = (B)(!this->frozen_bits[i]) && X_N[i];\n+\n+ // second time encode because of systematic encoder\n+ this->light_encode(X_N);\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::module::Encoder_polar_MK_sys<B_8>;\n+template class aff3ct::module::Encoder_polar_MK_sys<B_16>;\n+template class aff3ct::module::Encoder_polar_MK_sys<B_32>;\n+template class aff3ct::module::Encoder_polar_MK_sys<B_64>;\n+#else\n+template class aff3ct::module::Encoder_polar_MK_sys<B>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Encoder/Polar_MK/Encoder_polar_MK_sys.hpp",
"diff": "+#ifndef ENCODER_POLAR_MK_SYS_HPP_\n+#define ENCODER_POLAR_MK_SYS_HPP_\n+\n+#include \"Encoder_polar_MK.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int>\n+class Encoder_polar_MK_sys : public Encoder_polar_MK<B>\n+{\n+public:\n+ Encoder_polar_MK_sys(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n+ const std::vector<std::vector<bool>>& kernel_matrix = {{1,0},{1,1}}, const int n_frames = 1);\n+\n+ Encoder_polar_MK_sys(const int& K, const int& N, const std::vector<bool>& frozen_bits,\n+ const std::vector<std::vector<std::vector<bool>>>& kernel_matrices,\n+ const std::vector<uint32_t> &stages, const int n_frames = 1);\n+\n+ Encoder_polar_MK_sys(const int& K, const int& N, const std::vector<bool>& frozen_bits, const std::string &code_path,\n+ const int n_frames = 1);\n+\n+ virtual ~Encoder_polar_MK_sys() = default;\n+\n+ void init();\n+\n+protected:\n+ virtual void _encode(const B *U_K, B *X_N, const int frame_id);\n+};\n+}\n+}\n+\n+#endif // ENCODER_POLAR_MK_SYS_HPP_\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a systematic encoder for Polar_ML codes.
|
8,490 |
31.10.2018 16:59:15
| -3,600 |
cb32be08eb566b8b0c79729cf0767571ea622053
|
Fix colors maccro.
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -100,9 +100,9 @@ else()\nmessage(STATUS \"AFF3CT - Polar bit packing: off\")\nendif()\nif (AFF3CT_COLORS)\n+ add_definitions (-DAFF3CT_COLORS)\nmessage(STATUS \"AFF3CT - Terminal colors: on\")\nelse()\n- add_definitions (-DAFF3CT_NO_COLOR)\nmessage(STATUS \"AFF3CT - Terminal colors: off\")\nendif()\nif (AFF3CT_BACKTRACE AND NOT (WIN32 AND APPLE))\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Launcher/Launcher.cpp",
"new_path": "src/Factory/Launcher/Launcher.cpp",
"diff": "@@ -132,7 +132,7 @@ void factory::Launcher::parameters\ntools::arg_rank::ADV);\n-#ifdef AFF3CT_NO_COLOR\n+#ifdef AFF3CT_COLORS\nargs.add(\n{p+\"-no-colors\"},\ntools::None(),\n@@ -169,7 +169,7 @@ void factory::Launcher::parameters\ntools::exception::no_backtrace = vals.exist({\"except-no-bt\"});\ntools::exception::no_addr_to_line = !vals.exist({\"except-a2l\" });\n-#ifdef AFF3CT_NO_COLOR\n+#ifdef AFF3CT_COLORS\nif (vals.exist({p+\"-no-colors\"})) rang::setControlMode(rang::control::Off);\n#else\nrang::setControlMode(rang::control::Off);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix colors maccro.
|
8,490 |
31.10.2018 18:17:52
| -3,600 |
0622f90d8e061756537f1e74c2e8828caf55b4c8
|
Fix old school style CMake options.
|
[
{
"change_type": "MODIFY",
"old_path": ".gitlab-ci.yml",
"new_path": ".gitlab-ci.yml",
"diff": "@@ -41,7 +41,7 @@ build-linux-gcc-nointr:\n- export CXX=\"g++\"\n- export CFLAGS=\"-DMIPP_NO_INTRINSICS\"\n- export LFLAGS=\"-static -static-libgcc -static-libstdc++ -Wl,--whole-archive -lpthread -Wl,--no-whole-archive\"\n- - export CMAKE_OPT=\"-DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n- export NAME=\"build_linux_gcc_nointr\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n@@ -64,7 +64,7 @@ build-linux-gcc-x64-sse4.2:\n- export CXX=\"g++\"\n- export CFLAGS=\"-m64 -msse4.2\"\n- export LFLAGS=\"-static -static-libgcc -static-libstdc++ -Wl,--whole-archive -lpthread -Wl,--no-whole-archive\"\n- - export CMAKE_OPT=\"-DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n- export NAME=\"build_linux_gcc_x64_sse4.2\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n@@ -87,7 +87,7 @@ build-linux-gcc-x64-avx2:\n- export CXX=\"g++\"\n- export CFLAGS=\"-m64 -mavx2 -mfma\"\n- export LFLAGS=\"-static -static-libgcc -static-libstdc++ -Wl,--whole-archive -lpthread -Wl,--no-whole-archive\"\n- - export CMAKE_OPT=\"-DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n- export NAME=\"build_linux_gcc_x64_avx2\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n@@ -108,7 +108,7 @@ build-linux-gcc-8-bit:\n- export CC=\"gcc\"\n- export CXX=\"g++\"\n- export CFLAGS=\"-march=native\"\n- - export CMAKE_OPT=\"-DAFF3CT_8BIT_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_8BIT_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n- export NAME=\"build_linux_gcc_8_bit\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n@@ -129,7 +129,7 @@ build-linux-gcc-mpi:\n- export CC=\"gcc\"\n- export CXX=\"g++\"\n- export CFLAGS=\"-march=native\"\n- - export CMAKE_OPT=\"-DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON -DAFF3CT_MPI=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON -DAFF3CT_MPI=ON\"\n- export NAME=\"build_linux_gcc_mpi\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n@@ -151,7 +151,7 @@ build-linux-gcc-systemc:\n- export CC=\"gcc\"\n- export CXX=\"g++\"\n- export CFLAGS=\"-march=native -Wno-deprecated-declarations\"\n- - export CMAKE_OPT=\"-DAFF3CT_MULTI_PREC=ON -DAFF3CT_SYSTEMC=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_MULTI_PREC=ON -DAFF3CT_SYSTEMC=ON\"\n- export NAME=\"build_linux_gcc_systemc\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n@@ -171,7 +171,7 @@ build-linux-clang:\n- export CC=\"clang\"\n- export CXX=\"clang++\"\n- export CFLAGS=\"\"\n- - export CMAKE_OPT=\"-DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n- export NAME=\"build_linux_clang\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n@@ -191,7 +191,7 @@ build-linux-gcc-4.8:\n- export CC=\"gcc-4.8\"\n- export CXX=\"g++-4.8\"\n- export CFLAGS=\"-march=native\"\n- - export CMAKE_OPT=\"-DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON\"\n- export NAME=\"build_linux_gcc-4.8\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n@@ -214,7 +214,7 @@ build-linux-icpc:\n- export CC=\"icc\"\n- export CXX=\"icpc\"\n- export CFLAGS=\"-march=native -std=c++11\"\n- - export CMAKE_OPT=\"-DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON -DAFF3CT_LINK_MKL=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_MULTI_PREC=ON -DAFF3CT_LINK_GSL=ON -DAFF3CT_LINK_MKL=ON\"\n- export NAME=\"build_linux_icpc\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n@@ -234,7 +234,7 @@ build-windows-gcc-x86-sse4.2:\nscript:\n- set \"CFLAGS=-m32 -msse4.2\"\n- set \"LFLAGS=-static -static-libgcc -static-libstdc++\"\n- - set \"CMAKE_OPT=-DAFF3CT_MULTI_PREC=ON -DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON\"\n+ - set \"CMAKE_OPT=-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_MULTI_PREC=ON\"\n- set \"NAME=build_windows_gcc_x86_sse4.2\"\n- call ./ci/tools/threads.bat\n- ./ci/build-windows-gcc.bat\n@@ -254,7 +254,7 @@ build-windows-gcc-x64-avx2:\nscript:\n- set \"CFLAGS=-m64 -mavx2\"\n- set \"LFLAGS=-static -static-libgcc -static-libstdc++\"\n- - set \"CMAKE_OPT=-DAFF3CT_MULTI_PREC=ON -DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON\"\n+ - set \"CMAKE_OPT=-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_MULTI_PREC=ON\"\n- set \"NAME=build_windows_gcc_x64_avx2\"\n- call ./ci/tools/threads.bat\n- ./ci/build-windows-gcc.bat\n@@ -272,7 +272,7 @@ build-windows-msvc-avx:\n- build_windows_msvc_avx\nscript:\n- set \"CFLAGS=/arch:AVX\"\n- - set \"CMAKE_OPT=-DAFF3CT_MULTI_PREC=ON -DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON\"\n+ - set \"CMAKE_OPT=-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_MULTI_PREC=ON\"\n- set \"NAME=build_windows_msvc_avx\"\n- call ./ci/tools/threads.bat\n- ./ci/build-windows-msvc.bat\n@@ -292,7 +292,7 @@ build-macos-clang-x64-sse4.2:\n- export CC=\"clang\"\n- export CXX=\"clang++\"\n- export CFLAGS=\"-m64 -msse4.2\"\n- - export CMAKE_OPT=\"-DAFF3CT_MULTI_PREC=ON\"\n+ - export CMAKE_OPT=\"-DAFF3CT_COMPILE_EXE=ON -DAFF3CT_COMPILE_STATIC_LIB=ON -DAFF3CT_COMPILE_SHARED_LIB=ON -DAFF3CT_MULTI_PREC=ON\"\n- export NAME=\"build_macos_clang_x64_sse4.2\"\n- source ./ci/tools/threads.sh\n- ./ci/build-linux-macos.sh\n"
},
{
"change_type": "MODIFY",
"old_path": "ci/build-linux-macos.sh",
"new_path": "ci/build-linux-macos.sh",
"diff": "@@ -31,14 +31,14 @@ fi\nif [ -z \"$LFLAGS\" ]\nthen\ncmake .. -G\"Unix Makefiles\" -DCMAKE_CXX_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX \\\n- -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=\"-Wall -funroll-loops -DENABLE_COOL_BASH $CFLAGS\" \\\n- -DENABLE_EXEC=ON -DENABLE_STATIC_LIB=ON -DENABLE_SHARED_LIB=ON $CMAKE_OPT\n+ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=\"-Wall -funroll-loops $CFLAGS\" \\\n+ $CMAKE_OPT\nrc=$?; if [[ $rc != 0 ]]; then exit $rc; fi\nelse\ncmake .. -G\"Unix Makefiles\" -DCMAKE_CXX_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX \\\n- -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=\"-Wall -funroll-loops -DENABLE_COOL_BASH $CFLAGS\" \\\n+ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=\"-Wall -funroll-loops $CFLAGS\" \\\n-DCMAKE_EXE_LINKER_FLAGS=\"$LFLAGS\" \\\n- -DENABLE_EXEC=ON -DENABLE_STATIC_LIB=ON -DENABLE_SHARED_LIB=ON $CMAKE_OPT\n+ $CMAKE_OPT\nrc=$?; if [[ $rc != 0 ]]; then exit $rc; fi\nfi\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix old school style CMake options.
|
8,490 |
31.10.2018 18:18:33
| -3,600 |
5b0205af6fefd64b4fcc458cac4a1bcf660f7be9
|
Add the 'install' directives in the CMake.
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -313,3 +313,32 @@ if (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\" OR\n\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Intel\")\naff3ct_link_libraries (-lpthread)\nendif()\n+\n+# ---------------------------------------------------------------------------------------------------------------------\n+# ------------------------------------------------------------------------------------------------------------- INSTALL\n+# ---------------------------------------------------------------------------------------------------------------------\n+\n+if (AFF3CT_COMPILE_EXE)\n+ install(TARGETS aff3ct-bin RUNTIME DESTINATION bin)\n+endif()\n+if (AFF3CT_COMPILE_SHARED_LIB)\n+ install(TARGETS aff3ct-shared-lib LIBRARY DESTINATION lib)\n+endif()\n+if (AFF3CT_COMPILE_STATIC_LIB)\n+ install(TARGETS aff3ct-static-lib ARCHIVE DESTINATION lib)\n+endif()\n+\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct\n+ FILES_MATCHING PATTERN \"*.h\")\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct\n+ FILES_MATCHING PATTERN \"*.hpp\")\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct\n+ FILES_MATCHING PATTERN \"*.hxx\")\n+if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/conf/itl/GSM-LDPC_4224.itl\")\n+ install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/conf/\" DESTINATION share/aff3ct/conf\n+ FILES_MATCHING PATTERN \"*\")\n+endif()\n+if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/refs/BCH/AWGN/BPSK/ALGEBRAIC/BCH_N7_K4_algebraic_T1.txt\")\n+ install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/refs/\" DESTINATION share/aff3ct/refs\n+ FILES_MATCHING PATTERN \"*.txt\")\n+endif()\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the 'install' directives in the CMake.
|
8,490 |
31.10.2018 18:50:52
| -3,600 |
2f064568cc25c0563c8150441f1c7f34bf4ae5d1
|
Simplify the CMakeList a little bit.
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -334,11 +334,11 @@ install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct\nFILES_MATCHING PATTERN \"*.hpp\")\ninstall(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct\nFILES_MATCHING PATTERN \"*.hxx\")\n-if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/conf/itl/GSM-LDPC_4224.itl\")\n+if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/conf/cde/\")\ninstall(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/conf/\" DESTINATION share/aff3ct/conf\nFILES_MATCHING PATTERN \"*\")\nendif()\n-if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/refs/BCH/AWGN/BPSK/ALGEBRAIC/BCH_N7_K4_algebraic_T1.txt\")\n+if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/refs/BCH/\")\ninstall(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/refs/\" DESTINATION share/aff3ct/refs\nFILES_MATCHING PATTERN \"*.txt\")\nendif()\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simplify the CMakeList a little bit.
|
8,490 |
31.10.2018 18:51:56
| -3,600 |
efd9cd73f6e937f147cf66d9b890bdf8fe04778c
|
Improve the CI builds following the Linux style.
|
[
{
"change_type": "MODIFY",
"old_path": "ci/build-linux-macos.sh",
"new_path": "ci/build-linux-macos.sh",
"diff": "@@ -45,11 +45,11 @@ fi\nmake -j $THREADS -k\nrc=$?; if [[ $rc != 0 ]]; then exit $rc; fi\n-mkdir $NAME $NAME/bin $NAME/lib $NAME/inc\n+mkdir $NAME $NAME/bin $NAME/lib $NAME/include $NAME/include/aff3ct\ncp bin/aff3ct $NAME/bin/aff3ct\ncp lib/libaff3ct.a $NAME/lib/libaff3ct.a\n-cp -r ../src/* $NAME/inc/\n-find $NAME/inc/ -type f -follow -print | grep \"[.]cpp$\" | xargs rm -f\n-find $NAME/inc/ -type f -follow -print | grep \"[.]cpp.in$\" | xargs rm -f\n+cp -r ../src/* $NAME/include/aff3ct/\n+find $NAME/include/aff3ct/ -type f -follow -print | grep \"[.]cpp$\" | xargs rm -f\n+find $NAME/include/aff3ct/ -type f -follow -print | grep \"[.]cpp.in$\" | xargs rm -f\nmv $NAME ../\n"
},
{
"change_type": "MODIFY",
"old_path": "ci/build-windows-gcc.bat",
"new_path": "ci/build-windows-gcc.bat",
"diff": "@@ -10,10 +10,11 @@ if %ERRORLEVEL% neq 0 exit /B %ERRORLEVEL%\nmkdir %NAME%\nmkdir %NAME%\\bin\\\nmkdir %NAME%\\lib\\\n-mkdir %NAME%\\inc\\\n+mkdir %NAME%\\include\\\n+mkdir %NAME%\\include\\aff3ct\\\ncopy bin\\aff3ct.exe %NAME%\\bin\\aff3ct.exe\ncopy lib\\libaff3ct.a %NAME%\\lib\\aff3ct.lib\n-xcopy ..\\src\\* %NAME%\\inc\\ /s /e\n+xcopy ..\\src\\* %NAME%\\include\\aff3ct\\ /s /e\nmove %NAME% ..\\\n"
},
{
"change_type": "MODIFY",
"old_path": "ci/build-windows-msvc.bat",
"new_path": "ci/build-windows-msvc.bat",
"diff": "@@ -14,10 +14,11 @@ if %ERRORLEVEL% neq 0 exit /B %ERRORLEVEL%\nmkdir %NAME%\nmkdir %NAME%\\bin\\\nmkdir %NAME%\\lib\\\n-mkdir %NAME%\\inc\\\n+mkdir %NAME%\\include\\\n+mkdir %NAME%\\include\\aff3ct\\\ncopy bin\\Release\\aff3ct.exe %NAME%\\bin\\\ncopy lib\\Release\\aff3ct.lib %NAME%\\lib\\\n-xcopy ..\\src\\* %NAME%\\inc\\ /s /e\n+xcopy ..\\src\\* %NAME%\\include\\aff3ct\\ /s /e\nmove %NAME% ..\\\n"
},
{
"change_type": "MODIFY",
"old_path": "ci/deploy-builds-linux.sh",
"new_path": "ci/deploy-builds-linux.sh",
"diff": "@@ -52,10 +52,14 @@ do\nZIP_NAME=$(echo \"${BUILD/build/$PREFIX}\")\nZIP_NAME=$(echo \"${ZIP_NAME/\\./\\_}_$GIT_HASH.zip\")\n- find $BUILD/inc/ -type f -follow -print | grep \"[.]cpp$\" | xargs rm -f\n- find $BUILD/inc/ -type f -follow -print | grep \"[.]cpp.in$\" | xargs rm -f\n- cp -r conf $BUILD/\n- rm -rf $BUILD/conf/.git\n+ find $BUILD/include/aff3ct/ -type f -follow -print | grep \"[.]cpp$\" | xargs rm -f\n+ find $BUILD/include/aff3ct/ -type f -follow -print | grep \"[.]cpp.in$\" | xargs rm -f\n+ mkdir $BUILD/share\n+ mkdir $BUILD/share/aff3ct\n+ cp -r conf $BUILD/share/aff3ct/\n+ cp -r refs $BUILD/share/aff3ct/\n+ rm -rf $BUILD/share/aff3ct/conf/.git\n+ rm -rf $BUILD/share/aff3ct/refs/.git\nzip -r $ZIP_NAME $BUILD\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve the CI builds following the Linux style.
|
8,490 |
01.11.2018 01:18:25
| -3,600 |
0b09d8b41fcddbfeea6316ab668cb1fd02baf3b1
|
Improve the 'CMakeList.txt' to automatically generate CMake config files.
|
[
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "@@ -12,6 +12,8 @@ src_files.txt\n.idea/\n.vs\nCMakeSettings.json\n+aff3ct-config.cmake\n+aff3ct-config-version.cmake\n.scannerwork/\nbuild*/\n"
},
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "-# CMake entry point\n+# ---------------------------------------------------------------------------------------------------------------------\n+# ------------------------------------------------------------------------------------------------------- CMAKE PROJECT\n+# ---------------------------------------------------------------------------------------------------------------------\n+\ncmake_minimum_required (VERSION 3.0.2)\ncmake_policy(SET CMP0054 NEW)\n-\nproject (aff3ct)\n+# ---------------------------------------------------------------------------------------------------------------------\n+# ------------------------------------------------------------------------------------------------------- CMAKE OPTIONS\n+# ---------------------------------------------------------------------------------------------------------------------\n+\n+option (AFF3CT_COMPILE_EXE \"Compile the executable\" ON )\n+option (AFF3CT_COMPILE_STATIC_LIB \"Compile the static library\" OFF)\n+option (AFF3CT_COMPILE_SHARED_LIB \"Compile the shared library\" OFF)\n+option (AFF3CT_LINK_GSL \"Link with the GSL library (used in the channels)\" OFF)\n+option (AFF3CT_LINK_MKL \"Link with the MKL library (used in the channels)\" OFF)\n+option (AFF3CT_SYSTEMC \"Enable the SystemC support\" OFF)\n+option (AFF3CT_SYSTEMC_MODULE \"Enable the SystemC support (only for the modules)\" OFF)\n+option (AFF3CT_MPI \"Enable the MPI support\" OFF)\n+option (AFF3CT_POLAR_BIT_PACKING \"Enable the bit packing technique for Polar code SC decoding\" ON )\n+option (AFF3CT_COLORS \"Enable the colors in the terminal\" ON )\n+option (AFF3CT_BACKTRACE \"Enable the backtrace display when and exception is raised (for Unix systems)\" ON )\n+option (AFF3CT_MULTI_PREC \"Compile in 8-bit, 16-bit, 32-bit and 64-bit precisions\" ON )\n+option (AFF3CT_8BIT_PREC \"Compile only in 8-bit precision (fixed-point)\" OFF)\n+option (AFF3CT_16BIT_PREC \"Compile only in 16-bit precision (fixed-point)\" OFF)\n+option (AFF3CT_32BIT_PREC \"Compile only in 32-bit precision (floating-point)\" OFF)\n+option (AFF3CT_64BIT_PREC \"Compile only in 64-bit precision (floating-point)\" OFF)\n+\n+if(AFF3CT_COMPILE_STATIC_LIB OR AFF3CT_COMPILE_SHARED_LIB)\n+ set(AFF3CT_COMPILE_LIB ON)\n+else()\n+ set(AFF3CT_COMPILE_LIB OFF)\n+endif()\n+\n+# ---------------------------------------------------------------------------------------------------------------------\n+# ------------------------------------------------------------------------------------------------- CMAKE CONFIGURATION\n+# ---------------------------------------------------------------------------------------------------------------------\n+\nset (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} \"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/\")\nset (CMAKE_MACOSX_RPATH 1)\n@@ -21,13 +54,56 @@ set (LIBRARY_OUTPUT_PATH lib/)\n# Generate the source files list\nfile (GLOB_RECURSE source_files src/*)\n-# Auto generate a header containing the last GIT SHA1\n+# Lists used to generate the CMake config files\n+set(AFF3CT_DEFINITIONS \"\")\n+set(AFF3CT_INCLUDE_DIRS \"\")\n+set(AFF3CT_LIBRARIES \"\")\n+\n+# ---------------------------------------------------------------------------------------------------------------------\n+# ------------------------------------------------------------------------------------------------ GET VERSION FROM GIT\n+# ---------------------------------------------------------------------------------------------------------------------\n+\ninclude(GetGitRevisionDescription)\nget_git_head_revision(GIT_REFSPEC GIT_SHA1)\ngit_describe(GIT_VERSION \"--tags\")\n-configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/version.cpp.in\" \"${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/version.cpp\" @ONLY)\n+\n+string(REGEX REPLACE \"^v\" \"\" GIT_VERSION_RMV ${GIT_VERSION})\n+string(REGEX REPLACE \"-.*\" \"\" GIT_VERSION_MMP ${GIT_VERSION_RMV})\n+string(REGEX REPLACE \"^.*-\" \"\" GIT_HASH ${GIT_VERSION_RMV})\n+string( REPLACE \"-\" \"\" GIT_BUILD ${GIT_VERSION_RMV})\n+string( REPLACE \"${GIT_VERSION_MMP}\" \"\" GIT_BUILD ${GIT_BUILD})\n+string( REPLACE \"${GIT_HASH}\" \"\" GIT_BUILD ${GIT_BUILD})\n+string(REGEX REPLACE \"[.].*\" \"\" GIT_VERSION_MAJOR ${GIT_VERSION_MMP})\n+string( REPLACE \"${GIT_VERSION_MAJOR}.\" \"\" GIT_VERSION_MINOR ${GIT_VERSION_MMP})\n+string(REGEX REPLACE \"[.].*\" \"\" GIT_VERSION_MINOR ${GIT_VERSION_MINOR})\n+string( REPLACE \"${GIT_VERSION_MAJOR}.\" \"\" GIT_VERSION_PATCH ${GIT_VERSION_MMP})\n+string( REPLACE \"${GIT_VERSION_MINOR}.\" \"\" GIT_VERSION_PATCH ${GIT_VERSION_PATCH})\n+string(REGEX REPLACE \"[.].*\" \"\" GIT_VERSION_PATCH ${GIT_VERSION_PATCH})\n+\n+message(STATUS \"AFF3CT - Git Version: ${GIT_VERSION_MAJOR}.${GIT_VERSION_MINOR}.${GIT_VERSION_PATCH}\")\n+message(STATUS \"AFF3CT - Git Build: ${GIT_BUILD}\")\n+message(STATUS \"AFF3CT - Git Hash: ${GIT_HASH}\")\n+\n+if((\"GIT_BUILD\" STREQUAL \"\") OR (\"GIT_HASH\" STREQUAL \"\"))\n+ set(GIT_TAIL \"\")\n+else()\n+ set(GIT_TAIL \"-${GIT_BUILD}-${GIT_HASH}\")\n+endif()\n+\n+# ---------------------------------------------------------------------------------------------------------------------\n+# ----------------------------------------------------------------------------------------------- GENERATE VERSION FILE\n+# ---------------------------------------------------------------------------------------------------------------------\n+\n+# Auto generate a header containing the last GIT SHA1\n+configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/version.cpp.in\"\n+ \"${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/version.cpp\" @ONLY)\n+\nlist(APPEND source_files \"${CMAKE_CURRENT_SOURCE_DIR}/src/Tools/version.cpp\")\n+# ---------------------------------------------------------------------------------------------------------------------\n+# ------------------------------------------------------------------------------------------------------ CREATE FILTERS\n+# ---------------------------------------------------------------------------------------------------------------------\n+\n# Filters creation for IDEs (tested on Visual Studio and based on the \"source_group\" function)\nfunction(assign_source_group)\nforeach(_source IN ITEMS ${ARGN})\n@@ -44,32 +120,15 @@ endfunction(assign_source_group)\nassign_source_group(${source_files})\n-# ---------------------------------------------------------------------------------------------------------------------\n-# ------------------------------------------------------------------------------------------------------- CMAKE OPTIONS\n-# ---------------------------------------------------------------------------------------------------------------------\n-\n-# Command line options\n-option (AFF3CT_COMPILE_EXE \"Compile the executable\" ON )\n-option (AFF3CT_COMPILE_STATIC_LIB \"Compile the static library\" OFF)\n-option (AFF3CT_COMPILE_SHARED_LIB \"Compile the shared library\" OFF)\n-option (AFF3CT_LINK_GSL \"Link with the GSL library (used in the channels)\" OFF)\n-option (AFF3CT_LINK_MKL \"Link with the MKL library (used in the channels)\" OFF)\n-option (AFF3CT_SYSTEMC \"Enable the SystemC support\" OFF)\n-option (AFF3CT_SYSTEMC_MODULE \"Enable the SystemC support (only for the modules)\" OFF)\n-option (AFF3CT_MPI \"Enable the MPI support\" OFF)\n-option (AFF3CT_POLAR_BIT_PACKING \"Enable the bit packing technique for Polar code SC decoding\" ON )\n-option (AFF3CT_COLORS \"Enable the colors in the terminal\" ON )\n-option (AFF3CT_BACKTRACE \"Enable the backtrace display when and exception is raised (for Unix systems)\" ON )\n-option (AFF3CT_MULTI_PREC \"Compile in 8-bit, 16-bit, 32-bit and 64-bit precisions\" ON )\n-option (AFF3CT_8BIT_PREC \"Compile only in 8-bit precision (fixed-point)\" OFF)\n-option (AFF3CT_16BIT_PREC \"Compile only in 16-bit precision (fixed-point)\" OFF)\n-option (AFF3CT_32BIT_PREC \"Compile only in 32-bit precision (floating-point)\" OFF)\n-option (AFF3CT_64BIT_PREC \"Compile only in 64-bit precision (floating-point)\" OFF)\n-\n# ---------------------------------------------------------------------------------------------------------------------\n# ------------------------------------------------------------------------------------ COMPILER OPTIONS AND DEFINITIONS\n# ---------------------------------------------------------------------------------------------------------------------\n+macro (aff3ct_add_definitions def)\n+ add_definitions (${def})\n+ list(APPEND AFF3CT_DEFINITIONS ${def})\n+endmacro()\n+\n# by compiler\nif (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\" OR \"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"AppleClang\")\nadd_compile_options(-Wno-overloaded-virtual)\n@@ -82,8 +141,8 @@ endif()\n# by system\nif (WIN32) # for Windows operating system in general\nset (WINDOWS_VISTA 0x0600)\n- add_definitions (-D_WIN32_WINNT=${WINDOWS_VISTA})\n- add_definitions (-DNOMINMAX)\n+ aff3ct_add_definitions (-D_WIN32_WINNT=${WINDOWS_VISTA})\n+ aff3ct_add_definitions (-DNOMINMAX)\nmessage(STATUS \"AFF3CT - System: Windows\")\nelseif (APPLE) # for macOS\nmessage(STATUS \"AFF3CT - System: macOS\")\n@@ -94,37 +153,37 @@ endif()\n# common\nif (AFF3CT_POLAR_BIT_PACKING)\n- add_definitions (-DAFF3CT_POLAR_BIT_PACKING)\n+ aff3ct_add_definitions (-DAFF3CT_POLAR_BIT_PACKING)\nmessage(STATUS \"AFF3CT - Polar bit packing: on\")\nelse()\nmessage(STATUS \"AFF3CT - Polar bit packing: off\")\nendif()\nif (AFF3CT_COLORS)\n- add_definitions (-DAFF3CT_COLORS)\n+ aff3ct_add_definitions (-DAFF3CT_COLORS)\nmessage(STATUS \"AFF3CT - Terminal colors: on\")\nelse()\nmessage(STATUS \"AFF3CT - Terminal colors: off\")\nendif()\nif (AFF3CT_BACKTRACE AND NOT (WIN32 AND APPLE))\n- add_definitions (-DAFF3CT_BACKTRACE)\n+ aff3ct_add_definitions (-DAFF3CT_BACKTRACE)\nmessage(STATUS \"AFF3CT - Backtrace: on\")\nelse()\nmessage(STATUS \"AFF3CT - Backtrace: off\")\nendif()\nif (AFF3CT_8BIT_PREC)\n- add_definitions (-DAFF3CT_8BIT_PREC)\n+ aff3ct_add_definitions (-DAFF3CT_8BIT_PREC)\nmessage(STATUS \"AFF3CT - Precision: 8-bit\")\nelseif(AFF3CT_16BIT_PREC)\n- add_definitions (-DAFF3CT_16BIT_PREC)\n+ aff3ct_add_definitions (-DAFF3CT_16BIT_PREC)\nmessage(STATUS \"AFF3CT - Precision: 16-bit\")\nelseif (AFF3CT_32BIT_PREC)\n- add_definitions (-DAFF3CT_32BIT_PREC)\n+ aff3ct_add_definitions (-DAFF3CT_32BIT_PREC)\nmessage(STATUS \"AFF3CT - Precision: 32-bit\")\nelseif (AFF3CT_64BIT_PREC)\n- add_definitions (-DAFF3CT_64BIT_PREC)\n+ aff3ct_add_definitions (-DAFF3CT_64BIT_PREC)\nmessage(STATUS \"AFF3CT - Precision: 64-bit\")\nelse()\n- add_definitions (-DAFF3CT_MULTI_PREC)\n+ aff3ct_add_definitions (-DAFF3CT_MULTI_PREC)\nmessage(STATUS \"AFF3CT - Precision: 8/16/32/64-bit\")\nendif()\n@@ -142,7 +201,7 @@ endif()\n# MIPP\nif (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/lib/MIPP/src/mipp.h\")\n- add_definitions (-DMIPP_ENABLE_BACKTRACE)\n+ aff3ct_add_definitions (-DMIPP_ENABLE_BACKTRACE)\ninclude_directories (\"${CMAKE_CURRENT_SOURCE_DIR}/lib/MIPP/src/\")\nmessage(STATUS \"AFF3CT - Header found: MIPP\")\nelse ()\n@@ -205,6 +264,11 @@ if (AFF3CT_COMPILE_STATIC_LIB)\nmessage(STATUS \"AFF3CT - Compile: static library\")\nendif (AFF3CT_COMPILE_STATIC_LIB)\n+macro (aff3ct_include_directories dir)\n+ include_directories (${dir})\n+ list(APPEND AFF3CT_INCLUDE_DIRS ${dir})\n+endmacro()\n+\nmacro (aff3ct_link_libraries lib)\nif (AFF3CT_COMPILE_EXE)\ntarget_link_libraries (aff3ct-bin ${lib})\n@@ -215,6 +279,7 @@ macro (aff3ct_link_libraries lib)\nif (AFF3CT_COMPILE_STATIC_LIB)\ntarget_link_libraries (aff3ct-static-lib ${lib})\nendif (AFF3CT_COMPILE_STATIC_LIB)\n+ list(APPEND AFF3CT_LIBRARIES ${lib})\nendmacro()\n# ---------------------------------------------------------------------------------------------------------------------\n@@ -223,24 +288,24 @@ endmacro()\n# GSL\nif (AFF3CT_LINK_GSL)\n- add_definitions(\"-DAFF3CT_CHANNEL_GSL\")\n+ aff3ct_add_definitions(\"-DAFF3CT_CHANNEL_GSL\")\nfind_package (GSL REQUIRED)\nif (GSL_FOUND)\nmessage(STATUS \"AFF3CT - Library found: GSL\")\n- include_directories (${GSL_INCLUDE_DIRS})\n+ aff3ct_include_directories (${GSL_INCLUDE_DIRS})\naff3ct_link_libraries (\"${GSL_LIBRARIES}\")\nendif (GSL_FOUND)\nendif (AFF3CT_LINK_GSL)\n# MKL\nif (AFF3CT_LINK_MKL)\n- add_definitions(\"-DAFF3CT_CHANNEL_MKL\")\n+ aff3ct_add_definitions(\"-DAFF3CT_CHANNEL_MKL\")\nfind_package (MKL REQUIRED)\nif (MKL_FOUND)\nmessage(STATUS \"AFF3CT - Library found: MKL\")\n- include_directories (${MKL_INCLUDE_DIRS})\n+ aff3ct_include_directories (${MKL_INCLUDE_DIRS})\naff3ct_link_libraries (\"${MKL_MINIMAL_LIBRARIES}\")\nendif (MKL_FOUND)\nendif (AFF3CT_LINK_MKL)\n@@ -248,35 +313,35 @@ endif (AFF3CT_LINK_MKL)\n# SystemC\nif (AFF3CT_SYSTEMC)\nif (AFF3CT_SYSTEMC_MODULE)\n- add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\n+ aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\nelse ()\n- add_definitions (\"-DAFF3CT_SYSTEMC\")\n- add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\n+ aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC\")\n+ aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\nendif (AFF3CT_SYSTEMC_MODULE)\nfind_package (SystemC REQUIRED)\nif (SystemC_FOUND)\nmessage(STATUS \"AFF3CT - Library found: SystemC\")\n- include_directories (${SystemC_INCLUDE_DIRS})\n+ aff3ct_include_directories (${SystemC_INCLUDE_DIRS})\naff3ct_link_libraries (\"${SystemC_LIBRARIES}\")\nendif (SystemC_FOUND)\nfind_package (TLM REQUIRED)\nif (TLM_FOUND)\nmessage(STATUS \"AFF3CT - Library found: TLM\")\n- include_directories (${TLM_INCLUDE_DIRS})\n+ aff3ct_include_directories (${TLM_INCLUDE_DIRS})\nendif (TLM_FOUND)\nendif (AFF3CT_SYSTEMC)\n# MPI\nif (AFF3CT_MPI)\n- add_definitions (\"-DAFF3CT_ENABLE_MPI\")\n+ aff3ct_add_definitions (\"-DAFF3CT_ENABLE_MPI\")\nfind_package (MPI REQUIRED)\nif (MPI_CXX_FOUND)\nmessage(STATUS \"AFF3CT - Library found: MPI\")\n- include_directories (${MPI_CXX_INCLUDE_PATH})\n+ aff3ct_include_directories (${MPI_CXX_INCLUDE_PATH})\naff3ct_link_libraries (\"${MPI_CXX_LIBRARIES}\")\nif (MPI_CXX_COMPILE_FLAGS)\n@@ -314,31 +379,57 @@ if (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\" OR\naff3ct_link_libraries (-lpthread)\nendif()\n+# ---------------------------------------------------------------------------------------------------------------------\n+# ----------------------------------------------------------------------------------------- GENERATE CMAKE CONFIG FILES\n+# ---------------------------------------------------------------------------------------------------------------------\n+\n+# Auto generate cmake config files to link with AFF3CT\n+configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config.cmake.in\"\n+ \"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config.cmake\" @ONLY)\n+configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config-version.cmake.in\"\n+ \"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config-version.cmake\" @ONLY)\n+\n# ---------------------------------------------------------------------------------------------------------------------\n# ------------------------------------------------------------------------------------------------------------- INSTALL\n# ---------------------------------------------------------------------------------------------------------------------\nif (AFF3CT_COMPILE_EXE)\n- install(TARGETS aff3ct-bin RUNTIME DESTINATION bin)\n+ install(TARGETS aff3ct-bin RUNTIME DESTINATION bin/aff3ct-${GIT_VERSION_RMV})\nendif()\nif (AFF3CT_COMPILE_SHARED_LIB)\n- install(TARGETS aff3ct-shared-lib LIBRARY DESTINATION lib)\n+ install(TARGETS aff3ct-shared-lib LIBRARY DESTINATION lib/aff3ct-${GIT_VERSION_RMV})\nendif()\nif (AFF3CT_COMPILE_STATIC_LIB)\n- install(TARGETS aff3ct-static-lib ARCHIVE DESTINATION lib)\n+ install(TARGETS aff3ct-static-lib ARCHIVE DESTINATION lib/aff3ct-${GIT_VERSION_RMV})\nendif()\n-install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/aff3ct\nFILES_MATCHING PATTERN \"*.h\")\n-install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/aff3ct\n+ FILES_MATCHING PATTERN \"*.hpp\")\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/aff3ct\n+ FILES_MATCHING PATTERN \"*.hxx\")\n+\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib/CLI11/include/CLI/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/CLI11\nFILES_MATCHING PATTERN \"*.hpp\")\n-install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib/date/include/date/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/date\n+ FILES_MATCHING PATTERN \"*.h\")\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib/MIPP/src/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/MIPP\n+ FILES_MATCHING PATTERN \"*.h\")\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib/MIPP/src/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/MIPP\nFILES_MATCHING PATTERN \"*.hxx\")\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib/MSVC/include/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/dirent\n+ FILES_MATCHING PATTERN \"*.h\")\n+install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib/rang/include/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/rang\n+ FILES_MATCHING PATTERN \"*.hpp\")\n+\nif (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/conf/cde/\")\n- install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/conf/\" DESTINATION share/aff3ct/conf\n+ install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/conf/\" DESTINATION share/aff3ct-${GIT_VERSION_RMV}/conf\nFILES_MATCHING PATTERN \"*\")\nendif()\nif (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/refs/BCH/\")\n- install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/refs/\" DESTINATION share/aff3ct/refs\n+ install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/refs/\" DESTINATION share/aff3ct-${GIT_VERSION_RMV}/refs\nFILES_MATCHING PATTERN \"*.txt\")\nendif()\n+install(FILES \"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config.cmake\" \"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config-version.cmake\"\n+ DESTINATION lib/cmake/aff3ct-${GIT_VERSION_RMV})\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "aff3ct-config-version.cmake.in",
"diff": "+set(PACKAGE_VERSION \"@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@\")\n+\n+# Check whether the requested PACKAGE_FIND_VERSION is compatible\n+if(\"${PACKAGE_VERSION}\" VERSION_LESS \"${PACKAGE_FIND_VERSION}\")\n+ set(PACKAGE_VERSION_COMPATIBLE FALSE)\n+else()\n+ set(PACKAGE_VERSION_COMPATIBLE TRUE)\n+ if (\"${PACKAGE_VERSION}\" VERSION_EQUAL \"${PACKAGE_FIND_VERSION}\")\n+ set(PACKAGE_VERSION_EXACT TRUE)\n+ endif()\n+endif()\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "aff3ct-config.cmake.in",
"diff": "+# - Config file for the AFF3CT package\n+# It defines the following variables\n+# AFF3CT_EXE - true if an executable has been compiled\n+# AFF3CT_LIB - true if a library has been compiled\n+# AFF3CT_STATIC - true if the library has been compiled statically\n+# AFF3CT_INCLUDE_DIRS - include directories for AFF3CT\n+# AFF3CT_LIBRARIES - libraries to link against\n+# AFF3CT_EXECUTABLE - the AFF3CT executable\n+# AFF3CT_DEFINITIONS - the list of preprocessor definitions\n+\n+set(AFF3CT_EXE @AFF3CT_COMPILE_EXE@)\n+set(AFF3CT_LIB @AFF3CT_COMPILE_LIB@)\n+set(AFF3CT_STATIC @AFF3CT_COMPILE_STATIC_LIB@)\n+set(AFF3CT_INCLUDE_DIRS \"@AFF3CT_INCLUDE_DIRS@\")\n+set(AFF3CT_LIBRARIES \"@AFF3CT_LIBRARIES@\")\n+set(AFF3CT_DEFINITIONS \"@AFF3CT_DEFINITIONS@\")\n+\n+if(WIN32)\n+ set(AFF3CT_EXE_EXT \".exe\")\n+ if(AFF3CT_STATIC)\n+ set(AFF3CT_LIB_PREFIX \"\")\n+ set(AFF3CT_LIB_EXT \".lib\")\n+ else()\n+ set(AFF3CT_LIB_PREFIX \"\")\n+ set(AFF3CT_LIB_EXT \".dll\")\n+ endif()\n+else()\n+ set(AFF3CT_EXE_EXT \"\")\n+ if(APPLE)\n+ if(AFF3CT_STATIC)\n+ set(AFF3CT_LIB_PREFIX \"lib\")\n+ set(AFF3CT_LIB_EXT \".a\")\n+ else()\n+ set(AFF3CT_LIB_PREFIX \"lib\")\n+ set(AFF3CT_LIB_EXT \".dylib\")\n+ endif()\n+ else()\n+ if(AFF3CT_STATIC)\n+ set(AFF3CT_LIB_PREFIX \"lib\")\n+ set(AFF3CT_LIB_EXT \".a\")\n+ else()\n+ set(AFF3CT_LIB_PREFIX \"lib\")\n+ set(AFF3CT_LIB_EXT \".so\")\n+ endif()\n+ endif()\n+endif()\n+\n+set(AFF3CT_INCLUDE_ROOT \"@CMAKE_INSTALL_PREFIX@/include/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@\")\n+set(AFF3CT_INCLUDE_DIRS \"${AFF3CT_INCLUDE_ROOT}/aff3ct\"\n+ \"${AFF3CT_INCLUDE_ROOT}/CLI11\"\n+ \"${AFF3CT_INCLUDE_ROOT}/date\"\n+ \"${AFF3CT_INCLUDE_ROOT}/MIPP\"\n+ \"${AFF3CT_INCLUDE_ROOT}/rang\")\n+\n+if (MSVC)\n+ list(APPEND AFF3CT_INCLUDE_DIRS \"${AFF3CT_INCLUDE_ROOT}/dirent\")\n+endif()\n+\n+if(AFF3CT_EXE)\n+ set(AFF3CT_EXECUTABLE_ROOT \"@CMAKE_INSTALL_PREFIX@/bin/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@)\n+ list(APPEND AFF3CT_EXECUTABLE \"${AFF3CT_EXECUTABLE_ROOT}/aff3ct${AFF3CT_EXE_EXT}\")\n+else()\n+ set(AFF3CT_EXECUTABLE \"\")\n+endif()\n+\n+if(AFF3CT_LIB)\n+ set(AFF3CT_LIBRARIES_ROOT \"@CMAKE_INSTALL_PREFIX@/lib/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@)\n+ list(APPEND AFF3CT_LIBRARIES \"${AFF3CT_LIBRARIES_ROOT}/${AFF3CT_LIB_PREFIX}aff3ct${AFF3CT_LIB_EXT}\")\n+else()\n+ set(AFF3CT_LIBRARIES \"\")\n+endif()\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve the 'CMakeList.txt' to automatically generate CMake config files.
|
8,490 |
01.11.2018 11:46:57
| -3,600 |
9ae74f0afa5a4dfd912d894906d2e8cd966a523a
|
Improve the generation of the CMake config files.
|
[
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "@@ -12,8 +12,6 @@ src_files.txt\n.idea/\n.vs\nCMakeSettings.json\n-aff3ct-config.cmake\n-aff3ct-config-version.cmake\n.scannerwork/\nbuild*/\n"
},
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -27,12 +27,6 @@ option (AFF3CT_16BIT_PREC \"Compile only in 16-bit precision (fixed-point\noption (AFF3CT_32BIT_PREC \"Compile only in 32-bit precision (floating-point)\" OFF)\noption (AFF3CT_64BIT_PREC \"Compile only in 64-bit precision (floating-point)\" OFF)\n-if(AFF3CT_COMPILE_STATIC_LIB OR AFF3CT_COMPILE_SHARED_LIB)\n- set(AFF3CT_COMPILE_LIB ON)\n-else()\n- set(AFF3CT_COMPILE_LIB OFF)\n-endif()\n-\n# ---------------------------------------------------------------------------------------------------------------------\n# ------------------------------------------------------------------------------------------------- CMAKE CONFIGURATION\n# ---------------------------------------------------------------------------------------------------------------------\n@@ -383,11 +377,13 @@ endif()\n# ----------------------------------------------------------------------------------------- GENERATE CMAKE CONFIG FILES\n# ---------------------------------------------------------------------------------------------------------------------\n-# Auto generate cmake config files to link with AFF3CT\n+# Auto generate cmake config files to link with AFF3CT library (only if an AFF3CT library has been compiled)\n+if (AFF3CT_COMPILE_STATIC_LIB OR AFF3CT_COMPILE_SHARED_LIB)\nconfigure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config.cmake.in\"\n- \"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config.cmake\" @ONLY)\n+ \"lib/cmake/aff3ct-config.cmake\" @ONLY)\nconfigure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config-version.cmake.in\"\n- \"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config-version.cmake\" @ONLY)\n+ \"lib/cmake/aff3ct-config-version.cmake\" @ONLY)\n+endif()\n# ---------------------------------------------------------------------------------------------------------------------\n# ------------------------------------------------------------------------------------------------------------- INSTALL\n@@ -403,6 +399,13 @@ if (AFF3CT_COMPILE_STATIC_LIB)\ninstall(TARGETS aff3ct-static-lib ARCHIVE DESTINATION lib/aff3ct-${GIT_VERSION_RMV})\nendif()\n+if (AFF3CT_COMPILE_SHARED_LIB OR AFF3CT_COMPILE_STATIC_LIB)\n+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)\n+ install(FILES \"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/aff3ct-config.cmake\"\n+ \"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/aff3ct-config-version.cmake\"\n+ DESTINATION lib/cmake/aff3ct-${GIT_VERSION_RMV})\n+endif()\n+\ninstall(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/aff3ct\nFILES_MATCHING PATTERN \"*.h\")\ninstall(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/aff3ct\n@@ -431,5 +434,3 @@ if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/refs/BCH/\")\ninstall(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/refs/\" DESTINATION share/aff3ct-${GIT_VERSION_RMV}/refs\nFILES_MATCHING PATTERN \"*.txt\")\nendif()\n\\ No newline at end of file\n-install(FILES \"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config.cmake\" \"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config-version.cmake\"\n- DESTINATION lib/cmake/aff3ct-${GIT_VERSION_RMV})\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "aff3ct-config-version.cmake.in",
"new_path": "aff3ct-config-version.cmake.in",
"diff": "-set(PACKAGE_VERSION \"@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@\")\n+set(PACKAGE_VERSION \"@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@\")\n# Check whether the requested PACKAGE_FIND_VERSION is compatible\nif(\"${PACKAGE_VERSION}\" VERSION_LESS \"${PACKAGE_FIND_VERSION}\")\n"
},
{
"change_type": "MODIFY",
"old_path": "aff3ct-config.cmake.in",
"new_path": "aff3ct-config.cmake.in",
"diff": "# - Config file for the AFF3CT package\n# It defines the following variables\n-# AFF3CT_EXE - true if an executable has been compiled\n-# AFF3CT_LIB - true if a library has been compiled\n-# AFF3CT_STATIC - true if the library has been compiled statically\n+# AFF3CT_STATIC_LIB - true if the library has been compiled statically (otherwise is shared lib)\n# AFF3CT_INCLUDE_DIRS - include directories for AFF3CT\n# AFF3CT_LIBRARIES - libraries to link against\n-# AFF3CT_EXECUTABLE - the AFF3CT executable\n# AFF3CT_DEFINITIONS - the list of preprocessor definitions\n-set(AFF3CT_EXE @AFF3CT_COMPILE_EXE@)\n-set(AFF3CT_LIB @AFF3CT_COMPILE_LIB@)\n-set(AFF3CT_STATIC @AFF3CT_COMPILE_STATIC_LIB@)\n+set(AFF3CT_STATIC_LIB @AFF3CT_COMPILE_STATIC_LIB@)\nset(AFF3CT_INCLUDE_DIRS \"@AFF3CT_INCLUDE_DIRS@\")\nset(AFF3CT_LIBRARIES \"@AFF3CT_LIBRARIES@\")\nset(AFF3CT_DEFINITIONS \"@AFF3CT_DEFINITIONS@\")\nif(WIN32)\n- set(AFF3CT_EXE_EXT \".exe\")\n- if(AFF3CT_STATIC)\n+ if(AFF3CT_STATIC_LIB)\nset(AFF3CT_LIB_PREFIX \"\")\nset(AFF3CT_LIB_EXT \".lib\")\nelse()\n@@ -25,9 +19,8 @@ if(WIN32)\nset(AFF3CT_LIB_EXT \".dll\")\nendif()\nelse()\n- set(AFF3CT_EXE_EXT \"\")\nif(APPLE)\n- if(AFF3CT_STATIC)\n+ if(AFF3CT_STATIC_LIB)\nset(AFF3CT_LIB_PREFIX \"lib\")\nset(AFF3CT_LIB_EXT \".a\")\nelse()\n@@ -35,7 +28,7 @@ else()\nset(AFF3CT_LIB_EXT \".dylib\")\nendif()\nelse()\n- if(AFF3CT_STATIC)\n+ if(AFF3CT_STATIC_LIB)\nset(AFF3CT_LIB_PREFIX \"lib\")\nset(AFF3CT_LIB_EXT \".a\")\nelse()\n@@ -56,16 +49,5 @@ if (MSVC)\nlist(APPEND AFF3CT_INCLUDE_DIRS \"${AFF3CT_INCLUDE_ROOT}/dirent\")\nendif()\n-if(AFF3CT_EXE)\n- set(AFF3CT_EXECUTABLE_ROOT \"@CMAKE_INSTALL_PREFIX@/bin/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@)\n- list(APPEND AFF3CT_EXECUTABLE \"${AFF3CT_EXECUTABLE_ROOT}/aff3ct${AFF3CT_EXE_EXT}\")\n-else()\n- set(AFF3CT_EXECUTABLE \"\")\n-endif()\n-\n-if(AFF3CT_LIB)\nset(AFF3CT_LIBRARIES_ROOT \"@CMAKE_INSTALL_PREFIX@/lib/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@)\nlist(APPEND AFF3CT_LIBRARIES \"${AFF3CT_LIBRARIES_ROOT}/${AFF3CT_LIB_PREFIX}aff3ct${AFF3CT_LIB_EXT}\")\n\\ No newline at end of file\n-else()\n- set(AFF3CT_LIBRARIES \"\")\n-endif()\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Improve the generation of the CMake config files.
|
8,490 |
01.11.2018 18:23:09
| -3,600 |
9cd60f6464ab53cdce3828648c871c492f7a81fe
|
Fix wrong definitions for SystemC.
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -320,12 +320,12 @@ endif (AFF3CT_LINK_MKL)\n# SystemC\nif (AFF3CT_SYSTEMC_SIMU OR AFF3CT_SYSTEMC_MODULE)\n- if (AFF3CT_SYSTEMC_MODULE)\n+ if (AFF3CT_SYSTEMC_SIMU)\n+ aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_SIMU\")\naff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\nelse ()\n- aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_SIMU\")\naff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\n- endif (AFF3CT_SYSTEMC_MODULE)\n+ endif ()\nfind_package (SystemC REQUIRED)\nif (SystemC_FOUND)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix wrong definitions for SystemC.
|
8,490 |
02.11.2018 14:44:23
| -3,600 |
3b80db98e6af37d260b84872145b63e2299a2589
|
Add 'AFF3CT_BACKTRACE' and 'AFF3CT_PREC' options to the CMake config file.
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -23,6 +23,8 @@ option (AFF3CT_COLORS \"Enable the colors in the terminal\"\nif (NOT (WIN32 OR APPLE))\noption (AFF3CT_BACKTRACE \"Enable the backtrace display when and exception is raised\" ON)\n+else()\n+ set (AFF3CT_BACKTRACE OFF)\nendif()\nset(AFF3CT_PREC \"MULTI\" CACHE STRING \"Select the precision in bits (can be '8', '16', '32', '64' or 'MULTI')\")\n@@ -168,14 +170,12 @@ if (AFF3CT_COLORS)\nelse()\nmessage(STATUS \"AFF3CT - Terminal colors: off\")\nendif()\n-if (NOT (WIN32 AND APPLE))\nif (AFF3CT_BACKTRACE)\naff3ct_add_definitions (-DAFF3CT_BACKTRACE)\nmessage(STATUS \"AFF3CT - Backtrace: on\")\nelse()\nmessage(STATUS \"AFF3CT - Backtrace: off\")\nendif()\n-endif()\nif (AFF3CT_PREC STREQUAL \"8\")\naff3ct_add_definitions (-DAFF3CT_8BIT_PREC)\nmessage(STATUS \"AFF3CT - Precision: 8-bit\")\n"
},
{
"change_type": "MODIFY",
"old_path": "aff3ct-config.cmake.in",
"new_path": "aff3ct-config.cmake.in",
"diff": "# AFF3CT_SYSTEMC_MODULE - true if AFF3CT has been linked with SystemC\n# AFF3CT_POLAR_BIT_PACKING - true if AFF3CT bit packing for Polar SC decoder is enabled\n# AFF3CT_COLORS - true if AFF3CT has been compiled with the terminal colors\n+# AFF3CT_BACKTRACE - true if AFF3CT has been compiled to print the backtrace when a exception is raised\n+# AFF3CT_PREC - specify the precision in bits ('8', '16', '32', '64' or 'MULTI')\nset(AFF3CT_INCLUDE_DIRS \"@AFF3CT_INCLUDE_DIRS@\")\nset(AFF3CT_LIBRARIES \"@AFF3CT_LIBRARIES@\")\n@@ -22,6 +24,8 @@ set(AFF3CT_SYSTEMC_MODULE @AFF3CT_SYSTEMC_MODULE@)\nset(AFF3CT_MPI @AFF3CT_MPI@)\nset(AFF3CT_POLAR_BIT_PACKING @AFF3CT_POLAR_BIT_PACKING@)\nset(AFF3CT_COLORS @AFF3CT_COLORS@)\n+set(AFF3CT_BACKTRACE @AFF3CT_BACKTRACE@)\n+set(AFF3CT_PREC \"@AFF3CT_PREC@\")\nif(WIN32)\nif(AFF3CT_STATIC_LIB)\n@@ -52,11 +56,11 @@ else()\nendif()\nset(AFF3CT_INCLUDE_ROOT \"@CMAKE_INSTALL_PREFIX@/include/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@\")\n-list(INSERT AFF3CT_INCLUDE_DIRS 0 \"${AFF3CT_INCLUDE_ROOT}/CLI11\"\n+list(INSERT AFF3CT_INCLUDE_DIRS 0 \"${AFF3CT_INCLUDE_ROOT}/aff3ct\"\n+ \"${AFF3CT_INCLUDE_ROOT}/CLI11\"\n\"${AFF3CT_INCLUDE_ROOT}/date\"\n\"${AFF3CT_INCLUDE_ROOT}/MIPP\"\n- \"${AFF3CT_INCLUDE_ROOT}/rang\"\n- \"${AFF3CT_INCLUDE_ROOT}/aff3ct\")\n+ \"${AFF3CT_INCLUDE_ROOT}/rang\")\nif (MSVC)\nlist(INSERT AFF3CT_INCLUDE_DIRS 0 \"${AFF3CT_INCLUDE_ROOT}/dirent\")\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add 'AFF3CT_BACKTRACE' and 'AFF3CT_PREC' options to the CMake config file.
|
8,483 |
02.11.2018 08:39:22
| -3,600 |
08b97918224f258829b71b3df87adaacf8c27015
|
Remove the powerful tag to the BCH/RS/Uncoded regression tests.
|
[
{
"change_type": "MODIFY",
"old_path": ".gitlab-ci.yml",
"new_path": ".gitlab-ci.yml",
"diff": "@@ -307,7 +307,6 @@ test-regression-bch:\n- x86\n- 64-bit\n- sse4.2\n- - powerful\n- python\nartifacts:\nname: test-regression-results-bch\n@@ -370,7 +369,6 @@ test-regression-rs:\n- x86\n- 64-bit\n- sse4.2\n- - powerful\n- python\nartifacts:\nname: test-regression-results-rs\n@@ -454,7 +452,6 @@ test-regression-uncoded:\n- x86\n- 64-bit\n- sse4.2\n- - powerful\n- python\nartifacts:\nname: test-regression-results-uncoded\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove the powerful tag to the BCH/RS/Uncoded regression tests.
|
8,490 |
05.11.2018 13:28:40
| -3,600 |
81fba8f5b3f5d6c18bd20d8c423be2e7da6f202b
|
Simplify the CMake config file.
|
[
{
"change_type": "MODIFY",
"old_path": "aff3ct-config.cmake.in",
"new_path": "aff3ct-config.cmake.in",
"diff": "@@ -27,34 +27,6 @@ set(AFF3CT_COLORS @AFF3CT_COLORS@)\nset(AFF3CT_BACKTRACE @AFF3CT_BACKTRACE@)\nset(AFF3CT_PREC \"@AFF3CT_PREC@\")\n-if(WIN32)\n- if(AFF3CT_STATIC_LIB)\n- set(AFF3CT_LIB_PREFIX \"\")\n- set(AFF3CT_LIB_EXT \".lib\")\n- else()\n- set(AFF3CT_LIB_PREFIX \"\")\n- set(AFF3CT_LIB_EXT \".dll\")\n- endif()\n-else()\n- if(APPLE)\n- if(AFF3CT_STATIC_LIB)\n- set(AFF3CT_LIB_PREFIX \"lib\")\n- set(AFF3CT_LIB_EXT \".a\")\n- else()\n- set(AFF3CT_LIB_PREFIX \"lib\")\n- set(AFF3CT_LIB_EXT \".dylib\")\n- endif()\n- else()\n- if(AFF3CT_STATIC_LIB)\n- set(AFF3CT_LIB_PREFIX \"lib\")\n- set(AFF3CT_LIB_EXT \".a\")\n- else()\n- set(AFF3CT_LIB_PREFIX \"lib\")\n- set(AFF3CT_LIB_EXT \".so\")\n- endif()\n- endif()\n-endif()\n-\nset(AFF3CT_INCLUDE_ROOT \"@CMAKE_INSTALL_PREFIX@/include/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@\")\nlist(INSERT AFF3CT_INCLUDE_DIRS 0 \"${AFF3CT_INCLUDE_ROOT}/aff3ct\"\n\"${AFF3CT_INCLUDE_ROOT}/CLI11\"\n@@ -67,5 +39,5 @@ if (MSVC)\nendif()\nset(AFF3CT_LIBRARIES_ROOT \"@CMAKE_INSTALL_PREFIX@/lib/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@\")\n-find_library (AFF3CT_LIBRARY ${AFF3CT_LIB_PREFIX}aff3ct${AFF3CT_LIB_EXT} PATHS ${AFF3CT_LIBRARIES_ROOT})\n+find_library (AFF3CT_LIBRARY aff3ct PATHS ${AFF3CT_LIBRARIES_ROOT})\nlist(INSERT AFF3CT_LIBRARIES 0 \"${AFF3CT_LIBRARY}\")\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simplify the CMake config file.
|
8,490 |
05.11.2018 14:44:50
| -3,600 |
c179f68921ac196cff1e605233c174651aed19bb
|
Add priority to static library in the CMake config file.
|
[
{
"change_type": "MODIFY",
"old_path": "aff3ct-config.cmake.in",
"new_path": "aff3ct-config.cmake.in",
"diff": "@@ -39,5 +39,5 @@ if (MSVC)\nendif()\nset(AFF3CT_LIBRARIES_ROOT \"@CMAKE_INSTALL_PREFIX@/lib/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@\")\n-find_library (AFF3CT_LIBRARY aff3ct PATHS ${AFF3CT_LIBRARIES_ROOT})\n+find_library (AFF3CT_LIBRARY NAMES libaff3ct.a aff3ct.lib aff3ct PATHS ${AFF3CT_LIBRARIES_ROOT})\nlist(INSERT AFF3CT_LIBRARIES 0 \"${AFF3CT_LIBRARY}\")\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add priority to static library in the CMake config file.
|
8,490 |
05.11.2018 15:58:42
| -3,600 |
d0e17872164372e48d74451b769fd032d0a098a3
|
Fix link with SystemC when using AFF3CT as a library.
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -294,6 +294,29 @@ endmacro()\n# -------------------------------------------------------------------------------------------------- COMPILED LIBRARIES\n# ---------------------------------------------------------------------------------------------------------------------\n+# SystemC (it is very important to have SystemC link before the other libraries !!!)\n+if (AFF3CT_SYSTEMC_SIMU OR AFF3CT_SYSTEMC_MODULE)\n+ if (AFF3CT_SYSTEMC_SIMU)\n+ aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_SIMU\")\n+ aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\n+ else ()\n+ aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\n+ endif ()\n+\n+ find_package (SystemC REQUIRED)\n+ if (SystemC_FOUND)\n+ message(STATUS \"AFF3CT - Library found: SystemC\")\n+ aff3ct_include_directories (${SystemC_INCLUDE_DIRS})\n+ aff3ct_link_libraries (\"${SystemC_LIBRARIES}\")\n+ endif (SystemC_FOUND)\n+\n+ find_package (TLM REQUIRED)\n+ if (TLM_FOUND)\n+ message(STATUS \"AFF3CT - Library found: TLM\")\n+ aff3ct_include_directories (${TLM_INCLUDE_DIRS})\n+ endif (TLM_FOUND)\n+endif ()\n+\n# GSL\nif (AFF3CT_LINK_GSL)\naff3ct_add_definitions(\"-DAFF3CT_CHANNEL_GSL\")\n@@ -318,29 +341,6 @@ if (AFF3CT_LINK_MKL)\nendif (MKL_FOUND)\nendif (AFF3CT_LINK_MKL)\n-# SystemC\n-if (AFF3CT_SYSTEMC_SIMU OR AFF3CT_SYSTEMC_MODULE)\n- if (AFF3CT_SYSTEMC_SIMU)\n- aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_SIMU\")\n- aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\n- else ()\n- aff3ct_add_definitions (\"-DAFF3CT_SYSTEMC_MODULE\")\n- endif ()\n-\n- find_package (SystemC REQUIRED)\n- if (SystemC_FOUND)\n- message(STATUS \"AFF3CT - Library found: SystemC\")\n- aff3ct_include_directories (${SystemC_INCLUDE_DIRS})\n- aff3ct_link_libraries (\"${SystemC_LIBRARIES}\")\n- endif (SystemC_FOUND)\n-\n- find_package (TLM REQUIRED)\n- if (TLM_FOUND)\n- message(STATUS \"AFF3CT - Library found: TLM\")\n- aff3ct_include_directories (${TLM_INCLUDE_DIRS})\n- endif (TLM_FOUND)\n-endif ()\n-\n# MPI\nif (AFF3CT_MPI)\naff3ct_add_definitions (\"-DAFF3CT_ENABLE_MPI\")\n"
},
{
"change_type": "MODIFY",
"old_path": "aff3ct-config.cmake.in",
"new_path": "aff3ct-config.cmake.in",
"diff": "@@ -40,4 +40,8 @@ endif()\nset(AFF3CT_LIBRARIES_ROOT \"@CMAKE_INSTALL_PREFIX@/lib/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@\")\nfind_library (AFF3CT_LIBRARY NAMES libaff3ct.a aff3ct.lib aff3ct PATHS ${AFF3CT_LIBRARIES_ROOT})\n+if (AFF3CT_SYSTEMC_MODULE) # need to link with SystemC first\n+ list(INSERT AFF3CT_LIBRARIES 1 \"${AFF3CT_LIBRARY}\")\n+else()\nlist(INSERT AFF3CT_LIBRARIES 0 \"${AFF3CT_LIBRARY}\")\n+endif()\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix link with SystemC when using AFF3CT as a library.
|
8,490 |
05.11.2018 19:03:59
| -3,600 |
d228d7cec0c2fb32cd27b17877c29e3bfe12f8ca
|
Move the aff3ct-config files into the cmake folder.
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -393,9 +393,9 @@ endif()\n# Auto generate cmake config files to link with AFF3CT library (only if an AFF3CT library has been compiled)\nif (AFF3CT_COMPILE_STATIC_LIB OR AFF3CT_COMPILE_SHARED_LIB)\n- configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config.cmake.in\"\n+ configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/aff3ct-config.cmake.in\"\n\"lib/cmake/aff3ct-config.cmake\" @ONLY)\n- configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/aff3ct-config-version.cmake.in\"\n+ configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/aff3ct-config-version.cmake.in\"\n\"lib/cmake/aff3ct-config-version.cmake\" @ONLY)\nendif()\n"
},
{
"change_type": "RENAME",
"old_path": "aff3ct-config-version.cmake.in",
"new_path": "cmake/Modules/aff3ct-config-version.cmake.in",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "aff3ct-config.cmake.in",
"new_path": "cmake/Modules/aff3ct-config.cmake.in",
"diff": ""
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Move the aff3ct-config files into the cmake folder.
|
8,490 |
06.11.2018 11:05:50
| -3,600 |
d60f653af72bbe349864ed9161b1f55d5dd68e00
|
Removed submodule 'lib/CLI11' as it is not used at this time.
|
[
{
"change_type": "MODIFY",
"old_path": ".gitmodules",
"new_path": ".gitmodules",
"diff": "[submodule \"refs\"]\npath = refs\nurl = ../error_rate_references\n-[submodule \"lib/CLI11\"]\n- path = lib/CLI11\n- url = https://github.com/CLIUtils/CLI11.git\n[submodule \"lib/rang\"]\npath = lib/rang\nurl = https://github.com/agauniyal/rang.git\n"
},
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -226,17 +226,6 @@ else ()\n\"$ git submodule update --init -- ../lib/rang/\")\nendif ()\n-# CLI11\n-if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/lib/CLI11/include/CLI/CLI.hpp\")\n- include_directories (\"${CMAKE_CURRENT_SOURCE_DIR}/lib/CLI11/include/CLI/\")\n- message(STATUS \"AFF3CT - Header found: CLI11\")\n- #add_subdirectory(lib/CLI11)\n- #aff3ct_link_libraries(CLI11::CLI11)\n-else ()\n- message(FATAL_ERROR \"AFF3CT - CLI11 can't be found, try to init the submodule with the following cmd:\\n\"\n- \"$ git submodule update --init -- ../lib/CLI11/\")\n-endif ()\n-\n# date\nif (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/lib/date/include/date/date.h\")\ninclude_directories (\"${CMAKE_CURRENT_SOURCE_DIR}/lib/date/include/date/\")\n@@ -427,8 +416,6 @@ install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct-\ninstall(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/src/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/aff3ct\nFILES_MATCHING PATTERN \"*.hxx\")\n-install(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib/CLI11/include/CLI/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/CLI11\n- FILES_MATCHING PATTERN \"*.hpp\")\ninstall(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib/date/include/date/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/date\nFILES_MATCHING PATTERN \"*.h\")\ninstall(DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib/MIPP/src/\" DESTINATION include/aff3ct-${GIT_VERSION_RMV}/MIPP\n"
},
{
"change_type": "MODIFY",
"old_path": "cmake/Modules/aff3ct-config.cmake.in",
"new_path": "cmake/Modules/aff3ct-config.cmake.in",
"diff": "@@ -29,7 +29,6 @@ set(AFF3CT_PREC \"@AFF3CT_PREC@\")\nset(AFF3CT_INCLUDE_ROOT \"@CMAKE_INSTALL_PREFIX@/include/aff3ct-@GIT_VERSION_MAJOR@.@GIT_VERSION_MINOR@.@GIT_VERSION_PATCH@@GIT_TAIL@\")\nlist(INSERT AFF3CT_INCLUDE_DIRS 0 \"${AFF3CT_INCLUDE_ROOT}/aff3ct\"\n- \"${AFF3CT_INCLUDE_ROOT}/CLI11\"\n\"${AFF3CT_INCLUDE_ROOT}/date\"\n\"${AFF3CT_INCLUDE_ROOT}/MIPP\"\n\"${AFF3CT_INCLUDE_ROOT}/rang\")\n"
},
{
"change_type": "DELETE",
"old_path": "lib/CLI11",
"new_path": null,
"diff": "-Subproject commit b519a13119358fc0cde28b070bf8984e814f8c4a\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Removed submodule 'lib/CLI11' as it is not used at this time.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.