Hoa Nguyen has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/29372 )
Change subject: python: Change m5's tick mechanism of rounding non
intergral ticks
......................................................................
python: Change m5's tick mechanism of rounding non intergral ticks
This commit changes m5's tick rounding mechanism from python's round()
to python's ceil() function.
Currently, non intergral ticks are rounded by round() function in python.
In python2, this function rounds values >= 0.5 to 1. However, in python3,
0.5 is rounded to 0. This causes the function to return 0 ticks for
non-zero second values, which doesn't make sense, and also causes
several tests to fail.
ceil() function is now used to round up the tick values. This makes more
sense as non-zero second values won't be rounded to zero in any cases.
Signed-off-by: Hoa Nguyen <hoangu...@ucdavis.edu>
Change-Id: I14c43e38e8c678f77baf13407f7eeff4b86f1014
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29372
Maintainer: Bobby R. Bruce <bbr...@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/python/m5/ticks.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved
Bobby R. Bruce: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/python/m5/ticks.py b/src/python/m5/ticks.py
index 64b7cb8..047116a 100644
--- a/src/python/m5/ticks.py
+++ b/src/python/m5/ticks.py
@@ -25,6 +25,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from __future__ import print_function
+from math import ceil
import six
if six.PY3:
long = int
@@ -73,7 +74,7 @@
# convert the value from time to ticks
value *= _m5.core.getClockFrequency()
- int_value = int(round(value))
+ int_value = int(ceil(value))
err = (value - int_value) / value
if err > frequency_tolerance:
warn("rounding error > tolerance\n %f rounded to %d", value,
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/29372
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: release-staging-v20.0.0.0
Gerrit-Change-Id: I14c43e38e8c678f77baf13407f7eeff4b86f1014
Gerrit-Change-Number: 29372
Gerrit-PatchSet: 2
Gerrit-Owner: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s