186 Commits
Author SHA1 Message Date
Nathan Goldbaum 28da957ee1 cache ntdll pointer at startup 2026-08-05 09:02:15 -06:00
Nathan Goldbaum 4ea40779bd Add explanatory note about RtlDllShutdownInProgress 2026-08-05 08:37:44 -06:00
Nathan Goldbaum b8d83a72f4 Avoid possible hang on Windows by introspecting shutdown state 2026-08-05 08:10:43 -06:00
Nathan Goldbaum 95120da710 Centralize buffer release bookkeeping 2026-08-05 08:10:30 -06:00
Martin Kroeker 63ad298a67 Merge branch 'develop' into attrib-hidden 2026-07-21 20:00:16 +02:00
Hugo Meiland 269e1cd505 RISC-V: add get_L2_size() and blas_set_parameter() for cache-aware GEMM blocking
RISC-V was the only major architecture without a get_L2_size() /
blas_set_parameter() implementation, so the GEMM cache-blocking parameters
(P/Q/R) were fixed at compile time regardless of the actual L2 cache size.

Because the blocking is now derived from the L2 cache detected at runtime
rather than a fixed compile-time constant, future RISC-V cores - which are
arriving with progressively larger and more varied L2 caches - get more
optimal blocking automatically, and the port gains the same runtime-tuning
hook x86 and LoongArch already use.

This adds, under ARCH_RISCV64:

- get_L2_size(): reads the level-2 (unified) cache size from Linux sysfs
  (/sys/devices/system/cpu/cpu0/cache/index*/{level,size}); RISC-V has no
  architectural cache-size query like x86 CPUID or LoongArch CPUCFG. Falls
  back to 512 KB when sysfs is unavailable.

- blas_set_parameter(): scales each precision's packed-A dimension P from the
  detected L2. The base blocking and the reference cache size come from the
  active core's own param.h block (*_DEFAULT_P_BASE, RISCV_L2_REFERENCE_KB),
  so the function carries no core-specific constants and is a no-op for cores
  that do not opt in. Q and R keep their param.h defaults.

- driver/others/memory.c and common_macro.h: add ARCH_RISCV64 to the existing
  architecture lists that call blas_set_parameter() and declare the runtime
  parameter variables (sgemm_p, dgemm_p, ...).

- param.h RISCV64_ZVL256B: declares the per-core base blocking + reference and
  maps SGEMM/DGEMM/CGEMM/ZGEMM DEFAULT_P to the runtime variables for static
  builds; DYNAMIC_ARCH keeps the literals, since kernel/setparam-ref.c
  init_parameter() initialises the gotoblas table from these macros and
  blas_set_parameter() is not called on the dynamic path.

Only RISCV64_ZVL256B opts in so far; its base + reference are tuned on the
SpaceMiT X60, where a 512 KB L2 reproduces the stock blocking, so this is
performance-neutral on current hardware. Verified: a static RISCV64_ZVL256B
build reproduces the stock 128/128/16384 (SGEMM) and 64/128/8192 (DGEMM)
blocking; a DYNAMIC_ARCH build compiles cleanly (per-core setparam-ref objects
build without error); and get_L2_size() reads the correct size on both a
SpaceMiT X60 (512 KB L2) and a SiFive U74 / VisionFive 2 (2 MB L2).
2026-07-13 11:00:15 +02:00
Kumar Aditya a2261f9e52 fix thread safety of openmp backend 2026-07-02 15:39:09 +05:30
Martin Kroeker 494a3f735f Improve error message displayed when running out of buffers 2026-03-22 22:46:17 +01:00
mattip be7da1f111 add visibility=default to exported functions, visibility=hidden to most assembler 2026-02-05 06:31:17 +11:00
Martin Kroeker 80995622dd Rename the DllMain copy used in static linking to OpenBLASDllMain 2026-01-22 11:19:04 +01:00
Martin Kroeker 31ef2cbbb3 Exit if memory allocation keeps failing, instead of looping forever 2025-06-13 14:11:03 +02:00
Ralf Gommers 765ad8bcd2 Fix guard around alloc_hugetlb, fixes compile warning
The warning was:
```
/home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c: At top level:
/home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c:2565:14: warning: 'alloc_hugetlb' defined but not used [-Wunused-function]
 2565 | static void *alloc_hugetlb(void *address){
      |              ^~~~~~~~~~~~~
```

The added define is the same as is already present in the TLS part of
`memory.c`. This follows up on gh-4681.
2024-12-18 09:42:05 +01:00
Ralf Gommers 48caf2303d Fix build warning about discarding volatile qualifier in memory.c
The warning was:
```
[4339/5327] Building C object driver/others/CMakeFiles/driver_others.dir/memory.c.o
/home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c: In function 'blas_shutdown':
/home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c:3257:10: warning: passing argument 1 of 'free' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
 3257 |     free(newmemory);
      |          ^~~~~~~~~
In file included from /home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/common.h:83,
                 from /home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c:74:
/home/rgommers/code/pixi-dev-scipystack/openblas/.pixi/envs/default/x86_64-conda-linux-gnu/sysroot/usr/include/stdlib.h:482:25: note: expected 'void *' but argument is of type 'volatile struct newmemstruct *'
  482 | extern void free (void *__ptr) __THROW;
      |                   ~~~~~~^~~~~
```

