Skip to content
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

RawCommandQueue #95

Merged
merged 9 commits into from
Jun 1, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
RawCommandQueue 1
  • Loading branch information
kirillgarbar committed May 10, 2024
commit 4485640126194272bb7921c8ec1548d2e72a7a97
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ type Benchmarks(
member this.ClearPreparedMatrix() =
matrixPrepared.Dispose this.Processor

member this.ClearResult() = this.Result.Dispose this.Processor
member this.ClearResult() = this.Result.Dispose()

member this.ReadMatrix() =
let converter =
115 changes: 0 additions & 115 deletions benchmarks/GraphBLAS-sharp.Benchmarks/Common/SetArgs.fs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@
<Compile Include="Helpers.fs" />
<Compile Include="Columns.fs" />
<Compile Include="Configs.fs" />
<Compile Include="Common/SetArgs.fs" />
<Compile Include="Matrix/SpGeMM/Masked.fs" />
<Compile Include="Matrix/SpGeMM/Expand.fs" />
<Compile Include="Matrix/Map2/Map2.fs" />
23 changes: 14 additions & 9 deletions benchmarks/GraphBLAS-sharp.Benchmarks/Helpers.fs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ open Expecto
module Utils =
type BenchmarkContext =
{ ClContext: Brahma.FSharp.ClContext
Queue: DeviceCommandQueue<Msg> }
Queue: RawCommandQueue }

let getMatricesFilenames configFilename =
let getFullPathToConfig filename =
@@ -103,9 +103,11 @@ module Utils =
let context =
Brahma.FSharp.ClContext(device, translator)

let queue = context.QueueProvider.CreateQueue()
let queue =
RawCommandQueue(context.ClDevice.Device, context.Context, context.Translator)

{ ClContext = context; Queue = queue })

seq {
for wgSize in workGroupSizes do
for context in contexts do
@@ -119,13 +121,14 @@ module Utils =

let normalFloatGenerator =
(Arb.Default.NormalFloat()
|> Arb.toGen
|> Gen.map float)
|> Arb.toGen
|> Gen.map float)

let fIsEqual x y = abs (x - y) < Accuracy.medium.absolute || x.Equals y
let fIsEqual x y =
abs (x - y) < Accuracy.medium.absolute
|| x.Equals y

let nextInt (random: System.Random) =
random.Next()
let nextInt (random: System.Random) = random.Next()

