1- namespace GraphBLAS.FSharp.Benchmarks.Algorithms
1+ namespace GraphBLAS.FSharp.Benchmarks.Algorithms.BFS
22
33open System.IO
44open BenchmarkDotNet.Attributes
@@ -16,7 +16,7 @@ open GraphBLAS.FSharp.Backend.Objects
1616[<IterationCount( 100 ) >]
1717[<WarmupCount( 10 ) >]
1818[<Config( typeof< Configs.Matrix>) >]
19- type BFS < 'elem when 'elem : struct >(
19+ type Benchmarks < 'elem when 'elem : struct >(
2020 buildFunToBenchmark,
2121 converter: string -> 'elem,
2222 binaryConverter,
@@ -43,7 +43,7 @@ type BFS<'elem when 'elem : struct>(
4343 p.Error.Add( fun e -> failwithf " %A " e)
4444 p
4545
46- static member AvailableContexts = Utils.avaliableContexts
46+ static member AvailableContexts = Utils.availableContexts
4747
4848 static member InputMatrixProviderBuilder pathToConfig =
4949 let datasetFolder = " BFS"
@@ -92,87 +92,89 @@ type BFS<'elem when 'elem : struct>(
9292
9393 abstract member Benchmark : unit -> unit
9494
95- type BFSBenchmarksWithoutDataTransfer < 'elem when 'elem : struct >(
96- buildFunToBenchmark,
97- converter: string -> 'elem,
98- boolConverter,
99- vertex) =
100-
101- inherit BFS< 'elem>(
102- buildFunToBenchmark,
103- converter,
104- boolConverter,
105- vertex)
106-
107- [<GlobalSetup>]
108- override this.GlobalSetup () =
109- this.ReadMatrix()
110- this.LoadMatrixToGPU()
111-
112- [<IterationCleanup>]
113- override this.IterationCleanup () =
114- this.ClearResult()
115-
116- [<GlobalCleanup>]
117- override this.GlobalCleanup () =
118- this.ClearInputMatrix()
119-
120- [<Benchmark>]
121- override this.Benchmark () =
122- this.BFS()
123- this.Processor.PostAndReply Msg.MsgNotifyMe
124-
125- type BFSBenchmarksWithTransfer < 'elem when 'elem : struct >(
126- buildFunToBenchmark,
127- converter: string -> 'elem,
128- boolConverter,
129- vertex) =
130-
131- inherit BFS< 'elem>(
95+ module WithoutTransfer =
96+ type Benchmark < 'elem when 'elem : struct >(
13297 buildFunToBenchmark,
133- converter,
98+ converter: string -> 'elem ,
13499 boolConverter,
135- vertex)
136-
137- [<GlobalSetup>]
138- override this.GlobalSetup () =
139- this.ReadMatrix()
100+ vertex) =
140101
141- [<GlobalCleanup>]
142- override this.GlobalCleanup () =
143- this.ClearResult()
102+ inherit Benchmarks< 'elem>(
103+ buildFunToBenchmark,
104+ converter,
105+ boolConverter,
106+ vertex)
144107
145- [<IterationCleanup >]
146- override this.IterationCleanup () =
147- this.ClearInputMatrix ()
148- this.ClearResult ()
108+ [<GlobalSetup >]
109+ override this.GlobalSetup () =
110+ this.ReadMatrix ()
111+ this.LoadMatrixToGPU ()
149112
150- [<Benchmark>]
151- override this.Benchmark () =
152- this.LoadMatrixToGPU()
153- this.BFS()
154- this.ResultLevels.ToHost this.Processor |> ignore
155- this.Processor.PostAndReply Msg.MsgNotifyMe
113+ [<IterationCleanup>]
114+ override this.IterationCleanup () =
115+ this.ClearResult()
156116
157- type BFSIntWithoutTransferBenchmark () =
117+ [<GlobalCleanup>]
118+ override this.GlobalCleanup () =
119+ this.ClearInputMatrix()
158120
159- inherit BFSBenchmarksWithoutDataTransfer< int>(
160- ( fun context -> singleSource context ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption),
161- int32,
162- ( fun _ -> Utils.nextInt ( System.Random())),
163- 0 )
121+ [<Benchmark>]
122+ override this.Benchmark () =
123+ this.BFS()
124+ this.Processor.PostAndReply Msg.MsgNotifyMe
164125
165- static member InputMatrixProvider =
166- BFS<_>. InputMatrixProviderBuilder " BFSBenchmarks.txt"
126+ type Int () =
167127
168- type BFSIntWithTransferBenchmark () =
128+ inherit Benchmark< int>(
129+ ( fun context -> singleSource context ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption),
130+ int32,
131+ ( fun _ -> Utils.nextInt ( System.Random())),
132+ 0 )
169133
170- inherit BFSBenchmarksWithTransfer< int>(
171- ( fun context -> singleSource context ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption),
172- int32,
173- ( fun _ -> Utils.nextInt ( System.Random())),
174- 0 )
134+ static member InputMatrixProvider =
135+ Benchmark<_>. InputMatrixProviderBuilder " BFSBenchmarks.txt"
175136
176- static member InputMatrixProvider =
177- BFS<_>. InputMatrixProviderBuilder " BFSBenchmarks.txt"
137+ module WithTransfer =
138+ type Benchmark < 'elem when 'elem : struct >(
139+ buildFunToBenchmark,
140+ converter: string -> 'elem,
141+ boolConverter,
142+ vertex) =
143+
144+ inherit Benchmarks< 'elem>(
145+ buildFunToBenchmark,
146+ converter,
147+ boolConverter,
148+ vertex)
149+
150+ [<GlobalSetup>]
151+ override this.GlobalSetup () =
152+ this.ReadMatrix()
153+
154+ [<GlobalCleanup>]
155+ override this.GlobalCleanup () =
156+ this.ClearResult()
157+
158+ [<IterationCleanup>]
159+ override this.IterationCleanup () =
160+ this.ClearInputMatrix()
161+ this.ClearResult()
162+
163+ [<Benchmark>]
164+ override this.Benchmark () =
165+ this.LoadMatrixToGPU()
166+ this.BFS()
167+ this.ResultLevels.ToHost this.Processor |> ignore
168+ this.Processor.PostAndReply Msg.MsgNotifyMe
169+
170+ type Int () =
171+
172+ inherit Benchmark< int>(
173+ ( fun context -> singleSource context ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption),
174+ int32,
175+ ( fun _ -> Utils.nextInt ( System.Random())),
176+ 0 )
177+
178+ static member InputMatrixProvider =
179+ Benchmark<_>. InputMatrixProviderBuilder " BFSBenchmarks.txt"
178180
0 commit comments