Browse Source

Merge pull request #4904 from XiWeiGu/la64_cross_cmake

LoongArch64: Enable cmake cross-compilation
tags/v0.3.29
Martin Kroeker GitHub 1 year ago
parent
commit
de421b7764
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
6 changed files with 64 additions and 2 deletions
  1. +4
    -0
      cmake/arch.cmake
  2. +48
    -0
      cmake/prebuild.cmake
  3. +2
    -2
      cmake/system.cmake
  4. +2
    -0
      cmake/system_check.cmake
  5. +2
    -0
      driver/others/CMakeLists.txt
  6. +6
    -0
      kernel/loongarch64/KERNEL.LOONGSONGENERIC

+ 4
- 0
cmake/arch.cmake View File

@@ -94,6 +94,10 @@ if (DYNAMIC_ARCH)
endif () endif ()
endif () endif ()


if (LOONGARCH64)
set(DYNAMIC_CORE LOONGSONGENERIC LOONGSON2K1000 LOONGSON3R5)
endif ()

if (EXISTS ${PROJECT_SOURCE_DIR}/config_kernel.h) if (EXISTS ${PROJECT_SOURCE_DIR}/config_kernel.h)
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") 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")
endif () endif ()


+ 48
- 0
cmake/prebuild.cmake View File

@@ -1349,6 +1349,54 @@ endif ()
"#define DTB_DEFAULT_ENTRIES 128\n" "#define DTB_DEFAULT_ENTRIES 128\n"
"#define DTB_SIZE 4096\n" "#define DTB_SIZE 4096\n"
"#define L2_ASSOCIATIVE 4\n") "#define L2_ASSOCIATIVE 4\n")
elseif ("${TCORE}" STREQUAL "LOONGSONGENERIC")
file(APPEND ${TARGET_CONF_TEMP}
"#define DTB_DEFAULT_ENTRIES 64\n")
set(SGEMM_UNROLL_M 2)
set(SGEMM_UNROLL_N 8)
set(DGEMM_UNROLL_M 2)
set(DGEMM_UNROLL_N 8)
set(CGEMM_UNROLL_M 1)
set(CGEMM_UNROLL_N 4)
set(ZGEMM_UNROLL_M 1)
set(ZGEMM_UNROLL_N 4)
set(CGEMM3M_UNROLL_M 2)
set(CGEMM3M_UNROLL_N 8)
set(ZGEMM3M_UNROLL_M 2)
set(ZGEMM3M_UNROLL_N 8)
elseif ("${TCORE}" STREQUAL "LOONGSON2K1000")
file(APPEND ${TARGET_CONF_TEMP}
"#define DTB_DEFAULT_ENTRIES 64\n")
set(HAVE_LSX 1)
set(SGEMM_UNROLL_M 2)
set(SGEMM_UNROLL_N 8)
set(DGEMM_UNROLL_M 8)
set(DGEMM_UNROLL_N 4)
set(CGEMM_UNROLL_M 8)
set(CGEMM_UNROLL_N 4)
set(ZGEMM_UNROLL_M 4)
set(ZGEMM_UNROLL_N 4)
set(CGEMM3M_UNROLL_M 2)
set(CGEMM3M_UNROLL_N 8)
set(ZGEMM3M_UNROLL_M 8)
set(ZGEMM3M_UNROLL_N 4)
elseif ("${TCORE}" STREQUAL "LOONGSON3R5")
file(APPEND ${TARGET_CONF_TEMP}
"#define DTB_DEFAULT_ENTRIES 64\n")
set(HAVE_LASX 1)
set(HAVE_LSX 1)
set(SGEMM_UNROLL_M 16)
set(SGEMM_UNROLL_N 8)
set(DGEMM_UNROLL_M 16)
set(DGEMM_UNROLL_N 6)
set(CGEMM_UNROLL_M 16)
set(CGEMM_UNROLL_N 4)
set(ZGEMM_UNROLL_M 8)
set(ZGEMM_UNROLL_N 4)
set(CGEMM3M_UNROLL_M 16)
set(CGEMM3M_UNROLL_N 8)
set(ZGEMM3M_UNROLL_M 16)
set(ZGEMM3M_UNROLL_N 6)
endif() endif()
set(SBGEMM_UNROLL_M 8) set(SBGEMM_UNROLL_M 8)
set(SBGEMM_UNROLL_N 4) set(SBGEMM_UNROLL_N 4)


+ 2
- 2
cmake/system.cmake View File

@@ -388,7 +388,7 @@ if (NEED_PIC)
endif() endif()
endif () endif ()


if (X86_64 OR ${CORE} STREQUAL POWER10)
if (X86_64 OR ${CORE} STREQUAL POWER10 OR LOONGARCH64)
set(SMALL_MATRIX_OPT TRUE) set(SMALL_MATRIX_OPT TRUE)
endif () endif ()
if (ARM64) if (ARM64)
@@ -403,7 +403,7 @@ if (SMALL_MATRIX_OPT)
endif () endif ()


if (DYNAMIC_ARCH) if (DYNAMIC_ARCH)
if (X86 OR X86_64 OR ARM64 OR POWER OR RISCV64)
if (X86 OR X86_64 OR ARM64 OR POWER OR RISCV64 OR LOONGARCH64)
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_ARCH") set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_ARCH")
if (DYNAMIC_OLDER) if (DYNAMIC_OLDER)
set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_OLDER") set(CCOMMON_OPT "${CCOMMON_OPT} -DDYNAMIC_OLDER")


+ 2
- 0
cmake/system_check.cmake View File

@@ -104,6 +104,8 @@ elseif(ARM)
set(ARCH "arm") set(ARCH "arm")
elseif(ARM64) elseif(ARM64)
set(ARCH "arm64") set(ARCH "arm64")
elseif(LOONGARCH64)
set(ARCH "loongarch64")
else() else()
set(ARCH ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "Target Architecture") set(ARCH ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "Target Architecture")
endif () endif ()


+ 2
- 0
driver/others/CMakeLists.txt View File

@@ -54,6 +54,8 @@ if (DYNAMIC_ARCH)
list(APPEND COMMON_SOURCES dynamic_power.c) list(APPEND COMMON_SOURCES dynamic_power.c)
elseif (RISCV64) elseif (RISCV64)
list(APPEND COMMON_SOURCES dynamic_riscv64.c detect_riscv64.c) list(APPEND COMMON_SOURCES dynamic_riscv64.c detect_riscv64.c)
elseif (LOONGARCH64)
list(APPEND COMMON_SOURCES dynamic_loongarch64.c)
else () else ()
list(APPEND COMMON_SOURCES dynamic.c) list(APPEND COMMON_SOURCES dynamic.c)
endif () endif ()


+ 6
- 0
kernel/loongarch64/KERNEL.LOONGSONGENERIC View File

@@ -0,0 +1,6 @@
include $(KERNELDIR)/KERNEL

STRMMKERNEL = gemm_kernel.S
DTRMMKERNEL = gemm_kernel.S
CTRMMKERNEL = zgemm_kernel.S
ZTRMMKERNEL = zgemm_kernel.S

Loading…
Cancel
Save