6 template <
typename F1>
double Dnrm2_core(
const F1 &x) {
11 const double *xd = x.data();
12 size_t size = x.size();
13 const size_t xoffset = x.get_offset();
15 if (x.get_device_mem_stat() ==
true) {
18 internal::check_CUDA(cublasCreate(&h));
19 #pragma omp target data use_device_ptr(xd)
20 { internal::check_CUDA(cublasDnrm2(h, size, xd + xoffset, 1, &ans)); }
23 throw std::runtime_error(
24 "error USE_GPU is false, but get_device_mem_stat() == true");
27 ans = cblas_dnrm2(size, xd + xoffset, 1);
33 template <
typename F1>
float Snrm2_core(
const F1 &x) {
38 const float *xd = x.data();
39 size_t size = x.size();
40 const size_t xoffset = x.get_offset();
42 if (x.get_device_mem_stat() ==
true) {
45 internal::check_CUDA(cublasCreate(&h));
46 #pragma omp target data use_device_ptr(xd)
47 { internal::check_CUDA(cublasSnrm2(h, size, xd + xoffset, 1, &ans)); }
50 throw std::runtime_error(
51 "error USE_GPU is false, but get_device_mem_stat() == true");
54 ans = cblas_snrm2(size, xd + xoffset, 1);