@@ -229,79 +229,25 @@ module Utils =
229229 random.NextBytes buffer
230230 System.BitConverter.ToSingle( buffer, 0 )
231231
232- let rowPointers2rowIndices ( rowPointers : int []) =
233- let rowIndices =
234- Array.zeroCreate rowPointers.[ rowPointers.Length - 1 ]
235-
236- [| 0 .. rowPointers.Length - 2 |]
237- |> Array.Parallel.iter
238- ( fun i ->
239- [| rowPointers.[ i] .. rowPointers.[ i + 1 ] - 1 |]
240- |> Array.Parallel.iter ( fun j -> rowIndices.[ j] <- i))
241-
242- rowIndices
243-
244- let rowIndices2rowPointers ( rowIndices : int []) rowCount =
245- let nnzPerRow = Array.zeroCreate rowCount
246- let rowPointers = Array.zeroCreate rowCount
247-
248- Array.iter ( fun rowIndex -> nnzPerRow.[ rowIndex] <- nnzPerRow.[ rowIndex] + 1 ) rowIndices
249-
250- for i in 1 .. rowCount - 1 do
251- rowPointers.[ i] <- rowPointers.[ i - 1 ] + nnzPerRow.[ i - 1 ]
252-
253- rowPointers
254-
255- let inline buildCooMatrix ( context : ClContext ) matrix =
256- match matrix with
257- | MatrixCOO m ->
258- let rows =
259- context.CreateClArray ( m.Rows, hostAccessMode = HostAccessMode.ReadOnly, deviceAccessMode = DeviceAccessMode.ReadOnly, allocationMode = AllocationMode.CopyHostPtr)
260-
261- let cols =
262- context.CreateClArray ( m.Columns, hostAccessMode = HostAccessMode.ReadOnly, deviceAccessMode = DeviceAccessMode.ReadOnly, allocationMode = AllocationMode.CopyHostPtr)
263-
264- let vals =
265- context.CreateClArray ( m.Values, hostAccessMode = HostAccessMode.ReadOnly, deviceAccessMode = DeviceAccessMode.ReadOnly, allocationMode = AllocationMode.CopyHostPtr)
266-
267- { Backend.COOMatrix.Context = context
268- Backend.COOMatrix.RowCount = m.RowCount
269- Backend.COOMatrix.ColumnCount = m.ColumnCount
270- Backend.COOMatrix.Rows = rows
271- Backend.COOMatrix.Columns = cols
272- Backend.COOMatrix.Values = vals }
273-
274- | x -> failwith " Unsupported matrix format: %A "
275-
276- let inline buildCsrMatrix ( context : ClContext ) matrix =
277- match matrix with
278- | MatrixCOO m ->
279- let rowPointers =
280- context.CreateClArray(
281- Utils.rowIndices2rowPointers m.Rows m.RowCount
282- , hostAccessMode = HostAccessMode.ReadOnly
283- , deviceAccessMode = DeviceAccessMode.ReadOnly
284- , allocationMode = AllocationMode.CopyHostPtr)
285-
286- let cols =
287- context.CreateClArray (
288- m.Columns
289- , hostAccessMode = HostAccessMode.ReadOnly
290- , deviceAccessMode = DeviceAccessMode.ReadOnly
291- , allocationMode = AllocationMode.CopyHostPtr)
292-
293- let vals =
294- context.CreateClArray (
295- m.Values
296- , hostAccessMode = HostAccessMode.ReadOnly
297- , deviceAccessMode = DeviceAccessMode.ReadOnly
298- , allocationMode = AllocationMode.CopyHostPtr)
299-
300- { Backend.CSRMatrix.Context = context
301- Backend.CSRMatrix.RowCount = m.RowCount
302- Backend.CSRMatrix.ColumnCount = m.ColumnCount
303- Backend.CSRMatrix.RowPointers = rowPointers
304- Backend.CSRMatrix.Columns = cols
305- Backend.CSRMatrix.Values = vals }
306-
307- | x -> failwith " Unsupported matrix format: %A "
232+ // let rowPointers2rowIndices (rowPointers: int []) =
233+ // let rowIndices =
234+ // Array.zeroCreate rowPointers.[rowPointers.Length - 1]
235+
236+ // [| 0 .. rowPointers.Length - 2 |]
237+ // |> Array.Parallel.iter
238+ // (fun i ->
239+ // [| rowPointers.[i] .. rowPointers.[i + 1] - 1 |]
240+ // |> Array.Parallel.iter (fun j -> rowIndices.[j] <- i))
241+
242+ // rowIndices
243+
244+ // let rowIndices2rowPointers (rowIndices: int []) rowCount =
245+ // let nnzPerRow = Array.zeroCreate rowCount
246+ // let rowPointers = Array.zeroCreate rowCount
247+
248+ // Array.iter (fun rowIndex -> nnzPerRow.[rowIndex] <- nnzPerRow.[rowIndex] + 1) rowIndices
249+
250+ // for i in 1 .. rowCount - 1 do
251+ // rowPointers.[i] <- rowPointers.[i - 1] + nnzPerRow.[i - 1]
252+
253+ // rowPointers
0 commit comments