Skip to content

Commit 4c620c6

Browse files
committed
Formatting
1 parent 11e7e32 commit 4c620c6

6 files changed

Lines changed: 31 additions & 77 deletions

File tree

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksEWiseAdd.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ type EWiseAddBenchmarks4BoolCSRWithoutDataTransfer() =
340340
type EWiseAddAtLeastOneBenchmarks4BoolCOOWithoutDataTransfer() =
341341

342342
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.COOMatrix<bool>,bool>(
343-
(fun context wgSize -> Backend.COOMatrix.eWiseAdd2 context Backend.Common.StandardOperations.boolSum2 wgSize),
343+
(fun context wgSize -> Backend.COOMatrix.eWiseAddAtLeastOne context Backend.Common.StandardOperations.boolSumAtLeastOne wgSize),
344344
(fun _ -> true),
345345
(fun _ -> true),
346346
M.buildCooMatrix
@@ -352,7 +352,7 @@ type EWiseAddAtLeastOneBenchmarks4BoolCOOWithoutDataTransfer() =
352352
type EWiseAddAtLeastOneBenchmarks4BoolCSRWithoutDataTransfer() =
353353

354354
inherit EWiseAddBenchmarksWithoutDataTransfer<Backend.CSRMatrix<bool>,bool>(
355-
(fun context wgSize -> Backend.CSRMatrix.eWiseAdd2 context Backend.Common.StandardOperations.boolSum2 wgSize),
355+
(fun context wgSize -> Backend.CSRMatrix.eWiseAddAtLeastOne context Backend.Common.StandardOperations.boolSumAtLeastOne wgSize),
356356
(fun _ -> true),
357357
(fun _ -> true),
358358
M.buildCsrMatrix

benchmarks/GraphBLAS-sharp.Benchmarks/Helpers.fs

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,6 @@ type CommonConfig() =
3838
)
3939
|> ignore
4040

41-
type ClContext =
42-
| ClContext of Brahma.FSharp.ClContext
43-
override this.ToString() =
44-
let mutable e = ErrorCode.Unknown
45-
let (ClContext context) = this
46-
let device = context.ClDevice.Device
47-
48-
let deviceName =
49-
Cl
50-
.GetDeviceInfo(device, DeviceInfo.Name, &e)
51-
.ToString()
52-
53-
if deviceName.Length < 20 then
54-
sprintf "%s" deviceName
55-
else
56-
let platform =
57-
Cl
58-
.GetDeviceInfo(device, DeviceInfo.Platform, &e)
59-
.CastTo<Platform>()
60-
61-
let platformName =
62-
Cl
63-
.GetPlatformInfo(platform, PlatformInfo.Name, &e)
64-
.ToString()
65-
66-
let deviceType =
67-
match Cl
68-
.GetDeviceInfo(device, DeviceInfo.Type, &e)
69-
.CastTo<DeviceType>() with
70-
| DeviceType.Cpu -> "CPU"
71-
| DeviceType.Gpu -> "GPU"
72-
| DeviceType.Accelerator -> "Accelerator"
73-
| _ -> "another"
74-
75-
sprintf "%s, %s" platformName deviceType
76-
7741
type MatrixShapeColumn(columnName: string, getShape: (MtxReader * MtxReader) -> int) =
7842
interface IColumn with
7943
member this.AlwaysShow: bool = true
@@ -238,14 +202,17 @@ module Utils =
238202
| DeviceType.Default -> ClDeviceType.Default
239203
| _ -> failwith "Unsupported"
240204

241-
let device = ClDevice.GetFirstAppropriateDevice(clPlatform)
205+
let device =
206+
ClDevice.GetFirstAppropriateDevice(clPlatform)
207+
242208
let translator = FSQuotationToOpenCLTranslator device
243209

244-
let context = Brahma.FSharp.ClContext(device, translator)
210+
let context =
211+
Brahma.FSharp.ClContext(device, translator)
212+
245213
let queue = context.QueueProvider.CreateQueue()
246214

247-
{ ClContext = context
248-
Queue = queue })
215+
{ ClContext = context; Queue = queue })
249216

