diff --git a/CMakeLists.txt b/CMakeLists.txt index 96c2a43642..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) @@ -78,6 +94,73 @@ 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.") + +# 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.") + +# 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)") +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) + +# 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) +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<