From b70996ee14eeb644a69295c2de08d712c845caee Mon Sep 17 00:00:00 2001 From: lkcl Date: Tue, 21 Nov 2023 11:47:39 +0000 Subject: [PATCH] --- openpower/sv/cookbook/pospopcnt.mdwn | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) 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 ]] -- 2.30.2