Skip to content

Commit 184c488

Browse files
committed
Bitonic sort tests are only for gpu
1 parent 1e643ae commit 184c488

2 files changed

Lines changed: 45 additions & 32 deletions

File tree

tests/GraphBLAS-sharp.Tests/BackendCommonTests/BitonicSortTests.fs

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
module Backend.BitonicSort
22

33
open Expecto
4-
open GraphBLAS.FSharp.Tests
5-
open TypeShape.Core
64
open Expecto.Logging
75
open Expecto.Logging.Message
86
open GraphBLAS.FSharp.Backend.Common
97
open Brahma.FSharp
108
open GraphBLAS.FSharp.Tests.Utils
9+
open OpenCL.Net
1110

1211
let logger = Log.create "BitonicSort.Tests"
1312

1413
let testContext =
15-
let contexts = "" |> avaliableContexts |> Seq.toList
16-
contexts.[0]
17-
18-
let context = testContext.ClContext
19-
printfn "%A" testContext
20-
21-
let makeTest (q: MailboxProcessor<_>) sort (filter: 'a -> bool) (array: ('n * 'n * 'a) []) =
14+
""
15+
|> avaliableContexts
16+
|> Seq.filter
17+
(fun context ->
18+
let mutable e = ErrorCode.Unknown
19+
let device = context.ClContext.ClDevice.Device
20+
21+
let deviceType =
22+
Cl
23+
.GetDeviceInfo(device, DeviceInfo.Type, &e)
24+
.CastTo<DeviceType>()
25+
26+
deviceType = DeviceType.Gpu)
27+
|> Seq.tryHead
28+
29+
let makeTest (context: ClContext) (q: MailboxProcessor<_>) sort (filter: 'a -> bool) (array: ('n * 'n * 'a) []) =
2230
if array.Length > 0 then
2331
let projection (row: 'n) (col: 'n) (v: 'a) = row, col
2432

@@ -77,22 +85,26 @@ let makeTest (q: MailboxProcessor<_>) sort (filter: 'a -> bool) (array: ('n * 'n
7785
vals)
7886
|> Expect.sequenceEqual actualVals expectedVals
7987

80-
let testFixtures<'a when 'a: equality> config wgSize q filter =
88+
let testFixtures<'a when 'a: equality> config wgSize context q filter =
8189
let sort: MailboxProcessor<_> -> ClArray<int> -> ClArray<int> -> ClArray<'a> -> unit =
8290
BitonicSort.sortKeyValuesInplace context wgSize
8391

84-
makeTest q sort filter
92+
makeTest context q sort filter
8593
|> testPropertyWithConfig config (sprintf "Correctness on %A" typeof<'a>)
8694

8795
let tests =
88-
let config = defaultConfig
89-
90-
let wgSize = 128
91-
let q = testContext.Queue
92-
q.Error.Add(fun e -> failwithf "%A" e)
93-
94-
[ testFixtures<int> config wgSize q (fun _ -> true)
95-
testFixtures<float> config wgSize q (System.Double.IsNaN >> not)
96-
testFixtures<byte> config wgSize q (fun _ -> true)
97-
testFixtures<bool> config wgSize q (fun _ -> true) ]
96+
match testContext with
97+
| Some c ->
98+
let context = c.ClContext
99+
let config = defaultConfig
100+
101+
let wgSize = 128
102+
let q = c.Queue
103+
q.Error.Add(fun e -> failwithf "%A" e)
104+
105+
[ testFixtures<int> config wgSize context q (fun _ -> true)
106+
testFixtures<float> config wgSize context q (System.Double.IsNaN >> not)
107+
testFixtures<byte> config wgSize context q (fun _ -> true)
108+
testFixtures<bool> config wgSize context q (fun _ -> true) ]
109+
| _ -> []
98110
|> testList "Backend.Common.BitonicSort tests"

tests/GraphBLAS-sharp.Tests/Program.fs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@ open GraphBLAS.FSharp.IO
1111
let allTests =
1212
testList
1313
"All tests"
14-
[ Backend.BitonicSort.tests //Backend.PrefixSum.tests
15-
// Backend.Convert.tests
16-
// Backend.RemoveDuplicates.tests
17-
// Backend.Copy.tests
18-
// Backend.Replicate.tests
19-
//Backend.EwiseAdd.tests
20-
// Backend.Transpose.tests
21-
//Matrix.GetTuples.tests
22-
//Matrix.Mxv.tests
23-
//Algo.Bfs.tests
24-
]
14+
[ Backend.BitonicSort.tests
15+
Backend.PrefixSum.tests
16+
Backend.Convert.tests
17+
Backend.RemoveDuplicates.tests
18+
Backend.Copy.tests
19+
Backend.Replicate.tests
20+
Backend.EwiseAdd.tests
21+
Backend.Transpose.tests
22+
//Matrix.GetTuples.tests
23+
//Matrix.Mxv.tests
24+
//Algo.Bfs.tests
25+
]
2526
|> testSequenced
2627

2728
[<EntryPoint>]

0 commit comments

Comments
 (0)