250217
seq {
251218
for wgSize in workGroupSizes do

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,7 @@ module ClArray =
306306
else
307307
isUniqueBitmap.[i] <- 1 @>
308308

309-
let kernel =
310-
clContext.Compile(getUniqueBitmap)
309+
let kernel = clContext.Compile(getUniqueBitmap)
311310

312311
fun (processor: MailboxProcessor<_>) workGroupSize (inputArray: ClArray<'a>) ->
313312

@@ -336,7 +335,7 @@ module ClArray =
336335
let setPositions (clContext: ClContext) =
337336

338337
let setPositions =
339-
<@ fun (ndRange: Range1D) (inputArray: ClArray<'a>) inputLength (positions: ClArray<int>) (outputArray: ClArray<'a>) ->
338+
<@ fun (ndRange: Range1D) (inputArray: ClArray<int>) inputLength (positions: ClArray<int>) (outputArray: ClArray<int>) ->
340339

341340
let i = ndRange.GlobalID0
342341

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ module COOMatrix =
2525
resultColumnsBuffer.[index] <- allColumnsBuffer.[i]
2626
resultValuesBuffer.[index] <- allValuesBuffer.[i] @>
2727

28-
let kernel =
29-
clContext.Compile(setPositions)
28+
let kernel = clContext.Compile(setPositions)
3029

3130
let sum =
3231
GraphBLAS.FSharp.Backend.ClArray.prefixSumExcludeInplace clContext workGroupSize
@@ -135,8 +134,7 @@ module COOMatrix =
135134
rawPositionsBuffer.[i] <- 1
136135
| None -> rawPositionsBuffer.[i] <- 0 @>
137136

138-
let kernel =
139-
clContext.Compile(preparePositions)
137+
let kernel = clContext.Compile(preparePositions)
140138

141139
fun (processor: MailboxProcessor<_>) (allRows: ClArray<int>) (allColumns: ClArray<int>) (leftValues: ClArray<'a>) (rightValues: ClArray<'b>) (isLeft: ClArray<int>) ->
142140
let length = leftValues.Length
@@ -491,14 +489,11 @@ module COOMatrix =
491489
if i < totalSum then
492490
expandedNnzPerRow.[nonZeroRowsIndices.[i] + 1] <- nnzPerRowSparse.[i] @>
493491

494-
let kernelCalcHyperSparseRows =
495-
clContext.Compile(calcHyperSparseRows)
492+
let kernelCalcHyperSparseRows = clContext.Compile(calcHyperSparseRows)
496493

497-
let kernelCalcNnzPerRowSparse =
498-
clContext.Compile(calcNnzPerRowSparse)
494+
let kernelCalcNnzPerRowSparse = clContext.Compile(calcNnzPerRowSparse)
499495

500-
let kernelExpandNnzPerRow =
501-
clContext.Compile(expandNnzPerRow)
496+
let kernelExpandNnzPerRow = clContext.Compile(expandNnzPerRow)
502497

503498
let getUniqueBitmap = ClArray.getUniqueBitmap clContext
504499

@@ -701,8 +696,7 @@ module COOMatrix =
701696
rawPositionsBuffer.[i] <- 1
702697
| None -> rawPositionsBuffer.[i] <- 0 @>
703698

704-
let kernel =
705-
clContext.Compile(preparePositions)
699+
let kernel = clContext.Compile(preparePositions)
706700

707701
fun (processor: MailboxProcessor<_>) (allRows: ClArray<int>) (allColumns: ClArray<int>) (leftValues: ClArray<'a>) (rightValues: ClArray<'b>) (isLeft: ClArray<int>) ->
708702
let length = leftValues.Length

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module Matrix =
7272
COOMatrix.eWiseAddAtLeastOne clContext opAdd workGroupSize
7373

7474
let CSReWiseAdd =
75-
CSRMatrix.eWiseAdd2 clContext opAdd workGroupSize
75+
CSRMatrix.eWiseAddAtLeastOne clContext opAdd workGroupSize
7676

7777
fun (processor: MailboxProcessor<_>) matrix1 matrix2 ->
7878
match matrix1, matrix2 with

tests/GraphBLAS-sharp.Tests/BackendCommonTests/MatrixEwiseAddTests.fs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,35 +95,31 @@ let testFixtures case =
9595
let q = case.ClContext.Queue
9696
q.Error.Add(fun e -> failwithf "%A" e)
9797

98-
let boolAdd =
99-
Matrix.eWiseAdd context boolSum wgSize
98+
let boolAdd = Matrix.eWiseAdd context boolSum wgSize
10099

101100
let boolToCOO = Matrix.toCOO context wgSize
102101

103102
case
104103
|> correctnessGenericTest false (||) boolAdd boolToCOO (=) q
105104
|> testPropertyWithConfig config (getCorrectnessTestName "bool")
106105

107-
let intAdd =
108-
Matrix.eWiseAdd context intSum wgSize
106+
let intAdd = Matrix.eWiseAdd context intSum wgSize
109107

110108
let intToCOO = Matrix.toCOO context wgSize
111109

112110
case
113111
|> correctnessGenericTest 0 (+) intAdd intToCOO (=) q
114112
|> testPropertyWithConfig config (getCorrectnessTestName "int")
115113

116-
let floatAdd =
117-
Matrix.eWiseAdd context floatSum wgSize
114+
let floatAdd = Matrix.eWiseAdd context floatSum wgSize
118115

119116
let floatToCOO = Matrix.toCOO context wgSize
120117

121118
case
122119
|> correctnessGenericTest 0.0 (+) floatAdd floatToCOO (fun x y -> abs (x - y) < Accuracy.medium.absolute) q
123120
|> testPropertyWithConfig config (getCorrectnessTestName "float")
124121

125-
let byteAdd =
126-
Matrix.eWiseAdd context byteSum wgSize
122+
let byteAdd = Matrix.eWiseAdd context byteSum wgSize
127123

128124
let byteToCOO = Matrix.toCOO context wgSize
129125

@@ -143,12 +139,11 @@ let tests =
143139
.GetDeviceInfo(device, DeviceInfo.Type, &e)
144140
.CastTo<DeviceType>()
145141

146-
deviceType = DeviceType.Gpu
147-
)
142+
deviceType = DeviceType.Gpu)
148143
|> List.collect testFixtures
149144
|> testList "Backend.Matrix.eWiseAdd tests"
150145

