Hi,
CUBLAS_Library_2.2.pdf describes cublasSaxpy() as follows, "void cublasSaxpy(int n, float alpha, const float *x, int incx, float *y, int incy) multiplies single-precision vector x by single-precision scalar alpha and adds the result to single-precision vector y; that is, it overwrites single-precision y with singlr-precision alpha*x + y.
for i = 0 to n-1, it replaces y[ly + iincy] with alphax[lx + iincx]+y[ly + iincy], where incx is the storage spacing between elements of x, y is single-precision vector with n elements, incy is the storage spacing between elements of y."
according to the above description, when n=3, alpha=1.0f, x=1, incx = 1, y = 0, incy = 1, then after calling cublasSaxpy() at least y[1] becomes 1. But after running the codes as follows, all y are still 0, none becomes 1. Why? Thanks!!!
#include <stdio.h>
#include <cublas.h>
#include <cuda.h>
#include <cuda_runtime.h>
int main(){
int N = 3;
float x[3],y[3];
for(int i = 0; i < N; i++){
x[i] = 1.0;
y[i] = 0;
}
cublasSaxpy ( N, 1.0f, x, 1, y, 1 ) ;
for(int i = 0; i < N; i++){
printf("x[%d] = %f ", i, x[i]);
printf("y[%d] = %f ", i, y[i]);
}
return 0;
}