6 template <
typename F1,
typename F2,
typename F3>
7 void Dxpay_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) {
23 #pragma omp target teams distribute parallel for
24 for (
size_t i = 0; i < size; i++) {
25 yd[i + yoffset] = xd[i + xoffset] + alpha * yd[i + yoffset];
28 throw std::runtime_error(
29 "error USE_GPU is false, but get_device_mem_stat() == true");
32 #pragma omp parallel for
33 for (
size_t i = 0; i < size; i++) {
34 yd[i + yoffset] = xd[i + xoffset] + alpha * yd[i + yoffset];
40 template <
typename F1,
typename F2,
typename F3>
41 void Sxpay_core(
const F1 alpha,
const F2 &x, F3 &y) {
49 const float *xd = x.data();
51 size_t size = x.size();
52 const size_t xoffset = x.get_offset();
53 const size_t yoffset = y.get_offset();
55 if (x.get_device_mem_stat() ==
true) {
57 #pragma omp target teams distribute parallel for
58 for (
size_t i = 0; i < size; i++) {
59 yd[i + yoffset] = xd[i + xoffset] + alpha * yd[i + yoffset];
62 throw std::runtime_error(
63 "error USE_GPU is false, but get_device_mem_stat() == true");
66 #pragma omp parallel for
67 for (
size_t i = 0; i < size; i++) {
68 yd[i + yoffset] = xd[i + xoffset] + alpha * yd[i + yoffset];