From 2accc2be54d3f9ad20d15f21bca6397ef6cabf92 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Tue, 20 Feb 2024 16:03:38 -0500 Subject: Rewrite clock rate synchronization code to increase accuracy Mirrors architecture used for instantaneous clock synchronization. The PPM (parts-per-million) error after a two-second synchronization period (using results from new implementation after a 100-second synchronization period as ground truth, as after 100 seconds, the new and old implementation disagree by at most 2 PPM). GPU (machine name) Before After ------------------------------ ------ ------ GTX 1060 3 GiB (jbakita-old): 12 1 GTX 970 (jbakita-old): 9 2 GTX 1080 Ti (yamaha): 5 1 RTX 6000 Ada (yamaha): 4 2 (An error of 1 PPM is 1 microsecond per second.) Also modify `preemption_logger` to print the rate of skew as PPM, rather than just as a multiplier. --- preemption_logger.cu | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'preemption_logger.cu') diff --git a/preemption_logger.cu b/preemption_logger.cu index 89b348a..ec3c22e 100644 --- a/preemption_logger.cu +++ b/preemption_logger.cu @@ -90,10 +90,11 @@ int main(int argc, char **argv) { // Synchronize the GPU and CPU clocks (if requested) using the utilities // from task_host_utilities.cu. if (!skip_conversion) { - // Note that this appears to almost always be 1.0 on recent GPUs - d2h_scale = GetGPUTimerScale(0); + // The skew is between -13 and 60 microseconds per second on the GTX + // 1080, GTX 1060 3 GiB, GTX 970, RTX 6000 Ada, and GTX 1080 Ti. + d2h_scale = InternalGetGPUTimerScale(0); InternalReadGPUNanoseconds(0, &host_s, &dev_ns); - if (host_s == 0 && !dev_ns) { + if (d2h_scale == -1 || (host_s == 0 && !dev_ns)) { fprintf(stderr, "Unable to synchronize time with the GPU. Aborting...\n"); return 1; } @@ -153,7 +154,9 @@ int main(int argc, char **argv) { fprintf(stderr, "(%d) Aprox launch overhead: %ld ns\n", pid, launch_oh); fprintf(stderr, "(%d) CPU clock - GPU clock: %ld tick gap\n", pid, (long)s2ns(host_s) - dev_ns); - fprintf(stderr, "(%d) 1 CPU tick/1 GPU tick: %.3f\n", pid, d2h_scale); + fprintf(stderr, "(%d) After 1 second, the GPU clock is %.f us %s (%.9fx d2h)\n", + pid, fabs((d2h_scale - 1) * 1e6), + d2h_scale > 1 ? "behind" : "ahead", d2h_scale); } return 0; -- cgit v1.2.2