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

Fix leak in new csr/cscLayout records' implementation #26193

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion modules/layouts/CompressedSparseLayout.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,19 @@ module CompressedSparseLayout {
}
return x;
}

proc deinit() {
on _value {
// Count the number of domains that refer to this distribution.
// and mark the distribution to be freed when that number reaches 0.
// If the number is 0, .remove() returns the distribution
// that should be freed.
var distToFree = _value.remove();
if distToFree != nil {
_delete_dist(distToFree!, false);
}
}
}
}

/*
Expand Down Expand Up @@ -236,7 +249,7 @@ module CompressedSparseLayout {
proc init(value: CSImpl(?)) {
this.compressRows = value.compressRows;
this.sortedIndices = value.sortedIndices;
this.chpl_layoutHelp = new chpl_layoutHelper(value);
this.chpl_layoutHelp = new chpl_layoutHelper(value.dsiClone());
}

operator ==(l: csLayout(?), r: csLayout(?)) param {
Expand Down
2 changes: 1 addition & 1 deletion test/arrays/sparse/copyRemoteSparse-cs.good
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ In initCopy(definedConst=true), domain definedConst: false; localizing
| 0 | 32 | 0 |
| 1 | 0 | 0 |
| 2 | 0 | 0 |
| 3 | 195 | 2 |
| 3 | 194 | 1 |
1.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 2.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 3.3 0.0 0.0 0.0 0.0 0.0 0.0
Expand Down
24 changes: 12 additions & 12 deletions test/studies/spsMatMatMult/driver-comms.good
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ B is:
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

| locale | get | put | execute_on | execute_on_nb |
| -----: | --: | --: | ---------: | ------------: |
| 0 | 150 | 2 | 4 | 3 |
| 1 | 224 | 2 | 4 | 0 |
| 2 | 199 | 2 | 4 | 0 |
| 3 | 137 | 2 | 4 | 0 |
| locale | get | execute_on_nb |
| -----: | --: | ------------: |
| 0 | 146 | 3 |
| 1 | 220 | 0 |
| 2 | 195 | 0 |
| 3 | 133 | 0 |

C (sparsely computed) is:
0 0 0 0 0 0 0 0 0 0
Expand All @@ -41,12 +41,12 @@ C (sparsely computed) is:
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

| locale | get | put | execute_on | execute_on_nb |
| -----: | ----: | --: | ---------: | ------------: |
| 0 | 31100 | 2 | 4 | 9 |
| 1 | 242 | 3 | 4 | 0 |
| 2 | 217 | 3 | 4 | 0 |
| 3 | 155 | 3 | 4 | 0 |
| locale | get | put | execute_on_nb |
| -----: | ----: | --: | ------------: |
| 0 | 31096 | 0 | 9 |
| 1 | 238 | 1 | 0 |
| 2 | 213 | 1 | 0 |
| 3 | 151 | 1 | 0 |

C (densely computed) is:
0 0 0 0 0 0 0 0 0 0
Expand Down
24 changes: 12 additions & 12 deletions test/studies/spsMatMatMult/driver-full-comms.good
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ B is:
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1

| locale | get | put | execute_on | execute_on_nb |
| -----: | --: | --: | ---------: | ------------: |
| 0 | 682 | 2 | 4 | 3 |
| 1 | 684 | 2 | 4 | 0 |
| 2 | 684 | 2 | 4 | 0 |
| 3 | 684 | 2 | 4 | 0 |
| locale | get | execute_on_nb |
| -----: | --: | ------------: |
| 0 | 678 | 3 |
| 1 | 680 | 0 |
| 2 | 680 | 0 |
| 3 | 680 | 0 |

C (sparsely computed) is:
10 10 10 10 10 10 10 10 10 10
Expand All @@ -41,12 +41,12 @@ C (sparsely computed) is:
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10

| locale | get | put | execute_on | execute_on_nb |
| -----: | ----: | --: | ---------: | ------------: |
| 0 | 60682 | 2 | 4 | 9 |
| 1 | 702 | 3 | 4 | 0 |
| 2 | 702 | 3 | 4 | 0 |
| 3 | 702 | 3 | 4 | 0 |
| locale | get | put | execute_on_nb |
| -----: | ----: | --: | ------------: |
| 0 | 60678 | 0 | 9 |
| 1 | 698 | 1 | 0 |
| 2 | 698 | 1 | 0 |
| 3 | 698 | 1 | 0 |

C (densely computed) is:
10 10 10 10 10 10 10 10 10 10
Expand Down