[lworld+vector] RFR: 8304310: Initial compilers and runtime handling for multifield backed vectors. [v2]

Xiaohong Gong xgong at openjdk.org
Fri Mar 24 02:20:05 UTC 2023


On Thu, 23 Mar 2023 06:10:38 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> Please find below the summary of changes included with the patch:
>>   
>> a) _ci Model:_
>>    oops model creates separate fieldDescriptor/FieldInfo for each scalar field of a multifield bundle, root field is marked as multifield_base and non -  root (synthetic) fileds carry a multifield flag. To ease vector IR construction ci only exposes base multifield and ciType holding bundle size to compilers.
>> 
>> b) _C1 compiler:_
>>    Special handling to copy entire multifield bundle during withfield bytecode processing.
>> 
>> c) _C2 compiler:_
>>    VectorBox becomes a derivative of InlineType IR node, changes in vector box/unbox expansions. Preventing scalarization of Vector arguments and return values.
>> 
>> d) _Runtime:_
>>    Changes in object re-construction during deoptimization since now concrete vectors have multifield based payloads. Payload (VectorPayloadMF) is a primitive class object which gets fully flattened within its parent/holding instance i.e. a concrete vector, special handling has been added for non-flattened case where payload is allocated over heap and concrete vector payload field is assigned its reference.
>> 
>> e) Added type specific multifield payloads to ease vector IR creation by C2, this will ensure bundle type and C2 IR type are compatible.               
>> 
>> Scope of current changes is limited to Vector types only, shuffles and masks are still backed by array based payloads. This PoC patch has been validated over vector only tests. More robust validation will be done in due course.
>> 
>> More information can be found at following link
>> [https://cr.openjdk.org/~jbhateja/vectorIntrinsics/Valhalla/lworld%2Bvector.pptx](https://cr.openjdk.org/~jbhateja/vectorIntrinsics/Valhalla/lworld%2Bvector.pptx)
>> 
>> Please share your feedback and suggestions.
>> 
>> Best Regards,
>> Jatin
>
> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix incorrect type size computation during withfield handling in c1.

Hi @jatin-bhateja ,

I ran an unit test on a ARM NEON system, and the jvm crashes with following log:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/mnt/local/code/valhalla/src/hotspot/share/opto/loopnode.cpp:5871), pid=544741, tid=544757
#  assert(false) failed: Bad graph detected in build_loop_late
#
# JRE version: OpenJDK Runtime Environment (21.0) (fastdebug build 21-internal-git-558fb2e03)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 21-internal-git-558fb2e03, mixed mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
# Problematic frame:
# V  [libjvm.so+0x13b395c]  PhaseIdealLoop::build_loop_late_post_work(Node*, bool)+0x18c
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /mnt/local/code/test/vector_api/aarch64/armie/core.544741)
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

And here is the call stack:

---------------  T H R E A D  ---------------

Current thread (0x0000fffe0008dc80):  JavaThread "C2 CompilerThread2" daemon [_thread_in_native, id=544757, stack(0x0000fffe24d00000,0x0000fffe24f00000)]


Current CompileTask:
C2:    377  172             jdk.incubator.vector.IntVector::fromArray0Template (39 bytes)

Stack: [0x0000fffe24d00000,0x0000fffe24f00000],  sp=0x0000fffe24ef9920,  free space=2022k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x13b395c]  PhaseIdealLoop::build_loop_late_post_work(Node*, bool)+0x18c  (loopnode.cpp:5871)
V  [libjvm.so+0x13b4194]  PhaseIdealLoop::build_loop_late(VectorSet&, Node_List&, Node_Stack&)+0xd4  (loopnode.cpp:5775)
V  [libjvm.so+0x13b4aa4]  PhaseIdealLoop::build_and_optimize()+0x4d0  (loopnode.cpp:4403)
V  [libjvm.so+0xa30f28]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x1e8  (loopnode.hpp:1086)
V  [libjvm.so+0xa2be08]  Compile::Optimize()+0x428  (compile.cpp:2828)
V  [libjvm.so+0xa2f10c]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x11ec  (compile.cpp:842)
V  [libjvm.so+0x829cd4]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x3f0  (c2compiler.cpp:113)
V  [libjvm.so+0xa3c410]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xbb0  (compileBroker.cpp:2237)
V  [libjvm.so+0xa3cd44]  CompileBroker::compiler_thread_loop()+0x3f4  (compileBroker.cpp:1916)
V  [libjvm.so+0xf92068]  JavaThread::thread_main_inner()+0x2f4  (javaThread.cpp:710)
V  [libjvm.so+0x1a3afb8]  Thread::call_run()+0xf8  (thread.cpp:224)
V  [libjvm.so+0x15f6814]  thread_native_entry(Thread*)+0x100  (os_linux.cpp:739)
C  [libc.so.6+0x7d5c8]

The unit test is:

static VectorSpecies<Integer> I_SPECIES = IntVector.SPECIES_PREFERRED;

for (int i = 0; i < LENGTH; i += vl) {
            var av = IntVector.fromArray(I_SPECIES, ia, i);
            var bv = IntVector.fromArray(I_SPECIES, ib, i);
            av.lanewise(VectorOperators.ADD, bv).intoArray(ic, i);
}

And I cannot reproduce the same issue on a X86 AVX-512 machine. But from the log, it seems not an AArch64 backend issue. So do you have any idea or met this issue before?

BTW, is it possible to split this big patch into two parts: 1) multi-field vectorization part 2) hotspot compiler support for vector intrinsification part. This patch is too big which covers several compiler/runtime support parts. It's not so easy to analysis the issue to me once it happens. And I also tried to separate it by myself. But unfortunately, I also met another JVM crash issue which may related to the register allocation to vector registers on AArch64 when testing the "multi-fields" vectorization changes. I'm not sure whether I have missed something when doing the separation. But it will be helpful to look at the issue with your help.  Thanks a lot!

Best Regards,
Xiaohong

-------------

PR Comment: https://git.openjdk.org/valhalla/pull/833#issuecomment-1482157644



More information about the valhalla-dev mailing list