#include #include void saxpy(int n, float a, float *restrict x, float *restrict y) { #pragma acc parallel loop for (int i = 0; i < n; ++i) y[i] = a*x[i] + y[i]; } int main(void) { const int n = 1 << 20; float *x = new float[n]; float *y = new float[n]; for (int i = 0; i < n; ++i) { x[i] = (float)i / (float)n; y[i] = (float)i; // Perform SAXPY on 1M elements saxpy(1<<20, 2.0, x, y); } }