summaryrefslogtreecommitdiffstats
path: root/preemption_logger.cu
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2024-02-20 16:03:38 -0500
committerJoshua Bakita <bakitajoshua@gmail.com>2024-02-20 16:03:38 -0500
commit2accc2be54d3f9ad20d15f21bca6397ef6cabf92 (patch)
tree34f9d054f798173bdb3c610eadd2e17d201fb01b /preemption_logger.cu
parentd90826c1cc5f03fdc0aaef5bf20c57aec6556940 (diff)
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.
Diffstat (limited to 'preemption_logger.cu')
-rw-r--r--preemption_logger.cu11
1 files changed, 7 insertions, 4 deletions
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) {
90 // Synchronize the GPU and CPU clocks (if requested) using the utilities 90 // Synchronize the GPU and CPU clocks (if requested) using the utilities
91 // from task_host_utilities.cu. 91 // from task_host_utilities.cu.
92 if (!skip_conversion) { 92 if (!skip_conversion) {
93 // Note that this appears to almost always be 1.0 on recent GPUs 93 // The skew is between -13 and 60 microseconds per second on the GTX
94 d2h_scale = GetGPUTimerScale(0); 94 // 1080, GTX 1060 3 GiB, GTX 970, RTX 6000 Ada, and GTX 1080 Ti.
95 d2h_scale = InternalGetGPUTimerScale(0);
95 InternalReadGPUNanoseconds(0, &host_s, &dev_ns); 96 InternalReadGPUNanoseconds(0, &host_s, &dev_ns);
96 if (host_s == 0 && !dev_ns) { 97 if (d2h_scale == -1 || (host_s == 0 && !dev_ns)) {
97 fprintf(stderr, "Unable to synchronize time with the GPU. Aborting...\n"); 98 fprintf(stderr, "Unable to synchronize time with the GPU. Aborting...\n");
98 return 1; 99 return 1;
99 } 100 }
@@ -153,7 +154,9 @@ int main(int argc, char **argv) {
153 fprintf(stderr, "(%d) Aprox launch overhead: %ld ns\n", pid, launch_oh); 154 fprintf(stderr, "(%d) Aprox launch overhead: %ld ns\n", pid, launch_oh);
154 fprintf(stderr, "(%d) CPU clock - GPU clock: %ld tick gap\n", pid, 155 fprintf(stderr, "(%d) CPU clock - GPU clock: %ld tick gap\n", pid,
155 (long)s2ns(host_s) - dev_ns); 156 (long)s2ns(host_s) - dev_ns);
156 fprintf(stderr, "(%d) 1 CPU tick/1 GPU tick: %.3f\n", pid, d2h_scale); 157 fprintf(stderr, "(%d) After 1 second, the GPU clock is %.f us %s (%.9fx d2h)\n",
158 pid, fabs((d2h_scale - 1) * 1e6),
159 d2h_scale > 1 ? "behind" : "ahead", d2h_scale);
157 } 160 }
158 161
159 return 0; 162 return 0;