Skip to content

Commit 2ddbe37

Browse files
committed
refactor: tests
1 parent bae988e commit 2ddbe37

File tree

2 files changed

+122
-17
lines changed
  • benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM
  • tests/GraphBLAS-sharp.Tests

2 files changed

+122
-17
lines changed

benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Expand.fs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Benchmarks<'elem when 'elem : struct>(
3030
let mutable firstMatrixHost = Unchecked.defaultof<_>
3131
let mutable secondMatrixHost = Unchecked.defaultof<_>
3232

33-
member val ResultMatrix = Unchecked.defaultof<ClMatrix<'elem>> with get, set
33+
member val ResultMatrix = Unchecked.defaultof<ClMatrix.COO<'elem> option> with get, set
3434

3535
[<ParamsSource("AvailableContexts")>]
3636
member val OclContextInfo = Unchecked.defaultof<Utils.BenchmarkContext * int> with get, set
@@ -85,7 +85,9 @@ type Benchmarks<'elem when 'elem : struct>(
8585
secondMatrix.Dispose this.Processor
8686

8787
member this.ClearResult() =
88-
this.ResultMatrix.Dispose this.Processor
88+
match this.ResultMatrix with
89+
| Some matrix -> matrix.Dispose this.Processor
90+
| None -> ()
8991

9092
member this.ReadMatrices() =
9193
firstMatrixHost <- this.ReadMatrix this.InputMatrixReader
@@ -134,14 +136,14 @@ module WithoutTransfer =
134136
override this.GlobalCleanup () =
135137
this.ClearInputMatrices()
136138

137-
// type Float32() =
138-
//
139-
// inherit Benchmark<float32>(
140-
// Matrix.SpGeMM.expand (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul),
141-
// float32,
142-
// (fun _ -> Utils.nextSingle (System.Random())),
143-
// (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context)
144-
// )
145-
//
146-
// static member InputMatrixProvider =
147-
// Benchmarks<_>.InputMatrixProviderBuilder "SpGeMM.txt"
139+
type Float32() =
140+
141+
inherit Benchmark<float32>(
142+
Matrix.SpGeMM.expand (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul),
143+
float32,
144+
(fun _ -> Utils.nextSingle (System.Random())),
145+
(fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context)
146+
)
147+
148+
static member InputMatrixProvider =
149+
Benchmarks<_>.InputMatrixProviderBuilder "SpGeMM.txt"

tests/GraphBLAS-sharp.Tests/Program.fs

Lines changed: 107 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,112 @@ open Expecto
22
open GraphBLAS.FSharp.Tests.Backend
33
open GraphBLAS.FSharp.Tests
44

5+
let matrixTests =
6+
testList
7+
"Matrix"
8+
[ Matrix.Convert.tests
9+
Matrix.Map2.allTests
10+
Matrix.Map.allTests
11+
Matrix.Merge.allTests
12+
Matrix.Transpose.tests
13+
Matrix.RowsLengths.tests
14+
Matrix.ByRows.tests
15+
Matrix.ExpandRows.tests
16+
Matrix.SubRows.tests
517

6-
[<EntryPoint>]
7-
let main argv =
8-
Matrix.SpGeMM.Expand.generalTests
18+
Matrix.SpGeMM.Expand.generalTests
19+
Matrix.SpGeMM.Masked.tests ]
20+
|> testSequenced
21+
22+
let commonTests =
23+
let scanTests =
24+
testList
25+
"Scan"
26+
[ Common.Scan.ByKey.sequentialSegmentsTests
27+
Common.Scan.PrefixSum.tests ]
28+
29+
let reduceTests =
30+
testList
31+
"Reduce"
32+
[ Common.Reduce.ByKey.allTests
33+
Common.Reduce.Reduce.tests
34+
Common.Reduce.Sum.tests ]
35+
36+
let clArrayTests =
37+
testList
38+
"ClArray"
39+
[ Common.ClArray.RemoveDuplicates.tests
40+
Common.ClArray.Copy.tests
41+
Common.ClArray.Replicate.tests
42+
Common.ClArray.Exists.tests
43+
Common.ClArray.Map.tests
44+
Common.ClArray.Map2.addTests
45+
Common.ClArray.Map2.mulTests
46+
Common.ClArray.Choose.allTests
47+
Common.ClArray.ChunkBySize.allTests
48+
Common.ClArray.Blit.tests
49+
Common.ClArray.Concat.tests
50+
Common.ClArray.Fill.tests
51+
Common.ClArray.Pairwise.tests
52+
Common.ClArray.UpperBound.tests ]
53+
54+
let sortTests =
55+
testList
56+
"Sort"
57+
[ Common.Sort.Bitonic.tests
58+
Common.Sort.Radix.allTests ]
59+
60+
testList
61+
"Common"
62+
[ Common.Scatter.allTests
63+
Common.Gather.allTests
64+
Common.Merge.tests
65+
clArrayTests
66+
sortTests
67+
reduceTests
68+
scanTests ]
969
|> testSequenced
10-
|> runTestsWithCLIArgs [] argv
70+
71+
let vectorTests =
72+
testList
73+
"Vector"
74+
[ Vector.SpMV.tests
75+
Vector.ZeroCreate.tests
76+
Vector.OfList.tests
77+
Vector.Copy.tests
78+
Vector.Convert.tests
79+
Vector.Map2.allTests
80+
Vector.AssignByMask.tests
81+
Vector.AssignByMask.complementedTests
82+
Vector.Reduce.tests
83+
Vector.Merge.tests ]
84+
|> testSequenced
85+
86+
let algorithmsTests =
87+
testList "Algorithms tests" [ Algorithms.BFS.tests ]
88+
|> testSequenced
89+
90+
let deviceTests =
91+
testList
92+
"Device"
93+
[ matrixTests
94+
commonTests
95+
vectorTests
96+
algorithmsTests ]
97+
|> testSequenced
98+
99+
let hostTests =
100+
testList
101+
"Host"
102+
[ Host.Matrix.FromArray2D.tests
103+
Host.Matrix.Convert.tests
104+
Host.IO.MtxReader.test ]
105+
|> testSequenced
106+
107+
[<Tests>]
108+
let allTests =
109+
testList "All" [ deviceTests; hostTests ]
110+
|> testSequenced
111+
112+
[<EntryPoint>]
113+
let main argv = allTests |> runTestsWithCLIArgs [] argv

0 commit comments

Comments
 (0)