File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,5 @@ module TriangleCounting =
1313 let! result = ( matrix', transposed) ||> Matrix.mxmWithMask AddMult.int lowerTriangularMask
1414 let! count = result |> Matrix.reduce Add.int
1515
16- do ! Scalar.synchronize count
17-
18- return ! ( Scalar.extractValue count)
16+ return ! ( Scalar.exportValue count)
1917 }
Original file line number Diff line number Diff line change @@ -9,9 +9,7 @@ module Scalar =
99 constructors
1010 *)
1111
12- let internal createFromArray ( value : 'a []) : GraphblasEvaluation < Scalar < 'a >> = graphblas { return Scalar.FromArray( value) }
13-
14- let create ( value : 'a ) : GraphblasEvaluation < Scalar < 'a >> = createFromArray [| value|]
12+ let create ( value : 'a ) : GraphblasEvaluation < Scalar < 'a >> = graphblas { return Scalar { Value = [| value|] } }
1513
1614 (*
1715 methods
@@ -20,8 +18,9 @@ module Scalar =
2018 let copy ( scalar : Scalar < 'a >) : GraphblasEvaluation < Scalar < 'a >> = failwith " Not Implemented yet"
2119
2220 let synchronize ( scalar : Scalar < 'a >) : GraphblasEvaluation < unit > =
23- opencl {
24- let! _ = ToHost scalar.Value
21+ match scalar with
22+ | Scalar s -> opencl {
23+ let! _ = ToHost s.Value
2524
2625 return ()
2726 }
@@ -31,9 +30,12 @@ module Scalar =
3130 assignment and extraction
3231 *)
3332
34- let extractValue ( scalar : Scalar < 'a >) : GraphblasEvaluation < 'a > = graphblas { return scalar.Value.[ 0 ] }
35-
36- let internal extractArray ( scalar : Scalar < 'a >) : GraphblasEvaluation < 'a []> = graphblas { return scalar.Value }
33+ let exportValue ( scalar : Scalar < 'a >) : GraphblasEvaluation < 'a > =
34+ match scalar with
35+ | Scalar s -> graphblas {
36+ do ! synchronize scalar
37+ return s.Value.[ 0 ]
38+ }
3739
3840 let assignValue ( scalar : Scalar < 'a >) ( target : Scalar < 'a >) : GraphblasEvaluation < unit > =
3941 failwith " Not Implemented yet"
Original file line number Diff line number Diff line change @@ -99,7 +99,8 @@ module Vector =
9999 if t.Size <> s.Size then
100100 invalidArg " source" <| sprintf " The size of source vector must be %A . Received: %A " t.Size s.Size
101101
102- if mask.IsComplemented then failwith " Not Implemented yet" else
102+ if mask.IsComplemented then failwith " Not Implemented yet"
103+ else
103104 graphblas {
104105 let! resultIndices , resultValues = AssignSubVector.run t.Indices t.Values s.Indices s.Values mask.Indices |> EvalGB.fromCl
105106 t.Indices <- resultIndices
@@ -115,13 +116,12 @@ module Vector =
115116 failwith " Not Implemented yet"
116117
117118 /// vec.[ mask] <- value
118- let fillSubVector ( mask : Mask1D ) ( value : Scalar < 'a >) ( vector : Vector < 'a >) : GraphblasEvaluation < unit > =
119+ let fillSubVector ( mask : Mask1D ) (( Scalar scalar ) : Scalar < 'a >) ( vector : Vector < 'a >) : GraphblasEvaluation < unit > =
119120 match vector with
120121 | VectorCOO v ->
121122 if mask.IsComplemented then failwith " Not Implemented yet" else
122123 graphblas {
123- let! s = Scalar.extractArray value
124- let! resultIndices , resultValues = FillSubVector.run v.Indices v.Values mask.Indices s |> EvalGB.fromCl
124+ let! resultIndices , resultValues = FillSubVector.run v.Indices v.Values mask.Indices scalar.Value |> EvalGB.fromCl
125125 v.Indices <- resultIndices
126126 v.Values <- resultValues
127127 }
@@ -147,7 +147,7 @@ module Vector =
147147 }
148148 |> EvalGB.fromCl
149149
150- return ! ( Scalar.createFromArray result)
150+ return Scalar { Value = result}
151151 }
152152
153153 let vxmWithMask ( semiring : ISemiring < 'a >) ( mask : Mask1D ) ( vector : Vector < 'a >) ( matrix : Matrix < 'a >) : GraphblasEvaluation < Vector < 'a >> = failwith " Not Implemented yet"
Original file line number Diff line number Diff line change 11namespace GraphBLAS.FSharp
22
33type Scalar < 'a when 'a : struct > =
4+ | Scalar of ArrayScalar < 'a >
5+
6+ and ArrayScalar < 'a > =
47 {
58 Value: 'a []
69 }
You can’t perform that action at this time.
0 commit comments