Skip to content

Commit 0af7b00

Browse files
committed
refactor: Backend.Matrix -> ClMatrix
1 parent 4efaca5 commit 0af7b00

29 files changed

Lines changed: 134 additions & 135 deletions

File tree

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksEWiseAdd.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ type EWiseAddBenchmarksWithDataTransfer<'matrixT, 'elem when 'matrixT :> Backend
195195
this.Processor.PostAndReply Msg.MsgNotifyMe
196196

197197
module M =
198-
let resultToHostCOO (resultMatrix:Backend.COOMatrix<'a>) (procesor:MailboxProcessor<_>) =
198+
let resultToHostCOO (resultMatrix:Backend.ClCOOMatrix<'a>) (procesor:MailboxProcessor<_>) =
199199
let cols =
200200
let a = Array.zeroCreate resultMatrix.ColumnCount
201201
procesor.Post(Msg.CreateToHostMsg<_>(resultMatrix.Columns,a))
@@ -219,7 +219,7 @@ module M =
219219

220220
type EWiseAddBenchmarks4Float32COOWithoutDataTransfer() =
221221

222-
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.COOMatrix<float32>,float32>(
222+
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.ClCOOMatrix<float32>,float32>(
223223
(fun context wgSize -> Backend.COOMatrix.elementwise context Backend.Common.StandardOperations.float32Sum wgSize),
224224
float32,
225225
(fun _ -> Utils.nextSingle (System.Random())),
@@ -231,7 +231,7 @@ type EWiseAddBenchmarks4Float32COOWithoutDataTransfer() =
231231

232232
type EWiseAddBenchmarks4Float32COOWithDataTransfer() =
233233

234-
inherit EWiseAddBenchmarksWithDataTransfer<Backend.COOMatrix<float32>,float32>(
234+
inherit EWiseAddBenchmarksWithDataTransfer<Backend.ClCOOMatrix<float32>,float32>(
235235
(fun context wgSize -> Backend.COOMatrix.elementwise context Backend.Common.StandardOperations.float32Sum wgSize),
236236
float32,
237237
(fun _ -> Utils.nextSingle (System.Random())),
@@ -245,7 +245,7 @@ type EWiseAddBenchmarks4Float32COOWithDataTransfer() =
245245

246246
type EWiseAddBenchmarks4BoolCOOWithoutDataTransfer() =
247247

248-
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.COOMatrix<bool>,bool>(
248+
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.ClCOOMatrix<bool>,bool>(
249249
(fun context wgSize -> Backend.COOMatrix.elementwise context Backend.Common.StandardOperations.boolSum wgSize),
250250
(fun _ -> true),
251251
(fun _ -> true),
@@ -258,7 +258,7 @@ type EWiseAddBenchmarks4BoolCOOWithoutDataTransfer() =
258258

259259
type EWiseAddBenchmarks4Float32CSRWithoutDataTransfer() =
260260

261-
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.CSRMatrix<float32>,float32>(
261+
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.ClCSRMatrix<float32>,float32>(
262262
(fun context wgSize -> Backend.CSRMatrix.elementwise context Backend.Common.StandardOperations.float32Sum wgSize),
263263
float32,
264264
(fun _ -> Utils.nextSingle (System.Random())),
@@ -271,7 +271,7 @@ type EWiseAddBenchmarks4Float32CSRWithoutDataTransfer() =
271271

272272
type EWiseAddBenchmarks4BoolCSRWithoutDataTransfer() =
273273

274-
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.CSRMatrix<bool>,bool>(
274+
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.ClCSRMatrix<bool>,bool>(
275275
(fun context wgSize -> Backend.CSRMatrix.elementwise context Backend.Common.StandardOperations.boolSum wgSize),
276276
(fun _ -> true),
277277
(fun _ -> true),
@@ -285,7 +285,7 @@ type EWiseAddBenchmarks4BoolCSRWithoutDataTransfer() =
285285

286286
type EWiseAddAtLeastOneBenchmarks4BoolCOOWithoutDataTransfer() =
287287

288-
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.COOMatrix<bool>,bool>(
288+
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.ClCOOMatrix<bool>,bool>(
289289
(fun context wgSize -> Backend.COOMatrix.elementwiseAtLeastOne context Backend.Common.StandardOperations.boolSumAtLeastOne wgSize),
290290
(fun _ -> true),
291291
(fun _ -> true),
@@ -297,7 +297,7 @@ type EWiseAddAtLeastOneBenchmarks4BoolCOOWithoutDataTransfer() =
297297

298298
type EWiseAddAtLeastOneBenchmarks4BoolCSRWithoutDataTransfer() =
299299

300-
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.CSRMatrix<bool>,bool>(
300+
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.ClCSRMatrix<bool>,bool>(
301301
(fun context wgSize -> Backend.CSRMatrix.elementwiseAtLeastOne context Backend.Common.StandardOperations.boolSumAtLeastOne wgSize),
302302
(fun _ -> true),
303303
(fun _ -> true),
@@ -309,7 +309,7 @@ type EWiseAddAtLeastOneBenchmarks4BoolCSRWithoutDataTransfer() =
309309

310310
type EWiseAddAtLeastOneBenchmarks4Float32COOWithoutDataTransfer() =
311311

312-
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.COOMatrix<float32>,float32>(
312+
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.ClCOOMatrix<float32>,float32>(
313313
(fun context wgSize -> Backend.COOMatrix.elementwiseAtLeastOne context Backend.Common.StandardOperations.float32SumAtLeastOne wgSize),
314314
float32,
315315
(fun _ -> Utils.nextSingle (System.Random())),
@@ -321,7 +321,7 @@ type EWiseAddAtLeastOneBenchmarks4Float32COOWithoutDataTransfer() =
321321

322322
type EWiseAddAtLeastOneBenchmarks4Float32CSRWithoutDataTransfer() =
323323

324-
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.CSRMatrix<float32>,float32>(
324+
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.ClCSRMatrix<float32>,float32>(
325325
(fun context wgSize -> Backend.CSRMatrix.elementwiseAtLeastOne context Backend.Common.StandardOperations.float32SumAtLeastOne wgSize),
326326
float32,
327327
(fun _ -> Utils.nextSingle (System.Random())),

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksMxm.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ type MxmBenchmarks<'elem when 'elem : struct>(
2020
let mutable funCSR2CSC = None
2121
let mutable funCSC2CSR = None
2222

23-
let mutable firstMatrix = Unchecked.defaultof<Backend.Matrix<'elem>>
24-
let mutable secondMatrix = Unchecked.defaultof<Backend.Matrix<'elem>>
23+
let mutable firstMatrix = Unchecked.defaultof<Backend.ClMatrix<'elem>>
24+
let mutable secondMatrix = Unchecked.defaultof<Backend.ClMatrix<'elem>>
2525
let mutable mask = Unchecked.defaultof<Backend.Mask2D>
2626

2727
let mutable firstMatrixHost = Unchecked.defaultof<_>
2828
let mutable secondMatrixHost = Unchecked.defaultof<_>
2929
let mutable maskHost = Unchecked.defaultof<Mask2D>
3030

31-
member val ResultMatrix = Unchecked.defaultof<Backend.Matrix<'elem>> with get, set
31+
member val ResultMatrix = Unchecked.defaultof<Backend.ClMatrix<'elem>> with get, set
3232

3333
[<ParamsSource("AvaliableContexts")>]
3434
member val OclContextInfo = Unchecked.defaultof<Utils.BenchmarkContext * int> with get, set

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksMxv.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ open GraphBLAS.FSharp.IO
1212
type MxvBenchmarks() =
1313
let rand = System.Random()
1414

15-
let mutable matrix = Unchecked.defaultof<Matrix<float>>
15+
let mutable matrix = Unchecked.defaultof<ClMatrix<float>>
1616
let mutable vector = Unchecked.defaultof<Vector<float>>
1717
let semiring = Predefined.AddMult.float
1818

src/GraphBLAS-sharp.Backend/Algorithms/BFS.fs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ open Brahma.FSharp
55
open FSharp.Quotations
66
open GraphBLAS.FSharp.Backend.ArraysExtensions
77
open GraphBLAS.FSharp.Backend.Common
8+
open GraphBLAS.FSharp.Backend.Vector
9+
open GraphBLAS.FSharp.Backend.Vector.Dense
810

911
module BFS =
1012
let singleSource
@@ -23,15 +25,15 @@ module BFS =
2325
let ofList = Vector.ofList clContext Dense
2426

2527
let maskComplementedTo =
26-
DenseVector.DenseVector.elementWiseTo clContext StandardOperations.complementedMaskOp workGroupSize
28+
DenseVector.elementWiseTo clContext StandardOperations.complementedMaskOp workGroupSize
2729

2830
let fillSubVectorTo =
29-
DenseVector.DenseVector.standardFillSubVectorTo<int, int> clContext workGroupSize
31+
DenseVector.standardFillSubVectorTo<int, int> clContext workGroupSize
3032

3133
let containsNonZero =
32-
DenseVector.DenseVector.containsNonZero clContext workGroupSize
34+
DenseVector.containsNonZero clContext workGroupSize
3335

34-
fun (queue: MailboxProcessor<Msg>) (matrix: CSRMatrix<'a>) (source: int) ->
36+
fun (queue: MailboxProcessor<Msg>) (matrix: ClCSRMatrix<'a>) (source: int) ->
3537
let vertexCount = matrix.RowCount
3638

3739
let levels = zeroCreate queue vertexCount

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
namespace GraphBLAS.FSharp.Backend
1+
namespace GraphBLAS.FSharp.Backend.Common
22

3-
open GraphBLAS.FSharp.Backend
43
open Brahma.FSharp
54
open Microsoft.FSharp.Quotations
65

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace GraphBLAS.FSharp.Backend
1+
namespace GraphBLAS.FSharp.Backend.Common
22

33
open Brahma.FSharp
44
open FSharp.Quotations

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace GraphBLAS.FSharp.Backend
1+
namespace GraphBLAS.FSharp.Backend.Common
22

33
open Brahma.FSharp
44

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace GraphBLAS.FSharp.Backend.Common
22

33
open Brahma.FSharp
4-
open GraphBLAS.FSharp.Backend
54
open Microsoft.FSharp.Control
65
open Microsoft.FSharp.Quotations
76

src/GraphBLAS-sharp.Backend/GraphBLAS-sharp.Backend.fsproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<Compile Include="AssemblyInfo.fs" />
14-
<Compile Include="Common/CommonQuotes.fs" />
14+
<Compile Include="Common\Quotes.fs" />
1515
<Compile Include="Common/Utils.fs" />
1616
<Compile Include="Common/Sum.fs" />
1717
<Compile Include="Common/PrefixSum.fs" />
@@ -26,14 +26,13 @@
2626
<Compile Include="Objects/Common.fs" />
2727
<Compile Include="Objects/ArraysExtentions.fs" />
2828
<Compile Include="Objects/Vector.fs" />
29-
<Compile Include="Objects/Matrix.fs" />
29+
<Compile Include="Objects\Matrix.fs" />
3030
<Compile Include="Matrix/COOMatrix/COOMatrix.fs" />
3131
<Compile Include="Matrix/CSRMatrix/Elementwise.fs" />
3232
<Compile Include="Matrix/CSRMatrix/SpGEMM.fs" />
3333
<Compile Include="Matrix/CSRMatrix/CSRMatrix.fs" />
34-
<Compile Include="Matrix/CSRMatrix/CSRMatrix.fs" />
3534
<Compile Include="Matrix/Matrix.fs" />
36-
<Compile Include="Vector/SparseVector/SparseElementwise.fs" />
35+
<Compile Include="Vector/SparseVector/Elementwise.fs" />
3736
<Compile Include="Vector/SparseVector/SparseVector.fs" />
3837
<Compile Include="Vector/DenseVector/DenseVector.fs" />
3938
<Compile Include="Vector/Vector.fs" />

src/GraphBLAS-sharp.Backend/Matrix/COOMatrix/COOMatrix.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace GraphBLAS.FSharp.Backend
1+
namespace GraphBLAS.FSharp.Backend.Matrix.COO
22

33
open Brahma.FSharp
44
open GraphBLAS.FSharp.Backend
@@ -370,7 +370,7 @@ module COOMatrix =
370370

371371
let setPositions = setPositions<'c> clContext workGroupSize
372372

373-
fun (queue: MailboxProcessor<_>) (matrixLeft: COOMatrix<'a>) (matrixRight: COOMatrix<'b>) ->
373+
fun (queue: MailboxProcessor<_>) (matrixLeft: ClCOOMatrix<'a>) (matrixRight: ClCOOMatrix<'b>) ->
374374

375375
let allRows, allColumns, leftMergedValues, rightMergedValues, isLeft =
376376
merge
@@ -412,7 +412,7 @@ module COOMatrix =
412412
let copyData =
413413
GraphBLAS.FSharp.Backend.ClArray.copy clContext workGroupSize
414414

415-
fun (processor: MailboxProcessor<_>) (matrix: COOMatrix<'a>) ->
415+
fun (processor: MailboxProcessor<_>) (matrix: ClCOOMatrix<'a>) ->
416416

417417
let resultRows = copy processor matrix.Rows
418418

@@ -468,7 +468,7 @@ module COOMatrix =
468468
let copy = ClArray.copy clContext workGroupSize
469469
let copyData = ClArray.copy clContext workGroupSize
470470

471-
fun (processor: MailboxProcessor<_>) (matrix: COOMatrix<'a>) ->
471+
fun (processor: MailboxProcessor<_>) (matrix: ClCOOMatrix<'a>) ->
472472
let rowPointers =
473473
prepare processor matrix.Rows matrix.RowCount
474474

@@ -485,7 +485,7 @@ module COOMatrix =
485485
let toCSRInplace (clContext: ClContext) workGroupSize =
486486
let prepare = compressRows clContext workGroupSize
487487

488-
fun (processor: MailboxProcessor<_>) (matrix: COOMatrix<'a>) ->
488+
fun (processor: MailboxProcessor<_>) (matrix: ClCOOMatrix<'a>) ->
489489
let rowPointers =
490490
prepare processor matrix.Rows matrix.RowCount
491491

@@ -514,7 +514,7 @@ module COOMatrix =
514514
let sort =
515515
BitonicSort.sortKeyValuesInplace clContext workGroupSize
516516

517-
fun (queue: MailboxProcessor<_>) (matrix: COOMatrix<'a>) ->
517+
fun (queue: MailboxProcessor<_>) (matrix: ClCOOMatrix<'a>) ->
518518
sort queue matrix.Columns matrix.Rows matrix.Values
519519

520520
{ Context = clContext
@@ -530,7 +530,7 @@ module COOMatrix =
530530
let copy = ClArray.copy clContext workGroupSize
531531
let copyData = ClArray.copy clContext workGroupSize
532532

533-
fun (queue: MailboxProcessor<_>) (matrix: COOMatrix<'a>) ->
533+
fun (queue: MailboxProcessor<_>) (matrix: ClCOOMatrix<'a>) ->
534534
let copiedMatrix =
535535
{ Context = clContext
536536
RowCount = matrix.RowCount

0 commit comments

Comments
 (0)