Changes

Jump to: navigation, search

BetaT

36 bytes added, 19:56, 1 April 2017
New Kernel
// The original code had the following statement:: u[m * nx + it] = un[m * nx + it - 1] - c*dt / dx*(un[m * nx + it - 1] - un[(m - 1) * nx + it - 1]);
// Rather than having each thread perform this calculation which will be an additional 2 instructions per thread, i have just stored it in a variable
float total = c*dt / dx;
{
// The original code as can be seen below is basically copying array un to array u. So i arranged the threads to do the same
un[j * nx + i] = u[j * nx + i];
__syncthreads();
if (i != 0)
{
// This part was a bit trickier. As seen in the original code below array u would access all threads in the [0,0] [0,1] [0,2] etc... // And copy a value from array un's [1,1] [1,2] [1,3]..etc range. The trick here was the -1 difference at the end // Because in the original for look, (it) starts at the value 1, I added and if condition to make sure the threads don't perform the operation on the thread of value 0. But it can still be access through the -1 operator.
u[i] = un[1 * nx + i-1];
__syncthreads();
212
edits

Navigation menu