151-
let testFixtures2 case =
146+
let testFixturesAtLeastOne case =
152147
[ let config = defaultConfig
153148
let wgSize = 256
154149

@@ -160,7 +155,7 @@ let testFixtures2 case =
160155
q.Error.Add(fun e -> failwithf "%A" e)
161156

162157
let boolAdd =
163-
Matrix.eWiseAdd2 context boolSum2 wgSize
158+
Matrix.eWiseAddAtLeastOne context boolSumAtLeastOne wgSize
164159

165160
let boolToCOO = Matrix.toCOO context wgSize
166161

@@ -169,7 +164,7 @@ let testFixtures2 case =
169164
|> testPropertyWithConfig config (getCorrectnessTestName "bool")
170165

171166
let intAdd =
172-
Matrix.eWiseAdd2 context intSum2 wgSize
167+
Matrix.eWiseAddAtLeastOne context intSumAtLeastOne wgSize
173168

174169
let intToCOO = Matrix.toCOO context wgSize
175170

@@ -178,7 +173,7 @@ let testFixtures2 case =
178173
|> testPropertyWithConfig config (getCorrectnessTestName "int")
179174

180175
let floatAdd =
181-
Matrix.eWiseAdd2 context floatSum2 wgSize
176+
Matrix.eWiseAddAtLeastOne context floatSumAtLeastOne wgSize
182177

183178
let floatToCOO = Matrix.toCOO context wgSize
184179

@@ -187,7 +182,7 @@ let testFixtures2 case =
187182
|> testPropertyWithConfig config (getCorrectnessTestName "float")
188183

189184
let byteAdd =
190-
Matrix.eWiseAdd2 context byteSum2 wgSize
185+
Matrix.eWiseAddAtLeastOne context byteSumAtLeastOne wgSize
191186

192187
let byteToCOO = Matrix.toCOO context wgSize
193188

@@ -207,7 +202,6 @@ let tests2 =
207202
.GetDeviceInfo(device, DeviceInfo.Type, &e)
208203
.CastTo<DeviceType>()
209204

210-
deviceType = DeviceType.Gpu
211-
)
212-
|> List.collect testFixtures2
213-
|> testList "Backend.Matrix.eWiseAdd2 tests"
205+
deviceType = DeviceType.Gpu)
206+
|> List.collect testFixturesAtLeastOne
207+
|> testList "Backend.Matrix.eWiseAddAtLeastOne tests"

0 commit comments

Comments
 (0)