The use of `volatile` for `newmemstruct` seems on purpose, and there are
more such constructs in this file. The warning appeared after gh-4451
and is correct. The `free` prototype doesn't expect a volatile pointer,
hence this change adds a cast to silence the warning.
2024-12-18 08:53:29 +01:00
Martin Kroeker 5257f807a9 fix invalid ifdef syntax in HUGETLB handling 2024-08-04 00:03:17 +02:00
Deeksha Goplani 0dc80a5c8d locks improvement 2024-05-13 22:17:23 +05:30
Martin Kroeker f0f1ff7820 fix HUGETLB allocation for TLS mode as well 2024-05-08 00:40:36 +02:00
Martin Kroeker dc99b61380 sort unwanted interdependencies of alloc_shm and alloc_hugetlb 2024-05-04 14:49:00 +02:00
gxw d8c4ea8793 loongarch: Optimizing the performance of the GEMM on servers 2024-04-09 09:03:34 -04:00
Martin Kroeker d938aed7fe reset "mem structure overflowed" state on shutdown 2024-01-23 17:15:53 +01:00
Martin Kroeker 90f890ee67 fix improper function prototypes (empty parentheses) (USE_TLS branch) 2023-09-30 23:12:36 +02:00
Martin Kroeker c6b1d8e7a3 fix improper function prototypes (empty parentheses) 2023-09-30 12:52:06 +02:00
Martin Kroeker 7e939fb831 Fix handling of additional buffer structures in case of overflow 2023-09-19 23:33:39 +02:00
Tiziano Müller 6a611db560 memory: show correct number of max threads 2023-09-10 08:44:07 +02:00
Martin Kroeker 3326b924b3 remove status variable blas_num_threads_set; initialize openmp thread maximum on startup 2023-07-26 00:31:24 +02:00
Martin Kroeker e5538a62cb Add suggestions to NUM_THREADS/auxiliary buffer message 2023-05-04 22:56:39 +02:00
Martin Kroeker e298d613fa initialize status variable for openblas_set_num_threads 2023-03-08 23:43:15 +01:00
Martin Kroeker e38ab079a0 Fix OpenMP thread counting returning places rather than cores 2023-03-08 19:17:33 +01:00
Martin Kroeker 69148ae795 Guard against sysconf returning zero processors 2022-07-06 17:22:18 +02:00
Martin Kroeker b329e45288 Guard against omp_get_num_places returning zero 2022-01-01 00:46:23 +01:00
Martin Kroeker c8d05aa7a5 Move the threads overflow flag under the protection of the local blas lock (#3476)
* Move accesses to the overflow flag into the scope of the blas lock
2021-12-13 08:34:52 +01:00
Martin Kroeker 4f057bffd6 Fix NULL pointer checks in blas_memory_alloc 2021-11-05 10:43:17 +01:00
Martin Kroeker efb16fafb0 Fix miscounting of threadpool size on Linux with OMP_PROC_BIND=TRUE (#3437)
*  return OMP places (if available, or SC_NPROCESSORS_CONF) for maximum thread count when built with OpenMP
2021-11-04 12:11:16 +01:00
Martin Kroeker dd09f0173e Remove extraneous qualifiers from struct definition 2021-09-14 21:52:26 +02:00
Martin Kroeker cd10d1c03b Fix typo 2021-08-30 14:38:28 +02:00
Martin Kroeker 2db1a99aca Clean up debug messages 2021-08-30 14:21:25 +02:00
Martin Kroeker 89fc5b8f4f Fix unmap logic 2021-08-29 19:50:24 +02:00
Martin Kroeker 7fd12a5e69 Add likely() hints for gcc 2021-08-29 13:54:51 +02:00
Martin Kroeker 2ba9a567aa Fix typo 2021-08-28 17:14:59 +02:00
Martin Kroeker b4b952eece Add auxiliary tracking space for thread buffer frees too 2021-08-28 17:03:53 +02:00
Martin Kroeker 7d1becc575 Allocate an auxiliary struct when running out of preconfigured threads 2021-08-28 14:18:36 +02:00
Martin Kroeker 898212efcd Actually add the message to the TLS section
continuous build / build (cmake, flang, macos-latest) (push) Canceled after 0s
continuous build / build (cmake, flang, ubuntu-latest) (push) Canceled after 0s
continuous build / build (cmake, gfortran, macos-latest) (push) Canceled after 0s
continuous build / build (cmake, gfortran, ubuntu-latest) (push) Canceled after 0s
continuous build / build (make, flang, macos-latest) (push) Canceled after 0s
continuous build / build (make, flang, ubuntu-latest) (push) Canceled after 0s
continuous build / build (make, gfortran, macos-latest) (push) Canceled after 0s
continuous build / build (make, gfortran, ubuntu-latest) (push) Canceled after 0s
2021-08-02 14:50:14 +02:00
Martin Kroeker 210a1584c5 Rebase source and edit TLS version of the message as well 2021-08-02 14:19:16 +02:00
Martin Kroeker f2a7a67f5a Improve the "tried to allocate too many buffers" error message 2021-07-31 17:23:40 +02:00
Craig Watson 4d7dfe4845 Include Haiku in processor count checks 2021-07-27 09:00:30 +00:00
River Dillon 2f6326a630 Remove <linux/unistd.h> 2021-07-10 00:36:07 -07:00
Martin Kroeker 1a3ad4b670 Fix signatures of the TLS-mode dll_callback and p_process_term functions for Win64 2021-02-22 19:40:36 +01:00
Martin Kroeker b0bded3f2f Fix get_num_procs() in the USE_TLS branch for non-glibc systems 2021-02-18 11:14:05 +01:00
Martin Kroeker 0cc36770f1 Merge pull request #3073 from xoviat/embedded
add embedded option
2021-01-31 18:02:41 +01:00
Alex Henrie 113840da12 Fix null pointer check in blas_memory_alloc 2021-01-24 22:20:44 -07:00
xoviat 2e8d6e8690 add functions for embedded 2021-01-23 22:12:17 -06:00