Skip to content

Commit 89b3546

Browse files
committed
refactor: formatting
1 parent 33a7c7b commit 89b3546

16 files changed

Lines changed: 155 additions & 83 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ module BFS =
2525
let zeroCreate =
2626
ClArray.zeroCreate clContext workGroupSize CPUInterop
2727

28-
let ofList = Vector.ofList clContext workGroupSize GPUOnly
28+
let ofList =
29+
Vector.ofList clContext workGroupSize GPUOnly
2930

3031
let maskComplementedTo =
3132
DenseVector.elementWiseTo clContext Mask.complementedMaskOp workGroupSize

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ module ClArray =
6464

6565
let create = create clContext workGroupSize flag
6666

67-
fun (processor: MailboxProcessor<_>) length ->
68-
create processor length Unchecked.defaultof<'a>
67+
fun (processor: MailboxProcessor<_>) length -> create processor length Unchecked.defaultof<'a>
6968

7069
let copy (clContext: ClContext) workGroupSize flag =
7170
let copy =

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,11 @@ module COOMatrix =
316316

317317
let getTuples (clContext: ClContext) workGroupSize flag =
318318

319-
let copy = ClArray.copy clContext workGroupSize flag
319+
let copy =
320+
ClArray.copy clContext workGroupSize flag
320321

321-
let copyData = ClArray.copy clContext workGroupSize flag
322+
let copyData =
323+
ClArray.copy clContext workGroupSize flag
322324

