From 87247daadc1fa874ab4fd05e90f58e0e8b3eab3e Mon Sep 17 00:00:00 2001 From: Chris Sidebottom Date: Thu, 24 Jul 2025 11:30:43 +0000 Subject: [PATCH 1/3] Add NEOVERSEV2 target support Did a quick run around to make `TARGET=NEVOERSEV2` build successfully. Fixes #5385 --- Makefile.arm64 | 39 +++++++++++++++++++++++++++++++++--- cmake/cc.cmake | 49 ++++++++++++++++++++++++++++++++++++++++++++-- cmake/system.cmake | 40 +++++++++++++++++++++++++++++++++++++ getarch.c | 16 +++++++++++++++ param.h | 2 +- 5 files changed, 140 insertions(+), 6 deletions(-) diff --git a/Makefile.arm64 b/Makefile.arm64 index b27852691..b98933b77 100644 --- a/Makefile.arm64 +++ b/Makefile.arm64 @@ -1,3 +1,31 @@ +############################################################################### +# 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. +############################################################################### + ifneq ($(C_COMPILER), PGI) ifeq ($(C_COMPILER), CLANG) @@ -183,10 +211,15 @@ endif # Detect ARM Neoverse V2. ifeq ($(CORE), NEOVERSEV2) -ifeq (1, $(filter 1,$(GCCVERSIONGTEQ12) $(ISCLANG))) -CCOMMON_OPT += -march=armv9-a -mtune=neoverse-v2 +ifeq (1, $(filter 1,$(GCCVERSIONGTEQ13) $(ISCLANG))) +CCOMMON_OPT += -mcpu=neoverse-v2 +ifneq ($(F_COMPILER), NAG) +FCOMMON_OPT += -mcpu=neoverse-v2 +endif +else +CCOMMON_OPT += -march=armv8.2-a+sve+bf16 -mtune=neoverse-n1 ifneq ($(F_COMPILER), NAG) -FCOMMON_OPT += -march=armv9-a -mtune=neoverse-v2 +FCOMMON_OPT += -march=armv8.2-a -mtune=neoverse-n1 endif endif endif diff --git a/cmake/cc.cmake b/cmake/cc.cmake index 3679278b0..952b2dd7a 100644 --- a/cmake/cc.cmake +++ b/cmake/cc.cmake @@ -1,3 +1,30 @@ +############################################################################### +# 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. +############################################################################### ## ## Author: Hank Anderson ## Description: Ported from portion of OpenBLAS/Makefile.system @@ -192,6 +219,24 @@ if (${CORE} STREQUAL A64FX) endif () endif () +if (${CORE} STREQUAL NEOVERSEV2) + if (NOT DYNAMIC_ARCH) + if (${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT NO_SVE) + set (CCOMMON_OPT "${CCOMMON_OPT} -Msve_intrinsics -march=armv8.5-a+sve+sve2+bf16 -mtune=neoverse-v2") + elseif (${CMAKE_C_COMPILER_ID} STREQUAL "NVC" AND NOT NO_SVE) + set (CCOMMON_OPT "${CCOMMON_OPT} -tp=neoverse-v2") + else () + if (${GCC_VERSION} VERSION_GREATER 13.0 OR ${GCC_VERSION} VERSION_EQUAL 13.0) + set (CCOMMON_OPT "${CCOMMON_OPT} -mcpu=neoverse-v2") + elseif (${GCC_VERSION} VERSION_GREATER 10.4 OR ${GCC_VERSION} VERSION_EQUAL 10.4) + set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.4-a+sve+bf16 -mtune=neoverse-v1") + else () + set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.2-a+sve+bf16") + endif() + endif () + endif () +endif () + if (${CORE} STREQUAL NEOVERSEN2) if (NOT DYNAMIC_ARCH) if (${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT NO_SVE) @@ -199,10 +244,10 @@ if (${CORE} STREQUAL NEOVERSEN2) elseif (${CMAKE_C_COMPILER_ID} STREQUAL "NVC" AND NOT NO_SVE) set (CCOMMON_OPT "${CCOMMON_OPT} -tp=neoverse-v2") else () - if (${GCC_VERSION} VERSION_GREATER 10.4 OR ${GCC_VERSION} VERSION_EQUAL 10.4) + if (${GCC_VERSION} VERSION_GREATER 11.1 OR ${GCC_VERSION} VERSION_EQUAL 11.1) set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.5-a+sve+sve2+bf16 -mtune=neoverse-n2") else () - set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.2-a+sve") + set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.2-a+sve+bf16") endif() endif () endif () diff --git a/cmake/system.cmake b/cmake/system.cmake index 81f1a67ad..338f00947 100644 --- a/cmake/system.cmake +++ b/cmake/system.cmake @@ -1,3 +1,30 @@ +############################################################################### +# 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. +############################################################################### ## ## Author: Hank Anderson ## Description: Ported from OpenBLAS/Makefile.system @@ -311,6 +338,19 @@ if (${TARGET} STREQUAL NEOVERSEV1) endif() endif() endif() + if (${TARGET} STREQUAL NEOVERSEN2) + if (${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT NO_SVE) + set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -Msve-intrinsics -march=armv9-a+sve+sve2+bf16 -mtune=neoverse-v2") + else () + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER 13.0 OR CMAKE_C_COMPILER_VERSION VERSION_EQUAL 13.0) + set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mcpu=neoverse-v2") + elseif (CMAKE_C_COMPILER_VERSION VERSION_GREATER 10.4 OR CMAKE_C_COMPILER_VERSION VERSION_EQUAL 10.4) + set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -march=armv8.4-a+sve+bf16 -mtune=neoverse-v1") + else () + message(FATAL_ERROR "Compiler $${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_VERSION} does not support Neoverse N2.") + endif() + endif() + endif() if (${TARGET} STREQUAL ARMV8SVE) if (${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT NO_SVE) set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -Msve-intrinsics -march=armv8.2-a+sve") diff --git a/getarch.c b/getarch.c index 51c6705fe..417a3d08c 100644 --- a/getarch.c +++ b/getarch.c @@ -1498,6 +1498,22 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define CORENAME "NEOVERSEN2" #endif +#ifdef FORCE_NEOVERSEV2 +#define FORCE +#define ARCHITECTURE "ARM64" +#define SUBARCHITECTURE "NEOVERSEV2" +#define SUBDIRNAME "arm64" +#define ARCHCONFIG "-DNEOVERSEV2 " \ + "-DL1_CODE_SIZE=65536 -DL1_CODE_LINESIZE=64 -DL1_CODE_ASSOCIATIVE=4 " \ + "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 -DL1_DATA_ASSOCIATIVE=4 " \ + "-DL2_SIZE=1048576 -DL2_LINESIZE=64 -DL2_ASSOCIATIVE=16 " \ + "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \ + "-DHAVE_VFPV4 -DHAVE_VFPV3 -DHAVE_VFP -DHAVE_NEON -DHAVE_SVE -DARMV8 " \ + "-mcpu=neoverse-v2" +#define LIBNAME "neoversev2" +#define CORENAME "NEOVERSEV2" +#endif + #ifdef FORCE_CORTEXA55 #define FORCE #define ARCHITECTURE "ARM64" diff --git a/param.h b/param.h index 662d08449..7c8397f6a 100644 --- a/param.h +++ b/param.h @@ -3636,7 +3636,7 @@ is a big desktop or server with abundant cache rather than a phone or embedded d #define CGEMM_DEFAULT_R 4096 #define ZGEMM_DEFAULT_R 4096 -#elif defined(NEOVERSEN2) +#elif defined(NEOVERSEN2) || defined(NEOVERSEV2) #if defined(XDOUBLE) || defined(DOUBLE) #define SWITCH_RATIO 8 From 2f89a5970ea4ccb08d10aabd1e14b331269aa68e Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Fri, 25 Jul 2025 15:43:37 +0200 Subject: [PATCH 2/3] fix NeoverseV2 typo --- cmake/system.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/system.cmake b/cmake/system.cmake index 338f00947..2e43885b3 100644 --- a/cmake/system.cmake +++ b/cmake/system.cmake @@ -338,7 +338,7 @@ if (${TARGET} STREQUAL NEOVERSEV1) endif() endif() endif() - if (${TARGET} STREQUAL NEOVERSEN2) + if (${TARGET} STREQUAL NEOVERSEV2) if (${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT NO_SVE) set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -Msve-intrinsics -march=armv9-a+sve+sve2+bf16 -mtune=neoverse-v2") else () @@ -347,7 +347,7 @@ if (${TARGET} STREQUAL NEOVERSEV1) elseif (CMAKE_C_COMPILER_VERSION VERSION_GREATER 10.4 OR CMAKE_C_COMPILER_VERSION VERSION_EQUAL 10.4) set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -march=armv8.4-a+sve+bf16 -mtune=neoverse-v1") else () - message(FATAL_ERROR "Compiler $${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_VERSION} does not support Neoverse N2.") + message(FATAL_ERROR "Compiler $${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_VERSION} does not support Neoverse V2.") endif() endif() endif() From b9e107932a1b6491715dbeed0cf59dcb30c1879a Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Fri, 25 Jul 2025 15:44:34 +0200 Subject: [PATCH 3/3] add NeoverseV2 --- TargetList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/TargetList.txt b/TargetList.txt index 0c94869e7..b890c1440 100644 --- a/TargetList.txt +++ b/TargetList.txt @@ -102,6 +102,7 @@ CORTEXX2 NEOVERSEN1 NEOVERSEV1 NEOVERSEN2 +NEOVERSEV2 CORTEXA55 EMAG8180 FALKOR