Skip to content

Commit

Permalink
More fixes for Windows CUDA examples
Browse files Browse the repository at this point in the history
For some stupid reason, plot3, plotting and surface CUDA examples
are not compiling on WINDOWS stating CUDA kernel has no visiblity
to the global constant variables.
  • Loading branch information
9prady9 committed Nov 6, 2015
1 parent 6354af4 commit f3956a4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions examples/cuda/plot3.cu
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int main(void)


__global__
void gen_curve(float t, float dx, float* out)
void gen_curve(float t, float dx, float* out, const float ZMIN, const size_t ZSIZE)
{
int offset = blockIdx.x * blockDim.x + threadIdx.x;

Expand All @@ -110,5 +110,5 @@ void kernel(float t, float dx, float* dev_out)
static const dim3 threads(1024);
dim3 blocks(divup(ZSIZE, 1024));

gen_curve<<< blocks, threads >>>(t, dx, dev_out);
gen_curve<<< blocks, threads >>>(t, dx, dev_out, ZMIN, ZSIZE);
}
12 changes: 6 additions & 6 deletions examples/cuda/plotting.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const unsigned DIMY = 800;
const unsigned WIN_ROWS = 2;
const unsigned WIN_COLS = 2;

const float dx = 0.1;
const float FRANGE_START = 0.f;
const float FRANGE_END = 2 * 3.141592f;
const size_t DATA_SIZE = ( FRANGE_END - FRANGE_START ) / dx;
static const float dx = 0.1;
static const float FRANGE_START = 0.f;
static const float FRANGE_END = 2 * 3.141592f;
static const size_t DATA_SIZE = ( FRANGE_END - FRANGE_START ) / dx;

void kernel(float* dev_out);

Expand Down Expand Up @@ -97,7 +97,7 @@ int main(void)


__global__
void simple_sinf(float* out)
void simple_sinf(float* out, const size_t DATA_SIZE, const float dx)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;

Expand All @@ -112,5 +112,5 @@ void kernel(float* dev_out)
static const dim3 threads(DATA_SIZE);
dim3 blocks(1);

simple_sinf<<< blocks, threads >>>(dev_out);
simple_sinf << < blocks, threads >> >(dev_out, DATA_SIZE, dx);
}
18 changes: 10 additions & 8 deletions examples/cuda/surface.cu
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
const unsigned DIMX = 1000;
const unsigned DIMY = 800;

static const float XMIN = -1.0f;
static const float XMAX = 2.f;
static const float YMIN = -1.0f;
static const float YMAX = 1.f;
const float XMIN = -1.0f;
const float XMAX = 2.f;
const float YMIN = -1.0f;
const float YMAX = 1.f;

const float DX = 0.01;
const size_t XSIZE = (XMAX-XMIN)/DX+1;
Expand Down Expand Up @@ -86,13 +86,15 @@ int main(void)


__global__
void sincos_surf(float t, float dx, float* out)
void sincos_surf(float t, float dx, float* out,
const float XMIN, const float YMIN,
const size_t XSIZE, const size_t YSIZE)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;

float x=XMIN+i*dx;
float y=YMIN+j*dx;
float x= ::XMIN + i*dx;
float y= ::YMIN + j*dx;
if (i<XSIZE && j<YSIZE) {
int offset = j + i * YSIZE;
out[ 3 * offset ] = x;
Expand All @@ -112,5 +114,5 @@ void kernel(float t, float dx, float* dev_out)
dim3 blocks(divup(XSIZE, threads.x),
divup(YSIZE, threads.y));

sincos_surf<<< blocks, threads >>>(t, dx, dev_out);
sincos_surf<<< blocks, threads >>>(t, dx, dev_out, XMIN, YMIN, XSIZE, YSIZE);
}

0 comments on commit f3956a4

Please sign in to comment.