Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize buffers in sparse! to satisfy buffer checks in constructor #314

Merged
merged 1 commit into from
Dec 12, 2022

Conversation

fredrikekre
Copy link
Member

With this patch the output buffers to sparse! are resized in order to satisfy the buffer length checks in the SparseMatrixCSC constructor that were introduced in JuliaLang/julia#40523. Previously csccolptr was never resized, and cscrowval and cscnzval were only resized if the buffers were too short (i.e. never truncated).

The requirement length(csccolptr) >= n + 1 could be kept, but seems unnecessary since all buffers need to be resized anyway (to pass the constructor checks).

In particular this fixes calling sparse! with I, J, V as both input and output buffers: sparse!(I, J, V, m, n, ..., I, J, V).

Fixes #313.

@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2022

Codecov Report

Merging #314 (40e989c) into main (57cbb74) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #314      +/-   ##
==========================================
+ Coverage   93.62%   93.68%   +0.05%     
==========================================
  Files          12       12              
  Lines        7390     7391       +1     
==========================================
+ Hits         6919     6924       +5     
+ Misses        471      467       -4     
Impacted Files Coverage Δ
src/sparsematrix.jl 95.56% <100.00%> (+0.16%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

With this patch the output buffers to `sparse!` are resized in order to
satisfy the buffer length checks in the `SparseMatrixCSC` constructor
that were introduced in JuliaLang/julia#40523. Previously `csccolptr`
was never resized, and  `cscrowval` and `cscnzval` were only resized if
the buffers were too short (i.e. never truncated).

The requirement `length(csccolptr) >= n + 1` could be kept, but seems
unnecessary since all buffers need to be resized anyway (to pass the
constructor checks).

In particular this fixes calling `sparse!` with `I`, `J`, `V` as both
input and output buffers: `sparse!(I, J, V, m, n, ..., I, J, V)`.

Fixes #313.
@fredrikekre fredrikekre removed the request for review from dkarrasch December 12, 2022 22:17
@fredrikekre fredrikekre merged commit 85a381b into main Dec 12, 2022
@fredrikekre fredrikekre deleted the fe/sparse-bang branch December 12, 2022 22:17
@github-actions
Copy link

The backport to 1.8 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.8 1.8
# Navigate to the new working tree
cd .worktrees/backport-1.8
# Create a new branch
git switch --create backport-314-to-1.8
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 85a381b2ea0f5e8a1553b51bc75a83dfc0445e36
# Push it to GitHub
git push --set-upstream origin backport-314-to-1.8
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.8

Then, create a pull request where the base branch is 1.8 and the compare/head branch is backport-314-to-1.8.

@github-actions
Copy link

The backport to 1.9 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.9 1.9
# Navigate to the new working tree
cd .worktrees/backport-1.9
# Create a new branch
git switch --create backport-314-to-1.9
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 85a381b2ea0f5e8a1553b51bc75a83dfc0445e36
# Push it to GitHub
git push --set-upstream origin backport-314-to-1.9
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.9

Then, create a pull request where the base branch is 1.9 and the compare/head branch is backport-314-to-1.9.

fredrikekre added a commit that referenced this pull request Dec 12, 2022
…314)

With this patch the output buffers to `sparse!` are resized in order to
satisfy the buffer length checks in the `SparseMatrixCSC` constructor
that were introduced in JuliaLang/julia#40523. Previously `csccolptr`
was never resized, and  `cscrowval` and `cscnzval` were only resized if
the buffers were too short (i.e. never truncated).

The requirement `length(csccolptr) >= n + 1` could be kept, but seems
unnecessary since all buffers need to be resized anyway (to pass the
constructor checks).

In particular this fixes calling `sparse!` with `I`, `J`, `V` as both
input and output buffers: `sparse!(I, J, V, m, n, ..., I, J, V)`.

Fixes #313.

(cherry picked from commit 85a381b)
fredrikekre added a commit that referenced this pull request Dec 12, 2022
…314)

With this patch the output buffers to `sparse!` are resized in order to
satisfy the buffer length checks in the `SparseMatrixCSC` constructor
that were introduced in JuliaLang/julia#40523. Previously `csccolptr`
was never resized, and  `cscrowval` and `cscnzval` were only resized if
the buffers were too short (i.e. never truncated).

The requirement `length(csccolptr) >= n + 1` could be kept, but seems
unnecessary since all buffers need to be resized anyway (to pass the
constructor checks).

In particular this fixes calling `sparse!` with `I`, `J`, `V` as both
input and output buffers: `sparse!(I, J, V, m, n, ..., I, J, V)`.

Fixes #313.

(cherry picked from commit 85a381b)
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.

Buffer checking breaks buffer re-use
3 participants