Skip to content

Commit 32b27ba

Browse files
committed
add: allocation first kronecker
1 parent e1a9e5b commit 32b27ba

12 files changed

Lines changed: 998 additions & 109 deletions

File tree

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,36 @@ 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: ClCell<'a>) (inputArray: ClArray<'b>) ->
176+
177+
let result =
178+
clContext.CreateClArrayWithSpecificAllocationMode(allocationMode, inputArray.Length)
179+
180+
let ndRange =
181+
Range1D.CreateValid(inputArray.Length, workGroupSize)
182+
183+
let kernel = kernel.GetKernel()
184+
185+
processor.Post(
186+
Msg.MsgSetArguments(fun () -> kernel.KernelFunc ndRange inputArray.Length value inputArray result)
187+
)
188+
189+
processor.Post(Msg.CreateRunMsg<_, _>(kernel))
190+
191+
result
192+
163193
let map2InPlace<'a, 'b, 'c> (map: Expr<'a -> 'b -> 'c>) (clContext: ClContext) workGroupSize =
164194

165195
let kernel =

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<Compile Include="Matrix/CSR/Merge.fs" />
5555
<Compile Include="Matrix/CSR/Map2.fs" />
5656
<Compile Include="Matrix/CSR/Map.fs" />
57+
<Compile Include="Matrix/CSR/Kronecker.fs" />
5758
<Compile Include="Matrix/CSR/Matrix.fs" />
5859
<Compile Include="Matrix/LIL/Matrix.fs" />
5960
<Compile Include="Matrix/SpGeMM/Expand.fs" />

0 commit comments

Comments
 (0)