323325
fun (processor: MailboxProcessor<_>) (matrix: ClMatrix.COO<'a>) ->
324326

@@ -348,7 +350,8 @@ module COOMatrix =
348350

349351
let program = clContext.Compile(compressRows)
350352

351-
let create = ClArray.create clContext workGroupSize flag
353+
let create =
354+
ClArray.create clContext workGroupSize flag
352355

353356
let scan =
354357
ClArray.prefixSumBackwardsIncludeInplace <@ min @> clContext workGroupSize
@@ -371,10 +374,14 @@ module COOMatrix =
371374
rowPointers
372375

373376
let toCSR (clContext: ClContext) workGroupSize flag =
374-
let prepare = compressRows clContext workGroupSize flag
377+
let prepare =
378+
compressRows clContext workGroupSize flag
375379

376-
let copy = ClArray.copy clContext workGroupSize flag
377-
let copyData = ClArray.copy clContext workGroupSize flag
380+
let copy =
381+
ClArray.copy clContext workGroupSize flag
382+
383+
let copyData =
384+
ClArray.copy clContext workGroupSize flag
378385

379386
fun (processor: MailboxProcessor<_>) (matrix: ClMatrix.COO<'a>) ->
380387
let rowPointers =
@@ -391,7 +398,8 @@ module COOMatrix =
391398
Values = vals }
392399

393400
let toCSRInplace (clContext: ClContext) workGroupSize flag =
394-
let prepare = compressRows clContext workGroupSize flag
401+
let prepare =
402+
compressRows clContext workGroupSize flag
395403

396404
fun (processor: MailboxProcessor<_>) (matrix: ClMatrix.COO<'a>) ->
397405
let rowPointers =
@@ -436,8 +444,12 @@ module COOMatrix =
436444
let transpose (clContext: ClContext) workGroupSize flag =
437445

438446
let transposeInplace = transposeInplace clContext workGroupSize
439-
let copy = ClArray.copy clContext workGroupSize flag
440-
let copyData = ClArray.copy clContext workGroupSize flag
447+
448+
let copy =
449+
ClArray.copy clContext workGroupSize flag
450+
451+
let copyData =
452+
ClArray.copy clContext workGroupSize flag
441453

442454
fun (queue: MailboxProcessor<_>) (matrix: ClMatrix.COO<'a>) ->
443455

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ module CSRMatrix =
2626

2727
let program = clContext.Compile(expandRowPointers)
2828

29-
let create = ClArray.create clContext workGroupSize flag
29+
let create =
30+
ClArray.create clContext workGroupSize flag
3031

3132
let scan =
3233
ClArray.prefixSumIncludeInplace <@ max @> clContext workGroupSize
@@ -53,8 +54,11 @@ module CSRMatrix =
5354
let prepare =
5455
expandRowPointers clContext workGroupSize flag
5556

56-
let copy = ClArray.copy clContext workGroupSize flag
57-
let copyData = ClArray.copy clContext workGroupSize flag
57+
let copy =
58+
ClArray.copy clContext workGroupSize flag
59+
60+
let copyData =
61+
ClArray.copy clContext workGroupSize flag
5862

5963
fun (processor: MailboxProcessor<_>) (matrix: ClMatrix.CSR<'a>) ->
6064
let rows =
@@ -88,7 +92,12 @@ module CSRMatrix =
8892
Values = matrix.Values }
8993

9094
///<remarks>Old version</remarks>
91-
let elementwiseWithCOO (clContext: ClContext) (opAdd: Expr<'a option -> 'b option -> 'c option>) workGroupSize flag =
95+
let elementwiseWithCOO
96+
(clContext: ClContext)
97+
(opAdd: Expr<'a option -> 'b option -> 'c option>)
98+
workGroupSize
99+
flag
100+
=
92101

93102
let prepareRows =
94103
expandRowPointers clContext workGroupSize flag
@@ -135,7 +144,8 @@ module CSRMatrix =
135144

136145
let transposeInplace (clContext: ClContext) workGroupSize flag =
137146

138-
let toCOOInplace = toCOOInplace clContext workGroupSize flag
147+
let toCOOInplace =
148+
toCOOInplace clContext workGroupSize flag
139149

140150
let transposeInplace =
141151
COOMatrix.transposeInplace clContext workGroupSize

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ open GraphBLAS.FSharp.Backend.Objects.ClMatrix
1010

1111
module Matrix =
1212
let copy (clContext: ClContext) workGroupSize flag =
13-
let copy = ClArray.copy clContext workGroupSize flag
13+
let copy =
14+
ClArray.copy clContext workGroupSize flag
1415

15-
let copyData = ClArray.copy clContext workGroupSize flag
16+
let copyData =
17+
ClArray.copy clContext workGroupSize flag
1618

1719
fun (processor: MailboxProcessor<_>) (matrix: ClMatrix<'a>) ->
1820
match matrix with
@@ -47,7 +49,9 @@ module Matrix =
4749
///<param name="clContext">OpenCL context.</param>
4850
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
4951
let toCSR (clContext: ClContext) workGroupSize flag =
50-
let toCSR = COOMatrix.toCSR clContext workGroupSize flag
52+
let toCSR =
53+
COOMatrix.toCSR clContext workGroupSize flag
54+
5155
let copy = copy clContext workGroupSize flag
5256

5357
let transpose =
@@ -103,7 +107,9 @@ module Matrix =
103107
///<param name="clContext">OpenCL context.</param>
104108
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
105109
let toCOO (clContext: ClContext) workGroupSize flag =
106-
let toCOO = CSRMatrix.toCOO clContext workGroupSize flag
110+
let toCOO =
111+
CSRMatrix.toCOO clContext workGroupSize flag
112+
107113
let copy = copy clContext workGroupSize flag
108114

109115
let transposeInplace =
@@ -162,7 +168,9 @@ module Matrix =
162168
///<param name="clContext">OpenCL context.</param>
163169
///<param name="workGroupSize">Should be a power of 2 and greater than 1.</param>
164170
let toCSC (clContext: ClContext) workGroupSize flag =
165-
let toCSR = COOMatrix.toCSR clContext workGroupSize flag
171+
let toCSR =
172+
COOMatrix.toCSR clContext workGroupSize flag
173+
166174
let copy = copy clContext workGroupSize flag
167175

168176
let transposeCSR =
@@ -352,7 +360,12 @@ module Matrix =
352360
|> ClMatrix.CSC
353361
| _ -> failwith "Matrix formats are not matching"
354362

355-
let elementwiseAtLeastOneToCOO (clContext: ClContext) (opAdd: Expr<AtLeastOne<'a, 'b> -> 'c option>) workGroupSize flag =
363+
let elementwiseAtLeastOneToCOO
364+
(clContext: ClContext)
365+
(opAdd: Expr<AtLeastOne<'a, 'b> -> 'c option>)
366+
workGroupSize
367+
flag
368+
=
356369
let COOElementwise =
357370
COOMatrix.elementwiseAtLeastOne clContext opAdd workGroupSize flag
358371

@@ -440,8 +453,11 @@ module Matrix =
440453
let COOtranspose =
441454
COOMatrix.transpose clContext workGroupSize flag
442455

443-
let copy = ClArray.copy clContext workGroupSize flag
444-
let copyData = ClArray.copy clContext workGroupSize flag
456+
let copy =
457+
ClArray.copy clContext workGroupSize flag
458+
459+
let copyData =
460+
ClArray.copy clContext workGroupSize flag
445461

446462
fun (processor: MailboxProcessor<_>) matrix ->
447463
match matrix with

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ module DenseVector =
126126
let kernel = clContext.Compile(getPositions)
127127

128128
fun (processor: MailboxProcessor<_>) (vector: ClArray<'a option>) ->
129-
let positions = clContext.CreateClArrayWithFlag(flag, vector.Length)
129+
let positions =
130+
clContext.CreateClArrayWithFlag(flag, vector.Length)
130131

131132
let ndRange =
132133
Range1D.CreateValid(vector.Length, workGroupSize)
@@ -159,7 +160,8 @@ module DenseVector =
159160

160161
let kernel = clContext.Compile(getValuesAndIndices)
161162

162-
let getPositions = getBitmap clContext workGroupSize GPUOnly
163+
let getPositions =
164+
getBitmap clContext workGroupSize GPUOnly
163165

164166
let prefixSum =
165167
PrefixSum.standardExcludeInplace clContext workGroupSize

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ module SparseVector =
152152
let prepare =
153153
preparePositions<'a, 'b, 'c> clContext op workGroupSize
154154

155-
let setPositions = setPositions clContext workGroupSize flag
155+
let setPositions =
156+
setPositions clContext workGroupSize flag
156157

157158
fun (processor: MailboxProcessor<_>) (leftVector: ClVector.Sparse<'a>) (rightVector: ClVector.Sparse<'b>) ->
158159

@@ -178,12 +179,7 @@ module SparseVector =
178179
Indices = resultIndices
179180
Size = max leftVector.Size rightVector.Size }
180181

181-
let elementWiseAtLeastOne
182-
(clContext: ClContext)
183-
opAdd
184-
workGroupSize
185-
flag
186-
=
182+
let elementWiseAtLeastOne (clContext: ClContext) opAdd workGroupSize flag =
187183
elementWise clContext (Convert.atLeastOneToOption opAdd) workGroupSize flag
188184

189185
let private preparePositionsFillSubVector<'a, 'b when 'a: struct and 'b: struct>
@@ -239,7 +235,8 @@ module SparseVector =
239235
let prepare =
240236
preparePositionsFillSubVector clContext op workGroupSize
241237

242-
let setPositions = setPositions clContext workGroupSize flag
238+
let setPositions =
239+
setPositions clContext workGroupSize flag
243240

244241
fun (processor: MailboxProcessor<_>) (leftVector: ClVector.Sparse<'a>) (rightVector: ClVector.Sparse<'b>) (value: ClCell<'a>) ->
245242

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ module Vector =
5050
Size = size }
5151
|> ClVector.Sparse
5252
| Dense ->
53-
let values = clContext.CreateClArrayWithFlag(GPUOnly, values)
54-
let indices = clContext.CreateClArrayWithFlag(GPUOnly, indices)
53+
let values =
54+
clContext.CreateClArrayWithFlag(GPUOnly, values)
5555

56-
let mappedValues =
57-
map processor values
56+
let indices =
57+
clContext.CreateClArrayWithFlag(GPUOnly, indices)
58+
59+
let mappedValues = map processor values
5860

5961
let result =
6062
clContext.CreateClArrayWithFlag(flag, size)
@@ -68,11 +70,14 @@ module Vector =
6870
ClVector.Dense result
6971

7072
let copy (clContext: ClContext) workGroupSize flag =
71-
let copy = ClArray.copy clContext workGroupSize flag
73+
let copy =
74+
ClArray.copy clContext workGroupSize flag
7275

73-
let copyData = ClArray.copy clContext workGroupSize flag
76+
let copyData =
77+
ClArray.copy clContext workGroupSize flag
7478

75-
let copyOptionData = ClArray.copy clContext workGroupSize flag
79+
let copyOptionData =
80+
ClArray.copy clContext workGroupSize flag
7681

7782
fun (processor: MailboxProcessor<_>) (vector: ClVector<'a>) ->
7883
match vector with
@@ -103,7 +108,8 @@ module Vector =
103108
let toDense =
104109
SparseVector.toDense clContext workGroupSize flag
105110

106-
let copy = ClArray.copy clContext workGroupSize flag
111+
let copy =
112+
ClArray.copy clContext workGroupSize flag
107113

108114
fun (processor: MailboxProcessor<_>) (vector: ClVector<'a>) ->
109115
match vector with

tests/GraphBLAS-sharp.Tests/Common/Copy.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ open Expecto.Logging.Message
66
open Brahma.FSharp
77
open GraphBLAS.FSharp.Tests
88
open GraphBLAS.FSharp.Backend.Common
9+
open GraphBLAS.FSharp.Backend.Objects.ClContext
910

1011
let logger = Log.create "Copy.Tests"
1112

@@ -22,7 +23,7 @@ let testCases =
2223
|> Array.filter (fun i -> array.Length % i = 0)
2324
|> Array.max
2425

25-
copy wgSize q
26+
copy wgSize CPUInterop q
2627

2728
let makeTest getCopyFun (array: array<'a>) filterFun =
2829
if array.Length > 0 then

tests/GraphBLAS-sharp.Tests/Common/Replicate.fs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ open Expecto.Logging.Message
66
open Brahma.FSharp
77
open GraphBLAS.FSharp.Backend.Common
88
open GraphBLAS.FSharp.Tests
9+
open GraphBLAS.FSharp.Backend.Objects.ClContext
910

1011
let logger = Log.create "Replicate.Tests"
1112

@@ -53,24 +54,24 @@ let testCases =
5354
|> Expect.sequenceEqual actual expected
5455

5556
[ testProperty "Correctness test on random int arrays"
56-
<| (let replicate = ClArray.replicate context
57+
<| (let replicate = ClArray.replicate context CPUInterop
5758
let getReplicateFun = getReplicateFun replicate
5859
fun (array: array<int>) -> makeTest getReplicateFun array id)
5960

6061
testProperty "Correctness test on random bool arrays"
61-
<| (let replicate = ClArray.replicate context
62+
<| (let replicate = ClArray.replicate context CPUInterop
6263
let getReplicateFun = getReplicateFun replicate
6364

6465
fun (array: array<bool>) -> makeTest getReplicateFun array id)
6566

6667
testProperty "Correctness test on random float arrays"
67-
<| (let replicate = ClArray.replicate context
68+
<| (let replicate = ClArray.replicate context CPUInterop
6869
let getReplicateFun = getReplicateFun replicate
6970

7071
fun (array: array<float>) -> makeTest getReplicateFun array (Array.filter (System.Double.IsNaN >> not)))
7172

7273
testProperty "Correctness test on random byte arrays"
73-
<| (let replicate = ClArray.replicate context
74+
<| (let replicate = ClArray.replicate context CPUInterop
7475
let getReplicateFun = getReplicateFun replicate
7576

7677
fun (array: array<byte>) -> makeTest getReplicateFun array id)

0 commit comments

Comments
 (0)