QMCPACK
CUDAfill.hpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2021 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #ifndef QMCPLUSPLUS_CUDAFILL_H
14 #define QMCPLUSPLUS_CUDAFILL_H
15 
16 #include <complex>
17 #include <stdexcept>
18 #include <cstddef>
19 
20 namespace qmcplusplus
21 {
22 /** fill device memory with a given value.
23  * @param ptr pointer to device memory
24  * @param n size of type T elemements
25  * @value desired value. Due to cudaMemset limitation. Only filling 0 is supported.
26  *
27  * this function is only intended to prevent NaN in containers when device memory segments are allocated.
28  * do not use outside allocators.
29  */
30 template<typename T>
31 void CUDAfill_n(T* ptr, size_t n, const T& value);
32 
33 extern template void CUDAfill_n<int>(int* ptr, size_t n, const int& value);
34 extern template void CUDAfill_n<size_t>(size_t* ptr, size_t n, const size_t& value);
35 
36 extern template void CUDAfill_n<float>(float* ptr, size_t n, const float& value);
37 extern template void CUDAfill_n<double>(double* ptr, size_t n, const double& value);
38 
39 extern template void CUDAfill_n<std::complex<float>>(std::complex<float>* ptr,
40  size_t n,
41  const std::complex<float>& value);
42 extern template void CUDAfill_n<std::complex<double>>(std::complex<double>* ptr,
43  size_t n,
44  const std::complex<double>& value);
45 
46 } // namespace qmcplusplus
47 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
template void CUDAfill_n< double >(double *ptr, size_t n, const double &value)
template void CUDAfill_n< float >(float *ptr, size_t n, const float &value)
template void CUDAfill_n< size_t >(size_t *ptr, size_t n, const size_t &value)
void CUDAfill_n(T *ptr, size_t n, const T &value)
fill device memory with a given value.
Definition: CUDAfill.cpp:20
template void CUDAfill_n< int >(int *ptr, size_t n, const int &value)