Skip to content

Commit ae8f51d

Browse files
authored
[STF] Adapt timing_with_fences test to be more reliable (#2658)
* Change the timing_with_fences test to be compatible with a system that is very busy * Do not make expectations about timers
1 parent f5d497c commit ae8f51d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

cudax/test/stf/utility/timing_with_fences.cu

+11-5
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@ void run(int NTASKS, int ms)
6565

6666
ctx.finalize();
6767

68-
float elapsed;
68+
[[maybe_unused]] float elapsed;
6969
cuda_safe_call(cudaEventElapsedTime(&elapsed, start, stop));
7070

71-
// Give 25% margin of error
72-
float expected = 1.0f * NTASKS * ms;
73-
float err = fabs(elapsed - expected) / expected;
74-
EXPECT(err < 0.25f);
71+
[[maybe_unused]] float expected = 1.0f * NTASKS * ms;
72+
73+
/* We cannot really expect this measurement to be accurate because the
74+
* thread(s) executing the code might be preempted on a system with a high load
75+
* (as during unit tests). So the best we can expect is that the elapsed time
76+
* is larger than the sleep time, but event the timer on the GPU is not
77+
* perfectly accurate so we do not make any strict assumptions about the
78+
* test, and just keep this test to demonstrate how to use the mechanisms,
79+
* and ensure they are functional . */
80+
// EXPECT(elapsed >= expected);
7581
}
7682

7783
int main(int argc, char** argv)

0 commit comments

Comments
 (0)