|
8 | 8 | const TRIXI_UUID = UUID("a7f1ee26-1774-49b1-8366-f1abc58fbfcb") |
9 | 9 |
|
10 | 10 | """ |
11 | | - Trixi.set_polyester!(toggle::Bool; force = true) |
12 | | -
|
13 | | -Toggle the usage of [Polyester.jl](https://github.com/JuliaSIMD/Polyester.jl) for multithreading. |
14 | | -By default, Polyester.jl is enabled, but it can |
15 | | -be useful for performance comparisons to switch to the Julia core backend. |
16 | | -
|
17 | | -This does not fully disable Polyester.jl, |
18 | | -but only its use as part of Trixi.jl's [`@threaded`](@ref) macro. |
| 11 | + Trixi.set_threading_backend!(backend::Symbol; force = true) |
| 12 | +
|
| 13 | +Toggle and/or switch backend behavior used in multithreaded loops inside Trixi.jl. |
| 14 | +The selected backend affects the behavior of Trixi.jl's [`@threaded`](@ref) macro, which is used |
| 15 | +throughout the codebase for parallel loops. By default, Polyester.jl is enabled for |
| 16 | +optimal performance, but switching backends can be useful for comparisons or debugging. |
| 17 | +
|
| 18 | +# Available backends |
| 19 | +- `:polyester`: Uses the default [Polyester.jl](https://github.com/JuliaSIMD/Polyester.jl) |
| 20 | +- `:static`: Uses Julia's built-in static thread scheduling via `Threads.@threads :static` |
| 21 | +- `:serial`: Disables threading, executing loops serially |
| 22 | +- `:kernelabstractions`: Preferentially use the [KernelAbstractions.jl](https://github.com/JuliaGPU/KernelAbstractions.jl) |
| 23 | + kernels written in Trixi.jl, falling back to `:static` execution. |
19 | 24 | """ |
20 | | -function set_polyester!(toggle::Bool; force = true) |
21 | | - set_preferences!(TRIXI_UUID, "polyester" => toggle, force = force) |
22 | | - @info "Please restart Julia and reload Trixi.jl for the `polyester` change to take effect" |
| 25 | +function set_threading_backend!(backend::Symbol = :polyester; force = true) |
| 26 | + valid_backends = (:polyester, :static, :serial, :kernelabstractions) |
| 27 | + if !(backend in valid_backends) |
| 28 | + throw(ArgumentError("Invalid threading backend: $(backend). Current options are: $(join(valid_backends, ", "))")) |
| 29 | + end |
| 30 | + set_preferences!(TRIXI_UUID, "backend" => backend, force = force) |
| 31 | + @info "Please restart Julia and reload Trixi.jl for the `backend` change to take effect" |
23 | 32 | end |
24 | 33 |
|
25 | 34 | """ |
|
0 commit comments