Skip to content

Commit d0133ec

Browse files
committed
wip: Vector.map2
1 parent a79542d commit d0133ec

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,5 +489,3 @@ module ClArray =
489489
processor.Post(Msg.MsgSetArguments(fun () -> kernel.KernelFunc ndRange firstPosition (firstPosition + count) value targetArray))
490490

491491
processor.Post(Msg.CreateRunMsg<_, _>(kernel))
492-
493-
()

src/GraphBLAS-sharp.Backend/Quotes/Map.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ module Map =
2222
| Some _ -> 1
2323
| None -> 0 @>
2424

25+
let choose2Bitmap<'a, 'b, 'c> (map: Expr<'a -> 'b -> 'c option>) =
26+
<@ fun (leftItem: 'a) (rightItem: 'b) ->
27+
match (%map) leftItem rightItem with
28+
| Some _ -> 1
29+
| None -> 0 @>
30+
2531
let fst () = <@ fun fst _ -> fst @>
2632

2733
let snd () = <@ fun _ snd -> snd @>

src/GraphBLAS-sharp.Backend/Vector/Sparse/Map.fs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ open GraphBLAS.FSharp.Backend.Objects.ClContext
88
open GraphBLAS.FSharp.Backend.Quotes
99
open FSharp.Quotations
1010
open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions
11+
open GraphBLAS.FSharp.Backend.Common
1112

1213
module internal Map =
1314
let preparePositions<'a, 'b> (clContext: ClContext) workGroupSize opAdd =
@@ -97,3 +98,16 @@ module internal Map =
9798
Size = vector.Size }
9899

99100
module AtLeastOne =
101+
let run (clContext: ClContext) workGroupSize op =
102+
103+
let getOptionBitmap =
104+
ClArray.map2 clContext workGroupSize
105+
<| Map.choose2Bitmap op
106+
107+
let prefixSum = PrefixSum.standardExcludeInplace clContext workGroupSize
108+
109+
let scatter = Scatter.runInplace clContext workGroupSize
110+
111+
fun (processor: MailboxProcessor<_>) ->
112+
113+
()

0 commit comments

Comments
 (0)