Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1036088 // countDifferingBits_1024bit_vectorAPI [for JDK 19, OK but slower than unvectorized]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Compilation Failed (57L/1K).

1  
import jdk.incubator.vector.*;
2  
3  
static int countDifferingBits_1024bit_vectorAPI(long[] array1, long[] array2, int i1) {
4  
  VectorSpecies<Long> SPECIES = LongVector.SPECIES_PREFERRED;
5  
  
6  
  int diff = 0;
7  
  int n = 1024/64;
8  
  var upperBound = SPECIES.loopBound(n);
9  
10  
  var i = 0;
11  
  for (; i < upperBound; i += SPECIES.length()) {
12  
    var vector1 = LongVector.fromArray(SPECIES, array1, i);
13  
    var vector2 = LongVector.fromArray(SPECIES, array2, i1+i);
14  
    var xored = vector1.lanewise(VectorOperators.XOR, vector2);
15  
    var bitCount = xored.lanewise(VectorOperators.BIT_COUNT);
16  
    diff += (int) bitCount.reduceLanes(VectorOperators.ADD);
17  
  } 
18  
  
19  
  // Compute elements not fitting in the vector alignment.
20  
  for (; i < n; i++)
21  
    diff += Long.bitCount(array1[i]^array2[i1+i]);
22  
23  
  ret diff;
24  
}

Author comment

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: 148 / 206
Referenced in: [show references]