Skip to content

Commit abdb353

Browse files
authored
Merge pull request #70 from IgorErin/radix
Radix
2 parents c7bb9b1 + b2384b9 commit abdb353

File tree

27 files changed

+589
-1318
lines changed

27 files changed

+589
-1318
lines changed

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

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

130130
outputArray
131131

132-
/// <summary>
133-
/// Exclude inplace prefix sum.
134-
/// </summary>
135-
/// <example>
136-
/// <code>
137-
/// let arr = [| 1; 1; 1; 1 |]
138-
/// let sum = [| 0 |]
139-
/// runExcludeInplace clContext workGroupSize processor arr sum <@ (+) @> 0
140-
/// |> ignore
141-
/// ...
142-
/// > val arr = [| 0; 1; 2; 3 |]
143-
/// > val sum = [| 4 |]
144-
/// </code>
145-
/// </example>
146-
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
147-
///<param name="plus">Associative binary operation.</param>
148-
///<param name="zero">Zero element for binary operation.</param>
149-
let prefixSumExcludeInplace = PrefixSum.runExcludeInplace
150-
151-
/// <summary>
152-
/// Include inplace prefix sum.
153-
/// </summary>
154-
/// <example>
155-
/// <code>
156-
/// let arr = [| 1; 1; 1; 1 |]
157-
/// let sum = [| 0 |]
158-
/// runExcludeInplace clContext workGroupSize processor arr sum <@ (+) @> 0
159-
/// |> ignore
160-
/// ...
161-
/// > val arr = [| 1; 2; 3; 4 |]
162-
/// > val sum = [| 4 |]
163-
/// </code>
164-
/// </example>
165-
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
166-
///<param name="plus">Associative binary operation.</param>
167-
///<param name="zero">Zero element for binary operation.</param>
168-
let prefixSumIncludeInplace = PrefixSum.runIncludeInplace
169-
170-
let prefixSumExclude plus (clContext: ClContext) workGroupSize =
171-
172-
let runExcludeInplace =
173-
prefixSumExcludeInplace plus clContext workGroupSize
174-
175-
let copy = copy clContext workGroupSize
176-
177-
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) (zero: 'a) ->
178-
179-
let outputArray = copy processor allocationMode inputArray
180-
181-
let totalSum =
182-
runExcludeInplace processor outputArray zero
183-
184-
outputArray, totalSum
185-
186-
let prefixSumInclude plus (clContext: ClContext) workGroupSize =
187-
188-
let runIncludeInplace =
189-
prefixSumIncludeInplace plus clContext workGroupSize
190-
191-
let copy = copy clContext workGroupSize
192-
193-
fun (processor: MailboxProcessor<_>) allocationMode (inputArray: ClArray<'a>) (zero: 'a) ->
194-
195-
let outputArray = copy processor allocationMode inputArray
196-
197-
let totalSum =
198-
runIncludeInplace processor outputArray zero
199-
200-
outputArray, totalSum
201-
202-
let prefixSumBackwardsExcludeInplace plus =
203-
PrefixSum.runBackwardsExcludeInplace plus
204-
205-
let prefixSumBackwardsIncludeInplace plus =
206-
PrefixSum.runBackwardsIncludeInplace plus
207-
208132
let getUniqueBitmap (clContext: ClContext) workGroupSize =
209133

210134
let getUniqueBitmap =
@@ -250,7 +174,7 @@ module ClArray =
250174
let getUniqueBitmap = getUniqueBitmap clContext workGroupSize
251175

252176
let prefixSumExclude =
253-
prefixSumExcludeInplace <@ (+) @> clContext workGroupSize
177+
PrefixSum.runExcludeInplace <@ (+) @> clContext workGroupSize
254178

255179
fun (processor: MailboxProcessor<_>) (inputArray: ClArray<'a>) ->
256180

@@ -380,7 +304,7 @@ module ClArray =
380304
<| Map.optionToValueOrZero Unchecked.defaultof<'b>
381305

382306
let prefixSum =
383-
prefixSumExcludeInplace <@ (+) @> clContext workGroupSize
307+
PrefixSum.runExcludeInplace <@ (+) @> clContext workGroupSize
384308

385309
let scatter =
386310
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)