title: Parallelize functions, Kernel inside Kernel is possible? gcc OpenCL
body: <p>I'm new in the world of OpenCL and I would like to increase my knowledge about it.</p>
  
  <p>I have tried to find information about how build 'complex functions' using OpenCL. For 'complex functions', I mean functions which could be parallelized and have a function inside that can be parallelized too.
  I have seen links like:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/7741256/calling-opencl-kernel-from-another-opencl-kernel">Calling OpenCL kernel from another OpenCL kernel</a></li>
  <li><a href="https://stackoverflow.com/questions/3979419/multiple-opencl-kernels">Multiple OpenCl Kernels</a></li>
  </ul>
  
  <p>And now, here I go with my question, I'm going to use an example:</p>
  
  <pre><code>// A and B are int vectors
  // The value of M and N are different!! M != N
  for(int i=0; i&lt;=M-2;i++){
    for(int j=i+1;j&lt;=M-1;j++){
      distance=calculate_distance(A[i],B[j]);
      //more sequential instructions
    }
  }
  </code></pre>
  
  <p>And the calculate_distance concatenate both vectors and has a loop:</p>
  
  <pre><code>for(int i=0; i&lt;=N-1;i++)
    // Some sequential instructions
  </code></pre>
  
  <p>Could this full fragment of code be parallelized? In that case How (this is the reason of the tittle kernel inside kernel)?</p>
  
  <p>Note:
   I'm using Intel(R) SDK for OpenCL - Offline Compiler 2012 ( Windows) to check my kernels.</p>
  
  <p>Thanks in advance</p>