@@ -6,35 +6,19 @@ open Expecto.Logging.Message
66open GraphBLAS.FSharp .Backend .Common
77open Brahma.FSharp
88open GraphBLAS.FSharp .Tests .Utils
9- open OpenCL.Net
109
1110let logger = Log.create " BitonicSort.Tests"
1211
13- let testContext =
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 ) []) =
12+ let makeTest ( context : ClContext ) ( q : MailboxProcessor < _ >) sort ( array : ( 'n * 'n * 'a ) []) =
3013 if array.Length > 0 then
3114 let projection ( row : 'n ) ( col : 'n ) ( v : 'a ) = row, col
3215
33- let rows , cols , vals =
34- array
35- |> Array.distinctBy ((<|||) projection)
36- |> Array.filter ( fun ( _ , _ , v ) -> filter v)
37- |> Array.unzip3
16+ logger.debug (
17+ eventX " Initial size is {size}"
18+ >> setField " size" ( sprintf " %A " array.Length)
19+ )
20+
21+ let rows , cols , vals = Array.unzip3 array
3822
3923 use clRows = context.CreateClArray rows
4024 use clCols = context.CreateClArray cols
@@ -55,56 +39,46 @@ let makeTest (context: ClContext) (q: MailboxProcessor<_>) sort (filter: 'a -> b
5539
5640 rows, cols, vals
5741
58- logger.debug (
59- eventX " Actual are {actualRows}, {actualCols}, {actualVals}"
60- >> setField " actualRows" ( sprintf " %A " actualRows)
61- >> setField " actualCols" ( sprintf " %A " actualCols)
62- >> setField " actualVals" ( sprintf " %A " actualVals)
63- )
64-
6542 let expectedRows , expectedCols , expectedVals =
6643 ( rows, cols, vals)
6744 |||> Array.zip3
6845 |> Array.sortBy ((<|||) projection)
6946 |> Array.unzip3
7047
7148 ( sprintf " Row arrays should be equal. Actual is \n %A , expected \n %A , input is \n %A " actualRows expectedRows rows)
72- |> Expect.sequenceEqual actualRows expectedRows
49+ |> compareArrays (=) actualRows expectedRows
7350
7451 ( sprintf
7552 " Column arrays should be equal. Actual is \n %A , expected \n %A , input is \n %A "
7653 actualCols
7754 expectedCols
7855 cols)
79- |> Expect.sequenceEqual actualCols expectedCols
56+ |> compareArrays (=) actualCols expectedCols
8057
8158 ( sprintf
8259 " Value arrays should be equal. Actual is \n %A , expected \n %A , input is \n %A "
8360 actualVals
8461 expectedVals
8562 vals)
86- |> Expect.sequenceEqual actualVals expectedVals
63+ |> compareArrays (=) actualVals expectedVals
8764
88- let testFixtures < 'a when 'a : equality > config wgSize context q filter =
65+ let testFixtures < 'a when 'a : equality > config wgSize context q =
8966 let sort : MailboxProcessor < _ > -> ClArray < int > -> ClArray < int > -> ClArray < 'a > -> unit =
9067 BitonicSort.sortKeyValuesInplace context wgSize
9168
92- makeTest context q sort filter
69+ makeTest context q sort
9370 |> testPropertyWithConfig config ( sprintf " Correctness on %A " typeof< 'a>)
9471
9572let tests =
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- | _ -> []
73+ let context = defaultContext.ClContext
74+ let config = { defaultConfig with endSize = 1000000 }
75+
76+ let wgSize = 32
77+ let q = defaultContext.Queue
78+ q.Error.Add( fun e -> failwithf " %A " e)
79+
80+ [ testFixtures< int> config wgSize context q
81+ testFixtures< float> config wgSize context q
82+ testFixtures< byte> config wgSize context q
83+ testFixtures< bool> config wgSize context q ]
11084 |> testList " Backend.Common.BitonicSort tests"
0 commit comments