1- namespace GraphBLAS.FSharp.Backend.Algorithms
1+ namespace GraphBLAS.FSharp.Backend.Algorithms
22
33open GraphBLAS.FSharp
44open GraphBLAS.FSharp .Backend
@@ -14,7 +14,7 @@ open GraphBLAS.FSharp.Objects.ClCellExtensions
1414module internal PageRank =
1515 let alpha = 0.85 f
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.85 f
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.0 f
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.0 f 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.85 f
140- let accuracy = 0.00000001 f
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