summaryrefslogtreecommitdiffstats
path: root/task_host_utilities.cu
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2024-02-19 20:39:39 -0500
committerJoshua Bakita <bakitajoshua@gmail.com>2024-02-19 20:39:39 -0500
commitcd9ee070e2fcaa49fe35944ea0fd60ed5d197ba2 (patch)
treecb31473e1793e383a06dd0b560c7ab83374040ff /task_host_utilities.cu
parent18641058a2d60e172f18176b41d51baa706ffd85 (diff)
Split SAFE() macro into API-specific typed variants
Avoids incorrectly interpreting CUDA Driver Library error codes as though they were CUDA Runtime Library error codes (the numbering is similar, but not identical). Also cleans up how we initialize and terminate a context for capability checking in `mon_cross_ctx_copies`.
Diffstat (limited to 'task_host_utilities.cu')
-rw-r--r--task_host_utilities.cu6
1 files changed, 4 insertions, 2 deletions
diff --git a/task_host_utilities.cu b/task_host_utilities.cu
index 9bb95aa..1f76080 100644
--- a/task_host_utilities.cu
+++ b/task_host_utilities.cu
@@ -4,6 +4,7 @@
4// been copied and heavily modified for use in the gpu-microbench project. 4// been copied and heavily modified for use in the gpu-microbench project.
5#include <cuda_runtime.h> 5#include <cuda_runtime.h>
6#include <errno.h> 6#include <errno.h>
7#include <sched.h>
7#include <stdint.h> 8#include <stdint.h>
8#include <stdio.h> 9#include <stdio.h>
9#include <string.h> 10#include <string.h>
@@ -191,8 +192,8 @@ static void InternalReadGPUNanoseconds(int cuda_device, double *cpu_time,
191 if (!CheckCUDAError(cudaMemcpy(gpu_time, device_time, sizeof(device_time), 192 if (!CheckCUDAError(cudaMemcpy(gpu_time, device_time, sizeof(device_time),
192 cudaMemcpyDeviceToHost))) goto out; 193 cudaMemcpyDeviceToHost))) goto out;
193 max_error = (cpu_end - cpu_start) / 2.0; 194 max_error = (cpu_end - cpu_start) / 2.0;
194 fprintf(stderr, "Time synchronized to a maximum error of +/- %f us.\n", 195 fprintf(stderr, "Time synchronized to a maximum error of +/- %f us on CPU%d.\n",
195 max_error * (1000.0 * 1000.0)); 196 max_error * (1000.0 * 1000.0), sched_getcpu());
196out: 197out:
197 cudaFree(device_time); 198 cudaFree(device_time);
198 cudaFree((void*)start_barrier); 199 cudaFree((void*)start_barrier);
@@ -200,6 +201,7 @@ out:
200 cudaFree((void*)ready_barrier); 201 cudaFree((void*)ready_barrier);
201} 202}
202 203
204// Returns 0 on success, 1 on error
203int GetHostDeviceTimeOffset(int cuda_device, double *host_seconds, 205int GetHostDeviceTimeOffset(int cuda_device, double *host_seconds,
204 uint64_t *gpu_nanoseconds) { 206 uint64_t *gpu_nanoseconds) {
205 uint64_t *shared_gpu_time = NULL; 207 uint64_t *shared_gpu_time = NULL;