Skip to content

Commit 3616f94

Browse files
committed
SSSP optimization, using front as mask
1 parent 3ceb397 commit 3616f94

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

  • src/GraphBLAS-sharp.Backend/Algorithms

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,16 @@ module SSSP =
2424

2525
let create = ClArray.create clContext workGroupSize
2626

27-
let createMask = ClArray.create clContext workGroupSize
28-
2927
let ofList = Vector.ofList clContext workGroupSize
3028

3129
let eWiseMulLess =
32-
ClArray.map2InPlace less clContext workGroupSize
30+
Map.map2InPlace less clContext workGroupSize
3331

3432
let eWiseAddMin =
35-
ClArray.map2InPlace min clContext workGroupSize
33+
Map.map2InPlace min clContext workGroupSize
3634

37-
let fillSubVectorTo =
38-
Vector.assignByMaskInPlace (Convert.assignToOption Mask.assignComplemented) clContext workGroupSize
35+
let filter =
36+
Map.map2InPlace Mask.op clContext workGroupSize
3937

4038
let containsNonZero =
4139
ClArray.exists Predicates.isSome clContext workGroupSize
@@ -54,25 +52,22 @@ module SSSP =
5452
create queue DeviceOnly vertexCount None
5553
|> ClVector.Dense
5654

57-
let m =
58-
createMask queue DeviceOnly vertexCount None
59-
|> ClVector.Dense
60-
6155
let mutable stop = false
6256

6357
while not stop do
64-
match f1, f2, distance, m with
65-
| ClVector.Dense front1, ClVector.Dense front2, ClVector.Dense dist, ClVector.Dense mask ->
58+
match f1, f2, distance with
59+
| ClVector.Dense front1, ClVector.Dense front2, ClVector.Dense dist ->
6660
//Getting new frontier
6761
spMVTo queue matrix front1 front2
6862

6963
//Checking which distances were updated
70-
eWiseMulLess queue front2 dist mask
64+
eWiseMulLess queue front2 dist front1
7165
//Updating
7266
eWiseAddMin queue dist front2 dist
7367

7468
//Filtering unproductive vertices
75-
fillSubVectorTo queue front2 mask (clContext.CreateClCell 0) front2
69+
//Front1 is a mask
70+
filter queue front2 front1 front2
7671

7772
//Swap fronts
7873
let temp = f1
@@ -82,13 +77,13 @@ module SSSP =
8277
//Checking if no distances were updated
8378
stop <-
8479
not
85-
<| (containsNonZero queue mask).ToHostAndFree(queue)
80+
<| (containsNonZero queue front1)
81+
.ToHostAndFree(queue)
8682

8783
| _ -> failwith "not implemented"
8884

8985
f1.Dispose queue
9086
f2.Dispose queue
91-
m.Dispose queue
9287

9388
match distance with
9489
| ClVector.Dense dist -> dist

0 commit comments

Comments
 (0)