[vector] Add tests for slice and unslice operations
Kharbas, Kishor
kishor.kharbas at intel.com
Sat Oct 5 03:00:24 UTC 2019
Hi Vivek,
One comment about masked unslice(). The code looks correct but can be make simpler if you use same logic as in un-masked unsliced().
For the lanes which are unset just use the value from the background array (example below shown for Int256VectorTests). This is what the spec for unslice()<http://cr.openjdk.java.net/~kkharbas/vector-api/CSR/javadoc.02/jdk.incubator.vector/jdk/incubator/vector/Vector.html> says -
"For each lane N selected by the mask, the lane value is copied into lane origin+N of the first background vector, if that lane exists, else into lane origin+N-VLENGTH of the second background vector (which is guaranteed to exist). Background lanes retain their original values if the corresponding input lanes N are unset in the mask.'
static int[] unslice(int[] a, int[] b, int origin, int part, int idx) {
int[] res = new int[SPECIES.length()];
for (int i = 0, j = 0; i < SPECIES.length(); i++){
if (part == 0) {
if (i < origin)
res[i] = b[idx+i];
else {
res[i] = mask[i]? a[idx+j] : b[idx+i];
j++;
}
} else if (part == 1) {
if (i < origin)
res[i] = mask[i] ? a[idx+SPECIES.length()-origin+i]: b[idx + i];
else {
res[i] = b[idx+origin+j];
j++;
}
}
}
return res;
}
Everything else looks correct.
Thanks,
Kishor
-----Original Message-----
From: panama-dev [mailto:panama-dev-bounces at openjdk.java.net] On Behalf Of Deshpande, Vivek R
Sent: Monday, September 30, 2019 5:51 PM
To: panama-dev at openjdk.java.net
Subject: [vector] Add tests for slice and unslice operations
Hi All
Could you please review the patch for tests for slice and unsliced.
http://cr.openjdk.java.net/~vdeshpande/webrev_slice_unslice/
Code contributed by: Vikash Kumar (vikash1.kumar at intel.com<mailto:vikash1.kumar at intel.com>)
And Vivek Deshpande(vdeshpande)
Regards,
Vivek
More information about the panama-dev
mailing list