Open main menu

CDOT Wiki β

Changes

BetaT

1,300 bytes added, 00:03, 8 April 2017
OPTIMIZATION
(5000 ^ 2) 28787 | 127373 | n/a | 1417
(10000 ^ 2) 124179 | 522576 | n/a | 3054
 
== SECOND OPTIMIZATION ==
 
The original Initialize Kernel needed some altering. Below is the original:
 
__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;
if (i < nx && j < nx)
{
if (i*dx >= 0.5 && i*dx <= 1)
{
u[i * nx] = 2;
__syncthreads();
}
else
{
u[i * nx] = 1;
__syncthreads();
}
}
}
 
 
I removed the variable (j), removed the syncthreads() which were not needed, I also removed the function running on the CPU that initializes all indexes int he arrays to 0, and moved it into the GPU below.
__global__ void Initalize(float* u, float* un, int nx, int nt, float dx)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < nx)
{
for (int it = 0; it < nx; it++)
{
u[i * nx + it] = 0;
un[i * nx + it] = 0;
}
if (i*dx >= 0.5 && i*dx <= 1)
u[i * nx] = 2;
else
u[i * nx] = 1;
}
}
212
edits