@@ -5,6 +5,7 @@ open Microsoft.FSharp.Quotations
55open GraphBLAS.FSharp .Backend .Objects .ClContext
66open GraphBLAS.FSharp .Backend .Objects .ClCell
77open GraphBLAS.FSharp .Backend .Quotes
8+ open GraphBLAS.FSharp .Backend .Objects .ArraysExtensions
89
910module ClArray =
1011 let init ( clContext : ClContext ) workGroupSize ( initializer : Expr < int -> 'a >) =
@@ -33,30 +34,6 @@ module ClArray =
3334
3435 outputArray
3536
36- let assignManyInit ( clContext : ClContext ) workGroupSize ( initializer : Expr < int -> 'a >) =
37-
38- let init =
39- <@ fun ( range : Range1D ) indicesLength ( indices : ClArray < int >) ( outputBuffer : ClArray < 'a >) ->
40-
41- let gid = range.GlobalID0
42-
43- if gid < indicesLength then
44- let targetIndex = indices.[ gid]
45-
46- outputBuffer.[ targetIndex] <- (% initializer) gid @>
47-
48- let program = clContext.Compile( init)
49-
50- fun ( processor : MailboxProcessor < _ >) ( indices : ClArray < int >) ( result : ClArray < 'a >) ->
51-
52- let kernel = program.GetKernel()
53-
54- let ndRange =
55- Range1D.CreateValid( indices.Length, workGroupSize)
56-
57- processor.Post( Msg.MsgSetArguments( fun () -> kernel.KernelFunc ndRange indices.Length indices result))
58- processor.Post( Msg.CreateRunMsg<_, _> kernel)
59-
6037 let create ( clContext : ClContext ) workGroupSize =
6138
6239 let create =
@@ -315,6 +292,24 @@ module ClArray =
315292
316293 resultArray
317294
295+ let getUniqueBitmap2 < 'a when 'a : equality > ( clContext : ClContext ) workGroupSize =
296+
297+ let map = map2 clContext workGroupSize <@ fun x y -> if x = 1 && y = 1 then 1 else 0 @>
298+
299+ let getUniqueBitmap = getUniqueBitmap clContext workGroupSize
300+
301+ fun ( processor : MailboxProcessor < _ >) allocationMode ( firstArray : ClArray < 'a >) ( secondArray : ClArray < 'a >) ->
302+ let firstBitmap = getUniqueBitmap processor DeviceOnly firstArray
303+
304+ let secondBitmap = getUniqueBitmap processor DeviceOnly secondArray
305+
306+ let result = map processor allocationMode firstBitmap secondBitmap
307+
308+ firstBitmap.Free processor
309+ secondBitmap.Free processor
310+
311+ result
312+
318313 let choose < 'a , 'b > ( clContext : ClContext ) workGroupSize ( predicate : Expr < 'a -> 'b option >) =
319314 let getBitmap =
320315 map< 'a, int> clContext workGroupSize
@@ -353,3 +348,14 @@ module ClArray =
353348 scatter processor positions values result
354349
355350 result
351+
352+ let iterate ( clContext : ClContext ) workGroupSize iterator =
353+
354+ let create = create clContext workGroupSize iterator
355+
356+ let scatter = Scatter.runInplace clContext workGroupSize
357+
358+ fun ( processor : MailboxProcessor < _ >) allocationMode ( inputArray : ClArray < 'a >) ( resultArray : ClArray < 'a >) ->
359+
360+ let positions = create processor allocationMode
361+
0 commit comments