From eb8bcefdd947da28010d56440718c12f516b91d0 Mon Sep 17 00:00:00 2001 From: Joongi Kim Date: Wed, 24 Feb 2016 00:19:25 +0900 Subject: [PATCH] refs #27: Add unit test stubs for CUDA * I've found alignment issues in complex/nested structs in CUDA; we need some thorough tests for them! --- include/nba/engines/cuda/test.hh | 5 +++ include/nba/framework/datablock_shared.hh | 1 - src/engines/cuda/test.cu | 16 ++++++++++ tests/test_cuda.cc | 37 +++++++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 include/nba/engines/cuda/test.hh create mode 100644 src/engines/cuda/test.cu create mode 100644 tests/test_cuda.cc diff --git a/include/nba/engines/cuda/test.hh b/include/nba/engines/cuda/test.hh new file mode 100644 index 0000000..4e7ef03 --- /dev/null +++ b/include/nba/engines/cuda/test.hh @@ -0,0 +1,5 @@ +namespace nba { +extern void* get_test_kernel_noop(); +} + +// vim: ts=8 sts=4 sw=4 et diff --git a/include/nba/framework/datablock_shared.hh b/include/nba/framework/datablock_shared.hh index 3e1ef34..7c0a487 100644 --- a/include/nba/framework/datablock_shared.hh +++ b/include/nba/framework/datablock_shared.hh @@ -8,7 +8,6 @@ #include #include -#include struct datablock_batch_info { void *buffer_bases_in; diff --git a/src/engines/cuda/test.cu b/src/engines/cuda/test.cu new file mode 100644 index 0000000..6890ba7 --- /dev/null +++ b/src/engines/cuda/test.cu @@ -0,0 +1,16 @@ +#include + +using namespace std; +using namespace nba; + +__global__ void noop() +{ + __syncthreads(); +} + +void *nba::get_test_kernel_noop() +{ + return reinterpret_cast (noop); +} + +// vim: ts=8 sts=4 sw=4 et diff --git a/tests/test_cuda.cc b/tests/test_cuda.cc new file mode 100644 index 0000000..c74b26e --- /dev/null +++ b/tests/test_cuda.cc @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include +#if 0 +#require +#endif + +using namespace std; +using namespace nba; + +#ifdef USE_CUDA + +TEST(CUDADeviceTest, Initialization) { + EXPECT_EQ(cudaSuccess, cudaSetDevice(0)); + EXPECT_EQ(cudaSuccess, cudaDeviceReset()); +} + +TEST(CUDADeviceTest, NoopKernel) { + EXPECT_EQ(cudaSuccess, cudaSetDevice(0)); + void *k = get_test_kernel_noop(); + EXPECT_EQ(cudaSuccess, cudaLaunchKernel(k, dim3(1), dim3(1), nullptr, 0, 0)); + EXPECT_EQ(cudaSuccess, cudaDeviceSynchronize()); + EXPECT_EQ(cudaSuccess, cudaDeviceReset()); +} + +#else + +TEST(CUDATest, Noop) { + EXPECT_TRUE(1); +} + +#endif + +// vim: ts=8 sts=4 sw=4 et