Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ elseif(LOONGARCH64MATCH GREATER "-1")
message(STATUS "Detected LOONGARCH64 target processor")

option(LOONGARCH64_RUNTIME_CPU_DETECT "Enable LOONGARCH64 run-time CPU feature detection" ON)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD")
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
set(LOONGARCH64_RUNTIME_CPU_DETECT OFF CACHE BOOL "" FORCE)
message(STATUS "Run-time CPU feature detection unsupported on this platform")
endif()
Expand Down
1 change: 1 addition & 0 deletions source/common/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ uint32_t cpu_detect(bool benableavx512)

uint32_t cpu_detect( bool benableavx512 )
{
(void)benableavx512;
uint32_t flags = 0;

#ifdef ENABLE_ASSEMBLY
Expand Down
18 changes: 17 additions & 1 deletion source/common/loongarch64/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@

#if LOONGARCH64_RUNTIME_CPU_DETECT

#if HAVE_GETAUXVAL

#include <sys/auxv.h>

#define LA_HWCAP_LSX ( 1U << 4 )
#define LA_HWCAP_LASX ( 1U << 5 )

static inline uint32_t loongarch64_cpu_detect()
static inline uint32_t loongarch64_get_cpu_flags()
{
uint32_t flags = 0;
#if HAVE_LSX || HAVE_LSX
Expand All @@ -52,6 +54,20 @@ static inline uint32_t loongarch64_cpu_detect()
return flags;
}

#else // HAVE_GETAUXVAL
#error \
"Run-time CPU feature detection selected, but no detection method" \
"available for your platform. Rerun cmake configure with" \
"-DLOONGARCH64_RUNTIME_CPU_DETECT=OFF."
#endif // HAVE_GETAUXVAL

static inline uint32_t loongarch64_cpu_detect()
{
uint32_t flags = loongarch64_get_cpu_flags();

return flags;
}

#else // if LOONGARCH64_RUNTIME_CPU_DETECT

static inline uint32_t loongarch64_cpu_detect()
Expand Down