NVIDIA / NVIDIA/AMGX

AMG_Level::Aoriginal not intuitive

Open
#181 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Cuda
Stars
692
Forks
197
PR merge metrics
No merged PRs in 30d

Description

It took me quite a while to figure out what's the point of AMG_Level::Aoriginal. In constructor A and Aoriginal are set to point to the same newly created matrix. Then if AMG_Level::setA() gets called the original matrix is deleted, Aorigial is set to NULL and A uses the passed matrix. In the destructor the matrix is only deleted if Aoriginal and A are the same, i.e. if AMG_Level::setA() was never called.
So this is an ownership management mechanism: only the matrix created in the constructor gets deleted, AMG_Level does not take the ownership of matrices passed through AMG_Level::setA().
This mechanism works, but it is rather confusing and likely to break if a new developer tries to edit the code (my first thought was that it is a dead code which can be removed).
Smart pointers would be a much better option, but that would require an API change.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the AMG_Level constructor, setA(), and destructor to trace the ownership behavior described in the issue. Decide and document the intended ownership model and API impact; the work is done when the confusing Aoriginal behavior is replaced or clearly resolved without ambiguity.

Written by the indexing model from the issue text.

Assessment

Domain
hpc
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.