Skip to content

Commit c5fa0d0

Browse files
committed
refactor: ClArray.Free and *.FreeAndWait
1 parent 95fea31 commit c5fa0d0

7 files changed

Lines changed: 22 additions & 19 deletions

File tree

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksBFS.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ type BFSBenchmarks<'matrixT, 'elem when 'matrixT :> IDeviceMemObject and 'elem :
8383
(matrix :> IDeviceMemObject).Dispose this.Processor
8484

8585
member this.ClearResult() =
86-
this.ResultVector.Free this.Processor
86+
this.ResultVector.FreeAndWait this.Processor
8787

8888
member this.ReadMatrix() =
8989
let matrixReader = this.InputMatrixReader

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ module internal Scatter =
6464
/// </code>
6565
/// </example>
6666
let firstOccurrence clContext =
67-
general <| Predicates.firstOccurrence () <| clContext
67+
general
68+
<| Predicates.firstOccurrence ()
69+
<| clContext
6870

6971
/// <summary>
7072
/// Creates a new array from the given one where it is indicated by the array of positions at which position in the new array
@@ -85,7 +87,9 @@ module internal Scatter =
8587
/// </code>
8688
/// </example>
8789
let lastOccurrence clContext =
88-
general <| Predicates.lastOccurrence () <| clContext
90+
general
91+
<| Predicates.lastOccurrence ()
92+
<| clContext
8993

9094
let private generalInit<'a> predicate valueMap (clContext: ClContext) workGroupSize =
9195

src/GraphBLAS-sharp.Backend/Objects/ArraysExtentions.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ open Brahma.FSharp
44

55
module ArraysExtensions =
66
type ClArray<'a> with
7-
member this.Free(q: MailboxProcessor<Msg>) =
7+
member this.FreeAndWait(q: MailboxProcessor<Msg>) =
88
q.Post(Msg.CreateFreeMsg this)
99
q.PostAndReply(Msg.MsgNotifyMe)
1010

1111
member this.ToHost(q: MailboxProcessor<Msg>) =
1212
let dst = Array.zeroCreate this.Length
1313
q.PostAndReply(fun ch -> Msg.CreateToHostMsg(this, dst, ch))
1414

15-
// member this.Free(q: MailboxProcessor<_>) = q.Post <| Msg.CreateFreeMsg this TODO()
15+
member this.Free(q: MailboxProcessor<_>) = q.Post <| Msg.CreateFreeMsg this
1616

1717
member this.ToHostAndFree(q: MailboxProcessor<_>) =
1818
let result = this.ToHost q

src/GraphBLAS-sharp.Backend/Objects/Vector.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ type ClVector<'a when 'a: struct> =
3434
member this.Dispose(q) =
3535
match this with
3636
| Sparse vector -> vector.Dispose(q)
37-
| Dense vector -> vector.Free(q)
37+
| Dense vector -> vector.FreeAndWait(q)

src/GraphBLAS-sharp.Backend/Quotes/Predicates.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ module Predicates =
1111

1212
let inline lastOccurrence () =
1313
<@ fun (gid: int) (length: int) (inputArray: ClArray<'a>) ->
14-
gid = length - 1
15-
|| inputArray.[gid] <> inputArray.[gid + 1] @>
14+
gid = length - 1
15+
|| inputArray.[gid] <> inputArray.[gid + 1] @>
1616

1717
let inline firstOccurrence () =
1818
<@ fun (gid: int) (_: int) (inputArray: ClArray<'a>) ->
19-
gid = 0
20-
|| inputArray.[gid - 1] <> inputArray.[gid] @>
19+
gid = 0
20+
|| inputArray.[gid - 1] <> inputArray.[gid] @>

tests/GraphBLAS-sharp.Tests/Common/Reduce/ReduceByKey.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,10 @@ let testsSegmentsSequential2DOption =
458458

459459
let allTests =
460460
testList
461-
"Reduce.ByKey"
462-
[ sequentialTest
463-
oneWorkGroupTest
464-
sequentialSegmentTests
465-
sequential2DTest
466-
sequentialSegment2DTests
467-
testsSegmentsSequential2DOption ]
461+
"Reduce.ByKey"
462+
[ sequentialTest
463+
oneWorkGroupTest
464+
sequentialSegmentTests
465+
sequential2DTest
466+
sequentialSegment2DTests
467+
testsSegmentsSequential2DOption ]

tests/GraphBLAS-sharp.Tests/Vector/SpMV.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ let correctnessGenericTest
7777

7878
(ClMatrix.CSR m).Dispose q
7979
v.Free q
80-
let hostRes = res.ToHost q
81-
res.Free q
80+
let hostRes = res.ToHostAndFree q
8281

8382
checkResult isEqual sumOp mulOp zero matrix vector hostRes
8483
| _ -> failwith "Impossible"

0 commit comments

Comments
 (0)