Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8368722

RISC-V: Several vector load/store tests fail due to lack of support for misaligned vector access

XMLWordPrintable

    • riscv
    • linux

      In `*VectorLoadStoreTests.java`, `loadMemorySegmentMaskIOOBE` and `storeMemorySegmentMaskIOOBE` may fail because `int index = fi.apply((int) a.byteSize())` can generate random indices that result in misaligned addresses, leading to SIGBUS on hardware that disallows misaligned vector accesses.

      Some RISC-V hardware supports fast misaligned scalar accesses but not vector ones, which causes SIGBUS when executing these tests with misaligned vector memory operations.

      After JDK-8368732, we can use AlignVector to check the result on platforms with or without fast misaligned vector accesses. When misaligned vector accesses are not supported, it is possible to completely disable the VM’s VectorAPI support by setting EnableVectorSupport, without affecting auto-vectorization.

      In addition, after running fastdebug tests including jdk_vector, jdk_vector_sanity, hotspot_vector_1, hotspot_vector_2, compiler/vectorapi, and compiler/vectorization, we found that these IR-related tests require EnableVectorSupport:
      test/hotspot/jtreg/compiler/rangechecks/TestRangeCheckHoistingScaledIV.java
      test/hotspot/jtreg/compiler/vectorapi/TestVectorAddMulReduction.java
      test/hotspot/jtreg/compiler/vectorapi/TestVectorTest.java
      test/hotspot/jtreg/compiler/vectorapi/VectorCommutativeOperSharingTest.java
      test/hotspot/jtreg/compiler/vectorapi/VectorExpandTest.java
      test/hotspot/jtreg/compiler/vectorapi/VectorFusedMultiplyAddSubTest.java
      test/hotspot/jtreg/compiler/vectorapi/VectorMaskCompareNotTest.java
      test/hotspot/jtreg/compiler/vectorapi/VectorMaskFromLongTest.java
      test/hotspot/jtreg/compiler/vectorapi/VectorMaskLaneIsSetTest.java
      test/hotspot/jtreg/compiler/vectorapi/VectorMaskToLongTest.java
      test/hotspot/jtreg/compiler/vectorapi/VectorSaturatedOperationsTest.java
      test/hotspot/jtreg/compiler/vectorapi/VectorUnsignedMinMaxOperationsTest.java
      test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorCastRVV.java
      test/hotspot/jtreg/compiler/vectorapi/reshape/TestVectorReinterpret.java

      Therefore, we added `@requires vm.opt.EnableVectorSupport == true` to skip these tests.

      Failed tests:
      jdk/incubator/vector/Double128VectorLoadStoreTests.java
      jdk/incubator/vector/Double256VectorLoadStoreTests.java
      jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java
      jdk/incubator/vector/Float128VectorLoadStoreTests.java
      jdk/incubator/vector/Float256VectorLoadStoreTests.java
      jdk/incubator/vector/Float64VectorLoadStoreTests.java
      jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java
      jdk/incubator/vector/Int128VectorLoadStoreTests.java
      jdk/incubator/vector/Int256VectorLoadStoreTests.java
      jdk/incubator/vector/Int64VectorLoadStoreTests.java
      jdk/incubator/vector/IntMaxVectorLoadStoreTests.java
      jdk/incubator/vector/Long128VectorLoadStoreTests.java
      jdk/incubator/vector/Long256VectorLoadStoreTests.java
      jdk/incubator/vector/LongMaxVectorLoadStoreTests.java
      jdk/incubator/vector/Short128VectorLoadStoreTests.java
      jdk/incubator/vector/Short256VectorLoadStoreTests.java
      jdk/incubator/vector/Short64VectorLoadStoreTests.java
      jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java

      Error log of `Short128VectorLoadStoreTests.java`:

      ```
      test Short128VectorLoadStoreTests.loadMemorySegmentMaskIOOBE(short[i * 5], l + 1, mask[i % 2]): success [106ms]
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # SIGBUS (0x7) at pc=0x0000003fa439695c, pid=304030, tid=304053
      #
      # JRE version: OpenJDK Runtime Environment (26.0) (build 26-internal-adhoc.zhangdingli.jdk)
      # Java VM: OpenJDK 64-Bit Server VM (26-internal-adhoc.zhangdingli.jdk, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
      # Problematic frame:
      # J 997 c2 jdk.incubator.vector.Short128Vector.fromMemorySegment0(Ljava/lang/foreign/MemorySegment;JLjdk/incubator/vector/VectorMask;I)Ljdk/incubator/vector/ShortVector; jdk.incubator.vector@26-internal (16 bytes) @ 0x0000003fa439695c [0x0000003fa4396880+0x00000000000000dc]
      #
      # Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %d %F" (or dumping to /home/zhangdingli/jdk/build/linux-riscv64-server-release/test-support/jtreg_test_jdk_jdk_vector/scratch/6/core.304030)
      #
      # An error report file with more information is saved as:
      # /home/zhangdingli/jdk/build/linux-riscv64-server-release/test-support/jtreg_test_jdk_jdk_vector/scratch/6/hs_err_pid304030.log
      [32.542s][warning][os] Loading hsdis library failed
      #
      # If you would like to submit a bug report, please visit:
      # https://bugreport.java.com/bugreport/crash.jsp
      #
      ----------System.err:(1/55)----------
      WARNING: Using incubator modules: jdk.incubator.vector
      ```

            dzhang Dingli Zhang
            dzhang Dingli Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: