Open main menu

CDOT Wiki β

Changes

BetaT

27 bytes added, 19:15, 1 April 2017
New Kernel
== New Kernel ==
'''__global__ void Initalize(float* u, float* un, int nx, int nt, float dx) 
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;
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 in coalesced memory escalting i from 0 to nx if (i*dx >= 0.5 && i*dx <= 1)
// replace k here with i. for the X dimension because i represents we want to change the x first instance in each dimension in coalesced memory escalting u[i * nx] = 2; else u[i from * nx] = 1; } } The old code was: for (int k = 0 to ; k <= nx- 1; k++) if (ik*dx >= 0.5 && ik*dx <= 1) { // replace k here with i for the X dimension because we want to change the first instance in each dimension u[i k * nx] = 2; } else {
else u[i k * 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;
}'''
So I removed the for loop and simply changed the "k" in the "if" statement to represnt the threadIdx.x identifier because X is the fastest moving dimension it will range from 0 to NX like a for look. This matches the orignal Naiver output.
Next I have updated
212
edits