From 707ffabedc3bbc7a1c6a2874c060e3a3bd8e63b3 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Thu, 17 Jan 2019 15:50:11 +0100 Subject: [PATCH] Skip CUDA-related tests if no GPU is present (cms-patatrack#252) Make unit tests that require a CUDA device skip the test and exit succesfully if the CUDA runtime is not available, or no CUDA devices are available. --- .../PixelTrackFitting/test/BuildFile.xml | 59 ++++++++++--------- .../PixelTrackFitting/test/testEigenGPU.cu | 7 ++- .../test/testEigenGPUNoFit.cu | 3 + 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/RecoPixelVertexing/PixelTrackFitting/test/BuildFile.xml b/RecoPixelVertexing/PixelTrackFitting/test/BuildFile.xml index b4b5e3a335bcb..e6c67be031342 100644 --- a/RecoPixelVertexing/PixelTrackFitting/test/BuildFile.xml +++ b/RecoPixelVertexing/PixelTrackFitting/test/BuildFile.xml @@ -1,21 +1,20 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - @@ -32,28 +31,34 @@ + + + + - - - - + + + + + - - - - + + + + + - - - + + + diff --git a/RecoPixelVertexing/PixelTrackFitting/test/testEigenGPU.cu b/RecoPixelVertexing/PixelTrackFitting/test/testEigenGPU.cu index a60eeda935d79..3917de89a8185 100644 --- a/RecoPixelVertexing/PixelTrackFitting/test/testEigenGPU.cu +++ b/RecoPixelVertexing/PixelTrackFitting/test/testEigenGPU.cu @@ -3,11 +3,10 @@ #include #include - -#include "RecoPixelVertexing/PixelTrackFitting/interface/RiemannFit.h" - #include "test_common.h" #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h" +#include "HeterogeneousCore/CUDAUtilities/interface/exitSansCUDADevices.h" +#include "RecoPixelVertexing/PixelTrackFitting/interface/RiemannFit.h" using namespace Eigen; @@ -216,6 +215,8 @@ void testFit() { } int main (int argc, char * argv[]) { + exitSansCUDADevices(); + testFit(); std::cout << "TEST FIT, NO ERRORS" << std::endl; diff --git a/RecoPixelVertexing/PixelTrackFitting/test/testEigenGPUNoFit.cu b/RecoPixelVertexing/PixelTrackFitting/test/testEigenGPUNoFit.cu index ead2e3cc00504..17413f4ef3e2a 100644 --- a/RecoPixelVertexing/PixelTrackFitting/test/testEigenGPUNoFit.cu +++ b/RecoPixelVertexing/PixelTrackFitting/test/testEigenGPUNoFit.cu @@ -5,6 +5,8 @@ #include "test_common.h" +#include "HeterogeneousCore/CUDAUtilities/interface/exitSansCUDADevices.h" + using namespace Eigen; __host__ __device__ void eigenValues(Matrix3d * m, Eigen::SelfAdjointEigenSolver::RealVectorType * ret) { @@ -183,6 +185,7 @@ std::cout << "*************************\n\n" << std::endl; int main (int argc, char * argv[]) { + exitSansCUDADevices(); testEigenvalues(); testInverse3x3();