This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/1173 utils/conv_gen.py: use shared tables if possible This change introduces the memory usage optimization, mentioned in d2d9760c08f35a231d32f0ebeb73b2927e5573b3. The aim is to make code generator able to detect, whether the same tables are used by several convolutional code definitions, and prevent one from writing these tables multiple times. For now, the detection process isn't fully automatic, so all shared polynomials should be placed inside the 'shared_polys' dictionary, for example: shared_polys = { "xcch" : [ ( G0, 1 ), ( G1, 1 ), ], "mcs" : [ ( G4, 1 ), ( G7, 1 ), ( G5, 1 ), ], } Change-Id: I84760f5cdfdaece376b801d2e6cb2954ee875a3b --- M utils/conv_gen.py 1 file changed, 61 insertions(+), 37 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/73/1173/1 diff --git a/utils/conv_gen.py b/utils/conv_gen.py index 78b2335..a51e0e0 100644 --- a/utils/conv_gen.py +++ b/utils/conv_gen.py @@ -163,7 +163,7 @@ # Up to 12 numbers should be placed per line print_formatted(self.puncture, "%3d, ", 12, fi) - def gen_tables(self, pref, fi): + def print_state_and_output(self, fi): pack = lambda n: \ sum([x << (self.rate_inv - i - 1) for i, x in enumerate(n)]) num_states = 1 << (self.k - 1) @@ -185,6 +185,14 @@ self._print_term(fi, num_states, pack) fi.write("};\n\n") + def gen_tables(self, pref, fi, shared_tables = False): + # Do not print shared tables + if not shared_tables: + self.print_state_and_output(fi) + table_pref = self.name + else: + table_pref = shared_tables + if len(self.puncture): fi.write("static const int %s_puncture[] = {\n" % self.name) self._print_puncture(fi) @@ -202,15 +210,15 @@ fi.write("\t.N = %d,\n" % self.rate_inv) fi.write("\t.K = %d,\n" % self.k) fi.write("\t.len = %d,\n" % self.block_len) - fi.write("\t.next_output = %s_output,\n" % self.name) - fi.write("\t.next_state = %s_state,\n" % self.name) + fi.write("\t.next_output = %s_output,\n" % table_pref) + fi.write("\t.next_state = %s_state,\n" % table_pref) if self.term_type is not None: fi.write("\t.term = %s,\n" % self.term_type) if self.recursive: - fi.write("\t.next_term_output = %s_term_output,\n" % self.name) - fi.write("\t.next_term_state = %s_term_state,\n" % self.name) + fi.write("\t.next_term_output = %s_term_output,\n" % table_pref) + fi.write("\t.next_term_state = %s_term_state,\n" % table_pref) if len(self.puncture): fi.write("\t.puncture = %s_puncture,\n" % self.name) @@ -238,6 +246,12 @@ fi.write("\n") +def print_shared(fi): + for name, polys in shared_polys.iteritems(): + # HACK + code = ConvolutionalCode(0, polys, name = name) + code.print_state_and_output(fi) + # Polynomials according to 3GPP TS 05.03 Annex B G0 = poly(0, 3, 4) G1 = poly(0, 1, 3, 4) @@ -248,22 +262,23 @@ G6 = poly(0, 1, 2, 3, 4, 6) G7 = poly(0, 1, 2, 3, 6) -CCH_poly = [ - ( G0, 1 ), - ( G1, 1 ), -] - -MCS_poly = [ - ( G4, 1 ), - ( G7, 1 ), - ( G5, 1 ), -] +shared_polys = { + "xcch" : [ + ( G0, 1 ), + ( G1, 1 ), + ], + "mcs" : [ + ( G4, 1 ), + ( G7, 1 ), + ( G5, 1 ), + ], +} conv_codes = [ # xCCH definition ConvolutionalCode( 224, - CCH_poly, + shared_polys["xcch"], name = "xcch", description = [ "xCCH convolutional code:", @@ -276,7 +291,7 @@ # RACH definition ConvolutionalCode( 14, - CCH_poly, + shared_polys["xcch"], name = "rach", description = ["RACH convolutional code"] ), @@ -284,7 +299,7 @@ # SCH definition ConvolutionalCode( 35, - CCH_poly, + shared_polys["xcch"], name = "sch", description = ["SCH convolutional code"] ), @@ -292,7 +307,7 @@ # CS2 definition ConvolutionalCode( 290, - CCH_poly, + shared_polys["xcch"], puncture = [ 15, 19, 23, 27, 31, 35, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 91, 95, 99, 103, 107, 111, 115, 119, 123, 127, 131, @@ -316,7 +331,7 @@ # CS3 definition ConvolutionalCode( 334, - CCH_poly, + shared_polys["xcch"], puncture = [ 15, 17, 21, 23, 27, 29, 33, 35, 39, 41, 45, 47, 51, 53, 57, 59, 63, 65, 69, 71, 75, 77, 81, 83, 87, 89, 93, 95, @@ -578,7 +593,7 @@ # TCH_FR definition ConvolutionalCode( 185, - CCH_poly, + shared_polys["xcch"], name = "tch_fr", description = ["TCH/F convolutional code"] ), @@ -723,7 +738,7 @@ # EDGE MCS1_DL_HDR definition ConvolutionalCode( 36, - MCS_poly, + shared_polys["mcs"], name = "mcs1_dl_hdr", term_type = "CONV_TERM_TAIL_BITING", description = [ @@ -738,7 +753,7 @@ # EDGE MCS1_UL_HDR definition ConvolutionalCode( 39, - MCS_poly, + shared_polys["mcs"], name = "mcs1_ul_hdr", term_type = "CONV_TERM_TAIL_BITING", description = [ @@ -753,7 +768,7 @@ # EDGE MCS1 definition ConvolutionalCode( 190, - MCS_poly, + shared_polys["mcs"], name = "mcs1", description = [ "EDGE MCS-1 data convolutional code:", @@ -767,7 +782,7 @@ # EDGE MCS2 definition ConvolutionalCode( 238, - MCS_poly, + shared_polys["mcs"], name = "mcs2", description = [ "EDGE MCS-2 data convolutional code:", @@ -781,7 +796,7 @@ # EDGE MCS3 definition ConvolutionalCode( 310, - MCS_poly, + shared_polys["mcs"], name = "mcs3", description = [ "EDGE MCS-3 data convolutional code:", @@ -795,7 +810,7 @@ # EDGE MCS4 definition ConvolutionalCode( 366, - MCS_poly, + shared_polys["mcs"], name = "mcs4", description = [ "EDGE MCS-4 data convolutional code:", @@ -809,7 +824,7 @@ # EDGE MCS5_DL_HDR definition ConvolutionalCode( 33, - MCS_poly, + shared_polys["mcs"], name = "mcs5_dl_hdr", term_type = "CONV_TERM_TAIL_BITING", description = [ @@ -824,7 +839,7 @@ # EDGE MCS5_UL_HDR definition ConvolutionalCode( 45, - MCS_poly, + shared_polys["mcs"], name = "mcs5_ul_hdr", term_type = "CONV_TERM_TAIL_BITING", description = [ @@ -839,7 +854,7 @@ # EDGE MCS5 definition ConvolutionalCode( 462, - MCS_poly, + shared_polys["mcs"], name = "mcs5", description = [ "EDGE MCS-5 data convolutional code:", @@ -853,7 +868,7 @@ # EDGE MCS6 definition ConvolutionalCode( 606, - MCS_poly, + shared_polys["mcs"], name = "mcs6", description = [ "EDGE MCS-6 data convolutional code:", @@ -867,7 +882,7 @@ # EDGE MCS7_DL_HDR definition ConvolutionalCode( 45, - MCS_poly, + shared_polys["mcs"], name = "mcs7_dl_hdr", term_type = "CONV_TERM_TAIL_BITING", description = [ @@ -882,7 +897,7 @@ # EDGE MCS7_UL_HDR definition ConvolutionalCode( 54, - MCS_poly, + shared_polys["mcs"], name = "mcs7_ul_hdr", term_type = "CONV_TERM_TAIL_BITING", description = [ @@ -897,7 +912,7 @@ # EDGE MCS7 definition ConvolutionalCode( 462, - MCS_poly, + shared_polys["mcs"], name = "mcs7", description = [ "EDGE MCS-7 data convolutional code:", @@ -911,7 +926,7 @@ # EDGE MCS8 definition ConvolutionalCode( 558, - MCS_poly, + shared_polys["mcs"], name = "mcs8", description = [ "EDGE MCS-8 data convolutional code:", @@ -925,7 +940,7 @@ # EDGE MCS9 definition ConvolutionalCode( 606, - MCS_poly, + shared_polys["mcs"], name = "mcs9", description = [ "EDGE MCS-9 data convolutional code:", @@ -948,10 +963,19 @@ f.write(mod_license + "\n") f.write("#include <stdint.h>\n") f.write("#include <osmocom/core/conv.h>\n\n") + print_shared(f) # Generate the tables one by one for code in conv_codes: sys.stderr.write("Generate '%s' definition\n" % code.name) - code.gen_tables(prefix, f) + + # Check whether shared polynomials are used + shared = False + for name, polys in shared_polys.iteritems(): + if code.polys == polys: + shared = name + break + + code.gen_tables(prefix, f, shared_tables = shared) sys.stderr.write("Generation complete.\n") -- To view, visit https://gerrit.osmocom.org/1173 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I84760f5cdfdaece376b801d2e6cb2954ee875a3b Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>