|
| 1 | +namespace GraphBLAS.FSharp.Benchmarks |
| 2 | + |
| 3 | +open GraphBLAS.FSharp |
| 4 | +open GraphBLAS.FSharp.Algorithms |
| 5 | +open BenchmarkDotNet.Attributes |
| 6 | +open BenchmarkDotNet.Configs |
| 7 | +open BenchmarkDotNet.Columns |
| 8 | +open System.IO |
| 9 | +open System |
| 10 | +open System.IO |
| 11 | +open System.Text.RegularExpressions |
| 12 | +open GraphBLAS.FSharp |
| 13 | +open GraphBLAS.FSharp.Predefined |
| 14 | +open BenchmarkDotNet.Attributes |
| 15 | +open BenchmarkDotNet.Configs |
| 16 | +open BenchmarkDotNet.Columns |
| 17 | +open BenchmarkDotNet.Filters |
| 18 | +open Brahma.FSharp.OpenCL.WorkflowBuilder.Basic |
| 19 | +open Brahma.FSharp.OpenCL.WorkflowBuilder.Evaluation |
| 20 | +open OpenCL.Net |
| 21 | +open GraphBLAS.FSharp.IO |
| 22 | +open QuickGraph |
| 23 | + |
| 24 | +type Config2() = |
| 25 | + inherit ManualConfig() |
| 26 | + |
| 27 | + do |
| 28 | + base.AddColumn( |
| 29 | + MatrixShapeColumn("RowCount", fun mtxReader -> mtxReader.ReadMatrixShape().RowCount) :> IColumn, |
| 30 | + MatrixShapeColumn("ColumnCount", fun mtxReader -> mtxReader.ReadMatrixShape().ColumnCount) :> IColumn, |
| 31 | + MatrixShapeColumn("NNZ", fun mtxReader -> mtxReader.ReadMatrixShape().Nnz) :> IColumn, |
| 32 | + TEPSColumn() :> IColumn, |
| 33 | + StatisticColumn.Min, |
| 34 | + StatisticColumn.Max |
| 35 | + ) |> ignore |
| 36 | + |
| 37 | +[<IterationCount(5)>] |
| 38 | +[<WarmupCount(3)>] |
| 39 | +[<Config(typeof<Config2>)>] |
| 40 | +type QGBenchmarks() = |
| 41 | + let random = Random() |
| 42 | + |
| 43 | + let graph = AdjacencyGraph<int, Edge<int>>(false) |
| 44 | + let mutable source = 0 |
| 45 | + let mutable bfs = Unchecked.defaultof<Algorithms.Search.BreadthFirstSearchAlgorithm<int, Edge<int>>> |
| 46 | + |
| 47 | + [<ParamsSource("InputMatricesProvider")>] |
| 48 | + member val InputMatrixReader = Unchecked.defaultof<MtxReader> with get, set |
| 49 | + |
| 50 | + [<GlobalSetup>] |
| 51 | + member this.BuildMatrixAndSetSource() = |
| 52 | + let matrix = this.InputMatrixReader.ReadMatrixBoolean(fun _ -> true) |
| 53 | + |
| 54 | + match matrix with |
| 55 | + | MatrixCSR csr -> failwith "Not implemented" |
| 56 | + | MatrixCOO coo -> |
| 57 | + for i = 0 to coo.Values.Length - 1 do |
| 58 | + graph.AddVerticesAndEdge(Edge(coo.Rows.[i], coo.Columns.[i])) |> ignore |
| 59 | + |
| 60 | + source <- random.Next <| Matrix.rowCount matrix |
| 61 | + bfs <- Algorithms.Search.BreadthFirstSearchAlgorithm(graph) |
| 62 | + |
| 63 | + [<Benchmark>] |
| 64 | + member this.LevelBFS() = |
| 65 | + bfs.Compute(source) |
| 66 | + |
| 67 | + static member InputMatricesProvider = |
| 68 | + "BFSBenchmarks.txt" |
| 69 | + |> Utils.getMatricesFilenames |
| 70 | + |> Seq.map |
| 71 | + (fun matrixFilename -> |
| 72 | + match Path.GetExtension matrixFilename with |
| 73 | + | ".mtx" -> MtxReader(Utils.getFullPathToMatrix "BFSDatasets" matrixFilename) |
| 74 | + | _ -> failwith "Unsupported matrix format" |
| 75 | + ) |
0 commit comments