Open main menu

CDOT Wiki β

Changes

BetaT

2 bytes added, 18:15, 29 March 2017
Optimizing Problems
__global__ void Initalize(double* u, double* un, int nx, int nt, double dx)
 
{
 
int i = blockIdx.x * blockDim.x + threadIdx.x;
 
int j = blockIdx.y * blockDim.y + threadIdx.y;
  for (int k = 0; k <= nx - 1; k++)
if (k*dx >= 0.5 && k*dx <= 1)
{
u[k * nt] = 2;
__syncthreads();
}
 
else
  {
u[k * nt] = 1;
__syncthreads();
}
 
}
The second kernel works perfectly find for arguments less than 1024 1024 (user inputs 2 values), anything higher for example an argument of 2000 2000 will crash the driver and results will be set to pre kernel launch. The kernel code is below:
''' __global__ void Calculate (double* u, double* un,int nx, int c, double dx, double dt) 
{
 
for (int it = 1; it <= nx - 1; it++) { for (int k = 0; k <= nx - 1; k++) { un[k * nx + it - 1] = u[k * nx + it - 1]; } for (int m = 1; m <= nx - 1; m++) { u[0 * nx + it] = un[1 * nx + it - 1]; u[m * nx + it] = un[m * nx + it - 1] - c*dt / dx*(un[m * nx + it - 1] - un[(m - 1) * nx + it - 1]); } }
for (int it = 1; it <= nx - 1; it++)
{
for (int k = 0; k <= nx - 1; k++)
{
un[k * nx + it - 1] = u[k * nx + it - 1];
}
for (int m = 1; m <= nx - 1; m++)
{
u[0 * nx + it] = un[1 * nx + it - 1];
u[m * nx + it] = un[m * nx + it - 1] - c*dt / dx*(un[m * nx + it - 1] - un[(m - 1) * nx + it - 1]);
}
}
 
}'''
212
edits