You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-3Lines changed: 27 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This provides a Julia interface to some of the
4
4
[macOS Accelerate framework](https://developer.apple.com/documentation/accelerate). At
5
5
the moment, this package provides:
6
6
1. Access to Accelerate BLAS and LAPACK using the [libblastrampoline](https://github.com/JuliaLinearAlgebra/libblastrampoline) framework,
7
-
2. An interface to the [array-oriented functions](https://developer.apple.com/library/mac/documentation/Performance/Conceptual/vecLib/index.html#//apple_ref/doc/uid/TP30000414-357225),
7
+
2. An interface to the [array-oriented functions](https://developer.apple.com/documentation/accelerate/veclib),
8
8
which provide a vectorised form for many common mathematical functions
9
9
10
10
The performance is significantly better than using standard libm functions in some cases, though there does appear to be some reduced accuracy.
@@ -36,9 +36,33 @@ Some additional functions that are also available:
36
36
*`fdiv(x,y)`: divide (`x ./ y` in Base)
37
37
*`sincos(x)`: returns `(sin(x), cos(x))`
38
38
39
-
## Setting the number of threads
39
+
## BLAS Multi-threading
40
+
41
+
Accelerate BLAS is multi-threaded by default. Starting with macOS 15 (Sequoia), `get_num_threads()` and `set_num_threads()` are available. The Accelerate API only allows the user to choose single-threaded operation or multi-threaded operation. Thus, `set_num_threads(1)` will give single-threaded operation, and any number greater than 1 will give multi-threaded operation. `get_num_threads()` will return `1` for single-threaded operation and `Sys.CPU_THREADS` for multi-threaded operation. The following example is on Apple M2 Max, where `Sys.CPU_THREADS` is `8`.
42
+
43
+
```julia
44
+
julia>using AppleAccelerate
45
+
46
+
julia> AppleAccelerate.get_num_threads() # Default is multi-threaded. Return value is `Sys.CPU_THREADS`
47
+
8
48
+
49
+
julia> AppleAccelerate.set_num_threads(1) # Set single-threaded operation
50
+
51
+
julia> AppleAccelerate.get_num_threads()
52
+
1
53
+
54
+
julia> AppleAccelerate.set_num_threads(4) # Set multi-threaded operation, with input value > 1.
55
+
56
+
julia> AppleAccelerate.get_num_threads() # Return value is `Sys.CPU_THREADS` for multi-threaded operation
57
+
8
58
+
```
59
+
60
+
On older versions of macOS (< 15), the number of threads can be changed with the `VECLIB_MAXIMUM_THREADS` environment variable before starting Julia:
61
+
62
+
```julia
63
+
VECLIB_MAXIMUM_THREADS=1 julia
64
+
```
40
65
41
-
Accelerate is multithreaded by default. You can set an upper limit on the number of threads through the `VECLIB_MAXIMUM_THREADS` environment variable; for example, for single-threaded execution, start Julia as `VECLIB_MAXIMUM_THREADS=1 julia`. Accelerate does not support the `BLAS.set_num_threads(nthreads)` and `BLAS.get_num_threads()` API used by other BLAS backends (`set_num_threads` is a no-op and `get_num_threads` returns a hardcoded default).
0 commit comments