File tree Expand file tree Collapse file tree
src/GraphBLAS-sharp.Backend Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 <ItemGroup >
1010 <Compile Include =" AssemblyInfo.fs" />
1111 <Compile Include =" Common/Utils.fs" />
12- <Compile Include =" Common/ClArray.fs" />
12+ <Compile Include =" Common/ClArray.fs" />
1313 <Compile Include =" Common/Sum.fs" />
1414 <Compile Include =" Common/BitonicSort.fs" />
1515 <Compile Include =" Matrices.fs" />
16- <Compile Include =" COOMatrix/COOMatrix.fs" />
17- <Compile Include =" CSRMatrix/CSRMatrix.fs" />
16+ <Compile Include =" Matrix/COOMatrix/COOMatrix.fs" />
17+ <Compile Include =" Matrix/CSRMatrix/CSRMatrix.fs" />
18+ <Compile Include =" Matrix/CSRMatrix/SpGEMM.fs" />
19+ <Compile Include =" Matrix/CSRMatrix/SpMV.fs" />
20+ <Compile Include =" Matrix/Matrix.fs" />
1821 <!-- Compile Include="Backend/CSRMatrix/GetTuples.fs" /-->
19- <Compile Include =" CSRMatrix/SpGEMM.fs" />
2022 <!-- Compile Include="Backend/CSRMatrix/SpMSpV.fs" /-->
21- <Compile Include =" CSRMatrix/SpMV.fs" />
2223 <!-- Compile Include="Backend/CSRMatrix/Transpose.fs" /-->
2324 <!-- Compile Include="Backend/COOVector/Utilities/SetPositions.fs" />
2425 <Compile Include="Backend/COOVector/Utilities/AssignSubVector/Intersect.fs" />
Original file line number Diff line number Diff line change @@ -2,21 +2,39 @@ namespace GraphBLAS.FSharp.Backend
22
33open Brahma.FSharp .OpenCL
44
5- type CSRMatrix < 'elem when 'elem: struct > =
5+ type MatrixFromat =
6+ | CSR
7+ | COO
8+
9+ type Matrix < 'a when 'a: struct > =
10+ | MatrixCSR of CSRMatrix < 'a >
11+ | MatrixCOO of COOMatrix < 'a >
12+
13+ member this.RowCount =
14+ match this with
15+ | MatrixCSR matrix -> matrix.RowCount
16+ | MatrixCOO matrix -> matrix.RowCount
17+
18+ member this.ColumnCount =
19+ match this with
20+ | MatrixCSR matrix -> matrix.ColumnCount
21+ | MatrixCOO matrix -> matrix.ColumnCount
22+
23+ and CSRMatrix < 'elem when 'elem : struct > =
624 { RowCount: int
725 ColumnCount: int
826 RowPointers: ClArray < int >
927 Columns: ClArray < int >
1028 Values: ClArray < 'elem > }
1129
12- type TupleMatrix < 'elem when 'elem: struct > =
13- { RowIndices: ClArray < int >
14- ColumnIndices: ClArray < int >
15- Values: ClArray < 'elem > }
16-
17- type COOMatrix < 'elem when 'elem: struct > =
30+ and COOMatrix < 'elem when 'elem : struct > =
1831 { RowCount: int
1932 ColumnCount: int
2033 Rows: ClArray < int >
2134 Columns: ClArray < int >
2235 Values: ClArray < 'elem > }
36+
37+ and TupleMatrix < 'elem when 'elem : struct > =
38+ { RowIndices: ClArray < int >
39+ ColumnIndices: ClArray < int >
40+ Values: ClArray < 'elem > }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ namespace GraphBLAS.FSharp.Backend
2+
3+ open Brahma.FSharp .OpenCL
4+ open Microsoft.FSharp .Quotations
5+
6+ module Matrix =
7+ let toCSR ( clContext : ClContext ) workGroupSize processor matrix =
8+ let toCSR =
9+ COOMatrix.toCSR clContext workGroupSize processor
10+
11+ match matrix with
12+ | MatrixCOO m -> toCSR m |> MatrixCSR
13+ | MatrixCSR _ -> matrix
14+
15+ let toCOO ( clContext : ClContext ) workGroupSize processor matrix =
16+ let toCOO =
17+ CSRMatrix.toCOO clContext processor workGroupSize
18+
19+ match matrix with
20+ | MatrixCOO _ -> matrix
21+ | MatrixCSR m -> toCOO m |> MatrixCOO
22+
23+ let eWiseAdd ( clContext : ClContext ) ( opAdd : Expr < 'a -> 'a -> 'a >) workGroupSize processor matrix1 matrix2 =
24+ let COOeWiseAdd =
25+ COOMatrix.eWiseAdd clContext opAdd workGroupSize processor
26+
27+ let CSReWiseAdd =
28+ CSRMatrix.eWiseAdd clContext opAdd workGroupSize processor
29+
30+ match matrix1, matrix2 with
31+ | MatrixCOO m1, MatrixCOO m2 -> COOeWiseAdd m1 m2 |> MatrixCOO
32+ | MatrixCSR m1, MatrixCSR m2 -> CSReWiseAdd m1 m2 |> MatrixCSR
33+ | _ -> failwith " Matrix formats are not matching"
You can’t perform that action at this time.
0 commit comments