@@ -498,84 +498,6 @@ module COOMatrix =
498498 Columns = matrix.Columns
499499 Values = matrix.Values }
500500
501- let private preparePositionsAtLeastOne < 'a , 'b , 'c when 'a : struct and 'b : struct and 'c : struct and 'c : equality >
502- ( clContext : ClContext )
503- ( opAdd : Expr < AtLeastOne < 'a , 'b > -> 'c option >)
504- workGroupSize
505- =
506-
507- let preparePositions =
508- <@ fun ( ndRange : Range1D ) length ( allRowsBuffer : ClArray < int >) ( allColumnsBuffer : ClArray < int >) ( leftValuesBuffer : ClArray < 'a >) ( rightValuesBuffer : ClArray < 'b >) ( allValuesBuffer : ClArray < 'c >) ( rawPositionsBuffer : ClArray < int >) ( isLeftBitmap : ClArray < int >) ->
509-
510- let i = ndRange.GlobalID0
511-
512- if ( i < length - 1
513- && allRowsBuffer.[ i] = allRowsBuffer.[ i + 1 ]
514- && allColumnsBuffer.[ i] = allColumnsBuffer.[ i + 1 ]) then
515-
516- let result =
517- (% opAdd) ( Both( leftValuesBuffer.[ i + 1 ], rightValuesBuffer.[ i]))
518-
519- (% PreparePositions.both) i result rawPositionsBuffer allValuesBuffer
520- elif ( i > 0
521- && i < length
522- && ( allRowsBuffer.[ i] <> allRowsBuffer.[ i - 1 ]
523- || allColumnsBuffer.[ i] <> allColumnsBuffer.[ i - 1 ]))
524- || i = 0 then
525-
526- let leftResult = (% opAdd) ( Left leftValuesBuffer.[ i])
527- let rightResult = (% opAdd) ( Right rightValuesBuffer.[ i])
528-
529- (% PreparePositions.leftRight)
530- i
531- leftResult
532- rightResult
533- isLeftBitmap
534- allValuesBuffer
535- rawPositionsBuffer @>
536-
537- let kernel = clContext.Compile( preparePositions)
538-
539- fun ( processor : MailboxProcessor < _ >) ( allRows : ClArray < int >) ( allColumns : ClArray < int >) ( leftValues : ClArray < 'a >) ( rightValues : ClArray < 'b >) ( isLeft : ClArray < int >) ->
540- let length = leftValues.Length
541-
542- let ndRange =
543- Range1D.CreateValid( length, workGroupSize)
544-
545- let rawPositionsGpu =
546- clContext.CreateClArray< int>(
547- length,
548- hostAccessMode = HostAccessMode.NotAccessible,
549- allocationMode = AllocationMode.Default
550- )
551-
552- let allValues =
553- clContext.CreateClArray< 'c>(
554- length,
555- hostAccessMode = HostAccessMode.NotAccessible,
556- allocationMode = AllocationMode.Default
557- )
558-
559- let kernel = kernel.GetKernel()
560-
561- processor.Post(
562- Msg.MsgSetArguments
563- ( fun () ->
564- kernel.KernelFunc
565- ndRange
566- length
567- allRows
568- allColumns
569- leftValues
570- rightValues
571- allValues
572- rawPositionsGpu
573- isLeft)
574- )
575-
576- processor.Post( Msg.CreateRunMsg<_, _>( kernel))
577- rawPositionsGpu, allValues
578-
579501 ///<param name =" clContext " >.</param >
580502 ///<param name =" opAdd " >.</param >
581503 ///<param name =" workGroupSize " >Should be a power of 2 and greater than 1.</param >
@@ -585,46 +507,7 @@ module COOMatrix =
585507 workGroupSize
586508 =
587509
588- let merge = merge clContext workGroupSize
589-
590- let preparePositions =
591- preparePositionsAtLeastOne clContext opAdd workGroupSize
592-
593- let setPositions = setPositions< 'c> clContext workGroupSize
594-
595- fun ( queue : MailboxProcessor < _ >) ( matrixLeft : COOMatrix < 'a >) ( matrixRight : COOMatrix < 'b >) ->
596-
597- let allRows , allColumns , leftMergedValues , rightMergedValues , isLeft =
598- merge
599- queue
600- matrixLeft.Rows
601- matrixLeft.Columns
602- matrixLeft.Values
603- matrixRight.Rows
604- matrixRight.Columns
605- matrixRight.Values
606-
607- let rawPositions , allValues =
608- preparePositions queue allRows allColumns leftMergedValues rightMergedValues isLeft
609-
610- queue.Post( Msg.CreateFreeMsg<_>( leftMergedValues))
611- queue.Post( Msg.CreateFreeMsg<_>( rightMergedValues))
612-
613- let resultRows , resultColumns , resultValues , resultLength =
614- setPositions queue allRows allColumns allValues rawPositions
615-
616- queue.Post( Msg.CreateFreeMsg<_>( isLeft))
617- queue.Post( Msg.CreateFreeMsg<_>( rawPositions))
618- queue.Post( Msg.CreateFreeMsg<_>( allRows))
619- queue.Post( Msg.CreateFreeMsg<_>( allColumns))
620- queue.Post( Msg.CreateFreeMsg<_>( allValues))
621-
622- { Context = clContext
623- RowCount = matrixLeft.RowCount
624- ColumnCount = matrixLeft.ColumnCount
625- Rows = resultRows
626- Columns = resultColumns
627- Values = resultValues }
510+ elementwise clContext ( StandardOperations.atLeastOneToNormalForm opAdd) workGroupSize
628511
629512 let transposeInplace ( clContext : ClContext ) workGroupSize =
630513
0 commit comments