|
1 | 1 | # GraphBLAS-sharp
|
2 | 2 |
|
3 |
| -GraphBLAS implementation in F#+OpenCL |
4 |
| - |
5 |
| ---- |
6 |
| - |
7 |
| -## Builds |
8 |
| - |
9 |
| -GitHub Actions | |
10 |
| -:---: | |
11 |
| -[](https://github.com/YaccConstructor/GraphBLAS-sharp/actions?query=branch%3Amaster) | |
12 |
| -[](https://github.com/YaccConstructor/GraphBLAS-sharp/actions?query=branch%3Amaster) | |
13 |
| - |
14 |
| -## NuGet |
15 |
| - |
16 |
| -Package | Stable | Prerelease |
17 |
| ---- | --- | --- |
18 |
| -GraphBLAS-sharp | [](https://www.nuget.org/packages/GraphBLAS-sharp/) | [](https://www.nuget.org/packages/GraphBLAS-sharp/) |
19 |
| - |
20 |
| ---- |
21 |
| - |
22 |
| -### Developing |
23 |
| - |
| 3 | +[](https://github.com/YaccConstructor/GraphBLAS-sharp/actions/workflows/build-on-push.yml) |
| 4 | +[](https://www.nuget.org/packages/GraphBLAS-sharp/) |
| 5 | +[](https://opensource.org/licenses/MIT) |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +GraphBLAS# is a GPGPU-based [GraphBLAS](https://graphblas.org/)-like API implementation in F#. To utilize GPGPUs we use [Brahma.FSharp](https://github.com/YaccConstructor/Brahma.FSharp). So, GraphBLAS# can utilize any OpenCL-compatible device. |
| 12 | + |
| 13 | +### Features |
| 14 | +- ```Option<'t>``` to solve [explicit/implicit zeroes problem](https://github.com/GraphBLAS/LAGraph/issues/28#issuecomment-542952115). If graph has labels of type ```'t``` then adjacency matrix is ```Matrix<Option<'t>>```. Sparse storage contains only values for ```Some<'t>``` cells. |
| 15 | +- Elementwise operations have type ```AtLeastOne<'t1,'t2> -> Option<'t3>``` to be shure that ```None op None``` is ```None```. Also developer explicitly controls what should be ```None```. ```AtLeastOne``` defined as fallows: |
| 16 | + ```fsharp |
| 17 | + type AtLeastOne<'t1, 't2> = |
| 18 | + | Both of 't1*'t2 |
| 19 | + | Left of 't1 |
| 20 | + | Right of 't2 |
| 21 | + ``` |
| 22 | + So, type of matrix-matrix elementwise oertion is ```Matrix<Option<'t1>> -> Matrix<Option<'t2>> -> (AtLeastOne<'t1,'t2> -> Option<'t3>) -> Matrix<Option<'t3>>```. |
| 23 | +- No semirings. Just functions. Ofcourse one can implement semirings on the top of provided API. |
| 24 | +- Minimal core: high-order functions allows us to minimaze core by functions unification. For example, such functions as matrix-matrix addition, matrix-matrix element-wise multiplication, masking all are partial case of `map2` function. |
| 25 | + |
| 26 | +### Operations |
| 27 | +- **Matrix-Matrix** |
| 28 | + - [x] COO-COO element-wize |
| 29 | + - [x] CSR-CSR element-wize |
| 30 | + - [ ] CSR-CSR multiplication |
| 31 | + - [ ] COO transpose |
| 32 | + - [ ] CSR transpose |
| 33 | +- **Vector-Matrix** |
| 34 | + - [x] Dense-CSR multiplication |
| 35 | + - [ ] COO-CSR multiplication |
| 36 | +- **Vector-Vector** |
| 37 | + - [x] Dense-Dense element-wise |
| 38 | + - [ ] ... |
| 39 | +- **Matrix** |
| 40 | + - [ ] `map` |
| 41 | + - [ ] `iter` |
| 42 | + - [ ] ... |
| 43 | +- **Vector** |
| 44 | + - [ ] `map` |
| 45 | + - [ ] `iter` |
| 46 | + - [ ] `filter` |
| 47 | + - [ ] `contains` |
| 48 | + - [ ] ... |
| 49 | + |
| 50 | +### Graph Analysis Algorithms |
| 51 | +- [ ] BFS |
| 52 | +- [ ] Parent BFS |
| 53 | +- [ ] Single Source Shortest Path |
| 54 | +- [ ] Triangles Counting |
| 55 | +- [ ] Local Clustering Coefficient |
| 56 | +- [ ] Community Detection using Label Propagation |
| 57 | +- [ ] Weakly Connected Components |
| 58 | +- [ ] PageRank |
| 59 | + |
| 60 | +### Evaluation |
| 61 | +Matrices from [SuiteSparse matrix collection](https://sparse.tamu.edu/) which we choose for evaluation. |
| 62 | +<table> |
| 63 | +<thead> |
| 64 | + <tr> |
| 65 | + <th>Matrix</th> |
| 66 | + <th>Size</th> |
| 67 | + <th>NNZ</th> |
| 68 | + <th>Squared matrix NNZ</th> |
| 69 | + </tr> |
| 70 | +</thead> |
| 71 | +<tbody> |
| 72 | + <tr> |
| 73 | + <td>wing</td> |
| 74 | + <td>62 032</td> |
| 75 | + <td>243 088</td> |
| 76 | + <td>714 200</td> |
| 77 | + </tr> |
| 78 | + <tr> |
| 79 | + <td>luxembourg osm</td> |
| 80 | + <td>114 599</td> |
| 81 | + <td>119 666</td> |
| 82 | + <td>393 261</td> |
| 83 | + </tr> |
| 84 | + <tr> |
| 85 | + <td>amazon0312</td> |
| 86 | + <td>400 727</td> |
| 87 | + <td>3 200 440</td> |
| 88 | + <td>14 390 544</td> |
| 89 | + </tr> |
| 90 | + <tr> |
| 91 | + <td>amazon-2008</td> |
| 92 | + <td>735 323</td> |
| 93 | + <td>5 158 388</td> |
| 94 | + <td>25 366 745</td> |
| 95 | + </tr> |
| 96 | + <tr> |
| 97 | + <td>web-Google</td> |
| 98 | + <td>916 428</td> |
| 99 | + <td>5 105 039</td> |
| 100 | + <td>29 710 164</td> |
| 101 | + </tr> |
| 102 | + <tr> |
| 103 | + <td>webbase-1M</td> |
| 104 | + <td>1 000 005</td> |
| 105 | + <td>3 105 536</td> |
| 106 | + <td>51 111 996</td> |
| 107 | + </tr> |
| 108 | + <tr> |
| 109 | + <td>cit-Patents</td> |
| 110 | + <td>3 774 768</td> |
| 111 | + <td>16 518 948</td> |
| 112 | + <td>469</td> |
| 113 | + </tr> |
| 114 | +</tbody> |
| 115 | +</table> |
| 116 | + |
| 117 | +Element-wise matrix-matrix evaluation results presented below. Time is measured in milliseconds. We perform our experiments on the PC with Ubuntu 20.04 installed and with the following hardware configuration: Intel Core i7–4790 CPU, 3.60GHz, 32GB DDR4 RAM with GeForce GTX 2070, 8GB GDDR6, 1.41GHz. |
| 118 | + |
| 119 | +<table> |
| 120 | +<thead> |
| 121 | + <tr> |
| 122 | + <th rowspan="3">Matrix</th> |
| 123 | + <th colspan="4">Elemint-wise addition</th> |
| 124 | + <th colspan="2">Elemint-wise multiplication</th> |
| 125 | + </tr> |
| 126 | + <tr> |
| 127 | + <th colspan="2">GraphBLAS-sharp</th> |
| 128 | + <th rowspan="2">SuiteSparse</th> |
| 129 | + <th rowspan="2">CUSP</th> |
| 130 | + <th rowspan="2">GraphBLAS-sharp</th> |
| 131 | + <th rowspan="2">SuiteSparse</th> |
| 132 | + </tr> |
| 133 | + <tr> |
| 134 | + <th>No AtLeastOne</th> |
| 135 | + <th>AtLeastOne</th> |
| 136 | + </tr> |
| 137 | +</thead> |
| 138 | +<tbody> |
| 139 | + <tr> |
| 140 | + <td>wing</td> |
| 141 | + <td>4,3 ± 0,8</td> |
| 142 | + <td>4,3 ± 0,6</td> |
| 143 | + <td>2,7 ± 0,9</td> |
| 144 | + <td>1,5 ± 0,0</td> |
| 145 | + <td>3,7 ± 0,5</td> |
| 146 | + <td>3,5 ± 0,4</td> |
| 147 | + </tr> |
| 148 | + <tr> |
| 149 | + <td>luxembourg osm</td> |
| 150 | + <td>4,9 ± 0,7</td> |
| 151 | + <td>4,1 ± 0,5</td> |
| 152 | + <td>3,0 ± 1,1</td> |
| 153 | + <td>1,2 ± 0,1</td> |
| 154 | + <td>3,8 ± 0,6</td> |
| 155 | + <td>3,0 ± 0,6</td> |
| 156 | + </tr> |
| 157 | + <tr> |
| 158 | + <td>amazon0312</td> |
| 159 | + <td>22,3 ± 1,3</td> |
| 160 | + <td>22,1 ± 1,3</td> |
| 161 | + <td>33,4 ± 0,8</td> |
| 162 | + <td>11,0 ± 1,4</td> |
| 163 | + <td>18,7 ± 0,9</td> |
| 164 | + <td>35,7 ± 1,4</td> |
| 165 | + </tr> |
| 166 | + <tr> |
| 167 | + <td>amazon-2008</td> |
| 168 | + <td>38,7 ± 0,8</td> |
| 169 | + <td>39,0 ± 1,0</td> |
| 170 | + <td>55,9 ± 1,0</td> |
| 171 | + <td>19,1 ± 1,4</td> |
| 172 | + <td>34,5 ± 1,0</td> |
| 173 | + <td>58,9 ± 1,9</td> |
| 174 | + </tr> |
| 175 | + <tr> |
| 176 | + <td>web-Google</td> |
| 177 | + <td>43,4 ± 0,8</td> |
| 178 | + <td>43,4 ± 1,1</td> |
| 179 | + <td>67,2 ± 7,5</td> |
| 180 | + <td>21,3 ± 1,3</td> |
| 181 | + <td>39,0 ± 1,2</td> |
| 182 | + <td>66,2 ± 0,4</td> |
| 183 | + </tr> |
| 184 | + <tr> |
| 185 | + <td>webbase-1M</td> |
| 186 | + <td>63,6 ± 1,1</td> |
| 187 | + <td>63,7 ± 1,3</td> |
| 188 | + <td>86,5 ± 2,0</td> |
| 189 | + <td>24,3 ± 1,3</td> |
| 190 | + <td>54,5 ± 0,7</td> |
| 191 | + <td>37,6 ± 5,6</td> |
| 192 | + </tr> |
| 193 | + <tr> |
| 194 | + <td>cit-Patents</td> |
| 195 | + <td>26,9 ± 0,7</td> |
| 196 | + <td>26,0 ± 0,7</td> |
| 197 | + <td>183,4 ± 5,4</td> |
| 198 | + <td>10,8 ± 0,6</td> |
| 199 | + <td>24,3 ± 0,7</td> |
| 200 | + <td>162,2 ± 1,7</td> |
| 201 | + </tr> |
| 202 | +</tbody> |
| 203 | +</table> |
| 204 | + |
| 205 | + |
| 206 | +## Contributing |
| 207 | +Contributions, issues and feature requests are welcome. |
| 208 | +Feel free to check [issues](https://github.com/YaccConstructor/GraphBLAS-sharp/issues) page if you want to contribute. |
| 209 | + |
| 210 | +## Build |
24 | 211 | Make sure the following **requirements** are installed on your system:
|
| 212 | +- [dotnet SDK](https://dotnet.microsoft.com/en-us/download/dotnet/5.0) 5.0 or higher |
| 213 | +- OpenCL-compatible device and respective OpenCL driver |
25 | 214 |
|
26 |
| -- [dotnet SDK](https://www.microsoft.com/net/download/core) 3.0 or higher |
27 |
| -- [Mono](http://www.mono-project.com/) if you're on Linux or macOS. |
28 |
| - |
29 |
| -or |
30 |
| - |
31 |
| -- [VSCode Dev Container](https://code.visualstudio.com/docs/remote/containers) |
32 |
| - |
33 |
| - |
34 |
| ---- |
35 |
| - |
36 |
| -### Environment Variables |
37 |
| - |
38 |
| -- `CONFIGURATION` will set the [configuration](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x#options) of the dotnet commands. If not set, it will default to Release. |
39 |
| - - `CONFIGURATION=Debug ./build.sh` will result in `-c` additions to commands such as in `dotnet build -c Debug` |
40 |
| -- `GITHUB_TOKEN` will be used to upload release notes and Nuget packages to GitHub. |
41 |
| - - Be sure to set this before releasing |
42 |
| -- `DISABLE_COVERAGE` Will disable running code coverage metrics. AltCover can have [severe performance degradation](https://github.com/SteveGilham/altcover/issues/57) so it's worth disabling when looking to do a quicker feedback loop. |
43 |
| - - `DISABLE_COVERAGE=1 ./build.sh` |
44 |
| - |
45 |
| - |
46 |
| ---- |
47 |
| - |
48 |
| -### Building |
49 |
| - |
50 |
| - |
51 |
| -```sh |
52 |
| -> build.cmd <optional buildtarget> // on windows |
53 |
| -$ ./build.sh <optional buildtarget>// on unix |
54 |
| -``` |
55 |
| - |
56 |
| -The bin of your library should look similar to: |
57 |
| - |
58 |
| -``` |
59 |
| -$ tree src/MyCoolNewLib/bin/ |
60 |
| -src/MyCoolNewLib/bin/ |
61 |
| -└── Debug |
62 |
| - └── net50 |
63 |
| - ├── MyCoolNewLib.deps.json |
64 |
| - ├── MyCoolNewLib.dll |
65 |
| - ├── MyCoolNewLib.pdb |
66 |
| - └── MyCoolNewLib.xml |
| 215 | +To build and run all tests: |
67 | 216 |
|
| 217 | +- on Windows |
| 218 | +```cmd |
| 219 | +build.cmd |
68 | 220 | ```
|
69 | 221 |
|
70 |
| ---- |
71 |
| - |
72 |
| -### Build Targets |
73 |
| - |
74 |
| -- `Clean` - Cleans artifact and temp directories. |
75 |
| -- `DotnetRestore` - Runs [dotnet restore](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-restore?tabs=netcore2x) on the [solution file](https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file?view=vs-2019). |
76 |
| -- [`DotnetBuild`](#Building) - Runs [dotnet build](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x) on the [solution file](https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file?view=vs-2019). |
77 |
| -- `DotnetTest` - Runs [dotnet test](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test?tabs=netcore21) on the [solution file](https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file?view=vs-2019). |
78 |
| -- `GenerateCoverageReport` - Code coverage is run during `DotnetTest` and this generates a report via [ReportGenerator](https://github.com/danielpalme/ReportGenerator). |
79 |
| -- `WatchTests` - Runs [dotnet watch](https://docs.microsoft.com/en-us/aspnet/core/tutorials/dotnet-watch?view=aspnetcore-3.0) with the test projects. Useful for rapid feedback loops. |
80 |
| -- `GenerateAssemblyInfo` - Generates [AssemblyInfo](https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.applicationservices.assemblyinfo?view=netframework-4.8) for libraries. |
81 |
| -- `DotnetPack` - Runs [dotnet pack](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-pack). This includes running [Source Link](https://github.com/dotnet/sourcelink). |
82 |
| -- `SourceLinkTest` - Runs a Source Link test tool to verify Source Links were properly generated. |
83 |
| -- `PublishToNuGet` - Publishes the NuGet packages generated in `DotnetPack` to NuGet via [paket push](https://fsprojects.github.io/Paket/paket-push.html). |
84 |
| -- `GitRelease` - Creates a commit message with the [Release Notes](https://fake.build/apidocs/v5/fake-core-releasenotes.html) and a git tag via the version in the `Release Notes`. |
85 |
| -- `GitHubRelease` - Publishes a [GitHub Release](https://help.github.com/en/articles/creating-releases) with the Release Notes and any NuGet packages. |
86 |
| -- `FormatCode` - Runs [Fantomas](https://github.com/fsprojects/fantomas) on the solution file. |
87 |
| -- `BuildDocs` - Generates Documentation from `docsSrc` and the [XML Documentation Comments](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/) from your libraries in `src`. |
88 |
| -- `WatchDocs` - Generates documentation and starts a webserver locally. It will rebuild and hot reload if it detects any changes made to `docsSrc` files, libraries in `src`, or the `docsTool` itself. |
89 |
| -- `ReleaseDocs` - Will stage, commit, and push docs generated in the `BuildDocs` target. |
90 |
| -- [`Release`](#Releasing) - Task that runs all release type tasks such as `PublishToNuGet`, `GitRelease`, `ReleaseDocs`, and `GitHubRelease`. Make sure to read [Releasing](#Releasing) to setup your environment correctly for releases. |
91 |
| ---- |
92 |
| - |
93 |
| - |
94 |
| -### Releasing |
95 |
| - |
96 |
| -- [Start a git repo with a remote](https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/) |
97 |
| - |
98 |
| -```sh |
99 |
| -git add . |
100 |
| -git commit -m "Scaffold" |
101 |
| -git remote add origin https://github.com/user/MyCoolNewLib.git |
102 |
| -git push -u origin master |
103 |
| -``` |
104 |
| - |
105 |
| -- [Create your NuGeT API key](https://docs.microsoft.com/en-us/nuget/nuget-org/publish-a-package#create-api-keys) |
106 |
| - - [Add your NuGet API key to paket](https://fsprojects.github.io/Paket/paket-config.html#Adding-a-NuGet-API-key) |
107 |
| - |
108 |
| - ```sh |
109 |
| - paket config add-token "https://www.nuget.org" 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a |
110 |
| - ``` |
111 |
| - |
112 |
| - - or set the environment variable `NUGET_TOKEN` to your key |
113 |
| - |
114 |
| - |
115 |
| -- [Create a GitHub OAuth Token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/) |
116 |
| - - You can then set the environment variable `GITHUB_TOKEN` to upload release notes and artifacts to github |
117 |
| - - Otherwise it will fallback to username/password |
118 |
| - |
119 |
| -- Then update the `CHANGELOG.md` with an "Unreleased" section containing release notes for this version, in [KeepAChangelog](https://keepachangelog.com/en/1.1.0/) format. |
120 |
| - |
121 |
| -NOTE: Its highly recommend to add a link to the Pull Request next to the release note that it affects. The reason for this is when the `RELEASE` target is run, it will add these new notes into the body of git commit. GitHub will notice the links and will update the Pull Request with what commit referenced it saying ["added a commit that referenced this pull request"](https://github.com/TheAngryByrd/MiniScaffold/pull/179#ref-commit-837ad59). Since the build script automates the commit message, it will say "Bump Version to x.y.z". The benefit of this is when users goto a Pull Request, it will be clear when and which version those code changes released. Also when reading the `CHANGELOG`, if someone is curious about how or why those changes were made, they can easily discover the work and discussions. |
122 |
| - |
123 |
| -Here's an example of adding an "Unreleased" section to a `CHANGELOG.md` with a `0.1.0` section already released. |
124 |
| -
|
125 |
| -```markdown |
126 |
| -## [Unreleased] |
127 |
| -
|
128 |
| -### Added |
129 |
| -- Does cool stuff! |
130 |
| -
|
131 |
| -### Fixed |
132 |
| -- Fixes that silly oversight |
133 |
| -
|
134 |
| -## [0.1.0] - 2017-03-17 |
135 |
| -First release |
136 |
| -
|
137 |
| -### Added |
138 |
| -- This release already has lots of features |
139 |
| -
|
140 |
| -[Unreleased]: https://github.com/user/MyCoolNewLib.git/compare/v0.1.0...HEAD |
141 |
| -[0.1.0]: https://github.com/user/MyCoolNewLib.git/releases/tag/v0.1.0 |
142 |
| -``` |
143 |
| -
|
144 |
| -- You can then use the `Release` target, specifying the version number either in the `RELEASE_VERSION` environment |
145 |
| - variable, or else as a parameter after the target name. This will: |
146 |
| - - update `CHANGELOG.md`, moving changes from the `Unreleased` section into a new `0.2.0` section |
147 |
| - - if there were any prerelease versions of 0.2.0 in the changelog, it will also collect their changes into the final 0.2.0 entry |
148 |
| - - make a commit bumping the version: `Bump version to 0.2.0` and adds the new changelog section to the commit's body |
149 |
| - - publish the package to NuGet |
150 |
| - - push a git tag |
151 |
| - - create a GitHub release for that git tag |
152 |
| - |
153 |
| -macOS/Linux Parameter: |
154 |
| - |
155 |
| -```sh |
156 |
| -./build.sh Release 0.2.0 |
157 |
| -``` |
158 |
| - |
159 |
| -macOS/Linux Environment Variable: |
160 |
| - |
161 |
| -```sh |
162 |
| -RELEASE_VERSION=0.2.0 ./build.sh Release |
| 222 | +- on Linux/macOS |
| 223 | +```shell |
| 224 | +./build.sh |
163 | 225 | ```
|
| 226 | +To find more options look at [MiniScaffold](https://github.com/TheAngryByrd/MiniScaffold). We use it in our project. |
164 | 227 |
|
| 228 | +## License |
| 229 | +This project licensed under MIT License. License text can be found in the [license file](https://github.com/YaccConstructor/GraphBLAS-sharp/blob/master/LICENSE.md). |
| 230 | + |
165 | 231 |
|
0 commit comments