Skip to content

Commit 3d9654d

Browse files
committed
fix: msbfs parents, clarray.copyto bugs
1 parent 94fec78 commit 3d9654d

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/GraphBLAS-sharp.Backend/Algorithms/MSBFS.fs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ module internal MSBFS =
119119
let vertexCount = matrix.RowCount
120120
let sourceVertexCount = source.Length
121121

122+
let source = source |> List.sort
123+
122124
let startMatrix =
123125
source |> List.mapi (fun i vertex -> i, vertex, 1)
124126

@@ -185,8 +187,6 @@ module internal MSBFS =
185187

186188
let copyIndices = ClArray.copyTo clContext workGroupSize
187189

188-
// let copyMatrix = Matrix.copy clContext workGroupSize
189-
190190
fun (queue: MailboxProcessor<Msg>) allocationMode (front: ClMatrix.COO<_>) (parents: ClMatrix.COO<_>) ->
191191

192192
// Find intersection of levels and front indices.
@@ -214,8 +214,8 @@ module internal MSBFS =
214214

215215
let spGeMM =
216216
Operations.SpGeMM.COO.expand
217-
(ArithmeticOperations.min -1)
218-
(ArithmeticOperations.fst -1)
217+
(ArithmeticOperations.min)
218+
(ArithmeticOperations.fst)
219219
clContext
220220
workGroupSize
221221

@@ -226,6 +226,8 @@ module internal MSBFS =
226226
let vertexCount = inputMatrix.RowCount
227227
let sourceVertexCount = source.Length
228228

229+
let source = source |> List.sort
230+
229231
let matrix =
230232
match inputMatrix with
231233
| ClMatrix.CSR m ->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ module ClArray =
133133
let i = ndRange.GlobalID0
134134

135135
if i < inputArrayLength then
136-
source.[i] <- destination.[i] @>
136+
destination.[i] <- source.[i] @>
137137

138138
let program = clContext.Compile(copy)
139139

src/GraphBLAS-sharp.Backend/Quotes/Arithmetic.fs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,9 @@ module ArithmeticOperations =
255255
| None, Some y -> Some y
256256
| _ -> None @>
257257

258-
let min zero =
259-
<@ fun x y ->
260-
let result = min x y
258+
let min<'a when 'a: comparison> = <@ fun (x: 'a) (y: 'a) -> Some (min x y) @>
261259

262-
if result = zero then
263-
None
264-
else
265-
Some result @>
266-
267-
let fst zero =
268-
<@ fun x _ -> if x = zero then None else Some x @>
260+
let fst<'a> = <@ fun (x: 'a) (_: 'a) -> Some x @>
269261

270262
//PageRank specific
271263
let squareOfDifference =

0 commit comments

Comments
 (0)