CMS 3D CMS Logo

memsetAsync.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_CUDAUtilities_memsetAsync_h
2 #define HeterogeneousCore_CUDAUtilities_memsetAsync_h
3 
6 
7 #include <type_traits>
8 
9 namespace cms {
10  namespace cuda {
11  template <typename T>
12  inline void memsetAsync(device::unique_ptr<T>& ptr, T value, cudaStream_t stream) {
13  // Shouldn't compile for array types because of sizeof(T), but
14  // let's add an assert with a more helpful message
15  static_assert(std::is_array<T>::value == false,
16  "For array types, use the other overload with the size parameter");
17  cudaCheck(cudaMemsetAsync(ptr.get(), value, sizeof(T), stream));
18  }
19 
26  template <typename T>
27  inline void memsetAsync(device::unique_ptr<T[]>& ptr, int value, size_t nelements, cudaStream_t stream) {
28  cudaCheck(cudaMemsetAsync(ptr.get(), value, nelements * sizeof(T), stream));
29  }
30  } // namespace cuda
31 } // namespace cms
32 
33 #endif
void memsetAsync(device::unique_ptr< T > &ptr, T value, cudaStream_t stream)
Definition: memsetAsync.h:12
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t Func __host__ __device__ V value
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: value.py:1
Namespace of DDCMS conversion namespace.
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
long double T