title: "CudaLaunch returned (0x9)", and program timing issues
body: <p>I wrote a CUDA program, I have two questions about this program.</p>
  
  <ol>
  <li><p>When I call the kernel function, I know that <strong><em>block_len</em></strong> must be &lt;= 1024, but I still set <strong><em>block_len</em></strong>> 1024. When I debugged with cuda-gdb and Nsight, there was an expected "cudaLaunch returned (0x9)" error. If I run the program without debug, the program runs smoothly and the result of the calculation is the same as using the CPU (without parallelism), indicating that my calculations are correct. Why the wrong program can get the correct result？</p></li>
  <li><p>The program will calculate an <strong><em>length * length</em></strong> matrix A, the calculation of each element of A is done by one thread, ngridDim is set to (1,1). When <strong><em>length</em></strong> &lt;32, the execution time of </p>
  
  <pre><code>kernel &lt;&lt;&lt; (1,1), (length, length) &gt;&gt;&gt; 
  </code></pre>
  
  <p>changes according to the regularity of the size of <strong><em>length</em></strong>. When <strong><em>length</em></strong>> 32, the time spent by the kernel suddenly decreases 100-1000 times. I first suspect that my timing code is wrong, but after checking, I think there is no mistake. Later, I will attach the timing code.What causes such a result？</p>
  
  <pre><code>dim3 dimBlock(length, length);
  dim3 dimGrid(1, 1);
  
  float a2;
  cudaEvent_t t1, t2;
  cudaEventCreate(&amp;t1);
  cudaEventCreate(&amp;t2);
  
  cudaEventRecord(t1, 0);
  kernel&lt;&lt;&lt;dimGrid, dimBlock&gt;&gt;&gt;(dev_d, dev_D);
  cudaEventRecord(t2, 0);
  
  cudaEventSynchronize(t1);
  cudaEventSynchronize(t2);
  cudaEventElapsedTime(&amp;a2,t1,t2);
  printf("kernel time: %f (ms)\n",a2);
  </code></pre></li>
  </ol>
  
  <p>If length=32,the kernel time is:</p>
  
  <pre><code>    kernel time: 37.341919 (ms)
  </code></pre>
  
  <p>If length=33,the kernel time is:</p>
  
  <pre><code>    kernel time: 0.004128 (ms)
  </code></pre>
  
  <p><strong>Some information of my device:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/0LLaW.png" alt="Information of my devices screenshot"></p>