-
Notifications
You must be signed in to change notification settings - Fork 7
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
PageRank #88
Merged
Merged
PageRank #88
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
faf242c
PageRankMatrix type
kirillgarbar b278b7a
BFS on bool
kirillgarbar ebdb250
Merge remote-tracking branch 'YaccConstructor/dev' into dev
kirillgarbar 6f3819b
Fix merge
kirillgarbar 1ed601c
Fix ZeroCreate test
kirillgarbar 858cd82
Constants for test
kirillgarbar 0826562
Docs for PageRank
kirillgarbar b82fe68
Block after setup and cleanup in benchmarks
kirillgarbar c8f3042
Constants module and signature for PageRank module
kirillgarbar 0ab7361
MailboxProcessor extensions
kirillgarbar 97b6db4
Module qualifiers
kirillgarbar f671a2e
Add pagerank link
kirillgarbar 6de410f
Restart CI attempt
kirillgarbar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/PageRank.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
namespace GraphBLAS.FSharp.Benchmarks.Algorithms.PageRank | ||
|
||
open System.IO | ||
open BenchmarkDotNet.Attributes | ||
open GraphBLAS.FSharp | ||
open GraphBLAS.FSharp.IO | ||
open Brahma.FSharp | ||
open Microsoft.FSharp.Core | ||
open GraphBLAS.FSharp.Objects.ArraysExtensions | ||
open GraphBLAS.FSharp.Objects.MailboxProcessorExtensions | ||
open GraphBLAS.FSharp.Benchmarks | ||
open GraphBLAS.FSharp.Objects | ||
|
||
[<AbstractClass>] | ||
[<IterationCount(10)>] | ||
[<WarmupCount(3)>] | ||
[<Config(typeof<Configs.Matrix>)>] | ||
type Benchmarks( | ||
buildFunToBenchmark, | ||
converter: string -> float32, | ||
binaryConverter, | ||
buildMatrix) | ||
= | ||
|
||
let mutable funToBenchmark = None | ||
let mutable matrix = Unchecked.defaultof<ClMatrix<float32>> | ||
let mutable matrixPrepared = Unchecked.defaultof<Algorithms.PageRank.PageRankMatrix> | ||
let mutable matrixHost = Unchecked.defaultof<_> | ||
|
||
member val Result = Unchecked.defaultof<ClVector<float32>> 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 = "" | ||
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.PageRank() = | ||
this.Result <- this.FunToBenchmark this.Processor matrixPrepared Constants.PageRank.accuracy | ||
|
||
member this.ClearInputMatrix() = | ||
matrix.Dispose this.Processor | ||
|
||
member this.ClearPreparedMatrix() = | ||
matrixPrepared.Dispose this.Processor | ||
|
||
member this.ClearResult() = this.Result.Dispose this.Processor | ||
|
||
member this.ReadMatrix() = | ||
let converter = | ||
match this.InputMatrixReader.Field with | ||
| Pattern -> binaryConverter | ||
| _ -> converter | ||
|
||
matrixHost <- this.InputMatrixReader.ReadMatrix converter | ||
|
||
member this.LoadMatrixToGPU() = | ||
matrix <- buildMatrix this.OclContext matrixHost | ||
|
||
member this.PrepareMatrix() = | ||
matrixPrepared <- Algorithms.PageRank.prepareMatrix this.OclContext this.WorkGroupSize this.Processor matrix | ||
|
||
abstract member GlobalSetup : unit -> unit | ||
|
||
abstract member IterationCleanup : unit -> unit | ||
|
||
abstract member GlobalCleanup : unit -> unit | ||
|
||
abstract member Benchmark : unit -> unit | ||
|
||
type PageRankWithoutTransferBenchmarkFloat32() = | ||
|
||
inherit Benchmarks( | ||
Algorithms.PageRank.run, | ||
float32, | ||
(fun _ -> float32 <| Utils.nextInt (System.Random())), | ||
(fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context)) | ||
|
||
static member InputMatrixProvider = | ||
Benchmarks.InputMatrixProviderBuilder "BFSBenchmarks.txt" | ||
|
||
[<GlobalSetup>] | ||
override this.GlobalSetup() = | ||
this.ReadMatrix() | ||
this.LoadMatrixToGPU() | ||
finish this.Processor | ||
this.PrepareMatrix() | ||
this.ClearInputMatrix() | ||
finish this.Processor | ||
|
||
[<IterationCleanup>] | ||
override this.IterationCleanup() = | ||
this.ClearResult() | ||
finish this.Processor | ||
|
||
[<GlobalCleanup>] | ||
override this.GlobalCleanup() = | ||
this.ClearPreparedMatrix() | ||
|
||
[<Benchmark>] | ||
override this.Benchmark() = | ||
this.PageRank() | ||
finish this.Processor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've always thought about it. Don't you need to make the preparatory methods blocking? Then is it possible to avoid blocking in the
[<Benchmark>]
itself?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good idea to block after preparotory methods in case some of them are not blocking by itself, but blocking in the
[<Benchmark>]
is still necessary to wait for all kernels to execute.