Skip to content

Commit faf242c

Browse files
committed
PageRankMatrix type
1 parent e548294 commit faf242c

4 files changed

Lines changed: 38 additions & 4 deletions

File tree

benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/PageRank.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Benchmarks(
2323

2424
let mutable funToBenchmark = None
2525
let mutable matrix = Unchecked.defaultof<ClMatrix<float32>>
26-
let mutable matrixPrepared = Unchecked.defaultof<ClMatrix<float32>>
26+
let mutable matrixPrepared = Unchecked.defaultof<PageRankMatrix<float32>>
2727
let mutable matrixHost = Unchecked.defaultof<_>
2828

2929
let accuracy = 0.00000001f

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ module internal PageRank =
131131

132132
transposeInPlace queue DeviceOnly newMatrix
133133
|> ClMatrix.CSR
134+
|> PageRankMatrix
134135
| _ -> failwith "Not implemented"
135136

136137
let run (clContext: ClContext) workGroupSize =
@@ -154,8 +155,7 @@ module internal PageRank =
154155
let create =
155156
GraphBLAS.FSharp.Vector.create clContext workGroupSize
156157

157-
fun (queue: MailboxProcessor<Msg>) (matrix: ClMatrix<float32>) accuracy ->
158-
158+
fun (queue: MailboxProcessor<Msg>) (PageRankMatrix matrix) accuracy ->
159159
let vertexCount = matrix.RowCount
160160

161161
//None is 0

src/GraphBLAS-sharp.Backend/Objects/Matrix.fs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,36 @@ type ClMatrix<'a when 'a: struct> =
173173
| ClMatrix.COO matrix -> matrix.NNZ
174174
| ClMatrix.CSC matrix -> matrix.NNZ
175175
| ClMatrix.LIL matrix -> matrix.NNZ
176+
177+
/// <summary>
178+
/// Represents an abstraction over matrix, which is converted to correct format for PageRank algorithm
179+
/// </summary>
180+
type PageRankMatrix<'a when 'a: struct> =
181+
| PageRankMatrix of ClMatrix<'a>
182+
/// <summary>
183+
/// Gets the number of rows in matrix.
184+
/// </summary>
185+
member this.RowCount =
186+
match this with
187+
| PageRankMatrix matrix -> matrix.RowCount
188+
189+
/// <summary>
190+
/// Gets the number of columns in matrix.
191+
/// </summary>
192+
member this.ColumnCount =
193+
match this with
194+
| PageRankMatrix matrix -> matrix.ColumnCount
195+
196+
/// <summary>
197+
/// Release device resources allocated for the matrix.
198+
/// </summary>
199+
member this.Dispose q =
200+
match this with
201+
| PageRankMatrix matrix -> matrix.Dispose q
202+
203+
/// <summary>
204+
/// Gets the number of non-zero elements in matrix.
205+
/// </summary>
206+
member this.NNZ =
207+
match this with
208+
| PageRankMatrix matrix -> matrix.NNZ

tests/GraphBLAS-sharp.Tests/Program.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ let algorithmsTests =
9292
testList
9393
"Algorithms tests"
9494
[ Algorithms.BFS.tests
95-
Algorithms.SSSP.tests ]
95+
Algorithms.SSSP.tests
96+
Algorithms.PageRank.tests ]
9697
|> testSequenced
9798

9899
let deviceTests =

0 commit comments

Comments
 (0)