Skip to content

Commit

Permalink
8320911: RISC-V: Enable hotspot/jtreg/compiler/intrinsics/chacha/Test…
Browse files Browse the repository at this point in the history
…ChaCha20.java

Reviewed-by: fyang
  • Loading branch information
Hamlin Li committed Nov 29, 2023
1 parent 77d604a commit 335f5db
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions test/hotspot/jtreg/compiler/intrinsics/chacha/TestChaCha20.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
* @bug 8247645
* @summary ChaCha20 Intrinsics
* @library /test/lib
* @requires (vm.cpu.features ~= ".*avx512.*" | vm.cpu.features ~= ".*avx2.*" | vm.cpu.features ~= ".*avx.*") |
* (os.arch=="aarch64" & vm.cpu.features ~= ".*simd.*") |
* (os.arch == "riscv64" & vm.cpu.features ~= ".*v,.*")
* @build compiler.intrinsics.chacha.ExerciseChaCha20
* jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
Expand All @@ -57,9 +60,13 @@ private static List<String> mix(List<String> o, String... mix) {
return n;
}

private static boolean containsFuzzy(List<String> list, String sub) {
private static boolean containsFuzzy(List<String> list, String sub, Boolean matchExactly) {
for (String s : list) {
if (s.contains(sub)) return true;
if (matchExactly) {
if (s.equals(sub)) return true;
} else {
if (s.contains(sub)) return true;
}
}
return false;
}
Expand All @@ -79,26 +86,32 @@ public static void main(String... args) throws Exception {
}

// Otherwise, select the tests that make sense on current platform.
if (containsFuzzy(cpuFeatures, "avx512")) {
if (containsFuzzy(cpuFeatures, "avx512", false)) {
System.out.println("Setting up AVX512 worker");
configs.add(List.of("-XX:UseAVX=3"));
}
if (containsFuzzy(cpuFeatures, "avx2")) {
if (containsFuzzy(cpuFeatures, "avx2", false)) {
System.out.println("Setting up AVX2 worker");
configs.add(List.of("-XX:UseAVX=2"));
}
if (containsFuzzy(cpuFeatures, "avx")) {
if (containsFuzzy(cpuFeatures, "avx", false)) {
System.out.println("Setting up AVX worker");
configs.add(List.of("-XX:UseAVX=1"));
}
} else if (Platform.isAArch64()) {
// AArch64 intrinsics require the advanced simd instructions
if (containsFuzzy(cpuFeatures, "simd")) {
if (containsFuzzy(cpuFeatures, "simd", false)) {
System.out.println("Setting up ASIMD worker");
configs.add(new ArrayList());
}
} else if (Platform.isRISCV64()) {
// Riscv64 intrinsics require the vector instructions
if (containsFuzzy(cpuFeatures, "v", true)) {
System.out.println("Setting up vector worker");
configs.add(List.of("-XX:+UseRVV"));
}
} else {
// We only have ChaCha20 intrinsics on x64 and aarch64
// We only have ChaCha20 intrinsics on x64, aarch64 and riscv64
// currently. If the platform is neither of these then
// the ChaCha20 known answer tests in
// com/sun/crypto/provider/Cipher are sufficient.
Expand Down

1 comment on commit 335f5db

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.