@@ -258,20 +258,21 @@ module SparseVector =
258258 =
259259
260260 let kernel =
261- clContext.Compile( Map2.prepareFillVector op)
261+ clContext.Compile( Map2.prepareFillGeneral op)
262262
263- fun ( processor : MailboxProcessor < _ >) ( allIndices : ClArray < int > ) ( leftValues : ClArray < 'a >) ( rightValues : ClArray < 'b >) ( value : ClCell < 'a >) ( isLeft : ClArray < int >) ->
263+ fun ( processor : MailboxProcessor < _ >) ( vectorLenght : int) ( leftValues : ClArray < 'a >) ( leftIndices : ClArray < int >) ( rightValues : ClArray < 'b >) ( rightIndices : ClArray < int >) ( value : ClCell < 'a >) ->
264264
265- let length = allIndices.Length
265+ let resultBitmap =
266+ clContext.CreateClArrayWithSpecificAllocationMode< int>( DeviceOnly, vectorLenght)
266267
267- let allValues =
268- clContext.CreateClArrayWithSpecificAllocationMode< 'a >( DeviceOnly, length )
268+ let resultIndices =
269+ clContext.CreateClArrayWithSpecificAllocationMode< int >( DeviceOnly, vectorLenght )
269270
270- let positions =
271- clContext.CreateClArrayWithSpecificAllocationMode( DeviceOnly, length )
271+ let resultValues =
272+ clContext.CreateClArrayWithSpecificAllocationMode< 'a > ( DeviceOnly, vectorLenght )
272273
273274 let ndRange =
274- Range1D.CreateValid( length , workGroupSize)
275+ Range1D.CreateValid( vectorLenght , workGroupSize)
275276
276277 let kernel = kernel.GetKernel()
277278
@@ -280,26 +281,31 @@ module SparseVector =
280281 ( fun () ->
281282 kernel.KernelFunc
282283 ndRange
283- length
284- allIndices
284+ vectorLenght
285+ leftValues.Length
286+ rightValues.Length
285287 leftValues
288+ leftIndices
286289 rightValues
290+ rightIndices
287291 value
288- isLeft
289- allValues
290- positions )
292+ resultBitmap
293+ resultValues
294+ resultIndices )
291295 )
292296
293297 processor.Post( Msg.CreateRunMsg<_, _>( kernel))
294298
295- allValues , positions
299+ resultBitmap , resultValues , resultIndices
296300
297301 ///<param name =" clContext " >.</param >
298302 ///<param name =" op " >.</param >
299303 ///<param name =" workGroupSize " >Should be a power of 2 and greater than 1.</param >
300- let fillSubVector < 'a , 'b when 'a : struct and 'b : struct > ( clContext : ClContext ) op workGroupSize =
301-
302- let merge = merge clContext workGroupSize
304+ let fillSubVector < 'a , 'b when 'a : struct and 'b : struct >
305+ ( clContext : ClContext )
306+ op
307+ workGroupSize
308+ =
303309
304310 let prepare =
305311 preparePositionsFillSubVector clContext op workGroupSize
@@ -308,27 +314,20 @@ module SparseVector =
308314
309315 fun ( processor : MailboxProcessor < _ >) allocationMode ( leftVector : ClVector.Sparse < 'a >) ( rightVector : ClVector.Sparse < 'b >) ( value : ClCell < 'a >) ->
310316
311- let allIndices , leftValues , rightValues , isLeft =
312- merge processor leftVector.Indices leftVector.Values rightVector.Indices rightVector.Values
313-
314- let allValues , positions =
315- prepare processor allIndices leftValues rightValues value isLeft
316-
317- processor.Post( Msg.CreateFreeMsg<_>( leftValues))
318- processor.Post( Msg.CreateFreeMsg<_>( rightValues))
319- processor.Post( Msg.CreateFreeMsg<_>( isLeft))
317+ let bitmap , values , indices =
318+ prepare processor leftVector.Size leftVector.Values leftVector.Indices rightVector.Values rightVector.Indices value
320319
321320 let resultValues , resultIndices =
322- setPositions processor allocationMode allValues allIndices positions
321+ setPositions processor allocationMode values indices bitmap
323322
324- processor.Post( Msg.CreateFreeMsg<_>( allIndices ))
325- processor.Post( Msg.CreateFreeMsg<_>( allValues ))
326- processor.Post( Msg.CreateFreeMsg<_>( positions ))
323+ processor.Post( Msg.CreateFreeMsg<_>( indices ))
324+ processor.Post( Msg.CreateFreeMsg<_>( values ))
325+ processor.Post( Msg.CreateFreeMsg<_>( bitmap ))
327326
328327 { Context = clContext
329328 Values = resultValues
330329 Indices = resultIndices
331- Size = max leftVector.Size rightVector.Size }
330+ Size = rightVector.Size }
332331
333332 let toDense ( clContext : ClContext ) workGroupSize =
334333
0 commit comments