Skip to content

Commit d94a1ed

Browse files
committed
Add matrix shape columns to benchmarks summary; change run strategy
1 parent 7458001 commit d94a1ed

2 files changed

Lines changed: 64 additions & 35 deletions

File tree

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksEWiseAdd.fs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,23 @@ with
2323
let (ClContext context) = this
2424
let device = context.Device
2525
let deviceName = Cl.GetDeviceInfo(device, DeviceInfo.Name, &e).ToString()
26-
sprintf "%20s" deviceName
27-
28-
type InputMatrixFormat = {
29-
MatrixName: string
30-
MatrixStructure: COOFormat<float>
31-
}
32-
with
33-
override this.ToString() =
34-
sprintf "%s (%i, %i)"
35-
this.MatrixName
36-
this.MatrixStructure.RowCount
37-
this.MatrixStructure.ColumnCount
26+
if deviceName.Length < 20 then
27+
sprintf "%s" deviceName
28+
else
29+
let platform = Cl.GetDeviceInfo(device, DeviceInfo.Platform, &e).CastTo<Platform>()
30+
let platformName = Cl.GetPlatformInfo(platform, PlatformInfo.Name, &e).ToString()
31+
let deviceType =
32+
match Cl.GetDeviceInfo(device, DeviceInfo.Type, &e).CastTo<DeviceType>() with
33+
| DeviceType.Cpu -> "CPU"
34+
| DeviceType.Gpu -> "GPU"
35+
| DeviceType.Accelerator -> "Accelerator"
36+
| _ -> "another"
37+
38+
sprintf "%s, %s" platformName deviceType
3839

3940
[<MinColumn; MaxColumn>]
4041
[<Config(typeof<Config>)>]
41-
[<SimpleJob(RunStrategy.Throughput)>]
42+
[<SimpleJob(RunStrategy.ColdStart, targetCount=1)>]
4243
type EWiseAddBenchmarks() =
4344
let mutable leftCOO = Unchecked.defaultof<Matrix<float>>
4445
let mutable rightCOO = Unchecked.defaultof<Matrix<float>>
@@ -179,7 +180,7 @@ type EWiseAddBenchmarks() =
179180
let (nrows, ncols, nnz) =
180181
matrixInfo.[0], matrixInfo.[1], matrixInfo.[2]
181182

