Skip to content

Kronecker #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 16, 2023
32 changes: 32 additions & 0 deletions src/GraphBLAS-sharp.Backend/Common/ClArray.fs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,38 @@ module ClArray =

result

let mapWithValue<'a, 'b, 'c> (clContext: ClContext) workGroupSize (op: Expr<'a -> 'b -> 'c>) =

let map =
<@ fun (ndRange: Range1D) lenght (value: ClCell<'a>) (inputArray: ClArray<'b>) (result: ClArray<'c>) ->

let gid = ndRange.GlobalID0

if gid < lenght then
result.[gid] <- (%op) value.Value inputArray.[gid] @>

let kernel = clContext.Compile map

fun (processor: MailboxProcessor<_>) allocationMode (value: 'a) (inputArray: ClArray<'b>) ->

let result =
clContext.CreateClArrayWithSpecificAllocationMode(allocationMode, inputArray.Length)

let valueClCell = value |> clContext.CreateClCell

let ndRange =
Range1D.CreateValid(inputArray.Length, workGroupSize)

let kernel = kernel.GetKernel()

processor.Post(
Msg.MsgSetArguments(fun () -> kernel.KernelFunc ndRange inputArray.Length valueClCell inputArray result)
)

processor.Post(Msg.CreateRunMsg<_, _>(kernel))

result

let map2InPlace<'a, 'b, 'c> (map: Expr<'a -> 'b -> 'c>) (clContext: ClContext) workGroupSize =

let kernel =
Expand Down
2 changes: 2 additions & 0 deletions src/GraphBLAS-sharp.Backend/GraphBLAS-sharp.Backend.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<Compile Include="Vector/Sparse/Common.fs" />
<Compile Include="Vector/Sparse/Merge.fs" />
<Compile Include="Vector/Sparse/Map2.fs" />
<Compile Include="Vector/Sparse/Map.fs" />
<Compile Include="Vector/Sparse/Vector.fs" />
<Compile Include="Vector/SpMV.fs" />
<Compile Include="Vector/Vector.fs" />
Expand All @@ -54,6 +55,7 @@
<Compile Include="Matrix/CSR/Merge.fs" />
<Compile Include="Matrix/CSR/Map2.fs" />
<Compile Include="Matrix/CSR/Map.fs" />
<Compile Include="Matrix/CSR/Kronecker.fs" />
<Compile Include="Matrix/CSR/Matrix.fs" />
<Compile Include="Matrix/LIL/Matrix.fs" />
<Compile Include="Matrix/SpGeMM/Expand.fs" />
Expand Down
Loading