Skip to content

Commit 97df0e4

Browse files
committed
refactor: flags in tests
1 parent f20a75b commit 97df0e4

12 files changed

Lines changed: 133 additions & 122 deletions

File tree

src/GraphBLAS-sharp.Backend/Predefined/PrefixSum.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ module internal PrefixSum =
2121

2222
scan processor inputArray totalSum 0
2323

24-
let standardInclude (clContext: ClContext) workGroupSize =
24+
let standardInclude (clContext: ClContext) workGroupSize flag =
2525

2626
let scan =
27-
ClArray.prefixSumInclude <@ (+) @> clContext workGroupSize
27+
ClArray.prefixSumInclude <@ (+) @> clContext workGroupSize flag
2828

2929
fun (processor: MailboxProcessor<_>) (inputArray: ClArray<int>) (totalSum: ClCell<int>) ->
3030

3131
scan processor inputArray totalSum 0
3232

33-
let standardExclude (clContext: ClContext) workGroupSize =
33+
let standardExclude (clContext: ClContext) workGroupSize flag =
3434

3535
let scan =
36-
ClArray.prefixSumExclude <@ (+) @> clContext workGroupSize
36+
ClArray.prefixSumExclude <@ (+) @> clContext workGroupSize flag
3737

3838
fun (processor: MailboxProcessor<_>) (inputArray: ClArray<int>) (totalSum: ClCell<int>) ->
3939

tests/GraphBLAS-sharp.Tests/Matrix/Convert.fs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ open GraphBLAS.FSharp.Objects
1010
open GraphBLAS.FSharp.Backend.Matrix
1111
open GraphBLAS.FSharp.Backend.Objects
1212
open GraphBLAS.FSharp.Objects.MatrixExtensions
13+
open GraphBLAS.FSharp.Backend.Objects.ClContext
1314

1415
let logger = Log.create "Convert.Tests"
1516

@@ -50,15 +51,15 @@ let testFixtures formatTo =
5051

