fix issue where width was being computed based on 2 maximum values
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 13 Oct 2021 14:44:19 +0000 (15:44 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 13 Oct 2021 14:44:19 +0000 (15:44 +0100)
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

index 5e14244bd5168cbeb8c5f4d94a5153889acdec69..81c39d3aa026fdc79ddf72498a1a57c743b9b5e1 100644 (file)
@@ -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"