Skip to content

Commit 1cf8c18

Browse files
committed
Fix merge
1 parent 3a1f9e9 commit 1cf8c18

16 files changed

Lines changed: 73 additions & 66 deletions

File tree

src/GraphBLAS-sharp/Algorithms/BFS.fs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ module BFS =
1919
let! currentLevelScalar = Scalar.create currentLevel
2020

2121
let! frontierMask = Vector.mask frontier
22-
do! Vector.fillSubVector frontierMask levels currentLevelScalar
22+
do! Vector.fillSubVector levels frontierMask currentLevelScalar
2323

2424
let! levelsComplemented = Vector.complemented levels
2525
do! Matrix.mxvWithMask AnyAll.bool levelsComplemented transposed frontier // q[!v] = (A' ||.&& q)' = q' ||.&& A -- replace + comp
2626
>>= Vector.assignVector frontier
2727

28-
// TODO need export or sync for scalar
29-
let! (Scalar succ) = Vector.reduce AnyAll.bool frontier
28+
let! succ =
29+
Vector.reduce AnyAll.bool frontier
30+
>>= Scalar.exportValue
31+
3032
break' <- not succ
3133

3234
return levels

src/GraphBLAS-sharp/Algorithms/BetweennessCentrality.fs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ module BetweennessCentrality =
3232
do! Matrix.vxmWithMask AddMult.int pMask q matrix
3333
>>= Vector.assignVector q
3434

35-
do! Vector.reduce Add.int q
36-
>>= fun (Scalar s) -> EvalGB.return' (sum <- s)
35+
let! sum' =
36+
Vector.reduce Add.int q
37+
>>= Scalar.exportValue
3738

39+
sum <- sum'
3840
d <- d + 1
3941

4042
let! t1 = Vector.zeroCreate<float32> n

src/GraphBLAS-sharp/Algorithms/TriangleCounting.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ module TriangleCounting =
1313
let! result = (matrix', transposed) ||> Matrix.mxmWithMask AddMult.int lowerTriangularMask
1414
let! count = result |> Matrix.reduce Add.int
1515

16-
return! (Scalar.exportValue count)
16+
return! Scalar.exportValue count
1717
}

src/GraphBLAS-sharp/Backend/COOVector/AssignSubVector.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ module internal AssignSubVector =
2020
let run (leftIndices: int[]) (leftValues: 'a[]) (rightIndices: int[]) (rightValues: 'a[]) (maskIndices: int[]) : OpenCLEvaluation<int[] * 'a[]> =
2121
if leftValues.Length = 0 then
2222
opencl {
23-
let! resultIndices = Copy.run rightIndices
24-
let! resultValues = Copy.run rightValues
23+
let! resultIndices = Copy.copyArray rightIndices
24+
let! resultValues = Copy.copyArray rightValues
2525

2626
return resultIndices, resultValues
2727
}

