Skip to content

Commit 4485640

Browse files
committed
RawCommandQueue 1
1 parent 1b0a670 commit 4485640

File tree

18 files changed

+134
-257
lines changed

18 files changed

+134
-257
lines changed

benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/PageRank.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type Benchmarks(
7373
member this.ClearPreparedMatrix() =
7474
matrixPrepared.Dispose this.Processor
7575

76-
member this.ClearResult() = this.Result.Dispose this.Processor
76+
member this.ClearResult() = this.Result.Dispose()
7777

7878
member this.ReadMatrix() =
7979
let converter =

benchmarks/GraphBLAS-sharp.Benchmarks/Common/SetArgs.fs

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

benchmarks/GraphBLAS-sharp.Benchmarks/GraphBLAS-sharp.Benchmarks.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<Compile Include="Helpers.fs" />
2020
<Compile Include="Columns.fs" />
2121
<Compile Include="Configs.fs" />
22-
<Compile Include="Common/SetArgs.fs" />
2322
<Compile Include="Matrix/SpGeMM/Masked.fs" />
2423
<Compile Include="Matrix/SpGeMM/Expand.fs" />
2524
<Compile Include="Matrix/Map2/Map2.fs" />

benchmarks/GraphBLAS-sharp.Benchmarks/Helpers.fs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ open Expecto
1515
module Utils =
1616
type BenchmarkContext =
1717
{ ClContext: Brahma.FSharp.ClContext
18-
Queue: DeviceCommandQueue<Msg> }
18+
Queue: RawCommandQueue }
1919

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

106-
let queue = context.QueueProvider.CreateQueue()
106+
let queue =
107+
RawCommandQueue(context.ClDevice.Device, context.Context, context.Translator)
107108

108109
{ ClContext = context; Queue = queue })
110+
109111
seq {
110112
for wgSize in workGroupSizes do
111113
for context in contexts do
@@ -119,13 +121,14 @@ module Utils =
119121

120122
let normalFloatGenerator =
121123
(Arb.Default.NormalFloat()
122-
|> Arb.toGen
123-
|> Gen.map float)
124+
|> Arb.toGen
125+
|> Gen.map float)
124126

125-
let fIsEqual x y = abs (x - y) < Accuracy.medium.absolute || x.Equals y
127+
let fIsEqual x y =
128+
abs (x - y) < Accuracy.medium.absolute
129+
|| x.Equals y
126130

127-
let nextInt (random: System.Random) =
128-
random.Next()
131+
let nextInt (random: System.Random) = random.Next()
129132

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

146149
let floatPair format =
147-
let fIsEqual x y = abs (x - y) < Accuracy.medium.absolute || x = y
150+
let fIsEqual x y =
151+
abs (x - y) < Accuracy.medium.absolute || x = y
148152

149-
let createVector array = Utils.createVectorFromArray format array (fIsEqual 0.0)
153+
let createVector array =
154+
Utils.createVectorFromArray format array (fIsEqual 0.0)
150155

151156
pairOfVectorsOfEqualSize Utils.normalFloatGenerator createVector

benchmarks/GraphBLAS-sharp.Benchmarks/Program.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ open BenchmarkDotNet.Running
44
[<EntryPoint>]
55
let main argv =
66
let benchmarks =
7-
BenchmarkSwitcher [| typeof<Common.SetArgs.BenchmarkSetArgs> |]
7+
BenchmarkSwitcher [| typeof<Algorithms.BFS.BFSWithoutTransferBenchmarkBool> |]
88

99
benchmarks.Run argv |> ignore
1010
0

