From: lkcl Date: Sat, 9 Oct 2021 14:38:46 +0000 (+0100) Subject: (no commit message) X-Git-Tag: opf_rfc_ls005_v1~3677 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=23345de129714605c6b63e136b439c99dee72c68;p=libreriscv.git --- diff --git a/3d_gpu/architecture/dynamic_simd/shape.mdwn b/3d_gpu/architecture/dynamic_simd/shape.mdwn index 6cb0259ed..8be82debf 100644 --- a/3d_gpu/architecture/dynamic_simd/shape.mdwn +++ b/3d_gpu/architecture/dynamic_simd/shape.mdwn @@ -102,4 +102,28 @@ occur on `Shape.width`. >>> print(x2.signed) True +With this capability it becomes possible to use the Liskov Substitution +Principle in dynamically compiling code that switches between scalar and +SIMD: + + # scalar context + scalarctx = scl = object() + scl.XLEN = 64 + scl.SigKls = Signal + # SIMD context + simdctx = sdc = object() + sdc = SimdShape(64, ....) + sdc.SigKls = SimdSignal + sdc.elwidth = Signal(2) + # select one + if compiletime_switch == 'SIMD': + ctx = simdctx + else: + ctx = scalarctx + + # exact same code switching context at compile time + m = Module(): + with ctx: + x = ctx.SigKls(ctx.XLEN) + ...