Skip to content

Commit 1c5663c

Browse files
authored
Merge pull request #47 from YaccConstructor/spgemm-crs-csc
Matrix multiplication CSR CSC
2 parents 835e7bf + 86237c9 commit 1c5663c

35 files changed

Lines changed: 1742 additions & 1248 deletions

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksEWiseAdd.fs

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

197197
module M =
198-
let inline buildCooMatrix (context:ClContext) matrix =
199-
match matrix with
200-
| MatrixCOO m ->
201-
let rows =
202-
context.CreateClArray (m.Rows, hostAccessMode = HostAccessMode.ReadOnly, deviceAccessMode = DeviceAccessMode.ReadOnly, allocationMode = AllocationMode.CopyHostPtr)
203-
204-
let cols =
205-
context.CreateClArray (m.Columns, hostAccessMode = HostAccessMode.ReadOnly, deviceAccessMode = DeviceAccessMode.ReadOnly, allocationMode = AllocationMode.CopyHostPtr)
206-
207-
let vals =
208-
context.CreateClArray (m.Values, hostAccessMode = HostAccessMode.ReadOnly, deviceAccessMode = DeviceAccessMode.ReadOnly, allocationMode = AllocationMode.CopyHostPtr)
209-
210-
{ Backend.COOMatrix.Context = context
211-
Backend.COOMatrix.RowCount = m.RowCount
212-
Backend.COOMatrix.ColumnCount = m.ColumnCount
213-
Backend.COOMatrix.Rows = rows
214-
Backend.COOMatrix.Columns = cols
215-
Backend.COOMatrix.Values = vals }
216-
217-
| x -> failwith "Unsupported matrix format: %A"
218-
219-
let inline buildCsrMatrix (context:ClContext) matrix =
220-
match matrix with
221-
| MatrixCOO m ->
222-
let rowPointers =
223-
context.CreateClArray(
224-
Utils.rowIndices2rowPointers m.Rows m.RowCount
225-
,hostAccessMode = HostAccessMode.ReadOnly
226-
,deviceAccessMode = DeviceAccessMode.ReadOnly
227-
,allocationMode = AllocationMode.CopyHostPtr)
228-
229-
let cols =
230-
context.CreateClArray (
231-
m.Columns
232-
,hostAccessMode = HostAccessMode.ReadOnly
233-
,deviceAccessMode = DeviceAccessMode.ReadOnly
234-
,allocationMode = AllocationMode.CopyHostPtr)
235-
236-
let vals =
237-
context.CreateClArray (
238-
m.Values
239-
,hostAccessMode = HostAccessMode.ReadOnly
240-
,deviceAccessMode = DeviceAccessMode.ReadOnly
241-
,allocationMode = AllocationMode.CopyHostPtr)
242-
243-
{ Backend.CSRMatrix.Context = context
244-
Backend.CSRMatrix.RowCount = m.RowCount
245-
Backend.CSRMatrix.ColumnCount = m.ColumnCount
246-
Backend.CSRMatrix.RowPointers = rowPointers
247-
Backend.CSRMatrix.Columns = cols
248-
Backend.CSRMatrix.Values = vals }
249-
250-
| x -> failwith "Unsupported matrix format: %A"
251-
252198
let resultToHostCOO (resultMatrix:Backend.COOMatrix<'a>) (procesor:MailboxProcessor<_>) =
253199
let cols =
254200
let a = Array.zeroCreate resultMatrix.ColumnCount
@@ -277,7 +223,7 @@ type EWiseAddBenchmarks4Float32COOWithoutDataTransfer() =
277223
(fun context wgSize -> Backend.COOMatrix.elementwise context Backend.Common.StandardOperations.float32Sum wgSize),
278224
float32,
279225
(fun _ -> Utils.nextSingle (System.Random())),
280-
M.buildCooMatrix
226+
COOMatrix<float32>.ToBackend
281227
)
282228

283229
static member InputMatricesProvider =
@@ -289,7 +235,7 @@ type EWiseAddBenchmarks4Float32COOWithDataTransfer() =
289235
(fun context wgSize -> Backend.COOMatrix.elementwise context Backend.Common.StandardOperations.float32Sum wgSize),
290236
float32,
291237
(fun _ -> Utils.nextSingle (System.Random())),
292-
M.buildCooMatrix,
238+
COOMatrix<float32>.ToBackend,
293239
M.resultToHostCOO
294240
)
295241

@@ -303,7 +249,7 @@ type EWiseAddBenchmarks4BoolCOOWithoutDataTransfer() =
303249
(fun context wgSize -> Backend.COOMatrix.elementwise context Backend.Common.StandardOperations.boolSum wgSize),
304250
(fun _ -> true),
305251
(fun _ -> true),
306-
M.buildCooMatrix
252+
COOMatrix<bool>.ToBackend
307253
)
308254

309255
static member InputMatricesProvider =
@@ -316,7 +262,7 @@ type EWiseAddBenchmarks4Float32CSRWithoutDataTransfer() =
316262
(fun context wgSize -> Backend.CSRMatrix.elementwise context Backend.Common.StandardOperations.float32Sum wgSize),
317263
float32,
318264
(fun _ -> Utils.nextSingle (System.Random())),
319-
M.buildCsrMatrix
265+
CSRMatrix<float32>.ToBackend
320266
)
321267

322268
static member InputMatricesProvider =
@@ -329,7 +275,7 @@ type EWiseAddBenchmarks4BoolCSRWithoutDataTransfer() =
329275
(fun context wgSize -> Backend.CSRMatrix.elementwise context Backend.Common.StandardOperations.boolSum wgSize),
330276
(fun _ -> true),
331277
(fun _ -> true),
332-
M.buildCsrMatrix
278+
CSRMatrix<bool>.ToBackend
333279
)
334280

335281
static member InputMatricesProvider =
@@ -343,7 +289,7 @@ type EWiseAddAtLeastOneBenchmarks4BoolCOOWithoutDataTransfer() =
343289
(fun context wgSize -> Backend.COOMatrix.elementwiseAtLeastOne context Backend.Common.StandardOperations.boolSumAtLeastOne wgSize),
344290
(fun _ -> true),
345291
(fun _ -> true),
346-
M.buildCooMatrix
292+
COOMatrix<bool>.ToBackend
347293
)
348294

349295
static member InputMatricesProvider =
@@ -355,7 +301,7 @@ type EWiseAddAtLeastOneBenchmarks4BoolCSRWithoutDataTransfer() =
355301
(fun context wgSize -> Backend.CSRMatrix.elementwiseAtLeastOne context Backend.Common.StandardOperations.boolSumAtLeastOne wgSize),
356302
(fun _ -> true),
357303
(fun _ -> true),
358-
M.buildCsrMatrix
304+
CSRMatrix<bool>.ToBackend
359305
)
360306

361307
static member InputMatricesProvider =
@@ -367,7 +313,7 @@ type EWiseAddAtLeastOneBenchmarks4Float32COOWithoutDataTransfer() =
367313
(fun context wgSize -> Backend.COOMatrix.elementwiseAtLeastOne context Backend.Common.StandardOperations.float32SumAtLeastOne wgSize),
368314
float32,
369315
(fun _ -> Utils.nextSingle (System.Random())),
370-
M.buildCooMatrix
316+
COOMatrix<float32>.ToBackend
371317
)
372318

373319
static member InputMatricesProvider =
@@ -379,7 +325,7 @@ type EWiseAddAtLeastOneBenchmarks4Float32CSRWithoutDataTransfer() =
379325
(fun context wgSize -> Backend.CSRMatrix.elementwiseAtLeastOne context Backend.Common.StandardOperations.float32SumAtLeastOne wgSize),
380326
float32,
381327
(fun _ -> Utils.nextSingle (System.Random())),
382-
M.buildCsrMatrix
328+
CSRMatrix<float32>.ToBackend
383329
)
384330

385331
static member InputMatricesProvider =

0 commit comments

Comments
 (0)