From f0f4d2482dbb9f9e27ebb6fbe41482850f93ce5f Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Wed, 28 Feb 2018 15:20:42 +0100 Subject: [PATCH 1/2] Fix math domain error in decaying poll rate * Check that `self._a` is not smaller that a minimum allowed value. --- reframe/frontend/executors/policies.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reframe/frontend/executors/policies.py b/reframe/frontend/executors/policies.py index c85fb0ee76..0e790f1e37 100644 --- a/reframe/frontend/executors/policies.py +++ b/reframe/frontend/executors/policies.py @@ -65,6 +65,8 @@ def run_check(self, check, partition, environ): class PollRateFunction: + _min_a = 0.01 + def __init__(self, min_rate, decay_time): self._min_rate = min_rate self._decay = decay_time @@ -79,6 +81,8 @@ def _init_poll_fn(self, init_rate): self._init_rate = init_rate self._b = self._min_rate self._a = init_rate - self._b + if self._a < self._min_a: + self._a = self._min_a self._c = math.log(self._a / (self._thres*self._b)) / self._decay getlogger().debug('rate equation: %.3f*exp(-%.3f*x)+%.3f' % (self._a, self._c, self._b)) From de0ee0edbf82b99c0413f9e017b53557608500ee Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Thu, 1 Mar 2018 15:24:09 +0100 Subject: [PATCH 2/2] Address PR comments --- reframe/frontend/executors/policies.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/reframe/frontend/executors/policies.py b/reframe/frontend/executors/policies.py index 0e790f1e37..c601d3b2bc 100644 --- a/reframe/frontend/executors/policies.py +++ b/reframe/frontend/executors/policies.py @@ -65,8 +65,6 @@ def run_check(self, check, partition, environ): class PollRateFunction: - _min_a = 0.01 - def __init__(self, min_rate, decay_time): self._min_rate = min_rate self._decay = decay_time @@ -80,10 +78,14 @@ def __init__(self, min_rate, decay_time): def _init_poll_fn(self, init_rate): self._init_rate = init_rate self._b = self._min_rate - self._a = init_rate - self._b - if self._a < self._min_a: - self._a = self._min_a - self._c = math.log(self._a / (self._thres*self._b)) / self._decay + log_arg = (init_rate - self._b) / (self._thres*self._b) + if log_arg < sys.float_info.min: + self._a = 0.0 + self._c = 0.0 + else: + self._a = init_rate - self._b + self._c = math.log(self._a / (self._thres*self._b)) / self._decay + getlogger().debug('rate equation: %.3f*exp(-%.3f*x)+%.3f' % (self._a, self._c, self._b))