From 46a84e1f16f1f9670120a71b8dbbc7492a992595 Mon Sep 17 00:00:00 2001 From: lkcl Date: Thu, 21 Apr 2022 09:34:43 +0100 Subject: [PATCH] --- openpower/sv/biginteger/analysis.mdwn | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/openpower/sv/biginteger/analysis.mdwn b/openpower/sv/biginteger/analysis.mdwn index cd2e3bd61..ce4898372 100644 --- a/openpower/sv/biginteger/analysis.mdwn +++ b/openpower/sv/biginteger/analysis.mdwn @@ -4,6 +4,12 @@ This section covers an analysis of big integer operations. Use of smaller sub-operations is a given: worst-case, addition is O(N) whilst multiply and divide are O(N^2). +Links + +* +* +* + # Add and Subtract Surprisingly, no new additional instructions are required to perform @@ -69,6 +75,28 @@ to multiply, and an additional accumulator (C). However if C is left out (and added afterwards with a Vector-Add) things become more manageable. +Demonstrating in c, a Row-based multiply using a temporary vector. +Adapted from a simple implementation +of Knuth M: + +``` + // this becomes the basis for sv.madded in RS=RC Mode, + // where k is RC + k = 0; + for (i = 0; i < m; i++) { + unsigned product = u[i]*v[j] + k; + k = product>>16; + plo[i] = product; // & 0xffff + } + // this is simply sv.adde where k is XER.CA + k = 0; + for (i = 0; i < m; i++) { + t = plo[i] + w[i + j] + k; + w[i + j] = t; // (I.e., t & 0xFFFF). + k = t >> 16; // carry: should only be 1 bit + } +``` + We therefore propose an operation that is 3-in, 2-out, that, noting that the connection between successive mul-adds has the UPPER half of the previous operation -- 2.30.2