Skip to content

Commit f4d1f03

Browse files
authored
Merge pull request #3474 from rafaelcfsousa/rafael/cmake_power
Add CMake support for Power
2 parents 697e275 + d38110a commit f4d1f03

File tree

5 files changed

+75
-9
lines changed

5 files changed

+75
-9
lines changed

cmake/cc.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,34 @@ if (${CORE} STREQUAL ARMV8SVE)
161161
endif ()
162162
endif ()
163163

164+
if (${CORE} STREQUAL POWER10)
165+
if (NOT DYNAMIC_ARCH)
166+
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
167+
if (${GCC_VERSION} VERSION_GREATER 10.2 OR ${GCC_VERSION} VERSION_EQUAL 10.2)
168+
set (CCOMMON_OPT "${CCOMMON_OPT} -mcpu=power10 -mtune=power10 -mvsx -fno-fast-math")
169+
else ()
170+
message(FATAL_ERROR "Compiler GCC.${GCC_VERSION} does not support Power10." )
171+
endif()
172+
endif ()
173+
endif ()
174+
175+
if (${CORE} STREQUAL POWER9)
176+
if (NOT DYNAMIC_ARCH)
177+
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
178+
if (${GCC_VERSION} VERSION_GREATER 5.0 OR ${GCC_VERSION} VERSION_EQUAL 5.0)
179+
set (CCOMMON_OPT "${CCOMMON_OPT} -mcpu=power9 -mtune=power9 -mvsx -fno-fast-math")
180+
else ()
181+
set (CCOMMON_OPT "${CCOMMON_OPT} -mcpu=power8 -mtune=power8 -mvsx -fno-fast-math")
182+
message(WARNING "Compiler GCC.${GCC_VERSION} does not fully support Power9.")
183+
endif ()
184+
endif ()
185+
endif ()
186+
187+
if (${CORE} STREQUAL POWER8)
188+
if (NOT DYNAMIC_ARCH)
189+
set (CCOMMON_OPT "${CCOMMON_OPT} -mcpu=power8 -mtune=power8 -mvsx -fno-fast-math")
190+
endif ()
191+
endif ()
164192

165193
if (NOT DYNAMIC_ARCH)
166194
if (HAVE_AVX2)

cmake/system.cmake

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ if (DEFINED BINARY AND DEFINED TARGET AND BINARY EQUAL 32)
4242
if (${TARGET} STREQUAL "ARMV8" OR ${TARGET} STREQUAL "CORTEXA57" OR ${TARGET} STREQUAL "CORTEXA53" OR ${TARGET} STREQUAL "CORTEXA55")
4343
set(TARGET "ARMV7")
4444
endif ()
45+
if (${TARGET} STREQUAL "POWER8" OR ${TARGET} STREQUAL "POWER9" OR ${TARGET} STREQUAL "POWER10")
46+
set(TARGET "POWER6")
47+
endif ()
4548
endif ()
4649

4750

@@ -102,6 +105,18 @@ if (CMAKE_C_COMPILER STREQUAL loongcc)
102105
set(GETARCH_FLAGS "${GETARCH_FLAGS} -static")
103106
endif ()
104107

108+
if (POWER)
109+
set(NO_WARMUP 1)
110+
set(HAVE_GAS 1)
111+
if (CMAKE_ASM_COMPILER_ID STREQUAL "GNU")
112+
set(HAVE_GAS 0)
113+
elseif (CMAKE_ASM_COMPILER_ID STREQUAL "Clang")
114+
set(CCOMMON_OPT "${CCOMMON_OPT} -fno-integrated-as")
115+
set(HAVE_GAS 0)
116+
endif ()
117+
set(GETARCH_FLAGS "${GETARCH_FLAGS} -DHAVE_GAS=${HAVE_GAS}")
118+
endif ()
119+
105120
#if don't use Fortran, it will only compile CBLAS.
106121
if (ONLY_CBLAS)
107122
set(NO_LAPACK 1)
@@ -222,6 +237,27 @@ if (DEFINED TARGET)
222237
if (DEFINED HAVE_SSE4_1)
223238
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -msse4.1")
224239
endif()
240+
241+
if (${TARGET} STREQUAL POWER10)
242+
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
243+
if (${GCC_VERSION} VERSION_GREATER 10.2 OR ${GCC_VERSION} VERSION_EQUAL 10.2)
244+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mcpu=power10 -mtune=power10 -mvsx -fno-fast-math")
245+
else ()
246+
message(FATAL_ERROR "Compiler GCC.${GCC_VERSION} does not support Power10.")
247+
endif()
248+
endif()
249+
if (${TARGET} STREQUAL POWER9)
250+
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
251+
if (${GCC_VERSION} VERSION_GREATER 5.0 OR ${GCC_VERSION} VERSION_EQUAL 5.0)
252+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mcpu=power9 -mtune=power9 -mvsx -fno-fast-math")
253+
else ()
254+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mcpu=power8 -mtune=power8 -mvsx -fno-fast-math")
255+
message(WARNING "Compiler GCC.${GCC_VERSION} does not support fully Power9.")
256+
endif()
257+
endif()
258+
if (${TARGET} STREQUAL POWER8)
259+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mcpu=power8 -mtune=power8 -mvsx -fno-fast-math")
260+
endif()
225261
endif()
226262
if (DEFINED BINARY)
227263
message(STATUS "Compiling a ${BINARY}-bit binary.")
@@ -279,15 +315,15 @@ if (NEED_PIC)
279315
endif()
280316
endif ()
281317

