@@ -95,30 +95,17 @@ module DenseVector =
9595 let getBitmap = ClArray.map clContext workGroupSize <| Map.option 1 0
9696
9797 let prefixSum =
98- PrefixSum.standardExcludeInplace clContext workGroupSize
98+ PrefixSum.standardExcludeInplaceLengthToHost clContext workGroupSize
9999
100100 let allIndices = ClArray.init clContext workGroupSize <@ id @>
101101
102102 let allValues = ClArray.map clContext workGroupSize Map.optionToValueOrZero
103103
104- let resultLength = Array.zeroCreate< int> 1
105-
106104 fun ( processor : MailboxProcessor < _ >) allocationMode ( vector : ClArray < 'a option >) ->
107105
108106 let positions = getBitmap processor DeviceOnly vector
109107
110- let resultLengthGpu = clContext.CreateClCell 0
111-
112- let _ , r =
113- prefixSum processor positions resultLengthGpu
114-
115- let resultLength =
116- let res =
117- processor.PostAndReply( fun ch -> Msg.CreateToHostMsg<_>( r, resultLength, ch))
118-
119- processor.Post( Msg.CreateFreeMsg<_>( r))
120-
121- res.[ 0 ]
108+ let resultLength = prefixSum processor positions
122109
123110 // compute result indices
124111 let resultIndices =
@@ -131,11 +118,11 @@ module DenseVector =
131118 processor.Post <| Msg.CreateFreeMsg<_>( allIndices)
132119
133120 // compute result values
134- let allValues = allValues processor DeviceOnly vector
135-
136121 let resultValues =
137122 clContext.CreateClArrayWithSpecificAllocationMode< 'a>( allocationMode, resultLength)
138123
124+ let allValues = allValues processor DeviceOnly vector
125+
139126 scatterValues processor positions allValues resultValues
140127
141128 processor.Post <| Msg.CreateFreeMsg<_>( allValues)
0 commit comments