In this problem, you need to use CUDA to parallelize concurrent wave equation (http://en.wikipedia. org/wiki/Wave equation). Below show a serial implementation of the concurrent wave equation (http: //www.cs.nctu.edu.tw/∼ypyou/courses/PP-f19/assignments/HW4/serial wave.c).
/* check number of points, number of iterations */ while ((tpoints < MINPOINTS) || (tpoints MAXPOINTS)) { printf("Enter number of points along vibrating string [%d-%d]: "
if ((tpoints < MINPOINTS) || (tpoints MAXPOINTS)) printf("Invalid. Please enter value between %d and %d\n", MINPOINTS, MAXPOINTS);
}
while ((nsteps < 1) || (nsteps MAXSTEPS)) { printf("Enter number of time steps [1-%d]: ", MAXSTEPS); scanf("%s", tchar); nsteps = atoi(tchar); if ((nsteps < 1) || (nsteps MAXSTEPS)) printf("Invalid. Please enter value between 1 and %d\n", MAXSTEPS);
/* Calculate initial values based on sine curve */ fac = 2.0 * PI; k = 0.0; tmp = tpoints - 1; for (j = 1; j <= tpoints; j++) { x = k/tmp; values[j] = sin (fac * x); k = k + 1.0;
}
/* Initialize old values array */ for (i = 1; i <= tpoints; i++) oldval[i] = values[i];
}
/********************************************************************** * Calculate new values using wave equation
/* Update values for each time step */ for (i = 1; i<= nsteps; i++) {
/* Update points along line for this time step */ for (j = 1; j <= tpoints; j++) { /* global endpoints */ if ((j == 1) || (j == tpoints)) newval[j] = 0.0;
else do_math(j);
}
/* Update old values with new values */ for (j = 1; j <= tpoints; j++) { oldval[j] = values[j]; values[j] = newval[j];
printf("Initializing points on the line...\n"); init_line();
printf("Updating all points for all time steps...\n"); update();
printf("Printing final results...\n"); printfinal(); printf("\nDone.\n\n");
return 0;
} 1 Requirements • Your program should take two command-line arguments, which indicate the number of points andthe number of iterations, respectively.
• The output format should not be changed.
2 Development Environment 2.1 Building the CUDA environment on your own computer If you have an nVIDIA GPU, you can build your own development environment by installing CUDA SDK.