[Libre-soc-bugs] [Bug 1155] O(n^2) multiplication REMAP mode(s)
bugzilla-daemon at libre-soc.org
bugzilla-daemon at libre-soc.org
Fri Dec 22 05:24:39 GMT 2023
https://bugs.libre-soc.org/show_bug.cgi?id=1155
--- Comment #8 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Jacob Lifshay from comment #7)
> I came up with a somewhat different bigint mul remap algorithm, it has a few
> issues though...I also rebased the branch on latest master.
so, basically, we have to decide if we want a really compact but somewhat
problematic loop, or a somewhat bigger loop (algorithm in comment #0 and copied
below) that's likely easier for hw to handle (since it matches the scalar *
vector multiply pattern closer):
void mul(
uint64_t *product,
const uint64_t *a,
const uint64_t *b,
size_t a_sz,
size_t b_sz
) {
for(size_t bi = 0; bi < a_sz; bi++) {
product[bi] = 0;
}
for(size_t ai = 0; ai < a_sz; ai++) {
uint64_t carry = 0;
for(size_t bi = 0; bi < a_sz; bi++) {
uint128_t v = (uint128_t)a[ai] * (uint128_t)b[bi];
v += (uint128_t)carry;
v += (uint128_t)product[ai + bi];
carry = v >> 64;
product[ai + bi] = (uint64_t)v;
}
product[ai + b_sz] = carry;
}
}
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the libre-soc-bugs
mailing list