@@ -4,20 +4,49 @@ open Brahma.FSharp.OpenCL
44open Microsoft.FSharp .Quotations
55
66module Matrix =
7+ let copy ( clContext : ClContext ) =
8+ let copy = GraphBLAS.FSharp.Backend.ClArray.copy clContext
9+ let copyData = GraphBLAS.FSharp.Backend.ClArray.copy clContext
10+
11+ fun ( processor : MailboxProcessor < _ >) workGroupSize ( matrix : Matrix < 'a >) ->
12+ match matrix with
13+ | MatrixCOO m ->
14+ let res =
15+ { Context = clContext
16+ RowCount = m.RowCount
17+ ColumnCount = m.ColumnCount
18+ Rows = copy processor workGroupSize m.Rows
19+ Columns = copy processor workGroupSize m.Columns
20+ Values = copyData processor workGroupSize m.Values
21+ }
22+ MatrixCOO res
23+ | MatrixCSR m ->
24+ let res =
25+ { Context = clContext
26+ RowCount = m.RowCount
27+ ColumnCount = m.ColumnCount
28+ RowPointers = copy processor workGroupSize m.RowPointers
29+ Columns = copy processor workGroupSize m.Columns
30+ Values = copyData processor workGroupSize m.Values
31+ }
32+ MatrixCSR res
33+
734 let toCSR ( clContext : ClContext ) workGroupSize =
835 let toCSR = COOMatrix.toCSR clContext workGroupSize
36+ let copy = copy clContext
937
1038 fun ( processor : MailboxProcessor < _ >) ( matrix : Matrix < 'a >) ->
1139 match matrix with
1240 | MatrixCOO m -> toCSR processor m |> MatrixCSR
13- | MatrixCSR _ -> matrix
41+ | MatrixCSR _ -> copy processor workGroupSize matrix
1442
1543 let toCOO ( clContext : ClContext ) workGroupSize =
1644 let toCOO = CSRMatrix.toCOO clContext
45+ let copy = copy clContext
1746
1847 fun ( processor : MailboxProcessor < _ >) ( matrix : Matrix < 'a >) ->
1948 match matrix with
20- | MatrixCOO _ -> matrix
49+ | MatrixCOO _ -> copy processor workGroupSize matrix
2150 | MatrixCSR m -> toCOO workGroupSize processor m |> MatrixCOO
2251
2352 let eWiseAdd ( clContext : ClContext ) ( opAdd : Expr < 'a -> 'a -> 'a >) workGroupSize =
0 commit comments