diff --git a/testing/cuda_timer.cu b/testing/cuda_timer.cu index 751bcd8..0c85a3b 100644 --- a/testing/cuda_timer.cu +++ b/testing/cuda_timer.cu @@ -3,28 +3,11 @@ #include #include +#include "sleep_kernel.cuh" #include "test_asserts.cuh" #include -#include - -#include - -__global__ void sleep_kernel(double seconds) -{ - const auto start = cuda::std::chrono::high_resolution_clock::now(); - const auto ns = cuda::std::chrono::nanoseconds( - static_cast(seconds * 1000 * 1000 * 1000)); - const auto finish = start + ns; - - auto now = cuda::std::chrono::high_resolution_clock::now(); - while (now < finish) - { - now = cuda::std::chrono::high_resolution_clock::now(); - } -} - void test_basic(cudaStream_t time_stream, cudaStream_t exec_stream, bool expected) diff --git a/testing/sleep_kernel.cuh b/testing/sleep_kernel.cuh new file mode 100644 index 0000000..2d18f87 --- /dev/null +++ b/testing/sleep_kernel.cuh @@ -0,0 +1,19 @@ +#pragma once + +#include + +#include + +__global__ void sleep_kernel(double seconds) +{ + const auto start = cuda::std::chrono::high_resolution_clock::now(); + const auto ns = cuda::std::chrono::nanoseconds( + static_cast(seconds * 1000 * 1000 * 1000)); + const auto finish = start + ns; + + auto now = cuda::std::chrono::high_resolution_clock::now(); + while (now < finish) + { + now = cuda::std::chrono::high_resolution_clock::now(); + } +}