English subtitles

← Cubing Numbers Using CUDA - Intro to Parallel Programming

Get Embed Code
3 Languages

Showing Revision 4 created 05/24/2016 by Udacity Robot.

  1. Okay, so let's see ho we'd solve this problem.
  2. The first thing we're going to do is to change the square routine into a cubed routine
  3. and change the math accordingly.
  4. So now we're going to change square to cube.
  5. And instead of computing f x f, now we simply compute f x f x f.
  6. Now, since our new name is cube here, we are going to have to scroll all the way back down here.
  7. And instead of launching square, we've now launched q.
  8. The next thing we have to change is the allocation.
  9. Now, instead of running this on 64 elements, we want to run this on 96 elements.
  10. We've conveniently written this code such that everything is done in terms of array size, including the allocations.
  11. That should be all that we need to do.
  12. Now, let's go over to my shell window and demonstrate that this works, okay?
  13. Now we're going to do it in our own terminal window.
  14. First, I'll make sure to show you that I actually made the changes in this file.
  15. Notice that we now have a cube routine, f x f x f and now 96.
  16. Now, we're going to compile it into a cube executable.
  17. Then we're going to run it.
  18. Notice that instead of printing out squares now it prints 0, 1, 8, 27 and so on.
  19. Ninety-six cubes altogether.
  20. Okay, good work. Let's move on.