Skip to content

Commit 564540d

Browse files
committed
Merge branch 'dev' into map2
2 parents fe2edc3 + b9ef287 commit 564540d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1252
-158
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Benchmark GraphBLAS-sharp
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'docs/benchmarks/**'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
deployments: write
12+
13+
jobs:
14+
build-and-bench-self-hosted:
15+
runs-on: self-hosted
16+
steps:
17+
18+
- name: Check out repository code
19+
uses: actions/checkout@v3
20+
with:
21+
clean: false
22+
23+
- name: OpenCL Info
24+
run: clinfo
25+
26+
- name: Build GraphBLAS-sharp
27+
run: |
28+
dotnet tool restore
29+
dotnet build -c Release
30+
31+
- name: Benchmark
32+
run: python3 benchmarks/GraphBLAS-sharp.Benchmarks/Scripts/Benchmark.py
33+
34+
- name: Charts
35+
uses: rhysd/github-action-benchmark@v1
36+
with:
37+
name: BFS
38+
tool: 'benchmarkdotnet'
39+
output-file-path: BenchmarkDotNet.Artifacts/results/GraphBLAS.FSharp.Benchmarks.BFSBenchmarksWithoutDataTransfer-report-brief.json
40+
# Access token to deploy GitHub Pages branch
41+
github-token: ${{ secrets._GITHUB_TOKEN }}
42+
# Push and deploy GitHub pages branch automatically
43+
auto-push: true
44+
gh-pages-branch: master
45+
benchmark-data-dir-path: docs/benchmarks
46+
skip-fetch-gh-pages: true

.github/workflows/build-on-push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: FAKE Build on Push
22

33
on:
44
push:
5+
paths-ignore:
6+
- 'docs/benchmarks/**'
57
workflow_dispatch:
68

79
jobs:

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksBFS.fs

Lines changed: 143 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,164 @@
1-
namespace GraphBLAS.FSharp.Benchmarks
1+
namespace GraphBLAS.FSharp.Benchmarks
22

3-
open GraphBLAS.FSharp
4-
open GraphBLAS.FSharp.Algorithms
3+
open System.IO
4+
open GraphBLAS.FSharp.Backend.Quotes
5+
open GraphBLAS.FSharp.IO
56
open BenchmarkDotNet.Attributes
67
open BenchmarkDotNet.Configs
78
open BenchmarkDotNet.Columns
8-
open System.IO
9-
open System
10-
open System.Text.RegularExpressions
11-
open Brahma.FSharp.OpenCL
12-
open OpenCL.Net
13-
open GraphBLAS.FSharp.IO
14-
open QuickGraph
9+
open Brahma.FSharp
10+
open GraphBLAS.FSharp.Objects
11+
open GraphBLAS.FSharp.Backend.Objects
12+
open GraphBLAS.FSharp.Backend.Algorithms
13+
open MatrixExtensions
14+
open ArraysExtensions
15+
16+
[<AbstractClass>]
17+
[<IterationCount(10)>]
18+
[<WarmupCount(5)>]
19+
[<Config(typeof<AlgorithmConfig>)>]
20+
type BFSBenchmarks<'matrixT, 'elem when 'matrixT :> IDeviceMemObject and 'elem : struct>(
21+
buildFunToBenchmark,
22+
converter: string -> 'elem,
23+
converterBool,
24+
buildMatrix) =
25+
26+
let mutable funToBenchmark = None
27+
let mutable matrix = Unchecked.defaultof<'matrixT>
28+
let mutable matrixHost = Unchecked.defaultof<_>
29+
30+
let source = 0
31+
32+
member val ResultVector = Unchecked.defaultof<ClArray<'elem option>> with get,set
33+
34+
[<ParamsSource("AvaliableContexts")>]
35+
member val OclContextInfo = Unchecked.defaultof<Utils.BenchmarkContext * int> with get, set
1536

16-
[<Config(typeof<CommonConfig>)>]
17-
type BFSBenchmarks() =
18-
let random = Random()
37+
[<ParamsSource("InputMatricesProvider")>]
38+
member val InputMatrixReader = Unchecked.defaultof<MtxReader> with get, set
1939

20-
let mutable source = 0
40+
member this.OclContext:ClContext = (fst this.OclContextInfo).ClContext
41+
member this.WorkGroupSize = snd this.OclContextInfo
2142

22-
// gb
23-
let mutable matrix = Unchecked.defaultof<Matrix<int>>
43+
member this.Processor =
44+
let p = (fst this.OclContextInfo).Queue
45+
p.Error.Add(fun e -> failwithf "%A" e)
46+
p
2447

25-
// qg
26-
let graph = AdjacencyGraph<int, Edge<int>>(false)
27-
let mutable bfs = Unchecked.defaultof<Algorithms.Search.BreadthFirstSearchAlgorithm<int, Edge<int>>>
48+
static member AvaliableContexts = Utils.avaliableContexts
2849

29-
[<ParamsSource("AvaliableContextsProvider")>]
30-
member val OclContext = Unchecked.defaultof<ClContext> with get, set
31-
member this.Context =
32-
failwith "fix me"
33-
//let (ClContext context) = this.OclContext
34-
//context
50+
static member InputMatricesProviderBuilder pathToConfig =
51+
let datasetFolder = ""
52+
pathToConfig
53+
|> Utils.getMatricesFilenames
54+
|> Seq.map
55+
(fun matrixFilename ->
56+
printfn "%A" matrixFilename
3557

36-
[<ParamsSource("InputMatricesProvider")>]
37-
member val InputMatrixReader = Unchecked.defaultof<MtxReader> with get, set
58+
match Path.GetExtension matrixFilename with
59+
| ".mtx" ->
60+
MtxReader(Utils.getFullPathToMatrix datasetFolder matrixFilename)
61+
| _ -> failwith "Unsupported matrix format")
62+
63+
member this.FunToBenchmark =
64+
match funToBenchmark with
65+
| None ->
66+
let x = buildFunToBenchmark this.OclContext this.WorkGroupSize
67+
funToBenchmark <- Some x
68+
x
69+
| Some x -> x
70+
71+
member this.ReadMatrix (reader:MtxReader) =
72+
let converter =
73+
match reader.Field with
74+
| Pattern -> converterBool
75+
| _ -> converter
76+
77+
reader.ReadMatrix converter
78+
79+
member this.BFS() =
80+
this.ResultVector <- this.FunToBenchmark this.Processor matrix source
81+
82+
member this.ClearInputMatrix() =
83+
(matrix :> IDeviceMemObject).Dispose this.Processor
84+
85+
member this.ClearResult() =
86+
this.ResultVector.Dispose this.Processor
87+
88+
member this.ReadMatrix() =
89+
let matrixReader = this.InputMatrixReader
90+
matrixHost <- this.ReadMatrix matrixReader
91+
92+
member this.LoadMatrixToGPU() =
93+
matrix <- buildMatrix this.OclContext matrixHost
94+
95+
abstract member GlobalSetup : unit -> unit
96+
97+
abstract member IterationCleanup : unit -> unit
98+
99+
abstract member GlobalCleanup : unit -> unit
100+
101+
abstract member Benchmark : unit -> unit
102+
103+
type BFSBenchmarksWithoutDataTransfer() =
104+
105+
inherit BFSBenchmarks<ClMatrix.CSR<int>, int>(
106+
(fun context wgSize -> BFS.singleSource context ArithmeticOperations.intSum ArithmeticOperations.intMul wgSize),
107+
int,
108+
(fun _ -> Utils.nextInt (System.Random())),
109+
Matrix.ToBackendCSR)
110+
111+
static member InputMatricesProvider =
112+
BFSBenchmarks<_,_>.InputMatricesProviderBuilder "BFSBenchmarks.txt"
38113

39114
[<GlobalSetup>]
40-
member this.BuildGraph() =
41-
let inputMatrix = this.InputMatrixReader.ReadMatrix(fun _ -> 1)
42-
43-
failwith "fix me"
44-
(*matrix <-
45-
graphblas {
46-
failwith "fix me"
47-
//return! Matrix.switch CSR inputMatrix
48-
//>>= Matrix.synchronizeAndReturn
49-
}
50-
|> EvalGB.withClContext this.Context
51-
|> EvalGB.runSync
52-
*)
53-
match inputMatrix with
54-
| MatrixCSR csr -> failwith "Not implemented"
55-
| MatrixCOO coo ->
56-
for i = 0 to coo.Values.Length - 1 do
57-
graph.AddVerticesAndEdge(Edge(coo.Rows.[i], coo.Columns.[i])) |> ignore
58-
59-
bfs <- Algorithms.Search.BreadthFirstSearchAlgorithm(graph)
60-
61-
[<IterationSetup>]
62-
member this.SetSource() =
63-
source <- random.Next <| Matrix.rowCount matrix
115+
override this.GlobalSetup() =
116+
this.ReadMatrix ()
117+
this.LoadMatrixToGPU ()
64118

65-
[<Benchmark>]
66-
member this.GraphblasLevelBFS() =
67-
BFS.levelSingleSource matrix source
68-
|> EvalGB.withClContext this.Context
69-
|> EvalGB.runSync
119+
[<IterationCleanup>]
120+
override this.IterationCleanup() =
121+
this.ClearResult()
122+
123+
[<GlobalCleanup>]
124+
override this.GlobalCleanup() =
125+
this.ClearInputMatrix()
70126

