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
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
device_unique_ptr.h
prod1Switch_cff.cuda
cuda
Definition: prod1Switch_cff.py:11
cms::cuda::memsetAsync
void memsetAsync(device::unique_ptr< T > &ptr, T value, cudaStream_t stream)
Definition: memsetAsync.h:12
value
Definition: value.py:1
cudaCheck.h
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:62
T
long double T
Definition: Basic3DVectorLD.h:48
relativeConstraints.value
value
Definition: relativeConstraints.py:53
cms::cuda::value
cudaStream_t T uint32_t const T *__restrict__ const uint32_t *__restrict__ uint32_t int cudaStream_t Func V value
Definition: HistoContainer.h:124
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21