Skip to content

Commit 372fed4

Browse files
committed
refactor: scatter in ClArrat.removeDuplicates
1 parent 0a0e2f6 commit 372fed4

6 files changed

Lines changed: 20 additions & 48 deletions

File tree

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

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -255,44 +255,13 @@ module ClArray =
255255

256256
bitmap
257257

258-
let setPositions (clContext: ClContext) =
259-
260-
let setPositions =
261-
<@ fun (ndRange: Range1D) (inputArray: ClArray<int>) inputLength (positions: ClArray<int>) (outputArray: ClArray<int>) ->
262-
263-
let i = ndRange.GlobalID0
264-
265-
if i < inputLength then
266-
outputArray.[positions.[i]] <- inputArray.[i] @>
267-
268-
let kernel = clContext.Compile(setPositions)
269-
270-
fun (processor: MailboxProcessor<_>) workGroupSize (inputArray: ClArray<'a>) (positions: ClArray<int>) (outputArraySize: int) ->
271-
272-
let ndRange =
273-
Range1D.CreateValid(inputArray.Length, workGroupSize)
274-
275-
let outputArray =
276-
clContext.CreateClArrayWithGPUOnlyFlags outputArraySize
277-
278-
let kernel = kernel.GetKernel()
279-
280-
processor.Post(
281-
Msg.MsgSetArguments
282-
(fun () -> kernel.KernelFunc ndRange inputArray inputArray.Length positions outputArray)
283-
)
284-
285-
processor.Post(Msg.CreateRunMsg<_, _> kernel)
286-
287-
outputArray
288-
289258
///<description>Remove duplicates form the given array.</description>
290259
///<param name="clContext">Computational context</param>
291260
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
292261
///<param name="inputArray">Should be sorted.</param>
293262
let removeDuplications (clContext: ClContext) workGroupSize =
294263

295-
let setPositions = setPositions clContext
264+
let scatter = Scatter.runInplace clContext workGroupSize
296265
let getUniqueBitmap = getUniqueBitmap clContext
297266

298267
let prefixSumExclude =
@@ -318,6 +287,8 @@ module ClArray =
318287
a.[0]
319288

320289
let outputArray =
321-
setPositions processor workGroupSize inputArray positions resultLength
290+
clContext.CreateClArrayWithGPUOnlyFlags resultLength
291+
292+
scatter processor positions inputArray outputArray
322293

323294
outputArray

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111

1212
<ItemGroup>
1313
<Compile Include="AssemblyInfo.fs" />
14+
<Compile Include="Common\Scatter.fs" />
1415
<Compile Include="Common/Quotes.fs" />
1516
<Compile Include="Common/Utils.fs" />
1617
<Compile Include="Common/Sum.fs" />
1718
<Compile Include="Common/PrefixSum.fs" />
1819
<Compile Include="Common/ClArray.fs" />
1920
<Compile Include="Common/BitonicSort.fs" />
20-
<Compile Include="Common/Scatter.fs" />
2121
<Compile Include="Common/StandardOperations.fs" />
2222
<Compile Include="Common/Reduce.fs" />
2323
<Compile Include="Predefined/PrefixSum.fs" />

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ module COOMatrix =
172172

173173
let mutable rightEdge = firstSide - 1
174174

175-
if rightEdge > diagonalNumber then
175+
if rightEdge > diagonalNumber then // TODO()
176176
rightEdge <- diagonalNumber
177177

178178
while leftEdge <= rightEdge do
@@ -233,7 +233,7 @@ module COOMatrix =
233233

234234
let mutable rightEdge = firstLocalLength - 1
235235

236-
if rightEdge > localID then
236+
if rightEdge > localID then // TODO()
237237
rightEdge <- localID
238238

239239
while leftEdge <= rightEdge do

src/GraphBLAS-sharp.Backend/Vector/DenseVector/DenseVector.fs

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

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

tests/GraphBLAS-sharp.Tests/Common/RemoveDuplicates.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ let logger = Log.create "RemoveDuplicates.Tests"
1212
let context = Context.defaultContext.ClContext
1313

1414
let testCases =
15-
let removeDuplicates_wg_1 = ClArray.removeDuplications context 1
1615
let removeDuplicates_wg_2 = ClArray.removeDuplications context 2
1716
let removeDuplicates_wg_32 = ClArray.removeDuplications context 32
1817
let q = Context.defaultContext.Queue

tests/GraphBLAS-sharp.Tests/Program.fs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ let matrixTests =
1616
let commonTests =
1717
testList
1818
"Common tests"
19-
[ Common.BitonicSort.tests
20-
Common.PrefixSum.tests
21-
Common.Scatter.tests
19+
[
20+
// [ Common.BitonicSort.tests
21+
// Common.PrefixSum.tests
22+
// Common.Scatter.tests
2223
Common.RemoveDuplicates.tests
23-
Common.Copy.tests
24-
Common.Replicate.tests
25-
Common.Reduce.tests
26-
Common.Sum.tests ]
24+
// Common.Copy.tests
25+
// Common.Replicate.tests
26+
// Common.Reduce.tests
27+
// Common.Sum.tests ]
28+
]
2729
|> testSequenced
2830

2931
let vectorTests =
@@ -53,9 +55,10 @@ let allTests =
5355
testList
5456
"All tests"
5557
[ commonTests
56-
matrixTests
57-
vectorTests
58-
algorithmsTests ]
58+
//matrixTests
59+
//vectorTests
60+
//algorithmsTests ]
61+
]
5962
|> testSequenced
6063

6164
[<EntryPoint>]

0 commit comments

Comments
 (0)