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_DeviceAdapterTimerImplementationCuda_h 21 #define vtk_m_cont_cuda_internal_DeviceAdapterTimerImplementationCuda_h 22 23 #include <vtkm/cont/vtkm_cont_export.h> 24 25 #include <vtkm/Types.h> 26 27 #include <vtkm/cont/DeviceAdapterAlgorithm.h> 28 #include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h> 29 30 #include <cuda.h> 31 32 namespace vtkm 33 { 34 namespace cont 35 { 36 37 /// 38 /// Specialization of DeviceAdapterTimerImplementation for CUDA 39 /// CUDA contains its own high resolution timer that are able 40 /// to track how long it takes to execute async kernels. 41 /// If we simply measured time on the CPU it would incorrectly 42 /// just capture how long it takes to launch a kernel. 43 template <> 44 class VTKM_CONT_EXPORT DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda> 45 { 46 public: 47 VTKM_CONT DeviceAdapterTimerImplementation(); 48 49 VTKM_CONT ~DeviceAdapterTimerImplementation(); 50 51 VTKM_CONT void Reset(); 52 53 VTKM_CONT vtkm::Float64 GetElapsedTime(); 54 55 private: 56 // Copying CUDA events is problematic. 57 DeviceAdapterTimerImplementation( 58 const DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>&) = delete; 59 void operator=(const DeviceAdapterTimerImplementation<vtkm::cont::DeviceAdapterTagCuda>&) = 60 delete; 61 62 cudaEvent_t StartEvent; 63 cudaEvent_t EndEvent; 64 }; 65 } 66 } // namespace vtkm::cont 67 68 69 #endif 70