Skip to content

Commit 627e8c5

Browse files
committed
fix: SpGeMM, last item in pointers
1 parent 35e5e29 commit 627e8c5

File tree

1 file changed

+9
-3
lines changed
  • src/GraphBLAS-sharp.Backend/Matrix/SpGeMM

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,19 +345,24 @@ module Expand =
345345
let upperBound =
346346
ClArray.upperBoundAndValue clContext workGroupSize
347347

348+
let set = ClArray.set clContext workGroupSize
349+
348350
let subMatrix =
349351
CSR.Matrix.subRows clContext workGroupSize
350352

351353
let runCOO =
352354
runCOO opAdd opMul clContext workGroupSize
353355

354-
fun (processor: MailboxProcessor<_>) allocationMode maxAllocSize (leftMatrix: ClMatrix.CSR<'a>) segmentLengths rightMatrixRowsNNZ (rightMatrix: ClMatrix.CSR<'b>) ->
356+
fun (processor: MailboxProcessor<_>) allocationMode maxAllocSize generalLength (leftMatrix: ClMatrix.CSR<'a>) segmentLengths rightMatrixRowsNNZ (rightMatrix: ClMatrix.CSR<'b>) ->
355357
// extract segment lengths by left matrix rows pointers
356358
let segmentPointersByLeftMatrixRows =
357359
clContext.CreateClArrayWithSpecificAllocationMode(DeviceOnly, leftMatrix.RowPointers.Length)
358360

359361
gather processor leftMatrix.RowPointers segmentLengths segmentPointersByLeftMatrixRows
360362

363+
// set last element to one step length
364+
set processor segmentPointersByLeftMatrixRows (leftMatrix.RowPointers.Length - 1) generalLength
365+
361366
// curring
362367
let upperBound =
363368
upperBound processor segmentPointersByLeftMatrixRows
@@ -422,10 +427,10 @@ module Expand =
422427
let rightMatrixRowsNNZ =
423428
getNNZInRows processor DeviceOnly rightMatrix
424429

425-
let length, segmentLengths =
430+
let generalLength, segmentLengths =
426431
getSegmentPointers processor leftMatrix.Columns rightMatrixRowsNNZ
427432

428-
if length < maxAllocSize then
433+
if generalLength < maxAllocSize then
429434
segmentLengths.Free processor
430435

431436
runOneStep processor allocationMode leftMatrix rightMatrixRowsNNZ rightMatrix
@@ -435,6 +440,7 @@ module Expand =
435440
processor
436441
allocationMode
437442
maxAllocSize
443+
generalLength
438444
leftMatrix
439445
segmentLengths
440446
rightMatrixRowsNNZ

0 commit comments

Comments
 (0)