module VectorGenerator =
let private pairOfVectorsOfEqualSize (valuesGenerator: Gen<'a>) createVector =
@@ -144,8 +147,10 @@ module VectorGenerator =
|> pairOfVectorsOfEqualSize Arb.generate<int32>

let floatPair format =
let fIsEqual x y = abs (x - y) < Accuracy.medium.absolute || x = y
let fIsEqual x y =
abs (x - y) < Accuracy.medium.absolute || x = y

let createVector array = Utils.createVectorFromArray format array (fIsEqual 0.0)
let createVector array =
Utils.createVectorFromArray format array (fIsEqual 0.0)

pairOfVectorsOfEqualSize Utils.normalFloatGenerator createVector
2 changes: 1 addition & 1 deletion benchmarks/GraphBLAS-sharp.Benchmarks/Program.fs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ open BenchmarkDotNet.Running
[<EntryPoint>]
let main argv =
let benchmarks =
BenchmarkSwitcher [| typeof<Common.SetArgs.BenchmarkSetArgs> |]
BenchmarkSwitcher [| typeof<Algorithms.BFS.BFSWithoutTransferBenchmarkBool> |]

benchmarks.Run argv |> ignore
0
6 changes: 3 additions & 3 deletions benchmarks/GraphBLAS-sharp.Benchmarks/Vector/Map2.fs
Original file line number Diff line number Diff line change
@@ -63,12 +63,12 @@ type Benchmarks<'elem when 'elem : struct>(
| ex -> raise ex

member this.ClearInputVectors()=
firstVector.Dispose this.Processor
secondVector.Dispose this.Processor
firstVector.Dispose()
secondVector.Dispose()

member this.ClearResult() =
match this.ResultVector with
| Some v -> v.Dispose this.Processor
| Some v -> v.Dispose()
| None -> ()

member this.CreateVectors() =
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ nuget System.CodeDom >= 7.0
nuget FSharp.Quotations.Evaluator 2.1.0
nuget FSharpx.Collections >= 3.1
nuget FSharpx.Text.StructuredFormat >= 3.1
nuget Brahma.FSharp 3.0.0-alpha1.3
nuget Brahma.FSharp 3.0.0-alpha1.5
nuget BenchmarkDotNet
nuget MathNet.Numerics.FSharp 4.0.0
nuget MathNet.Numerics.MKL.Win-x64 2.5.0
34 changes: 17 additions & 17 deletions paket.lock
Original file line number Diff line number Diff line change
@@ -19,26 +19,26 @@ NUGET
System.Reflection.Emit.Lightweight (>= 4.7) - restriction: && (< net6.0) (>= netstandard2.0)
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: && (< net6.0) (>= netstandard2.0)
BenchmarkDotNet.Annotations (0.13.12) - restriction: >= netstandard2.0
Brahma.FSharp (3.0.0-alpha1.3)
Brahma.FSharp.OpenCL.Printer (>= 3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Shared (>= 3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Translator (>= 3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp (3.0.0-alpha1.5)
Brahma.FSharp.OpenCL.Printer (>= 3.0.0-alpha1.5) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Shared (>= 3.0.0-alpha1.5) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Translator (>= 3.0.0-alpha1.5) - restriction: >= net7.0
FSharp.Core (7.0) - restriction: >= net7.0
FSharp.Quotations.Evaluator (>= 2.1) - restriction: >= net7.0
YC.OpenCL.NET (>= 3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.AST (3.0.0-alpha1.3) - restriction: >= net7.0
YC.OpenCL.NET (>= 3.0.0-alpha1.5) - restriction: >= net7.0
Brahma.FSharp.OpenCL.AST (3.0.0-alpha1.5) - restriction: >= net7.0
FSharp.Core (7.0) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Printer (3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.AST (>= 3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Translator (>= 3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Printer (3.0.0-alpha1.5) - restriction: >= net7.0
Brahma.FSharp.OpenCL.AST (>= 3.0.0-alpha1.5) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Translator (>= 3.0.0-alpha1.5) - restriction: >= net7.0
FSharp.Core (7.0) - restriction: >= net7.0
FSharpx.Collections (>= 3.1) - restriction: >= net7.0
FSharpx.Text.StructuredFormat (>= 3.1) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Shared (3.0.0-alpha1.3) - restriction: >= net7.0
YC.OpenCL.NET (>= 3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Translator (3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.AST (>= 3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Shared (>= 3.0.0-alpha1.3) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Shared (3.0.0-alpha1.5) - restriction: >= net7.0
YC.OpenCL.NET (>= 3.0.0-alpha1.5) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Translator (3.0.0-alpha1.5) - restriction: >= net7.0
Brahma.FSharp.OpenCL.AST (>= 3.0.0-alpha1.5) - restriction: >= net7.0
Brahma.FSharp.OpenCL.Shared (>= 3.0.0-alpha1.5) - restriction: >= net7.0
FSharp.Core (7.0) - restriction: >= net7.0
FSharp.Quotations.Evaluator (>= 2.1) - restriction: >= net7.0
FSharpx.Collections (>= 3.1) - restriction: >= net7.0
@@ -849,7 +849,7 @@ NUGET
System.Xml.XmlDocument (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
TypeShape (9.0)
FSharp.Core (>= 4.3.2) - restriction: >= netstandard2.0
YC.OpenCL.NET (3.0.0-alpha1.3) - restriction: >= net7.0
YC.OpenCL.NET (3.0.0-alpha1.5) - restriction: >= net7.0
ExtraConstraints.Fody (1.14) - restriction: >= net7.0
Microsoft.Build.Framework (16.10) - restriction: >= net7.0
System.CodeDom (>= 7.0) - restriction: >= net7.0
@@ -1071,7 +1071,7 @@ NUGET
System.Security.AccessControl (>= 5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp2.0)) (>= monotouch) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0)) (>= net461) (>= netcoreapp2.1) (>= uap10.1) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos)
System.Security.Principal.Windows (>= 5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp2.0)) (>= monotouch) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0)) (>= net461) (>= netcoreapp2.1) (>= uap10.1) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos)
Mono.Posix.NETStandard (1.0) - restriction: >= netstandard2.0
MSBuild.StructuredLogger (2.2.206) - restriction: >= netstandard2.0
MSBuild.StructuredLogger (2.2.235) - restriction: >= netstandard2.0
Microsoft.Build.Framework (>= 17.5) - restriction: >= netstandard2.0
Microsoft.Build.Utilities.Core (>= 17.5) - restriction: >= netstandard2.0
Newtonsoft.Json (13.0.3) - restriction: >= netstandard2.0
@@ -1316,7 +1316,7 @@ NUGET
System.Security.AccessControl (>= 5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp2.0)) (>= monotouch) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0)) (>= net461) (>= netcoreapp2.1) (>= uap10.1) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos)
System.Security.Principal.Windows (>= 5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp2.0)) (>= monotouch) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0)) (>= net461) (>= netcoreapp2.1) (>= uap10.1) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos)
Mono.Posix.NETStandard (1.0) - restriction: >= netstandard2.0
MSBuild.StructuredLogger (2.2.206) - restriction: >= netstandard2.0
MSBuild.StructuredLogger (2.2.235) - restriction: >= netstandard2.0
Microsoft.Build.Framework (>= 17.5) - restriction: >= netstandard2.0
Microsoft.Build.Utilities.Core (>= 17.5) - restriction: >= netstandard2.0
Newtonsoft.Json (13.0.3) - restriction: >= netstandard2.0
22 changes: 11 additions & 11 deletions src/GraphBLAS-sharp.Backend/Algorithms/BFS.fs
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ module internal BFS =
let containsNonZero =
Vector.exists Predicates.isSome clContext workGroupSize

