From 4bb975400a7cc41c61089bc4ed7142ce20a2eb41 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 23 Dec 2025 10:59:59 -0500 Subject: [PATCH 1/2] cmake: document options and set defaults for influential variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add documentation strings and defaults for CMake cache variables including TARGET, BINARY, threading options, vector extensions, memory tuning, and precision types. Treat empty string values as "not set" to allow auto-detection while keeping options visible in ccmake. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CMakeLists.txt | 69 +++++++++++++++++++++++++++++++++++++++------- cmake/system.cmake | 42 ++++++++++++++++++++++------ 2 files changed, 92 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96c2a43642..1fc2bd3f0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,61 @@ set(SYMBOLPREFIX "" CACHE STRING "Add a prefix to all exported symbol names in set(SYMBOLSUFFIX "" CACHE STRING "Add a suffix to all exported symbol names in the shared library, e.g. _64 for INTERFACE64 builds" ) +# Target architecture - auto-detected if not specified +set(TARGET "" CACHE STRING "Target CPU architecture (e.g. HASWELL, SANDYBRIDGE, NEHALEM, ARMV8, POWER9). Auto-detected if not specified.") + +# Binary type (32-bit or 64-bit) +set(BINARY "" CACHE STRING "Build a 32-bit or 64-bit library (32 or 64). Auto-detected if not specified. Note: 32-bit disables AVX.") + +# Threading options +set(USE_THREAD "" CACHE STRING "Enable multi-threading (0=disabled, 1=enabled). Auto-detected based on NUM_THREADS if not specified.") +option(USE_OPENMP "Use OpenMP for threading instead of pthreads" OFF) +set(NUM_THREADS "" CACHE STRING "Maximum number of threads. Auto-detected from CPU cores if not specified.") +set(NUM_PARALLEL "1" CACHE STRING "Number of parallel OpenBLAS instances when using OpenMP (default: 1)") + +# 64-bit integer interface +option(INTERFACE64 "Use 64-bit integers for array indices (equivalent to -i8 in ifort)" OFF) + +# Vector extension control +option(NO_AVX "Disable AVX kernel support (use for compatibility with older systems)" OFF) +option(NO_AVX2 "Disable AVX2 optimizations" OFF) +option(NO_AVX512 "Disable AVX512 optimizations" OFF) + +# Memory tuning options +set(BUFFERSIZE "" CACHE STRING "Memory buffer size factor (32< Date: Tue, 23 Dec 2025 13:13:29 -0500 Subject: [PATCH 2/2] cmake: add THREAD_TIMEOUT, prevent in-tree builds, fix ARCH handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Add THREAD_TIMEOUT option for thread spin-wait timeout configuration - Prevent in-tree builds with clear error message (protects Makefiles) - Fix ARCH variable to not redundantly re-set when user provides it - Remove experimental warning (CMake now has full Makefile.rule parity) All Makefile.rule options are now supported in CMake: | Makefile.rule Option | CMake Equivalent | |-------------------------------|-------------------------------------| | LIBNAMEPREFIX | LIBNAMEPREFIX | | LIBNAMESUFFIX | LIBNAMESUFFIX | | TARGET | TARGET | | DYNAMIC_ARCH | DYNAMIC_ARCH | | DYNAMIC_OLDER | DYNAMIC_OLDER | | BINARY | BINARY | | USE_THREAD | USE_THREAD | | USE_LOCKING | USE_LOCKING | | USE_OPENMP | USE_OPENMP | | OMP_SCHED | OMP_SCHED | | NUM_THREADS | NUM_THREADS | | NUM_PARALLEL | NUM_PARALLEL | | BUFFERSIZE | BUFFERSIZE | | NO_STATIC / NO_SHARED | BUILD_STATIC_LIBS / BUILD_SHARED_LIBS | | NO_CBLAS | BUILD_WITHOUT_CBLAS | | ONLY_CBLAS | ONLY_CBLAS | | NO_LAPACK | BUILD_WITHOUT_LAPACK | | NO_LAPACKE | BUILD_WITHOUT_LAPACKE | | BUILD_LAPACK_DEPRECATED | BUILD_LAPACK_DEPRECATED | | LAPACK_STRLEN | LAPACK_STRLEN | | BUILD_RELAPACK | BUILD_RELAPACK | | RELAPACK_REPLACE | RELAPACK_REPLACE | | USE_SIMPLE_THREADED_LEVEL3 | USE_SIMPLE_THREADED_LEVEL3 | | USE_TLS | USE_TLS | | INTERFACE64 | INTERFACE64 | | NO_WARMUP | NO_WARMUP | | NO_AFFINITY | NO_AFFINITY | | BIGNUMA | BIGNUMA | | EMBEDDED | EMBEDDED | | NO_AVX / NO_AVX2 / NO_AVX512 | NO_AVX / NO_AVX2 / NO_AVX512 | | FUNCTION_PROFILE | FUNCTION_PROFILE | | QUAD_PRECISION | QUAD_PRECISION | | THREAD_TIMEOUT | THREAD_TIMEOUT | | DEVICEDRIVER_ALLOCATION | DEVICEDRIVER_ALLOCATION | | HUGETLB_ALLOCATION | HUGETLB_ALLOCATION | | HUGETLBFILE_ALLOCATION | HUGETLBFILE_ALLOCATION | | CONSISTENT_FPCSR | CONSISTENT_FPCSR | | GEMM_MULTITHREAD_THRESHOLD | GEMM_MULTITHREAD_THRESHOLD | | SANITY_CHECK | SANITY_CHECK | | MAX_STACK_ALLOC | MAX_STACK_ALLOC | | SYMBOLPREFIX / SYMBOLSUFFIX | SYMBOLPREFIX / SYMBOLSUFFIX | | CPP_THREAD_SAFETY_TEST | CPP_THREAD_SAFETY_TEST | | CPP_THREAD_SAFETY_GEMV | CPP_THREAD_SAFETY_GEMV | | BUILD_BFLOAT16 / BUILD_HFLOAT16 | BUILD_BFLOAT16 / BUILD_HFLOAT16 | | BLAS3_MEM_ALLOC_THRESHOLD | BLAS3_MEM_ALLOC_THRESHOLD | | BUILD_SINGLE/DOUBLE/COMPLEX/COMPLEX16 | BUILD_SINGLE/DOUBLE/COMPLEX/COMPLEX16 | | ARM_SOFTFP_ABI | ARM_SOFTFP_ABI | | DEBUG | CMAKE_BUILD_TYPE=Debug | | PREFIX | CMAKE_INSTALL_PREFIX | | HOSTCC | CMake toolchain files | 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CMakeLists.txt | 76 +++++++++++++++++++++++++++---------- cmake/arch.cmake | 4 +- cmake/prebuild.cmake | 4 +- cmake/system.cmake | 63 ++++++++++++++++++++++-------- cmake/system_check.cmake | 74 ++++++++++++++++++++++++++---------- relapack/src/CMakeLists.txt | 7 ++++ 6 files changed, 168 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fc2bd3f0a..51f3bf9a2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,11 @@ cmake_minimum_required(VERSION 3.16.0) set (CMAKE_ASM_SOURCE_FILE_EXTENSIONS "S") project(OpenBLAS C ASM) +# Prevent in-tree builds to avoid overwriting Makefiles +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + message(FATAL_ERROR "In-tree builds are not allowed. Use: cmake -B build -S .") +endif () + set(OpenBLAS_MAJOR_VERSION 0) set(OpenBLAS_MINOR_VERSION 3) set(OpenBLAS_PATCH_VERSION 30.dev) @@ -29,6 +34,10 @@ set(LAPACK_STRLEN "" CACHE STRING "When building LAPACK, use this type (e.g. \"i option(BUILD_TESTING "Build LAPACK testsuite when building LAPACK" ON) +option(BUILD_TESTS "Build the BLAS test suite (test/ and ctest/ directories)" ON) + +option(BUILD_UTESTS "Build the unit tests (utest/ directory)" ON) + option(BUILD_BENCHMARKS "Build the collection of BLAS/LAPACK benchmarks" OFF) option(C_LAPACK "Build LAPACK from C sources instead of the original Fortran" OFF) @@ -39,8 +48,14 @@ option(DYNAMIC_ARCH "Include support for multiple CPU targets, with automatic se option(DYNAMIC_OLDER "Include specific support for older x86 cpu models (Penryn,Dunnington,Atom,Nano,Opteron) with DYNAMIC_ARCH" OFF) +set(DYNAMIC_LIST "" CACHE STRING "Manually specify list of CPU targets for DYNAMIC_ARCH instead of default list (semicolon-separated, e.g., 'HASWELL;SKYLAKEX')") + +set(TARGET_CORE "" CACHE STRING "Override TARGET for DYNAMIC_ARCH kernel selection. Used to specify which CPU-specific kernels to build.") + option(BUILD_RELAPACK "Build with ReLAPACK (recursive implementation of several LAPACK functions on top of standard LAPACK)" OFF) +option(RELAPACK_REPLACE "Use ReLAPACK to replace standard LAPACK routines instead of adding RELAPACK_ prefixed equivalents (requires BUILD_RELAPACK)" OFF) + option(USE_LOCKING "Use locks even in single-threaded builds to make them callable from multiple threads" OFF) option(USE_PERL "Use the older PERL scripts for build preparation instead of universal shell scripts" OFF) @@ -51,6 +66,7 @@ option(FIXED_LIBNAME "Use a non-versioned name for the library and no symbolic l set(LIBNAMEPREFIX "" CACHE STRING "Add a prefix to the openblas part of the library name" ) set(LIBNAMESUFFIX "" CACHE STRING "Add a suffix after the openblas part of the library name" ) +set(LIBSONAMEBASE "openblas" CACHE STRING "Base name for shared library soname (default: openblas)") if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") option(NO_AFFINITY "Disable support for CPU affinity masks to avoid binding processes from e.g. R or numpy/scipy to a single core" ON) @@ -81,6 +97,9 @@ set(SYMBOLSUFFIX "" CACHE STRING "Add a suffix to all exported symbol names in # Target architecture - auto-detected if not specified set(TARGET "" CACHE STRING "Target CPU architecture (e.g. HASWELL, SANDYBRIDGE, NEHALEM, ARMV8, POWER9). Auto-detected if not specified.") +# Force architecture (normally auto-detected from system) +set(ARCH "" CACHE STRING "Force architecture (x86, x86_64, arm, arm64, power, mips, mips64, zarch, loongarch64, riscv64). Auto-detected if not specified.") + # Binary type (32-bit or 64-bit) set(BINARY "" CACHE STRING "Build a 32-bit or 64-bit library (32 or 64). Auto-detected if not specified. Note: 32-bit disables AVX.") @@ -89,6 +108,7 @@ set(USE_THREAD "" CACHE STRING "Enable multi-threading (0=disabled, 1=enabled). option(USE_OPENMP "Use OpenMP for threading instead of pthreads" OFF) set(NUM_THREADS "" CACHE STRING "Maximum number of threads. Auto-detected from CPU cores if not specified.") set(NUM_PARALLEL "1" CACHE STRING "Number of parallel OpenBLAS instances when using OpenMP (default: 1)") +set(OMP_SCHED "static" CACHE STRING "OpenMP schedule type (static, dynamic, guided, auto, runtime). Default: static") # 64-bit integer interface option(INTERFACE64 "Use 64-bit integers for array indices (equivalent to -i8 in ifort)" OFF) @@ -97,6 +117,8 @@ option(INTERFACE64 "Use 64-bit integers for array indices (equivalent to -i8 in option(NO_AVX "Disable AVX kernel support (use for compatibility with older systems)" OFF) option(NO_AVX2 "Disable AVX2 optimizations" OFF) option(NO_AVX512 "Disable AVX512 optimizations" OFF) +option(NO_SVE "Disable ARM SVE (Scalable Vector Extension) optimizations" OFF) +option(NO_SME "Disable ARM SME (Scalable Matrix Extension) optimizations" OFF) # Memory tuning options set(BUFFERSIZE "" CACHE STRING "Memory buffer size factor (32<