title: Optimizing a nested for-loop using CUDA
body: <p>So I have a project I'm working on that uses OpenCV to detect motion in moving objects. I'm trying to speed up the detection and have a nested for-loop that I want to speed up using CUDA. I have CUDA integration all set up in Visual Basic. Here is the nested for-loop in my .cpp file. </p>
  
  <pre><code>      for (int i=0; i&lt;NumberOfFeatures; i++)
    {
      // Compute integral image.
      cvIntegral(mFeatureImgs[i], mFirstOrderIIs[i]);
  
      for (int j=0; j&lt;NumberOfFeatures; j++)
      {
        // Compute product feature image.
        cvMul(mFeatureImgs[i], mFeatureImgs[j], mWorker);
  
        // Compute integral image.
        cvIntegral(mWorker, mSecondOrderIIs[i][j]);
      }
    }
  </code></pre>
  
  <p>I'm relatively new to CUDA, so my question is, could someone show me an example of how exactly I would make this nested for-loop go faster using CUDA? </p>