Win7, adding CUDA support in existing program.

I want to add CUDA support in my x64 program without creating new project. So I added paths and files in Additional Dependencies and Include/Library) Directories. Cuda.h - included. I added code from…t-cuda-program/ but I got errors (error C2065: ‘blockIdx’ : undeclared identifier etc.) - probably because I didn’t added sth in command line to compile code using nvcc. I found…p;sloc=&p=1 So now I have x64 CUDA rule, I created new .cu file with CUDA instead C/C++ Compiler Tool. In .cu file I have only function -

__global__ void square_array(float *a, int N)

but in .cpp file I can’t use

square_array <<< n_blocks, block_size >>> (a_d, N);

because of errors:

Everything compiles and links without it bud of course it don’t works correctly because GPU does nothing (without probably copying data). So what to do fix it. Do I need do sth else to “connect” my .cu file? Maybe It’s wrong method and I must create new project etc.?

extern "C"

void calculateOnGPU(float *a, int N, int block_size, int n_blocks);

in .cpp

and adding

extern "C"

void calculateOnGPU(float *a, int N, int block_size, int n_blocks)


	square_array <<< n_blocks, block_size >>> (a, N);


in .cu - and all works.