6 template <
typename F1,
typename F2>
void Dscal_core(
const F1 alpha, F2 &x) {
10 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(cublasDscal(h, size, &alpha, xd + xoffset, 1)); }
22 throw std::runtime_error(
23 "error USE_GPU is false, but get_device_mem_stat() == true");
26 cblas_dscal(size, alpha, xd + xoffset, 1);
31 template <
typename F1,
typename F2>
void Sscal_core(
const F1 alpha, F2 &x) {
36 size_t size = x.size();
37 const size_t xoffset = x.get_offset();
39 if (x.get_device_mem_stat() ==
true) {
42 internal::check_CUDA(cublasCreate(&h));
43 #pragma omp target data use_device_ptr(xd)
44 { internal::check_CUDA(cublasSscal(h, size, &alpha, xd + xoffset, 1)); }
47 throw std::runtime_error(
48 "error USE_GPU is false, but get_device_mem_stat() == true");
51 cblas_sscal(size, alpha, xd + xoffset, 1);