title: CUDA Parallel Cross Product
body: <p>Disclaimer: I am fairly new to CUDA and parallel programming - so if you're not going to bother to answer my question, just ignore this, or at least point me to the right resources so I can find the answer myself.</p>
  
  <p>Here's the particular problem I'm looking to solve using parallel programming. I have some 1D arrays that store 3D vectors in this format -> <code>[v0x, v0y, v0z, ... vnx, vny, vnz]</code>, where <code>n</code> is the vector, and <code>x</code>, <code>y</code>, <code>z</code> are the respective components.</p>
  
  <p>Suppose I want to find the cross product between vectors <code>[v0, v1, ... vn]</code> in one array and their corresponding vectors <code>[v0, v1, ... vn]</code> in another array.</p>
  
  <p>The calculation is pretty straightforward without parallelization:</p>
  
  <pre><code>result[x] = vec1[y]*vec2[z] - vec1[z]*vec2[y];
  
  result[y] = vec1[z]*vec2[x] - vec1[x]*vec2[z];
  
  result[z] = vec1[x]*vec2[y] - vec1[y]*vec2[x];
  </code></pre>
  
  <p>The problem I'm having is understanding how to implement CUDA parallelization for the arrays I currently have. Since each value in the result vector is a separate calculation, I can effectively run the above calculation for each vector in parallel. Since each component of the resulting cross product is a separate calculation, those too could run in parallel. How would I go about setting up the blocks and threads/ go about thinking about setting up the threads for such a problem?</p>