Repository navigation
x86_64/arm64: fix complex Level-1 threaded worker ABI and dummy_alpha - #6272
Conversation
In legacy_exec, complex Level-1 jobs read two FLOAT elements from args->alpha and invoke the worker callback with both real and imaginary alpha arguments. Several x86_64 and arm64 complex Level-1 thread wrappers violate this calling convention in two ways. First, x86_64 casum, zasum, csum, and zsum plus ten arm64 thunderx2t99 Level-1 kernels declare a single FLOAT dummy2 parameter in their worker callbacks. Under the Windows x64 and ARM64EC ABIs, the missing fifth parameter shifts all stack arguments by 8 bytes, causing result to read ldb (NULL) and crash with an access violation whenever n > 10000 on multiple threads. In dual real/complex arm64 kernels (copy, dznrm2, dznrm2_fast, and scnrm2), guard the two-scalar signature under COMPLEX. Second, x86_64 zdot and six arm64 thunderx2t99 kernels pass a scalar dummy_alpha to blas_level1_thread_with_return_value or blas_level1_thread, causing an out-of-bounds stack read of alpha[1] in legacy_exec. Zero-initialize dummy_alpha[2] across all affected files and add multithreaded complex Level-1 regression tests in utest.
90984d4 to
425c5ea
Compare
|
Looks like there is something wrong with the Loongson zdot (assembly) kernels too, curiosly only visible in single-precision mode so could be unrelated to your change. And I guess no CI test executes the related Loongson3R3 kernel in mips64/zdot.S (all the other mips targets use plain C kernels) . All other CI failures are explained by the test issues fixed yesterday (Jenkins remains broken until OSUOSL gets their Java stack in order again) |
|
Loongson fault is definitely pre-existing, doesn't depend on thread count or even on having a large N, the difference appears to be a constant -4.0 no matter if N is 25 or 2005 so it's probably something silly but I'm too tired to track it down tonight. |
|
So actually it is the Loongarch SCASUM that is failing for N>7 - which begs the question if there really need to be unannounced tests for other BLAS functions lurking under the new cdot/zdot regression test ? |
|
This has to be a trivial error, but I'm only finding obvious typos in the non-unary increments branch, and all three affected kernels are of course closely related. I have reverted them to the generic C kernel in #6284 so as not to block further merging |
Summary
In
legacy_exec(blas_server.c,blas_server_win32.c, andblas_server_omp.c), everyBLAS_COMPLEXLevel-1 job reads both((FLOAT *)args->alpha)[0]and((FLOAT *)args->alpha)[1]and invokes the worker function with twoFLOATscalar arguments (dummy2r,dummy2i) prior to the vector pointers. Severalx86_64andarm64complex Level-1 threaded kernels violate this contract. Specifically,kernel/x86_64/{casum,zasum,csum,zsum}.c(active on SkylakeX, Cooperlake, SapphireRapids, Zen4, and Zen5) and tenkernel/arm64/*_thunderx2t99.cfiles declare a singleFLOAT dummy2parameter in their worker callbacks. Under the Windows x64 and ARM64EC calling conventions, the missing fifth argument shifts all subsequent stack arguments by 8 bytes, soresultreceivesldb(0/NULL) and dereferencesNULLwhenevern > 10000runs on multiple threads. Additionally,kernel/x86_64/zdot.cand sixkernel/arm64/*_thunderx2t99.ckernels declareFLOAT dummy_alphaas a single scalar, which causeslegacy_execto readalpha[1]past the variable on the caller stack during every multithreaded call.Changes
FLOAT dummy2r, FLOAT dummy2iinkernel/x86_64/{casum,zasum,csum,zsum}.candkernel/arm64/{casum,zasum,csum,zsum,zdot,izamax}_thunderx2t99.c, matching commitb2053239finkernel/x86_64/zdot.c.FLOAT dummy2(!defined(COMPLEX)) vsFLOAT dummy2r, FLOAT dummy2i(defined(COMPLEX)) in dual-compiledkernel/arm64/{copy_thunderx2t99,dznrm2_thunderx2t99,dznrm2_thunderx2t99_fast,scnrm2_thunderx2t99}.c.FLOAT dummy_alpha[2] = {ZERO, ZERO}acrosskernel/x86_64/{casum,zasum,csum,zsum,zdot}.cand all tenkernel/arm64/*_thunderx2t99.cfiles, and alignint (*function)(void)prototypes withblas_l1_thread.c.N = 20005) complex Level-1 regression tests forcdotu,zdotu,scasum,dzasum,scnrm2,dznrm2,icamax,izamax,ccopy,zcopy,scsum, anddzsuminutest.Verification
x86_64(MinGW-w64 GCC 14.3.0,-DMS_ABI -DSMP_SERVER): callingdzasum,scasum,dzsum, andscsumfromkernel/x86_64/{zasum,casum,zsum,csum}.cwithn = 20005on 2 threads crashed withSTATUS_ACCESS_VIOLATION(0xC0000005) prior to this patch and returned exact sums (40010.0, exit code0) with this patch.openblas_utest(163/163passed) andopenblas_utest_ext(1547/1547passed) with zero compiler warnings.