Skip to content

Commit de421b7

Browse files
authored
Merge pull request #4904 from XiWeiGu/la64_cross_cmake
LoongArch64: Enable cmake cross-compilation
2 parents edaf593 + 30af927 commit de421b7

File tree

6 files changed

+64
-2
lines changed

6 files changed

+64
-2
lines changed

cmake/arch.cmake

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ if (DYNAMIC_ARCH)
9494
endif ()
9595
endif ()
9696

97+
if (LOONGARCH64)
98+
set(DYNAMIC_CORE LOONGSONGENERIC LOONGSON2K1000 LOONGSON3R5)
99+
endif ()
100+
97101
if (EXISTS ${PROJECT_SOURCE_DIR}/config_kernel.h)
98102
message (FATAL_ERROR "Your build directory contains a file config_kernel.h, probably from a previous compilation with make. This will conflict with the cmake compilation and cause strange compiler errors - please remove the file before trying again")
99103
endif ()

cmake/prebuild.cmake

+48
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,54 @@ endif ()
13491349
"#define DTB_DEFAULT_ENTRIES 128\n"
13501350
"#define DTB_SIZE 4096\n"
13511351
"#define L2_ASSOCIATIVE 4\n")
1352+
elseif ("${TCORE}" STREQUAL "LOONGSONGENERIC")
1353+
file(APPEND ${TARGET_CONF_TEMP}
1354+
"#define DTB_DEFAULT_ENTRIES 64\n")
1355+
set(SGEMM_UNROLL_M 2)
1356+
set(SGEMM_UNROLL_N 8)
1357+
set(DGEMM_UNROLL_M 2)
1358+
set(DGEMM_UNROLL_N 8)
1359+
set(CGEMM_UNROLL_M 1)
1360+
set(CGEMM_UNROLL_N 4)
1361+
set(ZGEMM_UNROLL_M 1)
1362+
set(ZGEMM_UNROLL_N 4)
1363+
set(CGEMM3M_UNROLL_M 2)
1364+
set(CGEMM3M_UNROLL_N 8)
1365+
set(ZGEMM3M_UNROLL_M 2)
1366+
set(ZGEMM3M_UNROLL_N 8)
1367+
elseif ("${TCORE}" STREQUAL "LOONGSON2K1000")
1368+
file(APPEND ${TARGET_CONF_TEMP}
1369+
"#define DTB_DEFAULT_ENTRIES 64\n")
1370+
set(HAVE_LSX 1)
1371+
set(SGEMM_UNROLL_M 2)
1372+
set(SGEMM_UNROLL_N 8)
1373+
set(DGEMM_UNROLL_M 8)
1374+
set(DGEMM_UNROLL_N 4)
1375+
set(CGEMM_UNROLL_M 8)
1376+
set(CGEMM_UNROLL_N 4)
1377+
set(ZGEMM_UNROLL_M 4)
1378+
set(ZGEMM_UNROLL_N 4)
1379+
set(CGEMM3M_UNROLL_M 2)
1380+
set(CGEMM3M_UNROLL_N 8)
1381+
set(ZGEMM3M_UNROLL_M 8)
1382+
set(ZGEMM3M_UNROLL_N 4)
1383+
elseif ("${TCORE}" STREQUAL "LOONGSON3R5")
1384+
file(APPEND ${TARGET_CONF_TEMP}
1385+
"#define DTB_DEFAULT_ENTRIES 64\n")
1386+
set(HAVE_LASX 1)
1387+
set(HAVE_LSX 1)
1388+
set(SGEMM_UNROLL_M 16)
1389+
set(SGEMM_UNROLL_N 8)
1390+
set(DGEMM_UNROLL_M 16)
1391+
set(DGEMM_UNROLL_N 6)
1392+
set(CGEMM_UNROLL_M 16)
1393+
set(CGEMM_UNROLL_N 4)
1394+
set(ZGEMM_UNROLL_M 8)
1395+
set(ZGEMM_UNROLL_N 4)
1396+
set(CGEMM3M_UNROLL_M 16)
1397+
set(CGEMM3M_UNROLL_N 8)
1398+
set(ZGEMM3M_UNROLL_M 16)
1399+
set(ZGEMM3M_UNROLL_N 6)
13521400
endif()
13531401
set(SBGEMM_UNROLL_M 8)
13541402
set(SBGEMM_UNROLL_N 4)

cmake/system.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ if (NEED_PIC)
388388
endif()
389389
endif ()
390390

391-
if (X86_64 OR ${CORE} STREQUAL POWER10)
391+
if (X86_64 OR ${CORE} STREQUAL POWER10 OR LOONGARCH64)
392392
set(SMALL_MATRIX_OPT TRUE)
393393
endif ()
394394
if (ARM64)
@@ -403,7 +403,7 @@ if (SMALL_MATRIX_OPT)
403403
endif ()
404404

405405
if (DYNAMIC_ARCH)
406-
if (X86 OR X86_64 OR ARM64 OR POWER OR RISCV64)
406+
if (X86 OR X86_64 OR ARM64 OR POWER OR RISCV64 OR LOONGARCH64)
407407
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_ARCH")
408408
if (DYNAMIC_OLDER)
409409
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_OLDER")

cmake/system_check.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ elseif(ARM)
104104
set(ARCH "arm")
105105
elseif(ARM64)
106106
set(ARCH "arm64")
107+
elseif(LOONGARCH64)
108+
set(ARCH "loongarch64")
107109
else()
108110
set(ARCH ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "Target Architecture")
109111
endif ()

driver/others/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ if (DYNAMIC_ARCH)
5454
list(APPEND COMMON_SOURCES dynamic_power.c)
5555
elseif (RISCV64)
5656
list(APPEND COMMON_SOURCES dynamic_riscv64.c detect_riscv64.c)
57+
elseif (LOONGARCH64)
58+
list(APPEND COMMON_SOURCES dynamic_loongarch64.c)
5759
else ()
5860
list(APPEND COMMON_SOURCES dynamic.c)
5961
endif ()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include $(KERNELDIR)/KERNEL
2+
3+
STRMMKERNEL = gemm_kernel.S
4+
DTRMMKERNEL = gemm_kernel.S
5+
CTRMMKERNEL = zgemm_kernel.S
6+
ZTRMMKERNEL = zgemm_kernel.S

0 commit comments

Comments
 (0)