arrays

Stephen Weeks MLton@sourcelight.com
Wed, 3 Jan 2001 09:13:50 -0800 (PST)


> I did some quick tests of converting arrays with fat elements  into  parallel
> arrays.  The case I tried was an
>     (int * int * int) vector
> vs.
>     int vector * int vector * int vector
> and  a routine which added up, for all the elements in the vector, either all
> 3 fields together or just the last field.  (The notion is to  pick  which  on
> the basis of command line arguments so MLton won't optimize away any parts of
> the arrays.)
...
> This  saved  a lot of space (20 bytes per for the normal and 12 bytes for the
> `improved).  Interestingly, in the case where  you  couldn't  fit  everything
> into the L1 cache it sped things up by a lot because the tuple of vectors DID
> make it into the L1.  It make things 2-3 times faster, depending  on  if  you
> fit in the L2 cache or not.

I assume you meant L1 here.  Anyways, the conclusion I draw is that the
flattening optimization is worth it, even in the current CPS IL, because it
saves space, and may save time.