src/GraphBLAS-sharp/Backend/COOVector/FillSubVector.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module internal FillSubVector =
1818
let run (leftIndices: int[]) (leftValues: 'a[]) (rightIndices: int[]) (scalar: 'a[]) : OpenCLEvaluation<int[] * 'a[]> =
1919
if leftValues.Length = 0 then
2020
opencl {
21-
let! resultIndices = Copy.run rightIndices
21+
let! resultIndices = Copy.copyArray rightIndices
2222
let! resultValues = Replicate.run rightIndices.Length scalar
2323

2424
return resultIndices, resultValues

src/GraphBLAS-sharp/Backend/COOVector/Utilities/AssignSubVector/Filter.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ open GraphBLAS.FSharp.Backend.Common
88
[<AutoOpen>]
99
module internal Filter =
1010
let filter (leftIndices: int[]) (leftValues: 'a[]) (rightIndices: int[]) (rightValues: 'a[]) (bitmap: bool[]) : OpenCLEvaluation<int[] * 'a[] * int[]> = opencl {
11-
let workGroupSize = Utils.workGroupSize
11+
let workGroupSize = Utils.defaultWorkGroupSize
1212
let firstSide = leftValues.Length
1313
let secondSide = rightIndices.Length
1414
let sumOfSides = firstSide + secondSide
@@ -110,7 +110,7 @@ module internal Filter =
110110
let rawPositions = Array.create sumOfSides 1
111111

112112
do! RunCommand merge <| fun kernelPrepare ->
113-
let ndRange = _1D(Utils.workSize sumOfSides, workGroupSize)
113+
let ndRange = _1D(Utils.getDefaultGlobalSize sumOfSides, workGroupSize)
114114
kernelPrepare
115115
ndRange
116116
leftIndices

src/GraphBLAS-sharp/Backend/COOVector/Utilities/AssignSubVector/Intersect.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ open GraphBLAS.FSharp.Backend.Common
88
[<AutoOpen>]
99
module internal Intersect =
1010
let intersect (leftIndices: int[]) (leftValues: 'a[]) (rightIndices: int[]) : OpenCLEvaluation<bool[] * 'a[]> = opencl {
11-
let workGroupSize = Utils.workGroupSize
11+
let workGroupSize = Utils.defaultWorkGroupSize
1212
let firstSide = leftValues.Length
1313
let secondSide = rightIndices.Length
1414
let sumOfSides = firstSide + secondSide
@@ -100,7 +100,7 @@ module internal Intersect =
100100
let resultValues = Array.create secondSide Unchecked.defaultof<'a>
101101

102102
do! RunCommand merge <| fun kernelPrepare ->
103-
let ndRange = _1D(Utils.workSize sumOfSides, workGroupSize)
103+
let ndRange = _1D(Utils.getDefaultGlobalSize sumOfSides, workGroupSize)
104104
kernelPrepare
105105
ndRange
106106
leftIndices

src/GraphBLAS-sharp/Backend/COOVector/Utilities/AssignSubVector/PreparePositions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module internal PreparePositions =
2222
@>
2323

2424
do! RunCommand preparePositions <| fun kernelPrepare ->
25-
let ndRange = _1D(Utils.workSize (length - 1), Utils.workGroupSize)
25+
let ndRange = _1D(Utils.getDefaultGlobalSize (length - 1), Utils.defaultWorkGroupSize)
2626
kernelPrepare
2727
ndRange
2828
allIndices

src/GraphBLAS-sharp/Backend/COOVector/Utilities/FillSubVector/Merge.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ open GraphBLAS.FSharp.Backend.Common
99
[<AutoOpen>]
1010
module internal Merge =
1111
let merge (leftIndices: int[]) (leftValues: 'a[]) (rightIndices: int[]) (scalar: 'a[]) : OpenCLEvaluation<int[] * 'a[]> = opencl {
12-
let workGroupSize = Utils.workGroupSize
12+
let workGroupSize = Utils.defaultWorkGroupSize
1313
let firstSide = leftValues.Length
1414
let secondSide = rightIndices.Length
1515
let sumOfSides = firstSide + secondSide
@@ -105,7 +105,7 @@ module internal Merge =
105105
let allValues = Array.create sumOfSides Unchecked.defaultof<'a>
106106

107107
do! RunCommand merge <| fun kernelPrepare ->
108-
let ndRange = _1D(Utils.workSize sumOfSides, workGroupSize)
108+
let ndRange = _1D(Utils.getDefaultGlobalSize sumOfSides, workGroupSize)
109109
kernelPrepare
110110
ndRange
111111
leftIndices

src/GraphBLAS-sharp/Backend/COOVector/Utilities/FillSubVector/PreparePositions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module internal PreparePositions =
2424
let rawPositions = Array.create length 1
2525

2626
do! RunCommand preparePositions <| fun kernelPrepare ->
27-
let ndRange = _1D(Utils.workSize (length - 1), Utils.workGroupSize)
27+
let ndRange = _1D(Utils.getDefaultGlobalSize (length - 1), Utils.defaultWorkGroupSize)
2828
kernelPrepare
2929
ndRange
3030
allIndices

0 commit comments

Comments
 (0)