Skip to content

SpGeMM, Kronecker from Dev #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 160 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
aeea80e
refactor: COOMatrix
IgorErin Mar 3, 2023
98e7271
refactor: ToCSC, ToCSR
IgorErin Mar 6, 2023
39e8c0e
add: Matrix.map2
IgorErin Mar 7, 2023
fe2edc3
refactor: formattig
IgorErin Mar 7, 2023
564540d
Merge branch 'dev' into map2
IgorErin Mar 7, 2023
d55d34f
add: Gather
IgorErin Mar 12, 2023
a136bd3
add: Expand module
IgorErin Mar 13, 2023
f77b4d2
add: requiredRawsLengths test
IgorErin Mar 13, 2023
d22621e
wip: module Expand test
IgorErin Mar 13, 2023
9d25601
refactor: globalMap
IgorErin Mar 13, 2023
5479816
add: Expand stage
IgorErin Mar 13, 2023
5409b2e
Merge pull request #66 from IgorErin/map2
gsvgit Mar 14, 2023
be13d6e
add: Expand test
IgorErin Mar 16, 2023
146b17f
add: Matrix.map
artemiipatov Mar 21, 2023
5571002
refactor: tests, binSearch
artemiipatov Mar 23, 2023
7349c1d
refactor: formatting
artemiipatov Mar 23, 2023
3fc1b44
add: Search module
IgorErin Mar 23, 2023
c89e1b9
add: CSR.map2
artemiipatov Mar 23, 2023
f223b97
refactor: Map.tests, float32 generator shift
artemiipatov Mar 24, 2023
3261d08
add: reduce by key strategies
IgorErin Mar 24, 2023
de5d998
refactor: namespaces in tests
IgorErin Mar 24, 2023
bca2cf6
refactor: formatting
IgorErin Mar 24, 2023
24cb165
refactor: comments
IgorErin Mar 24, 2023
7b2ca81
refactor: comments in search module
IgorErin Mar 24, 2023
a4aa593
add: radix sort
IgorErin Mar 24, 2023
b028f01
refactor: formatting
IgorErin Mar 24, 2023
2e8f46b
refactor: imports
IgorErin Mar 24, 2023
4f2b965
refactor: map tests
artemiipatov Mar 25, 2023
9102d0f
refactor: modules in tests
IgorErin Mar 25, 2023
647d19d
refactor: Search.Bin.byKey2D
IgorErin Mar 25, 2023
953be9b
refactor: rename functions in binSearch module
artemiipatov Mar 25, 2023
02b702f
add: map tests for integer support
artemiipatov Mar 25, 2023
edfa3ff
fix: map tests
artemiipatov Mar 25, 2023
c7bb9b1
Merge pull request #69 from IgorErin/reducebykey
gsvgit Mar 25, 2023
ce30430
merge: dev
IgorErin Mar 25, 2023
4e54346
merge: dev
artemiipatov Mar 25, 2023
b2384b9
refactor: tests float shift
IgorErin Mar 25, 2023
abdb353
Merge pull request #70 from IgorErin/radix
gsvgit Mar 25, 2023
7885e8a
Merge pull request #68 from artemiipatov/map
gsvgit Mar 25, 2023
890bdd1
merge: dev
IgorErin Mar 26, 2023
6da457b
add: reduceByKey2D
IgorErin Mar 27, 2023
66c2711
refactor: wip
IgorErin Apr 1, 2023
fa392b0
refactor: prefix sum
IgorErin Apr 1, 2023
bc7ebdf
add: segment sequential scan
IgorErin Apr 2, 2023
3bb2e9a
refactor: formatting
IgorErin Apr 2, 2023
ab870bd
refactor
IgorErin Apr 2, 2023
91a72e2
add: Gather tests
IgorErin Apr 3, 2023
b679650
wip: segments computing tests
IgorErin Apr 4, 2023
7e09219
wip: expand tests passed
IgorErin Apr 4, 2023
84fb950
wip: getUniqueBitmap{first/last} occurrence
IgorErin Apr 5, 2023
8ec7fd7
add: Scatter.firstOccurrence
IgorErin Apr 5, 2023
63037b6
spgemm: left filtering
IgorErin Apr 6, 2023
03e7e95
add: init gather
IgorErin Apr 6, 2023
6f02570
add: init scatter
IgorErin Apr 6, 2023
29c564c
add: scatter init value
IgorErin Apr 6, 2023
972b392
refactor: init in spgemm
IgorErin Apr 6, 2023
73d755f
refactor: deforestation in ClArray.choose
IgorErin Apr 6, 2023
f34e590
add: ClArray.choose2
IgorErin Apr 6, 2023
751ee68
add: filter after multiplication
IgorErin Apr 6, 2023
69be680
add: reduce by key option
IgorErin Apr 6, 2023
3f7c0bf
add: spgemm
IgorErin Apr 7, 2023
96c0c08
refactor: spgemm
IgorErin Apr 7, 2023
420e2b8
refactor: Helpers
IgorErin Apr 7, 2023
95fea31
refactor: duplication, allTests in Reduce
IgorErin Apr 7, 2023
c5fa0d0
refactor: ClArray.Free and *.FreeAndWait
IgorErin Apr 7, 2023
e850a49
Merge pull request #71 from IgorErin/scan
gsvgit Apr 7, 2023
6ff1971
refactor: remove use in test
IgorErin Apr 7, 2023
048477d
refactor: formatting
IgorErin Apr 7, 2023
3703609
merge: dev
IgorErin Apr 7, 2023
4d26023
refactor: formatting
IgorErin Apr 7, 2023
cf7cc1d
refactor: expand endSize
IgorErin Apr 8, 2023
fdb9041
refactor: Scatter.test memory release
IgorErin Apr 8, 2023
a6ebc30
refactor: tests, names
IgorErin Apr 8, 2023
e0485c5
Merge pull request #72 from IgorErin/spgemm
gsvgit Apr 10, 2023
7e0d060
add: ClArray.chunk*
IgorErin Apr 13, 2023
babe90e
add: Split
IgorErin Apr 13, 2023
b30a9f8
add: ClArray.chunk* tests
IgorErin Apr 13, 2023
0cfe112
add: ClArray.append
IgorErin Apr 14, 2023
a79542d
add: Vector.map
IgorErin Apr 14, 2023
d0133ec
wip: Vector.map2
IgorErin Apr 14, 2023
2db0be2
merge: dev
IgorErin Apr 14, 2023
4b7c3ed
wip: expand refactor, tests in progress
IgorErin Apr 16, 2023
7d1ee0e
add: Reduce.ByKey.Option.sequintialSegments
IgorErin Apr 16, 2023
98d41dd
add: ClArray.assign tests
IgorErin Apr 16, 2023
1f273d1
add: ClArray.concat tests
IgorErin Apr 16, 2023
830b2f9
wip: ClArray.pairwise
IgorErin Apr 17, 2023
92b186f
add: ClArray.pairwise
IgorErin Apr 17, 2023
089e11e
add: Matrix.Rows.Convert
IgorErin Apr 17, 2023
6f2adb3
wip: SpGeMM expand phase
IgorErin Apr 18, 2023
cf48196
add: CSR.RowsLengths tests
IgorErin Apr 19, 2023
a60b12a
add: spgemm row wise
IgorErin Apr 20, 2023
3d0b07b
refactor: formatting
IgorErin Apr 20, 2023
c75fd57
wip: ArithmeticOps
IgorErin Apr 20, 2023
2441558
refactor: formatting
IgorErin Apr 21, 2023
abdd46c
refactor: ...
IgorErin Apr 21, 2023
7bdaf88
refactor: include gather tests
IgorErin Apr 21, 2023
ad66391
refactor: ClArray.assign -> *.blit
IgorErin Apr 21, 2023
5b94160
refactor: paths
IgorErin Apr 22, 2023
9cc2155
wip: benchmarks
IgorErin Apr 22, 2023
9e8b9bc
refactor: benchmarks
IgorErin Apr 22, 2023
b25bc97
refactor: benchmarks
IgorErin Apr 22, 2023
1d45950
refactor: README
IgorErin Apr 23, 2023
2a5617b
refactor: operations early binding
IgorErin Apr 23, 2023
d9dd757
wip: SpGeMM benchmark
IgorErin Apr 23, 2023
f5c6fe6
fix: count in CSR.byRows
IgorErin Apr 23, 2023
ad9b528
add: CSR.byRows tests
IgorErin Apr 24, 2023
acaa0c1
fix: host COO -> CSR
IgorErin Apr 24, 2023
a449754
add: host tests
IgorErin Apr 25, 2023
2972803
refactor: paths
IgorErin Apr 25, 2023
efa50f4
refactor: clean
IgorErin Apr 25, 2023
2b4a5b7
add: Vector.Merge
IgorErin Apr 26, 2023
848a11b
refactor: Vector.Merge
IgorErin Apr 26, 2023
661e085
add: Matrix.Merge.tests
IgorErin Apr 28, 2023
850ca14
add: Common.Merge with explicit error
IgorErin Apr 28, 2023
ab4d3ac
refactor: Common.Merge
IgorErin Apr 28, 2023
becee4d
refactor: formatting
IgorErin Apr 28, 2023
655fe67
refactor: list instead array in LIL
IgorErin Apr 28, 2023
7f3cb90
refactor: SpGeMM.expand
IgorErin Apr 28, 2023
bf1cd58
refactor: tests
IgorErin Apr 28, 2023
76de19b
refactor: benchmark workflow
IgorErin Apr 28, 2023
4ea099c
refactor: formatting
IgorErin Apr 28, 2023
cb8a791
Merge pull request #76 from IgorErin/merge
gsvgit Apr 28, 2023
743491e
merge: dev
IgorErin Apr 28, 2023
ecb4eb5
refactor: remove *.map2ToCOO
IgorErin Apr 28, 2023
dffcb5f
refactor: Matrix.map*, ClArray.choose
IgorErin Apr 29, 2023
1e3b53c
refactor: Dense.reduce
IgorErin Apr 29, 2023
45e4536
refactor: Matrix.AtLeastOne
IgorErin Apr 29, 2023
fb1909c
Merge pull request #75 from IgorErin/split
gsvgit Apr 29, 2023
269fc21
refactor: ClArray.Bitmap module
IgorErin Apr 30, 2023
1ebf84b
refactor: CSR.expandRowsPointers
IgorErin May 1, 2023
3d2cc7f
add: CSR.subByRows
IgorErin May 1, 2023
5551c57
add: ClArray.upperBound
IgorErin May 1, 2023
5b1b3cd
add: Search.Bin.lowerBound comments
IgorErin May 1, 2023
970ffa0
wip: SpGeMM
IgorErin May 2, 2023
fcbeee4
add: ClArray.upperBoundWithValue
IgorErin May 2, 2023
02fa1ff
add: MaxMemAllocSize
IgorErin May 2, 2023
9662efe
refactor: release in spgemm
IgorErin May 2, 2023
7e58687
add: maxAllocSize assert
IgorErin May 2, 2023
bae988e
add: measure maxAllocSize
IgorErin May 3, 2023
2ddbe37
refactor: tests
IgorErin May 3, 2023
35e5e29
add: ClArray.set, ClArray.item
IgorErin May 4, 2023
627e8c5
fix: SpGeMM, last item in pointers
IgorErin May 4, 2023
06be7e7
refactor: Naming, Generators
IgorErin May 4, 2023
9482cab
fix: allocSize compute in spgemm
IgorErin May 4, 2023
e647418
refactor: formatting
IgorErin May 4, 2023
e52847c
refactor: sparsity generators
IgorErin May 5, 2023
e1a9e5b
Merge pull request #77 from IgorErin/splitbench
gsvgit May 5, 2023
32b27ba
add: allocation first kronecker
artemiipatov May 9, 2023
ab946ea
fix: kronecker
artemiipatov May 9, 2023
fc55f85
perf: kronecker
artemiipatov May 9, 2023
2907167
refactor: kronecker
artemiipatov May 9, 2023
2a40ca3
add: vector.mapWithValue
artemiipatov May 9, 2023
10302da
refactor: kronecker
artemiipatov May 11, 2023
7522725
refactor
artemiipatov May 11, 2023
8ca161d
refactor: kronecker, tests, sparse.map
artemiipatov May 12, 2023
61447f0
refactor: remove commented code
artemiipatov May 12, 2023
3cbc088
refactor: add clarifying comments
artemiipatov May 12, 2023
a420aab
refactor: kronecker
artemiipatov May 12, 2023
372aa56
refactor: remove commented code
artemiipatov May 16, 2023
b494dab
Merge pull request #79 from artemiipatov/kronecker-alloc-first
gsvgit May 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
name: BFS
tool: 'benchmarkdotnet'
output-file-path: BenchmarkDotNet.Artifacts/results/GraphBLAS.FSharp.Benchmarks.BFSBenchmarksWithoutDataTransfer-report-brief.json
output-file-path: BenchmarkDotNet.Artifacts/results/GraphBLAS.FSharp.Benchmarks.BFSWithoutTransferBenchmarkInt32-report-brief.json
# Access token to deploy GitHub Pages branch
github-token: ${{ secrets._GITHUB_TOKEN }}
# Push and deploy GitHub pages branch automatically
Expand Down
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,38 @@ GraphBLAS# is a GPGPU-based [GraphBLAS](https://graphblas.org/)-like API impleme
| Left of 't1
| Right of 't2
```
So, type of matrix-matrix elementwise oertion is ```Matrix<Option<'t1>> -> Matrix<Option<'t2>> -> (AtLeastOne<'t1,'t2> -> Option<'t3>) -> Matrix<Option<'t3>>```.
- No semirings. Just functions. Ofcourse one can implement semirings on the top of provided API.
So, type of matrix-matrix elementwise operation is ```Matrix<Option<'t1>> -> Matrix<Option<'t2>> -> (AtLeastOne<'t1,'t2> -> Option<'t3>) -> Matrix<Option<'t3>>```.
- No semirings. Just functions. Of course one can implement semirings on the top of provided API.
- 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.

### Operations
- **Matrix-Matrix**
- [x] COO-COO element-wize
- [x] CSR-CSR element-wize
- [ ] CSR-CSR multiplication
- [ ] COO transpose
- [ ] CSR transpose
- [x] CSR-CSR `map2`
- [x] CSR-CSR `map2AtLeastOne`
- [x] COO-COO `map2`
- [x] COO-COO `map2AtLeastOne`
- [x] CSR-CSR multiplication
- **Vector-Matrix**
- [x] Dense-CSR multiplication
- [ ] COO-CSR multiplication
- [ ] Sparse-CSR multiplication
- **Vector-Vector**
- [x] Dense-Dense element-wise
- [x] Dense-Dense `map2`
- [x] Dense-Dense `map2AtLeastOne`
- [x] Sparse-Sparse `map2`
- [x] Sparse-Sparse `map2AtLeastOne`
- [ ] ...
- **Matrix**
- [ ] `map`
- [ ] `iter`
- [x] `copy`
- [x] `map`
- [x] COO transpose
- [x] CSR transpose
- [x] CSC transpose
- [ ] ...
- **Vector**
- [ ] `map`
- [ ] `iter`
- [ ] `filter`
- [ ] `contains`
- [x] `zeroCreate`
- [x] `ofList`
- [x] `copy`
- [x] `reduce`
- [ ] ...

### Graph Analysis Algorithms
Expand Down
178 changes: 178 additions & 0 deletions benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/BFS.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
namespace GraphBLAS.FSharp.Benchmarks.Algorithms.BFS

open System.IO
open BenchmarkDotNet.Attributes
open GraphBLAS.FSharp
open GraphBLAS.FSharp.Backend.Quotes
open GraphBLAS.FSharp.IO
open Brahma.FSharp
open Backend.Algorithms.BFS
open Microsoft.FSharp.Core
open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions
open GraphBLAS.FSharp.Benchmarks
open GraphBLAS.FSharp.Backend.Objects

[<AbstractClass>]
[<IterationCount(100)>]
[<WarmupCount(10)>]
[<Config(typeof<Configs.Matrix>)>]
type Benchmarks<'elem when 'elem : struct>(
buildFunToBenchmark,
converter: string -> 'elem,
binaryConverter,
vertex: int)
=

let mutable funToBenchmark = None
let mutable matrix = Unchecked.defaultof<ClMatrix.CSR<'elem>>
let mutable matrixHost = Unchecked.defaultof<_>

member val ResultLevels = Unchecked.defaultof<ClArray<'elem option>> with get,set

[<ParamsSource("AvailableContexts")>]
member val OclContextInfo = Unchecked.defaultof<Utils.BenchmarkContext * int> with get, set

[<ParamsSource("InputMatrixProvider")>]
member val InputMatrixReader = Unchecked.defaultof<MtxReader> with get, set

member this.OclContext = (fst this.OclContextInfo).ClContext
member this.WorkGroupSize = snd this.OclContextInfo

member this.Processor =
let p = (fst this.OclContextInfo).Queue
p.Error.Add(fun e -> failwithf "%A" e)
p

static member AvailableContexts = Utils.availableContexts

static member InputMatrixProviderBuilder pathToConfig =
let datasetFolder = "BFS"
pathToConfig
|> Utils.getMatricesFilenames
|> Seq.map
(fun matrixFilename ->
printfn "%A" matrixFilename

match Path.GetExtension matrixFilename with
| ".mtx" -> MtxReader(Utils.getFullPathToMatrix datasetFolder matrixFilename)
| _ -> failwith "Unsupported matrix format")

member this.FunToBenchmark =
match funToBenchmark with
| None ->
let x = buildFunToBenchmark this.OclContext this.WorkGroupSize
funToBenchmark <- Some x
x
| Some x -> x

member this.BFS() =
this.ResultLevels <- this.FunToBenchmark this.Processor matrix vertex

member this.ClearInputMatrix() =
(matrix :> IDeviceMemObject).Dispose this.Processor

member this.ClearResult() = this.ResultLevels.FreeAndWait this.Processor

member this.ReadMatrix() =
let converter =
match this.InputMatrixReader.Field with
| Pattern -> binaryConverter
| _ -> converter

matrixHost <- this.InputMatrixReader.ReadMatrix converter

member this.LoadMatrixToGPU() =
matrix <- matrixHost.ToCSR.ToDevice this.OclContext

abstract member GlobalSetup : unit -> unit

abstract member IterationCleanup : unit -> unit

abstract member GlobalCleanup : unit -> unit

abstract member Benchmark : unit -> unit

type WithoutTransferBenchmark<'elem when 'elem : struct>(
buildFunToBenchmark,
converter: string -> 'elem,
boolConverter,
vertex) =

inherit Benchmarks<'elem>(
buildFunToBenchmark,
converter,
boolConverter,
vertex)

[<GlobalSetup>]
override this.GlobalSetup() =
this.ReadMatrix()
this.LoadMatrixToGPU()

[<IterationCleanup>]
override this.IterationCleanup() =
this.ClearResult()

[<GlobalCleanup>]
override this.GlobalCleanup() =
this.ClearInputMatrix()

[<Benchmark>]
override this.Benchmark() =
this.BFS()
this.Processor.PostAndReply Msg.MsgNotifyMe

type BFSWithoutTransferBenchmarkInt32() =

inherit WithoutTransferBenchmark<int>(
(singleSource ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption),
int32,
(fun _ -> Utils.nextInt (System.Random())),
0)

static member InputMatrixProvider =
Benchmarks<_>.InputMatrixProviderBuilder "BFSBenchmarks.txt"

type WithTransferBenchmark<'elem when 'elem : struct>(
buildFunToBenchmark,
converter: string -> 'elem,
boolConverter,
vertex) =

inherit Benchmarks<'elem>(
buildFunToBenchmark,
converter,
boolConverter,
vertex)

[<GlobalSetup>]
override this.GlobalSetup() =
this.ReadMatrix()

[<GlobalCleanup>]
override this.GlobalCleanup() =
this.ClearResult()

[<IterationCleanup>]
override this.IterationCleanup() =
this.ClearInputMatrix()
this.ClearResult()

[<Benchmark>]
override this.Benchmark() =
this.LoadMatrixToGPU()
this.BFS()
this.ResultLevels.ToHost this.Processor |> ignore
this.Processor.PostAndReply Msg.MsgNotifyMe

type BFSWithTransferBenchmarkInt32() =

inherit WithTransferBenchmark<int>(
(singleSource ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption),
int32,
(fun _ -> Utils.nextInt (System.Random())),
0)

static member InputMatrixProvider =
Benchmarks<_>.InputMatrixProviderBuilder "BFSBenchmarks.txt"

Loading