FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
copy_stride.cu
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6// includes, FEAT
7#include <kernel/base_header.hpp>
8#include <kernel/lafem/arch/copy_stride.hpp>
9#include <kernel/util/exception.hpp>
10#include <kernel/util/cuda_util.hpp>
11#include <kernel/util/half.hpp>
12
13// includes, CUDA
14#include <cublas_v2.h>
15
16namespace FEAT::LAFEM::Arch
17{
18 template <typename DT_>
19 void CopyStride::exec_cuda_impl(DT_ * r, const DT_ * const x, const int stride_r, const int comp_r, const int stride_x, const int comp_x, const Index count)
20 {
21 cudaDataType dt;
22 if (typeid(DT_) == typeid(double))
23 {
24 dt = CUDA_R_64F;
25 }
26 else if (typeid(DT_) == typeid(float))
27 {
28 dt = CUDA_R_32F;
29 }
30#ifdef FEAT_HAVE_HALFMATH
31 else if (typeid(DT_) == typeid(Half))
32 {
33 dt = CUDA_R_16F;
34 }
35#endif
36 else
37 {
38 XABORTM("unsupported data type");
39 }
40
41 cublasStatus_t status = cublasCopyEx(Util::Intern::cublas_handle, int(count), &x[comp_x], dt, stride_x, &r[comp_r], dt, stride_r);
42#ifdef DEBUG
43 if (CUBLAS_STATUS_SUCCESS != status)
44 throw InternalError(__func__, __FILE__, __LINE__, "cuda error: " + stringify(cublasGetStatusString(status)));
45#endif
46 (void)status;
47 }
48
49#ifdef FEAT_HAVE_HALFMATH
50 template void CopyStride::exec_cuda_impl(Half *, const Half * const, const int, const int, const int, const int, const Index);
51#endif
52 template void CopyStride::exec_cuda_impl(float *, const float * const, const int, const int, const int, const int, const Index);
53 template void CopyStride::exec_cuda_impl(double *, const double * const, const int, const int, const int, const int, const Index);
54
55} // namespace FEAT::LAFEM::Arch