Libraryless. Compilation Failed (57L/1K).
import jdk.incubator.vector.*; static int countDifferingBits_1024bit_vectorAPI(long[] array1, long[] array2, int i1) { VectorSpecies<Long> SPECIES = LongVector.SPECIES_PREFERRED; int diff = 0; int n = 1024/64; var upperBound = SPECIES.loopBound(n); var i = 0; for (; i < upperBound; i += SPECIES.length()) { var vector1 = LongVector.fromArray(SPECIES, array1, i); var vector2 = LongVector.fromArray(SPECIES, array2, i1+i); var xored = vector1.lanewise(VectorOperators.XOR, vector2); var bitCount = xored.lanewise(VectorOperators.BIT_COUNT); diff += (int) bitCount.reduceLanes(VectorOperators.ADD); } // Compute elements not fitting in the vector alignment. for (; i < n; i++) diff += Long.bitCount(array1[i]^array2[i1+i]); ret diff; }
Began life as a copy of #1036056
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1036088 |
Snippet name: | countDifferingBits_1024bit_vectorAPI [for JDK 19, OK but slower than unvectorized] |
Eternal ID of this version: | #1036088/1 |
Text MD5: | 5e21801f90ee04f1b0c8973bdfde8383 |
Transpilation MD5: | aed4deeb174e3d4d97ff8c0d27fc334d |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-09-07 06:43:53 |
Source code size: | 813 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 147 / 203 |
Referenced in: | [show references] |