Skip to content

Commit e5ad7ac

Browse files
authored
Merge pull request #95 from kirillgarbar/command-queue
RawCommandQueue
2 parents 108c45c + 2f7ffe8 commit e5ad7ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1819
-1681
lines changed

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ open GraphBLAS.FSharp.IO
99
open GraphBLAS.FSharp.Benchmarks
1010
open GraphBLAS.FSharp.Objects
1111
open GraphBLAS.FSharp.Objects.ArraysExtensions
12-
open GraphBLAS.FSharp.Objects.MailboxProcessorExtensions
1312
open GraphBLAS.FSharp.Backend.Quotes
1413

1514
[<AbstractClass>]
@@ -41,7 +40,7 @@ type Benchmarks<'elem when 'elem : struct>(
4140

4241
member this.Processor =
4342
let p = (fst this.OclContextInfo).Queue
44-
p.Error.Add(fun e -> failwithf "%A" e)
43+
//p.Error.Add(fun e -> failwithf "%A" e)
4544
p
4645

4746
static member AvailableContexts = Utils.availableContexts
@@ -70,7 +69,7 @@ type Benchmarks<'elem when 'elem : struct>(
7069
this.ResultLevels <- this.FunToBenchmark this.Processor matrix vertex
7170

7271
member this.ClearInputMatrix() =
73-
matrix.Dispose this.Processor
72+
matrix.Dispose()
7473

7574
member this.ClearResult() =
7675
match this.ResultLevels with
@@ -114,12 +113,12 @@ type WithoutTransferBenchmark<'elem when 'elem : struct>(
114113
override this.GlobalSetup() =
115114
this.ReadMatrix()
116115
this.LoadMatrixToGPU()
117-
finish this.Processor
116+
this.Processor.Synchronize()
118117

119118
[<IterationCleanup>]
120119
override this.IterationCleanup() =
121120
this.ClearResult()
122-
finish this.Processor
121+
this.Processor.Synchronize()
123122

124123
[<GlobalCleanup>]
125124
override this.GlobalCleanup() =
@@ -128,7 +127,7 @@ type WithoutTransferBenchmark<'elem when 'elem : struct>(
128127
[<Benchmark>]
129128
override this.Benchmark() =
130129
this.BFS()
131-
this.Processor.PostAndReply Msg.MsgNotifyMe
130+
this.Processor.Synchronize()
132131

133132
type BFSWithoutTransferBenchmarkBool() =
134133

@@ -183,7 +182,7 @@ type WithTransferBenchmark<'elem when 'elem : struct>(
183182
[<GlobalSetup>]
184183
override this.GlobalSetup() =
185184
this.ReadMatrix()
186-
finish this.Processor
185+
this.Processor.Synchronize()
187186

188187
[<GlobalCleanup>]
189188
override this.GlobalCleanup() =
@@ -193,7 +192,7 @@ type WithTransferBenchmark<'elem when 'elem : struct>(
193192
override this.IterationCleanup() =
194193
this.ClearInputMatrix()
195194
this.ClearResult()
196-
finish this.Processor
195+
this.Processor.Synchronize()
197196

198197
[<Benchmark>]
199198
override this.Benchmark() =
@@ -202,7 +201,7 @@ type WithTransferBenchmark<'elem when 'elem : struct>(
202201
match this.ResultLevels with
203202
| ClVector.Dense result ->
204203
result.ToHost this.Processor |> ignore
205-
this.Processor.PostAndReply Msg.MsgNotifyMe
204+
this.Processor.Synchronize()
206205
| _ -> failwith "Impossible"
207206

208207
type BFSWithTransferBenchmarkBool() =

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ open GraphBLAS.FSharp.IO
77
open Brahma.FSharp
88
open Microsoft.FSharp.Core
99
open GraphBLAS.FSharp.Objects.ArraysExtensions
10-
open GraphBLAS.FSharp.Objects.MailboxProcessorExtensions
1110
open GraphBLAS.FSharp.Benchmarks
1211
open GraphBLAS.FSharp.Objects
1312

@@ -40,7 +39,7 @@ type Benchmarks(
4039

4140
member this.Processor =
4241
let p = (fst this.OclContextInfo).Queue
43-
p.Error.Add(fun e -> failwithf "%A" e)
42+
//p.Error.Add(fun e -> failwithf "%A" e)
4443
p
4544

4645
static member AvailableContexts = Utils.availableContexts
@@ -69,12 +68,12 @@ type Benchmarks(
6968
this.Result <- this.FunToBenchmark this.Processor matrixPrepared Constants.PageRank.accuracy
7069

7170
member this.ClearInputMatrix() =
72-
matrix.Dispose this.Processor
71+
matrix.Dispose()
7372

7473
member this.ClearPreparedMatrix() =
75-
matrixPrepared.Dispose this.Processor
74+
matrixPrepared.Dispose()
7675

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

7978
member this.ReadMatrix() =
8079
let converter =
@@ -113,15 +112,15 @@ type PageRankWithoutTransferBenchmarkFloat32() =
113112
override this.GlobalSetup() =
114113
this.ReadMatrix()
115114
this.LoadMatrixToGPU()
116-
finish this.Processor
115+
this.Processor.Synchronize()
117116
this.PrepareMatrix()
118117
this.ClearInputMatrix()
119-
finish this.Processor
118+
this.Processor.Synchronize()
120119

121120
[<IterationCleanup>]
122121
override this.IterationCleanup() =
123122
this.ClearResult()
124-
finish this.Processor
123+
this.Processor.Synchronize()
125124

126125
[<GlobalCleanup>]
127126
override this.GlobalCleanup() =
@@ -130,4 +129,4 @@ type PageRankWithoutTransferBenchmarkFloat32() =
130129
[<Benchmark>]
131130
override this.Benchmark() =
132131
this.PageRank()
133-
finish this.Processor
132+
this.Processor.Synchronize()
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
wing.mtx
22
coAuthorsCiteseer.mtx
3-
hollywood-2009.mtx
4-
roadNet-CA.mtx
3+
!hollywood-2009.mtx
4+
roadNet-CA.mtx
5+
belgium_osm.mtx
6+
road_central.mtx
7+
coPapersDBLP.mtx

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
@@ -25,9 +25,9 @@
2525
<Compile Include="Matrix/Map2/MathNET.fs" />
2626
<Compile Include="Vector/Map2.fs" />
2727
<Compile Include="Algorithms/BFS.fs" />
28-
<Compile Include="Algorithms/PageRank.fs" />
28+
<Compile Include="Algorithms/PageRank.fs" />
2929
<Compile Include="Program.fs" />
3030
<Folder Include="Datasets" />
3131
</ItemGroup>
3232
<Import Project="..\..\.paket\Paket.Restore.targets" />
33-
</Project>
33+
</Project>

benchmarks/GraphBLAS-sharp.Benchmarks/Helpers.fs

+14-9
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: MailboxProcessor<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/Matrix/Map2/Map2.fs

+10-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ open GraphBLAS.FSharp.IO
88
open GraphBLAS.FSharp.Objects
99
open GraphBLAS.FSharp.Objects.MatrixExtensions
1010
open GraphBLAS.FSharp.Objects.ClContextExtensions
11-
open GraphBLAS.FSharp.Objects.MailboxProcessorExtensions
1211
open GraphBLAS.FSharp.Backend.Quotes
1312
open GraphBLAS.FSharp.Benchmarks
1413

@@ -41,7 +40,7 @@ type Benchmarks<'matrixT, 'elem when 'matrixT :> IDeviceMemObject and 'elem : st
4140

4241
member this.Processor =
4342
let p = (fst this.OclContextInfo).Queue
44-
p.Error.Add(fun e -> failwithf "%A" e)
43+
//p.Error.Add(fun e -> failwithf "%A" e)
4544
p
4645

4746
static member AvailableContexts = Utils.availableContexts
@@ -80,11 +79,11 @@ type Benchmarks<'matrixT, 'elem when 'matrixT :> IDeviceMemObject and 'elem : st
8079
this.ResultMatrix <- this.FunToBenchmark this.Processor HostInterop firstMatrix secondMatrix
8180

8281
member this.ClearInputMatrices() =
83-
firstMatrix.Dispose this.Processor
84-
secondMatrix.Dispose this.Processor
82+
firstMatrix.Dispose()
83+
secondMatrix.Dispose()
8584

8685
member this.ClearResult() =
87-
this.ResultMatrix.Dispose this.Processor
86+
this.ResultMatrix.Dispose()
8887

8988
member this.ReadMatrices() =
9089
firstMatrixHost <- this.ReadMatrix <| fst this.InputMatrixReader
@@ -119,12 +118,12 @@ module WithoutTransfer =
119118
override this.GlobalSetup() =
120119
this.ReadMatrices ()
121120
this.LoadMatricesToGPU ()
122-
finish this.Processor
121+
this.Processor.Synchronize()
123122

124123
[<Benchmark>]
125124
override this.Benchmark () =
126125
this.EWiseAddition()
127-
finish this.Processor
126+
this.Processor.Synchronize()
128127

129128
[<IterationCleanup>]
130129
override this.IterationCleanup () =
@@ -252,7 +251,7 @@ module WithTransfer =
252251
[<GlobalSetup>]
253252
override this.GlobalSetup() =
254253
this.ReadMatrices()
255-
finish this.Processor
254+
this.Processor.Synchronize()
256255

257256
[<GlobalCleanup>]
258257
override this.GlobalCleanup() = ()
@@ -261,16 +260,15 @@ module WithTransfer =
261260
override this.IterationCleanup() =
262261
this.ClearInputMatrices()
263262
this.ClearResult()
264-
finish this.Processor
263+
this.Processor.Synchronize()
265264

266265
[<Benchmark>]
267266
override this.Benchmark() =
268267
this.LoadMatricesToGPU()
269268
this.EWiseAddition()
270-
this.Processor.PostAndReply Msg.MsgNotifyMe
269+
this.Processor.Synchronize()
271270
resultToHost this.ResultMatrix this.Processor |> ignore
272-
this.Processor.PostAndReply Msg.MsgNotifyMe
273-
271+
this.Processor.Synchronize()
274272
module COO =
275273
type Float32() =
276274

benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Expand.fs

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ open GraphBLAS.FSharp.IO
88
open GraphBLAS.FSharp.Backend.Quotes
99
open GraphBLAS.FSharp.Objects
1010
open GraphBLAS.FSharp.Objects.ClContextExtensions
11-
open GraphBLAS.FSharp.Objects.MailboxProcessorExtensions
1211
open GraphBLAS.FSharp.Benchmarks
1312

1413
[<AbstractClass>]
@@ -40,7 +39,7 @@ type Benchmarks<'elem when 'elem : struct>(
4039

4140
member this.Processor =
4241
let p = (fst this.OclContextInfo).Queue
43-
p.Error.Add(fun e -> failwithf "%A" e)
42+
//p.Error.Add(fun e -> failwithf "%A" e)
4443
p
4544

4645
static member AvailableContexts = Utils.availableContexts
@@ -78,11 +77,11 @@ type Benchmarks<'elem when 'elem : struct>(
7877
this.ResultMatrix <- this.FunToBenchmark this.Processor DeviceOnly matrix matrix
7978

8079
member this.ClearInputMatrices() =
81-
matrix.Dispose this.Processor
80+
matrix.Dispose()
8281

8382
member this.ClearResult() =
8483
match this.ResultMatrix with
85-
| Some matrix -> matrix.Dispose this.Processor
84+
| Some matrix -> matrix.Dispose()
8685
| None -> ()
8786

8887
member this.ReadMatrices() =
@@ -116,17 +115,17 @@ module WithoutTransfer =
116115
override this.GlobalSetup() =
117116
this.ReadMatrices()
118117
this.LoadMatricesToGPU()
119-
finish this.Processor
118+
this.Processor.Synchronize()
120119

121120
[<Benchmark>]
122121
override this.Benchmark() =
123122
this.Mxm()
124-
finish this.Processor
123+
this.Processor.Synchronize()
125124

126125
[<IterationCleanup>]
127126
override this.IterationCleanup () =
128127
this.ClearResult()
129-
finish this.Processor
128+
this.Processor.Synchronize()
130129

131130
[<GlobalCleanup>]
132131
override this.GlobalCleanup () =

0 commit comments

Comments
 (0)