benchmarks/GraphBLAS-sharp.Benchmarks/Vector/Map2.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ type Benchmarks<'elem when 'elem : struct>(
6363
| ex -> raise ex
6464

6565
member this.ClearInputVectors()=
66-
firstVector.Dispose this.Processor
67-
secondVector.Dispose this.Processor
66+
firstVector.Dispose()
67+
secondVector.Dispose()
6868

6969
member this.ClearResult() =
7070
match this.ResultVector with
71-
| Some v -> v.Dispose this.Processor
71+
| Some v -> v.Dispose()
7272
| None -> ()
7373

7474
member this.CreateVectors() =

paket.dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ nuget System.CodeDom >= 7.0
1616
nuget FSharp.Quotations.Evaluator 2.1.0
1717
nuget FSharpx.Collections >= 3.1
1818
nuget FSharpx.Text.StructuredFormat >= 3.1
19-
nuget Brahma.FSharp 3.0.0-alpha1.3
19+
nuget Brahma.FSharp 3.0.0-alpha1.5
2020
nuget BenchmarkDotNet
2121
nuget MathNet.Numerics.FSharp 4.0.0
2222
nuget MathNet.Numerics.MKL.Win-x64 2.5.0

paket.lock

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ NUGET
1919
System.Reflection.Emit.Lightweight (>= 4.7) - restriction: && (< net6.0) (>= netstandard2.0)
2020
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: && (< net6.0) (>= netstandard2.0)
2121
BenchmarkDotNet.Annotations (0.13.12) - restriction: >= netstandard2.0
22-
Brahma.FSharp (3.0.0-alpha1.3)
23-
Brahma.FSharp.OpenCL.Printer (>= 3.0.0-alpha1.3) - restriction: >= net7.0
24-
Brahma.FSharp.OpenCL.Shared (>= 3.0.0-alpha1.3) - restriction: >= net7.0
25-
Brahma.FSharp.OpenCL.Translator (>= 3.0.0-alpha1.3) - restriction: >= net7.0
22+
Brahma.FSharp (3.0.0-alpha1.5)
23+
Brahma.FSharp.OpenCL.Printer (>= 3.0.0-alpha1.5) - restriction: >= net7.0
24+
Brahma.FSharp.OpenCL.Shared (>= 3.0.0-alpha1.5) - restriction: >= net7.0
25+
Brahma.FSharp.OpenCL.Translator (>= 3.0.0-alpha1.5) - restriction: >= net7.0
2626
FSharp.Core (7.0) - restriction: >= net7.0
2727
FSharp.Quotations.Evaluator (>= 2.1) - restriction: >= net7.0
28-
YC.OpenCL.NET (>= 3.0.0-alpha1.3) - restriction: >= net7.0
29-
Brahma.FSharp.OpenCL.AST (3.0.0-alpha1.3) - restriction: >= net7.0
28+
YC.OpenCL.NET (>= 3.0.0-alpha1.5) - restriction: >= net7.0
29+
Brahma.FSharp.OpenCL.AST (3.0.0-alpha1.5) - restriction: >= net7.0
3030
FSharp.Core (7.0) - restriction: >= net7.0
31-
Brahma.FSharp.OpenCL.Printer (3.0.0-alpha1.3) - restriction: >= net7.0
32-
Brahma.FSharp.OpenCL.AST (>= 3.0.0-alpha1.3) - restriction: >= net7.0
33-
Brahma.FSharp.OpenCL.Translator (>= 3.0.0-alpha1.3) - restriction: >= net7.0
31+
Brahma.FSharp.OpenCL.Printer (3.0.0-alpha1.5) - restriction: >= net7.0
32+
Brahma.FSharp.OpenCL.AST (>= 3.0.0-alpha1.5) - restriction: >= net7.0
33+
Brahma.FSharp.OpenCL.Translator (>= 3.0.0-alpha1.5) - restriction: >= net7.0
3434
FSharp.Core (7.0) - restriction: >= net7.0
3535
FSharpx.Collections (>= 3.1) - restriction: >= net7.0
3636
FSharpx.Text.StructuredFormat (>= 3.1) - restriction: >= net7.0
37-
Brahma.FSharp.OpenCL.Shared (3.0.0-alpha1.3) - restriction: >= net7.0
38-
YC.OpenCL.NET (>= 3.0.0-alpha1.3) - restriction: >= net7.0
39-
Brahma.FSharp.OpenCL.Translator (3.0.0-alpha1.3) - restriction: >= net7.0
40-
Brahma.FSharp.OpenCL.AST (>= 3.0.0-alpha1.3) - restriction: >= net7.0
41-
Brahma.FSharp.OpenCL.Shared (>= 3.0.0-alpha1.3) - restriction: >= net7.0
37+
Brahma.FSharp.OpenCL.Shared (3.0.0-alpha1.5) - restriction: >= net7.0
38+
YC.OpenCL.NET (>= 3.0.0-alpha1.5) - restriction: >= net7.0
39+
Brahma.FSharp.OpenCL.Translator (3.0.0-alpha1.5) - restriction: >= net7.0
40+
Brahma.FSharp.OpenCL.AST (>= 3.0.0-alpha1.5) - restriction: >= net7.0
41+
Brahma.FSharp.OpenCL.Shared (>= 3.0.0-alpha1.5) - restriction: >= net7.0
4242
FSharp.Core (7.0) - restriction: >= net7.0
4343
FSharp.Quotations.Evaluator (>= 2.1) - restriction: >= net7.0
4444
FSharpx.Collections (>= 3.1) - restriction: >= net7.0
@@ -849,7 +849,7 @@ NUGET
849849
System.Xml.XmlDocument (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
850850
TypeShape (9.0)
851851
FSharp.Core (>= 4.3.2) - restriction: >= netstandard2.0
852-
YC.OpenCL.NET (3.0.0-alpha1.3) - restriction: >= net7.0
852+
YC.OpenCL.NET (3.0.0-alpha1.5) - restriction: >= net7.0
853853
ExtraConstraints.Fody (1.14) - restriction: >= net7.0
854854
Microsoft.Build.Framework (16.10) - restriction: >= net7.0
855855
System.CodeDom (>= 7.0) - restriction: >= net7.0
@@ -1071,7 +1071,7 @@ NUGET
10711071
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)
10721072
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)
10731073
Mono.Posix.NETStandard (1.0) - restriction: >= netstandard2.0
1074-
MSBuild.StructuredLogger (2.2.206) - restriction: >= netstandard2.0
1074+
MSBuild.StructuredLogger (2.2.235) - restriction: >= netstandard2.0
10751075
Microsoft.Build.Framework (>= 17.5) - restriction: >= netstandard2.0
10761076
Microsoft.Build.Utilities.Core (>= 17.5) - restriction: >= netstandard2.0
10771077
Newtonsoft.Json (13.0.3) - restriction: >= netstandard2.0
@@ -1316,7 +1316,7 @@ NUGET
13161316
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)
13171317
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)
13181318
Mono.Posix.NETStandard (1.0) - restriction: >= netstandard2.0
1319-
MSBuild.StructuredLogger (2.2.206) - restriction: >= netstandard2.0
1319+
MSBuild.StructuredLogger (2.2.235) - restriction: >= netstandard2.0
13201320
Microsoft.Build.Framework (>= 17.5) - restriction: >= netstandard2.0
13211321
Microsoft.Build.Utilities.Core (>= 17.5) - restriction: >= netstandard2.0
13221322
Newtonsoft.Json (13.0.3) - restriction: >= netstandard2.0

