6 template <
typename F1,
typename F2,
typename F3>
7 void Daxpy_core(
const F1 alpha,
const F2 &x, F3 &y) {
15 const double *xd = x.data();
16 double *yd = y.data();
17 size_t size = x.size();
18 const size_t xoffset = x.get_offset();
19 const size_t yoffset = y.get_offset();
21 if (x.get_device_mem_stat() ==
true) {
24 internal::check_CUDA(cublasCreate(&h));
25 #pragma omp target data use_device_ptr(xd, yd)
28 cublasDaxpy(h, size, &alpha, xd + xoffset, 1, yd + yoffset, 1));
32 throw std::runtime_error(
33 "error USE_GPU is false, but get_device_mem_stat() == true");
36 cblas_daxpy(size, alpha, xd + xoffset, 1, yd + yoffset, 1);
41 template <
typename F1,
typename F2,
typename F3>
42 void Saxpy_core(
const F1 alpha,
const F2 &x, F3 &y) {
50 const float *xd = x.data();
52 size_t size = x.size();
53 const size_t xoffset = x.get_offset();
54 const size_t yoffset = y.get_offset();
56 if (x.get_device_mem_stat() ==
true) {
59 internal::check_CUDA(cublasCreate(&h));
60 #pragma omp target data use_device_ptr(xd, yd)
63 cublasSaxpy(h, size, &alpha, xd + xoffset, 1, yd + yoffset, 1));
67 throw std::runtime_error(
68 "error USE_GPU is false, but get_device_mem_stat() == true");
71 cblas_saxpy(size, alpha, xd + xoffset, 1, yd + yoffset, 1);