Skip to content

Commit 4627907

Browse files
committed
refactor: SpGeMM memory release
1 parent e52847c commit 4627907

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/GraphBLAS-sharp.Backend/Common/Sort/Radix.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ module Radix =
318318
keysPair <- swap keysPair
319319
valuesPair <- swap valuesPair
320320

321+
globalOffset.Free processor
321322
localOffset.Free processor
322323
shift.Free processor
323324

src/GraphBLAS-sharp.Backend/Common/Sum.fs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@ module Reduce =
568568
.ToHostAndFree processor
569569

570570
if resultLength = 0 then
571+
reducedValues.Free processor
572+
reducedKeys.Free processor
573+
resultPositions.Free processor
574+
571575
None
572576
else
573577
// write values
@@ -848,6 +852,11 @@ module Reduce =
848852
.ToHostAndFree processor
849853

850854
if resultLength = 0 then
855+
reducedValues.Free processor
856+
firstReducedKeys.Free processor
857+
secondReducedKeys.Free processor
858+
resultPositions.Free processor
859+
851860
None
852861
else
853862
// write value

src/GraphBLAS-sharp.Backend/Matrix/SpGeMM/Expand.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ module Expand =
399399

400400
// compute sub result
401401
let length, result = runCOO subMatrix
402+
403+
// release subMatrix (TODO(non blocking Free)
404+
subMatrix.Dispose processor
405+
402406
// increase workOffset according to previous expand
403407
let workOffset = workOffset + length
404408

@@ -445,7 +449,12 @@ module Expand =
445449
if generalLength < maxAllocSize then
446450
segmentLengths.Free processor
447451

448-
runOneStep processor allocationMode leftMatrix rightMatrixRowsNNZ rightMatrix
452+
let result =
453+
runOneStep processor allocationMode leftMatrix rightMatrixRowsNNZ rightMatrix
454+
455+
rightMatrixRowsNNZ.Free processor
456+
457+
result
449458
else
450459
let result =
451460
runManySteps

0 commit comments

Comments
 (0)