Skip to content

Commit 34c838f

Browse files
committed
refactor: one Vector.elementewise test file
1 parent 639f131 commit 34c838f

9 files changed

Lines changed: 304 additions & 495 deletions

File tree

benchmarks/GraphBLAS-sharp.Benchmarks/VectorEWiseAddGen.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ module VectorGenerator =
179179
type VectorEWiseBenchmarks4FloatSparseWithoutDataTransfer() =
180180

181181
inherit VectorEWiseBenchmarksWithoutDataTransfer<float>(
182-
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.floatSum wgSize),
182+
(fun context wgSize -> Vector.elementwise context ArithmeticOperations.floatSum wgSize),
183183
VectorGenerator.floatPair Sparse)
184184

185185
type VectorEWiseBenchmarks4Int32SparseWithoutDataTransfer() =
186186

187187
inherit VectorEWiseBenchmarksWithoutDataTransfer<int32>(
188-
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.intSum wgSize),
188+
(fun context wgSize -> Vector.elementwise context ArithmeticOperations.intSum wgSize),
189189
VectorGenerator.intPair Sparse)
190190

191191
/// General
@@ -207,13 +207,13 @@ type VectorEWiseGeneralBenchmarks4Int32SparseWithoutDataTransfer() =
207207
type VectorEWiseBenchmarks4FloatSparseWithDataTransfer() =
208208

209209
inherit VectorEWiseBenchmarksWithDataTransfer<float>(
210-
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.floatSum wgSize),
210+
(fun context wgSize -> Vector.elementwise context ArithmeticOperations.floatSum wgSize),
211211
VectorGenerator.floatPair Sparse)
212212

213213
type VectorEWiseBenchmarks4Int32SparseWithDataTransfer() =
214214

215215
inherit VectorEWiseBenchmarksWithDataTransfer<int32>(
216-
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.intSum wgSize),
216+
(fun context wgSize -> Vector.elementwise context ArithmeticOperations.intSum wgSize),
217217
VectorGenerator.intPair Sparse)
218218

219219
/// General with data transfer

src/GraphBLAS-sharp.Backend/Vector/DenseVector/DenseVector.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module DenseVector =
3939

4040
processor.Post(Msg.CreateRunMsg<_, _>(kernel))
4141

42-
let elementWise<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct>
42+
let elementwise<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct>
4343
(clContext: ClContext)
4444
(opAdd: Expr<'a option -> 'b option -> 'c option>)
4545
workGroupSize
@@ -57,7 +57,7 @@ module DenseVector =
5757
resultVector
5858

5959
let elementWiseAtLeastOne clContext op workGroupSize =
60-
elementWise clContext (Convert.atLeastOneToOption op) workGroupSize
60+
elementwise clContext (Convert.atLeastOneToOption op) workGroupSize
6161

6262
let fillSubVectorTo<'a, 'b when 'a: struct and 'b: struct>
6363
(clContext: ClContext)

src/GraphBLAS-sharp.Backend/Vector/SparseVector/SparseVector.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ module SparseVector =
219219
///<param name="clContext">.</param>
220220
///<param name="op">.</param>
221221
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
222-
let elementWise<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct> (clContext: ClContext) op workGroupSize =
222+
let elementwise<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct> (clContext: ClContext) op workGroupSize =
223223

224224
let merge = merge clContext workGroupSize
225225

@@ -253,7 +253,7 @@ module SparseVector =
253253
Size = max leftVector.Size rightVector.Size }
254254

255255
let elementWiseAtLeastOne (clContext: ClContext) opAdd workGroupSize flag =
256-
elementWise clContext (Convert.atLeastOneToOption opAdd) workGroupSize flag
256+
elementwise clContext (Convert.atLeastOneToOption opAdd) workGroupSize flag
257257

258258
let private preparePositionsFillSubVector<'a, 'b when 'a: struct and 'b: struct>
259259
(clContext: ClContext)

