a very simple problem

I am just starting (like today) to program in CUDA. So i copied the makefile off one of the SDK examples and renamed some variables to make it make my own file.

The problem is that i cant get the compiler to recognise the built in variable threadIdx. I have a very simple program and i am using the command make emu=1 so that i can have printf statements in there.

Here is my code

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

#include <math.h>

// includes, project

#include <cufft.h>

#include <cutil.h>

void some(){

        int test = threadIdx.x;



int main(int argc, char** argv)



   CUT_EXIT(argc, argv);


and the compiler error message i get is:

-bash-3.2$ make emu=1

dave1.cu: In function 'void some()':

dave1.cu:13: error: 'threadIdx' was not declared in this scope

make: *** [obj/emurelease/dave1.cu_o] Error 255


What am i doing wrong?

dont post the same thing 3 times, it doesnt make it more likely your problem will be answered at all.

I am agree with qazax.

but i want to answer your problem
tell me that what do you want your code does?
just want to see the thread index to make sure your program work fine.
I think that the threadIdx.x only work on the kernel function but i don’t see any kernel function in your code

"printf " statements can use outside of kernel function