Skip to content

Commit 473dcf5

Browse files
test: make test_omp_get_wtime deterministic (#77)
The busy-wait asserted elapsed time within 5 ms (places=2). CI runner preemption past the deadline failed the macOS job intermittently. Timing accuracy belongs to libomp, not PyOMP. Keep binding coverage: omp_get_wtime is the only float64-returning _OpenmpExternalFunction, so the test checks a positive float from both njit and interpreted calls. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 23a8f34 commit 473dcf5

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

‎src/numba/openmp/tests/test_openmp.py‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4775,21 +4775,13 @@ def test_impl():
47754775

47764776
def test_omp_get_wtime(self):
47774777
@njit
4778-
def test_impl(t):
4779-
start = omp_get_wtime()
4780-
while start + t > omp_get_wtime():
4781-
continue
4782-
return omp_get_wtime() - start
4783-
4784-
t = 0.25
4785-
delay = test_impl(t)
4786-
self.assertAlmostEqual(delay, t, places=2)
4787-
4788-
start = omp_get_wtime()
4789-
while start + t > omp_get_wtime():
4790-
continue
4791-
delay = omp_get_wtime() - start
4792-
self.assertAlmostEqual(delay, t, places=2)
4778+
def test_impl():
4779+
return omp_get_wtime()
4780+
4781+
for wtime in (test_impl, omp_get_wtime):
4782+
t = wtime()
4783+
self.assertIsInstance(t, float)
4784+
self.assertGreater(t, 0.0)
47934785

47944786
@linux_only
47954787
def test_omp_get_num_devices(self):

0 commit comments

Comments
 (0)