6 template <
typename F1,
typename F2>
double Ddot_core(
const F1 &x,
const F2 &y) {
15 const double *xd = x.data();
16 const double *yd = y.data();
17 const 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 cublasDdot(h, size, xd + xoffset, 1, yd + yoffset, 1, &ans));
32 throw std::runtime_error(
33 "error USE_GPU is false, but get_device_mem_stat() == true");
36 ans = cblas_ddot(size, xd + xoffset, 1, yd + yoffset, 1);
42 template <
typename F1,
typename F2>
float Sdot_core(
const F1 &x,
const F2 &y) {
51 const float *xd = x.data();
52 const float *yd = y.data();
53 const size_t size = x.size();
54 const size_t xoffset = x.get_offset();
55 const size_t yoffset = y.get_offset();
57 if (x.get_device_mem_stat() ==
true) {
60 internal::check_CUDA(cublasCreate(&h));
61 #pragma omp target data use_device_ptr(xd, yd)
64 cublasSdot(h, size, xd + xoffset, 1, yd + yoffset, 1, &ans));
68 throw std::runtime_error(
69 "error USE_GPU is false, but get_device_mem_stat() == true");
72 ans = cblas_sdot(size, xd + xoffset, 1, yd + yoffset, 1);