Libraryless. Compilation Failed (56L/1K).
import jdk.incubator.vector.*; static int countDifferingBits_vectorAPI(long[] array1, long[] array2, int i1) { VectorSpecies<Long> SPECIES = LongVector.SPECIES_PREFERRED; int diff = 0; int n = array1.length; 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 #1030540
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1036056 |
Snippet name: | countDifferingBits_vectorAPI [for JDK 19, OK but slower than unvectorized] |
Eternal ID of this version: | #1036056/19 |
Text MD5: | cd0bcc9c44bdb6f682bb5a9a45e9b764 |
Transpilation MD5: | 1d3886404fdefec873ec7ef6ee8a0bf6 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-09-06 23:32:03 |
Source code size: | 809 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 157 / 273 |
Version history: | 18 change(s) |
Referenced in: | [show references] |