src/GraphBLAS-sharp.Backend/Algorithms/BFS.fs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module internal BFS =
3434
let containsNonZero =
3535
Vector.exists Predicates.isSome clContext workGroupSize
3636

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

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

65-
front.Dispose queue
65+
front.Dispose()
6666

6767
levels
6868

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

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

9393
let levels =
@@ -108,18 +108,18 @@ module internal BFS =
108108
//Getting new frontier
109109
match spMSpV queue matrix front with
110110
| None ->
111-
front.Dispose queue
111+
front.Dispose()
112112
stop <- true
113113
| Some newFrontier ->
114-
front.Dispose queue
114+
front.Dispose()
115115
//Filtering visited vertices
116116
match maskComplemented queue DeviceOnly newFrontier levels with
117117
| None ->
118118
stop <- true
119-
newFrontier.Dispose queue
119+
newFrontier.Dispose()
120120
| Some f ->
121121
front <- f
122-
newFrontier.Dispose queue
122+
newFrontier.Dispose()
123123

124124
levels
125125

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

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

167-
let SPARSITY = 0.001f
167+
let SPARSITY = 0.05f
168168

169169
let push nnz size =
170170
(float32 nnz) / (float32 size) <= SPARSITY
171171

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

175175
let levels =
@@ -192,7 +192,7 @@ module internal BFS =
192192
//Getting new frontier
193193
match spMSpV queue matrix frontier with
194194
| None ->
195-
frontier.Dispose queue
195+
frontier.Dispose()
196196
stop <- true
197197
| Some newFrontier ->
198198
frontier.Dispose queue

0 commit comments

Comments
 (0)