Skip to content
Snippets Groups Projects
Commit d14d4d69 authored by Nordine Feddal's avatar Nordine Feddal
Browse files

saxpy

parent 21363d45
No related branches found
No related tags found
No related merge requests found
......@@ -91,3 +91,33 @@ void initialize_vectorAdd_int() {
}
// End Init Function
// End vectorAdd_int
// Start saxpy
__global__ void saxpy_parallel(int n, float a, float *x, float *y)
{
int i = blockIdx.x*blockDim.x + threadIdx.x;
if (i<n) y[i] = a*x[i] + y[i];
}
// Start Parameters
int SIZE_SAXPY = 10000;
float SAXPY_a = 1.5;
float * SAXPY_hx;
float * SAXPY_hy;
// End Parameters
// Start Init function
void initialize_saxpy() {
SAXPY_hx = (float*)malloc(SIZE_SAXPY*sizeof(float));
SAXPY_hy = (float*)malloc(SIZE_SAXPY*sizeof(float));
float * SAXPY_dx;
float * SAXPY_dy;
cudaMalloc(&SAXPY_dx, SIZE_SAXPY * sizeof(float));
cudaMalloc(&SAXPY_dy, SIZE_SAXPY * sizeof(float));
}
// End Init Function
// End saxpy
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment