Skip to content

Commit 1d45950

Browse files
committed
refactor: README
1 parent b25bc97 commit 1d45950

17 files changed

Lines changed: 648 additions & 490 deletions

File tree

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,32 @@ GraphBLAS# is a GPGPU-based [GraphBLAS](https://graphblas.org/)-like API impleme
2525

2626
### Operations
2727
- **Matrix-Matrix**
28-
- [x] COO-COO `map2`
2928
- [x] CSR-CSR `map2`
29+
- [x] CSR-CSR `map2AtLeastOne`
30+
- [x] COO-COO `map2`
31+
- [x] COO-COO `map2AtLeastOne`
3032
- [x] CSR-CSR multiplication
3133
- **Vector-Matrix**
3234
- [x] Dense-CSR multiplication
33-
- [ ] COO-CSR multiplication
35+
- [ ] Sparse-CSR multiplication
3436
- **Vector-Vector**
35-
- [x] Dense-Dense element-wise
36-
- [x] Sparse-Sparse element-wise
37+
- [x] Dense-Dense `map2`
38+
- [x] Dense-Dense `map2AtLeastOne`
39+
- [x] Sparse-Sparse `map2`
40+
- [x] Sparse-Sparse `map2AtLeastOne`
3741
- [ ] ...
3842
- **Matrix**
43+
- [x] `copy`
3944
- [x] `map`
4045
- [x] COO transpose
4146
- [x] CSR transpose
42-
- [ ] `iter`
47+
- [x] CSC transpose
4348
- [ ] ...
4449
- **Vector**
45-
- [x] `map`
46-
- [ ] `iter`
47-
- [ ] `filter`
48-
- [ ] `contains`
50+
- [x] `zeroCreate`
51+
- [x] `ofList`
52+
- [x] `copy`
53+
- [x] `reduce`
4954
- [ ] ...
5055

5156
### Graph Analysis Algorithms

benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/BFS.fs renamed to benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/Benchmark.fs

Lines changed: 77 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace GraphBLAS.FSharp.Benchmarks.Algorithms
1+
namespace GraphBLAS.FSharp.Benchmarks.Algorithms.BFS
22

33
open System.IO
44
open 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

benchmarks/GraphBLAS-sharp.Benchmarks/GraphBLAS-sharp.Benchmarks.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
<Compile Include="Configs.fs" />
2222
<!--Compile Include="BenchmarksTranspose.fs" /-->
2323
<Compile Include="Matrix\SpGeMM\Masked.fs" />
24+
<Compile Include="Matrix\SpGeMM\Expand.fs" />
2425
<Compile Include="Matrix\Map2\Map2.fs" />
2526
<Compile Include="Matrix\Map2\MathNET.fs" />
2627
<Compile Include="Vector\Map2.fs" />
27-
<Compile Include="Algorithms\BFS.fs" />
28+
<Compile Include="Algorithms\Benchmark.fs" />
2829
<Compile Include="Program.fs" />
2930
</ItemGroup>
3031
<Import Project="..\..\.paket\Paket.Restore.targets" />

benchmarks/GraphBLAS-sharp.Benchmarks/Helpers.fs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module Utils =
3838
datasetsFolder
3939
matrixFilename |]
4040

41-
let avaliableContexts =
41+
let availableContexts =
4242
let pathToConfig =
4343
Path.Combine [| __SOURCE_DIRECTORY__
4444
"Configs"
@@ -97,18 +97,6 @@ module Utils =
9797
.ToString()
9898
|> Platform.Custom
9999

100-
let deviceType =
101-
Cl
102-
.GetDeviceInfo(device, DeviceInfo.Type, &e)
103-
.CastTo<DeviceType>()
104-
105-
let _ =
106-
match deviceType with
107-
| DeviceType.Cpu -> ClDeviceType.Cpu
108-
| DeviceType.Gpu -> ClDeviceType.Gpu
109-
| DeviceType.Default -> ClDeviceType.Default
110-
| _ -> failwith "Unsupported"
111-
112100
let device =
113101
ClDevice.GetFirstAppropriateDevice(clPlatform)
114102

@@ -142,34 +130,6 @@ module Utils =
142130
let nextInt (random: System.Random) =
143131
random.Next()
144132

145-
module Operations =
146-
let inline add () = <@ fun x y -> Some(x + y) @>
147-
148-
let addWithFilter = <@ fun x y ->
149-
let res = x + y
150-
if abs res < 1e-8f then None else Some res
151-
@>
152-
153-
let inline mult () = <@ fun x y -> Some <|x * y @>
154-
155-
let logicalOr = <@ fun x y ->
156-
let mutable res = None
157-
158-
match x, y with
159-
| false, false -> res <- None
160-
| _ -> res <- Some true
161-
162-
res @>
163-
164-
let logicalAnd = <@ fun x y ->
165-
let mutable res = None
166-
167-
match x, y with
168-
| true, true -> res <- Some true
169-
| _ -> res <- None
170-
171-
res @>
172-
173133
module VectorGenerator =
174134
let private pairOfVectorsOfEqualSize (valuesGenerator: Gen<'a>) createVector =
175135
gen {

0 commit comments

Comments
 (0)