Skip to content

Commit c504aed

Browse files
authored
Merge pull request #5400 from Mousius/neoversev2-target
Add NEOVERSEV2 target support
2 parents b4c2b34 + b9e1079 commit c504aed

File tree

6 files changed

+141
-6
lines changed

6 files changed

+141
-6
lines changed

Makefile.arm64

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
###############################################################################
2+
# Copyright (c) 2025, The OpenBLAS Project
3+
# All rights reserved.
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are
6+
# met:
7+
# 1. Redistributions of source code must retain the above copyright
8+
# notice, this list of conditions and the following disclaimer.
9+
# 2. Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in
11+
# the documentation and/or other materials provided with the
12+
# distribution.
13+
# 3. Neither the name of the OpenBLAS project nor the names of
14+
# its contributors may be used to endorse or promote products
15+
# derived from this software without specific prior written permission.
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
# ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
20+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
# POSSIBILITY OF SUCH DAMAGE.
27+
###############################################################################
28+
129
ifneq ($(C_COMPILER), PGI)
230

331
ifeq ($(C_COMPILER), CLANG)
@@ -183,10 +211,15 @@ endif
183211

184212
# Detect ARM Neoverse V2.
185213
ifeq ($(CORE), NEOVERSEV2)
186-
ifeq (1, $(filter 1,$(GCCVERSIONGTEQ12) $(ISCLANG)))
187-
CCOMMON_OPT += -march=armv9-a -mtune=neoverse-v2
214+
ifeq (1, $(filter 1,$(GCCVERSIONGTEQ13) $(ISCLANG)))
215+
CCOMMON_OPT += -mcpu=neoverse-v2
216+
ifneq ($(F_COMPILER), NAG)
217+
FCOMMON_OPT += -mcpu=neoverse-v2
218+
endif
219+
else
220+
CCOMMON_OPT += -march=armv8.2-a+sve+bf16 -mtune=neoverse-n1
188221
ifneq ($(F_COMPILER), NAG)
189-
FCOMMON_OPT += -march=armv9-a -mtune=neoverse-v2
222+
FCOMMON_OPT += -march=armv8.2-a -mtune=neoverse-n1
190223
endif
191224
endif
192225
endif

TargetList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ CORTEXX2
102102
NEOVERSEN1
103103
NEOVERSEV1
104104
NEOVERSEN2
105+
NEOVERSEV2
105106
CORTEXA55
106107
EMAG8180
107108
FALKOR

cmake/cc.cmake

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
###############################################################################
2+
# Copyright (c) 2025, The OpenBLAS Project
3+
# All rights reserved.
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are
6+
# met:
7+
# 1. Redistributions of source code must retain the above copyright
8+
# notice, this list of conditions and the following disclaimer.
9+
# 2. Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in
11+
# the documentation and/or other materials provided with the
12+
# distribution.
13+
# 3. Neither the name of the OpenBLAS project nor the names of
14+
# its contributors may be used to endorse or promote products
15+
# derived from this software without specific prior written permission.
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
# ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
20+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
# POSSIBILITY OF SUCH DAMAGE.
27+
###############################################################################
128
##
229
## Author: Hank Anderson <[email protected]>
330
## Description: Ported from portion of OpenBLAS/Makefile.system
@@ -192,17 +219,35 @@ if (${CORE} STREQUAL A64FX)
192219
endif ()
193220
endif ()
194221

