diff --git a/README.md b/README.md index b2b17f0c..8f1004a1 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ GraphBLAS# is a GPGPU-based [GraphBLAS](https://graphblas.org/)-like API impleme - [x] COO-COO `map2` - [x] COO-COO `map2AtLeastOne` - [x] CSR-CSR multiplication + - [x] CSR-CSR Kronecker product - **Vector-Matrix** - [x] Dense-CSR multiplication - [ ] Sparse-CSR multiplication diff --git a/benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/BFS.fs b/benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/BFS.fs index 7115a90c..376d30b2 100644 --- a/benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/BFS.fs +++ b/benchmarks/GraphBLAS-sharp.Benchmarks/Algorithms/BFS.fs @@ -2,15 +2,14 @@ open System.IO open BenchmarkDotNet.Attributes +open Microsoft.FSharp.Core +open Brahma.FSharp open GraphBLAS.FSharp -open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.IO -open Brahma.FSharp -open Backend.Algorithms.BFS -open Microsoft.FSharp.Core -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions open GraphBLAS.FSharp.Benchmarks -open GraphBLAS.FSharp.Backend.Objects +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Backend.Quotes [] [] @@ -20,11 +19,12 @@ type Benchmarks<'elem when 'elem : struct>( buildFunToBenchmark, converter: string -> 'elem, binaryConverter, - vertex: int) + vertex: int, + buildMatrix) = let mutable funToBenchmark = None - let mutable matrix = Unchecked.defaultof> + let mutable matrix = Unchecked.defaultof> let mutable matrixHost = Unchecked.defaultof<_> member val ResultLevels = Unchecked.defaultof> with get,set @@ -69,7 +69,7 @@ type Benchmarks<'elem when 'elem : struct>( this.ResultLevels <- this.FunToBenchmark this.Processor matrix vertex member this.ClearInputMatrix() = - (matrix :> IDeviceMemObject).Dispose this.Processor + matrix.Dispose this.Processor member this.ClearResult() = this.ResultLevels.FreeAndWait this.Processor @@ -82,7 +82,7 @@ type Benchmarks<'elem when 'elem : struct>( matrixHost <- this.InputMatrixReader.ReadMatrix converter member this.LoadMatrixToGPU() = - matrix <- matrixHost.ToCSR.ToDevice this.OclContext + matrix <- buildMatrix this.OclContext matrixHost abstract member GlobalSetup : unit -> unit @@ -96,13 +96,15 @@ type WithoutTransferBenchmark<'elem when 'elem : struct>( buildFunToBenchmark, converter: string -> 'elem, boolConverter, - vertex) = + vertex, + buildMatrix) = inherit Benchmarks<'elem>( buildFunToBenchmark, converter, boolConverter, - vertex) + vertex, + buildMatrix) [] override this.GlobalSetup() = @@ -125,10 +127,11 @@ type WithoutTransferBenchmark<'elem when 'elem : struct>( type BFSWithoutTransferBenchmarkInt32() = inherit WithoutTransferBenchmark( - (singleSource ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption), + (Algorithms.BFS.singleSource ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption), int32, (fun _ -> Utils.nextInt (System.Random())), - 0) + 0, + (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context)) static member InputMatrixProvider = Benchmarks<_>.InputMatrixProviderBuilder "BFSBenchmarks.txt" @@ -137,13 +140,15 @@ type WithTransferBenchmark<'elem when 'elem : struct>( buildFunToBenchmark, converter: string -> 'elem, boolConverter, - vertex) = + vertex, + buildMatrix) = inherit Benchmarks<'elem>( buildFunToBenchmark, converter, boolConverter, - vertex) + vertex, + buildMatrix) [] override this.GlobalSetup() = @@ -168,10 +173,11 @@ type WithTransferBenchmark<'elem when 'elem : struct>( type BFSWithTransferBenchmarkInt32() = inherit WithTransferBenchmark( - (singleSource ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption), + (Algorithms.BFS.singleSource ArithmeticOperations.intSumOption ArithmeticOperations.intMulOption), int32, (fun _ -> Utils.nextInt (System.Random())), - 0) + 0, + (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context)) static member InputMatrixProvider = Benchmarks<_>.InputMatrixProviderBuilder "BFSBenchmarks.txt" diff --git a/benchmarks/GraphBLAS-sharp.Benchmarks/Helpers.fs b/benchmarks/GraphBLAS-sharp.Benchmarks/Helpers.fs index 6ce43002..0867e214 100644 --- a/benchmarks/GraphBLAS-sharp.Benchmarks/Helpers.fs +++ b/benchmarks/GraphBLAS-sharp.Benchmarks/Helpers.fs @@ -5,14 +5,12 @@ namespace GraphBLAS.FSharp.Benchmarks open Brahma.FSharp open Brahma.FSharp.OpenCL.Translator open Brahma.FSharp.OpenCL.Translator.QuotationTransformers -open GraphBLAS.FSharp.Backend.Objects open OpenCL.Net open System.IO open System.Text.RegularExpressions open GraphBLAS.FSharp.Tests open FsCheck open Expecto -open GraphBLAS.FSharp.Test module Utils = type BenchmarkContext = diff --git a/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/Map2/Map2.fs b/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/Map2/Map2.fs index 2e2582f1..975e8a72 100644 --- a/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/Map2/Map2.fs +++ b/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/Map2/Map2.fs @@ -1,15 +1,14 @@ namespace GraphBLAS.FSharp.Benchmarks.Matrix.Map2 open System.IO -open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.IO open BenchmarkDotNet.Attributes open Brahma.FSharp +open GraphBLAS.FSharp +open GraphBLAS.FSharp.IO open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects open GraphBLAS.FSharp.Objects.MatrixExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Matrix +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Benchmarks [] @@ -138,7 +137,7 @@ module WithoutTransfer = type Float32() = inherit Benchmark,float32>( - (Matrix.map2 ArithmeticOperations.float32SumOption), + (Operations.Matrix.map2 ArithmeticOperations.float32SumOption), float32, (fun _ -> Utils.nextSingle (System.Random())), Matrix.COO @@ -150,7 +149,7 @@ module WithoutTransfer = type Bool() = inherit Benchmark,bool>( - (Matrix.map2 ArithmeticOperations.boolSumOption), + (Operations.Matrix.map2 ArithmeticOperations.boolSumOption), (fun _ -> true), (fun _ -> true), Matrix.COO @@ -163,7 +162,7 @@ module WithoutTransfer = type Float32() = inherit Benchmark,float32>( - (Matrix.map2 ArithmeticOperations.float32SumOption), + (Operations.Matrix.map2 ArithmeticOperations.float32SumOption), float32, (fun _ -> Utils.nextSingle (System.Random())), (fun matrix -> Matrix.CSR matrix.ToCSR) @@ -175,7 +174,7 @@ module WithoutTransfer = type Bool() = inherit Benchmark,bool>( - (Matrix.map2 ArithmeticOperations.boolSumOption), + (Operations.Matrix.map2 ArithmeticOperations.boolSumOption), (fun _ -> true), (fun _ -> true), (fun matrix -> Matrix.CSR matrix.ToCSR) @@ -189,7 +188,7 @@ module WithoutTransfer = type Bool() = inherit Benchmark,bool>( - (Matrix.map2AtLeastOne ArithmeticOperations.boolSumAtLeastOne), + (Operations.Matrix.map2AtLeastOne ArithmeticOperations.boolSumAtLeastOne), (fun _ -> true), (fun _ -> true), Matrix.COO @@ -201,7 +200,7 @@ module WithoutTransfer = type Float32() = inherit Benchmark,float32>( - (Matrix.map2AtLeastOne ArithmeticOperations.float32SumAtLeastOne), + (Operations.Matrix.map2AtLeastOne ArithmeticOperations.float32SumAtLeastOne), float32, (fun _ -> Utils.nextSingle (System.Random())), Matrix.COO @@ -214,7 +213,7 @@ module WithoutTransfer = type Bool() = inherit Benchmark,bool>( - (Matrix.map2AtLeastOne ArithmeticOperations.boolSumAtLeastOne), + (Operations.Matrix.map2AtLeastOne ArithmeticOperations.boolSumAtLeastOne), (fun _ -> true), (fun _ -> true), (fun matrix -> Matrix.CSR matrix.ToCSR) @@ -226,7 +225,7 @@ module WithoutTransfer = type Float32() = inherit Benchmark,float32>( - (Matrix.map2AtLeastOne ArithmeticOperations.float32SumAtLeastOne), + (Operations.Matrix.map2AtLeastOne ArithmeticOperations.float32SumAtLeastOne), float32, (fun _ -> Utils.nextSingle (System.Random())), (fun matrix -> Matrix.CSR matrix.ToCSR) @@ -273,7 +272,7 @@ module WithTransfer = type Float32() = inherit Benchmark,float32>( - (Matrix.map2 ArithmeticOperations.float32SumOption), + (Operations.Matrix.map2 ArithmeticOperations.float32SumOption), float32, (fun _ -> Utils.nextSingle (System.Random())), Matrix.COO, diff --git a/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Expand.fs b/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Expand.fs index 0a7193e7..0eb398cd 100644 --- a/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Expand.fs +++ b/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Expand.fs @@ -1,16 +1,14 @@ module GraphBLAS.FSharp.Benchmarks.Matrix.SpGeMM.Expand open System.IO -open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.IO open BenchmarkDotNet.Attributes open Brahma.FSharp +open GraphBLAS.FSharp +open GraphBLAS.FSharp.IO +open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions open GraphBLAS.FSharp.Benchmarks -open GraphBLAS.FSharp.Backend [] [] @@ -139,7 +137,7 @@ module WithoutTransfer = type Float32() = inherit Benchmark( - Matrix.SpGeMM.expand (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul), + Operations.SpGeMM.expand (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul), float32, (fun _ -> Utils.nextSingle (System.Random())), (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context) diff --git a/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Masked.fs b/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Masked.fs index 2a164021..69f0c399 100644 --- a/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Masked.fs +++ b/benchmarks/GraphBLAS-sharp.Benchmarks/Matrix/SpGeMM/Masked.fs @@ -5,12 +5,10 @@ open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.IO open BenchmarkDotNet.Attributes open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions open GraphBLAS.FSharp.Benchmarks -open GraphBLAS.FSharp.Backend [] [] @@ -204,7 +202,7 @@ type MxmBenchmarksWithTransposing<'elem when 'elem : struct>( type Mxm4Float32MultiplicationOnlyBenchmark() = inherit MxmBenchmarksMultiplicationOnly( - Matrix.SpGeMM.masked (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul), + Operations.SpGeMM.masked (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul), float32, (fun _ -> Utils.nextSingle (System.Random())), (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context) @@ -216,7 +214,7 @@ type Mxm4Float32MultiplicationOnlyBenchmark() = type Mxm4Float32WithTransposingBenchmark() = inherit MxmBenchmarksWithTransposing( - Matrix.SpGeMM.masked (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul), + Operations.SpGeMM.masked (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul), float32, (fun _ -> Utils.nextSingle (System.Random())), (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context) @@ -228,7 +226,7 @@ type Mxm4Float32WithTransposingBenchmark() = type Mxm4BoolMultiplicationOnlyBenchmark() = inherit MxmBenchmarksMultiplicationOnly( - (Matrix.SpGeMM.masked (fst ArithmeticOperations.boolAdd) (fst ArithmeticOperations.boolMul)), + (Operations.SpGeMM.masked (fst ArithmeticOperations.boolAdd) (fst ArithmeticOperations.boolMul)), (fun _ -> true), (fun _ -> true), (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context) @@ -240,7 +238,7 @@ type Mxm4BoolMultiplicationOnlyBenchmark() = type Mxm4BoolWithTransposingBenchmark() = inherit MxmBenchmarksWithTransposing( - (Matrix.SpGeMM.masked (fst ArithmeticOperations.boolAdd) (fst ArithmeticOperations.boolMul)), + (Operations.SpGeMM.masked (fst ArithmeticOperations.boolAdd) (fst ArithmeticOperations.boolMul)), (fun _ -> true), (fun _ -> true), (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context) @@ -252,7 +250,7 @@ type Mxm4BoolWithTransposingBenchmark() = type Mxm4Float32MultiplicationOnlyWithZerosFilterBenchmark() = inherit MxmBenchmarksMultiplicationOnly( - (Matrix.SpGeMM.masked (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul)), + (Operations.SpGeMM.masked (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul)), float32, (fun _ -> Utils.nextSingle (System.Random())), (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context) @@ -264,7 +262,7 @@ type Mxm4Float32MultiplicationOnlyWithZerosFilterBenchmark() = type Mxm4Float32WithTransposingWithZerosFilterBenchmark() = inherit MxmBenchmarksWithTransposing( - Matrix.SpGeMM.masked (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul), + Operations.SpGeMM.masked (fst ArithmeticOperations.float32Add) (fst ArithmeticOperations.float32Mul), float32, (fun _ -> Utils.nextSingle (System.Random())), (fun context matrix -> ClMatrix.CSR <| matrix.ToCSR.ToDevice context) diff --git a/benchmarks/GraphBLAS-sharp.Benchmarks/Vector/Map2.fs b/benchmarks/GraphBLAS-sharp.Benchmarks/Vector/Map2.fs index 523f5185..d4e0078c 100644 --- a/benchmarks/GraphBLAS-sharp.Benchmarks/Vector/Map2.fs +++ b/benchmarks/GraphBLAS-sharp.Benchmarks/Vector/Map2.fs @@ -2,16 +2,14 @@ module GraphBLAS.FSharp.Benchmarks.Vector.Map2 open FsCheck open BenchmarkDotNet.Attributes - open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects open GraphBLAS.FSharp.Backend.Quotes +open GraphBLAS.FSharp open GraphBLAS.FSharp.Benchmarks open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.ClVectorExtensions -open GraphBLAS.FSharp.Backend.Vector -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions [] [] @@ -122,26 +120,26 @@ module WithoutTransfer = type Float() = inherit Benchmark( - (Vector.map2 ArithmeticOperations.floatSumOption), + (Operations.Vector.map2 ArithmeticOperations.floatSumOption), VectorGenerator.floatPair Sparse) type Int32() = inherit Benchmark( - (Vector.map2 ArithmeticOperations.intSumOption), + (Operations.Vector.map2 ArithmeticOperations.intSumOption), VectorGenerator.intPair Sparse) module AtLeastOne = type Float() = inherit Benchmark( - (Vector.map2AtLeastOne ArithmeticOperations.floatSumAtLeastOne), + (Operations.Vector.map2AtLeastOne ArithmeticOperations.floatSumAtLeastOne), VectorGenerator.floatPair Sparse) type Int32() = inherit Benchmark( - (Vector.map2AtLeastOne ArithmeticOperations.intSumAtLeastOne), + (Operations.Vector.map2AtLeastOne ArithmeticOperations.intSumAtLeastOne), VectorGenerator.intPair Sparse) module WithTransfer = @@ -178,24 +176,24 @@ module WithTransfer = type Float() = inherit Benchmark( - (Vector.map2 ArithmeticOperations.floatSumOption), + (Operations.Vector.map2 ArithmeticOperations.floatSumOption), VectorGenerator.floatPair Sparse) type Int32() = inherit Benchmark( - (Vector.map2 ArithmeticOperations.intSumOption), + (Operations.Vector.map2 ArithmeticOperations.intSumOption), VectorGenerator.intPair Sparse) module AtLeastOne = type Float() = inherit Benchmark( - (Vector.map2AtLeastOne ArithmeticOperations.floatSumAtLeastOne), + (Operations.Vector.map2AtLeastOne ArithmeticOperations.floatSumAtLeastOne), VectorGenerator.floatPair Sparse) type Int32() = inherit Benchmark( - (Vector.map2AtLeastOne ArithmeticOperations.intSumAtLeastOne), + (Operations.Vector.map2AtLeastOne ArithmeticOperations.intSumAtLeastOne), VectorGenerator.intPair Sparse) diff --git a/paket.lock b/paket.lock index 59d73a6a..f2bbb161 100644 --- a/paket.lock +++ b/paket.lock @@ -2,23 +2,23 @@ STORAGE: NONE NUGET remote: https://www.nuget.org/api/v2 altcover (7.6.812) - BenchmarkDotNet (0.13.5) - BenchmarkDotNet.Annotations (>= 0.13.5) - restriction: >= netstandard2.0 - CommandLineParser (>= 2.4.3) - restriction: >= netstandard2.0 + BenchmarkDotNet (0.13.6) + BenchmarkDotNet.Annotations (>= 0.13.6) - restriction: >= netstandard2.0 + CommandLineParser (>= 2.9.1) - restriction: >= netstandard2.0 Gee.External.Capstone (>= 2.3) - restriction: >= netstandard2.0 Iced (>= 1.17) - restriction: >= netstandard2.0 - Microsoft.CodeAnalysis.CSharp (>= 3.0) - restriction: >= netstandard2.0 + Microsoft.CodeAnalysis.CSharp (>= 4.1) - restriction: >= netstandard2.0 Microsoft.Diagnostics.Runtime (>= 2.2.332302) - restriction: >= netstandard2.0 Microsoft.Diagnostics.Tracing.TraceEvent (>= 3.0.2) - restriction: >= netstandard2.0 Microsoft.DotNet.PlatformAbstractions (>= 3.1.6) - restriction: >= netstandard2.0 Microsoft.Win32.Registry (>= 5.0) - restriction: && (< net6.0) (>= netstandard2.0) - Perfolizer (>= 0.2.1) - restriction: >= netstandard2.0 - System.Management (>= 6.0) - restriction: >= netstandard2.0 + Perfolizer (0.2.1) - restriction: >= netstandard2.0 + System.Management (>= 5.0) - restriction: >= netstandard2.0 System.Numerics.Vectors (>= 4.5) - restriction: && (< net6.0) (>= netstandard2.0) System.Reflection.Emit (>= 4.7) - restriction: && (< net6.0) (>= netstandard2.0) 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.5) - restriction: >= netstandard2.0 + BenchmarkDotNet.Annotations (0.13.6) - restriction: >= netstandard2.0 Brahma.FSharp (2.0.5) Brahma.FSharp.OpenCL.Printer (>= 2.0.5) - restriction: >= net7.0 Brahma.FSharp.OpenCL.Shared (>= 2.0.5) - restriction: >= net7.0 @@ -52,8 +52,8 @@ NUGET ExtraConstraints.Fody (1.14) Fody (>= 6.0) - restriction: || (>= net452) (>= netstandard1.4) NETStandard.Library (>= 1.6.1) - restriction: && (< net452) (>= netstandard1.4) - Fody (6.7) - restriction: || (>= net452) (>= netstandard1.4) - FsCheck (2.16.5) - restriction: || (>= net461) (>= netstandard2.0) + Fody (6.8) - restriction: || (>= net452) (>= netstandard1.4) + FsCheck (2.16.6) - restriction: || (>= net461) (>= netstandard2.0) FSharp.Core (>= 4.2.3) - restriction: || (>= net452) (>= netstandard1.6) FSharp.Core (7.0) FSharp.Quotations.Evaluator (2.1) @@ -63,7 +63,7 @@ NUGET FSharpx.Text.StructuredFormat (3.1) FSharp.Core (>= 4.6.2) - restriction: || (>= net452) (>= netstandard2.0) Gee.External.Capstone (2.3) - restriction: >= netstandard2.0 - Iced (1.18) - restriction: >= netstandard2.0 + Iced (1.20) - restriction: >= netstandard2.0 MathNet.Numerics (5.0) - restriction: || (>= net45) (>= netstandard1.6) System.ValueTuple (>= 4.4) - restriction: && (>= net461) (< net48) MathNet.Numerics.FSharp (4.0) @@ -83,26 +83,27 @@ NUGET System.Security.Permissions (>= 4.7) - restriction: && (< net472) (>= netstandard2.0) Microsoft.Build.Tasks.Git (1.1.1) - copy_local: true Microsoft.CodeAnalysis.Analyzers (3.3.4) - restriction: >= netstandard2.0 - Microsoft.CodeAnalysis.Common (4.5) - restriction: >= netstandard2.0 - Microsoft.CodeAnalysis.Analyzers (>= 3.3.3) - restriction: >= netstandard2.0 - System.Collections.Immutable (>= 6.0) - restriction: >= netstandard2.0 - System.Memory (>= 4.5.5) - restriction: && (< netcoreapp3.1) (>= netstandard2.0) - System.Reflection.Metadata (>= 6.0.1) - restriction: >= netstandard2.0 + Microsoft.CodeAnalysis.Common (4.6) - restriction: >= netstandard2.0 + Microsoft.CodeAnalysis.Analyzers (>= 3.3.4) - restriction: >= netstandard2.0 + System.Collections.Immutable (>= 7.0) - restriction: >= netstandard2.0 + System.Memory (>= 4.5.5) - restriction: && (< net6.0) (>= netstandard2.0) + System.Reflection.Metadata (>= 7.0) - restriction: >= netstandard2.0 System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: >= netstandard2.0 - System.Text.Encoding.CodePages (>= 6.0) - restriction: >= netstandard2.0 - System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: && (< netcoreapp3.1) (>= netstandard2.0) - Microsoft.CodeAnalysis.CSharp (4.5) - restriction: >= netstandard2.0 - Microsoft.CodeAnalysis.Common (4.5) - restriction: >= netstandard2.0 - Microsoft.CodeCoverage (17.6) - restriction: || (>= net45) (>= netcoreapp2.1) + System.Text.Encoding.CodePages (>= 7.0) - restriction: >= netstandard2.0 + System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: && (< net6.0) (>= netstandard2.0) + Microsoft.CodeAnalysis.CSharp (4.6) - restriction: >= netstandard2.0 + Microsoft.CodeAnalysis.Common (4.6) - restriction: >= netstandard2.0 + Microsoft.CodeCoverage (17.6.3) - restriction: || (>= net45) (>= netcoreapp2.1) Microsoft.CSharp (4.7) - restriction: || (&& (< netstandard1.3) (>= uap10.0)) (&& (< netstandard2.0) (>= uap10.0)) - Microsoft.Diagnostics.NETCore.Client (0.2.421201) - restriction: >= netstandard2.0 - Microsoft.Bcl.AsyncInterfaces (>= 1.1) - restriction: && (< net6.0) (>= netstandard2.0) - Microsoft.Extensions.Logging (>= 2.1.1) - restriction: >= netstandard2.0 + Microsoft.Diagnostics.NETCore.Client (0.2.430602) - restriction: >= netstandard2.0 + Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: && (< net6.0) (>= netstandard2.0) + Microsoft.Extensions.Logging (>= 6.0) - restriction: >= netstandard2.0 + System.Buffers (>= 4.5.1) - restriction: && (< net6.0) (>= netstandard2.0) Microsoft.Diagnostics.Runtime (2.4.416101) - restriction: >= netstandard2.0 Microsoft.Diagnostics.NETCore.Client (>= 0.2.251802) - restriction: >= netstandard2.0 System.Collections.Immutable (>= 5.0) - restriction: >= netstandard2.0 System.Runtime.CompilerServices.Unsafe (>= 5.0) - restriction: >= netstandard2.0 - Microsoft.Diagnostics.Tracing.TraceEvent (3.1.2) - restriction: >= netstandard2.0 + Microsoft.Diagnostics.Tracing.TraceEvent (3.1.3) - restriction: >= netstandard2.0 System.Runtime.CompilerServices.Unsafe (>= 5.0) - restriction: >= netstandard2.0 Microsoft.DotNet.PlatformAbstractions (3.1.6) - restriction: >= netstandard2.0 System.Runtime.InteropServices.RuntimeInformation (>= 4.0) - restriction: || (>= net45) (&& (>= netstandard1.3) (< netstandard2.0)) @@ -121,7 +122,7 @@ NUGET Microsoft.Extensions.Options (>= 7.0) - restriction: || (>= net462) (>= netstandard2.0) System.Diagnostics.DiagnosticSource (>= 7.0) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.1)) (&& (>= netstandard2.0) (< netstandard2.1)) System.ValueTuple (>= 4.5) - restriction: >= net462 - Microsoft.Extensions.Logging.Abstractions (7.0) - restriction: >= netstandard2.0 + Microsoft.Extensions.Logging.Abstractions (7.0.1) - restriction: >= netstandard2.0 System.Buffers (>= 4.5.1) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) Microsoft.Extensions.Options (7.0.1) - restriction: >= netstandard2.0 @@ -138,17 +139,17 @@ NUGET System.ComponentModel.Primitives (>= 4.1) - restriction: >= uap10.0 System.ComponentModel.TypeConverter (>= 4.1) - restriction: >= uap10.0 System.Runtime.InteropServices.RuntimeInformation (>= 4.0) - restriction: >= uap10.0 - Microsoft.NETCore.Platforms (7.0.2) - restriction: || (&& (>= monoandroid) (>= netcoreapp2.0) (< netstandard1.3)) (&& (>= monoandroid) (>= netcoreapp2.1) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (< monoandroid) (< netstandard1.1) (>= netstandard1.6) (< win8)) (&& (>= monotouch) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netcoreapp2.1)) (&& (< net45) (>= net46) (< netstandard1.4) (>= netstandard1.6)) (&& (< net45) (>= net461) (>= netstandard1.6) (< netstandard2.0)) (&& (< 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) (< win8) (< wpa81)) (&& (>= net461) (>= netcoreapp2.0)) (&& (>= net461) (>= netcoreapp2.1)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinios)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinmac)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarintvos)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinwatchos)) (&& (>= netcoreapp2.0) (< netstandard2.0)) (&& (>= netcoreapp2.0) (>= uap10.1)) (&& (< netcoreapp2.0) (>= netcoreapp2.1)) (&& (>= netcoreapp2.1) (< netcoreapp3.0)) (&& (>= netcoreapp2.1) (>= uap10.1)) (&& (< netstandard1.0) (>= netstandard1.6) (< portable-net45+win8)) (&& (< netstandard1.0) (>= netstandard1.6) (>= win8)) (&& (< netstandard1.0) (>= netstandard1.6) (< win8)) (&& (< netstandard1.1) (>= netstandard1.6) (>= uap10.0) (< win8)) (&& (< netstandard1.3) (>= netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard1.3) (>= netstandard1.6) (< win8) (>= wpa81)) (&& (< netstandard1.5) (>= netstandard1.6) (>= uap10.0)) (&& (>= netstandard1.6) (< portable-net45+win8+wpa81)) (&& (>= netstandard1.6) (>= uap10.1)) (&& (>= netstandard1.6) (>= wp8)) + Microsoft.NETCore.Platforms (7.0.4) - restriction: || (&& (>= monoandroid) (>= netcoreapp2.0) (< netstandard1.3)) (&& (>= monoandroid) (>= netcoreapp2.1) (< netstandard1.3)) (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (< monoandroid) (< netstandard1.1) (>= netstandard1.6) (< win8)) (&& (>= monotouch) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netcoreapp2.1)) (&& (< net45) (>= net46) (< netstandard1.4) (>= netstandard1.6)) (&& (< net45) (>= net461) (>= netstandard1.6) (< netstandard2.0)) (&& (< 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) (< win8) (< wpa81)) (&& (>= net461) (>= netcoreapp2.0)) (&& (>= net461) (>= netcoreapp2.1)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinios)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinmac)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarintvos)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinwatchos)) (&& (>= netcoreapp2.0) (< netstandard2.0)) (&& (>= netcoreapp2.0) (>= uap10.1)) (&& (< netcoreapp2.0) (>= netcoreapp2.1)) (&& (>= netcoreapp2.1) (< netcoreapp3.0)) (&& (>= netcoreapp2.1) (>= uap10.1)) (&& (< netstandard1.0) (>= netstandard1.6) (< portable-net45+win8)) (&& (< netstandard1.0) (>= netstandard1.6) (>= win8)) (&& (< netstandard1.0) (>= netstandard1.6) (< win8)) (&& (< netstandard1.1) (>= netstandard1.6) (>= uap10.0) (< win8)) (&& (< netstandard1.3) (>= netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (< netstandard1.3) (>= netstandard1.6) (< win8) (>= wpa81)) (&& (< netstandard1.5) (>= netstandard1.6) (>= uap10.0)) (&& (>= netstandard1.6) (< portable-net45+win8+wpa81)) (&& (>= netstandard1.6) (>= uap10.1)) (&& (>= netstandard1.6) (>= wp8)) Microsoft.NETCore.Targets (5.0) - restriction: || (&& (< monoandroid) (< net45) (< netstandard1.2) (>= netstandard1.6) (< win8)) (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.4) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< monoandroid) (< netstandard1.1) (>= netstandard1.6) (< win8)) (&& (< monotouch) (< net45) (>= netstandard1.6) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< 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)) Microsoft.SourceLink.Common (1.1.1) - copy_local: true Microsoft.SourceLink.GitHub (1.0) - copy_local: true Microsoft.Build.Tasks.Git (>= 1.0) Microsoft.SourceLink.Common (>= 1.0) - Microsoft.TestPlatform.ObjectModel (17.6) - restriction: >= netcoreapp3.1 - NuGet.Frameworks (>= 5.11) - restriction: || (>= net462) (>= netstandard2.0) + Microsoft.TestPlatform.ObjectModel (17.6.3) - restriction: >= netcoreapp3.1 + NuGet.Frameworks (>= 6.5) - restriction: || (>= net462) (>= netstandard2.0) System.Reflection.Metadata (>= 1.6) - restriction: || (>= net462) (>= netstandard2.0) - Microsoft.TestPlatform.TestHost (17.6) - restriction: >= netcoreapp2.1 - Microsoft.TestPlatform.ObjectModel (>= 17.6) - restriction: >= netcoreapp3.1 + Microsoft.TestPlatform.TestHost (17.6.3) - restriction: >= netcoreapp2.1 + Microsoft.TestPlatform.ObjectModel (>= 17.6.3) - restriction: >= netcoreapp3.1 Newtonsoft.Json (>= 13.0.1) - restriction: >= netcoreapp3.1 Microsoft.Win32.Primitives (4.3) - restriction: || (&& (< net45) (>= net46) (< netstandard1.4) (>= netstandard1.6)) (&& (< net45) (< netstandard1.4) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (< netstandard1.5) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (>= netstandard1.6) (< netstandard2.0) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= netstandard1.6) (>= uap10.0)) Microsoft.NETCore.Platforms (>= 1.1) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) @@ -213,9 +214,9 @@ NUGET System.Runtime.Serialization.Formatters (>= 4.3) - restriction: && (< net20) (>= netstandard1.3) (< netstandard2.0) System.Runtime.Serialization.Primitives (>= 4.3) - restriction: || (&& (< net20) (>= netstandard1.0) (< netstandard1.3)) (&& (< net20) (>= netstandard1.3) (< netstandard2.0)) System.Xml.XmlDocument (>= 4.3) - restriction: && (< net20) (>= netstandard1.3) (< netstandard2.0) - NuGet.Frameworks (6.5) - restriction: >= netcoreapp3.1 - Perfolizer (0.3.4) - restriction: >= netstandard2.0 - System.Memory (>= 4.5.4) - restriction: && (>= netstandard2.0) (< netstandard2.1) + NuGet.Frameworks (6.6.1) - restriction: >= netcoreapp3.1 + Perfolizer (0.2.1) - restriction: >= netstandard2.0 + System.Memory (>= 4.5.3) - restriction: >= netstandard2.0 QuikGraph (2.5) NETStandard.Library (>= 1.6.1) - restriction: && (< net35) (>= netstandard1.3) (< netstandard2.0) runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - restriction: && (< monotouch) (< net45) (>= netstandard1.6) (< netstandard2.0) (< xamarintvos) (< xamarinwatchos) @@ -391,9 +392,9 @@ NUGET System.Runtime (>= 4.3) - restriction: || (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) (&& (< monoandroid) (< net45) (>= netstandard1.3) (< netstandard1.6) (< win8) (< wpa81)) (&& (< monotouch) (< net45) (>= netstandard1.6) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) System.Runtime.Extensions (>= 4.3) - restriction: && (< monotouch) (< net45) (>= netstandard1.6) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) System.Threading (>= 4.3) - restriction: && (< monotouch) (< net45) (>= netstandard1.6) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) - System.Management (7.0.1) - restriction: >= netstandard2.0 + System.Management (7.0.2) - restriction: >= netstandard2.0 System.CodeDom (>= 7.0) - restriction: >= netstandard2.0 - System.Memory (4.5.5) - restriction: || (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net462) (&& (< net6.0) (>= netstandard2.0)) (&& (< netcoreapp3.1) (>= netstandard2.0)) (&& (>= netstandard2.0) (< netstandard2.1)) (&& (>= netstandard2.0) (>= uap10.1)) + System.Memory (4.5.5) - restriction: || (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net462) (>= netstandard2.0) System.Buffers (>= 4.5.1) - restriction: || (&& (>= monoandroid) (< netstandard1.1)) (&& (< monoandroid) (< net45) (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< netstandard1.1) (>= portable-net45+win8+wpa81) (< win8)) (>= monotouch) (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (>= net461) (&& (< netstandard1.1) (>= win8)) (&& (< netstandard2.0) (< uap10.1) (>= wpa81)) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos) System.Numerics.Vectors (>= 4.4) - restriction: && (< net45) (< netcoreapp2.0) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) System.Numerics.Vectors (>= 4.5) - restriction: >= net461 @@ -486,7 +487,7 @@ NUGET Microsoft.NETCore.Targets (>= 1.1) - restriction: && (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) System.Reflection (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) System.Runtime (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< win8) (< wp8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) - System.Reflection.Metadata (7.0.1) - restriction: >= netstandard2.0 + System.Reflection.Metadata (7.0.2) - restriction: >= netstandard2.0 System.Collections.Immutable (>= 7.0) - restriction: || (>= net462) (>= netstandard2.0) System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) System.Reflection.Primitives (4.3) - restriction: || (&& (< 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) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= netstandard1.6) (>= uap10.0)) (&& (>= netstandard1.6) (< portable-net45+win8+wpa81)) @@ -677,7 +678,7 @@ NUGET Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) Microsoft.NETCore.Targets (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) System.Runtime (>= 4.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) - System.Threading.Tasks.Extensions (4.5.4) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.6) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (< netstandard1.2) (>= netstandard1.6) (< win8)) (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.4) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (>= net46) (< netstandard1.4) (>= netstandard1.6)) (&& (>= net462) (>= netstandard2.0)) (&& (< net6.0) (>= netstandard2.0)) (&& (< netcoreapp3.1) (>= netstandard2.0)) (&& (< netstandard1.5) (>= netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.6) (< portable-net45+win8+wpa81)) (&& (>= netstandard2.0) (< netstandard2.1)) + System.Threading.Tasks.Extensions (4.5.4) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.6) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (< netstandard1.2) (>= netstandard1.6) (< win8)) (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.4) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (>= net46) (< netstandard1.4) (>= netstandard1.6)) (&& (>= net462) (>= netstandard2.0)) (&& (< net6.0) (>= netstandard2.0)) (&& (< netstandard1.5) (>= netstandard1.6) (>= uap10.0) (< win8) (< wpa81)) (&& (>= netstandard1.6) (< portable-net45+win8+wpa81)) (&& (>= netstandard2.0) (< netstandard2.1)) System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.0) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< netstandard1.0) (>= portable-net45+win8+wp8+wpa81) (< win8)) (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.1) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= net461) (&& (< netstandard1.0) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) (>= wp8) System.Threading.Timer (4.3) - restriction: || (&& (< 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) (< win8) (< wpa81)) (&& (< netstandard1.5) (>= netstandard1.6) (>= uap10.0)) Microsoft.NETCore.Platforms (>= 1.1) - restriction: && (< monoandroid) (< monotouch) (< net451) (>= netstandard1.2) (< win81) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) @@ -761,11 +762,11 @@ NUGET BinaryDefense.FSharp.Analyzers.Hashing (0.2.2) FSharp.Analyzers.SDK (>= 0.8) - restriction: >= net5.0 FSharp.Core (>= 5.0.1) - restriction: >= net5.0 - FSharp.Analyzers.SDK (0.11) - restriction: >= net5.0 - FSharp.Compiler.Service (>= 41.0.1) - restriction: >= net5.0 - FSharp.Core (>= 6.0.1) - restriction: >= net5.0 - McMaster.NETCore.Plugins (>= 1.4) - restriction: >= net5.0 - FSharp.Compiler.Service (43.7.300) - restriction: >= net5.0 + FSharp.Analyzers.SDK (0.12) - restriction: >= net5.0 + FSharp.Compiler.Service (>= 43.7.200) - restriction: >= net6.0 + FSharp.Core (>= 7.0.200) - restriction: >= net6.0 + McMaster.NETCore.Plugins (>= 1.4) - restriction: >= net6.0 + FSharp.Compiler.Service (43.7.300) - restriction: >= net6.0 FSharp.Core (7.0.300) - restriction: >= netstandard2.0 System.Buffers (>= 4.5.1) - restriction: >= netstandard2.0 System.Collections.Immutable (>= 6.0) - restriction: >= netstandard2.0 @@ -775,45 +776,30 @@ NUGET System.Reflection.Metadata (>= 6.0.1) - restriction: >= netstandard2.0 System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: >= netstandard2.0 FSharp.Core (7.0.300) - restriction: >= net5.0 - McMaster.NETCore.Plugins (1.4) - restriction: >= net5.0 + McMaster.NETCore.Plugins (1.4) - restriction: >= net6.0 Microsoft.DotNet.PlatformAbstractions (>= 3.1.6) - restriction: >= netcoreapp2.1 Microsoft.Extensions.DependencyModel (>= 5.0) - restriction: >= netcoreapp2.1 - Microsoft.Bcl.AsyncInterfaces (7.0) - restriction: || (&& (>= net462) (>= net5.0)) (&& (>= net5.0) (< net6.0)) - Microsoft.DotNet.PlatformAbstractions (3.1.6) - restriction: >= net5.0 - Microsoft.Extensions.DependencyModel (7.0) - restriction: >= net5.0 - System.Buffers (>= 4.5.1) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) - System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) + Microsoft.DotNet.PlatformAbstractions (3.1.6) - restriction: >= net6.0 + Microsoft.Extensions.DependencyModel (7.0) - restriction: >= net6.0 System.Text.Encodings.Web (>= 7.0) - restriction: || (>= net462) (>= netstandard2.0) System.Text.Json (>= 7.0) - restriction: || (>= net462) (>= netstandard2.0) - System.Buffers (4.5.1) - restriction: >= net5.0 - System.Collections.Immutable (7.0) - restriction: >= net5.0 - System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) + System.Buffers (4.5.1) - restriction: >= net6.0 + System.Collections.Immutable (7.0) - restriction: >= net6.0 System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (>= net462) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= netstandard2.0)) - System.Diagnostics.DiagnosticSource (7.0.2) - restriction: >= net5.0 - System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) + System.Diagnostics.DiagnosticSource (7.0.2) - restriction: >= net6.0 System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (>= net462) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= netstandard2.0)) - System.Memory (4.5.5) - restriction: >= net5.0 + System.Memory (4.5.5) - restriction: >= net6.0 System.Buffers (>= 4.5.1) - restriction: || (&& (>= monoandroid) (< netstandard1.1)) (&& (< monoandroid) (< net45) (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< netstandard1.1) (>= portable-net45+win8+wpa81) (< win8)) (>= monotouch) (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (>= net461) (&& (< netstandard1.1) (>= win8)) (&& (< netstandard2.0) (< uap10.1) (>= wpa81)) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos) System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (>= monoandroid) (< netstandard1.1)) (&& (< monoandroid) (< net45) (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (< monoandroid) (< netstandard1.1) (>= portable-net45+win8+wpa81) (< win8)) (>= monotouch) (&& (>= net45) (< netstandard2.0)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (>= net461) (&& (< netstandard1.1) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) (>= uap10.1) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos) - System.Numerics.Vectors (4.5) - restriction: || (&& (>= net462) (>= net5.0)) (&& (>= net5.0) (< net6.0)) - System.Reflection.Emit (4.7) - restriction: >= net5.0 - System.Reflection.Metadata (7.0.1) - restriction: >= net5.0 + System.Reflection.Emit (4.7) - restriction: >= net6.0 + System.Reflection.Metadata (7.0.2) - restriction: >= net6.0 System.Collections.Immutable (>= 7.0) - restriction: || (>= net462) (>= netstandard2.0) - System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) - System.Runtime.CompilerServices.Unsafe (6.0) - restriction: || (>= net5.0) (&& (>= net6.0) (< net7.0)) - System.Text.Encodings.Web (7.0) - restriction: >= net5.0 - System.Buffers (>= 4.5.1) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) - System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) + System.Runtime.CompilerServices.Unsafe (6.0) - restriction: >= net6.0 + System.Text.Encodings.Web (7.0) - restriction: >= net6.0 System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (>= net462) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= netstandard2.0)) - System.Text.Json (7.0.2) - restriction: >= net5.0 - Microsoft.Bcl.AsyncInterfaces (>= 7.0) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) - System.Buffers (>= 4.5.1) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) - System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) - System.Numerics.Vectors (>= 4.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) + System.Text.Json (7.0.3) - restriction: >= net6.0 System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (>= net462) (&& (>= net6.0) (< net7.0)) (&& (< net6.0) (>= netstandard2.0)) System.Text.Encodings.Web (>= 7.0) - restriction: || (>= net462) (>= netstandard2.0) - System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) - System.Threading.Tasks.Extensions (4.5.4) - restriction: || (&& (>= net462) (>= net5.0)) (&& (>= net5.0) (< net6.0)) GROUP Build STORAGE: NONE @@ -947,27 +933,34 @@ NUGET FSharp.Core (>= 4.7.2) - restriction: >= netstandard2.0 System.Reactive (>= 5.0 < 6.0) - restriction: >= netstandard2.0 FSharp.Core (7.0.300) - restriction: >= netstandard2.0 - Microsoft.Build.Framework (17.5) - restriction: >= netstandard2.0 + Microsoft.Build.Framework (17.6.3) - restriction: >= netstandard2.0 + Microsoft.VisualStudio.Setup.Configuration.Interop (>= 3.2.2146) - restriction: >= net472 Microsoft.Win32.Registry (>= 5.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: >= net472 - System.Security.Permissions (>= 6.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net7.0) - Microsoft.Build.Utilities.Core (17.5) - restriction: >= netstandard2.0 - Microsoft.Build.Framework (>= 17.5) - restriction: >= netstandard2.0 + System.Security.Permissions (>= 7.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net7.0) + System.Security.Principal.Windows (>= 5.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) + Microsoft.Build.Utilities.Core (17.6.3) - restriction: >= netstandard2.0 + Microsoft.Build.Framework (>= 17.6.3) - restriction: >= netstandard2.0 Microsoft.IO.Redist (>= 6.0) - restriction: >= net472 - Microsoft.NET.StringTools (>= 17.5) - restriction: >= netstandard2.0 + Microsoft.NET.StringTools (>= 17.6.3) - restriction: >= netstandard2.0 + Microsoft.VisualStudio.Setup.Configuration.Interop (>= 3.2.2146) - restriction: || (>= net472) (>= net7.0) Microsoft.Win32.Registry (>= 5.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) - System.Collections.Immutable (>= 6.0) - restriction: >= netstandard2.0 - System.Configuration.ConfigurationManager (>= 6.0) - restriction: >= netstandard2.0 - System.Security.Permissions (>= 6.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) - System.Text.Encoding.CodePages (>= 6.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) + System.Collections.Immutable (>= 7.0) - restriction: >= netstandard2.0 + System.Configuration.ConfigurationManager (>= 7.0) - restriction: >= netstandard2.0 + System.Memory (>= 4.5.5) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) + System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) + System.Security.Permissions (>= 7.0) - restriction: >= netstandard2.0 + System.Security.Principal.Windows (>= 5.0) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) + System.Text.Encoding.CodePages (>= 7.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) Microsoft.IO.Redist (6.0) - restriction: >= net472 System.Buffers (>= 4.5.1) - restriction: >= net472 System.Memory (>= 4.5.4) - restriction: >= net472 - Microsoft.NET.StringTools (17.5) - restriction: >= netstandard2.0 + Microsoft.NET.StringTools (17.6.3) - restriction: >= netstandard2.0 System.Memory (>= 4.5.5) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) - Microsoft.NETCore.Platforms (7.0.2) - restriction: || (&& (>= monoandroid) (>= netcoreapp2.0) (< netstandard1.3)) (&& (>= monoandroid) (>= netcoreapp2.1) (< netstandard1.3)) (&& (< monoandroid) (< net45) (< netcoreapp3.1) (>= netstandard2.0) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (< netstandard1.2) (>= netstandard2.0) (< win8)) (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (>= net5.0) (< netcoreapp2.1) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (>= monotouch) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netcoreapp2.1)) (&& (>= net461) (>= netcoreapp2.0)) (&& (>= net461) (>= netcoreapp2.1)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinios)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinmac)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarintvos)) (&& (>= netcoreapp2.0) (< netcoreapp2.1) (>= xamarinwatchos)) (&& (>= netcoreapp2.0) (>= uap10.1)) (&& (< netcoreapp2.0) (>= netcoreapp2.1)) (&& (>= netcoreapp2.1) (< netcoreapp3.0)) (&& (>= netcoreapp2.1) (>= uap10.1)) + Microsoft.NETCore.Platforms (7.0.4) - restriction: || (&& (< monoandroid) (< net45) (< netcoreapp3.1) (>= netstandard2.0) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (< netstandard1.2) (>= netstandard2.0) (< win8)) (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (>= net5.0) (< netcoreapp2.1) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (>= netcoreapp2.1) (< netcoreapp3.0)) Microsoft.NETCore.Targets (5.0) - restriction: || (&& (< monoandroid) (< net45) (< netcoreapp3.1) (>= netstandard2.0) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (< netstandard1.2) (>= netstandard2.0) (< win8)) (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard2.0) (< win8) (< wpa81)) + Microsoft.VisualStudio.Setup.Configuration.Interop (3.6.2115) - restriction: || (>= net472) (>= net7.0) Microsoft.Win32.Registry (5.0) - restriction: || (&& (< net45) (>= netstandard2.0)) (&& (< net472) (< net7.0) (>= netstandard2.0)) System.Buffers (>= 4.5.1) - restriction: || (&& (>= monoandroid) (< netstandard1.3)) (>= monotouch) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0)) (>= xamarinios) (>= xamarinmac) (>= xamarintvos) (>= xamarinwatchos) System.Memory (>= 4.5.4) - restriction: || (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (>= uap10.1) @@ -975,25 +968,25 @@ NUGET 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) Microsoft.Win32.SystemEvents (7.0) - restriction: >= net6.0 Mono.Posix.NETStandard (1.0) - restriction: >= netstandard2.0 - MSBuild.StructuredLogger (2.1.820) - restriction: >= netstandard2.0 + MSBuild.StructuredLogger (2.1.844) - 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 - NuGet.Common (6.5) - restriction: >= netstandard2.0 - NuGet.Frameworks (>= 6.5) - restriction: >= netstandard2.0 - NuGet.Configuration (6.5) - restriction: >= netstandard2.0 - NuGet.Common (>= 6.5) - restriction: >= netstandard2.0 + NuGet.Common (6.6.1) - restriction: >= netstandard2.0 + NuGet.Frameworks (>= 6.6.1) - restriction: >= netstandard2.0 + NuGet.Configuration (6.6.1) - restriction: >= netstandard2.0 + NuGet.Common (>= 6.6.1) - restriction: >= netstandard2.0 System.Security.Cryptography.ProtectedData (>= 4.4) - restriction: && (< net472) (>= netstandard2.0) - NuGet.Frameworks (6.5) - restriction: >= netstandard2.0 - NuGet.Packaging (6.5) - restriction: >= netstandard2.0 + NuGet.Frameworks (6.6.1) - restriction: >= netstandard2.0 + NuGet.Packaging (6.6.1) - restriction: >= netstandard2.0 Newtonsoft.Json (>= 13.0.1) - restriction: >= netstandard2.0 - NuGet.Configuration (>= 6.5) - restriction: >= netstandard2.0 - NuGet.Versioning (>= 6.5) - restriction: >= netstandard2.0 + NuGet.Configuration (>= 6.6.1) - restriction: >= netstandard2.0 + NuGet.Versioning (>= 6.6.1) - restriction: >= netstandard2.0 System.Security.Cryptography.Cng (>= 5.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net5.0) System.Security.Cryptography.Pkcs (>= 5.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net5.0) - NuGet.Protocol (6.5) - restriction: >= netstandard2.0 - NuGet.Packaging (>= 6.5) - restriction: >= netstandard2.0 - NuGet.Versioning (6.5) - restriction: >= netstandard2.0 + NuGet.Protocol (6.6.1) - restriction: >= netstandard2.0 + NuGet.Packaging (>= 6.6.1) - restriction: >= netstandard2.0 + NuGet.Versioning (6.6.1) - restriction: >= netstandard2.0 Octokit (0.48) System.Buffers (4.5.1) - restriction: || (&& (>= monoandroid) (< netstandard1.1) (>= netstandard2.0)) (&& (>= monoandroid) (< netstandard1.3) (>= netstandard2.0)) (&& (< monoandroid) (< netstandard1.1) (>= netstandard2.0) (< win8)) (&& (>= monotouch) (>= netstandard2.0)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (&& (>= net461) (>= netstandard2.0)) (&& (>= net462) (>= netstandard2.0)) (&& (>= net462) (>= netstandard2.1)) (&& (< net462) (< net6.0) (>= netstandard2.0)) (&& (< net462) (>= netstandard2.0) (< netstandard2.1)) (>= net472) (&& (>= net5.0) (< netstandard2.1)) (&& (< net6.0) (>= netstandard2.1)) (&& (< netstandard1.1) (>= netstandard2.0) (>= win8)) (&& (>= netstandard2.0) (>= xamarintvos)) (&& (>= netstandard2.0) (>= xamarinwatchos)) (>= xamarinios) (>= xamarinmac) System.Collections.Immutable (7.0) - restriction: >= netstandard2.0 @@ -1037,7 +1030,7 @@ NUGET System.Formats.Asn1 (>= 5.0) - restriction: && (>= netcoreapp3.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) System.Security.Cryptography.Algorithms (>= 4.3.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net46) (>= netstandard1.6) (< netstandard2.0) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net46) (>= netstandard1.3) (< netstandard1.4)) (&& (< monoandroid) (< net46) (>= netstandard1.4) (< netstandard1.6) (< uap10.1)) (&& (>= net46) (< netstandard1.4)) (&& (>= net461) (< net462) (< netstandard1.6)) (&& (>= net462) (< netstandard1.6)) (>= net47) System.Security.Cryptography.Encoding (4.3) - restriction: || (&& (< monoandroid) (< net46) (< netstandard1.4) (>= netstandard2.0)) (&& (< monoandroid) (< net46) (< netstandard1.6) (>= netstandard2.0)) (&& (< monoandroid) (>= net5.0) (< netstandard1.4)) (&& (< monoandroid) (>= net5.0) (< netstandard1.6)) (&& (< monoandroid) (>= net5.0) (< netstandard2.0) (< xamarintvos) (< xamarinwatchos)) (&& (>= net46) (>= net5.0) (< netstandard1.4)) (&& (< net46) (>= net461) (< netstandard1.6) (>= netstandard2.0)) (&& (< net46) (>= net462) (< netstandard1.6) (>= netstandard2.0)) (&& (< net46) (>= net47) (>= netstandard2.0)) (&& (>= net461) (>= net5.0) (< netstandard1.6)) (&& (>= net462) (>= net5.0) (< netstandard1.6)) (&& (>= net463) (>= net5.0) (< netstandard1.4)) (&& (>= net463) (>= net5.0) (< netstandard1.6)) (&& (>= net463) (>= net5.0) (< netstandard2.0)) (&& (>= net463) (< netstandard1.4) (>= netstandard2.0)) (&& (>= net463) (< netstandard1.6) (>= netstandard2.0)) (&& (>= net47) (< net472) (>= netstandard2.0)) (&& (>= net47) (>= net5.0)) - System.Security.Cryptography.Pkcs (7.0.1) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net5.0) + System.Security.Cryptography.Pkcs (7.0.3) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net5.0) System.Buffers (>= 4.5.1) - restriction: && (< net462) (>= netstandard2.0) (< netstandard2.1) System.Formats.Asn1 (>= 7.0) - restriction: || (&& (< net462) (>= netstandard2.0)) (>= netstandard2.1) System.Memory (>= 4.5.5) - restriction: && (< net462) (>= netstandard2.0) (< netstandard2.1) @@ -1048,7 +1041,7 @@ NUGET System.Security.Permissions (7.0) - restriction: >= netstandard2.0 System.Security.AccessControl (>= 6.0) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) System.Windows.Extensions (>= 7.0) - restriction: >= net6.0 - System.Security.Principal.Windows (5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3) (>= netstandard2.0)) (&& (< monoandroid) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netstandard2.0)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (&& (>= net461) (>= netstandard2.0)) (&& (>= net462) (>= netstandard2.0)) (&& (< net6.0) (>= netstandard2.0)) (>= netcoreapp2.1) (&& (>= netstandard2.0) (>= uap10.1)) (&& (>= netstandard2.0) (>= xamarintvos)) (&& (>= netstandard2.0) (>= xamarinwatchos)) (>= xamarinios) (>= xamarinmac) + System.Security.Principal.Windows (5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3) (>= netstandard2.0)) (&& (< monoandroid) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netstandard2.0)) (&& (< net45) (< netcoreapp2.0) (>= netstandard2.0)) (&& (>= net461) (>= netstandard2.0)) (&& (>= net462) (>= netstandard2.0)) (>= net472) (&& (< net6.0) (>= netstandard2.0)) (&& (< net7.0) (>= netstandard2.0)) (>= netcoreapp2.1) (&& (>= netstandard2.0) (>= uap10.1)) (&& (>= netstandard2.0) (>= xamarintvos)) (&& (>= netstandard2.0) (>= xamarinwatchos)) (>= xamarinios) (>= xamarinmac) Microsoft.NETCore.Platforms (>= 5.0) - restriction: || (&& (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (>= netcoreapp2.1) (< netcoreapp3.0)) System.Text.Encoding.CodePages (7.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) @@ -1189,27 +1182,34 @@ NUGET FSharp.Literate (4.0.0-rc1) FSharp.Compiler.Service (>= 34.1) - restriction: >= netstandard2.0 FSharp.Core (>= 4.7) - restriction: >= netstandard2.0 - Microsoft.Build.Framework (17.5) - restriction: >= netstandard2.0 + Microsoft.Build.Framework (17.6.3) - restriction: >= netstandard2.0 + Microsoft.VisualStudio.Setup.Configuration.Interop (>= 3.2.2146) - restriction: >= net472 Microsoft.Win32.Registry (>= 5.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: >= net472 - System.Security.Permissions (>= 6.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net7.0) - Microsoft.Build.Utilities.Core (17.5) - restriction: >= netstandard2.0 - Microsoft.Build.Framework (>= 17.5) - restriction: >= netstandard2.0 + System.Security.Permissions (>= 7.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net7.0) + System.Security.Principal.Windows (>= 5.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) + Microsoft.Build.Utilities.Core (17.6.3) - restriction: >= netstandard2.0 + Microsoft.Build.Framework (>= 17.6.3) - restriction: >= netstandard2.0 Microsoft.IO.Redist (>= 6.0) - restriction: >= net472 - Microsoft.NET.StringTools (>= 17.5) - restriction: >= netstandard2.0 + Microsoft.NET.StringTools (>= 17.6.3) - restriction: >= netstandard2.0 + Microsoft.VisualStudio.Setup.Configuration.Interop (>= 3.2.2146) - restriction: || (>= net472) (>= net7.0) Microsoft.Win32.Registry (>= 5.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) - System.Collections.Immutable (>= 6.0) - restriction: >= netstandard2.0 - System.Configuration.ConfigurationManager (>= 6.0) - restriction: >= netstandard2.0 - System.Security.Permissions (>= 6.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) - System.Text.Encoding.CodePages (>= 6.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) + System.Collections.Immutable (>= 7.0) - restriction: >= netstandard2.0 + System.Configuration.ConfigurationManager (>= 7.0) - restriction: >= netstandard2.0 + System.Memory (>= 4.5.5) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) + System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) + System.Security.Permissions (>= 7.0) - restriction: >= netstandard2.0 + System.Security.Principal.Windows (>= 5.0) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) + System.Text.Encoding.CodePages (>= 7.0) - restriction: && (< net472) (< net7.0) (>= netstandard2.0) Microsoft.IO.Redist (6.0) - restriction: >= net472 System.Buffers (>= 4.5.1) - restriction: >= net472 System.Memory (>= 4.5.4) - restriction: >= net472 - Microsoft.NET.StringTools (17.5) - restriction: >= netstandard2.0 + Microsoft.NET.StringTools (17.6.3) - restriction: >= netstandard2.0 System.Memory (>= 4.5.5) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) System.Runtime.CompilerServices.Unsafe (>= 6.0) - restriction: || (>= net472) (&& (< net7.0) (>= netstandard2.0)) - Microsoft.NETCore.Platforms (7.0.2) - restriction: || (&& (>= monoandroid) (>= netcoreapp2.0) (< netstandard1.3)) (&& (>= monoandroid) (>= netcoreapp2.1) (< netstandard1.3)) (&& (< monoandroid) (< net45) (< netstandard1.2) (>= netstandard2.0) (< win8)) (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (>= net5.0) (< netcoreapp2.1) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= monotouch) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netcoreapp2.1)) (&& (< net45) (>= netstandard2.0) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< net46) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= net461) (>= netcoreapp2.0)) (&& (>= net461) (>= netcoreapp2.1)) (&& (>= netcoreapp2.0) (>= uap10.1)) (&& (< netcoreapp2.0) (>= netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= netcoreapp2.1) (< netcoreapp3.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= netcoreapp2.1) (>= uap10.1)) + Microsoft.NETCore.Platforms (7.0.4) - restriction: || (&& (>= monoandroid) (>= netcoreapp2.0) (< netstandard1.3)) (&& (>= monoandroid) (>= netcoreapp2.1) (< netstandard1.3)) (&& (< monoandroid) (< net45) (< netstandard1.2) (>= netstandard2.0) (< win8)) (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (>= net5.0) (< netcoreapp2.1) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (>= netcoreapp2.0) (< netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= monotouch) (>= netcoreapp2.0)) (&& (>= monotouch) (>= netcoreapp2.1)) (&& (< net45) (>= netstandard2.0) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< net46) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= net461) (>= netcoreapp2.0)) (&& (>= net461) (>= netcoreapp2.1)) (&& (>= netcoreapp2.0) (>= uap10.1)) (&& (< netcoreapp2.0) (>= netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= netcoreapp2.1) (< netcoreapp3.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= netcoreapp2.1) (>= uap10.1)) Microsoft.NETCore.Targets (5.0) - restriction: || (&& (< monoandroid) (< net45) (< netstandard1.2) (>= netstandard2.0) (< win8)) (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< net45) (>= netstandard2.0) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< net46) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) + Microsoft.VisualStudio.Setup.Configuration.Interop (3.6.2115) - restriction: || (>= net472) (>= net7.0) Microsoft.Win32.Primitives (4.3) - restriction: && (< net46) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) Microsoft.NETCore.Platforms (>= 1.1) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) Microsoft.NETCore.Targets (>= 1.1) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) @@ -1221,25 +1221,25 @@ NUGET 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) Microsoft.Win32.SystemEvents (7.0) - restriction: >= net6.0 Mono.Posix.NETStandard (1.0) - restriction: >= netstandard2.0 - MSBuild.StructuredLogger (2.1.820) - restriction: >= netstandard2.0 + MSBuild.StructuredLogger (2.1.844) - 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 - NuGet.Common (6.5) - restriction: >= netstandard2.0 - NuGet.Frameworks (>= 6.5) - restriction: >= netstandard2.0 - NuGet.Configuration (6.5) - restriction: >= netstandard2.0 - NuGet.Common (>= 6.5) - restriction: >= netstandard2.0 + NuGet.Common (6.6.1) - restriction: >= netstandard2.0 + NuGet.Frameworks (>= 6.6.1) - restriction: >= netstandard2.0 + NuGet.Configuration (6.6.1) - restriction: >= netstandard2.0 + NuGet.Common (>= 6.6.1) - restriction: >= netstandard2.0 System.Security.Cryptography.ProtectedData (>= 4.4) - restriction: && (< net472) (>= netstandard2.0) - NuGet.Frameworks (6.5) - restriction: >= netstandard2.0 - NuGet.Packaging (6.5) - restriction: >= netstandard2.0 + NuGet.Frameworks (6.6.1) - restriction: >= netstandard2.0 + NuGet.Packaging (6.6.1) - restriction: >= netstandard2.0 Newtonsoft.Json (>= 13.0.1) - restriction: >= netstandard2.0 - NuGet.Configuration (>= 6.5) - restriction: >= netstandard2.0 - NuGet.Versioning (>= 6.5) - restriction: >= netstandard2.0 + NuGet.Configuration (>= 6.6.1) - restriction: >= netstandard2.0 + NuGet.Versioning (>= 6.6.1) - restriction: >= netstandard2.0 System.Security.Cryptography.Cng (>= 5.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net5.0) System.Security.Cryptography.Pkcs (>= 5.0) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net5.0) - NuGet.Protocol (6.5) - restriction: >= netstandard2.0 - NuGet.Packaging (>= 6.5) - restriction: >= netstandard2.0 - NuGet.Versioning (6.5) - restriction: >= netstandard2.0 + NuGet.Protocol (6.6.1) - restriction: >= netstandard2.0 + NuGet.Packaging (>= 6.6.1) - restriction: >= netstandard2.0 + NuGet.Versioning (6.6.1) - restriction: >= netstandard2.0 runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - restriction: && (< net46) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) runtime.debian.9-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - restriction: && (< net46) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - restriction: && (< net46) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) @@ -1388,7 +1388,7 @@ NUGET System.Reflection.Emit (4.7) - restriction: && (< net461) (>= netstandard2.0) System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.1) (< netstandard2.0) (< win8) (< wpa81) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (< netcoreapp2.0) (>= netstandard2.0) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< netstandard1.1) (>= portable-net45+win8+wpa81) (< win8)) (&& (< netstandard1.1) (>= win8)) (&& (< netstandard2.0) (>= wpa81)) (>= uap10.1) System.Reflection.Emit.ILGeneration (4.7) - restriction: || (&& (< monoandroid) (< net45) (< netcoreapp2.0) (>= netstandard2.0) (< netstandard2.1) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< netstandard1.1) (>= netstandard2.0) (< win8)) (&& (< netstandard1.1) (>= netstandard2.0) (>= win8)) (&& (>= netstandard2.0) (>= uap10.1)) - System.Reflection.Metadata (7.0.1) - restriction: || (>= net461) (>= netstandard2.0) + System.Reflection.Metadata (7.0.2) - restriction: || (>= net461) (>= netstandard2.0) System.Collections.Immutable (>= 7.0) - restriction: || (>= net462) (>= netstandard2.0) System.Memory (>= 4.5.5) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) System.Reflection.Primitives (4.3) - restriction: || (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< net45) (>= netstandard2.0) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) @@ -1464,7 +1464,7 @@ NUGET System.Runtime.InteropServices (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) System.Security.Cryptography.Primitives (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) System.Text.Encoding (>= 4.3) - restriction: && (< monoandroid) (< monotouch) (< net46) (>= netstandard1.3) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos) - System.Security.Cryptography.Pkcs (7.0.1) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net5.0) + System.Security.Cryptography.Pkcs (7.0.3) - restriction: || (&& (< net472) (>= netstandard2.0)) (>= net5.0) System.Buffers (>= 4.5.1) - restriction: && (< net462) (>= netstandard2.0) (< netstandard2.1) System.Formats.Asn1 (>= 7.0) - restriction: || (&& (< net462) (>= netstandard2.0)) (>= netstandard2.1) System.Memory (>= 4.5.5) - restriction: && (< net462) (>= netstandard2.0) (< netstandard2.1) @@ -1482,7 +1482,7 @@ NUGET System.Security.Permissions (7.0) - restriction: >= netstandard2.0 System.Security.AccessControl (>= 6.0) - restriction: || (>= net462) (&& (< net6.0) (>= netstandard2.0)) System.Windows.Extensions (>= 7.0) - restriction: >= net6.0 - System.Security.Principal.Windows (5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3) (>= netstandard2.0)) (&& (< monoandroid) (>= netcoreapp2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= monotouch) (>= netstandard2.0)) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= net461) (>= netstandard2.0)) (&& (>= net462) (>= netstandard2.0)) (&& (< net6.0) (>= netstandard2.0)) (&& (>= netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= netstandard2.0) (>= uap10.1)) + System.Security.Principal.Windows (5.0) - restriction: || (&& (>= monoandroid) (< netstandard1.3) (>= netstandard2.0)) (&& (< monoandroid) (>= netcoreapp2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= monotouch) (>= netstandard2.0)) (&& (< net46) (< netcoreapp2.0) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= net461) (>= netstandard2.0)) (&& (>= net462) (>= netstandard2.0)) (>= net472) (&& (< net6.0) (>= netstandard2.0)) (&& (< net7.0) (>= netstandard2.0)) (&& (>= netcoreapp2.1) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (>= netstandard2.0) (>= uap10.1)) Microsoft.NETCore.Platforms (>= 5.0) - restriction: || (&& (>= netcoreapp2.0) (< netcoreapp2.1)) (&& (>= netcoreapp2.1) (< netcoreapp3.0)) System.Text.Encoding (4.3) - restriction: || (&& (< monoandroid) (< net45) (< netstandard1.3) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.4) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.5) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< monoandroid) (< net45) (< netstandard1.6) (>= netstandard2.0) (< win8) (< wpa81)) (&& (< net45) (>= net463) (>= netstandard2.0)) (&& (< net45) (>= netstandard2.0) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< net46) (>= netstandard2.0) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (< monoandroid) (< monotouch) (< net45) (>= netstandard1.3) (< win8) (< wpa81) (< xamarinios) (< xamarinmac) (< xamarintvos) (< xamarinwatchos)) (&& (< monoandroid) (< net45) (>= netstandard1.0) (< netstandard1.3) (< win8) (< wp8) (< wpa81)) diff --git a/src/GraphBLAS-sharp.Backend/Algorithms/Algorithms.fs b/src/GraphBLAS-sharp.Backend/Algorithms/Algorithms.fs new file mode 100644 index 00000000..e412d186 --- /dev/null +++ b/src/GraphBLAS-sharp.Backend/Algorithms/Algorithms.fs @@ -0,0 +1,9 @@ +namespace GraphBLAS.FSharp + +open Microsoft.FSharp.Core +open GraphBLAS.FSharp.Backend.Algorithms + +[] +module Algorithms = + module BFS = + let singleSource = BFS.singleSource diff --git a/src/GraphBLAS-sharp.Backend/Algorithms/BFS.fs b/src/GraphBLAS-sharp.Backend/Algorithms/BFS.fs index 9896a557..de7f0cc8 100644 --- a/src/GraphBLAS-sharp.Backend/Algorithms/BFS.fs +++ b/src/GraphBLAS-sharp.Backend/Algorithms/BFS.fs @@ -1,18 +1,16 @@ namespace GraphBLAS.FSharp.Backend.Algorithms -open GraphBLAS.FSharp.Backend open Brahma.FSharp open FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Vector open GraphBLAS.FSharp.Backend.Vector.Dense -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions -module BFS = +module internal BFS = let singleSource (add: Expr int option -> int option>) (mul: Expr<'a option -> int option -> int option>) @@ -21,7 +19,7 @@ module BFS = = let spMVTo = - SpMV.runTo add mul clContext workGroupSize + Operations.SpMVInplace add mul clContext workGroupSize let zeroCreate = ClArray.zeroCreate clContext workGroupSize @@ -37,7 +35,7 @@ module BFS = let containsNonZero = ClArray.exists Predicates.isSome clContext workGroupSize - fun (queue: MailboxProcessor) (matrix: ClMatrix.CSR<'a>) (source: int) -> + fun (queue: MailboxProcessor) (matrix: ClMatrix<'a>) (source: int) -> let vertexCount = matrix.RowCount let levels = zeroCreate queue HostInterop vertexCount @@ -58,7 +56,7 @@ module BFS = fillSubVectorTo queue levels front (clContext.CreateClCell level) levels //Getting new frontier - spMVTo queue matrix front front + spMVTo queue matrix frontier frontier maskComplementedTo queue front levels front diff --git a/src/GraphBLAS-sharp.Backend/AssemblyInfo.fs b/src/GraphBLAS-sharp.Backend/AssemblyInfo.fs index beeaabeb..12bc67b0 100644 --- a/src/GraphBLAS-sharp.Backend/AssemblyInfo.fs +++ b/src/GraphBLAS-sharp.Backend/AssemblyInfo.fs @@ -4,6 +4,8 @@ namespace System open System.Reflection open System.Runtime.CompilerServices +[] +[] [] [] [] diff --git a/src/GraphBLAS-sharp.Backend/Common/ClArray.fs b/src/GraphBLAS-sharp.Backend/Common/ClArray.fs index d048c650..c983415a 100644 --- a/src/GraphBLAS-sharp.Backend/Common/ClArray.fs +++ b/src/GraphBLAS-sharp.Backend/Common/ClArray.fs @@ -1,15 +1,21 @@ -namespace GraphBLAS.FSharp.Backend.Common +namespace GraphBLAS.FSharp -open System.Collections.Generic open Brahma.FSharp open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ClCell -open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Backend.Common open GraphBLAS.FSharp.Backend.Quotes +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions +[] module ClArray = + /// + /// Creates an array given the dimension and a generator function to compute the elements. + /// + /// The function to generate the initial values for each index. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let init (initializer: Expr 'a>) (clContext: ClContext) workGroupSize = let init = @@ -36,6 +42,11 @@ module ClArray = outputArray + /// + /// Creates an array whose elements are all initially the given value. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let create (clContext: ClContext) workGroupSize = let create = @@ -65,6 +76,11 @@ module ClArray = outputArray + /// + /// Creates an array where the entries are initially the default value of desired type. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let zeroCreate<'a> (clContext: ClContext) workGroupSize = let create = create clContext workGroupSize @@ -72,6 +88,11 @@ module ClArray = fun (processor: MailboxProcessor<_>) allocationMode length -> create processor allocationMode length Unchecked.defaultof<'a> + /// + /// Builds a new array that contains the elements of the given array. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let copy (clContext: ClContext) workGroupSize = let copy = <@ fun (ndRange: Range1D) (inputArrayBuffer: ClArray<'a>) (outputArrayBuffer: ClArray<'a>) inputArrayLength -> @@ -100,6 +121,11 @@ module ClArray = outputArray + /// + /// Creates an array of the given size by replicating the values of the given initial array. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let replicate (clContext: ClContext) workGroupSize = let replicate = @@ -132,6 +158,13 @@ module ClArray = outputArray + /// + /// Builds a new array whose elements are the results of applying the given function + /// to each of the elements of the array. + /// + /// The function to transform elements of the array. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let map<'a, 'b> (op: Expr<'a -> 'b>) (clContext: ClContext) workGroupSize = let map = @@ -160,6 +193,14 @@ module ClArray = result + /// + /// Builds a new array whose elements are the results of applying the given function + /// to the corresponding pairs of values, where the first element of pair is from the given array + /// and the second element is the given value. + /// + /// The function to transform elements of the array. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let mapWithValue<'a, 'b, 'c> (clContext: ClContext) workGroupSize (op: Expr<'a -> 'b -> 'c>) = let map = @@ -192,6 +233,16 @@ module ClArray = result + /// + /// Fills the third given array with the results of applying the given function + /// to the corresponding elements of the first two given arrays pairwise. + /// + /// + /// The first two input arrays must have the same lengths. + /// + /// The function to transform the pairs of the input elements. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let map2InPlace<'a, 'b, 'c> (map: Expr<'a -> 'b -> 'c>) (clContext: ClContext) workGroupSize = let kernel = @@ -219,6 +270,16 @@ module ClArray = processor.Post(Msg.CreateRunMsg<_, _>(kernel)) + /// + /// Builds a new array whose elements are the results of applying the given function + /// to the corresponding elements of the two given arrays pairwise. + /// + /// + /// The two input arrays must have the same lengths. + /// + /// The function to transform the pairs of the input elements. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let map2<'a, 'b, 'c> map (clContext: ClContext) workGroupSize = let map2 = map2InPlace<'a, 'b, 'c> map clContext workGroupSize @@ -268,11 +329,19 @@ module ClArray = bitmap + /// + /// Gets the bitmap that indicates the first elements of the sequences of consecutive identical elements + /// + /// OpenCL context. let firstOccurrence clContext = getUniqueBitmapGeneral <| Predicates.firstOccurrence () <| clContext + /// + /// Gets the bitmap that indicates the last elements of the sequences of consecutive identical elements + /// + /// OpenCL context. let lastOccurrence clContext = getUniqueBitmapGeneral <| Predicates.lastOccurrence () @@ -300,16 +369,28 @@ module ClArray = result + /// + /// Gets the bitmap that indicates the first elements of the sequences + /// of consecutive identical elements from either first array or second array. + /// + /// OpenCL context. let firstOccurrence2 clContext = getUniqueBitmap2General firstOccurrence clContext + /// + /// Gets the bitmap that indicates the last elements of the sequences + /// of consecutive identical elements from either first array or second array. + /// + /// OpenCL context. let lastOccurrence2 clContext = getUniqueBitmap2General lastOccurrence clContext - ///Remove duplicates form the given array. - ///Computational context - ///Should be a power of 2 and greater than 1. - ///Should be sorted. + /// + /// Removes duplicates form the given array. + /// + /// Computational context + /// Should be a power of 2 and greater than 1. + /// Should be sorted. let removeDuplications (clContext: ClContext) workGroupSize = let scatter = @@ -339,6 +420,12 @@ module ClArray = outputArray + /// + /// Tests if any element of the array satisfies the given predicate. + /// + /// The function to test the input elements. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let exists (predicate: Expr<'a -> bool>) (clContext: ClContext) workGroupSize = let exists = @@ -368,7 +455,15 @@ module ClArray = result - let assignOption (op: Expr<'a -> 'b option>) (clContext: ClContext) workGroupSize = + /// + /// Maps every value from the given value array and, if the result of applying function is Some, + /// places the result to a specific position from the input array of positions. + /// If the result of mapping is None, it is just ignored. + /// + /// Function that maps elements from value array. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let private assignOption (op: Expr<'a -> 'b option>) (clContext: ClContext) workGroupSize = let assign = <@ fun (ndRange: Range1D) length (values: ClArray<'a>) (positions: ClArray) (result: ClArray<'b>) resultLength -> @@ -404,6 +499,14 @@ module ClArray = processor.Post(Msg.CreateRunMsg<_, _>(kernel)) + /// + /// Applies the given function to each element of the array. + /// Returns the array comprised of the results x + /// for each element where the function returns Some(x). + /// + /// The function to generate options from the elements. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let choose<'a, 'b> (predicate: Expr<'a -> 'b option>) (clContext: ClContext) workGroupSize = let getBitmap = map<'a, int> (Map.chooseBitmap predicate) clContext workGroupSize @@ -437,6 +540,14 @@ module ClArray = Some result + /// + /// Maps pair of values from the given value arrays and, if the result of applying function is Some, + /// places the result to a specific position from the input array of positions. + /// If the result of mapping is None, it is just ignored. + /// + /// Function that maps pairs of elements from value arrays. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let assignOption2 (op: Expr<'a -> 'b -> 'c option>) (clContext: ClContext) workGroupSize = let assign = @@ -484,6 +595,14 @@ module ClArray = processor.Post(Msg.CreateRunMsg<_, _>(kernel)) + /// + /// Applies the given function to each pair of elements of the two given arrays. + /// Returns the array comprised of the results x + /// for each pairs where the function returns Some(x). + /// + /// The function to generate options from the pairs of elements. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let choose2 (predicate: Expr<'a -> 'b -> 'c option>) (clContext: ClContext) workGroupSize = let getBitmap = map2<'a, 'b, int> (Map.choose2Bitmap predicate) clContext workGroupSize @@ -510,6 +629,11 @@ module ClArray = result + /// + /// Builds a new array that contains the given subrange specified by starting index and length. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let sub (clContext: ClContext) workGroupSize = let kernel = @@ -549,10 +673,10 @@ module ClArray = result /// - /// Lazy divides the input array into chunks of size at most chunkSize. + /// Divides lazily the input array into chunks of size at most chunkSize. /// - /// Cl context. - /// Work group size. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. /// /// Since calculations are performed lazily, the array should not change. /// @@ -581,8 +705,8 @@ module ClArray = /// /// Divides the input array into chunks of size at most chunkSize. /// - /// Cl context. - /// Work group size. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let chunkBySize (clContext: ClContext) workGroupSize = let chunkBySizeLazy = lazyChunkBySize clContext workGroupSize @@ -592,6 +716,11 @@ module ClArray = |> Seq.map (fun lazyValue -> lazyValue.Value) |> Seq.toArray + /// + /// Reads a range of elements from the first array and write them into the second. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let blit<'a> (clContext: ClContext) workGroupSize = let assign = @@ -635,6 +764,11 @@ module ClArray = processor.Post(Msg.CreateRunMsg<_, _>(kernel)) + /// + /// Builds a new array that contains the elements of each of the given sequence of arrays. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let concat (clContext: ClContext) workGroupSize = let blit = blit clContext workGroupSize @@ -659,6 +793,11 @@ module ClArray = result + /// + /// Fills a range of elements of the array with the given value. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let fill (clContext: ClContext) workGroupSize = let fill = @@ -693,6 +832,12 @@ module ClArray = processor.Post(Msg.CreateRunMsg<_, _>(kernel)) + /// + /// Returns an array of each element in the input array and its predecessor, + /// with the exception of the first element which is only returned as the predecessor of the second element. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let pairwise (clContext: ClContext) workGroupSize = let idGather = @@ -729,7 +874,7 @@ module ClArray = None let private bound<'a, 'b when 'a: equality and 'a: comparison> - (lowerBound: Expr<(int -> 'a -> ClArray<'a> -> 'b)>) + (lowerBound: Expr 'a -> ClArray<'a> -> 'b>) (clContext: ClContext) workGroupSize = @@ -759,12 +904,32 @@ module ClArray = result + /// + /// Finds the position of the largest value and the value itself + /// that is less than the given one. + /// + /// + /// Array of values should be sorted. + /// + /// OpenCL context. let upperBoundAndValue<'a when 'a: comparison> clContext = bound<'a, int * 'a> Search.Bin.lowerBoundAndValue clContext + /// + /// Finds the position of the largest value that is less than the given one. + /// + /// + /// Array of values should be sorted. + /// + /// OpenCL context. let upperBound<'a when 'a: comparison> clContext = bound<'a, int> Search.Bin.lowerBound clContext + /// + /// Gets the value at the specified position from the input array. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let item<'a> (clContext: ClContext) workGroupSize = let kernel = @@ -794,6 +959,11 @@ module ClArray = result + /// + /// Sets an element of an array. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let set<'a> (clContext: ClContext) workGroupSize = let kernel = diff --git a/src/GraphBLAS-sharp.Backend/Common/Common.fs b/src/GraphBLAS-sharp.Backend/Common/Common.fs new file mode 100644 index 00000000..53777d33 --- /dev/null +++ b/src/GraphBLAS-sharp.Backend/Common/Common.fs @@ -0,0 +1,413 @@ +namespace GraphBLAS.FSharp + +open Brahma.FSharp +open Microsoft.FSharp.Quotations +open GraphBLAS.FSharp.Backend.Common + +module Common = + module Sort = + module Bitonic = + /// + /// Sorts in-place input array of values by their 2d indices, + /// which are stored in two given arrays of keys: rows and columns. + /// When comparing, it first looks at rows, then columns. + /// + /// + /// + /// let rows = [| 0; 0; 3; 2; 1; 0; 5 |] + /// let columns = [| 0; 2; 1; 2; 0; 3; 5; |] + /// let values = [| 1.9; 2.8; 3.7; 4.6; 5.5; 6.4; 7.3; |] + /// sortKeyValuesInplace clContext 32 processor rows columns values + /// ... + /// > val rows = [| 0; 0; 0; 1; 2; 3; 5 |] + /// > let columns = [| 0; 2; 3; 0; 2; 1; 5; |] + /// > val values = [| 1.9; 2.8; 6.4; 5.5; 4.6; 3.7; 7.3 |] + /// + /// + let sortKeyValuesInplace<'n, 'a when 'n: comparison> = + Sort.Bitonic.sortKeyValuesInplace<'n, 'a> + + module Radix = + /// + /// Sorts stable input array of values by given integer keys. + /// + /// + /// + /// let keys = [| 0; 4; 3; 1; 2; 6; 5 |] + /// let values = [| 1.9; 2.8; 3.7; 4.6; 5.5; 6.4; 7.3; |] + /// runByKeysStandard clContext 32 processor keys values + /// ... + /// > val keys = [| 0; 1; 2; 3; 4; 5; 6 |] + /// > val values = [| 1.9; 4.6; 5.5; 3.7; 2.8; 7.3; 6.4 |] + /// + /// + let runByKeysStandard = Sort.Radix.runByKeysStandard + + /// + /// Sorts stable input array of integer keys. + /// + /// + /// + /// let keys = [| 0; 4; 3; 1; 2; 6; 5 |] + /// standardRunKeysOnly clContext 32 processor keys + /// ... + /// > val keys = [| 0; 1; 2; 3; 4; 5; 6 |] + /// + /// + let standardRunKeysOnly = Sort.Radix.standardRunKeysOnly + + module Gather = + /// + /// Fills the given output array using the given value array and a function. The function maps old position + /// of each element of the value array to its position in the output array. + /// + /// + /// If index is out of bounds, the value will be ignored. + /// + /// + /// + /// let positions = [| 1; 0; 2; 6; 4; 3; 5 |] + /// let values = [| 1.9; 2.8; 3.7; 4.6; 5.5; 6.4; 7.3; |] + /// run clContext 32 processor positions values result + /// ... + /// > val result = [| 2.8; 1.9; 3.7; 7.3; 5.5; 4.6; 6.4 |] + /// + /// + let runInit positionMap (clContext: ClContext) workGroupSize = + Gather.runInit positionMap clContext workGroupSize + + /// + /// Fills the given output array using the given value and position arrays. Array of positions indicates + /// which element from the value array should be in each position of the output array. + /// + /// + /// If index is out of bounds, the value will be ignored. + /// + /// + /// + /// let positions = [| 1; 0; 2; 6; 4; 3; 5 |] + /// let values = [| 1.9; 2.8; 3.7; 4.6; 5.5; 6.4; 7.3; |] + /// run clContext 32 processor positions values result + /// ... + /// > val result = [| 2.8; 1.9; 3.7; 7.3; 5.5; 4.6; 6.4 |] + /// + /// + let run (clContext: ClContext) workGroupSize = Gather.run clContext workGroupSize + + module Scatter = + /// + /// Creates a new array from the given one where it is indicated + /// by the array of positions at which position in the new array + /// should be a value from the given one. + /// + /// + /// Every element of the positions array must not be less than the previous one. + /// If there are several elements with the same indices, the FIRST one of them will be at the common index. + /// If index is out of bounds, the value will be ignored. + /// + /// + /// + /// let positions = [| 0; 0; 1; 1; 1; 2; 3; 3; 4 |] + /// let values = [| 1.9; 2.8; 3.7; 4.6; 5.5; 6.4; 7.3; 8.2; 9.1 |] + /// run clContext 32 processor positions values result + /// ... + /// > val result = [| 1,9; 3.7; 6.4; 7.3; 9.1 |] + /// + /// + let firstOccurrence clContext = Scatter.firstOccurrence clContext + + /// + /// Creates a new array from the given one where it is indicated by the array of positions at which position in the new array + /// should be a value from the given one. + /// + /// + /// Every element of the positions array must not be less than the previous one. + /// If there are several elements with the same indices, the LAST one of them will be at the common index. + /// If index is out of bounds, the value will be ignored. + /// + /// + /// + /// let positions = [| 0; 0; 1; 1; 1; 2; 3; 3; 4 |] + /// let values = [| 1.9; 2.8; 3.7; 4.6; 5.5; 6.4; 7.3; 8.2; 9.1 |] + /// run clContext 32 processor positions values result + /// ... + /// > val result = [| 2.8; 5.5; 6.4; 8.2; 9.1 |] + /// + /// + let lastOccurrence clContext = Scatter.lastOccurrence clContext + + /// + /// Creates a new array from the given one where it is indicated by the array of positions at which position in the new array + /// should be a values obtained by applying the mapping to the global id. + /// + /// + /// Every element of the positions array must not be less than the previous one. + /// If there are several elements with the same indices, the FIRST one of them will be at the common index. + /// If index is out of bounds, the value will be ignored. + /// + /// + /// + /// let positions = [| 0; 0; 1; 1; 1; 2; 3; 3; 4 |] + /// let valueMap = id + /// run clContext 32 processor positions values result + /// ... + /// > val result = [| 0; 2; 5; 6; 8 |] + /// + /// + /// Maps global id to a value + let initFirstOccurrence valueMap = Scatter.initFirstOccurrence valueMap + + /// + /// Creates a new array from the given one where it is indicated by the array of positions at which position in the new array + /// should be a values obtained by applying the mapping to the global id. + /// + /// + /// Every element of the positions array must not be less than the previous one. + /// If there are several elements with the same indices, the LAST one of them will be at the common index. + /// If index is out of bounds, the value will be ignored. + /// + /// + /// + /// let positions = [| 0; 0; 1; 1; 1; 2; 3; 3; 4 |] + /// let valueMap = id + /// run clContext 32 processor positions values result + /// ... + /// > val result = [| 1; 4; 5; 7; 8 |] + /// + /// + /// Maps global id to a value + let initLastOccurrence valueMap = Scatter.initLastOccurrence valueMap + + module PrefixSum = + /// + /// Exclude in-place prefix sum. + /// + /// + /// + /// let arr = [| 1; 1; 1; 1 |] + /// let sum = [| 0 |] + /// runExcludeInplace clContext workGroupSize processor arr sum (+) 0 + /// |> ignore + /// ... + /// > val arr = [| 0; 1; 2; 3 |] + /// > val sum = [| 4 |] + /// + /// + /// ClContext. + /// Should be a power of 2 and greater than 1. + /// Associative binary operation. + /// Zero element for binary operation. + let runExcludeInPlace plus = PrefixSum.runExcludeInPlace plus + + /// + /// Include in-place prefix sum. + /// + /// + /// + /// let arr = [| 1; 1; 1; 1 |] + /// let sum = [| 0 |] + /// runExcludeInplace clContext workGroupSize processor arr sum (+) 0 + /// |> ignore + /// ... + /// > val arr = [| 0; 1; 2; 3 |] + /// > val sum = [| 4 |] + /// + /// + /// Associative binary operation. + /// ClContext. + /// Should be a power of 2 and greater than 1. + /// Zero element for binary operation. + let runIncludeInPlace plus = PrefixSum.runIncludeInPlace plus + + /// + /// Exclude in-place prefix sum. Array is scanned starting from the end. + /// + /// Associative binary operation. + /// ClContext. + /// Should be a power of 2 and greater than 1. + /// Zero element for binary operation. + let runBackwardsExcludeInPlace plus = + PrefixSum.runBackwardsExcludeInPlace plus + + /// + /// Include in-place prefix sum. Array is scanned starting from the end. + /// + /// Associative binary operation. + /// ClContext. + /// Should be a power of 2 and greater than 1. + /// Zero element for binary operation. + let runBackwardsIncludeInPlace plus = + PrefixSum.runBackwardsIncludeInPlace plus + + /// + /// Exclude in-place prefix sum of integer array with addition operation and start value that is equal to 0. + /// + /// + /// + /// let arr = [| 1; 1; 1; 1 |] + /// let sum = [| 0 |] + /// runExcludeInplace clContext workGroupSize processor arr sum (+) 0 + /// |> ignore + /// ... + /// > val arr = [| 0; 1; 2; 3 |] + /// > val sum = [| 4 |] + /// + /// + let standardExcludeInPlace = PrefixSum.standardExcludeInPlace + + /// + /// Include in-place prefix sum of integer array with addition operation and start value that is equal to 0. + /// + /// + /// + /// let arr = [| 1; 1; 1; 1 |] + /// let sum = [| 0 |] + /// runIncludeInplace clContext workGroupSize processor arr sum (+) 0 + /// |> ignore + /// ... + /// > val arr = [| 1; 2; 3; 4 |] + /// > val sum = [| 4 |] + /// + /// + /// ClContext. + /// Should be a power of 2 and greater than 1. + let standardIncludeInPlace = PrefixSum.standardIncludeInPlace + + module ByKey = + /// + /// Exclude scan by key. + /// + /// + /// + /// let arr = [| 1; 1; 1; 1; 1; 1|] + /// let keys = [| 1; 2; 2; 2; 3; 3 |] + /// ... + /// > val result = [| 0; 0; 1; 2; 0; 1 |] + /// + /// + let sequentialExclude op = PrefixSum.ByKey.sequentialExclude op + + /// + /// Include scan by key. + /// + /// + /// + /// let arr = [| 1; 1; 1; 1; 1; 1|] + /// let keys = [| 1; 2; 2; 2; 3; 3 |] + /// ... + /// > val result = [| 1; 1; 2; 3; 1; 2 |] + /// + /// + let sequentialInclude op = PrefixSum.ByKey.sequentialInclude op + + module Reduce = + /// + /// Summarizes array elements. + /// + /// ClContext. + /// Work group size. + /// Summation operation. + /// Neutral element for summation. + let sum op zero (clContext: ClContext) workGroupSize = + Reduce.sum op zero clContext workGroupSize + + /// + /// Reduces an array of values. + /// + /// ClContext. + /// Work group size. + /// Reduction operation. + let reduce op (clContext: ClContext) workGroupSize = + Reduce.reduce op clContext workGroupSize + + /// + /// Reduction of an array of values by an array of keys. + /// + module ByKey = + /// + /// Reduces an array of values by key using a single work item. + /// + /// ClContext. + /// Work group size. + /// Operation for reducing values. + /// + /// The length of the result must be calculated in advance. + /// + let sequential (reduceOp: Expr<'a -> 'a -> 'a>) (clContext: ClContext) workGroupSize = + Reduce.ByKey.sequential reduceOp clContext workGroupSize + + /// + /// Reduces values by key. Each segment is reduced by one work item. + /// + /// ClContext. + /// Work group size. + /// Operation for reducing values. + /// + /// The length of the result must be calculated in advance. + /// + let segmentSequential (reduceOp: Expr<'a -> 'a -> 'a>) (clContext: ClContext) workGroupSize = + Reduce.ByKey.segmentSequential reduceOp clContext workGroupSize + + /// + /// Reduces values by key. One work group participates in the reduction. + /// + /// ClContext. + /// Work group size. + /// Operation for reducing values. + /// + /// Reduces an array of values that does not exceed the size of the workgroup. + /// The length of the result must be calculated in advance. + /// + let oneWorkGroupSegments (reduceOp: Expr<'a -> 'a -> 'a>) (clContext: ClContext) workGroupSize = + Reduce.ByKey.oneWorkGroupSegments reduceOp clContext workGroupSize + + module Option = + /// + /// Reduces values by key. Each segment is reduced by one work item. + /// + /// ClContext. + /// Work group size. + /// Operation for reducing values. + /// + /// The length of the result must be calculated in advance. + /// + let segmentSequential<'a> (reduceOp: Expr<'a -> 'a -> 'a option>) (clContext: ClContext) workGroupSize = + Reduce.ByKey.Option.segmentSequential reduceOp clContext workGroupSize + + module ByKey2D = + /// + /// Reduces an array of values by 2D keys using a single work item. + /// + /// ClContext. + /// Work group size. + /// Operation for reducing values. + /// + /// The length of the result must be calculated in advance. + /// + let sequential (reduceOp: Expr<'a -> 'a -> 'a>) (clContext: ClContext) workGroupSize = + Reduce.ByKey2D.sequential reduceOp clContext workGroupSize + + /// + /// Reduces values by key. Each segment is reduced by one work item. + /// + /// ClContext. + /// Work group size. + /// Operation for reducing values. + /// + /// The length of the result must be calculated in advance. + /// + let segmentSequential (reduceOp: Expr<'a -> 'a -> 'a>) (clContext: ClContext) workGroupSize = + Reduce.ByKey2D.segmentSequential reduceOp clContext workGroupSize + + module Option = + /// + /// Reduces values by key. Each segment is reduced by one work item. + /// + /// ClContext. + /// Work group size. + /// Operation for reducing values. + /// + /// The length of the result must be calculated in advance. + /// + let segmentSequential (reduceOp: Expr<'a -> 'a -> 'a option>) (clContext: ClContext) workGroupSize = + Reduce.ByKey2D.Option.segmentSequential reduceOp clContext workGroupSize diff --git a/src/GraphBLAS-sharp.Backend/Common/Gather.fs b/src/GraphBLAS-sharp.Backend/Common/Gather.fs index 791c88de..32d90859 100644 --- a/src/GraphBLAS-sharp.Backend/Common/Gather.fs +++ b/src/GraphBLAS-sharp.Backend/Common/Gather.fs @@ -2,7 +2,23 @@ namespace GraphBLAS.FSharp.Backend.Common open Brahma.FSharp -module internal Gather = +module Gather = + /// + /// Fills the given output array using the given value array and a function. The function maps old position + /// of each element of the value array to its position in the output array. + /// + /// + /// If index is out of bounds, the value will be ignored. + /// + /// + /// + /// let positions = [| 1; 0; 2; 6; 4; 3; 5 |] + /// let values = [| 1.9; 2.8; 3.7; 4.6; 5.5; 6.4; 7.3; |] + /// run clContext 32 processor positions values result + /// ... + /// > val result = [| 2.8; 1.9; 3.7; 7.3; 5.5; 4.6; 6.4 |] + /// + /// let runInit positionMap (clContext: ClContext) workGroupSize = let gather = @@ -30,14 +46,19 @@ module internal Gather = processor.Post(Msg.CreateRunMsg<_, _>(kernel)) /// - /// Creates a new array obtained from positions replaced with values from the given array at these positions (indices). + /// Fills the given output array using the given value and position arrays. Array of positions indicates + /// which element from the value array should be in each position of the output array. /// + /// + /// If index is out of bounds, the value will be ignored. + /// /// /// - /// let positions = [| 2; 0; 2; 1 |] - /// let array = [| 1.4; 2.5; 3.6 |] + /// let positions = [| 1; 0; 2; 6; 4; 3; 5 |] + /// let values = [| 1.9; 2.8; 3.7; 4.6; 5.5; 6.4; 7.3; |] + /// run clContext 32 processor positions values result /// ... - /// > val result = [| 3.6; 1.4; 3.6; 2.5 |] + /// > val result = [| 2.8; 1.9; 3.7; 7.3; 5.5; 4.6; 6.4 |] /// /// let run (clContext: ClContext) workGroupSize = diff --git a/src/GraphBLAS-sharp.Backend/Common/Merge.fs b/src/GraphBLAS-sharp.Backend/Common/Merge.fs deleted file mode 100644 index 07199ef2..00000000 --- a/src/GraphBLAS-sharp.Backend/Common/Merge.fs +++ /dev/null @@ -1,144 +0,0 @@ -namespace GraphBLAS.FSharp.Backend.Common - -open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects.ClContext - -module Merge = - let run<'a, 'b when 'a: struct and 'b: struct and 'a: comparison> (clContext: ClContext) workGroupSize = - - let defaultValue = Unchecked.defaultof<'a> - - let merge = - <@ fun (ndRange: Range1D) (firstSide: int) (secondSide: int) (sumOfSides: int) (firstValues: ClArray<'a>) (secondValues: ClArray<'a>) (resultValues: ClArray<'a>) -> - - let gid = ndRange.GlobalID0 - let lid = ndRange.LocalID0 - - let mutable beginIdxLocal = local () - let mutable endIdxLocal = local () - - if lid < 2 then - // (n - 1) * wgSize - 1 for lid = 0 - // n * wgSize - 1 for lid = 1 - // where n in 1 .. wgGroupCount - let x = lid * (workGroupSize - 1) + gid - 1 - - let diagonalNumber = min (sumOfSides - 1) x - - let mutable leftEdge = max 0 (diagonalNumber + 1 - secondSide) - - let mutable rightEdge = min (firstSide - 1) diagonalNumber - - while leftEdge <= rightEdge do - let middleIdx = (leftEdge + rightEdge) / 2 - - let firstIndex = firstValues.[middleIdx] - - let secondIndex = - secondValues.[diagonalNumber - middleIdx] - - if firstIndex <= secondIndex then - leftEdge <- middleIdx + 1 - else - rightEdge <- middleIdx - 1 - - // Here localID equals either 0 or 1 - if lid = 0 then - beginIdxLocal <- leftEdge - else - endIdxLocal <- leftEdge - - barrierLocal () - - let beginIdx = beginIdxLocal - let endIdx = endIdxLocal - let firstLocalLength = endIdx - beginIdx - - let mutable x = workGroupSize - firstLocalLength - - if endIdx = firstSide then - x <- secondSide - gid + lid + beginIdx - - let secondLocalLength = x - - //First indices are from 0 to firstLocalLength - 1 inclusive - //Second indices are from firstLocalLength to firstLocalLength + secondLocalLength - 1 inclusive - let localIndices = localArray<'a> workGroupSize - - if lid < firstLocalLength then - localIndices.[lid] <- firstValues.[beginIdx + lid] - - if lid < secondLocalLength then - localIndices.[firstLocalLength + lid] <- secondValues.[gid - beginIdx] - - barrierLocal () - - if gid < sumOfSides then - let mutable leftEdge = lid + 1 - secondLocalLength - if leftEdge < 0 then leftEdge <- 0 - - let mutable rightEdge = firstLocalLength - 1 - - rightEdge <- min rightEdge lid - - while leftEdge <= rightEdge do - let middleIdx = (leftEdge + rightEdge) / 2 - let firstIndex = localIndices.[middleIdx] - - let secondIndex = - localIndices.[firstLocalLength + lid - middleIdx] - - if firstIndex <= secondIndex then - leftEdge <- middleIdx + 1 - else - rightEdge <- middleIdx - 1 - - let boundaryX = rightEdge - let boundaryY = lid - leftEdge - - // boundaryX and boundaryY can't be off the right edge of array (only off the left edge) - let isValidX = boundaryX >= 0 - let isValidY = boundaryY >= 0 - - let mutable fstIdx = defaultValue - - if isValidX then - fstIdx <- localIndices.[boundaryX] - - let mutable sndIdx = defaultValue - - if isValidY then - sndIdx <- localIndices.[firstLocalLength + boundaryY] - - if not isValidX || isValidY && fstIdx <= sndIdx then - resultValues.[gid] <- sndIdx - else - resultValues.[gid] <- fstIdx @> - - let kernel = clContext.Compile merge - - fun (processor: MailboxProcessor<_>) (firstValues: ClArray<'a>) (secondValues: ClArray<'a>) -> - - let firstSide = firstValues.Length - - let secondSide = secondValues.Length - - let sumOfSides = firstSide + secondSide - - let resultValues = - clContext.CreateClArrayWithSpecificAllocationMode<'a>(DeviceOnly, sumOfSides) - - let ndRange = - Range1D.CreateValid(sumOfSides, workGroupSize) - - let kernel = kernel.GetKernel() - - processor.Post( - Msg.MsgSetArguments - (fun () -> - kernel.KernelFunc ndRange firstSide secondSide sumOfSides firstValues secondValues resultValues) - ) - - processor.Post(Msg.CreateRunMsg<_, _>(kernel)) - - resultValues diff --git a/src/GraphBLAS-sharp.Backend/Common/PrefixSum.fs b/src/GraphBLAS-sharp.Backend/Common/PrefixSum.fs index 09cdfb5d..a56af91f 100644 --- a/src/GraphBLAS-sharp.Backend/Common/PrefixSum.fs +++ b/src/GraphBLAS-sharp.Backend/Common/PrefixSum.fs @@ -3,8 +3,8 @@ namespace GraphBLAS.FSharp.Backend.Common open Brahma.FSharp open FSharp.Quotations open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions module PrefixSum = let private update (opAdd: Expr<'a -> 'a -> 'a>) (clContext: ClContext) workGroupSize = @@ -209,7 +209,7 @@ module PrefixSum = let runBackwardsIncludeInPlace plus = runInPlace plus true scanInclusive /// - /// Exclude inplace prefix sum. + /// Exclude in-place prefix sum of integer array with addition operation and start value that is equal to 0. /// /// /// @@ -222,10 +222,8 @@ module PrefixSum = /// > val sum = [| 4 |] /// /// - ///ClContext. - ///Should be a power of 2 and greater than 1. - ///Associative binary operation. - ///Zero element for binary operation. + /// ClContext. + /// Should be a power of 2 and greater than 1. let standardExcludeInPlace (clContext: ClContext) workGroupSize = let scan = @@ -236,23 +234,21 @@ module PrefixSum = scan processor inputArray 0 /// - /// Include inplace prefix sum. + /// Include in-place prefix sum of integer array with addition operation and start value that is equal to 0. /// /// /// /// let arr = [| 1; 1; 1; 1 |] /// let sum = [| 0 |] - /// runExcludeInplace clContext workGroupSize processor arr sum (+) 0 + /// runIncludeInplace clContext workGroupSize processor arr sum (+) 0 /// |> ignore /// ... /// > val arr = [| 1; 2; 3; 4 |] /// > val sum = [| 4 |] /// /// - ///ClContext. - ///Should be a power of 2 and greater than 1. - ///Associative binary operation. - ///Zero element for binary operation. + /// ClContext. + /// Should be a power of 2 and greater than 1. let standardIncludeInPlace (clContext: ClContext) workGroupSize = let scan = diff --git a/src/GraphBLAS-sharp.Backend/Common/Scatter.fs b/src/GraphBLAS-sharp.Backend/Common/Scatter.fs index 4f51cb93..82980465 100644 --- a/src/GraphBLAS-sharp.Backend/Common/Scatter.fs +++ b/src/GraphBLAS-sharp.Backend/Common/Scatter.fs @@ -3,7 +3,7 @@ namespace GraphBLAS.FSharp.Backend.Common open Brahma.FSharp open GraphBLAS.FSharp.Backend.Quotes -module internal Scatter = +module Scatter = let private general<'a> predicate (clContext: ClContext) workGroupSize = let run = @@ -46,7 +46,8 @@ module internal Scatter = processor.Post(Msg.CreateRunMsg<_, _>(kernel)) /// - /// Creates a new array from the given one where it is indicated by the array of positions at which position in the new array + /// Creates a new array from the given one where it is indicated + /// by the array of positions at which position in the new array /// should be a value from the given one. /// /// @@ -147,7 +148,7 @@ module internal Scatter = /// /// /// Maps global id to a value - let initFirsOccurrence<'a> valueMap = + let initFirstOccurrence<'a> valueMap = generalInit<'a> <| Predicates.firstOccurrence () <| valueMap diff --git a/src/GraphBLAS-sharp.Backend/Common/Sort/Bitonic.fs b/src/GraphBLAS-sharp.Backend/Common/Sort/Bitonic.fs index db833874..f51e94ce 100644 --- a/src/GraphBLAS-sharp.Backend/Common/Sort/Bitonic.fs +++ b/src/GraphBLAS-sharp.Backend/Common/Sort/Bitonic.fs @@ -3,7 +3,7 @@ namespace GraphBLAS.FSharp.Backend.Common.Sort open Brahma.FSharp open GraphBLAS.FSharp.Backend.Common -module internal Bitonic = +module Bitonic = let private localBegin (clContext: ClContext) workGroupSize = let processedSize = workGroupSize * 2 diff --git a/src/GraphBLAS-sharp.Backend/Common/Sort/Radix.fs b/src/GraphBLAS-sharp.Backend/Common/Sort/Radix.fs index 29f9e26a..03ad4ed0 100644 --- a/src/GraphBLAS-sharp.Backend/Common/Sort/Radix.fs +++ b/src/GraphBLAS-sharp.Backend/Common/Sort/Radix.fs @@ -2,18 +2,19 @@ namespace GraphBLAS.FSharp.Backend.Common.Sort open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ClCell -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions -module Radix = +module internal Radix = // the number of bits considered per iteration - let defaultBitCount = 4 + let private defaultBitCount = 4 - let keyBitCount = 32 + let private keyBitCount = 32 - let localPrefixSum = + let private localPrefixSum = <@ fun (lid: int) (workGroupSize: int) (array: int []) -> let mutable offset = 1 @@ -29,7 +30,7 @@ module Radix = barrierLocal () array.[lid] <- value @> - let count (clContext: ClContext) workGroupSize mask = + let private count (clContext: ClContext) workGroupSize mask = let bitCount = mask + 1 @@ -108,7 +109,7 @@ module Radix = globalOffsets, localOffsets - let scatter (clContext: ClContext) workGroupSize mask = + let private scatter (clContext: ClContext) workGroupSize mask = let kernel = <@ fun (ndRange: Range1D) length (keys: ClArray) (shift: ClCell) (workGroupCount: ClCell) (globalOffsets: ClArray) (localOffsets: ClArray) (result: ClArray) -> @@ -147,7 +148,7 @@ module Radix = processor.Post(Msg.CreateRunMsg<_, _>(kernel)) - let runKeysOnly (clContext: ClContext) workGroupSize bitCount = + let private runKeysOnly (clContext: ClContext) workGroupSize bitCount = let copy = ClArray.copy clContext workGroupSize let mask = (pown 2 bitCount) - 1 @@ -198,7 +199,7 @@ module Radix = let standardRunKeysOnly clContext workGroupSize = runKeysOnly clContext workGroupSize defaultBitCount - let scatterByKey (clContext: ClContext) workGroupSize mask = + let private scatterByKey (clContext: ClContext) workGroupSize mask = let kernel = <@ fun (ndRange: Range1D) length (keys: ClArray) (values: ClArray<'a>) (shift: ClCell) (workGroupCount: ClCell) (globalOffsets: ClArray) (localOffsets: ClArray) (resultKeys: ClArray) (resultValues: ClArray<'a>) -> @@ -248,7 +249,7 @@ module Radix = processor.Post(Msg.CreateRunMsg<_, _>(kernel)) - let runByKeys (clContext: ClContext) workGroupSize bitCount = + let private runByKeys (clContext: ClContext) workGroupSize bitCount = let copy = ClArray.copy clContext workGroupSize let dataCopy = ClArray.copy clContext workGroupSize diff --git a/src/GraphBLAS-sharp.Backend/Common/Sum.fs b/src/GraphBLAS-sharp.Backend/Common/Sum.fs index fe7feeb2..8f3fe936 100644 --- a/src/GraphBLAS-sharp.Backend/Common/Sum.fs +++ b/src/GraphBLAS-sharp.Backend/Common/Sum.fs @@ -1,12 +1,12 @@ namespace GraphBLAS.FSharp.Backend.Common open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Quotes open Microsoft.FSharp.Control open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp.Backend.Quotes +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions module Reduce = /// @@ -133,7 +133,7 @@ module Reduce = resultCell /// - /// Summarize array elements. + /// Summarizes array elements. /// /// ClContext. /// Work group size. @@ -237,7 +237,7 @@ module Reduce = resultCell /// - /// Reduce an array of values. + /// Reduces an array of values. /// /// ClContext. /// Work group size. @@ -259,7 +259,7 @@ module Reduce = /// module ByKey = /// - /// Reduce an array of values by key using a single work item. + /// Reduces an array of values by key using a single work item. /// /// ClContext. /// Work group size. @@ -591,7 +591,7 @@ module Reduce = module ByKey2D = /// - /// Reduce an array of values by 2D keys using a single work item. + /// Reduces an array of values by 2D keys using a single work item. /// /// ClContext. /// Work group size. diff --git a/src/GraphBLAS-sharp.Backend/GraphBLAS-sharp.Backend.fsproj b/src/GraphBLAS-sharp.Backend/GraphBLAS-sharp.Backend.fsproj index 4709660f..f78fdefc 100644 --- a/src/GraphBLAS-sharp.Backend/GraphBLAS-sharp.Backend.fsproj +++ b/src/GraphBLAS-sharp.Backend/GraphBLAS-sharp.Backend.fsproj @@ -17,7 +17,7 @@ - + @@ -27,25 +27,24 @@ - + + - - - + + - @@ -55,14 +54,19 @@ - - - - + + + + + + + + + diff --git a/src/GraphBLAS-sharp.Backend/Matrix/COO/Map.fs b/src/GraphBLAS-sharp.Backend/Matrix/COO/Map.fs index 7700b476..9b9377f0 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/COO/Map.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/COO/Map.fs @@ -5,13 +5,13 @@ open Brahma.FSharp open GraphBLAS.FSharp.Backend.Matrix open GraphBLAS.FSharp.Backend.Quotes open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects +open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Backend -open GraphBLAS.FSharp.Backend.Objects.ClMatrix -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClContextExtensions module internal Map = - let preparePositions<'a, 'b> opAdd (clContext: ClContext) workGroupSize = + let private preparePositions<'a, 'b> opAdd (clContext: ClContext) workGroupSize = let preparePositions (op: Expr<'a option -> 'b option>) = <@ fun (ndRange: Range1D) rowCount columnCount valuesLength (values: ClArray<'a>) (rows: ClArray) (columns: ClArray) (resultBitmap: ClArray) (resultValues: ClArray<'b>) (resultRows: ClArray) (resultColumns: ClArray) -> @@ -84,13 +84,13 @@ module internal Map = resultBitmap, resultValues, resultRows, resultColumns let run<'a, 'b when 'a: struct and 'b: struct and 'b: equality> - (opAdd: Expr<'a option -> 'b option>) + (op: Expr<'a option -> 'b option>) (clContext: ClContext) workGroupSize = let map = - preparePositions opAdd clContext workGroupSize + preparePositions op clContext workGroupSize let setPositions = Common.setPositions<'b> clContext workGroupSize diff --git a/src/GraphBLAS-sharp.Backend/Matrix/COO/Map2.fs b/src/GraphBLAS-sharp.Backend/Matrix/COO/Map2.fs index 3d79eb9a..a728d546 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/COO/Map2.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/COO/Map2.fs @@ -1,17 +1,17 @@ namespace GraphBLAS.FSharp.Backend.Matrix.COO open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Matrix open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClContextExtensions open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Objects.ClMatrix -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Backend.Matrix module internal Map2 = - let preparePositions<'a, 'b, 'c> opAdd (clContext: ClContext) workGroupSize = + let private preparePositions<'a, 'b, 'c> opAdd (clContext: ClContext) workGroupSize = let preparePositions (op: Expr<'a option -> 'b option -> 'c option>) = <@ fun (ndRange: Range1D) rowCount columnCount leftValuesLength rightValuesLength (leftValues: ClArray<'a>) (leftRows: ClArray) (leftColumns: ClArray) (rightValues: ClArray<'b>) (rightRows: ClArray) (rightColumn: ClArray) (resultBitmap: ClArray) (resultValues: ClArray<'c>) (resultRows: ClArray) (resultColumns: ClArray) -> @@ -135,7 +135,7 @@ module internal Map2 = Values = resultValues } module AtLeastOne = - let preparePositionsAtLeastOne<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct and 'c: equality> + let private preparePositionsAtLeastOne<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct and 'c: equality> (clContext: ClContext) (opAdd: Expr<'a option -> 'b option -> 'c option>) workGroupSize diff --git a/src/GraphBLAS-sharp.Backend/Matrix/COO/Matrix.fs b/src/GraphBLAS-sharp.Backend/Matrix/COO/Matrix.fs index fd0fc338..327a1b45 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/COO/Matrix.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/COO/Matrix.fs @@ -1,23 +1,49 @@ namespace GraphBLAS.FSharp.Backend.Matrix.COO open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend.Quotes open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClMatrix -open GraphBLAS.FSharp.Backend.Objects.ClCell -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClCellExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions module Matrix = + /// + /// Builds a new COO matrix whose elements are the results of applying the given function + /// to each of the elements of the matrix. + /// + /// + /// A function to transform values of the input matrix. + /// Operand and result types should be optional to distinguish explicit and implicit zeroes + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let map = Map.run + /// + /// Builds a new COO matrix whose values are the results of applying the given function + /// to the corresponding pairs of values from the two matrices. + /// + /// + /// A function to transform pairs of values from the input matrices. + /// Operands and result types should be optional to distinguish explicit and implicit zeroes + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let map2 = Map2.run - ///. - ///. - ///Should be a power of 2 and greater than 1. + /// + /// Builds a new COO matrix whose values are the results of applying the given function + /// to the corresponding pairs of values from the two matrices. + /// + /// + /// A function to transform pairs of values from the input matrices. + /// Operation assumption: one of the operands should always be non-zero. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let rec map2AtLeastOne<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct and 'c: equality> (clContext: ClContext) (opAdd: Expr -> 'c option>) @@ -26,6 +52,11 @@ module Matrix = Map2.AtLeastOne.run clContext (Convert.atLeastOneToOption opAdd) workGroupSize + /// + /// Converts COO matrix format to Tuple. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let getTuples (clContext: ClContext) workGroupSize = let copy = ClArray.copy clContext workGroupSize @@ -48,6 +79,11 @@ module Matrix = ColumnIndices = resultColumns Values = resultValues } + /// + /// Converts rows of given COO matrix to rows in CSR format of the same matrix. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let private compressRows (clContext: ClContext) workGroupSize = let compressRows = @@ -66,7 +102,7 @@ module Matrix = let create = ClArray.create clContext workGroupSize let scan = - PrefixSum.runBackwardsIncludeInPlace <@ min @> clContext workGroupSize + Common.PrefixSum.runBackwardsIncludeInPlace <@ min @> clContext workGroupSize fun (processor: MailboxProcessor<_>) allocationMode (rowIndices: ClArray) rowCount -> @@ -85,6 +121,12 @@ module Matrix = rowPointers + /// + /// Converts the given COO matrix to CSR format. + /// Values and columns are copied and do not depend on input COO matrix anymore. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let toCSR (clContext: ClContext) workGroupSize = let prepare = compressRows clContext workGroupSize @@ -109,6 +151,12 @@ module Matrix = Columns = cols Values = values } + /// + /// Converts the given COO matrix to CSR format. + /// Values and columns are NOT copied and still depend on the input COO matrix. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let toCSRInPlace (clContext: ClContext) workGroupSize = let prepare = compressRows clContext workGroupSize @@ -125,10 +173,16 @@ module Matrix = Columns = matrix.Columns Values = matrix.Values } + /// + /// Transposes the given matrix and returns result. + /// The given matrix should neither be used afterwards nor be disposed. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let transposeInPlace (clContext: ClContext) workGroupSize = let sort = - Sort.Bitonic.sortKeyValuesInplace clContext workGroupSize + Common.Sort.Bitonic.sortKeyValuesInplace clContext workGroupSize fun (queue: MailboxProcessor<_>) (matrix: ClMatrix.COO<'a>) -> sort queue matrix.Columns matrix.Rows matrix.Values @@ -140,6 +194,11 @@ module Matrix = Columns = matrix.Rows Values = matrix.Values } + /// + /// Transposes the given matrix and returns result as a new matrix. + /// + ///OpenCL context. + ///Should be a power of 2 and greater than 1. let transpose (clContext: ClContext) workGroupSize = let transposeInPlace = transposeInPlace clContext workGroupSize diff --git a/src/GraphBLAS-sharp.Backend/Matrix/COO/Merge.fs b/src/GraphBLAS-sharp.Backend/Matrix/COO/Merge.fs index e9cbf08d..5e847976 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/COO/Merge.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/COO/Merge.fs @@ -1,8 +1,8 @@ namespace GraphBLAS.FSharp.Backend.Matrix.COO open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects module Merge = let run<'a, 'b when 'a: struct and 'b: struct> (clContext: ClContext) workGroupSize = diff --git a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Map.fs b/src/GraphBLAS-sharp.Backend/Matrix/CSR/Map.fs index a6c2b077..8d068d09 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Map.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/CSR/Map.fs @@ -5,14 +5,14 @@ open FSharp.Quotations open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClCell -open GraphBLAS.FSharp.Backend.Objects.ClMatrix -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClCellExtensions +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions module internal Map = - let preparePositions<'a, 'b> op (clContext: ClContext) workGroupSize = + let private preparePositions<'a, 'b> op (clContext: ClContext) workGroupSize = let preparePositions (op: Expr<'a option -> 'b option>) = <@ fun (ndRange: Range1D) rowCount columnCount (values: ClArray<'a>) (rowPointers: ClArray) (columns: ClArray) (resultBitmap: ClArray) (resultValues: ClArray<'b>) (resultRows: ClArray) (resultColumns: ClArray) -> @@ -83,13 +83,13 @@ module internal Map = resultBitmap, resultValues, resultRows, resultColumns let run<'a, 'b when 'a: struct and 'b: struct and 'b: equality> - (opAdd: Expr<'a option -> 'b option>) + (op: Expr<'a option -> 'b option>) (clContext: ClContext) workGroupSize = let map = - preparePositions opAdd clContext workGroupSize + preparePositions op clContext workGroupSize let setPositions = Common.setPositions<'b> clContext workGroupSize @@ -115,7 +115,7 @@ module internal Map = Values = resultValues } module WithValue = - let preparePositions<'a, 'b, 'c when 'b: struct> (clContext: ClContext) workGroupSize op = + let private preparePositions<'a, 'b, 'c when 'b: struct> (clContext: ClContext) workGroupSize op = let preparePositions (op: Expr<'a option -> 'b option -> 'c option>) = <@ fun (ndRange: Range1D) (operand: ClCell<'a option>) rowCount columnCount (values: ClArray<'b>) (rowPointers: ClArray) (columns: ClArray) (resultBitmap: ClArray) (resultValues: ClArray<'c>) (resultRows: ClArray) (resultColumns: ClArray) -> diff --git a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Map2.fs b/src/GraphBLAS-sharp.Backend/Matrix/CSR/Map2.fs index bfd5f161..70599c16 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Map2.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/CSR/Map2.fs @@ -5,13 +5,12 @@ open Microsoft.FSharp.Quotations open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Backend.Matrix open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClMatrix -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Matrix.COO +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClContextExtensions module internal Map2 = - let preparePositions<'a, 'b, 'c> opAdd (clContext: ClContext) workGroupSize = + let private preparePositions<'a, 'b, 'c> opAdd (clContext: ClContext) workGroupSize = let preparePositions (op: Expr<'a option -> 'b option -> 'c option>) = <@ fun (ndRange: Range1D) rowCount columnCount (leftValues: ClArray<'a>) (leftRowPointers: ClArray) (leftColumns: ClArray) (rightValues: ClArray<'b>) (rightRowPointers: ClArray) (rightColumn: ClArray) (resultBitmap: ClArray) (resultValues: ClArray<'c>) (resultRows: ClArray) (resultColumns: ClArray) -> @@ -136,7 +135,7 @@ module internal Map2 = Values = resultValues } module AtLeastOne = - let preparePositions<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct and 'c: equality> + let private preparePositions<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct and 'c: equality> (opAdd: Expr<'a option -> 'b option -> 'c option>) (clContext: ClContext) workGroupSize @@ -205,8 +204,7 @@ module internal Map2 = workGroupSize = - let merge = - GraphBLAS.FSharp.Backend.Matrix.CSR.Merge.run clContext workGroupSize + let merge = Merge.run clContext workGroupSize let preparePositions = preparePositions opAdd clContext workGroupSize diff --git a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Matrix.fs b/src/GraphBLAS-sharp.Backend/Matrix/CSR/Matrix.fs index 22171912..7373a0d7 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Matrix.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/CSR/Matrix.fs @@ -1,18 +1,22 @@ namespace GraphBLAS.FSharp.Backend.Matrix.CSR open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend.Matrix open GraphBLAS.FSharp.Backend.Quotes open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClMatrix -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ClVector -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions - +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ClVector +open GraphBLAS.FSharp.Objects.ArraysExtensions module Matrix = + /// + /// Converts rows of given CSR matrix to rows in COO format of the same matrix. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let expandRowPointers (clContext: ClContext) workGroupSize = let kernel = @@ -53,6 +57,11 @@ module Matrix = rows + /// + /// Gets an element from the given matrix on the input position. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let item<'a when 'a: struct> (clContext: ClContext) workGroupSize = let kernel = @@ -92,6 +101,11 @@ module Matrix = result + /// + /// Returns matrix composed of all elements from the given row range of the input matrix. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let subRows (clContext: ClContext) workGroupSize = let kernel = @@ -174,6 +188,12 @@ module Matrix = Columns = columns Values = values } + /// + /// Converts the given CSR matrix to COO format. + /// Values and columns are copied and do not depend on input CSR matrix anymore. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let toCOO (clContext: ClContext) workGroupSize = let prepare = expandRowPointers clContext workGroupSize @@ -198,6 +218,12 @@ module Matrix = Columns = cols Values = values } + /// + /// Converts the given CSR matrix to COO format. + /// Values and columns are NOT copied and still depend on input CSR matrix. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let toCOOInPlace (clContext: ClContext) workGroupSize = let prepare = expandRowPointers clContext workGroupSize @@ -214,10 +240,40 @@ module Matrix = Columns = matrix.Columns Values = matrix.Values } + /// + /// Builds a new COO matrix whose elements are the results of applying the given function + /// to each of the elements of the matrix. + /// + /// + /// A function to transform values of the input matrix. + /// Operand and result types should be optional to distinguish explicit and implicit zeroes + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let map = CSR.Map.run + /// + /// Builds a new COO matrix whose values are the results of applying the given function + /// to the corresponding pairs of values from the two matrices. + /// + /// + /// A function to transform pairs of values from the input matrices. + /// Operands and result types should be optional to distinguish explicit and implicit zeroes + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let map2 = Map2.run + /// + /// Builds a new COO matrix whose values are the results of applying the given function + /// to the corresponding pairs of values from the two matrices. + /// + /// + /// A function to transform pairs of values from the input matrices. + /// Operation assumption: one of the operands should always be non-zero. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let map2AtLeastOne<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct and 'c: equality> (clContext: ClContext) (opAdd: Expr -> 'c option>) @@ -226,6 +282,12 @@ module Matrix = Map2.AtLeastOne.run (Convert.atLeastOneToOption opAdd) clContext workGroupSize + /// + /// Transposes the given matrix and returns result. + /// The given matrix should neither be used afterwards nor be disposed. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let transposeInPlace (clContext: ClContext) workGroupSize = let toCOOInPlace = toCOOInPlace clContext workGroupSize @@ -241,6 +303,11 @@ module Matrix = |> transposeInPlace queue |> toCSRInPlace queue allocationMode + /// + /// Transposes the given matrix and returns result as a new matrix. + /// + ///OpenCL context. + ///Should be a power of 2 and greater than 1. let transpose (clContext: ClContext) workGroupSize = let toCOO = toCOO clContext workGroupSize @@ -256,6 +323,11 @@ module Matrix = |> transposeInPlace queue |> toCSRInPlace queue allocationMode + /// + /// Represents the given matrix as Seq of optional sparse vectors, that are computed lazily. + /// + ///OpenCL context. + ///Should be a power of 2 and greater than 1. let byRowsLazy (clContext: ClContext) workGroupSize = let getChunkValues = ClArray.sub clContext workGroupSize @@ -291,6 +363,11 @@ module Matrix = else None)) + /// + /// Represents the given matrix as Seq of optional sparse vectors. + /// + ///OpenCL context. + ///Should be a power of 2 and greater than 1. let byRows (clContext: ClContext) workGroupSize = let runLazy = byRowsLazy clContext workGroupSize @@ -299,6 +376,11 @@ module Matrix = runLazy processor allocationMode matrix |> Seq.map (fun lazyValue -> lazyValue.Value) + /// + /// Converts the given CSR matrix to LIL format. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let toLIL (clContext: ClContext) workGroupSize = let byRows = byRows clContext workGroupSize @@ -314,6 +396,11 @@ module Matrix = Rows = rows NNZ = matrix.NNZ } + /// + /// Gets the number of non-zero elements in each row. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let NNZInRows (clContext: ClContext) workGroupSize = let pairwise = ClArray.pairwise clContext workGroupSize @@ -334,5 +421,3 @@ module Matrix = pointerPairs.Free processor rowsLength - - let kronecker = Kronecker.run diff --git a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Merge.fs b/src/GraphBLAS-sharp.Backend/Matrix/CSR/Merge.fs index cf98d531..8376053e 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Merge.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/CSR/Merge.fs @@ -2,9 +2,8 @@ namespace GraphBLAS.FSharp.Backend.Matrix.CSR open Brahma.FSharp open System -open GraphBLAS.FSharp.Backend.Objects - -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions module Merge = let run<'a, 'b when 'a: struct and 'b: struct> (clContext: ClContext) workGroupSize = diff --git a/src/GraphBLAS-sharp.Backend/Matrix/Common.fs b/src/GraphBLAS-sharp.Backend/Matrix/Common.fs index 5588b203..e13b889e 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/Common.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/Common.fs @@ -1,9 +1,9 @@ namespace GraphBLAS.FSharp.Backend.Matrix open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions module internal Common = ///. @@ -11,13 +11,13 @@ module internal Common = let setPositions<'a when 'a: struct> (clContext: ClContext) workGroupSize = let indicesScatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let valuesScatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let sum = - PrefixSum.standardExcludeInPlace clContext workGroupSize + Common.PrefixSum.standardExcludeInPlace clContext workGroupSize fun (processor: MailboxProcessor<_>) allocationMode (allRows: ClArray) (allColumns: ClArray) (allValues: ClArray<'a>) (positions: ClArray) -> @@ -46,13 +46,13 @@ module internal Common = let setPositionsOption<'a when 'a: struct> (clContext: ClContext) workGroupSize = let indicesScatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let valuesScatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let sum = - PrefixSum.standardExcludeInPlace clContext workGroupSize + Common.PrefixSum.standardExcludeInPlace clContext workGroupSize fun (processor: MailboxProcessor<_>) allocationMode (allRows: ClArray) (allColumns: ClArray) (allValues: ClArray<'a>) (positions: ClArray) -> diff --git a/src/GraphBLAS-sharp.Backend/Matrix/LIL/Matrix.fs b/src/GraphBLAS-sharp.Backend/Matrix/LIL/Matrix.fs index 34eff782..838fdead 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/LIL/Matrix.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/LIL/Matrix.fs @@ -1,9 +1,9 @@ namespace GraphBLAS.FSharp.Backend.Matrix.LIL open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ClMatrix +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClContextExtensions module Matrix = let toCSR (clContext: ClContext) workGroupSize = diff --git a/src/GraphBLAS-sharp.Backend/Matrix/Matrix.fs b/src/GraphBLAS-sharp.Backend/Matrix/Matrix.fs index cd754379..c56ec5ea 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/Matrix.fs +++ b/src/GraphBLAS-sharp.Backend/Matrix/Matrix.fs @@ -1,15 +1,21 @@ -namespace GraphBLAS.FSharp.Backend.Matrix +namespace GraphBLAS.FSharp open Brahma.FSharp open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClMatrix open GraphBLAS.FSharp.Backend.Vector -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClMatrix +[] module Matrix = + /// + /// Creates new matrix with the values from the given one. + /// New matrix represented in the format of the given one. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let copy (clContext: ClContext) workGroupSize = let copy = ClArray.copy clContext workGroupSize @@ -166,8 +172,8 @@ module Matrix = /// /// Creates a new matrix, represented in CSC format, that is equal to the given one. /// - ///OpenCL context. - ///Should be a power of 2 and greater than 1. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let toCSC (clContext: ClContext) workGroupSize = let COOtoCSR = COO.Matrix.toCSR clContext workGroupSize @@ -228,6 +234,11 @@ module Matrix = |> ClMatrix.CSC | _ -> failwith "Not yet implemented" + /// + /// Creates a new matrix, represented in LIL format, that is equal to the given one. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let toLIL (clContext: ClContext) workGroupSize = let copy = copy clContext workGroupSize @@ -255,74 +266,6 @@ module Matrix = |> ClMatrix.LIL | ClMatrix.LIL _ -> copy processor allocationMode matrix - let map (opAdd: Expr<'a option -> 'b option>) (clContext: ClContext) workGroupSize = - let mapCOO = - COO.Matrix.map opAdd clContext workGroupSize - - let mapCSR = - CSR.Matrix.map opAdd clContext workGroupSize - - let transposeCOO = - COO.Matrix.transposeInPlace clContext workGroupSize - - fun (processor: MailboxProcessor<_>) allocationMode matrix -> - match matrix with - | ClMatrix.COO m -> mapCOO processor allocationMode m |> ClMatrix.COO - | ClMatrix.CSR m -> mapCSR processor allocationMode m |> ClMatrix.COO - | ClMatrix.CSC m -> - (mapCSR processor allocationMode m.ToCSR) - |> transposeCOO processor - |> ClMatrix.COO - | _ -> failwith "Not yet implemented" - - let map2 (opAdd: Expr<'a option -> 'b option -> 'c option>) (clContext: ClContext) workGroupSize = - let map2COO = - COO.Matrix.map2 opAdd clContext workGroupSize - - let map2CSR = - CSR.Matrix.map2 opAdd clContext workGroupSize - - let transposeCOO = - COO.Matrix.transposeInPlace clContext workGroupSize - - fun (processor: MailboxProcessor<_>) allocationMode matrix1 matrix2 -> - match matrix1, matrix2 with - | ClMatrix.COO m1, ClMatrix.COO m2 -> - map2COO processor allocationMode m1 m2 - |> ClMatrix.COO - | ClMatrix.CSR m1, ClMatrix.CSR m2 -> - map2CSR processor allocationMode m1 m2 - |> ClMatrix.COO - | ClMatrix.CSC m1, ClMatrix.CSC m2 -> - (map2CSR processor allocationMode m1.ToCSR m2.ToCSR) - |> transposeCOO processor - |> ClMatrix.COO - | _ -> failwith "Matrix formats are not matching" - - let map2AtLeastOne (opAdd: Expr -> 'c option>) (clContext: ClContext) workGroupSize = - let COOMap2 = - COO.Matrix.map2AtLeastOne clContext opAdd workGroupSize - - let CSRMap2 = - CSR.Matrix.map2AtLeastOne clContext opAdd workGroupSize - - let COOTranspose = - COO.Matrix.transposeInPlace clContext workGroupSize - - fun (processor: MailboxProcessor<_>) allocationMode matrix1 matrix2 -> - match matrix1, matrix2 with - | ClMatrix.COO m1, ClMatrix.COO m2 -> - COOMap2 processor allocationMode m1 m2 - |> ClMatrix.COO - | ClMatrix.CSR m1, ClMatrix.CSR m2 -> - CSRMap2 processor allocationMode m1 m2 - |> ClMatrix.COO - | ClMatrix.CSC m1, ClMatrix.CSC m2 -> - (CSRMap2 processor allocationMode m1.ToCSR m2.ToCSR) - |> COOTranspose processor - |> ClMatrix.COO - | _ -> failwith "Matrix formats are not matching" - /// /// Transposes the given matrix and returns result. /// The given matrix should neither be used afterwards nor be disposed. @@ -389,55 +332,3 @@ module Matrix = Values = copyData processor allocationMode m.Values } |> ClMatrix.CSR | ClMatrix.LIL _ -> failwith "Not yet implemented" - - let kronecker (op: Expr<'a option -> 'b option -> 'c option>) (clContext: ClContext) workGroupSize = - let run = - CSR.Matrix.kronecker clContext workGroupSize op - - fun (queue: MailboxProcessor<_>) allocationFlag (matrix1: ClMatrix<'a>) (matrix2: ClMatrix<'b>) -> - match matrix1, matrix2 with - | ClMatrix.CSR m1, ClMatrix.CSR m2 -> - let result = run queue allocationFlag m1 m2 - Option.map ClMatrix.COO result - | _ -> failwith "Both matrices should be in CSR format." - - module SpGeMM = - let masked - (opAdd: Expr<'c -> 'c -> 'c option>) - (opMul: Expr<'a -> 'b -> 'c option>) - (clContext: ClContext) - workGroupSize - = - - let runCSRnCSC = - SpGeMM.Masked.run opAdd opMul clContext workGroupSize - - fun (queue: MailboxProcessor<_>) (matrix1: ClMatrix<'a>) (matrix2: ClMatrix<'b>) (mask: ClMatrix<_>) -> - match matrix1, matrix2, mask with - | ClMatrix.CSR m1, ClMatrix.CSC m2, ClMatrix.COO mask -> runCSRnCSC queue m1 m2 mask |> ClMatrix.COO - | _ -> failwith "Matrix formats are not matching" - - let expand - (opAdd: Expr<'c -> 'c -> 'c option>) - (opMul: Expr<'a -> 'b -> 'c option>) - (clContext: ClContext) - workGroupSize - = - - let run = - SpGeMM.Expand.run opAdd opMul clContext workGroupSize - - fun (processor: MailboxProcessor<_>) allocationMode (leftMatrix: ClMatrix<'a>) (rightMatrix: ClMatrix<'b>) -> - match leftMatrix, rightMatrix with - | ClMatrix.CSR leftMatrix, ClMatrix.CSR rightMatrix -> - let allocCapacity = - List.max [ sizeof<'a> - sizeof<'c> - sizeof<'b> ] - * 1 - - let resultCapacity = - (clContext.MaxMemAllocSize / allocCapacity) / 3 - - run processor allocationMode resultCapacity leftMatrix rightMatrix - | _ -> failwith "Matrix formats are not matching" diff --git a/src/GraphBLAS-sharp.Backend/Objects/ArraysExtentions.fs b/src/GraphBLAS-sharp.Backend/Objects/ArraysExtentions.fs index 29aad544..5f5da3ae 100644 --- a/src/GraphBLAS-sharp.Backend/Objects/ArraysExtentions.fs +++ b/src/GraphBLAS-sharp.Backend/Objects/ArraysExtentions.fs @@ -1,4 +1,4 @@ -namespace GraphBLAS.FSharp.Backend.Objects +namespace GraphBLAS.FSharp.Objects open Brahma.FSharp diff --git a/src/GraphBLAS-sharp.Backend/Objects/AtLeastOne.fs b/src/GraphBLAS-sharp.Backend/Objects/AtLeastOne.fs index 758b2a4e..d0ab5aa5 100644 --- a/src/GraphBLAS-sharp.Backend/Objects/AtLeastOne.fs +++ b/src/GraphBLAS-sharp.Backend/Objects/AtLeastOne.fs @@ -1,4 +1,4 @@ -namespace GraphBLAS.FSharp.Backend.Objects +namespace GraphBLAS.FSharp.Objects type AtLeastOne<'a, 'b when 'a: struct and 'b: struct> = | Both of 'a * 'b diff --git a/src/GraphBLAS-sharp.Backend/Objects/ClCell.fs b/src/GraphBLAS-sharp.Backend/Objects/ClCellExtensions.fs similarity index 89% rename from src/GraphBLAS-sharp.Backend/Objects/ClCell.fs rename to src/GraphBLAS-sharp.Backend/Objects/ClCellExtensions.fs index 6b6b188f..20334aae 100644 --- a/src/GraphBLAS-sharp.Backend/Objects/ClCell.fs +++ b/src/GraphBLAS-sharp.Backend/Objects/ClCellExtensions.fs @@ -1,8 +1,8 @@ -namespace GraphBLAS.FSharp.Backend.Objects +namespace GraphBLAS.FSharp.Objects open Brahma.FSharp -module ClCell = +module ClCellExtensions = type ClCell<'a> with member this.ToHost(processor: MailboxProcessor<_>) = processor.PostAndReply(fun ch -> Msg.CreateToHostMsg<_>(this, (Array.zeroCreate<'a> 1), ch)).[0] diff --git a/src/GraphBLAS-sharp.Backend/Objects/ClContextExtensions.fs b/src/GraphBLAS-sharp.Backend/Objects/ClContextExtensions.fs index bd5c8a3a..f525e3cd 100644 --- a/src/GraphBLAS-sharp.Backend/Objects/ClContextExtensions.fs +++ b/src/GraphBLAS-sharp.Backend/Objects/ClContextExtensions.fs @@ -1,8 +1,8 @@ -namespace GraphBLAS.FSharp.Backend.Objects +namespace GraphBLAS.FSharp.Objects open Brahma.FSharp -module ClContext = +module ClContextExtensions = type AllocationFlag = | DeviceOnly | HostInterop @@ -47,5 +47,6 @@ module ClContext = Cl .GetDeviceInfo(this.ClDevice.Device, OpenCL.Net.DeviceInfo.MaxMemAllocSize, error) - .CastTo() - * 1 + .CastTo() + |> uint64 + |> ((*) 1UL) diff --git a/src/GraphBLAS-sharp.Backend/Objects/Common.fs b/src/GraphBLAS-sharp.Backend/Objects/Common.fs index 2c1d83ab..9efb172a 100644 --- a/src/GraphBLAS-sharp.Backend/Objects/Common.fs +++ b/src/GraphBLAS-sharp.Backend/Objects/Common.fs @@ -1,4 +1,4 @@ -namespace GraphBLAS.FSharp.Backend.Objects +namespace GraphBLAS.FSharp.Objects open Brahma.FSharp diff --git a/src/GraphBLAS-sharp.Backend/Objects/Matrix.fs b/src/GraphBLAS-sharp.Backend/Objects/Matrix.fs index 650c40b3..9a0af0c6 100644 --- a/src/GraphBLAS-sharp.Backend/Objects/Matrix.fs +++ b/src/GraphBLAS-sharp.Backend/Objects/Matrix.fs @@ -1,6 +1,7 @@ -namespace GraphBLAS.FSharp.Backend.Objects +namespace GraphBLAS.FSharp.Objects open Brahma.FSharp +open GraphBLAS.FSharp.Objects type MatrixFormat = | CSR @@ -112,13 +113,31 @@ module ClMatrix = member this.NNZ = this.Values.Length +/// +/// Represents an abstraction over matrix, whose values and indices are in OpenCL device memory. +/// [] type ClMatrix<'a when 'a: struct> = + /// + /// Represents an abstraction over matrix in CSR format, whose values and indices are in OpenCL device memory. + /// | CSR of ClMatrix.CSR<'a> + /// + /// Represents an abstraction over matrix in COO format, whose values and indices are in OpenCL device memory. + /// | COO of ClMatrix.COO<'a> + /// + /// Represents an abstraction over matrix in CSC format, whose values and indices are in OpenCL device memory. + /// | CSC of ClMatrix.CSC<'a> + /// + /// Represents an abstraction over matrix in LIL format, whose values and indices are in OpenCL device memory. + /// | LIL of ClMatrix.LIL<'a> + /// + /// Gets the number of rows in matrix. + /// member this.RowCount = match this with | ClMatrix.CSR matrix -> matrix.RowCount @@ -126,6 +145,9 @@ type ClMatrix<'a when 'a: struct> = | ClMatrix.CSC matrix -> matrix.RowCount | ClMatrix.LIL matrix -> matrix.RowCount + /// + /// Gets the number of columns in matrix. + /// member this.ColumnCount = match this with | ClMatrix.CSR matrix -> matrix.ColumnCount @@ -133,6 +155,9 @@ type ClMatrix<'a when 'a: struct> = | ClMatrix.CSC matrix -> matrix.ColumnCount | ClMatrix.LIL matrix -> matrix.ColumnCount + /// + /// Release device resources allocated for the matrix. + /// member this.Dispose q = match this with | ClMatrix.CSR matrix -> (matrix :> IDeviceMemObject).Dispose q @@ -140,6 +165,9 @@ type ClMatrix<'a when 'a: struct> = | ClMatrix.CSC matrix -> (matrix :> IDeviceMemObject).Dispose q | ClMatrix.LIL matrix -> (matrix :> IDeviceMemObject).Dispose q + /// + /// Gets the number of non-zero elements in matrix. + /// member this.NNZ = match this with | ClMatrix.CSR matrix -> matrix.NNZ diff --git a/src/GraphBLAS-sharp.Backend/Objects/Vector.fs b/src/GraphBLAS-sharp.Backend/Objects/Vector.fs index f7430242..82e25d8d 100644 --- a/src/GraphBLAS-sharp.Backend/Objects/Vector.fs +++ b/src/GraphBLAS-sharp.Backend/Objects/Vector.fs @@ -1,7 +1,7 @@ -namespace GraphBLAS.FSharp.Backend.Objects +namespace GraphBLAS.FSharp.Objects open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions type VectorFormat = | Sparse @@ -24,15 +24,31 @@ module ClVector = member this.NNZ = this.Values.Length +/// +/// Represents an abstraction over vector, whose values and indices are in OpenCL device memory. +/// [] type ClVector<'a when 'a: struct> = + /// + /// Represents an abstraction over sparse vector, whose values and indices are in OpenCL device memory. + /// | Sparse of ClVector.Sparse<'a> + /// + /// Represents an abstraction over dense vector, whose values and indices are in OpenCL device memory. + /// | Dense of ClArray<'a option> + + /// + /// Gets the number of elements in vector. + /// member this.Size = match this with | Sparse vector -> vector.Size | Dense vector -> vector.Size + /// + /// Release device resources allocated for the vector. + /// member this.Dispose(q) = match this with | Sparse vector -> vector.Dispose(q) diff --git a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Kronecker.fs b/src/GraphBLAS-sharp.Backend/Operations/Kronecker.fs similarity index 96% rename from src/GraphBLAS-sharp.Backend/Matrix/CSR/Kronecker.fs rename to src/GraphBLAS-sharp.Backend/Operations/Kronecker.fs index 10151f41..9ff810bf 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/CSR/Kronecker.fs +++ b/src/GraphBLAS-sharp.Backend/Operations/Kronecker.fs @@ -1,17 +1,17 @@ -namespace GraphBLAS.FSharp.Backend.Matrix.CSR +namespace GraphBLAS.FSharp.Backend.Operations open FSharpx.Collections open Microsoft.FSharp.Quotations open FSharp.Quotations.Evaluator.QuotationEvaluationExtensions open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Common open GraphBLAS.FSharp.Backend.Matrix.COO open GraphBLAS.FSharp.Backend.Matrix.CSR -open GraphBLAS.FSharp.Backend.Objects.ClCell -open GraphBLAS.FSharp.Backend.Objects.ClMatrix -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClCellExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions module internal Kronecker = let private updateBitmap (clContext: ClContext) workGroupSize op = @@ -67,7 +67,7 @@ module internal Kronecker = let updateBitmap = updateBitmap clContext workGroupSize op let sum = - Reduce.sum <@ fun x y -> x + y @> 0 clContext workGroupSize + Common.Reduce.sum <@ fun x y -> x + y @> 0 clContext workGroupSize let item = ClArray.item clContext workGroupSize @@ -191,7 +191,7 @@ module internal Kronecker = let kernel = clContext.Compile <| setPositions let scan = - PrefixSum.standardIncludeInPlace clContext workGroupSize + Common.PrefixSum.standardIncludeInPlace clContext workGroupSize fun (processor: MailboxProcessor<_>) rowCount columnCount (rowOffset: int) (columnOffset: int) (startIndex: int) (resultMatrix: COO<'c>) (values: ClArray<'c>) (bitmap: ClArray) -> @@ -224,6 +224,9 @@ module internal Kronecker = processor.Post(Msg.CreateRunMsg<_, _> kernel) + rowOffset.Free processor + columnOffset.Free processor + (sum.ToHostAndFree processor) + startIndex let private copyToResult (clContext: ClContext) workGroupSize = @@ -271,6 +274,9 @@ module internal Kronecker = processor.Post(Msg.CreateRunMsg<_, _> kernel) + rowOffset.Free processor + columnOffset.Free processor + let private insertZero (clContext: ClContext) workGroupSize = let copy = copyToResult clContext workGroupSize @@ -430,7 +436,7 @@ module internal Kronecker = let mapAll = mapAll clContext workGroupSize op let bitonic = - Sort.Bitonic.sortKeyValuesInplace clContext workGroupSize + Common.Sort.Bitonic.sortKeyValuesInplace clContext workGroupSize fun (queue: MailboxProcessor<_>) allocationMode (matrixLeft: CSR<'a>) (matrixRight: CSR<'b>) -> diff --git a/src/GraphBLAS-sharp.Backend/Operations/Operations.fs b/src/GraphBLAS-sharp.Backend/Operations/Operations.fs new file mode 100644 index 00000000..cb67d09c --- /dev/null +++ b/src/GraphBLAS-sharp.Backend/Operations/Operations.fs @@ -0,0 +1,315 @@ +namespace GraphBLAS.FSharp + +open Brahma.FSharp +open Microsoft.FSharp.Quotations +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Backend.Matrix +open GraphBLAS.FSharp.Backend.Vector +open GraphBLAS.FSharp.Backend.Operations + +[] +module Operations = + module Vector = + /// + /// Builds a new vector whose elements are the results of applying the given function + /// to each of the elements of the vector. + /// + /// + /// A function to transform values of the input vector. + /// Operand and result types should be optional to distinguish explicit and implicit zeroes. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let map (op: Expr<'a option -> 'b option>) (clContext: ClContext) workGroupSize = + let mapSparse = + Sparse.Vector.map op clContext workGroupSize + + let mapDense = + Dense.Vector.map op clContext workGroupSize + + fun (processor: MailboxProcessor<_>) allocationMode matrix -> + match matrix with + | ClVector.Sparse v -> + mapSparse processor allocationMode v + |> ClVector.Sparse + | ClVector.Dense v -> + mapDense processor allocationMode v + |> ClVector.Dense + + /// + /// Builds a new vector whose values are the results of applying the given function + /// to the corresponding pairs of values from the two vectors. + /// + /// + /// A function to transform pairs of values from the input vectors. + /// Operands and result types should be optional to distinguish explicit and implicit zeroes. + /// + /// + /// Formats of the given vectors should match, otherwise an exception will be thrown. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let map2 (op: Expr<'a option -> 'b option -> 'c option>) (clContext: ClContext) workGroupSize = + let map2Dense = + Dense.Vector.map2 op clContext workGroupSize + + let map2Sparse = + Sparse.Vector.map2 op clContext workGroupSize + + fun (processor: MailboxProcessor<_>) allocationMode (leftVector: ClVector<'a>) (rightVector: ClVector<'b>) -> + match leftVector, rightVector with + | ClVector.Dense left, ClVector.Dense right -> + ClVector.Dense + <| map2Dense processor allocationMode left right + | ClVector.Sparse left, ClVector.Sparse right -> + ClVector.Sparse + <| map2Sparse processor allocationMode left right + | _ -> failwith "Vector formats are not matching." + + /// + /// Builds a new vector whose values are the results of applying the given function + /// to the corresponding pairs of values from the two vectors. + /// + /// + /// A function to transform pairs of values from the input vectors. + /// Operation assumption: one of the operands should always be non-zero. + /// + /// + /// Formats of the given vectors should match, otherwise an exception will be thrown. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let map2AtLeastOne (op: Expr -> 'c option>) (clContext: ClContext) workGroupSize = + let map2Sparse = + Sparse.Vector.map2AtLeastOne op clContext workGroupSize + + let map2Dense = + Dense.Vector.map2AtLeastOne op clContext workGroupSize + + fun (processor: MailboxProcessor<_>) allocationMode (leftVector: ClVector<'a>) (rightVector: ClVector<'b>) -> + match leftVector, rightVector with + | ClVector.Sparse left, ClVector.Sparse right -> + ClVector.Sparse + <| map2Sparse processor allocationMode left right + | ClVector.Dense left, ClVector.Dense right -> + ClVector.Dense + <| map2Dense processor allocationMode left right + | _ -> failwith "Vector formats are not matching." + + module Matrix = + /// + /// Builds a new matrix whose elements are the results of applying the given function + /// to each of the elements of the matrix. + /// + /// + /// A function to transform values of the input matrix. + /// Operand and result types should be optional to distinguish explicit and implicit zeroes + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let map (op: Expr<'a option -> 'b option>) (clContext: ClContext) workGroupSize = + let mapCOO = + COO.Matrix.map op clContext workGroupSize + + let mapCSR = + CSR.Matrix.map op clContext workGroupSize + + let transposeCOO = + COO.Matrix.transposeInPlace clContext workGroupSize + + fun (processor: MailboxProcessor<_>) allocationMode matrix -> + match matrix with + | ClMatrix.COO m -> mapCOO processor allocationMode m |> ClMatrix.COO + | ClMatrix.CSR m -> mapCSR processor allocationMode m |> ClMatrix.COO + | ClMatrix.CSC m -> + (mapCSR processor allocationMode m.ToCSR) + |> transposeCOO processor + |> ClMatrix.COO + | _ -> failwith "Not yet implemented" + + /// + /// Builds a new matrix whose values are the results of applying the given function + /// to the corresponding pairs of values from the two matrices. + /// + /// + /// A function to transform pairs of values from the input matrices. + /// Operands and result types should be optional to distinguish explicit and implicit zeroes + /// + /// + /// Formats of the given matrices should match, otherwise an exception will be thrown. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let map2 (op: Expr<'a option -> 'b option -> 'c option>) (clContext: ClContext) workGroupSize = + let map2COO = + COO.Matrix.map2 op clContext workGroupSize + + let map2CSR = + CSR.Matrix.map2 op clContext workGroupSize + + let transposeCOO = + COO.Matrix.transposeInPlace clContext workGroupSize + + fun (processor: MailboxProcessor<_>) allocationMode matrix1 matrix2 -> + match matrix1, matrix2 with + | ClMatrix.COO m1, ClMatrix.COO m2 -> + map2COO processor allocationMode m1 m2 + |> ClMatrix.COO + | ClMatrix.CSR m1, ClMatrix.CSR m2 -> + map2CSR processor allocationMode m1 m2 + |> ClMatrix.COO + | ClMatrix.CSC m1, ClMatrix.CSC m2 -> + (map2CSR processor allocationMode m1.ToCSR m2.ToCSR) + |> transposeCOO processor + |> ClMatrix.COO + | _ -> failwith "Matrix formats are not matching" + + /// + /// Builds a new matrix whose values are the results of applying the given function + /// to the corresponding pairs of values from the two matrices. + /// + /// + /// A function to transform pairs of values from the input matrices. + /// Operation assumption: one of the operands should always be non-zero. + /// + /// + /// Formats of the given matrices should match, otherwise an exception will be thrown. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let map2AtLeastOne (op: Expr -> 'c option>) (clContext: ClContext) workGroupSize = + let COOMap2 = + COO.Matrix.map2AtLeastOne clContext op workGroupSize + + let CSRMap2 = + CSR.Matrix.map2AtLeastOne clContext op workGroupSize + + let COOTranspose = + COO.Matrix.transposeInPlace clContext workGroupSize + + fun (processor: MailboxProcessor<_>) allocationMode matrix1 matrix2 -> + match matrix1, matrix2 with + | ClMatrix.COO m1, ClMatrix.COO m2 -> + COOMap2 processor allocationMode m1 m2 + |> ClMatrix.COO + | ClMatrix.CSR m1, ClMatrix.CSR m2 -> + CSRMap2 processor allocationMode m1 m2 + |> ClMatrix.COO + | ClMatrix.CSC m1, ClMatrix.CSC m2 -> + (CSRMap2 processor allocationMode m1.ToCSR m2.ToCSR) + |> COOTranspose processor + |> ClMatrix.COO + | _ -> failwith "Matrix formats are not matching" + + /// + /// Matrix-vector multiplication. + /// Vector, that is going to be the result of the operation, should be passed as an argument. + /// + /// Type of binary function to reduce entries. + /// Type of binary function to combine entries. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let SpMVInplace + (add: Expr<'c option -> 'c option -> 'c option>) + (mul: Expr<'a option -> 'b option -> 'c option>) + (clContext: ClContext) + workGroupSize + = + + let runTo = + SpMV.runTo add mul clContext workGroupSize + + fun (queue: MailboxProcessor<_>) (matrix: ClMatrix<'a>) (vector: ClVector<'b>) (result: ClVector<'c>) -> + match matrix, vector, result with + | ClMatrix.CSR m, ClVector.Dense v, ClVector.Dense r -> runTo queue m v r + | _ -> failwith "Not implemented yet" + + /// + /// Matrix-vector multiplication. + /// + let SpMV = SpMV.run + + /// + /// Kronecker product for matrices. + /// + /// + /// Element-wise operation. + /// Operands and result types should be optional to distinguish explicit and implicit zeroes + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let kronecker (op: Expr<'a option -> 'b option -> 'c option>) (clContext: ClContext) workGroupSize = + let run = Kronecker.run clContext workGroupSize op + + fun (queue: MailboxProcessor<_>) allocationFlag (matrix1: ClMatrix<'a>) (matrix2: ClMatrix<'b>) -> + match matrix1, matrix2 with + | ClMatrix.CSR m1, ClMatrix.CSR m2 -> + let result = run queue allocationFlag m1 m2 + Option.map ClMatrix.COO result + | _ -> failwith "Both matrices should be in CSR format." + + /// + /// Sparse general matrix-matrix multiplication. + /// + module SpGeMM = + /// + /// Masked matrix-matrix multiplication. + /// + /// Type of binary function to reduce entries. + /// Type of binary function to combine entries. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let masked + (opAdd: Expr<'c -> 'c -> 'c option>) + (opMul: Expr<'a -> 'b -> 'c option>) + (clContext: ClContext) + workGroupSize + = + + let runCSRnCSC = + SpGeMM.Masked.run opAdd opMul clContext workGroupSize + + fun (queue: MailboxProcessor<_>) (matrix1: ClMatrix<'a>) (matrix2: ClMatrix<'b>) (mask: ClMatrix<_>) -> + match matrix1, matrix2, mask with + | ClMatrix.CSR m1, ClMatrix.CSC m2, ClMatrix.COO mask -> runCSRnCSC queue m1 m2 mask |> ClMatrix.COO + | _ -> failwith "Matrix formats are not matching" + + /// + /// Generalized matrix-matrix multiplication. + /// + /// Type of binary function to reduce entries. + /// Type of binary function to combine entries. + /// OpenCL context. + /// Should be a power of 2 and greater than 1. + let expand + (opAdd: Expr<'c -> 'c -> 'c option>) + (opMul: Expr<'a -> 'b -> 'c option>) + (clContext: ClContext) + workGroupSize + = + + let run = + SpGeMM.Expand.run opAdd opMul clContext workGroupSize + + fun (processor: MailboxProcessor<_>) allocationMode (leftMatrix: ClMatrix<'a>) (rightMatrix: ClMatrix<'b>) -> + match leftMatrix, rightMatrix with + | ClMatrix.CSR leftMatrix, ClMatrix.CSR rightMatrix -> + let allocCapacity = + List.max [ sizeof<'a> + sizeof<'c> + sizeof<'b> ] + |> uint64 + |> (*) 1UL + + let resultCapacity = + (clContext.MaxMemAllocSize / allocCapacity) / 3UL + + let resultCapacity = + (min + <| uint64 System.Int32.MaxValue + <| resultCapacity) + |> int + + run processor allocationMode resultCapacity leftMatrix rightMatrix + | _ -> failwith "Matrix formats are not matching" diff --git a/src/GraphBLAS-sharp.Backend/Matrix/SpGeMM/Expand.fs b/src/GraphBLAS-sharp.Backend/Operations/SpGeMM/Expand.fs similarity index 90% rename from src/GraphBLAS-sharp.Backend/Matrix/SpGeMM/Expand.fs rename to src/GraphBLAS-sharp.Backend/Operations/SpGeMM/Expand.fs index 92eba752..09f04bb7 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/SpGeMM/Expand.fs +++ b/src/GraphBLAS-sharp.Backend/Operations/SpGeMM/Expand.fs @@ -1,24 +1,25 @@ -namespace GraphBLAS.FSharp.Backend.Matrix.SpGeMM +namespace GraphBLAS.FSharp.Backend.Operations.SpGeMM open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Common.Sort +open FSharp.Quotations +open GraphBLAS.FSharp +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClCellExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions open GraphBLAS.FSharp.Backend.Matrix open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClCell -open FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects.ClMatrix -module Expand = +module internal Expand = let getSegmentPointers (clContext: ClContext) workGroupSize = - let gather = Gather.run clContext workGroupSize + let gather = + Common.Gather.run clContext workGroupSize let prefixSum = - PrefixSum.standardExcludeInPlace clContext workGroupSize + Common.PrefixSum.standardExcludeInPlace clContext workGroupSize fun (processor: MailboxProcessor<_>) (leftMatrixColumns: ClArray) (rightMatrixRowsLengths: ClArray) -> @@ -40,13 +41,13 @@ module Expand = ClArray.map2<'a, 'b, int> (Map.choose2Bitmap predicate) clContext workGroupSize let prefixSum = - PrefixSum.standardExcludeInPlace clContext workGroupSize + Common.PrefixSum.standardExcludeInPlace clContext workGroupSize let assignValues = ClArray.assignOption2 predicate clContext workGroupSize let scatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize fun (processor: MailboxProcessor<_>) (firstValues: ClArray<'a>) (secondValues: ClArray<'b>) (columns: ClArray) (rows: ClArray) -> @@ -84,30 +85,33 @@ module Expand = let expand (clContext: ClContext) workGroupSize = let idScatter = - Scatter.initLastOccurrence Map.id clContext workGroupSize + Common.Scatter.initLastOccurrence Map.id clContext workGroupSize let scatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let zeroCreate = ClArray.zeroCreate clContext workGroupSize let maxPrefixSum = - PrefixSum.runIncludeInPlace <@ max @> clContext workGroupSize + Common.PrefixSum.runIncludeInPlace <@ max @> clContext workGroupSize let create = ClArray.create clContext workGroupSize - let gather = Gather.run clContext workGroupSize + let gather = + Common.Gather.run clContext workGroupSize let segmentPrefixSum = - PrefixSum.ByKey.sequentialInclude <@ (+) @> 0 clContext workGroupSize + Common.PrefixSum.ByKey.sequentialInclude <@ (+) @> 0 clContext workGroupSize let removeDuplicates = ClArray.removeDuplications clContext workGroupSize - let leftMatrixGather = Gather.run clContext workGroupSize + let leftMatrixGather = + Common.Gather.run clContext workGroupSize - let rightMatrixGather = Gather.run clContext workGroupSize + let rightMatrixGather = + Common.Gather.run clContext workGroupSize fun (processor: MailboxProcessor<_>) (lengths: int) (segmentsPointers: ClArray) (leftMatrix: ClMatrix.COO<'a>) (rightMatrix: ClMatrix.CSR<'b>) -> // Compute left matrix positions @@ -171,13 +175,13 @@ module Expand = let sortByColumnsAndRows (clContext: ClContext) workGroupSize = let sortByKeyIndices = - Radix.runByKeysStandard clContext workGroupSize + Common.Sort.Radix.runByKeysStandard clContext workGroupSize let sortByKeyValues = - Radix.runByKeysStandard clContext workGroupSize + Common.Sort.Radix.runByKeysStandard clContext workGroupSize let sortKeys = - Radix.standardRunKeysOnly clContext workGroupSize + Common.Sort.Radix.standardRunKeysOnly clContext workGroupSize fun (processor: MailboxProcessor<_>) (values: ClArray<'a>) (columns: ClArray) (rows: ClArray) -> // sort by columns @@ -207,16 +211,16 @@ module Expand = let reduce opAdd (clContext: ClContext) workGroupSize = let reduce = - Reduce.ByKey2D.Option.segmentSequential opAdd clContext workGroupSize + Common.Reduce.ByKey2D.Option.segmentSequential opAdd clContext workGroupSize let getUniqueBitmap = ClArray.Bitmap.lastOccurrence2 clContext workGroupSize let prefixSum = - PrefixSum.standardExcludeInPlace clContext workGroupSize + Common.PrefixSum.standardExcludeInPlace clContext workGroupSize let idScatter = - Scatter.initFirsOccurrence Map.id clContext workGroupSize + Common.Scatter.initFirstOccurrence Map.id clContext workGroupSize fun (processor: MailboxProcessor<_>) allocationMode (values: ClArray<'a>) (columns: ClArray) (rows: ClArray) -> @@ -343,7 +347,8 @@ module Expand = let runManySteps opAdd opMul (clContext: ClContext) workGroupSize = - let gather = Gather.run clContext workGroupSize + let gather = + Common.Gather.run clContext workGroupSize let upperBound = ClArray.upperBound clContext workGroupSize @@ -442,7 +447,9 @@ module Expand = let generalLength, segmentLengths = getSegmentPointers processor leftMatrix.Columns rightMatrixRowsNNZ - if generalLength < maxAllocSize then + if generalLength = 0 then + None + elif generalLength < maxAllocSize then segmentLengths.Free processor runOneStep processor allocationMode leftMatrix rightMatrixRowsNNZ rightMatrix diff --git a/src/GraphBLAS-sharp.Backend/Matrix/SpGeMM/Masked.fs b/src/GraphBLAS-sharp.Backend/Operations/SpGeMM/Masked.fs similarity index 93% rename from src/GraphBLAS-sharp.Backend/Matrix/SpGeMM/Masked.fs rename to src/GraphBLAS-sharp.Backend/Operations/SpGeMM/Masked.fs index 700018c3..8c4e600a 100644 --- a/src/GraphBLAS-sharp.Backend/Matrix/SpGeMM/Masked.fs +++ b/src/GraphBLAS-sharp.Backend/Operations/SpGeMM/Masked.fs @@ -1,12 +1,12 @@ -namespace GraphBLAS.FSharp.Backend.Matrix.SpGeMM +namespace GraphBLAS.FSharp.Backend.Operations.SpGeMM -open GraphBLAS.FSharp.Backend.Common open Brahma.FSharp open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClMatrix -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClMatrix +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions module internal Masked = let private calculate @@ -152,13 +152,13 @@ module internal Masked = calculate opAdd opMul context workGroupSize let scatter = - Scatter.lastOccurrence context workGroupSize + Common.Scatter.lastOccurrence context workGroupSize let scatterData = - Scatter.lastOccurrence context workGroupSize + Common.Scatter.lastOccurrence context workGroupSize let scanInPlace = - PrefixSum.standardExcludeInPlace context workGroupSize + Common.PrefixSum.standardExcludeInPlace context workGroupSize fun (queue: MailboxProcessor<_>) (matrixLeft: ClMatrix.CSR<'a>) (matrixRight: ClMatrix.CSC<'b>) (mask: ClMatrix.COO<_>) -> diff --git a/src/GraphBLAS-sharp.Backend/Vector/SpMV.fs b/src/GraphBLAS-sharp.Backend/Operations/SpMV.fs similarity index 97% rename from src/GraphBLAS-sharp.Backend/Vector/SpMV.fs rename to src/GraphBLAS-sharp.Backend/Operations/SpMV.fs index 46895b0c..34b5f821 100644 --- a/src/GraphBLAS-sharp.Backend/Vector/SpMV.fs +++ b/src/GraphBLAS-sharp.Backend/Operations/SpMV.fs @@ -1,12 +1,12 @@ -namespace GraphBLAS.FSharp.Backend.Vector +namespace GraphBLAS.FSharp.Backend.Operations open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions -module SpMV = +module internal SpMV = let runTo (add: Expr<'c option -> 'c option -> 'c option>) (mul: Expr<'a option -> 'b option -> 'c option>) diff --git a/src/GraphBLAS-sharp.Backend/Quotes/Arithmetic.fs b/src/GraphBLAS-sharp.Backend/Quotes/Arithmetic.fs index f7d51a89..f79a2193 100644 --- a/src/GraphBLAS-sharp.Backend/Quotes/Arithmetic.fs +++ b/src/GraphBLAS-sharp.Backend/Quotes/Arithmetic.fs @@ -1,9 +1,9 @@ namespace GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Objects +open GraphBLAS.FSharp.Objects module ArithmeticOperations = - let inline mkUnaryOp zero unaryOp = + let inline private mkUnaryOp zero unaryOp = <@ fun x -> let mutable res = zero @@ -13,7 +13,7 @@ module ArithmeticOperations = if res = zero then None else Some res @> - let inline mkNumericSum zero = + let inline private mkNumericSum zero = <@ fun (x: 't option) (y: 't option) -> let mutable res = zero @@ -25,7 +25,7 @@ module ArithmeticOperations = if res = zero then None else Some res @> - let inline mkNumericSumAtLeastOne zero = + let inline private mkNumericSumAtLeastOne zero = <@ fun (values: AtLeastOne<'t, 't>) -> let mutable res = zero @@ -36,7 +36,7 @@ module ArithmeticOperations = if res = zero then None else Some res @> - let inline mkNumericMul zero = + let inline private mkNumericMul zero = <@ fun (x: 't option) (y: 't option) -> let mutable res = zero @@ -46,7 +46,7 @@ module ArithmeticOperations = if res = zero then None else Some res @> - let inline mkNumericMulAtLeastOne zero = + let inline private mkNumericMulAtLeastOne zero = <@ fun (values: AtLeastOne<'t, 't>) -> let mutable res = zero @@ -197,7 +197,7 @@ module ArithmeticOperations = else Some result - let inline createPair zero op opQ = binOpQ zero opQ, binOp zero op + let inline private createPair zero op opQ = binOpQ zero opQ, binOp zero op // addition let intAdd = createPair 0 (+) <@ (+) @> diff --git a/src/GraphBLAS-sharp.Backend/Quotes/Convert.fs b/src/GraphBLAS-sharp.Backend/Quotes/Convert.fs index d779ba5a..3491dfa8 100644 --- a/src/GraphBLAS-sharp.Backend/Quotes/Convert.fs +++ b/src/GraphBLAS-sharp.Backend/Quotes/Convert.fs @@ -1,7 +1,7 @@ namespace GraphBLAS.FSharp.Backend.Quotes open FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects +open GraphBLAS.FSharp.Objects module Convert = let atLeastOneToOption op = diff --git a/src/GraphBLAS-sharp.Backend/Quotes/PreparePositions.fs b/src/GraphBLAS-sharp.Backend/Quotes/PreparePositions.fs index d219e7ec..4252cd18 100644 --- a/src/GraphBLAS-sharp.Backend/Quotes/PreparePositions.fs +++ b/src/GraphBLAS-sharp.Backend/Quotes/PreparePositions.fs @@ -2,7 +2,7 @@ namespace GraphBLAS.FSharp.Backend.Quotes open Brahma.FSharp -module PreparePositions = +module internal PreparePositions = let both<'c> = <@ fun index (result: 'c option) (rawPositionsBuffer: ClArray) (allValuesBuffer: ClArray<'c>) -> rawPositionsBuffer.[index] <- 0 diff --git a/src/GraphBLAS-sharp.Backend/Quotes/Search.fs b/src/GraphBLAS-sharp.Backend/Quotes/Search.fs index d2ea346a..c56bf6f7 100644 --- a/src/GraphBLAS-sharp.Backend/Quotes/Search.fs +++ b/src/GraphBLAS-sharp.Backend/Quotes/Search.fs @@ -5,8 +5,10 @@ open Brahma.FSharp module Search = module Bin = /// - /// Searches a section of the array of indices, bounded by the given left and right edges, for an index, using a binary search algorithm. - /// In case searched section contains source index, the value at the same position in the array of values is returned. + /// Searches a section of the array of indices, bounded by the given left and right edges, + /// for an index, using a binary search algorithm. + /// In case searched section contains source index, + /// the value at the same position in the array of values is returned. /// /// /// Searched section of index array should be sorted in ascending order. @@ -42,10 +44,10 @@ module Search = /// In case there is a value at the given key position, it is returned. /// let byKey<'a> = - <@ fun lenght sourceIndex (keys: ClArray) (values: ClArray<'a>) -> + <@ fun length sourceIndex (keys: ClArray) (values: ClArray<'a>) -> let mutable leftEdge = 0 - let mutable rightEdge = lenght - 1 + let mutable rightEdge = length - 1 let mutable result = None @@ -69,10 +71,10 @@ module Search = /// In case there is a value at the given keys position, it is returned. /// let byKey2D<'a> = - <@ fun lenght sourceIndex (rowIndices: ClArray) (columnIndices: ClArray) (values: ClArray<'a>) -> + <@ fun length sourceIndex (rowIndices: ClArray) (columnIndices: ClArray) (values: ClArray<'a>) -> let mutable leftEdge = 0 - let mutable rightEdge = lenght - 1 + let mutable rightEdge = length - 1 let mutable result = None @@ -98,10 +100,10 @@ module Search = /// Find lower position of item in array. /// let lowerPosition<'a when 'a: equality and 'a: comparison> = - <@ fun lenght sourceItem (keys: 'a []) -> + <@ fun length sourceItem (keys: 'a []) -> let mutable leftEdge = 0 - let mutable rightEdge = lenght - 1 + let mutable rightEdge = length - 1 let mutable resultPosition = None @@ -138,15 +140,15 @@ module Search = /// /// let lowerBound<'a when 'a: comparison> = - <@ fun lenght sourceItem (keys: ClArray<'a>) -> + <@ fun length sourceItem (keys: ClArray<'a>) -> let mutable leftEdge = 0 - let mutable rightEdge = lenght - 1 + let mutable rightEdge = length - 1 let mutable resultPosition = 0 - if sourceItem >= keys.[lenght - 1] then - lenght - 1 + if sourceItem >= keys.[length - 1] then + length - 1 else while leftEdge <= rightEdge do let currentPosition = (leftEdge + rightEdge) / 2 @@ -164,15 +166,15 @@ module Search = let lowerBoundAndValue<'a when 'a: comparison> = let defaultValue = Unchecked.defaultof<'a> - <@ fun lenght sourceItem (keys: ClArray<'a>) -> + <@ fun length sourceItem (keys: ClArray<'a>) -> let mutable leftEdge = 0 - let mutable rightEdge = lenght - 1 + let mutable rightEdge = length - 1 let mutable resultPosition = 0, defaultValue - if sourceItem >= keys.[lenght - 1] then - (lenght - 1), keys.[lenght - 1] + if sourceItem >= keys.[length - 1] then + (length - 1), keys.[length - 1] else while leftEdge <= rightEdge do let currentPosition = (leftEdge + rightEdge) / 2 diff --git a/src/GraphBLAS-sharp.Backend/Vector/Dense/Vector.fs b/src/GraphBLAS-sharp.Backend/Vector/Dense/Vector.fs index 53f8de3e..cbc515de 100644 --- a/src/GraphBLAS-sharp.Backend/Vector/Dense/Vector.fs +++ b/src/GraphBLAS-sharp.Backend/Vector/Dense/Vector.fs @@ -1,14 +1,26 @@ namespace GraphBLAS.FSharp.Backend.Vector.Dense open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Quotes open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Objects.ClVector -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Backend.Quotes +open GraphBLAS.FSharp.Objects.ClVector +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions module Vector = + let map<'a, 'b when 'a: struct and 'b: struct> + (op: Expr<'a option -> 'b option>) + (clContext: ClContext) + workGroupSize + = + + let map = ClArray.map op clContext workGroupSize + + fun (processor: MailboxProcessor<_>) allocationMode (leftVector: ClArray<'a option>) -> + + map processor allocationMode leftVector + let map2InPlace<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct> (opAdd: Expr<'a option -> 'b option -> 'c option>) (clContext: ClContext) @@ -22,7 +34,6 @@ module Vector = map2InPlace processor leftVector rightVector resultVector - let map2<'a, 'b, 'c when 'a: struct and 'b: struct and 'c: struct> (opAdd: Expr<'a option -> 'b option -> 'c option>) (clContext: ClContext) @@ -36,7 +47,6 @@ module Vector = map2 processor allocationMode leftVector rightVector - let map2AtLeastOne op clContext workGroupSize = map2 (Convert.atLeastOneToOption op) clContext workGroupSize @@ -90,16 +100,16 @@ module Vector = let toSparse<'a when 'a: struct> (clContext: ClContext) workGroupSize = let scatterValues = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let scatterIndices = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let getBitmap = ClArray.map (Map.option 1 0) clContext workGroupSize let prefixSum = - PrefixSum.standardExcludeInPlace clContext workGroupSize + Common.PrefixSum.standardExcludeInPlace clContext workGroupSize let allIndices = ClArray.init Map.id clContext workGroupSize @@ -149,7 +159,7 @@ module Vector = ClArray.choose Map.id clContext workGroupSize let reduce = - Reduce.reduce opAdd clContext workGroupSize + Common.Reduce.reduce opAdd clContext workGroupSize fun (processor: MailboxProcessor<_>) (vector: ClArray<'a option>) -> choose processor DeviceOnly vector diff --git a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Common.fs b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Common.fs index cb6a8971..07e6e5e7 100644 --- a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Common.fs +++ b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Common.fs @@ -1,23 +1,23 @@ namespace GraphBLAS.FSharp.Backend.Vector.Sparse open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Objects.ClVector open Microsoft.FSharp.Control -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects.ClVector +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions module internal Common = let setPositions<'a when 'a: struct> (clContext: ClContext) workGroupSize = let sum = - PrefixSum.standardExcludeInPlace clContext workGroupSize + Common.PrefixSum.standardExcludeInPlace clContext workGroupSize let valuesScatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let indicesScatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize fun (processor: MailboxProcessor<_>) allocationMode (allValues: ClArray<'a>) (allIndices: ClArray) (positions: ClArray) -> @@ -39,13 +39,13 @@ module internal Common = let setPositionsOption<'a when 'a: struct> (clContext: ClContext) workGroupSize = let sum = - PrefixSum.standardExcludeInPlace clContext workGroupSize + Common.PrefixSum.standardExcludeInPlace clContext workGroupSize let valuesScatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let indicesScatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize fun (processor: MailboxProcessor<_>) allocationMode (allValues: ClArray<'a>) (allIndices: ClArray) (positions: ClArray) -> diff --git a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Map.fs b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Map.fs index 3d804101..329e5484 100644 --- a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Map.fs +++ b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Map.fs @@ -3,18 +3,104 @@ open FSharp.Quotations.Evaluator.QuotationEvaluationExtensions open Microsoft.FSharp.Quotations open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Backend.Vector.Sparse -open GraphBLAS.FSharp.Backend.Objects.ClVector -open GraphBLAS.FSharp.Backend.Common.ClArray -open GraphBLAS.FSharp.Backend.Objects.ClCell -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClVector +open GraphBLAS.FSharp.Objects.ClCellExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions + +module internal Map = + let preparePositions<'a, 'b> opAdd (clContext: ClContext) workGroupSize = + + let preparePositions (op: Expr<'a option -> 'b option>) = + <@ fun (ndRange: Range1D) size valuesLength (values: ClArray<'a>) (indices: ClArray) (resultBitmap: ClArray) (resultValues: ClArray<'b>) (resultIndices: ClArray) -> + + let gid = ndRange.GlobalID0 + + if gid < size then + + let value = + (%Search.Bin.byKey) valuesLength gid indices values + + match (%op) value with + | Some resultValue -> + resultValues.[gid] <- resultValue + resultIndices.[gid] <- gid + + resultBitmap.[gid] <- 1 + | None -> resultBitmap.[gid] <- 0 @> + + let kernel = + clContext.Compile <| preparePositions opAdd + + fun (processor: MailboxProcessor<_>) (size: int) (values: ClArray<'a>) (indices: ClArray) -> + + let resultBitmap = + clContext.CreateClArrayWithSpecificAllocationMode(DeviceOnly, size) + + let resultIndices = + clContext.CreateClArrayWithSpecificAllocationMode(DeviceOnly, size) + + let resultValues = + clContext.CreateClArrayWithSpecificAllocationMode<'b>(DeviceOnly, size) + + let ndRange = Range1D.CreateValid(size, workGroupSize) + + let kernel = kernel.GetKernel() + + processor.Post( + Msg.MsgSetArguments + (fun () -> + kernel.KernelFunc + ndRange + size + values.Length + values + indices + resultBitmap + resultValues + resultIndices) + ) + + processor.Post(Msg.CreateRunMsg<_, _> kernel) + + resultBitmap, resultValues, resultIndices + + let run<'a, 'b when 'a: struct and 'b: struct and 'b: equality> + (op: Expr<'a option -> 'b option>) + (clContext: ClContext) + workGroupSize + = + + let map = + preparePositions op clContext workGroupSize + + let setPositions = + Common.setPositions<'b> clContext workGroupSize + + fun (queue: MailboxProcessor<_>) allocationMode (vector: ClVector.Sparse<'a>) -> + + let bitmap, values, indices = + map queue vector.Size vector.Values vector.Indices + + let resultValues, resultIndices = + setPositions queue allocationMode values indices bitmap + + queue.Post(Msg.CreateFreeMsg<_>(bitmap)) + queue.Post(Msg.CreateFreeMsg<_>(values)) + queue.Post(Msg.CreateFreeMsg<_>(indices)) + + { Context = clContext + Indices = indices + Values = resultValues + Size = vector.Size } -module Map = module WithValueOption = - let preparePositions<'a, 'b, 'c> opAdd (clContext: ClContext) workGroupSize = + let private preparePositions<'a, 'b, 'c> opAdd (clContext: ClContext) workGroupSize = let preparePositions (op: Expr<'a option -> 'b option -> 'c option>) = <@ fun (ndRange: Range1D) (operand: ClCell<'a option>) size valuesLength (indices: ClArray) (values: ClArray<'b>) (resultIndices: ClArray) (resultValues: ClArray<'c>) (resultBitmap: ClArray) -> @@ -85,9 +171,10 @@ module Map = let setPositions = Common.setPositionsOption<'c> clContext workGroupSize - let create = create clContext workGroupSize + let create = ClArray.create clContext workGroupSize - let init = init <@ id @> clContext workGroupSize + let init = + ClArray.init <@ id @> clContext workGroupSize fun (queue: MailboxProcessor<_>) allocationMode (value: 'a option) size -> function diff --git a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Map2.fs b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Map2.fs index 1b8ef660..feb6e484 100644 --- a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Map2.fs +++ b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Map2.fs @@ -3,9 +3,9 @@ namespace GraphBLAS.FSharp.Backend.Vector.Sparse open Brahma.FSharp open FSharp.Quotations open Microsoft.FSharp.Control -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClVector -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClVector +open GraphBLAS.FSharp.Objects.ClContextExtensions open GraphBLAS.FSharp.Backend.Quotes module internal Map2 = diff --git a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Merge.fs b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Merge.fs index 459ab6d5..4c310edf 100644 --- a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Merge.fs +++ b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Merge.fs @@ -1,8 +1,8 @@ namespace GraphBLAS.FSharp.Backend.Vector.Sparse open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions module internal Merge = let run<'a, 'b when 'a: struct and 'b: struct> (clContext: ClContext) workGroupSize = diff --git a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Vector.fs b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Vector.fs index 5b3594ae..fed8bad6 100644 --- a/src/GraphBLAS-sharp.Backend/Vector/Sparse/Vector.fs +++ b/src/GraphBLAS-sharp.Backend/Vector/Sparse/Vector.fs @@ -3,11 +3,10 @@ namespace GraphBLAS.FSharp.Backend.Vector.Sparse open Brahma.FSharp open Microsoft.FSharp.Control open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClVector open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClVector -open GraphBLAS.FSharp.Backend.Vector.Sparse module Vector = let copy (clContext: ClContext) workGroupSize = @@ -21,6 +20,8 @@ module Vector = Values = copyData processor allocationMode vector.Values Size = vector.Size } + let map = Map.run + let mapWithValue = Map.WithValueOption.run let map2 = Map2.run @@ -68,6 +69,6 @@ module Vector = let reduce<'a when 'a: struct> (opAdd: Expr<'a -> 'a -> 'a>) (clContext: ClContext) workGroupSize = let reduce = - Reduce.reduce opAdd clContext workGroupSize + Common.Reduce.reduce opAdd clContext workGroupSize fun (processor: MailboxProcessor<_>) (vector: ClVector.Sparse<'a>) -> reduce processor vector.Values diff --git a/src/GraphBLAS-sharp.Backend/Vector/Vector.fs b/src/GraphBLAS-sharp.Backend/Vector/Vector.fs index 9c94992b..a9192eff 100644 --- a/src/GraphBLAS-sharp.Backend/Vector/Vector.fs +++ b/src/GraphBLAS-sharp.Backend/Vector/Vector.fs @@ -1,16 +1,22 @@ -namespace GraphBLAS.FSharp.Backend.Vector +namespace GraphBLAS.FSharp open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Quotes open Microsoft.FSharp.Control open Microsoft.FSharp.Quotations -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ClVector - +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ClVector +open GraphBLAS.FSharp.Backend.Quotes +open GraphBLAS.FSharp.Backend.Vector +[] module Vector = + /// + /// Builds vector of given format with fixed size and fills it with the default values of desired type. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let zeroCreate (clContext: ClContext) workGroupSize = let zeroCreate = ClArray.zeroCreate clContext workGroupSize @@ -31,9 +37,14 @@ module Vector = ClVector.Dense <| zeroCreate processor allocationMode size + /// + /// Builds vector of given format with fixed size and fills it with the values from the given list. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let ofList (clContext: ClContext) workGroupSize = let scatter = - Scatter.lastOccurrence clContext workGroupSize + Common.Scatter.lastOccurrence clContext workGroupSize let zeroCreate = ClArray.zeroCreate clContext workGroupSize @@ -76,6 +87,12 @@ module Vector = ClVector.Dense result + /// + /// Creates new vector with the values from the given one. + /// New vector represented in the format of the given one. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let copy (clContext: ClContext) workGroupSize = let sparseCopy = Sparse.Vector.copy clContext workGroupSize @@ -91,6 +108,12 @@ module Vector = ClVector.Dense <| copyOptionData processor allocationMode vector + /// + /// Sparsifies the given vector if it is in a dense format. + /// If the given vector is already sparse, copies it. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let toSparse (clContext: ClContext) workGroupSize = let toSparse = Dense.Vector.toSparse clContext workGroupSize @@ -104,6 +127,12 @@ module Vector = <| toSparse processor allocationMode vector | ClVector.Sparse _ -> copy processor allocationMode vector + /// + /// Densifies the given vector if it is in a sparse format. + /// If the given vector is already dense, copies it. + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let toDense (clContext: ClContext) workGroupSize = let toDense = Sparse.Vector.toDense clContext workGroupSize @@ -119,40 +148,6 @@ module Vector = ClVector.Dense <| toDense processor allocationMode vector - let map2 (opAdd: Expr<'a option -> 'b option -> 'c option>) (clContext: ClContext) workGroupSize = - let map2Dense = - Dense.Vector.map2 opAdd clContext workGroupSize - - let map2Sparse = - Sparse.Vector.map2 opAdd clContext workGroupSize - - fun (processor: MailboxProcessor<_>) allocationMode (leftVector: ClVector<'a>) (rightVector: ClVector<'b>) -> - match leftVector, rightVector with - | ClVector.Dense left, ClVector.Dense right -> - ClVector.Dense - <| map2Dense processor allocationMode left right - | ClVector.Sparse left, ClVector.Sparse right -> - ClVector.Sparse - <| map2Sparse processor allocationMode left right - | _ -> failwith "Vector formats are not matching." - - let map2AtLeastOne (opAdd: Expr -> 'c option>) (clContext: ClContext) workGroupSize = - let map2Sparse = - Sparse.Vector.map2AtLeastOne opAdd clContext workGroupSize - - let map2Dense = - Dense.Vector.map2AtLeastOne opAdd clContext workGroupSize - - fun (processor: MailboxProcessor<_>) allocationMode (leftVector: ClVector<'a>) (rightVector: ClVector<'b>) -> - match leftVector, rightVector with - | ClVector.Sparse left, ClVector.Sparse right -> - ClVector.Sparse - <| map2Sparse processor allocationMode left right - | ClVector.Dense left, ClVector.Dense right -> - ClVector.Dense - <| map2Dense processor allocationMode left right - | _ -> failwith "Vector formats are not matching." - let private assignByMaskGeneral<'a, 'b when 'a: struct and 'b: struct> op (clContext: ClContext) workGroupSize = let sparseFillVector = @@ -177,6 +172,18 @@ module Vector = let assignByMaskComplemented<'a, 'b when 'a: struct and 'b: struct> op clContext workGroupSize = assignByMaskGeneral<'a, 'b> (Convert.assignComplementedToOption op) clContext workGroupSize + /// + /// Applies a function to each value of the vector, threading an accumulator argument through the computation. + /// Begin by applying the function to the first two values. + /// Then feed this result into the function along with the third value and so on. + /// Return the final result. + /// + /// + /// Implicit zeroes are ignored during the computation. + /// + /// + /// OpenCL context. + /// Should be a power of 2 and greater than 1. let reduce (opAdd: Expr<'a -> 'a -> 'a>) (clContext: ClContext) workGroupSize = let sparseReduce = Sparse.Vector.reduce opAdd clContext workGroupSize diff --git a/src/GraphBLAS-sharp/Objects/Matrix.fs b/src/GraphBLAS-sharp/Objects/Matrix.fs index 45754431..e74e9153 100644 --- a/src/GraphBLAS-sharp/Objects/Matrix.fs +++ b/src/GraphBLAS-sharp/Objects/Matrix.fs @@ -1,8 +1,8 @@ namespace GraphBLAS.FSharp.Objects open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClMatrix +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClMatrix module Matrix = type CSR<'a when 'a: struct> = diff --git a/src/GraphBLAS-sharp/Objects/MatrixExtensions.fs b/src/GraphBLAS-sharp/Objects/MatrixExtensions.fs index f310ca31..a0e8332a 100644 --- a/src/GraphBLAS-sharp/Objects/MatrixExtensions.fs +++ b/src/GraphBLAS-sharp/Objects/MatrixExtensions.fs @@ -1,9 +1,9 @@ namespace GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects open Brahma.FSharp open Matrix -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ArraysExtensions open GraphBLAS.FSharp.Objects.ClVectorExtensions module MatrixExtensions = diff --git a/src/GraphBLAS-sharp/Objects/Vector.fs b/src/GraphBLAS-sharp/Objects/Vector.fs index 19b7e01a..6462109d 100644 --- a/src/GraphBLAS-sharp/Objects/Vector.fs +++ b/src/GraphBLAS-sharp/Objects/Vector.fs @@ -1,9 +1,9 @@ namespace GraphBLAS.FSharp.Objects open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClVector +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClVector module Vector = type Sparse<'a> = diff --git a/src/GraphBLAS-sharp/Objects/VectorExtensions.fs b/src/GraphBLAS-sharp/Objects/VectorExtensions.fs index 4bdb6a01..cfe098e7 100644 --- a/src/GraphBLAS-sharp/Objects/VectorExtensions.fs +++ b/src/GraphBLAS-sharp/Objects/VectorExtensions.fs @@ -1,8 +1,8 @@ namespace GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects +open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.Vector +open GraphBLAS.FSharp.Objects.ArraysExtensions module ClVectorExtensions = type ClVector.Sparse<'a> with diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Algorithms/BFS.fs b/tests/GraphBLAS-sharp.Tests/Backend/Algorithms/BFS.fs index a85d8424..edf40fea 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Algorithms/BFS.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Algorithms/BFS.fs @@ -1,14 +1,12 @@ module GraphBLAS.FSharp.Tests.Backend.Algorithms.BFS open Expecto -open GraphBLAS.FSharp.Backend -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Context open GraphBLAS.FSharp.Tests.Backend.QuickGraph.Algorithms open GraphBLAS.FSharp.Tests.Backend.QuickGraph.CreateGraph -open GraphBLAS.FSharp.Backend.Objects open GraphBLAS.FSharp.Objects.ClVectorExtensions open GraphBLAS.FSharp.Objects @@ -50,7 +48,8 @@ let testFixtures (testContext: TestContext) = match matrix with | ClMatrix.CSR mtx -> - let res = bfs queue mtx source |> ClVector.Dense + let res = + bfs queue matrix source |> ClVector.Dense let resHost = res.ToHost queue diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Blit.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Blit.fs index 771f3501..8387bdcc 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Blit.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Blit.fs @@ -2,10 +2,10 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Blit open Expecto open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Test open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Choose.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Choose.fs index c79d035f..3fd89e84 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Choose.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Choose.fs @@ -1,13 +1,13 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Choose -open GraphBLAS.FSharp.Backend.Common open Expecto +open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Context -open GraphBLAS.FSharp.Backend.Objects.ClContext -open Brahma.FSharp open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions let workGroupSize = Utils.defaultWorkGroupSize @@ -65,18 +65,19 @@ let makeTest2 testContext isEqual opMap testFun (firstArray: 'a [], secondArray: Array.map2 opMap firstArray secondArray |> Array.choose id - let clFirstArray = context.CreateClArray firstArray - let clSecondArray = context.CreateClArray secondArray + if expected.Length > 0 then + let clFirstArray = context.CreateClArray firstArray + let clSecondArray = context.CreateClArray secondArray - let (clActual: ClArray<_>) = - testFun processor HostInterop clFirstArray clSecondArray + let (clActual: ClArray<_>) = + testFun processor HostInterop clFirstArray clSecondArray - let actual = clActual.ToHostAndFree processor - clFirstArray.Free processor - clSecondArray.Free processor + let actual = clActual.ToHostAndFree processor + clFirstArray.Free processor + clSecondArray.Free processor - "Results must be the same" - |> Utils.compareArrays isEqual actual expected + "Results must be the same" + |> Utils.compareArrays isEqual actual expected let createTest2 testsContext (isEqual: 'a -> 'a -> bool) (opMapQ, opMap) testFun = testFun opMapQ testsContext.ClContext Utils.defaultWorkGroupSize diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/ChunkBySize.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/ChunkBySize.fs index ae282f9a..2cc3133e 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/ChunkBySize.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/ChunkBySize.fs @@ -2,11 +2,11 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.ChunkBySize open Expecto open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Test open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Concat.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Concat.fs index d27cdebf..48dcb77c 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Concat.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Concat.fs @@ -2,10 +2,10 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Concat open Expecto open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Copy.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Copy.fs index 2c8d2ba2..c36475a0 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Copy.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Copy.fs @@ -4,10 +4,10 @@ open Expecto open Expecto.Logging open Expecto.Logging.Message open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let logger = Log.create "ClArray.Copy.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Exists.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Exists.fs index ff061074..ac991951 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Exists.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Exists.fs @@ -2,13 +2,13 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Exists open Expecto open Expecto.Logging -open GraphBLAS.FSharp.Backend.Common +open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests open Context -open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClCellExtensions open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Objects.ClCell let logger = Log.create "ClArray.containsNonZero.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Fill.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Fill.fs index 0921ff26..8a285a2f 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Fill.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Fill.fs @@ -2,11 +2,10 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Fill open Expecto open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Test open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ArraysExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Item.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Item.fs index 352f2517..a3786832 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Item.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Item.fs @@ -2,11 +2,11 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Item open Expecto open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Test open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Map.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Map.fs index a49ea492..1cb85d29 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Map.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Map.fs @@ -1,12 +1,12 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Map +open Expecto open Brahma.FSharp open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Context -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend.Quotes -open Expecto -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let context = defaultContext.Queue diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Map2.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Map2.fs index ae4342b8..0b5ab49b 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Map2.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Map2.fs @@ -1,11 +1,12 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Map2 +open Expecto open Brahma.FSharp open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Context -open GraphBLAS.FSharp.Backend.Common -open Expecto -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects.ClContextExtensions + let context = defaultContext.Queue diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Pairwise.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Pairwise.fs index 5bd6957d..12db7aa8 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Pairwise.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Pairwise.fs @@ -2,11 +2,11 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Pairwise open Expecto open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Test open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/RemoveDuplicates.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/RemoveDuplicates.fs index 1f8e3f7d..276cf286 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/RemoveDuplicates.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/RemoveDuplicates.fs @@ -4,8 +4,8 @@ open Expecto open Expecto.Logging open Expecto.Logging.Message open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Common let logger = Log.create "RemoveDuplicates.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Replicate.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Replicate.fs index 0299eb05..2d6ecc6b 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Replicate.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Replicate.fs @@ -4,10 +4,10 @@ open Expecto open Expecto.Logging open Expecto.Logging.Message open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let logger = Log.create "Replicate.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Set.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Set.fs index a393b499..cf1d09e5 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Set.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/Set.fs @@ -2,10 +2,10 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.Set open Expecto open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common open GraphBLAS.FSharp.Test open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects.ArraysExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/UpperBound.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/UpperBound.fs index 78905478..7f1f2c81 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/UpperBound.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/ClArray/UpperBound.fs @@ -2,10 +2,10 @@ module GraphBLAS.FSharp.Tests.Backend.Common.ClArray.UpperBound open Expecto open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Test open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp.Objects.ClCellExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Gather.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Gather.fs index 3019d9d3..b82b65d6 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Gather.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/Gather.fs @@ -1,11 +1,11 @@ module GraphBLAS.FSharp.Tests.Backend.Common.Gather -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Tests open Expecto open Microsoft.FSharp.Collections -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Tests +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions open GraphBLAS.FSharp.Backend.Quotes let context = Context.defaultContext.ClContext @@ -55,14 +55,14 @@ let createTest<'a> (isEqual: 'a -> 'a -> bool) testFun = |> testPropertyWithConfig Utils.defaultConfig $"test on %A{typeof<'a>}" let tests = - [ createTest (=) Gather.run + [ createTest (=) Common.Gather.run if Utils.isFloat64Available context.ClDevice then - createTest Utils.floatIsEqual Gather.run + createTest Utils.floatIsEqual Common.Gather.run - createTest Utils.float32IsEqual Gather.run - createTest (=) Gather.run - createTest (=) Gather.run ] + createTest Utils.float32IsEqual Common.Gather.run + createTest (=) Common.Gather.run + createTest (=) Common.Gather.run ] |> testList "Gather" @@ -98,27 +98,27 @@ let createTestInit<'a> (isEqual: 'a -> 'a -> bool) testFun indexMapQ indexMap = let initTests = let idTests = - [ createTestInit (=) Gather.runInit Map.id id + [ createTestInit (=) Common.Gather.runInit Map.id id if Utils.isFloat64Available context.ClDevice then - createTestInit Utils.floatIsEqual Gather.runInit Map.id id + createTestInit Utils.floatIsEqual Common.Gather.runInit Map.id id - createTestInit Utils.float32IsEqual Gather.runInit Map.id id - createTestInit (=) Gather.runInit Map.id id - createTestInit (=) Gather.runInit Map.id id ] + createTestInit Utils.float32IsEqual Common.Gather.runInit Map.id id + createTestInit (=) Common.Gather.runInit Map.id id + createTestInit (=) Common.Gather.runInit Map.id id ] |> testList "id" let inc = ((+) 1) let incTests = - [ createTestInit (=) Gather.runInit Map.inc inc + [ createTestInit (=) Common.Gather.runInit Map.inc inc if Utils.isFloat64Available context.ClDevice then - createTestInit Utils.floatIsEqual Gather.runInit Map.inc inc + createTestInit Utils.floatIsEqual Common.Gather.runInit Map.inc inc - createTestInit Utils.float32IsEqual Gather.runInit Map.inc inc - createTestInit (=) Gather.runInit Map.inc inc - createTestInit (=) Gather.runInit Map.inc inc ] + createTestInit Utils.float32IsEqual Common.Gather.runInit Map.inc inc + createTestInit (=) Common.Gather.runInit Map.inc inc + createTestInit (=) Common.Gather.runInit Map.inc inc ] |> testList "inc" testList "init" [ idTests; incTests ] diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Merge.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Merge.fs deleted file mode 100644 index d937da3c..00000000 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Merge.fs +++ /dev/null @@ -1,54 +0,0 @@ -module GraphBLAS.FSharp.Tests.Common.Merge - -open Expecto -open Brahma.FSharp -open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions - -let context = Context.defaultContext.ClContext - -let processor = Context.defaultContext.Queue - -let config = - { Utils.defaultConfig with - endSize = 10000000 } - -let makeTest isEqual testFun (leftArray: 'a []) (rightArray: 'a []) = - if leftArray.Length > 0 && rightArray.Length > 0 then - - let leftArray = Array.sort leftArray |> Array.distinct - - let rightArray = Array.sort rightArray |> Array.distinct - - let clLeftArray = context.CreateClArray leftArray - let clRightArray = context.CreateClArray rightArray - - let clResult: ClArray<'a> = - testFun processor clLeftArray clRightArray - - let result = clResult.ToHostAndFree processor - clLeftArray.Free processor - clRightArray.Free processor - - let expected = - Array.concat [ leftArray; rightArray ] - |> Array.sort - - "Results must be the same" - |> Utils.compareArrays isEqual result expected - -let createTest<'a> isEqual = - Merge.run context Utils.defaultWorkGroupSize - |> makeTest isEqual - |> testPropertyWithConfig config $"test on {typeof<'a>}" - -let tests = - [ createTest (=) - - if Utils.isFloat64Available context.ClDevice then - createTest (=) - - createTest (=) - createTest (=) ] - |> testList "Merge" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/Reduce.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/Reduce.fs index 3500e639..54dfee30 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/Reduce.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/Reduce.fs @@ -4,10 +4,10 @@ open Expecto open Expecto.Logging open Expecto.Logging.Message open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ClCell -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let logger = Log.create "Reduce.Tests" @@ -52,7 +52,8 @@ let makeTest (reduce: MailboxProcessor<_> -> ClArray<'a> -> ClCell<'a>) plus zer |> Expect.equal actualSum expectedSum let testFixtures plus plusQ zero name = - let reduce = Reduce.reduce plusQ context wgSize + let reduce = + Common.Reduce.reduce plusQ context wgSize makeTest reduce plus zero |> testPropertyWithConfig config $"Correctness on %s{name}" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/ReduceByKey.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/ReduceByKey.fs index 772eafb5..0e58f323 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/ReduceByKey.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/ReduceByKey.fs @@ -1,13 +1,13 @@ module GraphBLAS.FSharp.Tests.Backend.Common.Reduce.ByKey open Expecto -open GraphBLAS.FSharp.Backend.Common +open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Test open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ClContext -open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let context = Context.defaultContext.ClContext @@ -63,7 +63,7 @@ let makeTest isEqual reduce reduceOp (arrayAndKeys: (int * 'a) []) = let createTestSequential<'a> (isEqual: 'a -> 'a -> bool) reduceOp reduceOpQ = let reduce = - Reduce.ByKey.sequential reduceOpQ context Utils.defaultWorkGroupSize + Common.Reduce.ByKey.sequential reduceOpQ context Utils.defaultWorkGroupSize makeTest isEqual reduce reduceOp |> testPropertyWithConfig config $"test on {typeof<'a>}" @@ -97,7 +97,7 @@ let sequentialTest = let createTestOneWorkGroup<'a> (isEqual: 'a -> 'a -> bool) reduceOp reduceOpQ = let reduce = - Reduce.ByKey.oneWorkGroupSegments reduceOpQ context Utils.defaultWorkGroupSize + Common.Reduce.ByKey.oneWorkGroupSegments reduceOpQ context Utils.defaultWorkGroupSize makeTest isEqual reduce reduceOp |> testPropertyWithConfig @@ -166,7 +166,7 @@ let makeTestSequentialSegments isEqual reduce reduceOp (valuesAndKeys: (int * 'a let createTestSequentialSegments<'a> (isEqual: 'a -> 'a -> bool) reduceOp reduceOpQ = let reduce = - Reduce.ByKey.segmentSequential reduceOpQ context Utils.defaultWorkGroupSize + Common.Reduce.ByKey.segmentSequential reduceOpQ context Utils.defaultWorkGroupSize makeTestSequentialSegments isEqual reduce reduceOp |> testPropertyWithConfig { config with startSize = 1000 } $"test on {typeof<'a>}" @@ -252,7 +252,7 @@ let makeTest2D isEqual reduce reduceOp (array: (int * int * 'a) []) = let createTestSequential2D<'a> (isEqual: 'a -> 'a -> bool) reduceOp reduceOpQ = let reduce = - Reduce.ByKey2D.sequential reduceOpQ context Utils.defaultWorkGroupSize + Common.Reduce.ByKey2D.sequential reduceOpQ context Utils.defaultWorkGroupSize makeTest2D isEqual reduce reduceOp |> testPropertyWithConfig @@ -331,7 +331,7 @@ let makeTestSequentialSegments2D isEqual reduce reduceOp (array: (int * int * 'a let createTestSequentialSegments2D<'a> (isEqual: 'a -> 'a -> bool) reduceOp reduceOpQ = let reduce = - Reduce.ByKey2D.segmentSequential reduceOpQ context Utils.defaultWorkGroupSize + Common.Reduce.ByKey2D.segmentSequential reduceOpQ context Utils.defaultWorkGroupSize makeTestSequentialSegments2D isEqual reduce reduceOp |> testPropertyWithConfig @@ -430,7 +430,7 @@ let testOption<'a> isEqual reduceOp testFun (array: (int * 'a) []) = |> checkResultOption isEqual keys values reduceOp let createTestOption (isEqual: 'a -> 'a -> bool) (reduceOpQ, reduceOp) = - Reduce.ByKey.Option.segmentSequential reduceOpQ context Utils.defaultWorkGroupSize + Common.Reduce.ByKey.Option.segmentSequential reduceOpQ context Utils.defaultWorkGroupSize |> testOption<'a> isEqual reduceOp |> testPropertyWithConfig { config with @@ -518,7 +518,7 @@ let test2DOption<'a> isEqual reduceOp reduce (array: (int * int * 'a) []) = |> checkResult2DOption isEqual firstKeys secondKeys values reduceOp let createTest2DOption (isEqual: 'a -> 'a -> bool) (reduceOpQ, reduceOp) = - Reduce.ByKey2D.Option.segmentSequential reduceOpQ context Utils.defaultWorkGroupSize + Common.Reduce.ByKey2D.Option.segmentSequential reduceOpQ context Utils.defaultWorkGroupSize |> test2DOption<'a> isEqual reduceOp |> testPropertyWithConfig { config with diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/Sum.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/Sum.fs index 977b085e..3953c3c0 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/Sum.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/Reduce/Sum.fs @@ -3,13 +3,13 @@ module GraphBLAS.FSharp.Tests.Backend.Common.Reduce.Sum open Expecto open Expecto.Logging open Expecto.Logging.Message +open FSharp.Quotations open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common open GraphBLAS.FSharp.Tests -open FSharp.Quotations open Context -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open GraphBLAS.FSharp.Backend.Objects.ClCell +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClCellExtensions let logger = Log.create "Sum.Test" @@ -51,7 +51,7 @@ let makeTest plus zero sum (array: 'a []) = |> Expect.equal actualSum expectedSum let testFixtures plus (plusQ: Expr<'a -> 'a -> 'a>) zero name = - Reduce.sum plusQ zero context wgSize + Common.Reduce.sum plusQ zero context wgSize |> makeTest plus zero |> testPropertyWithConfig config (sprintf "Correctness on %s" name) diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Scan/ByKey.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Scan/ByKey.fs index a89b5f36..1cea79dd 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Scan/ByKey.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/Scan/ByKey.fs @@ -1,10 +1,10 @@ module GraphBLAS.FSharp.Tests.Backend.Common.Scan.ByKey -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Objects.ClContext open Expecto +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions let context = Context.defaultContext.ClContext @@ -60,7 +60,7 @@ let createTest (zero: 'a) opAddQ opAdd isEqual deviceScan hostScan = let sequentialSegmentsTests = let excludeTests = - [ createTest 0 <@ (+) @> (+) (=) PrefixSum.ByKey.sequentialExclude HostPrimitives.prefixSumExclude + [ createTest 0 <@ (+) @> (+) (=) Common.PrefixSum.ByKey.sequentialExclude HostPrimitives.prefixSumExclude if Utils.isFloat64Available context.ClDevice then createTest @@ -68,7 +68,7 @@ let sequentialSegmentsTests = <@ (+) @> (+) Utils.floatIsEqual - PrefixSum.ByKey.sequentialExclude + Common.PrefixSum.ByKey.sequentialExclude HostPrimitives.prefixSumExclude createTest @@ -76,15 +76,15 @@ let sequentialSegmentsTests = <@ (+) @> (+) Utils.float32IsEqual - PrefixSum.ByKey.sequentialExclude + Common.PrefixSum.ByKey.sequentialExclude HostPrimitives.prefixSumExclude - createTest false <@ (||) @> (||) (=) PrefixSum.ByKey.sequentialExclude HostPrimitives.prefixSumExclude - createTest 0u <@ (+) @> (+) (=) PrefixSum.ByKey.sequentialExclude HostPrimitives.prefixSumExclude ] + createTest false <@ (||) @> (||) (=) Common.PrefixSum.ByKey.sequentialExclude HostPrimitives.prefixSumExclude + createTest 0u <@ (+) @> (+) (=) Common.PrefixSum.ByKey.sequentialExclude HostPrimitives.prefixSumExclude ] |> testList "exclude" let includeTests = - [ createTest 0 <@ (+) @> (+) (=) PrefixSum.ByKey.sequentialInclude HostPrimitives.prefixSumInclude + [ createTest 0 <@ (+) @> (+) (=) Common.PrefixSum.ByKey.sequentialInclude HostPrimitives.prefixSumInclude if Utils.isFloat64Available context.ClDevice then createTest @@ -92,7 +92,7 @@ let sequentialSegmentsTests = <@ (+) @> (+) Utils.floatIsEqual - PrefixSum.ByKey.sequentialInclude + Common.PrefixSum.ByKey.sequentialInclude HostPrimitives.prefixSumInclude createTest @@ -100,12 +100,15 @@ let sequentialSegmentsTests = <@ (+) @> (+) Utils.float32IsEqual - PrefixSum.ByKey.sequentialInclude + Common.PrefixSum.ByKey.sequentialInclude HostPrimitives.prefixSumInclude - createTest false <@ (||) @> (||) (=) PrefixSum.ByKey.sequentialInclude HostPrimitives.prefixSumInclude - createTest 0u <@ (+) @> (+) (=) PrefixSum.ByKey.sequentialInclude HostPrimitives.prefixSumInclude ] + createTest false <@ (||) @> (||) (=) Common.PrefixSum.ByKey.sequentialInclude HostPrimitives.prefixSumInclude + createTest 0u <@ (+) @> (+) (=) Common.PrefixSum.ByKey.sequentialInclude HostPrimitives.prefixSumInclude ] |> testList "include" testList "Sequential segments" [ excludeTests; includeTests ] + +let tests = + testList "ByKey" [ sequentialSegmentsTests ] diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Scan/PrefixSum.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Scan/PrefixSum.fs index fbf12398..f94b0564 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Scan/PrefixSum.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/Scan/PrefixSum.fs @@ -4,11 +4,10 @@ open Expecto open Expecto.Logging open Expecto.Logging.Message open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Tests.Context open GraphBLAS.FSharp -open GraphBLAS.FSharp.Backend.Objects.ClCell -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Tests.Context +open GraphBLAS.FSharp.Objects.ClCellExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let logger = Log.create "ClArray.PrefixSum.Tests" @@ -61,7 +60,7 @@ let makeTest plus zero isEqual scan (array: 'a []) = |> Tests.Utils.compareArrays isEqual actual expected let testFixtures plus plusQ zero isEqual name = - PrefixSum.runIncludeInPlace plusQ context wgSize + Common.PrefixSum.runIncludeInPlace plusQ context wgSize |> makeTest plus zero isEqual |> testPropertyWithConfig config $"Correctness on %s{name}" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Scatter.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Scatter.fs index a72de22b..c1d71dca 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Scatter.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/Scatter.fs @@ -3,11 +3,11 @@ module GraphBLAS.FSharp.Tests.Backend.Common.Scatter open Expecto open Expecto.Logging open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Context open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let logger = Log.create "Scatter.Tests" @@ -41,12 +41,12 @@ let makeTest<'a when 'a: equality> hostScatter scatter (array: (int * 'a) []) (r |> Utils.compareArrays (=) actual expected let testFixturesLast<'a when 'a: equality> = - Scatter.lastOccurrence context wgSize + Common.Scatter.lastOccurrence context wgSize |> makeTest<'a> HostPrimitives.scatterLastOccurrence |> testPropertyWithConfig config $"Correctness on %A{typeof<'a>}" let testFixturesFirst<'a when 'a: equality> = - Scatter.firstOccurrence context wgSize + Common.Scatter.firstOccurrence context wgSize |> makeTest<'a> HostPrimitives.scatterFirstOccurrence |> testPropertyWithConfig config $"Correctness on %A{typeof<'a>}" @@ -100,13 +100,13 @@ let initTests = let inc = ((+) 1) let firstOccurrence = - [ createInitTest Scatter.initFirsOccurrence HostPrimitives.scatterFirstOccurrence "id" id Map.id - createInitTest Scatter.initFirsOccurrence HostPrimitives.scatterFirstOccurrence "inc" inc Map.inc ] + [ createInitTest Common.Scatter.initFirstOccurrence HostPrimitives.scatterFirstOccurrence "id" id Map.id + createInitTest Common.Scatter.initFirstOccurrence HostPrimitives.scatterFirstOccurrence "inc" inc Map.inc ] |> testList "first occurrence" let lastOccurrence = - [ createInitTest Scatter.initLastOccurrence HostPrimitives.scatterLastOccurrence "id" id Map.id - createInitTest Scatter.initLastOccurrence HostPrimitives.scatterLastOccurrence "inc" inc Map.inc ] + [ createInitTest Common.Scatter.initLastOccurrence HostPrimitives.scatterLastOccurrence "id" id Map.id + createInitTest Common.Scatter.initLastOccurrence HostPrimitives.scatterLastOccurrence "inc" inc Map.inc ] |> testList "last occurrence" testList "init" [ firstOccurrence; lastOccurrence ] diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Sort/Bitonic.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Sort/Bitonic.fs index 60705e76..6297fe13 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Sort/Bitonic.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/Sort/Bitonic.fs @@ -3,11 +3,10 @@ namespace GraphBLAS.FSharp.Tests.Backend.Common.Sort open Expecto open Expecto.Logging open Expecto.Logging.Message -open GraphBLAS.FSharp.Backend.Common open Brahma.FSharp open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Context -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions module Bitonic = let logger = Log.create "BitonicSort.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Common/Sort/Radix.fs b/tests/GraphBLAS-sharp.Tests/Backend/Common/Sort/Radix.fs index 2f565f3e..9de0e054 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Common/Sort/Radix.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Common/Sort/Radix.fs @@ -1,11 +1,10 @@ module GraphBLAS.FSharp.Tests.Backend.Common.Sort.Radix open Expecto -open GraphBLAS.FSharp.Backend.Common.Sort -open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Tests +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions let config = { Utils.defaultConfig with @@ -41,7 +40,7 @@ let makeTestByKeys<'a when 'a: equality> sortFun (array: (int * 'a) []) = let createTestByKeys<'a when 'a: equality and 'a: struct> = let sort = - Radix.runByKeysStandard context workGroupSize + Sort.Radix.runByKeysStandard context workGroupSize makeTestByKeys<'a> sort |> testPropertyWithConfig config $"test on {typeof<'a>}" @@ -74,7 +73,7 @@ let makeTestKeysOnly sort (keys: uint []) = let testKeysOnly = let sort = - Radix.standardRunKeysOnly context workGroupSize + Sort.Radix.standardRunKeysOnly context workGroupSize makeTestKeysOnly sort |> testPropertyWithConfig config $"keys only" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/ByRows.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/ByRows.fs index 98270784..caa86e58 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/ByRows.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/ByRows.fs @@ -1,12 +1,12 @@ -module GraphBLAS.FSharp.Tests.Matrix.ByRows +module GraphBLAS.FSharp.Tests.Backend.Matrix.ByRows open Expecto open GraphBLAS.FSharp.Tests +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend -open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions open GraphBLAS.FSharp.Objects.ClVectorExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Convert.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Convert.fs index c27bf511..8e88e216 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Convert.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Convert.fs @@ -3,14 +3,13 @@ module GraphBLAS.FSharp.Tests.Backend.Matrix.Convert open Expecto open Expecto.Logging open Expecto.Logging.Message +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Context open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects open GraphBLAS.FSharp.Objects.MatrixExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let logger = Log.create "Convert.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/ExpandRows.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/ExpandRows.fs index 413df587..63cd8bee 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/ExpandRows.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/ExpandRows.fs @@ -1,13 +1,13 @@ module GraphBLAS.FSharp.Tests.Backend.Matrix.ExpandRows open Expecto +open Brahma.FSharp open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects.ClContext -open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Kronecker.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Kronecker.fs index add171ee..6d0f8d01 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Kronecker.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Kronecker.fs @@ -2,15 +2,13 @@ open Expecto open Expecto.Logging +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Context open GraphBLAS.FSharp.Tests.TestCases -open GraphBLAS.FSharp.Backend -open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.MatrixExtensions +open GraphBLAS.FSharp.Backend.Quotes let config = { Utils.defaultConfig with @@ -48,7 +46,7 @@ let makeTest testContext zero isEqual op kroneckerFun (leftMatrix: 'a [,], right let m2 = m2.ToDevice context let result = - kroneckerFun processor ClContext.HostInterop m1 m2 + kroneckerFun processor ClContextExtensions.HostInterop m1 m2 let actual = Option.map (fun (m: ClMatrix<'a>) -> m.ToHost processor) result @@ -65,7 +63,7 @@ let makeTest testContext zero isEqual op kroneckerFun (leftMatrix: 'a [,], right |> Expect.equal actual expectedOption let createGeneralTest testContext (zero: 'a) isEqual op opQ testName = - Matrix.kronecker opQ testContext.ClContext workGroupSize + Operations.kronecker opQ testContext.ClContext workGroupSize |> makeTest testContext zero isEqual op |> testPropertyWithConfig config $"test on %A{typeof<'a>} %s{testName}" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Map.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Map.fs index 6276019b..e61d65bf 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Map.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Map.fs @@ -4,15 +4,14 @@ open Expecto open Expecto.Logging open Expecto.Logging.Message open Microsoft.FSharp.Collections +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Backend.Quotes -open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Objects.ClContext open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Backend open GraphBLAS.FSharp.Tests.TestCases open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions open GraphBLAS.FSharp.Objects.MatrixExtensions let logger = Log.create "Map.Tests" @@ -98,7 +97,8 @@ let createTestMap case (zero: 'a) (constant: 'a) binOp isEqual opQ = let unaryOp = binOp constant let unaryOpQ = opQ zero constant - let map = Matrix.map unaryOpQ context wgSize + let map = + Operations.Matrix.map unaryOpQ context wgSize let toCOO = Matrix.toCOO context wgSize diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Map2.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Map2.fs index 1a8e2dab..9d746f11 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Map2.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Map2.fs @@ -3,24 +3,23 @@ module GraphBLAS.FSharp.Tests.Backend.Matrix.Map2 open Expecto open Expecto.Logging open Expecto.Logging.Message +open Microsoft.FSharp.Collections +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.TestCases -open Microsoft.FSharp.Collections -open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects open GraphBLAS.FSharp.Tests.Backend +open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.MatrixExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let logger = Log.create "Map2.Tests" let config = Utils.defaultConfig let wgSize = Utils.defaultWorkGroupSize -let getCorrectnessTestName case datatype = +let getCorrectTestName case datatype = $"Correctness on %s{datatype}, %A{case}" let checkResult isEqual op zero (baseMtx1: 'a [,]) (baseMtx2: 'a [,]) (actual: Matrix<'a>) = @@ -95,8 +94,8 @@ let correctnessGenericTest | ex when ex.Message = "InvalidBufferSize" -> () | ex -> raise ex -let creatTestMap2Add case (zero: 'a) add isEqual addQ map2 = - let getCorrectnessTestName = getCorrectnessTestName case +let createTestMap2Add case (zero: 'a) add isEqual addQ map2 = + let getCorrectnessTestName = getCorrectTestName case let context = case.TestContext.ClContext let q = case.TestContext.Queue @@ -114,14 +113,14 @@ let testFixturesMap2Add case = let q = case.TestContext.Queue q.Error.Add(fun e -> failwithf "%A" e) - creatTestMap2Add case false (||) (=) ArithmeticOperations.boolSumOption Matrix.map2 - creatTestMap2Add case 0 (+) (=) ArithmeticOperations.intSumOption Matrix.map2 + createTestMap2Add case false (||) (=) ArithmeticOperations.boolSumOption Operations.Matrix.map2 + createTestMap2Add case 0 (+) (=) ArithmeticOperations.intSumOption Operations.Matrix.map2 if Utils.isFloat64Available context.ClDevice then - creatTestMap2Add case 0.0 (+) Utils.floatIsEqual ArithmeticOperations.floatSumOption Matrix.map2 + createTestMap2Add case 0.0 (+) Utils.floatIsEqual ArithmeticOperations.floatSumOption Operations.Matrix.map2 - creatTestMap2Add case 0.0f (+) Utils.float32IsEqual ArithmeticOperations.float32SumOption Matrix.map2 - creatTestMap2Add case 0uy (+) (=) ArithmeticOperations.byteSumOption Matrix.map2 ] + createTestMap2Add case 0.0f (+) Utils.float32IsEqual ArithmeticOperations.float32SumOption Operations.Matrix.map2 + createTestMap2Add case 0uy (+) (=) ArithmeticOperations.byteSumOption Operations.Matrix.map2 ] let addTests = operationGPUTests "Backend.Matrix.map2 add tests" testFixturesMap2Add @@ -131,21 +130,27 @@ let testFixturesMap2AddAtLeastOne case = let q = case.TestContext.Queue q.Error.Add(fun e -> failwithf "%A" e) - creatTestMap2Add case false (||) (=) ArithmeticOperations.boolSumAtLeastOne Matrix.map2AtLeastOne - creatTestMap2Add case 0 (+) (=) ArithmeticOperations.intSumAtLeastOne Matrix.map2AtLeastOne + createTestMap2Add case false (||) (=) ArithmeticOperations.boolSumAtLeastOne Operations.Matrix.map2AtLeastOne + createTestMap2Add case 0 (+) (=) ArithmeticOperations.intSumAtLeastOne Operations.Matrix.map2AtLeastOne if Utils.isFloat64Available context.ClDevice then - creatTestMap2Add case 0.0 (+) Utils.floatIsEqual ArithmeticOperations.floatSumAtLeastOne Matrix.map2AtLeastOne - - creatTestMap2Add + createTestMap2Add + case + 0.0 + (+) + Utils.floatIsEqual + ArithmeticOperations.floatSumAtLeastOne + Operations.Matrix.map2AtLeastOne + + createTestMap2Add case 0.0f (+) Utils.float32IsEqual ArithmeticOperations.float32SumAtLeastOne - Matrix.map2AtLeastOne + Operations.Matrix.map2AtLeastOne - creatTestMap2Add case 0uy (+) (=) ArithmeticOperations.byteSumAtLeastOne Matrix.map2AtLeastOne ] + createTestMap2Add case 0uy (+) (=) ArithmeticOperations.byteSumAtLeastOne Operations.Matrix.map2AtLeastOne ] let addAtLeastOneTests = @@ -156,21 +161,27 @@ let testFixturesMap2MulAtLeastOne case = let q = case.TestContext.Queue q.Error.Add(fun e -> failwithf "%A" e) - creatTestMap2Add case false (&&) (=) ArithmeticOperations.boolMulAtLeastOne Matrix.map2AtLeastOne - creatTestMap2Add case 0 (*) (=) ArithmeticOperations.intMulAtLeastOne Matrix.map2AtLeastOne + createTestMap2Add case false (&&) (=) ArithmeticOperations.boolMulAtLeastOne Operations.Matrix.map2AtLeastOne + createTestMap2Add case 0 (*) (=) ArithmeticOperations.intMulAtLeastOne Operations.Matrix.map2AtLeastOne if Utils.isFloat64Available context.ClDevice then - creatTestMap2Add case 0.0 (*) Utils.floatIsEqual ArithmeticOperations.floatMulAtLeastOne Matrix.map2AtLeastOne - - creatTestMap2Add + createTestMap2Add + case + 0.0 + (*) + Utils.floatIsEqual + ArithmeticOperations.floatMulAtLeastOne + Operations.Matrix.map2AtLeastOne + + createTestMap2Add case 0.0f (*) Utils.float32IsEqual ArithmeticOperations.float32MulAtLeastOne - Matrix.map2AtLeastOne + Operations.Matrix.map2AtLeastOne - creatTestMap2Add case 0uy (*) (=) ArithmeticOperations.byteMulAtLeastOne Matrix.map2AtLeastOne ] + createTestMap2Add case 0uy (*) (=) ArithmeticOperations.byteMulAtLeastOne Operations.Matrix.map2AtLeastOne ] let mulAtLeastOneTests = operationGPUTests "Backend.Matrix.map2AtLeastOne multiplication tests" testFixturesMap2MulAtLeastOne diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Merge.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Merge.fs index fef357de..554fbff2 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Merge.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Merge.fs @@ -1,14 +1,13 @@ -module GraphBLAS.FSharp.Tests.Matrix.Merge +module GraphBLAS.FSharp.Tests.Backend.Matrix.Merge open Brahma.FSharp open Expecto open Microsoft.FSharp.Collections open GraphBLAS.FSharp.Backend -open GraphBLAS.FSharp.Backend.Matrix open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Backend open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions let context = Context.defaultContext.ClContext diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/RowsLengths.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/RowsLengths.fs index 6aab0988..f690ca3e 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/RowsLengths.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/RowsLengths.fs @@ -2,14 +2,14 @@ module GraphBLAS.FSharp.Tests.Backend.Matrix.RowsLengths open Expecto open Microsoft.FSharp.Collections +open Brahma.FSharp open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Backend.Matrix open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Backend open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions let processor = Context.defaultContext.Queue diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SpGeMM/Expand.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SpGeMM/Expand.fs index 67eac9d3..46b1d204 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SpGeMM/Expand.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SpGeMM/Expand.fs @@ -1,20 +1,18 @@ -module GraphBLAS.FSharp.Tests.Matrix.SpGeMM.Expand +module GraphBLAS.FSharp.Tests.Backend.Matrix.SpGeMM.Expand open Expecto -open GraphBLAS.FSharp.Backend.Matrix.SpGeMM +open Microsoft.FSharp.Collections +open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend.Quotes +open GraphBLAS.FSharp.Backend.Operations.SpGeMM +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.MatrixExtensions open GraphBLAS.FSharp.Test -open Microsoft.FSharp.Collections -open GraphBLAS.FSharp.Backend -open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Backend -open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions -open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Objects.MatrixExtensions let context = Context.defaultContext.ClContext @@ -215,7 +213,7 @@ let createGeneralTest (zero: 'a) isEqual (opAddQ, opAdd) (opMulQ, opMul) testFun |> testPropertyWithConfig config $"test on %A{typeof<'a>}" let generalTests = - [ createGeneralTest 0 (=) ArithmeticOperations.intAdd ArithmeticOperations.intMul Matrix.SpGeMM.expand + [ createGeneralTest 0 (=) ArithmeticOperations.intAdd ArithmeticOperations.intMul Operations.SpGeMM.expand if Utils.isFloat64Available context.ClDevice then createGeneralTest @@ -223,13 +221,16 @@ let generalTests = Utils.floatIsEqual ArithmeticOperations.floatAdd ArithmeticOperations.floatMul - Matrix.SpGeMM.expand + Operations.SpGeMM.expand createGeneralTest 0.0f Utils.float32IsEqual ArithmeticOperations.float32Add ArithmeticOperations.float32Mul - Matrix.SpGeMM.expand - createGeneralTest false (=) ArithmeticOperations.boolAdd ArithmeticOperations.boolMul Matrix.SpGeMM.expand ] - |> testList "general" + Operations.SpGeMM.expand + createGeneralTest false (=) ArithmeticOperations.boolAdd ArithmeticOperations.boolMul Operations.SpGeMM.expand ] + |> testList "General" + +let tests = + testList "SpGeMM.Expand" [ generalTests ] diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SpGeMM/Masked.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SpGeMM/Masked.fs index 7304b96e..18cc44c4 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SpGeMM/Masked.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SpGeMM/Masked.fs @@ -2,14 +2,12 @@ module GraphBLAS.FSharp.Tests.Backend.Matrix.SpGeMM.Masked open Expecto open Expecto.Logging -open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Tests.Context -open GraphBLAS.FSharp.Backend +open GraphBLAS.FSharp open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects open GraphBLAS.FSharp.Objects.MatrixExtensions open GraphBLAS.FSharp.Test +open GraphBLAS.FSharp.Tests +open GraphBLAS.FSharp.Tests.Context let logger = Log.create "SpGeMM.Masked.Tests" @@ -79,7 +77,7 @@ let tests = let mult = <@ fun x y -> Some(x * y) @> let mxmFun = - Matrix.SpGeMM.masked add mult context workGroupSize + Operations.SpGeMM.masked add mult context workGroupSize makeTest context q 0 (=) (+) (*) mxmFun |> testPropertyWithConfig config (getCorrectnessTestName "int") @@ -105,7 +103,7 @@ let tests = res @> let mxmFun = - Matrix.SpGeMM.masked logicalOr logicalAnd context workGroupSize + Operations.SpGeMM.masked logicalOr logicalAnd context workGroupSize makeTest context q false (=) (||) (&&) mxmFun |> testPropertyWithConfig config (getCorrectnessTestName "bool") ] diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SubRows.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SubRows.fs index e48a20e0..9a9ae54c 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SubRows.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/SubRows.fs @@ -4,10 +4,9 @@ open Expecto open GraphBLAS.FSharp.Test open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Backend -open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects.ClContext -open GraphBLAS.FSharp.Backend.Objects +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions open GraphBLAS.FSharp.Objects.MatrixExtensions open GraphBLAS.FSharp.Objects.Matrix @@ -26,13 +25,6 @@ let makeTest isEqual zero testFun (array: 'a [,], sourceRow, count) = if matrix.NNZ > 0 then - let clMatrix = matrix.ToDevice context - - let clActual: ClMatrix.COO<'a> = - testFun processor HostInterop sourceRow count clMatrix - - let actual = clActual.ToHostAndFree processor - let expected = array |> Array2D.mapi (fun rowIndex columnIndex value -> (value, rowIndex, columnIndex)) @@ -48,7 +40,15 @@ let makeTest isEqual zero testFun (array: 'a [,], sourceRow, count) = Columns = columns Values = values } - Utils.compareCOOMatrix isEqual actual expected + if expected.NNZ > 0 then + let clMatrix = matrix.ToDevice context + + let clActual: ClMatrix.COO<'a> = + testFun processor HostInterop sourceRow count clMatrix + + let actual = clActual.ToHostAndFree processor + + Utils.compareCOOMatrix isEqual actual expected let createTest isEqual (zero: 'a) = CSR.Matrix.subRows context Utils.defaultWorkGroupSize diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Transpose.fs b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Transpose.fs index 01e78bf7..e7308335 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Transpose.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Matrix/Transpose.fs @@ -3,14 +3,12 @@ module GraphBLAS.FSharp.Tests.Backend.Matrix.Transpose open Expecto open Expecto.Logging open Expecto.Logging.Message -open GraphBLAS.FSharp.Backend +open GraphBLAS.FSharp open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.TestCases -open GraphBLAS.FSharp.Backend.Matrix -open GraphBLAS.FSharp.Backend.Objects open GraphBLAS.FSharp.Objects.MatrixExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let logger = Log.create "Transpose.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/AssignByMask.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/AssignByMask.fs index 50dab7c2..737c5831 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Vector/AssignByMask.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/AssignByMask.fs @@ -2,16 +2,15 @@ module GraphBLAS.FSharp.Tests.Backend.Vector.AssignByMask open Expecto open Expecto.Logging +open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Tests -open Brahma.FSharp open TestCases -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Vector open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.ClVectorExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let logger = Log.create "Vector.assignByMask.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Convert.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Convert.fs index 2f586b03..d184bc47 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Convert.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Convert.fs @@ -3,14 +3,13 @@ module GraphBLAS.FSharp.Tests.Backend.Vector.Convert open Expecto open Expecto.Logging open Expecto.Logging.Message +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend open TestCases -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Vector +open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.ClVectorExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let logger = Log.create "Backend.Vector.Convert.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Copy.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Copy.fs index f5d28ca3..a83a1f3f 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Copy.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Copy.fs @@ -2,14 +2,13 @@ module GraphBLAS.FSharp.Tests.Backend.Vector.Copy open Expecto open Expecto.Logging +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Tests open TestCases -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Vector open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.ClVectorExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let logger = Log.create "Vector.copy.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Map.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Map.fs new file mode 100644 index 00000000..c3cfeab7 --- /dev/null +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Map.fs @@ -0,0 +1,146 @@ +module GraphBLAS.FSharp.Tests.Backend.Vector.Map + +open Expecto +open Expecto.Logging +open Expecto.Logging.Message +open Microsoft.FSharp.Collections +open GraphBLAS.FSharp +open GraphBLAS.FSharp.Backend +open GraphBLAS.FSharp.Backend.Quotes +open GraphBLAS.FSharp.Tests +open GraphBLAS.FSharp.Tests.Backend +open GraphBLAS.FSharp.Tests.TestCases +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ClVectorExtensions +open Mono.CompilerServices.SymbolWriter + +let logger = Log.create "Vector.Map.Tests" + +let config = Utils.defaultConfig +let wgSize = Utils.defaultWorkGroupSize + +let getCorrectnessTestName case datatype = + $"Correctness on %s{datatype}, %A{case}" + +let checkResult isEqual op zero (baseVector: 'a []) (actual: Vector<'b>) = + + let expectedArrayLength = baseVector.Length + + let expectedArray = Array.create expectedArrayLength zero + + for i in 0 .. expectedArrayLength - 1 do + expectedArray.[i] <- op baseVector.[i] + + let expected = + Utils.createVectorFromArray Dense expectedArray (isEqual zero) + |> Utils.vectorToDenseVector + + match actual with + | Vector.Dense actual -> + "arrays must have the same values" + |> Expect.equal actual expected + | _ -> failwith "Vector format must be Sparse." + +let correctnessGenericTest + zero + op + (addFun: MailboxProcessor<_> -> AllocationFlag -> ClVector<'a> -> ClVector<'a>) + (toDense: MailboxProcessor<_> -> AllocationFlag -> ClVector<'a> -> ClVector<'a>) + (isEqual: 'a -> 'a -> bool) + (case: OperationCase) + (array: 'a []) + = + + let isZero = (isEqual zero) + + let vectorHost = + Utils.createVectorFromArray case.Format array isZero + + if vectorHost.NNZ > 0 then + + let context = case.TestContext.ClContext + let q = case.TestContext.Queue + + let vector = vectorHost.ToDevice context + + try + let res = addFun q HostInterop vector + + vector.Dispose q + + let denseActual = toDense q HostInterop res + + let actual = denseActual.ToHost q + + res.Dispose q + denseActual.Dispose q + + checkResult isEqual op zero array actual + with + | ex when ex.Message = "InvalidBufferSize" -> () + | ex -> raise ex + +let createTestMap case (zero: 'a) (constant: 'a) binOp isEqual opQ = + let getCorrectnessTestName = getCorrectnessTestName case + + let context = case.TestContext.ClContext + let q = case.TestContext.Queue + + let unaryOp = binOp constant + let unaryOpQ = opQ zero constant + + let map = + Operations.Vector.map unaryOpQ context wgSize + + let toDense = Vector.toDense context wgSize + + case + |> correctnessGenericTest zero unaryOp map toDense isEqual + |> testPropertyWithConfig config (getCorrectnessTestName $"{typeof<'a>}") + +let testFixturesMapNot case = + [ let q = case.TestContext.Queue + q.Error.Add(fun e -> failwithf "%A" e) + + createTestMap case false true (fun _ -> not) (=) (fun _ _ -> ArithmeticOperations.notOption) ] + +let notTests = + operationGPUTests "not" testFixturesMapNot + +let testFixturesMapAdd case = + [ let context = case.TestContext.ClContext + let q = case.TestContext.Queue + q.Error.Add(fun e -> failwithf "%A" e) + + createTestMap case 0 10 (+) (=) ArithmeticOperations.addLeftConst + + if Utils.isFloat64Available context.ClDevice then + createTestMap case 0.0 10.0 (+) Utils.floatIsEqual ArithmeticOperations.addLeftConst + + createTestMap case 0.0f 10.0f (+) Utils.float32IsEqual ArithmeticOperations.addLeftConst + + createTestMap case 0uy 10uy (+) (=) ArithmeticOperations.addLeftConst ] + +let addTests = + operationGPUTests "add" testFixturesMapAdd + +let testFixturesMapMul case = + [ let context = case.TestContext.ClContext + let q = case.TestContext.Queue + q.Error.Add(fun e -> failwithf "%A" e) + + createTestMap case 0 10 (*) (=) ArithmeticOperations.mulLeftConst + + if Utils.isFloat64Available context.ClDevice then + createTestMap case 0.0 10.0 (*) Utils.floatIsEqual ArithmeticOperations.mulLeftConst + + createTestMap case 0.0f 10.0f (*) Utils.float32IsEqual ArithmeticOperations.mulLeftConst + + createTestMap case 0uy 10uy (*) (=) ArithmeticOperations.mulLeftConst ] + +let mulTests = + operationGPUTests "mul" testFixturesMapMul + +let allTests = + testList "Map" [ addTests; mulTests; notTests ] diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Map2.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Map2.fs index e5eadaa4..aac15b20 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Map2.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Map2.fs @@ -2,15 +2,14 @@ module GraphBLAS.FSharp.Tests.Backend.Vector.Map2 open Expecto open Expecto.Logging +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Backend.Quotes open GraphBLAS.FSharp.Tests.TestCases open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Vector open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.ClVectorExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let logger = Log.create "Vector.ElementWise.Tests" @@ -101,42 +100,54 @@ let createTest case isEqual (zero: 'a) plus plusQ map2 = let addTestFixtures case = let context = case.TestContext.ClContext - [ createTest case (=) 0 (+) ArithmeticOperations.intSumOption Vector.map2 + [ createTest case (=) 0 (+) ArithmeticOperations.intSumOption Operations.Vector.map2 if Utils.isFloat64Available context.ClDevice then - createTest case Utils.floatIsEqual 0.0 (+) ArithmeticOperations.floatSumOption Vector.map2 + createTest case Utils.floatIsEqual 0.0 (+) ArithmeticOperations.floatSumOption Operations.Vector.map2 - createTest case Utils.float32IsEqual 0.0f (+) ArithmeticOperations.float32SumOption Vector.map2 - createTest case (=) false (||) ArithmeticOperations.boolSumOption Vector.map2 - createTest case (=) 0uy (+) ArithmeticOperations.byteSumOption Vector.map2 ] + createTest case Utils.float32IsEqual 0.0f (+) ArithmeticOperations.float32SumOption Operations.Vector.map2 + createTest case (=) false (||) ArithmeticOperations.boolSumOption Operations.Vector.map2 + createTest case (=) 0uy (+) ArithmeticOperations.byteSumOption Operations.Vector.map2 ] let addTests = operationGPUTests "add" addTestFixtures let mulTestFixtures case = let context = case.TestContext.ClContext - [ createTest case (=) 0 (*) ArithmeticOperations.intMulOption Vector.map2 + [ createTest case (=) 0 (*) ArithmeticOperations.intMulOption Operations.Vector.map2 if Utils.isFloat64Available context.ClDevice then - createTest case Utils.floatIsEqual 0.0 (*) ArithmeticOperations.floatMulOption Vector.map2 + createTest case Utils.floatIsEqual 0.0 (*) ArithmeticOperations.floatMulOption Operations.Vector.map2 - createTest case Utils.float32IsEqual 0.0f (*) ArithmeticOperations.float32MulOption Vector.map2 - createTest case (=) false (&&) ArithmeticOperations.boolMulOption Vector.map2 - createTest case (=) 0uy (*) ArithmeticOperations.byteMulOption Vector.map2 ] + createTest case Utils.float32IsEqual 0.0f (*) ArithmeticOperations.float32MulOption Operations.Vector.map2 + createTest case (=) false (&&) ArithmeticOperations.boolMulOption Operations.Vector.map2 + createTest case (=) 0uy (*) ArithmeticOperations.byteMulOption Operations.Vector.map2 ] let mulTests = operationGPUTests "mul" addTestFixtures let addAtLeastOneTestFixtures case = let context = case.TestContext.ClContext - [ createTest case (=) 0 (+) ArithmeticOperations.intSumAtLeastOne Vector.map2AtLeastOne + [ createTest case (=) 0 (+) ArithmeticOperations.intSumAtLeastOne Operations.Vector.map2AtLeastOne if Utils.isFloat64Available context.ClDevice then - createTest case Utils.floatIsEqual 0.0 (+) ArithmeticOperations.floatSumAtLeastOne Vector.map2AtLeastOne + createTest + case + Utils.floatIsEqual + 0.0 + (+) + ArithmeticOperations.floatSumAtLeastOne + Operations.Vector.map2AtLeastOne - createTest case Utils.float32IsEqual 0.0f (+) ArithmeticOperations.float32SumAtLeastOne Vector.map2AtLeastOne - createTest case (=) false (||) ArithmeticOperations.boolSumAtLeastOne Vector.map2AtLeastOne - createTest case (=) 0uy (+) ArithmeticOperations.byteSumAtLeastOne Vector.map2AtLeastOne ] + createTest + case + Utils.float32IsEqual + 0.0f + (+) + ArithmeticOperations.float32SumAtLeastOne + Operations.Vector.map2AtLeastOne + createTest case (=) false (||) ArithmeticOperations.boolSumAtLeastOne Operations.Vector.map2AtLeastOne + createTest case (=) 0uy (+) ArithmeticOperations.byteSumAtLeastOne Operations.Vector.map2AtLeastOne ] let addAtLeastOneTests = operationGPUTests "addAtLeastOne" addTestFixtures @@ -144,14 +155,26 @@ let addAtLeastOneTests = let mulAtLeastOneTestFixtures case = let context = case.TestContext.ClContext - [ createTest case (=) 0 (*) ArithmeticOperations.intMulAtLeastOne Vector.map2AtLeastOne + [ createTest case (=) 0 (*) ArithmeticOperations.intMulAtLeastOne Operations.Vector.map2AtLeastOne if Utils.isFloat64Available context.ClDevice then - createTest case Utils.floatIsEqual 0.0 (*) ArithmeticOperations.floatMulAtLeastOne Vector.map2AtLeastOne + createTest + case + Utils.floatIsEqual + 0.0 + (*) + ArithmeticOperations.floatMulAtLeastOne + Operations.Vector.map2AtLeastOne - createTest case Utils.float32IsEqual 0.0f (*) ArithmeticOperations.float32MulAtLeastOne Vector.map2AtLeastOne - createTest case (=) false (&&) ArithmeticOperations.boolMulAtLeastOne Vector.map2AtLeastOne - createTest case (=) 0uy (*) ArithmeticOperations.byteMulAtLeastOne Vector.map2AtLeastOne ] + createTest + case + Utils.float32IsEqual + 0.0f + (*) + ArithmeticOperations.float32MulAtLeastOne + Operations.Vector.map2AtLeastOne + createTest case (=) false (&&) ArithmeticOperations.boolMulAtLeastOne Operations.Vector.map2AtLeastOne + createTest case (=) 0uy (*) ArithmeticOperations.byteMulAtLeastOne Operations.Vector.map2AtLeastOne ] let mulAtLeastOneTests = operationGPUTests "mulAtLeastOne" mulTestFixtures @@ -172,7 +195,7 @@ let fillSubVectorFun value zero isEqual = let complementedGeneralTestFixtures case = let context = case.TestContext.ClContext - [ createTest case (=) 0 (fillSubVectorFun 1 0 (=)) (fillSubVectorComplementedQ 1) Vector.map2 + [ createTest case (=) 0 (fillSubVectorFun 1 0 (=)) (fillSubVectorComplementedQ 1) Operations.Vector.map2 if Utils.isFloat64Available context.ClDevice then createTest @@ -181,7 +204,7 @@ let complementedGeneralTestFixtures case = 0.0 (fillSubVectorFun 1.0 0.0 Utils.floatIsEqual) (fillSubVectorComplementedQ 1.0) - Vector.map2 + Operations.Vector.map2 createTest case @@ -189,11 +212,17 @@ let complementedGeneralTestFixtures case = 0.0f (fillSubVectorFun 1.0f 0.0f Utils.float32IsEqual) (fillSubVectorComplementedQ 1.0f) - Vector.map2 + Operations.Vector.map2 - createTest case (=) false (fillSubVectorFun true false (=)) (fillSubVectorComplementedQ true) Vector.map2 + createTest + case + (=) + false + (fillSubVectorFun true false (=)) + (fillSubVectorComplementedQ true) + Operations.Vector.map2 - createTest case (=) 0uy (fillSubVectorFun 1uy 0uy (=)) (fillSubVectorComplementedQ 1uy) Vector.map2 ] + createTest case (=) 0uy (fillSubVectorFun 1uy 0uy (=)) (fillSubVectorComplementedQ 1uy) Operations.Vector.map2 ] let complementedGeneralTests = diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Merge.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Merge.fs index af693c80..ae363e78 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Merge.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Merge.fs @@ -1,13 +1,12 @@ -module GraphBLAS.FSharp.Tests.Vector.Merge +module GraphBLAS.FSharp.Tests.Backend.Vector.Merge -open GraphBLAS.FSharp.Backend.Vector -open GraphBLAS.FSharp.Backend.Common -open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions open Brahma.FSharp open Expecto +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend +open GraphBLAS.FSharp.Tests +open GraphBLAS.FSharp.Objects +open GraphBLAS.FSharp.Objects.ArraysExtensions let processor = Context.defaultContext.Queue diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/OfList.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/OfList.fs index 6bc5a392..9623073f 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Vector/OfList.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/OfList.fs @@ -2,15 +2,14 @@ module GraphBLAS.FSharp.Tests.Backend.Vector.OfList open Expecto open Expecto.Logging +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests -open GraphBLAS.FSharp.Backend open Context open TestCases -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Vector +open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.ClVectorExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let logger = Log.create "Vector.ofList.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Reduce.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Reduce.fs index 42f29688..7775d541 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Vector/Reduce.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/Reduce.fs @@ -2,13 +2,12 @@ module GraphBLAS.FSharp.Tests.Backend.Vector.Reduce open Expecto open Expecto.Logging +open Brahma.FSharp +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Tests -open Brahma.FSharp -open FSharp.Quotations open TestCases -open GraphBLAS.FSharp.Backend.Objects.ClCell -open GraphBLAS.FSharp.Backend.Vector +open GraphBLAS.FSharp.Objects.ClCellExtensions let logger = Log.create "Vector.reduce.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/SpMV.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/SpMV.fs index e19ade53..aed7ea50 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Vector/SpMV.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/SpMV.fs @@ -1,18 +1,17 @@ module GraphBLAS.FSharp.Tests.Backend.Vector.SpMV -open GraphBLAS.FSharp.Backend.Objects.ArraysExtensions open Expecto +open Microsoft.FSharp.Collections +open Microsoft.FSharp.Core open Brahma.FSharp -open GraphBLAS.FSharp.Backend.Quotes +open GraphBLAS.FSharp open GraphBLAS.FSharp.Tests open GraphBLAS.FSharp.Tests.Context open GraphBLAS.FSharp.Tests.TestCases -open Microsoft.FSharp.Collections -open Microsoft.FSharp.Core -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Vector open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions +open GraphBLAS.FSharp.Objects.ArraysExtensions +open GraphBLAS.FSharp.Backend.Quotes let config = Utils.defaultConfig @@ -92,7 +91,7 @@ let createTest testContext (zero: 'a) isEqual add mul addQ mulQ = let getCorrectnessTestName datatype = $"Correctness on %s{datatype}, %A{testContext.ClContext}" - let spMV = SpMV.run addQ mulQ context wgSize + let spMV = Operations.SpMV addQ mulQ context wgSize testContext |> correctnessGenericTest zero add mul spMV isEqual q diff --git a/tests/GraphBLAS-sharp.Tests/Backend/Vector/ZeroCreate.fs b/tests/GraphBLAS-sharp.Tests/Backend/Vector/ZeroCreate.fs index 313e0066..79c1e4d9 100644 --- a/tests/GraphBLAS-sharp.Tests/Backend/Vector/ZeroCreate.fs +++ b/tests/GraphBLAS-sharp.Tests/Backend/Vector/ZeroCreate.fs @@ -2,15 +2,14 @@ module GraphBLAS.FSharp.Tests.Backend.Vector.ZeroCreate open Expecto open Expecto.Logging +open GraphBLAS.FSharp open GraphBLAS.FSharp.Backend open GraphBLAS.FSharp.Tests open Context open TestCases -open GraphBLAS.FSharp.Backend.Objects -open GraphBLAS.FSharp.Backend.Vector open GraphBLAS.FSharp.Objects open GraphBLAS.FSharp.Objects.ClVectorExtensions -open GraphBLAS.FSharp.Backend.Objects.ClContext +open GraphBLAS.FSharp.Objects.ClContextExtensions let logger = Log.create "Vector.zeroCreate.Tests" diff --git a/tests/GraphBLAS-sharp.Tests/Generators.fs b/tests/GraphBLAS-sharp.Tests/Generators.fs index 38d3e388..fec8f61e 100644 --- a/tests/GraphBLAS-sharp.Tests/Generators.fs +++ b/tests/GraphBLAS-sharp.Tests/Generators.fs @@ -1,10 +1,8 @@ namespace GraphBLAS.FSharp.Test open FsCheck -open GraphBLAS.FSharp open Expecto.Logging open Expecto.Logging.Message -open FSharp.Quotations.Evaluator module Generators = let logger = Log.create "Generators" diff --git a/tests/GraphBLAS-sharp.Tests/GraphBLAS-sharp.Tests.fsproj b/tests/GraphBLAS-sharp.Tests/GraphBLAS-sharp.Tests.fsproj index 75a4f492..5e2185f9 100644 --- a/tests/GraphBLAS-sharp.Tests/GraphBLAS-sharp.Tests.fsproj +++ b/tests/GraphBLAS-sharp.Tests/GraphBLAS-sharp.Tests.fsproj @@ -41,7 +41,6 @@ - @@ -63,6 +62,7 @@ + diff --git a/tests/GraphBLAS-sharp.Tests/Helpers.fs b/tests/GraphBLAS-sharp.Tests/Helpers.fs index 1811c40b..5f8d043b 100644 --- a/tests/GraphBLAS-sharp.Tests/Helpers.fs +++ b/tests/GraphBLAS-sharp.Tests/Helpers.fs @@ -1,15 +1,13 @@ namespace GraphBLAS.FSharp.Tests -open Brahma.FSharp.OpenCL.Translator +open Expecto open Microsoft.FSharp.Reflection -open Brahma.FSharp -open OpenCL.Net -open GraphBLAS.FSharp.Test open System.Text.RegularExpressions -open Expecto +open Brahma.FSharp +open Brahma.FSharp.OpenCL.Translator open GraphBLAS.FSharp.Objects -open GraphBLAS.FSharp.Backend.Objects - +open GraphBLAS.FSharp.Test +open OpenCL.Net [] module Utils = diff --git a/tests/GraphBLAS-sharp.Tests/Program.fs b/tests/GraphBLAS-sharp.Tests/Program.fs index 9049b03e..ee9ffa90 100644 --- a/tests/GraphBLAS-sharp.Tests/Program.fs +++ b/tests/GraphBLAS-sharp.Tests/Program.fs @@ -1,6 +1,7 @@ open Expecto -open GraphBLAS.FSharp.Tests.Backend open GraphBLAS.FSharp.Tests +open GraphBLAS.FSharp.Tests.Backend +open GraphBLAS.FSharp.Tests.Backend.Matrix let matrixTests = testList @@ -16,7 +17,7 @@ let matrixTests = Matrix.SubRows.tests Matrix.Kronecker.tests - Matrix.SpGeMM.Expand.generalTests + Matrix.SpGeMM.Expand.tests Matrix.SpGeMM.Masked.tests ] |> testSequenced @@ -24,7 +25,7 @@ let commonTests = let scanTests = testList "Scan" - [ Common.Scan.ByKey.sequentialSegmentsTests + [ Common.Scan.ByKey.tests Common.Scan.PrefixSum.tests ] let reduceTests = @@ -64,7 +65,6 @@ let commonTests = "Common" [ Common.Scatter.allTests Common.Gather.allTests - Common.Merge.tests clArrayTests sortTests reduceTests @@ -79,6 +79,7 @@ let vectorTests = Vector.OfList.tests Vector.Copy.tests Vector.Convert.tests + Vector.Map.allTests Vector.Map2.allTests Vector.AssignByMask.tests Vector.AssignByMask.complementedTests @@ -91,12 +92,7 @@ let algorithmsTests = |> testSequenced let deviceTests = - testList - "Device" - [ matrixTests - commonTests - vectorTests - algorithmsTests ] + testList "Device" [ matrixTests; commonTests ] |> testSequenced let hostTests =