diff --git a/benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/PageRank.fs b/benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/PageRank.fs index 70273357..9e6a3f38 100644 --- a/benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/PageRank.fs +++ b/benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/PageRank.fs @@ -23,7 +23,7 @@ type Benchmarks( let mutable funToBenchmark = None let mutable matrix = Unchecked.defaultof> - let mutable matrixPrepared = Unchecked.defaultof> + let mutable matrixPrepared = Unchecked.defaultof> let mutable matrixHost = Unchecked.defaultof<_> let accuracy = 0.00000001f diff --git a/src/GraphBLAS-sharp.Backend/Algorithms/PageRank.fs b/src/GraphBLAS-sharp.Backend/Algorithms/PageRank.fs index d806b4fe..d089d945 100644 --- a/src/GraphBLAS-sharp.Backend/Algorithms/PageRank.fs +++ b/src/GraphBLAS-sharp.Backend/Algorithms/PageRank.fs @@ -131,6 +131,7 @@ module internal PageRank = transposeInPlace queue DeviceOnly newMatrix |> ClMatrix.CSR + |> PageRankMatrix | _ -> failwith "Not implemented" let run (clContext: ClContext) workGroupSize = @@ -154,8 +155,7 @@ module internal PageRank = let create = GraphBLAS.FSharp.Vector.create clContext workGroupSize - fun (queue: MailboxProcessor) (matrix: ClMatrix) accuracy -> - + fun (queue: MailboxProcessor) (PageRankMatrix matrix) accuracy -> let vertexCount = matrix.RowCount //None is 0 diff --git a/src/GraphBLAS-sharp.Backend/Objects/Matrix.fs b/src/GraphBLAS-sharp.Backend/Objects/Matrix.fs index 81771bd0..b17dbb2b 100644 --- a/src/GraphBLAS-sharp.Backend/Objects/Matrix.fs +++ b/src/GraphBLAS-sharp.Backend/Objects/Matrix.fs @@ -173,3 +173,36 @@ type ClMatrix<'a when 'a: struct> = | ClMatrix.COO matrix -> matrix.NNZ | ClMatrix.CSC matrix -> matrix.NNZ | ClMatrix.LIL matrix -> matrix.NNZ + +/// +/// Represents an abstraction over matrix, which is converted to correct format for PageRank algorithm +/// +type PageRankMatrix<'a when 'a: struct> = + | PageRankMatrix of ClMatrix<'a> + /// + /// Gets the number of rows in matrix. + /// + member this.RowCount = + match this with + | PageRankMatrix matrix -> matrix.RowCount + + /// + /// Gets the number of columns in matrix. + /// + member this.ColumnCount = + match this with + | PageRankMatrix matrix -> matrix.ColumnCount + + /// + /// Release device resources allocated for the matrix. + /// + member this.Dispose q = + match this with + | PageRankMatrix matrix -> matrix.Dispose q + + /// + /// Gets the number of non-zero elements in matrix. + /// + member this.NNZ = + match this with + | PageRankMatrix matrix -> matrix.NNZ diff --git a/tests/GraphBLAS-sharp.Tests/Program.fs b/tests/GraphBLAS-sharp.Tests/Program.fs index 5b7b7908..b3e11bc4 100644 --- a/tests/GraphBLAS-sharp.Tests/Program.fs +++ b/tests/GraphBLAS-sharp.Tests/Program.fs @@ -92,7 +92,8 @@ let algorithmsTests = testList "Algorithms tests" [ Algorithms.BFS.tests - Algorithms.SSSP.tests ] + Algorithms.SSSP.tests + Algorithms.PageRank.tests ] |> testSequenced let deviceTests =