@@ -40,32 +40,33 @@ module internal Map2 =
4040 let preparePositions ( op : Expr < 'a option -> 'b option -> 'c option >) =
4141 <@ fun ( ndRange : Range1D ) rowCount columnCount leftValuesLength rightValuesLength ( leftValues : ClArray < 'a >) ( leftRows : ClArray < int >) ( leftColumns : ClArray < int >) ( rightValues : ClArray < 'b >) ( rightRows : ClArray < int >) ( rightColumn : ClArray < int >) ( resultBitmap : ClArray < int >) ( resultValues : ClArray < 'c >) ( resultRows : ClArray < int >) ( resultColumns : ClArray < int >) ->
4242
43- let gid = ndRange.GlobalID0
43+ let gid = ndRange.GlobalID0
4444
45- if gid < rowCount * columnCount then
45+ if gid < rowCount * columnCount then
4646
47- let columnIndex = gid % columnCount
48- let rowIndex = gid / columnCount
47+ let columnIndex = gid % columnCount
48+ let rowIndex = gid / columnCount
4949
50- let index = ( uint64 rowIndex <<< 32 ) ||| ( uint64 columnIndex)
50+ let index =
51+ ( uint64 rowIndex <<< 32 ) ||| ( uint64 columnIndex)
5152
52- let leftValue =
53- (% binSearch) leftValuesLength index leftRows leftColumns leftValues
53+ let leftValue =
54+ (% binSearch) leftValuesLength index leftRows leftColumns leftValues
5455
55- let rightValue =
56- (% binSearch) rightValuesLength index rightRows rightColumn rightValues
56+ let rightValue =
57+ (% binSearch) rightValuesLength index rightRows rightColumn rightValues
5758
58- match (% op) leftValue rightValue with
59- | Some value ->
60- resultValues.[ gid] <- value
61- resultRows.[ gid] <- rowIndex
62- resultColumns.[ gid] <- columnIndex
59+ match (% op) leftValue rightValue with
60+ | Some value ->
61+ resultValues.[ gid] <- value
62+ resultRows.[ gid] <- rowIndex
63+ resultColumns.[ gid] <- columnIndex
6364
64- resultBitmap.[ gid] <- 1
65- | None ->
66- resultBitmap.[ gid] <- 0 @>
65+ resultBitmap.[ gid] <- 1
66+ | None -> resultBitmap.[ gid] <- 0 @>
6767
68- let kernel = clContext.Compile <| preparePositions opAdd
68+ let kernel =
69+ clContext.Compile <| preparePositions opAdd
6970
7071 fun ( processor : MailboxProcessor < _ >) rowCount columnCount ( leftValues : ClArray < 'a >) ( leftRows : ClArray < int >) ( leftColumns : ClArray < int >) ( rightValues : ClArray < 'b >) ( rightRows : ClArray < int >) ( rightColumns : ClArray < int >) ->
7172
@@ -83,51 +84,64 @@ module internal Map2 =
8384 let resultValues =
8485 clContext.CreateClArrayWithSpecificAllocationMode< 'c>( DeviceOnly, resultLength)
8586
86- let ndRange = Range1D.CreateValid( resultLength, workGroupSize)
87+ let ndRange =
88+ Range1D.CreateValid( resultLength, workGroupSize)
8789
8890 let kernel = kernel.GetKernel()
8991
9092 processor.Post(
91- Msg.MsgSetArguments(
92- fun () ->
93- kernel.KernelFunc
94- ndRange
95- rowCount
96- columnCount
97- leftValues.Length
98- rightValues.Length
99- leftValues
100- leftRows
101- leftColumns
102- rightValues
103- rightRows
104- rightColumns
105- resultBitmap
106- resultValues
107- resultRows
108- resultColumns))
93+ Msg.MsgSetArguments
94+ ( fun () ->
95+ kernel.KernelFunc
96+ ndRange
97+ rowCount
98+ columnCount
99+ leftValues.Length
100+ rightValues.Length
101+ leftValues
102+ leftRows
103+ leftColumns
104+ rightValues
105+ rightRows
106+ rightColumns
107+ resultBitmap
108+ resultValues
109+ resultRows
110+ resultColumns)
111+ )
109112
110113 processor.Post( Msg.CreateRunMsg<_, _> kernel)
111114
112115 resultBitmap, resultValues, resultRows, resultColumns
113116
114- ///<param name =" clContext " >.</param >
115- ///<param name =" opAdd " >.</param >
116- ///<param name =" workGroupSize " >Should be a power of 2 and greater than 1.</param >
117+ ///<param name =" clContext " >.</param >
118+ ///<param name =" opAdd " >.</param >
119+ ///<param name =" workGroupSize " >Should be a power of 2 and greater than 1.</param >
117120 let run < 'a , 'b , 'c when 'a : struct and 'b : struct and 'c : struct and 'c : equality >
118121 ( clContext : ClContext )
119122 ( opAdd : Expr < 'a option -> 'b option -> 'c option >)
120123 workGroupSize
121124 =
122125
123- let map2 = preparePositions clContext workGroupSize opAdd
126+ let map2 =
127+ preparePositions clContext workGroupSize opAdd
124128
125- let setPositions = Common.setPositions< 'c> clContext workGroupSize
129+ let setPositions =
130+ Common.setPositions< 'c> clContext workGroupSize
126131
127132 fun ( queue : MailboxProcessor < _ >) allocationMode ( matrixLeft : ClMatrix.COO < 'a >) ( matrixRight : ClMatrix.COO < 'b >) ->
128133
129134 let bitmap , values , rows , columns =
130- map2 queue matrixLeft.RowCount matrixLeft.ColumnCount matrixLeft.Values matrixLeft.Rows matrixLeft.Columns matrixRight.Values matrixRight.Rows matrixRight.Columns
135+ map2
136+ queue
137+ matrixLeft.RowCount
138+ matrixLeft.ColumnCount
139+ matrixLeft.Values
140+ matrixLeft.Rows
141+ matrixLeft.Columns
142+ matrixRight.Values
143+ matrixRight.Rows
144+ matrixRight.Columns
131145
132146 let resultRows , resultColumns , resultValues , _ =
133147 setPositions queue allocationMode rows columns values bitmap
0 commit comments