From: lkcl Date: Tue, 21 Nov 2023 11:47:39 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b70996ee14eeb644a69295c2de08d712c845caee;p=libreriscv.git --- diff --git a/openpower/sv/cookbook/pospopcnt.mdwn b/openpower/sv/cookbook/pospopcnt.mdwn index d28897169..d350ffae7 100644 --- a/openpower/sv/cookbook/pospopcnt.mdwn +++ b/openpower/sv/cookbook/pospopcnt.mdwn @@ -1,6 +1,17 @@ - +# Positional popcount SVP64 + +* +* + +Positional popcount in optimised assembler is typically done on SIMD ISAs in +around 500 lines. Power ISA thanks to `bpermd` can be much more efficient: +with SVP64 even more so. The reference implementation showing the concept +is below, and it adds up the totals of each bit set to 1 in each bit-position, +of an array of input alues. ``` +// Copyright (c) 2020 Robert Clausecker +// count8 reference implementation for tests. Do not alter. func count8safe(counts *[8]int, buf []uint8) { for i := range buf { for j := 0; j < 8; j++ { @@ -8,14 +19,6 @@ func count8safe(counts *[8]int, buf []uint8) { } } } - -func count16safe(counts *[16]int, buf []uint16) { - for i := range buf { - for j := 0; j < 16; j++ { - counts[j] += int(buf[i] >> j & 1) - } - } -} ``` [[!tag svp64_cookbook ]]