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

Workspace Y repeatedly reallocated in cholmod_l_solve2 #45

Closed
samuelpowell opened this issue Jun 11, 2020 · 3 comments
Closed

Workspace Y repeatedly reallocated in cholmod_l_solve2 #45

samuelpowell opened this issue Jun 11, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@samuelpowell
Copy link

samuelpowell commented Jun 11, 2020

Describe the bug
Repeatedly calling cholmod_l_solve2 with the same inputs reallocates workspace matrix Y on each call for simplical factorisations under certain conditions, this causes excessive calls to malloc/free when solving a large number of systems.

To Reproduce

  1. Compile the cholmod_l_demo demo, and debug with matrix Matrix/bcsstk01.tri, noting that at line 388 of cholmod_l_demo.c the solver is called repeatedly with the same inputs.

  2. Within the solver, at line 1635 of cholmod_solve.c, the handle Y_Handle is passed to ensure_dense to check that it is suitable for the current solve. On the first run, this will be allocated appropriately, note that, e.g., the leading dimension Y_Handle->d is set equal to 4.

  3. The workspace matrix Y is then used in a call to ptrans on line 1649, upon return the leading dimension Y_Handle->d is now set to 1.

  4. On the next call to the solver, ensure_dense will reallocate Y because a check that the leading dimension is equal to 4 will fail.

Expected behavior
I did not expect the workspace Y to be reallocated.

Desktop (please complete the following information):

  • OS: MacOS 10.15.4, Windows 10 2004
  • compiler: Clang (MacOS), MinGW cross compile (Windows)
  • BLAS and LAPACK library: OpenBLAS
  • Version: master and previous

Additional context
This behaviour was identified when tracking excessive allocation in a Julia program (which uses CHOLMOD for its sparse factorisation routines), https://discourse.julialang.org/t/in-place-cholesky-solve-with-zero-allocation-simplical-vs-supernodal/41115/6.

@samuelpowell
Copy link
Author

samuelpowell commented Jun 11, 2020

I suppose it would suffice to save the dimensionality of Y at line 1641 of cholmod_solve.c, and restore at 1677, if this is all that is required I can open a PR to that effect. Alternatively ensure_dense could do more work to see if the total size of the input matrix is suitable and reassign its dimensionality accordingly.

@DrTimothyAldenDavis DrTimothyAldenDavis added the enhancement New feature or request label Mar 12, 2022
@DrTimothyAldenDavis
Copy link
Owner

This should be fixed in CHOLMOD 5.1.0, soon to be released. cholmod_ensure_dense can now revise Y->d, if the space is large enough.

@DrTimothyAldenDavis
Copy link
Owner

This is now fixed in SuiteSparse 7.4.0.beta1, which is a pre-release. Thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants