Skip to content

Commit 33d974e

Browse files
committed
Elementwise setPositions fix
1 parent 9de7da5 commit 33d974e

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/GraphBLAS-sharp.Backend/Matrix/COOMatrix/COOMatrix.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ module COOMatrix =
1111
let private setPositions<'a when 'a: struct> (clContext: ClContext) workGroupSize =
1212

1313
let setPositions =
14-
<@ fun (ndRange: Range1D) prefixSumArrayLength (allRowsBuffer: ClArray<int>) (allColumnsBuffer: ClArray<int>) (allValuesBuffer: ClArray<'a>) (prefixSumArrayBuffer: ClArray<int>) (resultRowsBuffer: ClArray<int>) (resultColumnsBuffer: ClArray<int>) (resultValuesBuffer: ClArray<'a>) ->
14+
<@ fun (ndRange: Range1D) prefixSumArrayLength resultLength (allRowsBuffer: ClArray<int>) (allColumnsBuffer: ClArray<int>) (allValuesBuffer: ClArray<'a>) (prefixSumArrayBuffer: ClArray<int>) (resultRowsBuffer: ClArray<int>) (resultColumnsBuffer: ClArray<int>) (resultValuesBuffer: ClArray<'a>) ->
1515

1616
let i = ndRange.GlobalID0
17+
let index = prefixSumArrayBuffer.[i]
1718

18-
if i = prefixSumArrayLength - 1
19-
|| i < prefixSumArrayLength
20-
&& prefixSumArrayBuffer.[i]
21-
<> prefixSumArrayBuffer.[i + 1] then
22-
let index = prefixSumArrayBuffer.[i]
23-
19+
if (i < prefixSumArrayLength - 1
20+
&& index <> prefixSumArrayBuffer.[i + 1])
21+
|| (i = prefixSumArrayLength - 1
22+
&& index < resultLength) then
2423
resultRowsBuffer.[index] <- allRowsBuffer.[i]
2524
resultColumnsBuffer.[index] <- allColumnsBuffer.[i]
2625
resultValuesBuffer.[index] <- allValuesBuffer.[i] @>
@@ -82,6 +81,7 @@ module COOMatrix =
8281
kernel.KernelFunc
8382
ndRange
8483
prefixSumArrayLength
84+
resultLength
8585
allRows
8686
allColumns
8787
allValues

tests/GraphBLAS-sharp.Tests/Helpers.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ module Utils =
440440
|> Array.map (fun caseInfo -> FSharpValue.MakeUnion(caseInfo, [||]) :?> 'a)
441441
|> List.ofArray
442442

443-
let avaliableContexts (platformRegex: string) =
443+
let availableContexts (platformRegex: string) =
444444
let mutable e = ErrorCode.Unknown
445445

446446
Cl.GetPlatformIDs &e
@@ -520,7 +520,7 @@ module Utils =
520520
MatrixCase: MatrixFormat }
521521

522522
let testCases =
523-
[ avaliableContexts "" |> Seq.map box
523+
[ availableContexts "" |> Seq.map box
524524
listOfUnionCases<MatrixFormat> |> Seq.map box ]
525525
|> List.map List.ofSeq
526526
|> cartesian

0 commit comments

Comments
 (0)