Skip to content

Fix benchmark suite on 32-bit platforms #17268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmark/single-source/RandomValues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public func run_RandomIntegersDef(_ N: Int) {
@inline(never)
public func run_RandomIntegersLCG(_ N: Int) {
for _ in 0 ..< N {
var x = 0
var x: Int64 = 0
var generator = LCRNG(seed: 0)
for _ in 0 ..< 100_000 {
x &+= Int.random(in: 0...10_000, using: &generator)
x &+= Int64.random(in: 0...10_000, using: &generator)
}
CheckResults(x == 498214315)
}
Expand Down
4 changes: 4 additions & 0 deletions benchmark/utils/DriverUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ func runBench(_ test: Test, _ c: TestConfig) -> BenchResults? {
// Compute the scaling factor if a fixed c.fixedNumIters is not specified.
scale = c.fixedNumIters
}
// Make integer overflow less likely on platforms where Int is 32 bits wide.
// FIXME: Switch BenchmarkInfo to use Int64 for the iteration scale, or fix
// benchmarks to not let scaling get off the charts.
scale = min(scale, UInt(Int.max) / 10_000)

// Rerun the test with the computed scale factor.
if scale > 1 {
Expand Down