Skip to content

Use externally-supplied workspace for mul! - #8

Merged
timholy merged 1 commit into
masterfrom
teh/workspace
Apr 27, 2026
Merged

timholy merged 1 commit into
masterfrom
teh/workspace

Conversation

@timholy

@timholy timholy commented Apr 27, 2026

Copy link
Copy Markdown
Member

Creates a Workspace type to hold the intermediate buffers used in mul! for multiplying a FactoredMatrix by another matrix without intermediate allocations.

This has several advantages:

  • several different sizes of workspace can be created and reused as needed, e.g. for multiplying the same FactoredMatrix by different right-hand matrices with different numbers of columns.
  • it allows FactoredMatrices to be thread-safe
  • it avoids leaking an internal detail, the cache size, to users of the package.

The workspace is created by calling Workspace(fm, j) where fm is a FactoredMatrix and j is the number of columns in the right-hand matrix for the intended multiplication. The workspace can then be passed to mul! via the cache keyword argument, e.g. mul!(C, A, B; cache=ws).

Creates a `Workspace` type to hold the intermediate buffers used in
`mul!` for multiplying a `FactoredMatrix` by another matrix without
intermediate allocations.

This has several advantages:
- several different sizes of workspace can be created and reused as
  needed, e.g. for multiplying the same `FactoredMatrix` by different
  right-hand matrices with different numbers of columns.
- it allows `FactoredMatrices` to be thread-safe
- it avoids leaking an internal detail, the cache size, to users of the
  package.

The workspace is created by calling `Workspace(fm, j)` where `fm` is a
`FactoredMatrix` and `j` is the number of columns in the right-hand
matrix for the intended multiplication. The workspace can then be passed
to `mul!` via the `cache` keyword argument, e.g. `mul!(C, A, B;
cache=ws)`.
@timholy
timholy merged commit 8309af5 into master Apr 27, 2026
2 checks passed
@timholy
timholy deleted the teh/workspace branch April 27, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant