Skip to content

Commit add9637

Browse files
committed
Fix COO matrix init in EWiseAdd benchmarks
1 parent cb6b43c commit add9637

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

benchmarks/GraphBLAS-sharp.Benchmarks/BenchmarksEWiseAdd.fs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ with
4646

4747
[<MinColumn; MaxColumn>]
4848
[<Config(typeof<Config>)>]
49-
[<SimpleJob(RunStrategy.Monitoring, targetCount=3)>]
49+
[<SimpleJob(RunStrategy.Monitoring, targetCount=1)>]
5050
type EWiseAddBenchmarks4Float32() =
5151
let mutable leftCOO = Unchecked.defaultof<Matrix<float32>>
5252
let mutable rightCOO = Unchecked.defaultof<Matrix<float32>>
@@ -92,23 +92,37 @@ type EWiseAddBenchmarks4Float32() =
9292

9393
[<IterationSetup(Target="EWiseAdditionCOO")>]
9494
member this.BuildCOO() =
95+
let leftRows = Array.zeroCreate<int> firstMatrix.Rows.Length
96+
let leftCols = Array.zeroCreate<int> firstMatrix.Columns.Length
97+
let leftVals = Array.zeroCreate<float32> firstMatrix.Values.Length
98+
Array.blit firstMatrix.Rows 0 leftRows 0 firstMatrix.Rows.Length
99+
Array.blit firstMatrix.Columns 0 leftCols 0 firstMatrix.Columns.Length
100+
Array.blit firstMatrix.Values 0 leftVals 0 firstMatrix.Values.Length
101+
95102
leftCOO <-
96103
Matrix.Build<float32>(
97104
firstMatrix.RowCount,
98105
firstMatrix.ColumnCount,
99-
firstMatrix.Rows,
100-
firstMatrix.Columns,
101-
firstMatrix.Values,
106+
leftRows,
107+
leftCols,
108+
leftVals,
102109
COO
103110
)
104111

112+
let rightRows = Array.zeroCreate<int> secondMatrix.Rows.Length
113+
let rightCols = Array.zeroCreate<int> secondMatrix.Columns.Length
114+
let rightVals = Array.zeroCreate<float32> secondMatrix.Values.Length
115+
Array.blit secondMatrix.Rows 0 rightRows 0 secondMatrix.Rows.Length
116+
Array.blit secondMatrix.Columns 0 rightCols 0 secondMatrix.Columns.Length
117+
Array.blit secondMatrix.Values 0 rightVals 0 secondMatrix.Values.Length
118+
105119
rightCOO <-
106120
Matrix.Build<float32>(
107121
secondMatrix.RowCount,
108122
secondMatrix.ColumnCount,
109-
secondMatrix.Rows,
110-
secondMatrix.Columns,
111-
secondMatrix.Values,
123+
rightRows,
124+
rightCols,
125+
rightVals,
112126
COO
113127
)
114128

@@ -238,9 +252,3 @@ type EWiseAddBenchmarks4Float32() =
238252
let deviceType = Cl.GetDeviceInfo(device, DeviceInfo.Type, &e).CastTo<DeviceType>()
239253
OpenCLEvaluationContext(platformName, deviceType) |> ClContext
240254
)
241-
242-
// не уверен, что на каждой итерации трансфер данных снова происходит
243-
// тк ссылка на массивы присваивается одна и та же
244-
// надо бы каждый раз в iterationSetup делать глубокую копию исходных массивов
245-
246-
// нужен ToString для OpenCLEvaliationContext -- печатал бы DeviceInfo.Name

0 commit comments

Comments
 (0)