Skip to content

Split #75

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 46 commits into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
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
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
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
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