From 295f6a89b7319d13835ad721df9d3b8ae177d021 Mon Sep 17 00:00:00 2001 From: lucas Date: Sun, 28 Jan 2024 20:29:47 +0100 Subject: [PATCH] add got valid in timestep in lsd stats --- src_cpp/lsd.hpp | 23 ++++++++++++------- src_python/ldpc/bplsd_decoder/__init__.pyi | 1 + .../ldpc/bplsd_decoder/_bplsd_decoder.pxd | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src_cpp/lsd.hpp b/src_cpp/lsd.hpp index 00c1e98..051dd6f 100644 --- a/src_cpp/lsd.hpp +++ b/src_cpp/lsd.hpp @@ -49,7 +49,7 @@ namespace ldpc::lsd { std::vector cluster_bit_idx_to_pcm_bit_idx; gf2dense::PluDecomposition pluDecomposition; int nr_merges; - std::unordered_map>> *global_timestep_bit_history; + std::unordered_map>> *global_timestep_bit_history = nullptr; int curr_timestep = 0; LsdCluster() = default; @@ -213,8 +213,10 @@ namespace ldpc::lsd { this->merge_list.insert(bit_membership); } } - // add bit to timestep history with timestep the map size -1 - (*this->global_timestep_bit_history)[this->curr_timestep][this->cluster_id].push_back(bit_index); + if (this->global_timestep_bit_history != nullptr) { + // add bit to timestep history with timestep the map size -1 + (*this->global_timestep_bit_history)[this->curr_timestep][this->cluster_id].push_back(bit_index); + } // add incident checks this->add_column_to_cluster_pcm(bit_index); return true; @@ -380,11 +382,12 @@ namespace ldpc::lsd { struct ClusterStatistics { public: - int final_bit_count = 0; - int undergone_growth_steps = 0; - int nr_merges = 0; - std::vector size_history = {}; - bool active = false; + int final_bit_count = 0; // nr of bits in 'final' cluster version, i.e., before solving for solution + int undergone_growth_steps = 0; // nr of growth steps the cluster underwent + int nr_merges = 0; // nr of merges the cluster underwent + std::vector size_history = {}; // history of cluster sizes from 0 to final bit count + bool active = false; // if cluster is active, i.e., not merged into another cluster + int got_valid_in_timestep = -1; // timestep in which cluster got valid }; struct Statistics { @@ -407,6 +410,7 @@ namespace ldpc::lsd { result += "\"final_bit_count\":" + std::to_string(kv.second.final_bit_count) + ","; result += "\"undergone_growth_steps\":" + std::to_string(kv.second.undergone_growth_steps) + ","; result += "\"nr_merges\":" + std::to_string(kv.second.nr_merges) + ","; + result += "\"got_valid_in_timestep\":" + std::to_string(kv.second.got_valid_in_timestep) + ","; result += "\"size_history\":["; for (auto &s: kv.second.size_history) { result += std::to_string(s) + ","; @@ -474,6 +478,7 @@ namespace ldpc::lsd { for (auto &s: kv.second.size_history) { std::cout << s << " "; } + std::cout << "Got valid in timestep: " << kv.second.got_valid_in_timestep << std::endl; std::cout << std::endl; } // print global bit history map per timestep and cluster @@ -548,6 +553,8 @@ namespace ldpc::lsd { for (auto cl: clusters) { if (cl->active && !cl->valid) { invalid_clusters.push_back(cl); + } else if (cl->active && cl->valid && this->do_stats) { + this->statistics.individual_cluster_stats[cl->cluster_id].got_valid_in_timestep = timestep; } if (do_stats) { this->statistics.individual_cluster_stats[cl->cluster_id].active = cl->active; diff --git a/src_python/ldpc/bplsd_decoder/__init__.pyi b/src_python/ldpc/bplsd_decoder/__init__.pyi index 80c3dd9..c8e01bb 100644 --- a/src_python/ldpc/bplsd_decoder/__init__.pyi +++ b/src_python/ldpc/bplsd_decoder/__init__.pyi @@ -95,3 +95,4 @@ class BpLsdDecoder(BpDecoderBase): value : bool Whether the statistics are being collected. """ + diff --git a/src_python/ldpc/bplsd_decoder/_bplsd_decoder.pxd b/src_python/ldpc/bplsd_decoder/_bplsd_decoder.pxd index 6475346..220dff7 100644 --- a/src_python/ldpc/bplsd_decoder/_bplsd_decoder.pxd +++ b/src_python/ldpc/bplsd_decoder/_bplsd_decoder.pxd @@ -20,6 +20,7 @@ cdef extern from "lsd.hpp" namespace "ldpc::lsd": int nr_merges bool active vector[int] size_history + int got_valid_in_timestep cdef struct Statistics "ldpc::lsd::Statistics": cpp_map[int, ClusterStatistics] individual_cluster_stats