basic formula to compute number of blocks needed in cuda kernel
===

i was having some difficulty with getting the correct number of blocks per grid in CUDA.
can anyone show basic formula to compute number of blocks needed in CUDA kernel for 2D one? (i.e. gridDim.x and gridDim.y) given the fact that user wants to run N total number of threads, and his blocks are A by A, or for simple case let's assume his blocks are 8 by 8. thanks again. also can you point which things we have to keep in my mind, for example does it really matter whether they are powers of two or not... 