title: Cuda gridDim and blockDim
body: <p>I get what <code>blockDim</code> is, but I have a problem with <code>gridDim. Blockdim</code> gives the size of the block, but what is <code>gridDim</code>? On the Internet it says <code>gridDim.x</code> gives the number of blocks in the x coordinate.</p>
  
  <p>How can I know what <code>blockDim.x * gridDim.x</code> gives?</p>
  
  <p>How can I know that how many <code>gridDim.x</code> values are there in the x line?</p>
  
  <p>For example, consider the code below:</p>
  
  <pre><code>int tid = threadIdx.x + blockIdx.x * blockDim.x;
  double temp = a[tid];
  tid += blockDim.x * gridDim.x;
  
  while (tid &lt; count)
  {
      if (a[tid] &gt; temp)
      {
         temp = a[tid];
      }
      tid += blockDim.x * gridDim.x;
  }
  </code></pre>
  
  <p>I know that <code>tid</code> starts with 0. The code then has <code>tid+=blockDim.x * gridDim.x</code>. What is <code>tid</code> now after this operation?</p>