Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ When releasing a new version, move the "Unreleased" changes to a new version sec

- `twist!` and `twist` on a `TensorMap`, a `DiagonalTensorMap` or their adjoints use a cached tree transformer and the index manipulation kernel instead of a loop over all fusion trees, which removes the per-subblock bookkeeping and turns a twist of a GPU tensor, diagonal or not, into a single kernel launch ([#595](https://github.com/QuantumKitHub/TensorKit.jl/issues/595))
- `foreachblock` with several tensors is type stable, which removes the dynamic dispatch on every call to it and to the factorizations that go through it
- `taskforeach` with a single worker is a plain loop without an atomic counter, which lowers the cost per subblock of single-threaded index manipulations and planar traces

## [0.17.3](https://github.com/QuantumKitHub/TensorKit.jl/compare/v0.17.2...v0.17.3) - 2026-10-30

Expand Down
2 changes: 2 additions & 0 deletions src/auxiliary/auxiliary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Apply `f(item)` (respectively `f(item, resource)`) to all elements of `items`, d
The calling thread acts as the first of the workers, so at most `ntasks - 1` tasks are spawned, and none at all for a single worker.
"""
function taskforeach(f, items, ntasks::Integer)
ntasks == 1 && return foreach(f, items)
items′ = items isa AbstractArray ? items : collect(items)
n = length(items′)
nworkers = min(ntasks, n)
Expand All @@ -116,6 +117,7 @@ function taskforeach(f, items, ntasks::Integer)
return nothing
end
function taskforeach(f, items, resources)
length(resources) == 1 && return foreach(Base.Fix2(f, only(resources)), items)
items′ = items isa AbstractArray ? items : collect(items)
n = length(items′)
nworkers = min(length(resources), n)
Expand Down
Loading