Skip to content

Commit 1ad11ad

Browse files
authored
Merge pull request #61 from IgorErin/ewisegen
Refactor
2 parents 999799c + 9d52870 commit 1ad11ad

38 files changed

Lines changed: 298 additions & 572 deletions

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksMxm.fs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ type MxmBenchmarks<'elem when 'elem : struct>(
2626

2727
let mutable firstMatrix = Unchecked.defaultof<ClMatrix<'elem>>
2828
let mutable secondMatrix = Unchecked.defaultof<ClMatrix<'elem>>
29-
let mutable mask = Unchecked.defaultof<ClMask2D>
29+
let mutable mask = Unchecked.defaultof<ClMatrix<_>>
3030

3131
let mutable firstMatrixHost = Unchecked.defaultof<_>
3232
let mutable secondMatrixHost = Unchecked.defaultof<_>
33-
let mutable maskHost = Unchecked.defaultof<Mask2D>
33+
let mutable maskHost = Unchecked.defaultof<Matrix<_>>
3434

3535
member val ResultMatrix = Unchecked.defaultof<ClMatrix<'elem>> with get, set
3636

@@ -108,15 +108,7 @@ type MxmBenchmarks<'elem when 'elem : struct>(
108108
this.ResultMatrix.Dispose this.Processor
109109

110110
member this.ReadMask(maskReader) =
111-
match this.ReadMatrix maskReader with
112-
| Matrix.COO m ->
113-
maskHost <-
114-
{ IsComplemented = false
115-
RowCount = m.RowCount
116-
ColumnCount = m.ColumnCount
117-
Rows = m.Rows
118-
Columns = m.Columns }
119-
| _ -> failwith "Unsupported matrix format"
111+
maskHost <- this.ReadMatrix maskReader
120112

121113
member this.ReadMatrices() =
122114
let matrixReader, maskReader = this.InputMatrixReader
@@ -127,7 +119,7 @@ type MxmBenchmarks<'elem when 'elem : struct>(
127119
member this.LoadMatricesToGPU () =
128120
firstMatrix <- buildMatrix this.OclContext firstMatrixHost
129121
secondMatrix <- buildMatrix this.OclContext secondMatrixHost
130-
mask <- maskHost.ToBackend(this.OclContext)
122+
mask <- maskHost.ToDevice this.OclContext
131123

132124
member this.ConvertSecondMatrixToCSC() =
133125
secondMatrix <- this.FunCSR2CSC this.Processor HostInterop secondMatrix

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 >= 2.0.1
19+
nuget Brahma.FSharp >= 2.0.4
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: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ NUGET
1818
System.Reflection.Emit.Lightweight (>= 4.7) - restriction: >= netstandard2.0
1919
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: >= netstandard2.0
2020
BenchmarkDotNet.Annotations (0.13.2) - restriction: >= netstandard2.0
21-
Brahma.FSharp (2.0.3)
22-
Brahma.FSharp.OpenCL.Printer (>= 2.0.3) - restriction: >= net7.0
23-
Brahma.FSharp.OpenCL.Shared (>= 2.0.3) - restriction: >= net7.0
24-
Brahma.FSharp.OpenCL.Translator (>= 2.0.3) - restriction: >= net7.0
21+
Brahma.FSharp (2.0.4)
22+
Brahma.FSharp.OpenCL.Printer (>= 2.0.4) - restriction: >= net7.0
23+
Brahma.FSharp.OpenCL.Shared (>= 2.0.4) - restriction: >= net7.0
24+
Brahma.FSharp.OpenCL.Translator (>= 2.0.4) - restriction: >= net7.0
2525
FSharp.Core (7.0) - restriction: >= net7.0
2626
FSharp.Quotations.Evaluator (>= 2.1) - restriction: >= net7.0
27-
YC.OpenCL.NET (>= 2.0.3) - restriction: >= net7.0
28-
Brahma.FSharp.OpenCL.AST (2.0.3) - restriction: >= net7.0
27+
YC.OpenCL.NET (>= 2.0.4) - restriction: >= net7.0
28+
Brahma.FSharp.OpenCL.AST (2.0.4) - restriction: >= net7.0
2929
FSharp.Core (7.0) - restriction: >= net7.0
30-
Brahma.FSharp.OpenCL.Printer (2.0.3) - restriction: >= net7.0
31-
Brahma.FSharp.OpenCL.AST (>= 2.0.3) - restriction: >= net7.0
32-
Brahma.FSharp.OpenCL.Translator (>= 2.0.3) - restriction: >= net7.0
30+
Brahma.FSharp.OpenCL.Printer (2.0.4) - restriction: >= net7.0
31+
Brahma.FSharp.OpenCL.AST (>= 2.0.4) - restriction: >= net7.0
32+
Brahma.FSharp.OpenCL.Translator (>= 2.0.4) - restriction: >= net7.0
3333
FSharp.Core (7.0) - restriction: >= net7.0
3434
FSharpx.Collections (>= 3.1) - restriction: >= net7.0
3535
FSharpx.Text.StructuredFormat (>= 3.1) - restriction: >= net7.0
36-
Brahma.FSharp.OpenCL.Shared (2.0.3) - restriction: >= net7.0
37-
YC.OpenCL.NET (>= 2.0.3) - restriction: >= net7.0
38-
Brahma.FSharp.OpenCL.Translator (2.0.3) - restriction: >= net7.0
39-
Brahma.FSharp.OpenCL.AST (>= 2.0.3) - restriction: >= net7.0
40-
Brahma.FSharp.OpenCL.Shared (>= 2.0.3) - restriction: >= net7.0
36+
Brahma.FSharp.OpenCL.Shared (2.0.4) - restriction: >= net7.0
37+
YC.OpenCL.NET (>= 2.0.4) - restriction: >= net7.0
38+
Brahma.FSharp.OpenCL.Translator (2.0.4) - restriction: >= net7.0
39+
Brahma.FSharp.OpenCL.AST (>= 2.0.4) - restriction: >= net7.0
40+
Brahma.FSharp.OpenCL.Shared (>= 2.0.4) - restriction: >= net7.0
4141
FSharp.Core (7.0) - restriction: >= net7.0
4242
FSharp.Quotations.Evaluator (>= 2.1) - restriction: >= net7.0
4343
FSharpx.Collections (>= 3.1) - restriction: >= net7.0
@@ -501,7 +501,7 @@ NUGET
501501
System.Globalization (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
502502
System.Reflection (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
503503
System.Runtime (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
504-
System.Runtime (4.3.1) - restriction: || (&& (< monoandroid) (< net45) (< netstandard1.4) (>= netstandard1.6)) (&& (< monoandroid) (< netstandard1.1) (>= netstandard1.6) (< win8)) (&& (< net45) (< netstandard1.2) (>= netstandard1.6) (< win8)) (&& (< net45) (< netstandard1.3) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (< netstandard1.4) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (< netstandard1.5) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (>= netstandard1.6) (< netstandard2.0)) (&& (< netstandard1.1) (>= netstandard1.6) (>= uap10.0) (< win8)) (&& (< netstandard1.3) (>= netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.6) (< portable-net45+win8+wpa81)) (&& (< netstandard2.0) (>= uap10.0))
504+
System.Runtime (4.3.1) - restriction: || (&& (< monoandroid) (< netstandard1.1) (>= netstandard1.6) (< win8)) (&& (< net45) (< netstandard1.2) (>= netstandard1.6) (< win8)) (&& (< net45) (< netstandard1.3) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (< netstandard1.4) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (< netstandard1.5) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (>= netstandard1.6) (< netstandard2.0)) (&& (< netstandard1.1) (>= netstandard1.6) (>= uap10.0) (< win8)) (&& (< netstandard1.3) (>= netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.6) (< portable-net45+win8+wpa81)) (&& (< netstandard2.0) (>= uap10.0))
505505
Microsoft.NETCore.Platforms (>= 1.1.1) - restriction: || (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.2) (< win8) (< wp8)) (&& (< monoandroid) (< net45) (>= netstandard1.2) (< netstandard1.3) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.3) (< netstandard1.5) (< win8) (< wpa81)) (&& (< monotouch) (< net45) (>= netstandard1.5) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos))
506506
Microsoft.NETCore.Targets (>= 1.1.3) - restriction: || (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.2) (< win8) (< wp8)) (&& (< monoandroid) (< net45) (>= netstandard1.2) (< netstandard1.3) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.3) (< netstandard1.5) (< win8) (< wpa81)) (&& (< monotouch) (< net45) (>= netstandard1.5) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos))
507507
System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1)) (>= net462) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= xamarinios)) (&& (< net6.0) (>= xamarinmac)) (>= netstandard2.0)
@@ -744,7 +744,7 @@ NUGET
744744
System.Xml.XmlDocument (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)
745745
TypeShape (9.0)
746746
FSharp.Core (>= 4.3.2) - restriction: >= netstandard2.0
747-
YC.OpenCL.NET (2.0.3) - restriction: >= net7.0
747+
YC.OpenCL.NET (2.0.4) - restriction: >= net7.0
748748
ExtraConstraints.Fody (1.14) - restriction: >= net7.0
749749
Microsoft.Build.Framework (16.10) - restriction: >= net7.0
750750
System.CodeDom (>= 7.0) - restriction: >= net7.0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module BFS =
1515
let singleSource
1616
(clContext: ClContext)
1717
(add: Expr<int option -> int option -> int option>)
18-
(mul: Expr<'a option -> 'b option -> int option>)
18+
(mul: Expr<'a option -> int option -> int option>)
1919
workGroupSize
2020
=
2121

src/GraphBLAS-sharp.Backend/Common/BitonicSort.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ module internal BitonicSort =
290290
queue.Post(Msg.MsgSetArguments(fun () -> kernel.KernelFunc ndRange rows cols values values.Length))
291291
queue.Post(Msg.CreateRunMsg<_, _>(kernel))
292292

293-
let sortKeyValuesInplace (clContext: ClContext) workGroupSize =
293+
let sortKeyValuesInplace<'n, 'a when 'n: comparison> (clContext: ClContext) workGroupSize =
294294

295295
let localBegin = localBegin clContext workGroupSize
296296
let globalStep = globalStep clContext workGroupSize

src/GraphBLAS-sharp.Backend/Common/Scatter.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module internal Scatter =
2222
/// > val result = [| 2.8; 5.5; 6.4; 8.2; 9.1 |]
2323
/// </code>
2424
/// </example>
25-
let runInplace (clContext: ClContext) workGroupSize =
25+
let runInplace<'a> (clContext: ClContext) workGroupSize =
2626

2727
let run =
2828
<@ fun (ndRange: Range1D) (positions: ClArray<int>) (positionsLength: int) (values: ClArray<'a>) (result: ClArray<'a>) (resultLength: int) ->

src/GraphBLAS-sharp.Backend/Common/Utils.fs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ module internal Utils =
2626

2727
let ceilToMultiple multiple x = ((x - 1) / multiple + 1) * multiple
2828

29-
let getLocalMemorySize (clContext: ClContext) =
30-
let error = ref Unchecked.defaultof<ClErrorCode>
31-
32-
Cl
33-
.GetDeviceInfo(clContext.ClDevice.Device, OpenCL.Net.DeviceInfo.LocalMemSize, error)
34-
.CastTo<int>()
35-
3629
let getClArrayOfValueTypeSize<'a when 'a: struct> localMemorySize = localMemorySize / sizeof<'a>
3730

3831
//Option type in C is represented as structure with additional integer field

src/GraphBLAS-sharp.Backend/GraphBLAS-sharp.Backend.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<Compile Include="Objects/ArraysExtentions.fs" />
1616
<Compile Include="Objects/Vector.fs" />
1717
<Compile Include="Objects/Matrix.fs" />
18-
<Compile Include="Objects/Masks.fs" />
1918
<Compile Include="Objects/AtLeastOne.fs" />
2019
<Compile Include="Objects/ClContextExtensions.fs" />
2120
<Compile Include="Quotes/SubReduce.fs" />

src/GraphBLAS-sharp.Backend/Mask/GetComplemented.fs

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

src/GraphBLAS-sharp.Backend/Matrix/CSRMatrix/CSRMatrix.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,6 @@ module CSRMatrix =
253253
let run =
254254
SpGEMM.run clContext workGroupSize opAdd opMul
255255

256-
fun (queue: MailboxProcessor<_>) (matrixLeft: ClMatrix.CSR<'a>) (matrixRight: ClMatrix.CSC<'b>) (mask: ClMask2D) ->
256+
fun (queue: MailboxProcessor<_>) (matrixLeft: ClMatrix.CSR<'a>) (matrixRight: ClMatrix.CSC<'b>) (mask: ClMatrix.COO<_>) ->
257257

258258
run queue matrixLeft matrixRight mask

0 commit comments

Comments
 (0)