Skip to content

Commit 1f273d1

Browse files
committed
add: ClArray.concat tests
1 parent 98d41dd commit 1f273d1

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/GraphBLAS-sharp.Backend/Common/ClArray.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,12 +607,10 @@ module ClArray =
607607
let result =
608608
clContext.CreateClArrayWithSpecificAllocationMode(allocationMode, resultLength)
609609

610-
let assign = assign processor result
611-
612610
// write each array to result
613611
Seq.fold
614-
(fun previousLength array ->
615-
assign previousLength array
612+
(fun previousLength (array: ClArray<_>) ->
613+
assign processor array previousLength result
616614
previousLength + array.Length)
617615
0
618616
sourceArrays

tests/GraphBLAS-sharp.Tests/Common/ClArray/Concat.fs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Concat
33
open Expecto
44
open Brahma.FSharp
55
open GraphBLAS.FSharp.Backend.Common
6-
open GraphBLAS.FSharp.Test
76
open GraphBLAS.FSharp.Tests
87
open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions
98
open GraphBLAS.FSharp.Backend.Objects.ClContext
@@ -12,13 +11,12 @@ let context = Context.defaultContext.ClContext
1211

1312
let processor = Context.defaultContext.Queue
1413

15-
let config =
16-
{ Utils.defaultConfig with
17-
arbitrary = [ typeof<Generators.ArrayAndChunkPositions> ] }
14+
let config = Utils.defaultConfig
1815

19-
let makeTest<'a> isEqual testFun (arrays: 'a [] seq) =
16+
let makeTest<'a> isEqual testFun (arrays: 'a [] []) =
2017

21-
if Seq.length arrays > 0 then
18+
if Seq.length arrays > 0
19+
&& arrays |> Seq.forall (fun array -> array.Length > 0) then
2220

2321
let clArrays = arrays |> Seq.map context.CreateClArray
2422

@@ -35,14 +33,15 @@ let makeTest<'a> isEqual testFun (arrays: 'a [] seq) =
3533

3634
let createTest<'a> isEqual =
3735
ClArray.concat context Utils.defaultWorkGroupSize
38-
|> makeTest isEqual
36+
|> makeTest<'a> isEqual
3937
|> testPropertyWithConfig config $"test on %A{typeof<'a>}"
4038

4139
let tests =
4240
[ createTest<int> (=)
4341

4442
if Utils.isFloat64Available context.ClDevice then
45-
createTest<float> (=)
43+
createTest<float> Utils.floatIsEqual
4644

47-
createTest<float32> (=)
45+
createTest<float32> Utils.float32IsEqual
4846
createTest<bool> (=) ]
47+
|> testList "Concat"

tests/GraphBLAS-sharp.Tests/Program.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,5 @@ open GraphBLAS.FSharp.Tests
9595

9696
[<EntryPoint>]
9797
let main argv =
98-
testList "lol" [ Common.ClArray.Assign.tests ]
98+
testList "lol" [ Common.ClArray.Concat.tests ] |> testSequenced
9999
|> runTestsWithCLIArgs [] argv

0 commit comments

Comments
 (0)