Skip to content

Commit baa0c0b

Browse files
committed
Private functiona and constants
1 parent cadb104 commit baa0c0b

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace GraphBLAS.FSharp.Backend.Algorithms
1+
namespace GraphBLAS.FSharp.Backend.Algorithms
22

33
open GraphBLAS.FSharp
44
open GraphBLAS.FSharp.Backend
@@ -14,7 +14,7 @@ open GraphBLAS.FSharp.Objects.ClCellExtensions
1414
module internal PageRank =
1515
let alpha = 0.85f
1616

17-
let countOutDegree (clContext: ClContext) workGroupSize =
17+
let private countOutDegree (clContext: ClContext) workGroupSize =
1818

1919
let one =
2020
<@ fun (x: float32 option) (_: int option) ->
@@ -42,19 +42,18 @@ module internal PageRank =
4242

4343
let prepareMatrix (clContext: ClContext) workGroupSize =
4444

45-
let alpha = 0.85f
45+
//Passing global variable to kernel in Brahma is not possible
46+
let alpha = alpha
4647

4748
let op =
4849
<@ fun (x: float32 option) y ->
49-
let mutable res = 0.0f
50+
let mutable res = None
5051

5152
match x, y with
52-
| Some _, Some y -> res <- alpha / (float32 y)
53-
| Some _, None -> ()
54-
| None, Some _ -> ()
55-
| None, None -> ()
53+
| Some _, Some y -> res <- Some(alpha / (float32 y))
54+
| _ -> ()
5655

57-
if res = 0.0f then None else Some res @>
56+
res @>
5857

5958
//TODO: generalize to map2 Matrix x Vector
6059
let multiply =
@@ -136,10 +135,7 @@ module internal PageRank =
136135

137136
let run (clContext: ClContext) workGroupSize =
138137

139-
let alpha = 0.85f
140-
let accuracy = 0.00000001f
141-
142-
let minusAndSquare = ArithmeticOperations.minusAndSquare
138+
let squareOfDifference = ArithmeticOperations.squareOfDifference
143139
let plus = ArithmeticOperations.float32SumOption
144140
let mul = ArithmeticOperations.float32MulOption
145141

@@ -150,7 +146,7 @@ module internal PageRank =
150146
GraphBLAS.FSharp.Vector.map2InPlace plus clContext workGroupSize
151147

152148
let subtractAndSquare =
153-
GraphBLAS.FSharp.Vector.map2To minusAndSquare clContext workGroupSize
149+
GraphBLAS.FSharp.Vector.map2To squareOfDifference clContext workGroupSize
154150

155151
let reduce =
156152
GraphBLAS.FSharp.Vector.reduce <@ (+) @> clContext workGroupSize

0 commit comments

Comments
 (0)