Skip to content

Commit 639f131

Browse files
committed
refactor: later allocation flag binding
1 parent 2e991f7 commit 639f131

30 files changed

Lines changed: 585 additions & 666 deletions

File tree

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksEWiseAdd.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type EWiseAddBenchmarks<'matrixT, 'elem when 'matrixT :> IDeviceMemObject and 'e
109109
reader.ReadMatrix converter
110110

111111
member this.EWiseAddition() =
112-
this.ResultMatrix <- this.FunToBenchmark this.Processor firstMatrix secondMatrix
112+
this.ResultMatrix <- this.FunToBenchmark this.Processor HostInterop firstMatrix secondMatrix
113113

114114
member this.ClearInputMatrices() =
115115
(firstMatrix :> IDeviceMemObject).Dispose this.Processor
@@ -225,7 +225,7 @@ module M =
225225
type EWiseAddBenchmarks4Float32COOWithoutDataTransfer() =
226226

227227
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.COO<float32>,float32>(
228-
(fun context wgSize -> COOMatrix.elementwise context ArithmeticOperations.float32Sum wgSize HostInterop),
228+
(fun context wgSize -> COOMatrix.elementwise context ArithmeticOperations.float32Sum wgSize),
229229
float32,
230230
(fun _ -> Utils.nextSingle (System.Random())),
231231
Matrix.ToBackendCOO
@@ -237,7 +237,7 @@ type EWiseAddBenchmarks4Float32COOWithoutDataTransfer() =
237237
type EWiseAddBenchmarks4Float32COOWithDataTransfer() =
238238

239239
inherit EWiseAddBenchmarksWithDataTransfer<ClMatrix.COO<float32>,float32>(
240-
(fun context wgSize -> COOMatrix.elementwise context ArithmeticOperations.float32Sum wgSize HostInterop),
240+
(fun context wgSize -> COOMatrix.elementwise context ArithmeticOperations.float32Sum wgSize),
241241
float32,
242242
(fun _ -> Utils.nextSingle (System.Random())),
243243
Matrix.ToBackendCOO<float32>,
@@ -251,7 +251,7 @@ type EWiseAddBenchmarks4Float32COOWithDataTransfer() =
251251
type EWiseAddBenchmarks4BoolCOOWithoutDataTransfer() =
252252

253253
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.COO<bool>,bool>(
254-
(fun context wgSize -> COOMatrix.elementwise context ArithmeticOperations.boolSum wgSize HostInterop),
254+
(fun context wgSize -> COOMatrix.elementwise context ArithmeticOperations.boolSum wgSize),
255255
(fun _ -> true),
256256
(fun _ -> true),
257257
Matrix.ToBackendCOO<bool>
@@ -264,7 +264,7 @@ type EWiseAddBenchmarks4BoolCOOWithoutDataTransfer() =
264264
type EWiseAddBenchmarks4Float32CSRWithoutDataTransfer() =
265265

266266
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.CSR<float32>,float32>(
267-
(fun context wgSize -> CSRMatrix.elementwise context ArithmeticOperations.float32Sum wgSize HostInterop),
267+
(fun context wgSize -> CSRMatrix.elementwise context ArithmeticOperations.float32Sum wgSize),
268268
float32,
269269
(fun _ -> Utils.nextSingle (System.Random())),
270270
Matrix.ToBackendCSR
@@ -277,7 +277,7 @@ type EWiseAddBenchmarks4Float32CSRWithoutDataTransfer() =
277277
type EWiseAddBenchmarks4BoolCSRWithoutDataTransfer() =
278278

279279
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.CSR<bool>,bool>(
280-
(fun context wgSize -> CSRMatrix.elementwise context ArithmeticOperations.boolSum wgSize HostInterop),
280+
(fun context wgSize -> CSRMatrix.elementwise context ArithmeticOperations.boolSum wgSize),
281281
(fun _ -> true),
282282
(fun _ -> true),
283283
Matrix.ToBackendCSR
@@ -291,7 +291,7 @@ type EWiseAddBenchmarks4BoolCSRWithoutDataTransfer() =
291291
type EWiseAddAtLeastOneBenchmarks4BoolCOOWithoutDataTransfer() =
292292

293293
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.COO<bool>,bool>(
294-
(fun context wgSize -> COOMatrix.elementwiseAtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize HostInterop),
294+
(fun context wgSize -> COOMatrix.elementwiseAtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize),
295295
(fun _ -> true),
296296
(fun _ -> true),
297297
Matrix.ToBackendCOO<bool>
@@ -303,7 +303,7 @@ type EWiseAddAtLeastOneBenchmarks4BoolCOOWithoutDataTransfer() =
303303
type EWiseAddAtLeastOneBenchmarks4BoolCSRWithoutDataTransfer() =
304304

305305
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.CSR<bool>,bool>(
306-
(fun context wgSize -> CSRMatrix.elementwiseAtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize HostInterop),
306+
(fun context wgSize -> CSRMatrix.elementwiseAtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize),
307307
(fun _ -> true),
308308
(fun _ -> true),
309309
Matrix.ToBackendCSR
@@ -315,7 +315,7 @@ type EWiseAddAtLeastOneBenchmarks4BoolCSRWithoutDataTransfer() =
315315
type EWiseAddAtLeastOneBenchmarks4Float32COOWithoutDataTransfer() =
316316

317317
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.COO<float32>,float32>(
318-
(fun context wgSize -> COOMatrix.elementwiseAtLeastOne context ArithmeticOperations.float32SumAtLeastOne wgSize HostInterop),
318+
(fun context wgSize -> COOMatrix.elementwiseAtLeastOne context ArithmeticOperations.float32SumAtLeastOne wgSize),
319319
float32,
320320
(fun _ -> Utils.nextSingle (System.Random())),
321321
Matrix.ToBackendCOO<float32>
@@ -327,7 +327,7 @@ type EWiseAddAtLeastOneBenchmarks4Float32COOWithoutDataTransfer() =
327327
type EWiseAddAtLeastOneBenchmarks4Float32CSRWithoutDataTransfer() =
328328

329329
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.CSR<float32>,float32>(
330-
(fun context wgSize -> CSRMatrix.elementwiseAtLeastOne context ArithmeticOperations.float32SumAtLeastOne wgSize HostInterop),
330+
(fun context wgSize -> CSRMatrix.elementwiseAtLeastOne context ArithmeticOperations.float32SumAtLeastOne wgSize),
331331
float32,
332332
(fun _ -> Utils.nextSingle (System.Random())),
333333
Matrix.ToBackendCSR<float32>

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksMxm.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ type MxmBenchmarks<'elem when 'elem : struct>(
7575
member this.FunCSR2CSC =
7676
match funCSR2CSC with
7777
| None ->
78-
let x = Matrix.toCSCInplace this.OclContext this.WorkGroupSize HostInterop
78+
let x = Matrix.toCSCInplace this.OclContext this.WorkGroupSize
7979
funCSR2CSC <- Some x
8080
x
8181
| Some x -> x
8282

8383
member this.FunCSC2CSR =
8484
match funCSC2CSR with
8585
| None ->
86-
let x = Matrix.toCSRInplace this.OclContext this.WorkGroupSize HostInterop
86+
let x = Matrix.toCSRInplace this.OclContext this.WorkGroupSize
8787
funCSC2CSR <- Some x
8888
x
8989
| Some x -> x
@@ -130,10 +130,10 @@ type MxmBenchmarks<'elem when 'elem : struct>(
130130
mask <- maskHost.ToBackend(this.OclContext)
131131

132132
member this.ConvertSecondMatrixToCSC() =
133-
secondMatrix <- this.FunCSR2CSC this.Processor secondMatrix
133+
secondMatrix <- this.FunCSR2CSC this.Processor HostInterop secondMatrix
134134

135135
member this.ConvertSecondMatrixToCSR() =
136-
secondMatrix <- this.FunCSC2CSR this.Processor secondMatrix
136+
secondMatrix <- this.FunCSC2CSR this.Processor HostInterop secondMatrix
137137

138138
abstract member GlobalSetup : unit -> unit
139139

benchmarks/GraphBLAS-sharp.Benchmarks/VectorEWiseAddGen.fs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type VectorEWiseBenchmarks<'elem when 'elem : struct>(
3838

3939
let mutable secondVector = Unchecked.defaultof<ClVector<'elem>>
4040

41-
4241
member val HostVectorPair = Unchecked.defaultof<Vector<'elem> * Vector<'elem>> with get, set
4342

4443
member val ResultVector = Unchecked.defaultof<ClVector<'elem>> with get,set
@@ -68,7 +67,7 @@ type VectorEWiseBenchmarks<'elem when 'elem : struct>(
6867
| Some x -> x
6968

7069
member this.EWiseAddition() =
71-
this.ResultVector <- this.FunToBenchmark this.Processor firstVector secondVector
70+
this.ResultVector <- this.FunToBenchmark this.Processor HostInterop firstVector secondVector
7271

7372
member this.ClearInputVectors()=
7473
firstVector.Dispose this.Processor
@@ -180,53 +179,53 @@ module VectorGenerator =
180179
type VectorEWiseBenchmarks4FloatSparseWithoutDataTransfer() =
181180

182181
inherit VectorEWiseBenchmarksWithoutDataTransfer<float>(
183-
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.floatSum wgSize HostInterop),
182+
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.floatSum wgSize),
184183
VectorGenerator.floatPair Sparse)
185184

186185
type VectorEWiseBenchmarks4Int32SparseWithoutDataTransfer() =
187186

188187
inherit VectorEWiseBenchmarksWithoutDataTransfer<int32>(
189-
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.intSum wgSize HostInterop),
188+
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.intSum wgSize),
190189
VectorGenerator.intPair Sparse)
191190

192191
/// General
193192
194193
type VectorEWiseGeneralBenchmarks4FloatSparseWithoutDataTransfer() =
195194

196195
inherit VectorEWiseBenchmarksWithoutDataTransfer<float>(
197-
(fun context wgSize -> Vector.elementwiseGeneral context ArithmeticOperations.floatSum wgSize HostInterop),
196+
(fun context wgSize -> Vector.elementwiseGeneral context ArithmeticOperations.floatSum wgSize),
198197
VectorGenerator.floatPair Sparse)
199198

200199
type VectorEWiseGeneralBenchmarks4Int32SparseWithoutDataTransfer() =
201200

202201
inherit VectorEWiseBenchmarksWithoutDataTransfer<int32>(
203-
(fun context wgSize -> Vector.elementwiseGeneral context ArithmeticOperations.intSum wgSize HostInterop),
202+
(fun context wgSize -> Vector.elementwiseGeneral context ArithmeticOperations.intSum wgSize),
204203
VectorGenerator.intPair Sparse)
205204

206205
/// With data transfer
207206
208207
type VectorEWiseBenchmarks4FloatSparseWithDataTransfer() =
209208

210209
inherit VectorEWiseBenchmarksWithDataTransfer<float>(
211-
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.floatSum wgSize HostInterop),
210+
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.floatSum wgSize),
212211
VectorGenerator.floatPair Sparse)
213212

214213
type VectorEWiseBenchmarks4Int32SparseWithDataTransfer() =
215214

216215
inherit VectorEWiseBenchmarksWithDataTransfer<int32>(
217-
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.intSum wgSize HostInterop),
216+
(fun context wgSize -> Vector.elementWise context ArithmeticOperations.intSum wgSize),
218217
VectorGenerator.intPair Sparse)
219218

220219
/// General with data transfer
221220
222221
type VectorEWiseGeneralBenchmarks4FloatSparseWithDataTransfer() =
223222

224223
inherit VectorEWiseBenchmarksWithDataTransfer<float>(
225-
(fun context wgSize -> Vector.elementwiseGeneral context ArithmeticOperations.floatSum wgSize HostInterop),
224+
(fun context wgSize -> Vector.elementwiseGeneral context ArithmeticOperations.floatSum wgSize),
226225
VectorGenerator.floatPair Sparse)
227226

228227
type VectorEWiseGeneralBenchmarks4Int32SparseWithDataTransfer() =
229228

230229
inherit VectorEWiseBenchmarksWithDataTransfer<int32>(
231-
(fun context wgSize -> Vector.elementwiseGeneral context ArithmeticOperations.intSum wgSize HostInterop),
230+
(fun context wgSize -> Vector.elementwiseGeneral context ArithmeticOperations.intSum wgSize),
232231
VectorGenerator.intPair Sparse)

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ module BFS =
2323
SpMV.runTo clContext add mul workGroupSize
2424

2525
let zeroCreate =
26-
ClArray.zeroCreate clContext workGroupSize HostInterop
26+
ClArray.zeroCreate clContext workGroupSize
2727

28-
let ofList =
29-
Vector.ofList clContext workGroupSize DeviceOnly
28+
let ofList = Vector.ofList clContext workGroupSize
3029

3130
let maskComplementedTo =
3231
DenseVector.elementWiseTo clContext Mask.complementedMaskOp workGroupSize
@@ -40,10 +39,10 @@ module BFS =
4039
fun (queue: MailboxProcessor<Msg>) (matrix: ClMatrix.CSR<'a>) (source: int) ->
4140
let vertexCount = matrix.RowCount
4241

43-
let levels = zeroCreate queue vertexCount
42+
let levels = zeroCreate queue HostInterop vertexCount
4443

4544
let frontier =
46-
ofList queue Dense vertexCount [ source, 1 ]
45+
ofList queue DeviceOnly Dense vertexCount [ source, 1 ]
4746

4847
match frontier with
4948
| ClVector.Dense front ->

0 commit comments

Comments
 (0)