5 template <
typename F1>
double Dasum_core(
const F1 &x) {
10 const double *xd = x.data();
11 size_t size = x.size();
12 const size_t xoffset = x.get_offset();
14 if (x.get_device_mem_stat() ==
true) {
17 internal::check_CUDA(cublasCreate(&h));
18 #pragma omp target data use_device_ptr(xd)
19 { internal::check_CUDA(cublasDasum(h, size, xd + xoffset, 1, &ans)); }
22 throw std::runtime_error(
23 "error USE_GPU is false, but get_device_mem_stat() == true");
26 ans = cblas_dasum(size, xd + xoffset, 1);
32 template <
typename F1>
float Sasum_core(
const F1 &x) {
37 const float *xd = x.data();
38 size_t size = x.size();
39 const size_t xoffset = x.get_offset();
41 if (x.get_device_mem_stat() ==
true) {
44 internal::check_CUDA(cublasCreate(&h));
45 #pragma omp target data use_device_ptr(xd)
46 { internal::check_CUDA(cublasSasum(h, size, xd + xoffset, 1, &ans)); }
49 throw std::runtime_error(
50 "error USE_GPU is false, but get_device_mem_stat() == true");
53 ans = cblas_sasum(size, xd + xoffset, 1);