71127
[<Benchmark>]
72-
member this.QuickGraphBFS() =
73-
bfs.Compute(source)
128+
override this.Benchmark() =
129+
this.BFS()
130+
this.Processor.PostAndReply(Msg.MsgNotifyMe)
131+
132+
type BFSBenchmarksWithDataTransfer<'matrixT, 'elem when 'matrixT :> IDeviceMemObject and 'elem : struct>(
133+
buildFunToBenchmark,
134+
converter: string -> 'elem,
135+
converterBool,
136+
buildMatrix,
137+
resultToHost) =
138+
139+
inherit BFSBenchmarks<'matrixT, 'elem>(
140+
buildFunToBenchmark,
141+
converter,
142+
converterBool,
143+
buildMatrix)
74144

75-
//TODO fix me
76-
(*[<IterationCleanup>]
77-
member this.ClearBuffers() =
78-
this.Context.Provider.CloseAllBuffers()
145+
[<GlobalSetup>]
146+
override this.GlobalSetup() =
147+
this.ReadMatrix()
79148

80149
[<GlobalCleanup>]
81-
member this.ClearContext() =
82-
let (ClContext context) = this.OclContext
83-
context.Provider.Dispose()
150+
override this.GlobalCleanup() = ()
84151

85-
*)
152+
[<IterationCleanup>]
153+
override this.IterationCleanup() =
154+
this.ClearInputMatrix()
155+
this.ClearResult()
86156

87-
static member AvaliableContextsProvider = Utils.avaliableContexts
157+
[<Benchmark>]
158+
override this.Benchmark() =
159+
this.LoadMatrixToGPU()
160+
this.BFS()
161+
this.Processor.PostAndReply Msg.MsgNotifyMe
162+
let res = resultToHost this.ResultVector this.Processor
163+
this.Processor.PostAndReply Msg.MsgNotifyMe
88164

89-
static member InputMatricesProvider =
90-
"Common.txt"
91-
|> Utils.getMatricesFilenames
92-
|> Seq.map
93-
(fun matrixFilename ->
94-
match Path.GetExtension matrixFilename with
95-
| ".mtx" -> MtxReader(Utils.getFullPathToMatrix "Common" matrixFilename)
96-
| _ -> failwith "Unsupported matrix format"
97-
)

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksEWiseAdd.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ open GraphBLAS.FSharp.Backend.Objects.ClContext
1717
[<AbstractClass>]
1818
[<IterationCount(100)>]
1919
[<WarmupCount(10)>]
20-
[<Config(typeof<Config>)>]
20+
[<Config(typeof<CommonConfig>)>]
2121
type EWiseAddBenchmarks<'matrixT, 'elem when 'matrixT :> IDeviceMemObject and 'elem : struct>(
2222
buildFunToBenchmark,
2323
converter: string -> 'elem,

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksMathNET.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ open Microsoft.FSharp.Core
1111
[<AbstractClass>]
1212
[<IterationCount(100)>]
1313
[<WarmupCount(10)>]
14-
[<Config(typeof<Config>)>]
14+
[<Config(typeof<CommonConfig>)>]
1515
type MathNETBenchmark<'elem when 'elem: struct and 'elem :> System.IEquatable<'elem> and 'elem :> System.IFormattable and 'elem :> System.ValueType and 'elem: (new :
1616
unit -> 'elem)>(converter: string -> 'elem, converterBool) =
1717
do Control.UseNativeMKL()

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksMxm.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ open GraphBLAS.FSharp.Backend.Objects.ClContext
1313
[<AbstractClass>]
1414
[<IterationCount(100)>]
1515
[<WarmupCount(10)>]
16-
[<Config(typeof<Config>)>]
16+
[<Config(typeof<CommonConfig>)>]
1717
type MxmBenchmarks<'elem when 'elem : struct>(
1818
buildFunToBenchmark,
1919
converter: string -> 'elem,
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
arc130.mtx
2-
webbase-1M.mtx
1+
wing.mtx
2+
coAuthorsCiteseer.mtx
3+
hollywood-2009.mtx
4+
roadNet-CA.mtx

benchmarks/GraphBLAS-sharp.Benchmarks/Configs/Common.txt

Whitespace-only changes.

benchmarks/GraphBLAS-sharp.Benchmarks/Configs/EWiseAddBenchmarks4Bool.txt

Whitespace-only changes.

benchmarks/GraphBLAS-sharp.Benchmarks/Configs/EWiseAddBenchmarks4BoolCOO.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)