src/GraphBLAS-sharp.Backend/Vector/Vector.fs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,13 @@ module Vector =
8282
fun (processor: MailboxProcessor<_>) flag (vector: ClVector<'a>) ->
8383
match vector with
8484
| ClVector.Sparse vector ->
85-
let vector =
86-
{ Context = clContext
87-
Indices = copy processor flag vector.Indices
88-
Values = copyData processor flag vector.Values
89-
Size = vector.Size }
90-
91-
ClVector.Sparse vector
85+
{ Context = clContext
86+
Indices = copy processor flag vector.Indices
87+
Values = copyData processor flag vector.Values
88+
Size = vector.Size }
89+
|> ClVector.Sparse
9290
| ClVector.Dense vector ->
93-
ClVector.Dense
94-
<| copyOptionData processor flag vector
91+
ClVector.Dense <| copyOptionData processor flag vector
9592

9693
let mask = copy
9794

@@ -134,12 +131,12 @@ module Vector =
134131
<| addDense processor flag left right
135132
| _ -> failwith "Vector formats are not matching."
136133

137-
let elementWise (clContext: ClContext) (opAdd: Expr<'a option -> 'b option -> 'c option>) workGroupSize =
134+
let elementwise (clContext: ClContext) (opAdd: Expr<'a option -> 'b option -> 'c option>) workGroupSize =
138135
let addDense =
139-
DenseVector.elementWise clContext opAdd workGroupSize
136+
DenseVector.elementwise clContext opAdd workGroupSize
140137

141138
let addSparse =
142-
SparseVector.elementWise clContext opAdd workGroupSize
139+
SparseVector.elementwise clContext opAdd workGroupSize
143140

144141
fun (processor: MailboxProcessor<_>) flag (leftVector: ClVector<'a>) (rightVector: ClVector<'b>) ->
145142
match leftVector, rightVector with
@@ -161,7 +158,7 @@ module Vector =
161158
SparseVector.elementwiseGeneral clContext opAdd workGroupsSize
162159

163160
let denseEWise =
164-
DenseVector.elementWise clContext opAdd workGroupsSize
161+
DenseVector.elementwise clContext opAdd workGroupsSize
165162

166163
fun (processor: MailboxProcessor<_>) flag (leftVector: ClVector<'a>) (rightVector: ClVector<'b>) ->
167164
match leftVector, rightVector with

tests/GraphBLAS-sharp.Tests/GraphBLAS-sharp.Tests.fsproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@
3232
<Compile Include="Vector/OfList.fs" />
3333
<Compile Include="Vector/Copy.fs" />
3434
<Compile Include="Vector/FillSubVector.fs" />
35-
<Compile Include="Vector\ElementwiseAtLeasOne.fs" />
3635
<Compile Include="Vector/Convert.fs" />
3736
<Compile Include="Vector/Reduce.fs" />
3837
<Compile Include="Vector/Elementwise.fs" />
3938
<Compile Include="Vector/SpMV.fs" />
40-
<Compile Include="Vector\ElementwiseGen.fs" />
4139
<Compile Include="Algorithms/BFS.fs" />
4240
<Compile Include="Matrix/Convert.fs" />
4341
<Compile Include="Matrix/Elementwise.fs" />

tests/GraphBLAS-sharp.Tests/Program.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ let vectorTests =
3535
Vector.OfList.tests
3636
Vector.Copy.tests
3737
Vector.Convert.tests
38-
Vector.ElementwiseAtLeastOne.addTests
39-
Vector.ElementwiseAtLeastOne.mulTests
4038
Vector.Elementwise.addTests
4139
Vector.Elementwise.mulTests
40+
Vector.Elementwise.addAtLeastOneTests
41+
Vector.Elementwise.mulAtLeastOneTests
42+
Vector.Elementwise.addGeneralTests
43+
Vector.Elementwise.mulGeneralTests
44+
Vector.Elementwise.complementedGeneralTests
4245
Vector.FillSubVector.tests
4346
Vector.FillSubVector.complementedTests
4447
Vector.Reduce.tests ]

0 commit comments

Comments
 (0)