From 316c02716c365eee298ca3da5a65c3be58b57a1e Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 13 Oct 2021 15:44:19 +0100 Subject: [PATCH] fix issue where width was being computed based on 2 maximum values actually needed is to multiply the number of elements by the width of an element and use that to determine which is greater --- src/ieee754/part/layout_experiment.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ieee754/part/layout_experiment.py b/src/ieee754/part/layout_experiment.py index 5e14244b..81c39d3a 100644 --- a/src/ieee754/part/layout_experiment.py +++ b/src/ieee754/part/layout_experiment.py @@ -119,13 +119,20 @@ def layout(elwid, vec_el_counts, lane_shapes=None, fixed_width=None): # compute a set of partition widths print("lane_shapes", lane_shapes, "vec_el_counts", vec_el_counts) - cpart_wid = max(lane_shapes.values()) + cpart_wid = 0 + width = 0 + for i, lwid in lane_shapes.items(): + required_width = lwid * vec_el_counts[i] + print(" required width", cpart_wid, i, lwid, required_width) + if required_width > width: + cpart_wid = lwid + width = required_width + + # calculate the minumum width required if fixed_width specified part_count = max(vec_el_counts.values()) - # calculate the minumum width required - width = cpart_wid * part_count print("width", width, cpart_wid, part_count) if fixed_width is not None: # override the width and part_wid - assert width < fixed_width, "not enough space to fit partitions" + assert width <= fixed_width, "not enough space to fit partitions" part_wid = fixed_width // part_count assert part_wid * part_count == fixed_width, \ "calculated width not aligned multiples" -- 2.30.2