File tree Expand file tree Collapse file tree
src/GraphBLAS-sharp.Backend/Common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,10 +8,10 @@ module SubSum =
88 fun step lid wgSize ( localBuffer : 'a []) ->
99 let i = step * ( lid + 1 ) - 1
1010
11- let buff =
12- (% opAdd ) localBuffer .[ i - ( step >>> 1 )] localBuffer.[ i]
11+ let firstValue = localBuffer .[ i - ( step >>> 1 )]
12+ let secondValue = localBuffer.[ i]
1313
14- localBuffer.[ i] <- buff
14+ localBuffer.[ i] <- (% opAdd ) firstValue secondValue
1515 @>
1616
1717 let private sequentialAccess < 'a > opAdd =
@@ -23,7 +23,7 @@ module SubSum =
2323 localBuffer.[ lid] <- (% opAdd) firstValue secondValue
2424 @>
2525
26- let sumGeneral < 'a > memoryAccess =
26+ let private sumGeneral < 'a > memoryAccess =
2727 <@
2828 fun wgSize lid ( localBuffer : 'a []) ->
2929 let mutable step = 2
@@ -39,7 +39,7 @@ module SubSum =
3939
4040 let sequentialSum < 'a > opAdd = sumGeneral< 'a> <| sequentialAccess< 'a> opAdd
4141
42- let treeSum < 'a > opAdd = sumGeneral< 'a> <| treeAccess opAdd
42+ let treeSum < 'a > opAdd = sumGeneral< 'a> <| treeAccess< 'a > opAdd
4343
4444module PreparePositions =
4545 let both < 'c > =
Original file line number Diff line number Diff line change 11namespace GraphBLAS.FSharp.Backend.Common
22
33open Brahma.FSharp
4+ open GraphBLAS.FSharp .Backend
45open Microsoft.FSharp .Quotations
56
67module internal PrefixSum =
@@ -47,6 +48,8 @@ module internal PrefixSum =
4748 workGroupSize
4849 =
4950
51+ let subSum = SubSum.treeSum opAdd
52+
5053 let scan =
5154 <@ fun ( ndRange : Range1D ) inputArrayLength verticesLength ( resultBuffer : ClArray < 'a >) ( verticesBuffer : ClArray < 'a >) ( totalSumBuffer : ClCell < 'a >) ( zero : ClCell < 'a >) ( mirror : ClCell < bool >) ->
5255
@@ -68,23 +71,10 @@ module internal PrefixSum =
6871 else
6972 resultLocalBuffer.[ localID] <- zero
7073
71- let mutable step = 2
72-
73- while step <= workGroupSize do
74- barrierLocal ()
75-
76- if localID < workGroupSize / step then
77- let i = step * ( localID + 1 ) - 1
78-
79- let buff =
80- (% opAdd) resultLocalBuffer.[ i - ( step >>> 1 )] resultLocalBuffer.[ i]
81-
82- resultLocalBuffer.[ i] <- buff
83-
84- step <- step <<< 1
85-
8674 barrierLocal ()
8775
76+ (% subSum) workGroupSize localID resultLocalBuffer
77+
8878 if localID = workGroupSize - 1 then
8979 if verticesLength <= 1 && localID = gid then
9080 totalSumBuffer.Value <- resultLocalBuffer.[ localID]
@@ -93,7 +83,7 @@ module internal PrefixSum =
9383 (% beforeLocalSumClear) resultBuffer resultLocalBuffer.[ localID] inputArrayLength gid i
9484 resultLocalBuffer.[ localID] <- zero
9585
96- step <- workGroupSize
86+ let mutable step = workGroupSize
9787
9888 while step > 1 do
9989 barrierLocal ()
Original file line number Diff line number Diff line change @@ -54,8 +54,6 @@ module internal Sum =
5454
5555 processor.Post( Msg.CreateRunMsg<_, _>( kernel))
5656
57- ()
58-
5957 let private scanToCell
6058 ( clContext : ClContext )
6159 ( workGroupSize : int )
You can’t perform that action at this time.
0 commit comments