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

15
LINES

< > BotCompany Repo | #1030540 // rowAndColSums_8x8_vectorAPI

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

Libraryless. Click here for Pure Java version (9216L/51K).

import jdk.incubator.vector.*;

static Pair<int[]> rowAndColSums_8x8_vectorAPI(int[] data) {
  VectorSpecies<Int> species = IntVector.SPECIES_256;
  int[] rowSums = new[8];
  int[] colSums = new[8];
  IntVector vColSums = IntVector.zero(species);
  for y to 8: {
    IntVector v = IntVector.fromArray(species, data, y*8);
    rowSums[y] = v.reduceLanes(VectorOperators.ADD);
    vColSums = vColSums.add(v);
  }
  vColSums.intoArray(colSums, 0);
  ret pair(rowSums, colSums);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030540
Snippet name: rowAndColSums_8x8_vectorAPI
Eternal ID of this version: #1030540/2
Text MD5: b68beb11771cda952d30d74bdbf45d35
Transpilation MD5: 41c8c1d5daca9741ee140d547a3fc374
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-06 19:57:44
Source code size: 490 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 220 / 300
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1036056 - countDifferingBits_vectorAPI [for JDK 19, OK but slower than unvectorized]