Skip to content

Commit 0e6e92e

Browse files
committed
Add vector/matrix builders. Add comments to benchmark
1 parent 9a138db commit 0e6e92e

14 files changed

Lines changed: 74 additions & 52 deletions

File tree

benchmarks/GraphBLAS-sharp.Benchmarks/BfsBenchmark.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type BfsBenchmark() =
2828
member this.LevelBFS () =
2929
levelBFS matrix source
3030

31+
/// Sequence of paths to files where data for benchmarking will be taken from
3132
static member GraphPaths = seq {
33+
// Gets all mtx files from following directory
3234
yield! Directory.EnumerateFiles(Path.Join [|"Datasets"; "1"|], "*.mtx")
3335
}

benchmarks/GraphBLAS-sharp.Benchmarks/Config.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ type TEPSColumn() =
3636
member this.PriorityInCategory: int = 0
3737
member this.UnitType: UnitType = UnitType.Dimensionless
3838

39-
4039
type Config() =
4140
inherit ManualConfig()
4241

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
#r "nuget: FSharp.Data"
2-
#r "nuget: Luna.ConsoleProgressBar"
32

43
open System
54
open System.IO
65
open System.Net
76
open System.IO.Compression
87
open FSharp.Data
98
open FSharp.Data.CsvExtensions
10-
open Luna.ConsoleProgressBar
119

12-
let downloadGraphs graphName archiveType url (outputDir: string) =
10+
let downloadAndUnzip graphName archiveType url outputDir =
1311
use client = new WebClient()
14-
// use bar = new ConsoleProgressBar()
15-
// client.DownloadProgressChanged.Add (fun e ->
16-
// bar.Report (float e.ProgressPercentage / 100.)
17-
// )
1812
match archiveType with
1913
| "zip" ->
2014
let archive = Path.Combine [| outputDir; Path.ChangeExtension(graphName, ".zip") |]
2115
client.AsyncDownloadFile(Uri url, archive) |> Async.RunSynchronously
2216
ZipFile.ExtractToDirectory(archive, outputDir)
2317
| _ -> ()
2418

19+
(*
20+
Get all "graphs.csv" flies
21+
-> load all rows from all csv files
22+
-> download and unzip graph archives
23+
*)
2524
seq {
2625
for dir in fsi.CommandLineArgs.[1..] do
2726
yield! Directory.EnumerateFiles(dir, "graphs.csv", SearchOption.AllDirectories)
@@ -31,5 +30,5 @@ seq {
3130
CsvFile.Load(pathToCsv, separators=",", hasHeaders=true).Rows |> Seq.allPairs <| Seq.singleton pathToCsv)
3231
|> Seq.iter (fun (row, pathToCsv) ->
3332
let datasetRootPath = Path.GetDirectoryName pathToCsv
34-
downloadGraphs row?GraphName row?ArchiveType row?Url datasetRootPath)
33+
downloadAndUnzip row?GraphName row?ArchiveType row?Url datasetRootPath)
3534

src/GraphBLAS-sharp/Abstracts.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ type Matrix<'a when 'a : struct and 'a : equality>(nrow: int, ncol: int) =
2727

2828
static member inline (+) (x: Matrix<'a>, y: Matrix<'a>) = x.EWiseAdd y
2929
static member inline (*) (x: Matrix<'a>, y: Matrix<'a>) = x.EWiseMult y
30-
static member inline (.@) (x: Matrix<'a>, y: Matrix<'b>) = x.Mxm y
31-
static member inline (.@) (x: Matrix<'a>, y: Vector<'b>) = x.Mxv y
30+
static member inline (@.) (x: Matrix<'a>, y: Matrix<'b>) = x.Mxm y
31+
static member inline (@.) (x: Matrix<'a>, y: Vector<'b>) = x.Mxv y
3232

3333
and [<AbstractClass>] Vector<'a when 'a : struct and 'a : equality>(size: int) =
3434
abstract Size: int
@@ -49,7 +49,7 @@ and [<AbstractClass>] Vector<'a when 'a : struct and 'a : equality>(size: int) =
4949

5050
static member inline (+) (x: Vector<'a>, y: Vector<'a>) = x.EWiseAdd y
5151
static member inline (*) (x: Vector<'a>, y: Vector<'a>) = x.EWiseMult y
52-
static member inline (.@) (x: Vector<'a>, y: Matrix<'b>) = x.Vxm y
52+
static member inline (@.) (x: Vector<'a>, y: Matrix<'b>) = x.Vxm y
5353

5454
and Mask1D = {
5555
Indices: int list

src/GraphBLAS-sharp/Algorithms/BFS.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module BFS =
1616
while !> (frontier.Reduce BooleanMonoid.any) && currentLevel < vertexCount do
1717
levels.Fill(Mask1D.regular frontier) <- Scalar currentLevel
1818
frontier.Clear()
19-
frontier.[Mask1D.complemented levels] <- (frontier .@ matrix) (Mask1D.complemented levels) BooleanSemiring.anyAll
19+
frontier.[Mask1D.complemented levels] <- (frontier @. matrix) (Mask1D.complemented levels) BooleanSemiring.anyAll
2020
currentLevel <- currentLevel + 1
2121

2222
upcast levels

src/GraphBLAS-sharp/Algorithms/SSSP.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ module SSSP =
1010
let distance = SparseVector(vertexCount, [source, 0.])
1111

1212
for _ in 1 .. vertexCount - 1 do
13-
distance.[Mask1D.none] <- (distance .@ matrix) Mask1D.none FloatSemiring.addMult
13+
distance.[Mask1D.none] <- (distance @. matrix) Mask1D.none FloatSemiring.addMult
1414

1515
upcast distance

src/GraphBLAS-sharp/Backend.fs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/GraphBLAS-sharp/Exceptions.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace GraphBLAS.FSharp
2+
3+
exception DimensionalMismatchException of string

src/GraphBLAS-sharp/GlobalContext.fs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,5 @@ module GlobalContext =
99
| COO
1010
| Dense
1111

12-
type VectorBackendFormat =
13-
| Sparse
14-
| Dense
15-
1612
let mutable oclContext = OpenCLEvaluationContext()
1713
let mutable matrixBackendFormat = CSR

src/GraphBLAS-sharp/GraphBLAS-sharp.fsproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
<ItemGroup>
1010
<Compile Include="AssemblyInfo.fs" />
1111
<Compile Include="Helpers.fs" />
12-
<Compile Include="GlobalContext.fs" />
12+
<Compile Include="Exceptions.fs" />
1313
<Compile Include="Operators.fs" />
1414
<Compile Include="Monoid.fs" />
1515
<Compile Include="Semiring.fs" />
16+
<Compile Include="GlobalContext.fs" />
1617
<Compile Include="Scalar.fs" />
1718
<Compile Include="Abstracts.fs" />
1819
<Compile Include="Implementations.fs" />
19-
<Compile Include="Backend.fs" />
2020
<Compile Include="Matrix.fs" />
2121
<Compile Include="Vector.fs" />
2222
<Compile Include="Masks.fs" />
@@ -28,4 +28,4 @@
2828
<Compile Include="Algorithms/TriangleCounting.fs" />
2929
</ItemGroup>
3030
<Import Project="..\..\.paket\Paket.Restore.targets" />
31-
</Project>
31+
</Project>

0 commit comments

Comments
 (0)