/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
HeterogeneousCore/CUDAUtilities/interface/memsetAsync.h
33 строки
1 KB
Andrea Bocci
Rename GPU check macros to uppercase
24 июл 2026, 18:36
Не верифицирован
24 июл 2026, 18:36
4ca8016
Код
Авторство
О чём код?
#ifndef HeterogeneousCore_CUDAUtilities_memsetAsync_h #define HeterogeneousCore_CUDAUtilities_memsetAsync_h #include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h" #include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h" #include <type_traits> namespace cms { namespace cuda { template <typename T> inline void memsetAsync(device::unique_ptr<T>& ptr, T value, cudaStream_t stream) { // Shouldn't compile for array types because of sizeof(T), but // let's add an assert with a more helpful message static_assert(std::is_array<T>::value == false, "For array types, use the other overload with the size parameter"); CUDA_CHECK(cudaMemsetAsync(ptr.get(), value, sizeof(T), stream)); } /** * The type of `value` is `int` because of `cudaMemsetAsync()` takes * it as an `int`. Note that `cudaMemsetAsync()` sets the value of * each **byte** to `value`. This may lead to unexpected results if * `sizeof(T) > 1` and `value != 0`. */ template <typename T> inline void memsetAsync(device::unique_ptr<T[]>& ptr, int value, size_t nelements, cudaStream_t stream) { CUDA_CHECK(cudaMemsetAsync(ptr.get(), value, nelements * sizeof(T), stream)); } } // namespace cuda } // namespace cms #endif