Skip to content

Commit 0cfe112

Browse files
committed
add: ClArray.append
1 parent b30a9f8 commit 0cfe112

20 files changed

Lines changed: 148 additions & 174 deletions

File tree

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,36 @@ module ClArray =
411411
chunkBySizeLazy processor allocationMode chunkSize sourceArray
412412
|> Seq.map (fun lazyValue -> lazyValue.Value)
413413
|> Seq.toArray
414+
415+
let append<'a> (clContext: ClContext) workGroupSize =
416+
417+
let set =
418+
<@ fun (ndRange: Range1D) sourceArrayLength appendedArrayLength (inputArray: ClArray<'a>) (result: ClArray<'a>) ->
419+
420+
let gid = ndRange.GlobalID0
421+
422+
let resultPosition = gid + sourceArrayLength
423+
424+
if gid < appendedArrayLength then
425+
426+
result.[resultPosition] <- inputArray.[gid] @>
427+
428+
let kernel = clContext.Compile set
429+
430+
fun (processor: MailboxProcessor<_>) allocationMode (sourceArray: ClArray<'a>) (appendedArray: ClArray<'a>) ->
431+
432+
let resultLength = sourceArray.Length + appendedArray.Length
433+
434+
let result =
435+
clContext.CreateClArrayWithSpecificAllocationMode(allocationMode, resultLength)
436+
437+
let ndRange =
438+
Range1D.CreateValid(appendedArray.Length, workGroupSize)
439+
440+
let kernel = kernel.GetKernel()
441+
442+
processor.Post(Msg.MsgSetArguments(fun () -> kernel.KernelFunc ndRange sourceArray.Length appendedArray.Length appendedArray result))
443+
444+
processor.Post(Msg.CreateRunMsg<_, _>(kernel))
445+
446+
result

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

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,26 @@
3434
<Compile Include="Common/Sort/Radix.fs" />
3535
<Compile Include="Common/Sort/Bitonic.fs" />
3636
<Compile Include="Common/Sum.fs" />
37-
<!--Compile Include="Matrices.fs" /-->
38-
<Compile Include="Matrix/Common.fs" />
39-
<Compile Include="Matrix/COOMatrix/Map2.fs" />
40-
<Compile Include="Matrix/COOMatrix/Map2AtLeastOne.fs" />
41-
<Compile Include="Matrix/COOMatrix/Map.fs" />
42-
<Compile Include="Matrix/COOMatrix/Matrix.fs" />
43-
<Compile Include="Matrix/CSRMatrix/Map2.fs" />
44-
<Compile Include="Matrix/CSRMatrix/Map2AtLeastOne.fs" />
45-
<Compile Include="Matrix/CSRMatrix/SpGEMM.fs" />
46-
<Compile Include="Matrix/CSRMatrix/Map.fs" />
47-
<Compile Include="Matrix/CSRMatrix/Matrix.fs" />
48-
<Compile Include="Matrix\Split.fs" />
49-
<Compile Include="Matrix/Matrix.fs" />
5037
<Compile Include="Vector/SparseVector/Common.fs" />
5138
<Compile Include="Vector/SparseVector/Map2.fs" />
5239
<Compile Include="Vector/SparseVector/Map2AtLeastOne.fs" />
5340
<Compile Include="Vector/SparseVector/SparseVector.fs" />
5441
<Compile Include="Vector/DenseVector/DenseVector.fs" />
5542
<Compile Include="Vector/Vector.fs" />
5643
<Compile Include="Vector/SpMV.fs" />
44+
<Compile Include="Matrix/Common.fs" />
45+
<Compile Include="Matrix\COO\Map2.fs" />
46+
<Compile Include="Matrix\COO\Map2AtLeastOne.fs" />
47+
<Compile Include="Matrix\COO\Map.fs" />
48+
<Compile Include="Matrix\COO\Matrix.fs" />
49+
<Compile Include="Matrix\CSR\Map2.fs" />
50+
<Compile Include="Matrix\CSR\Map2AtLeastOne.fs" />
51+
<Compile Include="Matrix\CSR\SpGEMM.fs" />
52+
<Compile Include="Matrix\CSR\Map.fs" />
53+
<Compile Include="Matrix\CSR\Matrix.fs" />
54+
<Compile Include="Matrix\Rows\Matrix.fs" />
55+
<Compile Include="Matrix\Matrix.fs" />
5756
<Compile Include="Algorithms/BFS.fs" />
58-
<!--Compile Include="Backend/CSRMatrix/GetTuples.fs" /-->
59-
<!--Compile Include="Backend/CSRMatrix/SpMSpV.fs" /-->
60-
<!--Compile Include="Backend/CSRMatrix/Transpose.fs" /-->
61-
<!--Compile Include="Backend/COOVector/Utilities/SetPositions.fs" />
62-
<Compile Include="Backend/COOVector/Utilities/AssignSubVector/Intersect.fs" />
63-
<Compile Include="Backend/COOVector/Utilities/AssignSubVector/Filter.fs" />
64-
<Compile Include="Backend/COOVector/Utilities/AssignSubVector/PreparePositions.fs" />
65-
<Compile Include="Backend/COOVector/Utilities/EWiseAdd/Merge.fs" />
66-
<Compile Include="Backend/COOVector/Utilities/EWiseAdd/PreparePositions.fs" />
67-
<Compile Include="Backend/COOVector/Utilities/FillSubVector/Merge.fs" />
68-
<Compile Include="Backend/COOVector/Utilities/FillSubVector/PreparePositions.fs" />
69-
<Compile Include="Backend/COOVector/EWiseAdd.fs" />
70-
<Compile Include="Backend/COOVector/FillSubVector.fs" />
71-
<Compile Include="Backend/COOVector/AssignSubVector.fs" /-->
72-
<!--Compile Include="Backend/Mask/GetComplemented.fs" /-->
7357
</ItemGroup>
7458
<Import Project="..\..\.paket\Paket.Restore.targets" />
7559
</Project>
File renamed without changes.
File renamed without changes.

src/GraphBLAS-sharp.Backend/Matrix/COOMatrix/Map2AtLeastOne.fs renamed to src/GraphBLAS-sharp.Backend/Matrix/COO/Map2AtLeastOne.fs

File renamed without changes.
File renamed without changes.

src/GraphBLAS-sharp.Backend/Matrix/CSRMatrix/GetTuples.fs renamed to src/GraphBLAS-sharp.Backend/Matrix/CSR/GetTuples.fs

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/GraphBLAS-sharp.Backend/Matrix/CSRMatrix/Map2AtLeastOne.fs renamed to src/GraphBLAS-sharp.Backend/Matrix/CSR/Map2AtLeastOne.fs

File renamed without changes.

0 commit comments

Comments
 (0)