From a14caf464f31f628623f5384c48b36da56301975 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 17 Nov 2025 16:49:11 +0530 Subject: [PATCH] add tt for a64fx dot Signed-off-by: Abhishek Kumar --- kernel/arm64/KERNEL.A64FX | 4 ++-- kernel/arm64/dot.c | 37 ++++++++++++++++++++++++++++++++++--- kernel/arm64/dot_sve_v8.c | 34 ---------------------------------- 3 files changed, 36 insertions(+), 39 deletions(-) delete mode 100644 kernel/arm64/dot_sve_v8.c diff --git a/kernel/arm64/KERNEL.A64FX b/kernel/arm64/KERNEL.A64FX index edcff43bc0..6c1da89532 100644 --- a/kernel/arm64/KERNEL.A64FX +++ b/kernel/arm64/KERNEL.A64FX @@ -5,8 +5,8 @@ DGEMVNKERNEL = gemv_n_sve_v4x3.c SGEMVTKERNEL = gemv_t_sve_v4x3.c DGEMVTKERNEL = gemv_t_sve_v4x3.c -DDOTKERNEL = dot_sve_v8.c -SDOTKERNEL = dot_sve_v8.c +DDOTKERNEL = dot.c +SDOTKERNEL = dot.c SAXPYKERNEL = axpy_sve.c DAXPYKERNEL = axpy_sve.c diff --git a/kernel/arm64/dot.c b/kernel/arm64/dot.c index 068843ee40..1e49ffdd60 100644 --- a/kernel/arm64/dot.c +++ b/kernel/arm64/dot.c @@ -42,6 +42,8 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef USE_SVE #ifdef DOT_KERNEL_SVE #include DOT_KERNEL_SVE +#elif defined(A64FX) +#include "dot_kernel_sve_v8.c" #else #include "dot_kernel_sve.c" #endif @@ -82,14 +84,43 @@ static inline int get_dot_optimal_nthreads_neoversev1(BLASLONG N, int ncpu) { } #endif +#if defined(DYNAMIC_ARCH) || defined(A64FX) +static inline int get_dot_optimal_nthreads_a64fx(BLASLONG N, int ncpu) { + #ifdef DOUBLE + return (N <= 11000L) ? 1 + : (N <= 20000L) ? MIN(ncpu, 2) + : (N <= 35000L) ? MIN(ncpu, 4) + : (N <= 50000L) ? MIN(ncpu, 6) + : (N <= 440000L) ? MIN(ncpu, 8) + : (N <= 880000L) ? MIN(ncpu, 16) + : (N <= 1020000L) ? MIN(ncpu, 24) + : ncpu; + #else + return (N <= 22000L) ? 1 + : (N <= 39000L) ? MIN(ncpu, 2) + : (N <= 79000L) ? MIN(ncpu, 4) + : (N <= 120000L) ? MIN(ncpu, 6) + : (N <= 1020000L) ? MIN(ncpu, 8) + : ncpu; + #endif +} +#endif + static inline int get_dot_optimal_nthreads(BLASLONG n) { int ncpu = num_cpu_avail(1); -#if defined(NEOVERSEV1) && !defined(COMPLEX) && !defined(BFLOAT16) +#if defined(A64FX) && !defined(COMPLEX) && !defined(BFLOAT16) + return get_dot_optimal_nthreads_a64fx(n, ncpu); +#elif defined(NEOVERSEV1) && !defined(COMPLEX) && !defined(BFLOAT16) return get_dot_optimal_nthreads_neoversev1(n, ncpu); #elif defined(DYNAMIC_ARCH) && !defined(COMPLEX) && !defined(BFLOAT16) - if (strcmp(gotoblas_corename(), "neoversev1") == 0) { - return get_dot_optimal_nthreads_neoversev1(n, ncpu); + { + const char *core = gotoblas_corename(); + if (strcmp(core, "a64fx") == 0) { + return get_dot_optimal_nthreads_a64fx(n, ncpu); + } else if (strcmp(core, "neoversev1") == 0) { + return get_dot_optimal_nthreads_neoversev1(n, ncpu); + } } #endif diff --git a/kernel/arm64/dot_sve_v8.c b/kernel/arm64/dot_sve_v8.c deleted file mode 100644 index ace47b4e75..0000000000 --- a/kernel/arm64/dot_sve_v8.c +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** -Copyright (c) 2025, The OpenBLAS Project -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - 3. Neither the name of the OpenBLAS project nor the names of - its contributors may be used to endorse or promote products - derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*****************************************************************************/ - -#define DOT_KERNEL_SVE "dot_kernel_sve_v8.c" -#include "dot.c"