Now we are getting to the most interesting part of the curse.
It really helps knowing to know how matrices are stored in memory. Are they colum-major, or row-major? Julia is like Fortran, storing matrices as column-major data structures; while C uses row-major data structures.
So then in your implementation of the simulation of Life, the Universe, and Everything, then might need to have big matrices; and you might save a lot of Big-Thought's computing time by knowing if it is faster to traverse your Big-Matrix by the columns-first, or by rows-first.
If you have a lot of 0 entries in your matrix, then instead of allocating a big rectangular block of memory for it, then rather store it as a list of non-zero entries instead. For example, if you had a diagonal-matrix you really would only need one vector to store the data, right? And similarily, a tri-diagonal one would need 3.
A powerful example: What's a clever algorithm to transpose a matrix? Just flip the indices!
When you have data in the big memory and you want it in the cache - what do you do? Where can it be? The main philosophy here is: How do we reuse data that is already in the cache?
It might go something like this:
Byte-1 of main memory can only go to Byte-1 in the cache
Byte-2 of main memory can only go to Byte-2 in the cache
Byte-1024 of main memory can only go to Byte-1024 in the cache
Byte-1025 of main memory can only go to Byte-1 in the cache
Reading a cache like this is very fast, as you don't have to search for the data too long - every byte has a fixed and known location. But the main downside is: you rarely use the whole cache!
Solution to this is called padding.
Guðmundur Kári Stefánsson| 500px | vimeo | facebook |
email: gws5257 [at] psu.edu
09 March 2015 Installing a CDK24 Telescope at Penn State
06 December 2014 A Day in Pittsburgh
12 November 2014 HET trip - Results
11 November 2014 HET trip - day 1
01 October 2014 Black Moshannon State Park Observing
29 September 2014 HPF MLI blanket fabrication
19 September 2014 MLI Blankets
11 August 2014 HPF subsystem assembly
21 July 2014 Astrofest 2014
13 June 2014 HPF - Keeping it cool