5152
match formatTo with
5253
| COO ->
53-
[ let convertFun = Matrix.toCOO context wgSize
54+
[ let convertFun = Matrix.toCOO context wgSize CPUInterop
5455

5556
listOfUnionCases<MatrixFormat>
5657
|> List.map
5758
(fun formatFrom ->
5859
makeTest context q formatFrom formatTo convertFun ((=) 0)
5960
|> testPropertyWithConfig config (getCorrectnessTestName "int" formatFrom))
6061

61-
let convertFun = Matrix.toCOO context wgSize
62+
let convertFun = Matrix.toCOO context wgSize CPUInterop
6263

6364
listOfUnionCases<MatrixFormat>
6465
|> List.map
@@ -67,15 +68,15 @@ let testFixtures formatTo =
6768
|> testPropertyWithConfig config (getCorrectnessTestName "bool" formatFrom)) ]
6869
|> List.concat
6970
| CSR ->
70-
[ let convertFun = Matrix.toCSR context wgSize
71+
[ let convertFun = Matrix.toCSR context wgSize CPUInterop
7172

7273
listOfUnionCases<MatrixFormat>
7374
|> List.map
7475
(fun formatFrom ->
7576
makeTest context q formatFrom formatTo convertFun ((=) 0)
7677
|> testPropertyWithConfig config (getCorrectnessTestName "int" formatFrom))
7778

78-
let convertFun = Matrix.toCSR context wgSize
79+
let convertFun = Matrix.toCSR context wgSize CPUInterop
7980

8081
listOfUnionCases<MatrixFormat>
8182
|> List.map
@@ -84,15 +85,15 @@ let testFixtures formatTo =
8485
|> testPropertyWithConfig config (getCorrectnessTestName "bool" formatFrom)) ]
8586
|> List.concat
8687
| CSC ->
87-
[ let convertFun = Matrix.toCSC context wgSize
88+
[ let convertFun = Matrix.toCSC context wgSize CPUInterop
8889

8990
listOfUnionCases<MatrixFormat>
9091
|> List.map
9192
(fun formatFrom ->
9293
makeTest context q formatFrom formatTo convertFun ((=) 0)
9394
|> testPropertyWithConfig config (getCorrectnessTestName "int" formatFrom))
9495

95-
let convertFun = Matrix.toCSC context wgSize
96+
let convertFun = Matrix.toCSC context wgSize CPUInterop
9697

9798
listOfUnionCases<MatrixFormat>
9899
|> List.map

tests/GraphBLAS-sharp.Tests/Matrix/Elementwise.fs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ open GraphBLAS.FSharp.Objects
1414
open GraphBLAS.FSharp.Backend.Objects
1515
open GraphBLAS.FSharp.Tests.Backend
1616
open GraphBLAS.FSharp.Objects.MatrixExtensions
17+
open GraphBLAS.FSharp.Backend.Objects.ClContext
1718

1819
let logger = Log.create "Elementwise.Tests"
1920

@@ -102,36 +103,36 @@ let testFixturesEWiseAdd case =
102103
q.Error.Add(fun e -> failwithf "%A" e)
103104

104105
let boolAdd =
105-
Matrix.elementwise context ArithmeticOperations.boolSum wgSize
106+
Matrix.elementwise context ArithmeticOperations.boolSum wgSize CPUInterop
106107

107-
let boolToCOO = Matrix.toCOO context wgSize
108+
let boolToCOO = Matrix.toCOO context wgSize CPUInterop
108109

109110
case
110111
|> correctnessGenericTest false (||) boolAdd boolToCOO (=) q
111112
|> testPropertyWithConfig config (getCorrectnessTestName "bool")
112113

113114
let intAdd =
114-
Matrix.elementwise context ArithmeticOperations.intSum wgSize
115+
Matrix.elementwise context ArithmeticOperations.intSum wgSize CPUInterop
115116

116-
let intToCOO = Matrix.toCOO context wgSize
117+
let intToCOO = Matrix.toCOO context wgSize CPUInterop
117118

118119
case
119120
|> correctnessGenericTest 0 (+) intAdd intToCOO (=) q
120121
|> testPropertyWithConfig config (getCorrectnessTestName "int")
121122

122123
let floatAdd =
123-
Matrix.elementwise context ArithmeticOperations.floatSum wgSize
124+
Matrix.elementwise context ArithmeticOperations.floatSum wgSize CPUInterop
124125

125-
let floatToCOO = Matrix.toCOO context wgSize
126+
let floatToCOO = Matrix.toCOO context wgSize CPUInterop
126127

127128
case
128129
|> correctnessGenericTest 0.0 (+) floatAdd floatToCOO (fun x y -> abs (x - y) < Accuracy.medium.absolute) q
129130
|> testPropertyWithConfig config (getCorrectnessTestName "float")
130131

131132
let byteAdd =
132-
Matrix.elementwise context ArithmeticOperations.byteSum wgSize
133+
Matrix.elementwise context ArithmeticOperations.byteSum wgSize CPUInterop
133134

134-
let byteToCOO = Matrix.toCOO context wgSize
135+
let byteToCOO = Matrix.toCOO context wgSize CPUInterop
135136

136137
case
137138
|> correctnessGenericTest 0uy (+) byteAdd byteToCOO (=) q
@@ -152,36 +153,36 @@ let testFixturesEWiseAddAtLeastOne case =
152153
q.Error.Add(fun e -> failwithf "%A" e)
153154

154155
let boolAdd =
155-
Matrix.elementwiseAtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize
156+
Matrix.elementwiseAtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize CPUInterop
156157

157-
let boolToCOO = Matrix.toCOO context wgSize
158+
let boolToCOO = Matrix.toCOO context wgSize CPUInterop
158159

159160
case
160161
|> correctnessGenericTest false (||) boolAdd boolToCOO (=) q
161162
|> testPropertyWithConfig config (getCorrectnessTestName "bool")
162163

163164
let intAdd =
164-
Matrix.elementwiseAtLeastOne context ArithmeticOperations.intSumAtLeastOne wgSize
165+
Matrix.elementwiseAtLeastOne context ArithmeticOperations.intSumAtLeastOne wgSize CPUInterop
165166

166-
let intToCOO = Matrix.toCOO context wgSize
167+
let intToCOO = Matrix.toCOO context wgSize CPUInterop
167168

168169
case
169170
|> correctnessGenericTest 0 (+) intAdd intToCOO (=) q
170171
|> testPropertyWithConfig config (getCorrectnessTestName "int")
171172

172173
let floatAdd =
173-
Matrix.elementwiseAtLeastOne context ArithmeticOperations.floatSumAtLeastOne wgSize
174+
Matrix.elementwiseAtLeastOne context ArithmeticOperations.floatSumAtLeastOne wgSize CPUInterop
174175

175-
let floatToCOO = Matrix.toCOO context wgSize
176+
let floatToCOO = Matrix.toCOO context wgSize CPUInterop
176177

177178
case
178179
|> correctnessGenericTest 0.0 (+) floatAdd floatToCOO (fun x y -> abs (x - y) < Accuracy.medium.absolute) q
179180
|> testPropertyWithConfig config (getCorrectnessTestName "float")
180181

181182
let byteAdd =
182-
Matrix.elementwiseAtLeastOne context ArithmeticOperations.byteSumAtLeastOne wgSize
183+
Matrix.elementwiseAtLeastOne context ArithmeticOperations.byteSumAtLeastOne wgSize CPUInterop
183184

184-
let byteToCOO = Matrix.toCOO context wgSize
185+
let byteToCOO = Matrix.toCOO context wgSize CPUInterop
185186

186187
case
187188
|> correctnessGenericTest 0uy (+) byteAdd byteToCOO (=) q
@@ -202,36 +203,36 @@ let testFixturesEWiseAddAtLeastOneToCOO case =
202203
q.Error.Add(fun e -> failwithf "%A" e)
203204

204205
let boolAdd =
205-
Matrix.elementwiseAtLeastOneToCOO context ArithmeticOperations.boolSumAtLeastOne wgSize
206+
Matrix.elementwiseAtLeastOneToCOO context ArithmeticOperations.boolSumAtLeastOne wgSize CPUInterop
206207

207-
let boolToCOO = Matrix.toCOO context wgSize
208+
let boolToCOO = Matrix.toCOO context wgSize CPUInterop
208209

209210
case
210211
|> correctnessGenericTest false (||) boolAdd boolToCOO (=) q
211212
|> testPropertyWithConfig config (getCorrectnessTestName "bool")
212213

213214
let intAdd =
214-
Matrix.elementwiseAtLeastOneToCOO context ArithmeticOperations.intSumAtLeastOne wgSize
215+
Matrix.elementwiseAtLeastOneToCOO context ArithmeticOperations.intSumAtLeastOne wgSize CPUInterop
215216

216-
let intToCOO = Matrix.toCOO context wgSize
217+
let intToCOO = Matrix.toCOO context wgSize CPUInterop
217218

218219
case
219220
|> correctnessGenericTest 0 (+) intAdd intToCOO (=) q
220221
|> testPropertyWithConfig config (getCorrectnessTestName "int")
221222

222223
let floatAdd =
223-
Matrix.elementwiseAtLeastOneToCOO context ArithmeticOperations.floatSumAtLeastOne wgSize
224+
Matrix.elementwiseAtLeastOneToCOO context ArithmeticOperations.floatSumAtLeastOne wgSize CPUInterop
224225

225-
let floatToCOO = Matrix.toCOO context wgSize
226+
let floatToCOO = Matrix.toCOO context wgSize CPUInterop
226227

227228
case
228229
|> correctnessGenericTest 0.0 (+) floatAdd floatToCOO (fun x y -> abs (x - y) < Accuracy.medium.absolute) q
229230
|> testPropertyWithConfig config (getCorrectnessTestName "float")
230231

231232
let byteAdd =
232-
Matrix.elementwiseAtLeastOneToCOO context ArithmeticOperations.byteSumAtLeastOne wgSize
233+
Matrix.elementwiseAtLeastOneToCOO context ArithmeticOperations.byteSumAtLeastOne wgSize CPUInterop
233234

234-
let byteToCOO = Matrix.toCOO context wgSize
235+
let byteToCOO = Matrix.toCOO context wgSize CPUInterop
235236

236237
case
237238
|> correctnessGenericTest 0uy (+) byteAdd byteToCOO (=) q
@@ -252,36 +253,36 @@ let testFixturesEWiseMulAtLeastOne case =
252253
q.Error.Add(fun e -> failwithf "%A" e)
253254

254255
let boolMul =
255-
Matrix.elementwiseAtLeastOne context ArithmeticOperations.boolMulAtLeastOne wgSize
256+
Matrix.elementwiseAtLeastOne context ArithmeticOperations.boolMulAtLeastOne wgSize CPUInterop
256257

257-
let boolToCOO = Matrix.toCOO context wgSize
258+
let boolToCOO = Matrix.toCOO context wgSize CPUInterop
258259

259260
case
260261
|> correctnessGenericTest false (&&) boolMul boolToCOO (=) q
261262
|> testPropertyWithConfig config (getCorrectnessTestName "bool")
262263

263264
let intAdd =
264-
Matrix.elementwiseAtLeastOne context ArithmeticOperations.intMulAtLeastOne wgSize
265+
Matrix.elementwiseAtLeastOne context ArithmeticOperations.intMulAtLeastOne wgSize CPUInterop
265266

266-
let intToCOO = Matrix.toCOO context wgSize
267+
let intToCOO = Matrix.toCOO context wgSize CPUInterop
267268

268269
case
269270
|> correctnessGenericTest 0 (*) intAdd intToCOO (=) q
270271
|> testPropertyWithConfig config (getCorrectnessTestName "int")
271272

272273
let floatAdd =
273-
Matrix.elementwiseAtLeastOne context ArithmeticOperations.floatMulAtLeastOne wgSize
274+
Matrix.elementwiseAtLeastOne context ArithmeticOperations.floatMulAtLeastOne wgSize CPUInterop
274275

275-
let floatToCOO = Matrix.toCOO context wgSize
276+
let floatToCOO = Matrix.toCOO context wgSize CPUInterop
276277

277278
case
278279
|> correctnessGenericTest 0.0 (*) floatAdd floatToCOO (fun x y -> abs (x - y) < Accuracy.medium.absolute) q
279280
|> testPropertyWithConfig config (getCorrectnessTestName "float")
280281

281282
let byteAdd =
282-
Matrix.elementwiseAtLeastOne context ArithmeticOperations.byteMulAtLeastOne wgSize
283+
Matrix.elementwiseAtLeastOne context ArithmeticOperations.byteMulAtLeastOne wgSize CPUInterop
283284

284-
let byteToCOO = Matrix.toCOO context wgSize
285+
let byteToCOO = Matrix.toCOO context wgSize CPUInterop
285286

286287
case
287288
|> correctnessGenericTest 0uy (*) byteAdd byteToCOO (=) q

tests/GraphBLAS-sharp.Tests/Matrix/Transpose.fs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ open GraphBLAS.FSharp.Tests.TestCases
1010
open GraphBLAS.FSharp.Backend.Matrix
1111
open GraphBLAS.FSharp.Backend.Objects
1212
open GraphBLAS.FSharp.Objects.MatrixExtensions
13+
open GraphBLAS.FSharp.Backend.Objects.ClContext
1314

1415
let logger = Log.create "Transpose.Tests"
1516

@@ -134,7 +135,7 @@ let testFixtures case =
134135
let q = case.TestContext.Queue
135136
q.Error.Add(fun e -> failwithf "%A" e)
136137

137-
[ let transposeFun = Matrix.transpose context wgSize
138+
[ let transposeFun = Matrix.transpose context wgSize CPUInterop
138139

139140
case
140141
|> makeTestRegular context q transposeFun (=) 0
@@ -145,7 +146,7 @@ let testFixtures case =
145146
|> testPropertyWithConfig config (getCorrectnessTestName "int (twice transpose)")
146147

147148

148-
let transposeFun = Matrix.transpose context wgSize
149+
let transposeFun = Matrix.transpose context wgSize CPUInterop
149150

150151
case
151152
|> makeTestRegular context q transposeFun areEqualFloat 0.0
@@ -155,7 +156,7 @@ let testFixtures case =
155156
|> makeTestTwiceTranspose context q transposeFun areEqualFloat 0.0
156157
|> testPropertyWithConfig config (getCorrectnessTestName "float (twice transpose)")
157158

158-
let transposeFun = Matrix.transpose context wgSize
159+
let transposeFun = Matrix.transpose context wgSize CPUInterop
159160

160161
case
161162
|> makeTestRegular context q transposeFun (=) 0uy
@@ -165,7 +166,7 @@ let testFixtures case =
165166
|> makeTestTwiceTranspose context q transposeFun (=) 0uy
166167
|> testPropertyWithConfig config (getCorrectnessTestName "byte (twice transpose)")
167168

168-
let transposeFun = Matrix.transpose context wgSize
169+
let transposeFun = Matrix.transpose context wgSize CPUInterop
169170

170171
case
171172
|> makeTestRegular context q transposeFun (=) false

tests/GraphBLAS-sharp.Tests/Vector/Convert.fs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ open GraphBLAS.FSharp.Backend.Objects
1111
open GraphBLAS.FSharp.Backend.Vector
1212
open GraphBLAS.FSharp.Objects
1313
open GraphBLAS.FSharp.Objects.ClVectorExtensions
14+
open GraphBLAS.FSharp.Backend.Objects.ClContext
1415

1516
let logger =
1617
Log.create "Backend.Vector.Convert.Tests"
@@ -62,15 +63,15 @@ let testFixtures case =
6263

6364
match case.Format with
6465
| Sparse ->
65-
[ let convertFun = Vector.toSparse context wgSize
66+
[ let convertFun = Vector.toSparse context wgSize CPUInterop
6667

6768
listOfUnionCases<VectorFormat>
6869
|> List.map
6970
(fun formatFrom ->
7071
makeTest formatFrom convertFun ((=) 0) case
7172
|> testPropertyWithConfig config (getCorrectnessTestName "int" formatFrom))
7273

73-
let convertFun = Vector.toSparse context wgSize
74+
let convertFun = Vector.toSparse context wgSize CPUInterop
7475

7576
listOfUnionCases<VectorFormat>
7677
|> List.map
@@ -79,15 +80,15 @@ let testFixtures case =
7980
|> testPropertyWithConfig config (getCorrectnessTestName "bool" formatFrom)) ]
8081
|> List.concat
8182
| Dense ->
82-
[ let convertFun = Vector.toDense context wgSize
83+
[ let convertFun = Vector.toDense context wgSize CPUInterop
8384

8485
listOfUnionCases<VectorFormat>
8586
|> List.map
8687
(fun formatFrom ->
8788
makeTest formatFrom convertFun ((=) 0) case
8889
|> testPropertyWithConfig config (getCorrectnessTestName "int" formatFrom))
8990

90-
let convertFun = Vector.toDense context wgSize
91+
let convertFun = Vector.toDense context wgSize CPUInterop
9192

9293
listOfUnionCases<VectorFormat>
9394
|> List.map

0 commit comments

Comments
 (0)