Skip to content

Commit b494dab

Browse files
authored
Merge pull request #79 from artemiipatov/kronecker-alloc-first
Kronecker
2 parents e1a9e5b + 372aa56 commit b494dab

File tree

15 files changed

+1050
-11
lines changed

15 files changed

+1050
-11
lines changed

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

+32
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,38 @@ module ClArray =
160160

161161
result
162162

163+
let mapWithValue<'a, 'b, 'c> (clContext: ClContext) workGroupSize (op: Expr<'a -> 'b -> 'c>) =
164+
165+
let map =
166+
<@ fun (ndRange: Range1D) lenght (value: ClCell<'a>) (inputArray: ClArray<'b>) (result: ClArray<'c>) ->
167+
168+
let gid = ndRange.GlobalID0
169+
170+
if gid < lenght then
171+
result.[gid] <- (%op) value.Value inputArray.[gid] @>
172+
173+
let kernel = clContext.Compile map
174+
175+
fun (processor: MailboxProcessor<_>) allocationMode (value: 'a) (inputArray: ClArray<'b>) ->
176+
177+
let result =
178+
clContext.CreateClArrayWithSpecificAllocationMode(allocationMode, inputArray.Length)
179+
180+
let valueClCell = value |> clContext.CreateClCell
181+
182+
let ndRange =
183+
Range1D.CreateValid(inputArray.Length, workGroupSize)
184+
185+
let kernel = kernel.GetKernel()
186+
187+
processor.Post(
188+
Msg.MsgSetArguments(fun () -> kernel.KernelFunc ndRange inputArray.Length valueClCell inputArray result)
189+
)
190+
191+
processor.Post(Msg.CreateRunMsg<_, _>(kernel))
192+
193+
result
194+
163195
let map2InPlace<'a, 'b, 'c> (map: Expr<'a -> 'b -> 'c>) (clContext: ClContext) workGroupSize =
164196

165197
let kernel =

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

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<Compile Include="Vector/Sparse/Common.fs" />
4444
<Compile Include="Vector/Sparse/Merge.fs" />
4545
<Compile Include="Vector/Sparse/Map2.fs" />
46+
<Compile Include="Vector/Sparse/Map.fs" />
4647
<Compile Include="Vector/Sparse/Vector.fs" />
4748
<Compile Include="Vector/SpMV.fs" />
4849
<Compile Include="Vector/Vector.fs" />
@@ -54,6 +55,7 @@
5455
<Compile Include="Matrix/CSR/Merge.fs" />
5556
<Compile Include="Matrix/CSR/Map2.fs" />
5657
<Compile Include="Matrix/CSR/Map.fs" />
58+
<Compile Include="Matrix/CSR/Kronecker.fs" />
5759
<Compile Include="Matrix/CSR/Matrix.fs" />
5860
<Compile Include="Matrix/LIL/Matrix.fs" />
5961
<Compile Include="Matrix/SpGeMM/Expand.fs" />

0 commit comments

Comments
 (0)