222+
if (${CORE} STREQUAL NEOVERSEV2)
223+
if (NOT DYNAMIC_ARCH)
224+
if (${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT NO_SVE)
225+
set (CCOMMON_OPT "${CCOMMON_OPT} -Msve_intrinsics -march=armv8.5-a+sve+sve2+bf16 -mtune=neoverse-v2")
226+
elseif (${CMAKE_C_COMPILER_ID} STREQUAL "NVC" AND NOT NO_SVE)
227+
set (CCOMMON_OPT "${CCOMMON_OPT} -tp=neoverse-v2")
228+
else ()
229+
if (${GCC_VERSION} VERSION_GREATER 13.0 OR ${GCC_VERSION} VERSION_EQUAL 13.0)
230+
set (CCOMMON_OPT "${CCOMMON_OPT} -mcpu=neoverse-v2")
231+
elseif (${GCC_VERSION} VERSION_GREATER 10.4 OR ${GCC_VERSION} VERSION_EQUAL 10.4)
232+
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.4-a+sve+bf16 -mtune=neoverse-v1")
233+
else ()
234+
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.2-a+sve+bf16")
235+
endif()
236+
endif ()
237+
endif ()
238+
endif ()
239+
195240
if (${CORE} STREQUAL NEOVERSEN2)
196241
if (NOT DYNAMIC_ARCH)
197242
if (${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT NO_SVE)
198243
set (CCOMMON_OPT "${CCOMMON_OPT} -Msve_intrinsics -march=armv8.5-a+sve+sve2+bf16 -mtune=neoverse-n2")
199244
elseif (${CMAKE_C_COMPILER_ID} STREQUAL "NVC" AND NOT NO_SVE)
200245
set (CCOMMON_OPT "${CCOMMON_OPT} -tp=neoverse-v2")
201246
else ()
202-
if (${GCC_VERSION} VERSION_GREATER 10.4 OR ${GCC_VERSION} VERSION_EQUAL 10.4)
247+
if (${GCC_VERSION} VERSION_GREATER 11.1 OR ${GCC_VERSION} VERSION_EQUAL 11.1)
203248
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.5-a+sve+sve2+bf16 -mtune=neoverse-n2")
204249
else ()
205-
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.2-a+sve")
250+
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.2-a+sve+bf16")
206251
endif()
207252
endif ()
208253
endif ()

cmake/system.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
###############################################################################
2+
# Copyright (c) 2025, The OpenBLAS Project
3+
# All rights reserved.
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are
6+
# met:
7+
# 1. Redistributions of source code must retain the above copyright
8+
# notice, this list of conditions and the following disclaimer.
9+
# 2. Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in
11+
# the documentation and/or other materials provided with the
12+
# distribution.
13+
# 3. Neither the name of the OpenBLAS project nor the names of
14+
# its contributors may be used to endorse or promote products
15+
# derived from this software without specific prior written permission.
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
# ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
20+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
# POSSIBILITY OF SUCH DAMAGE.
27+
###############################################################################
128
##
229
## Author: Hank Anderson <[email protected]>
330
## Description: Ported from OpenBLAS/Makefile.system
@@ -311,6 +338,19 @@ if (${TARGET} STREQUAL NEOVERSEV1)
311338
endif()
312339
endif()
313340
endif()
341+
if (${TARGET} STREQUAL NEOVERSEV2)
342+
if (${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT NO_SVE)
343+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -Msve-intrinsics -march=armv9-a+sve+sve2+bf16 -mtune=neoverse-v2")
344+
else ()
345+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER 13.0 OR CMAKE_C_COMPILER_VERSION VERSION_EQUAL 13.0)
346+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mcpu=neoverse-v2")
347+
elseif (CMAKE_C_COMPILER_VERSION VERSION_GREATER 10.4 OR CMAKE_C_COMPILER_VERSION VERSION_EQUAL 10.4)
348+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -march=armv8.4-a+sve+bf16 -mtune=neoverse-v1")
349+
else ()
350+
message(FATAL_ERROR "Compiler $${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_VERSION} does not support Neoverse V2.")
351+
endif()
352+
endif()
353+
endif()
314354
if (${TARGET} STREQUAL ARMV8SVE)
315355
if (${CMAKE_C_COMPILER_ID} STREQUAL "PGI" AND NOT NO_SVE)
316356
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -Msve-intrinsics -march=armv8.2-a+sve")

getarch.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,22 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14981498
#define CORENAME "NEOVERSEN2"
14991499
#endif
15001500

1501+
#ifdef FORCE_NEOVERSEV2
1502+
#define FORCE
1503+
#define ARCHITECTURE "ARM64"
1504+
#define SUBARCHITECTURE "NEOVERSEV2"
1505+
#define SUBDIRNAME "arm64"
1506+
#define ARCHCONFIG "-DNEOVERSEV2 " \
1507+
"-DL1_CODE_SIZE=65536 -DL1_CODE_LINESIZE=64 -DL1_CODE_ASSOCIATIVE=4 " \
1508+
"-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 -DL1_DATA_ASSOCIATIVE=4 " \
1509+
"-DL2_SIZE=1048576 -DL2_LINESIZE=64 -DL2_ASSOCIATIVE=16 " \
1510+
"-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
1511+
"-DHAVE_VFPV4 -DHAVE_VFPV3 -DHAVE_VFP -DHAVE_NEON -DHAVE_SVE -DARMV8 " \
1512+
"-mcpu=neoverse-v2"
1513+
#define LIBNAME "neoversev2"
1514+
#define CORENAME "NEOVERSEV2"
1515+
#endif
1516+
15011517
#ifdef FORCE_CORTEXA55
15021518
#define FORCE
15031519
#define ARCHITECTURE "ARM64"

param.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3636,7 +3636,7 @@ is a big desktop or server with abundant cache rather than a phone or embedded d
36363636
#define CGEMM_DEFAULT_R 4096
36373637
#define ZGEMM_DEFAULT_R 4096
36383638

3639-
#elif defined(NEOVERSEN2)
3639+
#elif defined(NEOVERSEN2) || defined(NEOVERSEV2)
36403640

36413641
#if defined(XDOUBLE) || defined(DOUBLE)
36423642
#define SWITCH_RATIO 8

0 commit comments

Comments
 (0)