YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Burst Utilization - Intro to Parallel Programming

Get Embed Code
2 Languages

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

  1. So the idea of the data layout transformation

  2. is to reorganize the way data is laid out in memory to facilitate better memory performance.
  3. So a really common example of this data layout transformation
  4. is something we've seen before where we take data,
  5. which is laid out as an array of structures, like so.
  6. An array of structures.
  7. And transform it into a structure of arrays.
  8. Here's what those layouts would look like in memory.
  9. In the first case,
  10. the different fields in the structure are laid out one after another.
  11. Each structure is adjacent.
  12. In the next case, they're all laid out adjacently.
  13. So as a quick quiz,
  14. which of these 2 layouts: the array of structures or AOS or the structure of arrays, SOA,
  15. will perform better on the little code snippets I've given here?
  16. So you set i equal to the thread index.
  17. And then we access field a for a given thread.
  18. And then we access field b, c, and d.
  19. And then over here I've done the same code,
  20. but I've transformed it to use this data layout.
  21. So the question is to check off, which of these 2 data layouts you think will perform better?