Skip to content

Conversation

@XiWeiGu
Copy link
Contributor

@XiWeiGu XiWeiGu commented Sep 26, 2024

Refer to the following instructions:

cmake ../ -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake 
                -DTARGET=LOONGSON3R5
                -DDYNAMIC_ARCH=1
                -DCMAKE_C_COMPILER=${CROSS_TARGET}-gcc 
                -DCMAKE_Fortran_COMPILER=${CROSS_TARGET}-gfortran 

Contents of toolchain.cmake:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR loongarch64)

@martin-frbg martin-frbg added this to the 0.3.29 milestone Oct 3, 2024
@martin-frbg martin-frbg merged commit de421b7 into OpenMathLib:develop Oct 3, 2024
@azuresky01
Copy link
Contributor

@XiWeiGu @martin-frbg

This PR still uses old core names since it was issued before the Rename core PR #4900 was merged. I just did some tests and find that we should rename those old core names to new ones to avoid cmake errors. See below.

System details: Loongson 3A6000 CPU, Debian sid, kernel 6.11.0, gcc 14.2.0, gfortran 14.2.0, cmake 3.30.4.

cmake commands: CC=gcc FC=gfortran cmake -B build -DBUILD_TESTING=OFF -DUSE_OPENMP=1 -DDYNAMIC_ARCH=1 and then cmake --build build.

The result:

...
-- Compiling a 64-bit binary.
-- Reading vars from /home/loongson/test/build/kernel/loongarch64/KERNEL...
-- Reading vars from /home/loongson/test/build/kernel/loongarch64/KERNEL.LOONGSON2K1000...
CMake Error at cmake/utils.cmake:23 (file):
  file STRINGS file
  "/home/loongson/test/build/kernel/loongarch64/KERNEL.LOONGSON2K1000" cannot
  be read.
Call Stack (most recent call first):
  kernel/CMakeLists.txt:13 (ParseMakefileVars)
  kernel/CMakeLists.txt:1365 (build_core)


-- -- -- -- -- -- -- -- -- -- -- -- -- --
-- Targeting the LOONGSON3R5 architecture.
-- GEMM multithread threshold set to 4.
-- Multi-threading enabled with 8 threads.
-- Running getarch
-- GETARCH results:
CORE=LA464
LIBCORE=la464
NUM_CORES=8
MAKEFLAGS += -j 8

-- Compiling a 64-bit binary.
-- Reading vars from /home/loongson/test/build/kernel/loongarch64/KERNEL...
-- Reading vars from /home/loongson/test/build/kernel/loongarch64/KERNEL.LOONGSON3R5...
CMake Error at cmake/utils.cmake:23 (file):
  file STRINGS file
  "/home/loongson/test/build/kernel/loongarch64/KERNEL.LOONGSON3R5" cannot be
  read.
Call Stack (most recent call first):
  kernel/CMakeLists.txt:13 (ParseMakefileVars)
  kernel/CMakeLists.txt:1365 (build_core)


LOONGSONGENERIC
LOONGSON2K1000
LOONGSON3R5
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Generating openblas_config.h in include/openblas
-- Generating f77blas.h in include/openblas
-- Generating cblas.h in include/openblas
-- Copying LAPACKE header files to include/openblas
-- Configuring incomplete, errors occurred!


I then rename "LOONGSONGENERIC LOONGSON2K1000 LOONGSON3R5 " at line 98 in cmake/arch.cmake:

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

to new core names "LA64_GENERIC LA264 LA464", and also rename old core names at lines 1352,1367,1383 in cmake/prebuild.cmake:

OpenBLAS/cmake/prebuild.cmake

Lines 1352 to 1383 in 624e9d1

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")

to "LA64_GENERIC", "LA264", and "LA464" correspondingly.

After these changes I observe that cmake errors for LOONGSON2K1000 and LOONGSON3R5 disappear. But a new cmake error appears:

...
CMake Error at cmake/utils.cmake:23 (file):
  file STRINGS file
  "/home/loongson/test/build/kernel/loongarch64/KERNEL.LA64_GENERIC" cannot be
  read.
Call Stack (most recent call first):
  kernel/CMakeLists.txt:13 (ParseMakefileVars)
  kernel/CMakeLists.txt:1365 (build_core)
...

since there is no file called "kernel/loongarch64/KERNEL.LA64_GENERIC":

kernel

Rename the file "kernel/loongarch64/KERNEL.LOONGSONGENERIC" to "kernel/loongarch64/KERNEL.LA64_GENERIC" the above cmake error disappears and the compilation works well.

@XiWeiGu
Copy link
Contributor Author

XiWeiGu commented Oct 6, 2024

Yes, the #4904 was revised based on the old core name, and a patch is still needed to fix the cmake build after the core name revision.

@martin-frbg
Copy link
Collaborator

My fault for merging these in the wrong order, sorry. I'll try to fix this later today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants