From ff455da2a1e30a17c74ffd06ec5d0dcd53953093 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 25 Oct 2021 12:19:04 +0100 Subject: [PATCH] rename the arguments to SimdShape() so as to match up with Shape() params --- src/ieee754/part/partsig.py | 26 +++++++++++++++++++------- src/ieee754/part/simd_scope.py | 7 +++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index e38258be..f8c497c8 100644 --- a/src/ieee754/part/partsig.py +++ b/src/ieee754/part/partsig.py @@ -109,21 +109,33 @@ class ElWidthPartType: # TODO decide name class SimdShape(Shape): """a SIMD variant of Shape. supports: - * fixed overall width with variable (maxed-out) element lengths - * fixed element widths with overall size auto-determined - * both fixed overall width and fixed element widths + * fixed overall width with variable (maxed-out) element lengths + * fixed element widths with overall size auto-determined + * both fixed overall width and fixed element widths + + naming is preserved to be compatible with Shape(). """ - def __init__(self, scope, width=None, signed=False, widths_at_elwid=None): + def __init__(self, scope, width=None, # this is actually widths_at_elwid + signed=False, + fixed_width=None): # fixed overall width + widths_at_elwid = width # this check is done inside layout but do it again here anyway - assert width == None and widths_at_elwidth == None, \ - "both width and widths_at_elwidth cannot be None" + assert fixed_width == None and widths_at_elwidth == None, \ + "both width (widths_at_elwid) and fixed_width cannot be None" (pp, bitp, lpoints, bmask, fixed_width, lane_shapes, part_wid) = \ - layout(scope.elwid, scope.vec_el_counts, widths_at_elwid, width) + layout(scope.elwid, + scope.vec_el_counts, + widths_at_elwid, + fixed_width) self.partpoints = pp self.bitp = bitp # binary values for partpoints at each elwidth self.lpoints = lpoints # layout ranges self.blankmask = bmask # blanking mask (partitions always padding) self.partwid = partwid # smallest alignment start point for elements + + # pass through the calculated width to Shape() so that when/if + # objects using this Shape are downcast, they know exactly how to + # get *all* bits and need know absolutely nothing about SIMD at all Shape.__init__(self, fixed_width, signed) diff --git a/src/ieee754/part/simd_scope.py b/src/ieee754/part/simd_scope.py index 8e71a1c0..cf0702d0 100644 --- a/src/ieee754/part/simd_scope.py +++ b/src/ieee754/part/simd_scope.py @@ -197,5 +197,8 @@ class SimdScope: # straight from scalar to SIMD will have the exact same # width at all elwidths, because layout() detects the integer # case and converts it, preserving the width at all elwidths - return SimdShape(self, width=None, signed=signed, - widths_at_elwid=width) + # the names are preserved to ensure parameter-compatibility + # with Shape() + return SimdShape(self, width=width, # actually widths_at_elwid + signed=signed, + fixed_width=None) -- 2.30.2