1 //============================================================================
2 //  Copyright (c) Kitware, Inc.
3 //  All rights reserved.
4 //  See LICENSE.txt for details.
5 //  This software is distributed WITHOUT ANY WARRANTY; without even
6 //  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7 //  PURPOSE.  See the above copyright notice for more information.
8 //
9 //  Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
10 //  Copyright 2014 UT-Battelle, LLC.
11 //  Copyright 2014 Los Alamos National Security.
12 //
13 //  Under the terms of Contract DE-NA0003525 with NTESS,
14 //  the U.S. Government retains certain rights in this software.
15 //
16 //  Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
17 //  Laboratory (LANL), the U.S. Government retains certain rights in
18 //  this software.
19 //============================================================================
20 #ifndef vtk_m_cont_cuda_internal_Testing_h
21 #define vtk_m_cont_cuda_internal_Testing_h
22 
23 #include <vtkm/cont/testing/Testing.h>
24 
25 #include <cuda.h>
26 
27 namespace vtkm
28 {
29 namespace cont
30 {
31 namespace cuda
32 {
33 namespace internal
34 {
35 
36 struct Testing
37 {
38 public:
CheckCudaBeforeExitTesting39   static VTKM_CONT int CheckCudaBeforeExit(int result)
40   {
41     cudaError_t cudaError = cudaPeekAtLastError();
42     if (cudaError != cudaSuccess)
43     {
44       std::cout << "***** Unchecked Cuda error." << std::endl
45                 << cudaGetErrorString(cudaError) << std::endl;
46       return 1;
47     }
48     else
49     {
50       std::cout << "No Cuda error detected." << std::endl;
51     }
52     return result;
53   }
54 
55   template <class Func>
RunTesting56   static VTKM_CONT int Run(Func function)
57   {
58     int result = vtkm::cont::testing::Testing::Run(function);
59     return CheckCudaBeforeExit(result);
60   }
61 };
62 }
63 }
64 }
65 } // namespace vtkm::cont::cuda::internal
66 
67 #endif //vtk_m_cont_cuda_internal_Testing_h
68