Open main menu

CDOT Wiki β

Changes

BetaT

90 bytes added, 19:37, 1 April 2017
New Kernel
{
int i = blockIdx.x * blockDim.x + threadIdx.x; int j = blockIdx.y * blockDim.y + threadIdx.y;
if (i < nx && j < nx)
{ // replace k with i. because i represents the x dimension which will ascend in coalesced memory escalting i a range from 0 to nx . // So i * dx will essentially by equivalent to...for (int k = 0; k < nx; k++) if (i*dx >= 0.5 && i*dx <= 1) // replace k here with i for the X dimension because we want to change for the first instance in each dimension same reason as above u[i * nx] = 2; else u[i * nx] = 1; } }
The old code was:
for (int k = 0; k <= nx - 1; k++)
if (k*dx >= 0.5 && k*dx <= 1) { u[k * nx] = 2; } else { u[k * nx] = 1; }'''
212
edits