Skip to content

Improved precision of timeit #3185

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 1 commit into from
Mar 10, 2022
Merged

Conversation

willyborn
Copy link
Contributor

The variance of the returned timing is reduced.
Now the median of multiple measures is returned in stead of the mean, so that outliers have less impact on the result.
The function also runs for at least 3 consecutive times (or 50ms), giving the possibility to measure the overlapping between CPU and GPU. This can result in lower, although more correct readings, especially for fast functions.

Description

When measuring an empty function {}, the returned timing was 1/700 lower (1.2ps vs 800ps). This is, because the number of cycles is automatically increased to obtain 50ms for each measure.
For slow functions, at least 3 cycles are used for the measure.
In total 0.5s is the typical total time for the function to return.

The variance has now become small enough, so that also faster functions can be compared on speed progress.
A comparison, between old and new, on af::constant() can be found in timeit.xlsx

  • Is this a new feature or a bug fix? Improvement
  • Why these changes are necessary. The variance on small arrays is too high for correct comparison.
  • Potential impact on specific hardware, software or back-ends. None
  • New functions and their functionality. No change to API, faster is most cases.
  • Can this PR be back-ported to older versions? Yes
  • Future changes not implemented in this PR.

Changes to Users

The returned time will be of higher quality.

Checklist

  • Rebased on latest master
  • Code compiles
  • Tests pass
  • [-] Functions added to unified API
  • [-] Functions documented

@umar456 umar456 merged commit e7625d1 into arrayfire:master Mar 10, 2022
@willyborn willyborn deleted the timeit-LowerStdDev branch September 29, 2022 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants