Skip to content

Workspace Y repeatedly reallocated in cholmod_l_solve2 #45

@samuelpowell

Description

@samuelpowell

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.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions