Skip to content

Commit 890bdd1

Browse files
committed
merge: dev
2 parents be13d6e + 7885e8a commit 890bdd1

60 files changed

Lines changed: 3187 additions & 2788 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksEWiseAdd.fs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ open BenchmarkDotNet.Columns
99
open Brahma.FSharp
1010
open GraphBLAS.FSharp.Objects
1111
open GraphBLAS.FSharp.Backend.Objects
12-
open GraphBLAS.FSharp.Backend.Matrix.COO
13-
open GraphBLAS.FSharp.Backend.Matrix.CSR
12+
open GraphBLAS.FSharp.Backend.Matrix
1413
open GraphBLAS.FSharp.Objects.Matrix
1514
open GraphBLAS.FSharp.Benchmarks.MatrixExtensions
1615
open GraphBLAS.FSharp.Backend.Objects.ClContext
@@ -196,7 +195,7 @@ module M =
196195
type EWiseAddBenchmarks4Float32COOWithoutDataTransfer() =
197196

198197
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.COO<float32>,float32>(
199-
(fun context wgSize -> COOMatrix.map2 context ArithmeticOperations.float32Sum wgSize),
198+
(fun context wgSize -> COO.Matrix.map2 context ArithmeticOperations.float32Sum wgSize),
200199
float32,
201200
(fun _ -> Utils.nextSingle (System.Random())),
202201
Matrix.ToBackendCOO
@@ -208,7 +207,7 @@ type EWiseAddBenchmarks4Float32COOWithoutDataTransfer() =
208207
type EWiseAddBenchmarks4Float32COOWithDataTransfer() =
209208

210209
inherit EWiseAddBenchmarksWithDataTransfer<ClMatrix.COO<float32>,float32>(
211-
(fun context wgSize -> COOMatrix.map2 context ArithmeticOperations.float32Sum wgSize),
210+
(fun context wgSize -> COO.Matrix.map2 context ArithmeticOperations.float32Sum wgSize),
212211
float32,
213212
(fun _ -> Utils.nextSingle (System.Random())),
214213
Matrix.ToBackendCOO<float32>,
@@ -222,7 +221,7 @@ type EWiseAddBenchmarks4Float32COOWithDataTransfer() =
222221
type EWiseAddBenchmarks4BoolCOOWithoutDataTransfer() =
223222

224223
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.COO<bool>,bool>(
225-
(fun context wgSize -> COOMatrix.map2 context ArithmeticOperations.boolSum wgSize),
224+
(fun context wgSize -> COO.Matrix.map2 context ArithmeticOperations.boolSum wgSize),
226225
(fun _ -> true),
227226
(fun _ -> true),
228227
Matrix.ToBackendCOO<bool>
@@ -235,7 +234,7 @@ type EWiseAddBenchmarks4BoolCOOWithoutDataTransfer() =
235234
type EWiseAddBenchmarks4Float32CSRWithoutDataTransfer() =
236235

237236
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.CSR<float32>,float32>(
238-
(fun context wgSize -> CSRMatrix.map2 context ArithmeticOperations.float32Sum wgSize),
237+
(fun context wgSize -> CSR.Matrix.map2 context ArithmeticOperations.float32Sum wgSize),
239238
float32,
240239
(fun _ -> Utils.nextSingle (System.Random())),
241240
Matrix.ToBackendCSR
@@ -248,7 +247,7 @@ type EWiseAddBenchmarks4Float32CSRWithoutDataTransfer() =
248247
type EWiseAddBenchmarks4BoolCSRWithoutDataTransfer() =
249248

250249
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.CSR<bool>,bool>(
251-
(fun context wgSize -> CSRMatrix.map2 context ArithmeticOperations.boolSum wgSize),
250+
(fun context wgSize -> CSR.Matrix.map2 context ArithmeticOperations.boolSum wgSize),
252251
(fun _ -> true),
253252
(fun _ -> true),
254253
Matrix.ToBackendCSR
@@ -262,7 +261,7 @@ type EWiseAddBenchmarks4BoolCSRWithoutDataTransfer() =
262261
type EWiseAddAtLeastOneBenchmarks4BoolCOOWithoutDataTransfer() =
263262

264263
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.COO<bool>,bool>(
265-
(fun context wgSize -> COOMatrix.map2AtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize),
264+
(fun context wgSize -> COO.Matrix.map2AtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize),
266265
(fun _ -> true),
267266
(fun _ -> true),
268267
Matrix.ToBackendCOO<bool>
@@ -274,7 +273,7 @@ type EWiseAddAtLeastOneBenchmarks4BoolCOOWithoutDataTransfer() =
274273
type EWiseAddAtLeastOneBenchmarks4BoolCSRWithoutDataTransfer() =
275274

276275
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.CSR<bool>,bool>(
277-
(fun context wgSize -> CSRMatrix.map2AtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize),
276+
(fun context wgSize -> CSR.Matrix.map2AtLeastOne context ArithmeticOperations.boolSumAtLeastOne wgSize),
278277
(fun _ -> true),
279278
(fun _ -> true),
280279
Matrix.ToBackendCSR
@@ -286,7 +285,7 @@ type EWiseAddAtLeastOneBenchmarks4BoolCSRWithoutDataTransfer() =
286285
type EWiseAddAtLeastOneBenchmarks4Float32COOWithoutDataTransfer() =
287286

288287
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.COO<float32>,float32>(
289-
(fun context wgSize -> COOMatrix.map2AtLeastOne context ArithmeticOperations.float32SumAtLeastOne wgSize),
288+
(fun context wgSize -> COO.Matrix.map2AtLeastOne context ArithmeticOperations.float32SumAtLeastOne wgSize),
290289
float32,
291290
(fun _ -> Utils.nextSingle (System.Random())),
292291
Matrix.ToBackendCOO<float32>
@@ -298,7 +297,7 @@ type EWiseAddAtLeastOneBenchmarks4Float32COOWithoutDataTransfer() =
298297
type EWiseAddAtLeastOneBenchmarks4Float32CSRWithoutDataTransfer() =
299298

300299
inherit EWiseAddBenchmarksWithoutDataTransfer<ClMatrix.CSR<float32>,float32>(
301-
(fun context wgSize -> CSRMatrix.map2AtLeastOne context ArithmeticOperations.float32SumAtLeastOne wgSize),
300+
(fun context wgSize -> CSR.Matrix.map2AtLeastOne context ArithmeticOperations.float32SumAtLeastOne wgSize),
302301
float32,
303302
(fun _ -> Utils.nextSingle (System.Random())),
304303
Matrix.ToBackendCSR<float32>

benchmarks/GraphBLAS-sharp.Benchmarks/VectorEWiseAddGen.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ type VectorEWiseBenchmarksWithDataTransfer<'elem when 'elem : struct>(
155155
override this.GlobalCleanup() = ()
156156

157157
/// Without data transfer
158-
158+
/// AtLeastOne
159159
type VectorEWiseBenchmarks4FloatSparseWithoutDataTransfer() =
160160

161161
inherit VectorEWiseBenchmarksWithoutDataTransfer<float>(
@@ -173,13 +173,13 @@ type VectorEWiseBenchmarks4Int32SparseWithoutDataTransfer() =
173173
type VectorEWiseGeneralBenchmarks4FloatSparseWithoutDataTransfer() =
174174

175175
inherit VectorEWiseBenchmarksWithoutDataTransfer<float>(
176-
(fun context -> Vector.map2General context ArithmeticOperations.floatSum),
176+
(fun context -> Vector.map2 context ArithmeticOperations.floatSum),
177177
VectorGenerator.floatPair Sparse)
178178

179179
type VectorEWiseGeneralBenchmarks4Int32SparseWithoutDataTransfer() =
180180

181181
inherit VectorEWiseBenchmarksWithoutDataTransfer<int32>(
182-
(fun context -> Vector.map2General context ArithmeticOperations.intSum),
182+
(fun context -> Vector.map2 context ArithmeticOperations.intSum),
183183
VectorGenerator.intPair Sparse)
184184

185185
/// With data transfer
@@ -201,11 +201,11 @@ type VectorEWiseBenchmarks4Int32SparseWithDataTransfer() =
201201
type VectorEWiseGeneralBenchmarks4FloatSparseWithDataTransfer() =
202202

203203
inherit VectorEWiseBenchmarksWithDataTransfer<float>(
204-
(fun context -> Vector.map2General context ArithmeticOperations.floatSum),
204+
(fun context -> Vector.map2 context ArithmeticOperations.floatSum),
205205
VectorGenerator.floatPair Sparse)
206206

207207
type VectorEWiseGeneralBenchmarks4Int32SparseWithDataTransfer() =
208208

209209
inherit VectorEWiseBenchmarksWithDataTransfer<int32>(
210-
(fun context -> Vector.map2General context ArithmeticOperations.intSum),
210+
(fun context -> Vector.map2 context ArithmeticOperations.intSum),
211211
VectorGenerator.intPair Sparse)

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

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -153,82 +153,6 @@ module ClArray =
153153

154154
outputArray
155155

156-
/// <summary>
157-
/// Exclude inplace prefix sum.
158-
/// </summary>
159-
/// <example>
160-
/// <code>
161-
/// let arr = [| 1; 1; 1; 1 |]
162-
/// let sum = [| 0 |]
163-
/// runExcludeInplace clContext workGroupSize processor arr sum <@ (+) @> 0
164-
/// |> ignore
165-
/// ...
166-
/// > val arr = [| 0; 1; 2; 3 |]
167-
/// > val sum = [| 4 |]
168-
/// </code>
169-
/// </example>
170-
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
171-
///<param name="plus">Associative binary operation.</param>
172-
///<param name="zero">Zero element for binary operation.</param>
173-
let prefixSumExcludeInplace = PrefixSum.runExcludeInplace
174-
175-
/// <summary>
176-
/// Include inplace prefix sum.
177-
/// </summary>
178-
/// <example>
179-
/// <code>
180-
/// let arr = [| 1; 1; 1; 1 |]
181-
/// let sum = [| 0 |]
182-
/// runExcludeInplace clContext workGroupSize processor arr sum <@ (+) @> 0
183-
/// |> ignore
184-
/// ...
185-
/// > val arr = [| 1; 2; 3; 4 |]
186-
/// > val sum = [| 4 |]
187-
/// </code>
188-
/// </example>
189-
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
190-
///<param name="plus">Associative binary operation.</param>
191-
///<param name="zero">Zero element for binary operation.</param>
192-
let prefixSumIncludeInplace = PrefixSum.runIncludeInplace
193-
194-
let prefixSumExclude plus (clContext: ClContext) workGroupSize =
195-
196-
let runExcludeInplace =
197-
prefixSumExcludeInplace plus clContext workGroupSize
198-
199-
let copy = copy clContext workGroupSize
200-
201-
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) (zero: 'a) ->
202-
203-
let outputArray = copy processor allocationMode inputArray
204-
205-
let totalSum =
206-
runExcludeInplace processor outputArray zero
207-
208-
outputArray, totalSum
209-
210-
let prefixSumInclude plus (clContext: ClContext) workGroupSize =
211-
212-
let runIncludeInplace =
213-
prefixSumIncludeInplace plus clContext workGroupSize
214-
215-
let copy = copy clContext workGroupSize
216-
217-
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) (zero: 'a) ->
218-
219-
let outputArray = copy processor allocationMode inputArray
220-
221-
let totalSum =
222-
runIncludeInplace processor outputArray zero
223-
224-
outputArray, totalSum
225-
226-
let prefixSumBackwardsExcludeInplace plus =
227-
PrefixSum.runBackwardsExcludeInplace plus
228-
229-
let prefixSumBackwardsIncludeInplace plus =
230-
PrefixSum.runBackwardsIncludeInplace plus
231-
232156
let getUniqueBitmap (clContext: ClContext) workGroupSize =
233157

234158
let getUniqueBitmap =
@@ -274,7 +198,7 @@ module ClArray =
274198
let getUniqueBitmap = getUniqueBitmap clContext workGroupSize
275199

276200
let prefixSumExclude =
277-
prefixSumExcludeInplace <@ (+) @> clContext workGroupSize
201+
PrefixSum.runExcludeInplace <@ (+) @> clContext workGroupSize
278202

279203
fun (processor: MailboxProcessor<_>) (inputArray: ClArray<'a>) ->
280204

@@ -404,7 +328,7 @@ module ClArray =
404328
<| Map.optionToValueOrZero Unchecked.defaultof<'b>
405329

406330
let prefixSum =
407-
prefixSumExcludeInplace <@ (+) @> clContext workGroupSize
331+
PrefixSum.runExcludeInplace <@ (+) @> clContext workGroupSize
408332

409333
let scatter =
410334
Scatter.runInplace clContext workGroupSize

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,55 @@ module PrefixSum =
218218
let runBackwardsExcludeInplace plus = runInplace true scanExclusive plus
219219

220220
let runBackwardsIncludeInplace plus = runInplace true scanInclusive plus
221+
222+
/// <summary>
223+
/// Exclude inplace prefix sum.
224+
/// </summary>
225+
/// <example>
226+
/// <code>
227+
/// let arr = [| 1; 1; 1; 1 |]
228+
/// let sum = [| 0 |]
229+
/// runExcludeInplace clContext workGroupSize processor arr sum <@ (+) @> 0
230+
/// |> ignore
231+
/// ...
232+
/// > val arr = [| 0; 1; 2; 3 |]
233+
/// > val sum = [| 4 |]
234+
/// </code>
235+
/// </example>
236+
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
237+
///<param name="plus">Associative binary operation.</param>
238+
///<param name="zero">Zero element for binary operation.</param>
239+
let standardExcludeInplace (clContext: ClContext) workGroupSize =
240+
241+
let scan =
242+
runExcludeInplace <@ (+) @> clContext workGroupSize
243+
244+
fun (processor: MailboxProcessor<_>) (inputArray: ClArray<int>) ->
245+
246+
scan processor inputArray 0
247+
248+
/// <summary>
249+
/// Include inplace prefix sum.
250+
/// </summary>
251+
/// <example>
252+
/// <code>
253+
/// let arr = [| 1; 1; 1; 1 |]
254+
/// let sum = [| 0 |]
255+
/// runExcludeInplace clContext workGroupSize processor arr sum <@ (+) @> 0
256+
/// |> ignore
257+
/// ...
258+
/// > val arr = [| 1; 2; 3; 4 |]
259+
/// > val sum = [| 4 |]
260+
/// </code>
261+
/// </example>
262+
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
263+
///<param name="plus">Associative binary operation.</param>
264+
///<param name="zero">Zero element for binary operation.</param>
265+
let standardIncludeInplace (clContext: ClContext) workGroupSize =
266+
267+
let scan =
268+
runIncludeInplace <@ (+) @> clContext workGroupSize
269+
270+
fun (processor: MailboxProcessor<_>) (inputArray: ClArray<int>) ->
271+
272+
scan processor inputArray 0

src/GraphBLAS-sharp.Backend/Common/BitonicSort.fs renamed to src/GraphBLAS-sharp.Backend/Common/Sort/Bitonic.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
namespace GraphBLAS.FSharp.Backend.Common
1+
namespace GraphBLAS.FSharp.Backend.Common.Sort
22

33
open Brahma.FSharp
4+
open GraphBLAS.FSharp.Backend.Common
45

5-
module internal BitonicSort =
6+
module internal Bitonic =
67
let private localBegin (clContext: ClContext) workGroupSize =
78

89
let processedSize = workGroupSize * 2

0 commit comments

Comments
 (0)