182-
[ 0 .. nnz - 1 ]
183+
[0 .. nnz - 1]
183184
|> List.map
184185
(fun _ ->
185186
streamReader.ReadLine().Split(' ')
Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,52 @@
11
namespace GraphBLAS.FSharp.Benchmarks
22

3-
open GraphBLAS.FSharp.Algorithms
4-
open BenchmarkDotNet.Attributes
53
open BenchmarkDotNet.Configs
64
open BenchmarkDotNet.Columns
75
open BenchmarkDotNet.Reports
86
open BenchmarkDotNet.Running
97
open BenchmarkDotNet.Filters
10-
open System.IO
8+
open GraphBLAS.FSharp
9+
10+
type InputMatrixFormat = {
11+
MatrixName: string
12+
MatrixStructure: COOFormat<float>
13+
}
14+
with
15+
override this.ToString() =
16+
sprintf "%s" this.MatrixName
17+
18+
type MatrixShapeColumn(columnName: string, getShape: InputMatrixFormat -> int) =
19+
interface IColumn with
20+
member this.AlwaysShow: bool = true
21+
member this.Category: ColumnCategory = ColumnCategory.Params
22+
member this.ColumnName: string = columnName
23+
member this.GetValue(summary: Summary, benchmarkCase: BenchmarkCase): string =
24+
let inputMatrix = benchmarkCase.Parameters.["InputMatrix"] :?> InputMatrixFormat
25+
sprintf "%i" <| getShape inputMatrix
26+
member this.GetValue(summary: Summary, benchmarkCase: BenchmarkCase, style: SummaryStyle): string =
27+
(this :> IColumn).GetValue(summary, benchmarkCase)
28+
member this.Id: string = sprintf "%s.%s" "MatrixShapeColumn" columnName
29+
member this.IsAvailable(summary: Summary): bool = true
30+
member this.IsDefault(summary: Summary, benchmarkCase: BenchmarkCase): bool = false
31+
member this.IsNumeric: bool = true
32+
member this.Legend: string = sprintf "%s of input matrix" columnName
33+
member this.PriorityInCategory: int = 1
34+
member this.UnitType: UnitType = UnitType.Size
1135

1236
type TEPSColumn() =
1337
interface IColumn with
1438
member this.AlwaysShow: bool = true
1539
member this.Category: ColumnCategory = ColumnCategory.Statistics
1640
member this.ColumnName: string = "TEPS"
1741
member this.GetValue(summary: Summary, benchmarkCase: BenchmarkCase): string =
42+
let inputMatrix = benchmarkCase.Parameters.["InputMatrix"] :?> InputMatrixFormat
43+
let (nrows, ncols, nnz) =
44+
inputMatrix.MatrixStructure.RowCount,
45+
inputMatrix.MatrixStructure.ColumnCount,
46+
inputMatrix.MatrixStructure.Values.Length
47+
let (vertices, edges) = if nrows = ncols then (nrows, nnz) else (ncols, nrows)
1848
let meanTime = summary.[benchmarkCase].ResultStatistics.Mean
19-
let pathToFirstGraph = benchmarkCase.Parameters.["PathToGraphPair"] :?> (string * string) |> fst
20-
let getFullPathToGraph filename =
21-
Path.Join [| __SOURCE_DIRECTORY__
22-
"Datasets"
23-
"EWiseAddDatasets"
24-
filename |]
25-
match Path.GetExtension pathToFirstGraph with
26-
| ".mtx" ->
27-
use streamReader = new StreamReader(pathToFirstGraph |> getFullPathToGraph)
28-
while streamReader.Peek() = int '%' do
29-
streamReader.ReadLine() |> ignore
30-
let matrixInfo = streamReader.ReadLine().Split(' ') |> Array.map int
31-
let (nrows, ncols, nnz) = matrixInfo.[0], matrixInfo.[1], matrixInfo.[2]
32-
let (vertices, edges) = if nrows = ncols then (nrows, nnz) else (ncols, nrows)
33-
sprintf "%f" <| float edges / (meanTime * 1e-6)
34-
| another -> sprintf "%s files not supported" another
49+
sprintf "%f" <| float edges / (meanTime * 1e-6)
3550
member this.GetValue(summary: Summary, benchmarkCase: BenchmarkCase, style: SummaryStyle): string =
3651
(this :> IColumn).GetValue(summary, benchmarkCase)
3752
member this.Id: string = "TEPSColumn"
@@ -46,5 +61,18 @@ type Config() =
4661
inherit ManualConfig()
4762

4863
do
49-
// base.AddColumn [| TEPSColumn() :> IColumn |] |> ignore
50-
base.AddFilter [| NameFilter(fun name -> name.Contains "MathNet" || name.Contains "COO") :> IFilter |] |> ignore
64+
base.AddColumn(
65+
MatrixShapeColumn("RowCount", fun matrix -> matrix.MatrixStructure.RowCount) :> IColumn,
66+
MatrixShapeColumn("ColumnCount", fun matrix -> matrix.MatrixStructure.ColumnCount) :> IColumn,
67+
MatrixShapeColumn("NNZ", fun matrix -> matrix.MatrixStructure.Values.Length) :> IColumn,
68+
TEPSColumn() :> IColumn
69+
)
70+
|> ignore
71+
72+
base.AddFilter(
73+
DisjunctionFilter(
74+
NameFilter(fun name -> name.Contains "MathNet") :> IFilter,
75+
NameFilter(fun name -> name.Contains "COO") :> IFilter
76+
)
77+
)
78+
|> ignore

0 commit comments

Comments
 (0)