282-
if (X86_64)
318+
if (X86_64 OR ${CORE} STREQUAL POWER10)
283319
set(SMALL_MATRIX_OPT TRUE)
284320
endif ()
285321
if (SMALL_MATRIX_OPT)
286322
set(CCOMMON_OPT "${CCOMMON_OPT} -DSMALL_MATRIX_OPT")
287323
endif ()
288324

289325
if (DYNAMIC_ARCH)
290-
if (X86 OR X86_64 OR ARM64 OR PPC)
326+
if (X86 OR X86_64 OR ARM64 OR POWER)
291327
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_ARCH")
292328
if (DYNAMIC_OLDER)
293329
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_OLDER")

cmake/system_check.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if(CMAKE_CL_64 OR MINGW64)
3535
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING))
3636
set(X86 1)
3737
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc.*|power.*|Power.*")
38-
set(PPC 1)
38+
set(POWER 1)
3939
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "mips64.*")
4040
set(MIPS64 1)
4141
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch64.*")
@@ -88,7 +88,7 @@ if (X86_64)
8888
set(ARCH "x86_64")
8989
elseif(X86)
9090
set(ARCH "x86")
91-
elseif(PPC)
91+
elseif(POWER)
9292
set(ARCH "power")
9393
elseif(MIPS32)
9494
set(ARCH "mips")
@@ -103,7 +103,7 @@ else()
103103
endif ()
104104

105105
if (NOT BINARY)
106-
if (X86_64 OR ARM64 OR PPC OR MIPS64 OR LOONGARCH64)
106+
if (X86_64 OR ARM64 OR POWER OR MIPS64 OR LOONGARCH64)
107107
set(BINARY 64)
108108
else ()
109109
set(BINARY 32)

driver/others/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ GenerateNamedObjects("openblas_get_config.c;openblas_get_parallel.c" "" "" 0 ""
4949
if (DYNAMIC_ARCH)
5050
if (ARM64)
5151
list(APPEND COMMON_SOURCES dynamic_arm64.c)
52+
elseif (POWER)
53+
list(APPEND COMMON_SOURCES dynamic_power.c)
5254
else ()
5355
list(APPEND COMMON_SOURCES dynamic.c)
5456
endif ()

kernel/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,11 @@ endif ()
596596
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_NN}" "" "gemm_small_kernel_nn" false "" "" false ${float_type})
597597
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_NT}" "" "gemm_small_kernel_nt" false "" "" false ${float_type})
598598
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_TN}" "" "gemm_small_kernel_tn" false "" "" false ${float_type})
599-
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_NT}" "" "gemm_small_kernel_tt" false "" "" false ${float_type})
599+
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_TT}" "" "gemm_small_kernel_tt" false "" "" false ${float_type})
600600
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_B0_NN}" "B0" "gemm_small_kernel_b0_nn" false "" "" false ${float_type})
601601
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_B0_NT}" "B0" "gemm_small_kernel_b0_nt" false "" "" false ${float_type})
602602
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_B0_TN}" "B0" "gemm_small_kernel_b0_tn" false "" "" false ${float_type})
603-
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_B0_NT}" "B0" "gemm_small_kernel_b0_tt" false "" "" false ${float_type})
603+
GenerateNamedObjects("${KERNELDIR}/${${float_char}GEMM_SMALL_K_B0_TT}" "B0" "gemm_small_kernel_b0_tt" false "" "" false ${float_type})
604604
endif ()
605605
if (BUILD_BFLOAT16)
606606
if (NOT DEFINED SBGEMM_SMALL_M_PERMIT)
@@ -634,11 +634,11 @@ endif ()
634634
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_NN}" "" "gemm_small_kernel_nn" false "" "" false "BFLOAT16")
635635
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_NT}" "" "gemm_small_kernel_nt" false "" "" false "BFLOAT16")
636636
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_TN}" "" "gemm_small_kernel_tn" false "" "" false "BFLOAT16")
637-
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_NT}" "" "gemm_small_kernel_tt" false "" "" false "BFLOAT16")
637+
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_TT}" "" "gemm_small_kernel_tt" false "" "" false "BFLOAT16")
638638
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_B0_NN}" "B0" "gemm_small_kernel_b0_nn" false "" "" false "BFLOAT16")
639639
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_B0_NT}" "B0" "gemm_small_kernel_b0_nt" false "" "" false "BFLOAT16")
640640
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_B0_TN}" "B0" "gemm_small_kernel_b0_tn" false "" "" false "BFLOAT16")
641-
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_B0_NT}" "B0" "gemm_small_kernel_b0_tt" false "" "" false "BFLOAT16")
641+
GenerateNamedObjects("${KERNELDIR}/${SBGEMM_SMALL_K_B0_TT}" "B0" "gemm_small_kernel_b0_tt" false "" "" false "BFLOAT16")
642642
endif ()
643643
endif ()
644644

0 commit comments

Comments
 (0)