fun (queue: DeviceCommandQueue<Msg>) (matrix: ClMatrix<bool>) (source: int) ->
fun (queue: RawCommandQueue) (matrix: ClMatrix<bool>) (source: int) ->
let vertexCount = matrix.RowCount

let levels =
@@ -62,7 +62,7 @@ module internal BFS =
not
<| (containsNonZero queue front).ToHostAndFree queue

front.Dispose queue
front.Dispose()

levels

@@ -87,7 +87,7 @@ module internal BFS =
let fillSubVectorTo =
Vector.assignByMaskInPlace Mask.assign clContext workGroupSize

fun (queue: DeviceCommandQueue<Msg>) (matrix: ClMatrix<bool>) (source: int) ->
fun (queue: RawCommandQueue) (matrix: ClMatrix<bool>) (source: int) ->
let vertexCount = matrix.RowCount

let levels =
@@ -108,18 +108,18 @@ module internal BFS =
//Getting new frontier
match spMSpV queue matrix front with
| None ->
front.Dispose queue
front.Dispose()
stop <- true
| Some newFrontier ->
front.Dispose queue
front.Dispose()
//Filtering visited vertices
match maskComplemented queue DeviceOnly newFrontier levels with
| None ->
stop <- true
newFrontier.Dispose queue
newFrontier.Dispose()
| Some f ->
front <- f
newFrontier.Dispose queue
newFrontier.Dispose()

levels

@@ -159,17 +159,17 @@ module internal BFS =
ClArray.count Predicates.isSome clContext workGroupSize

//Push or pull functions
let getNNZ (queue: DeviceCommandQueue<Msg>) (v: ClVector<bool>) =
let getNNZ (queue: RawCommandQueue) (v: ClVector<bool>) =
match v with
| ClVector.Sparse v -> v.NNZ
| ClVector.Dense v -> countNNZ queue v

let SPARSITY = 0.001f
let SPARSITY = 0.05f

let push nnz size =
(float32 nnz) / (float32 size) <= SPARSITY

fun (queue: DeviceCommandQueue<Msg>) (matrix: ClMatrix<bool>) (source: int) ->
fun (queue: RawCommandQueue) (matrix: ClMatrix<bool>) (source: int) ->
let vertexCount = matrix.RowCount

let levels =
@@ -192,7 +192,7 @@ module internal BFS =
//Getting new frontier
match spMSpV queue matrix frontier with
| None ->
frontier.Dispose queue
frontier.Dispose()
stop <- true
| Some newFrontier ->
frontier.Dispose queue
Loading