Jump to content

Talk:Parallel array

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

I'm not sure I follow the logic for one of the advantages mentioned:

If the number of items is small, array indices can occupy significantly less space than full pointers, particularly on architectures with large words.

Let's assume In the case of the C code, the non-parallel array version would use a struct like so:

struct person_t {
    int age;
    char* name;
    int parent;
};
struct person_t person[] = 
{
    { 0,  "None",  0 /*None*/ },
    { 17, "Mike",  3 /*Tom*/  },
    { 2,  "Billy", 1 /*Mike*/ },
    { 52, "Tom",   0 /*None*/ },
    { 25, "Stan",  3 /*Tom*/  }
};

Assume a 64-bit system, where pointers are 8 bytes long, whereas indices for this array can be a byte (because there's only 5 items), why would the above data-structure take up more space than the parallel array version:

int  ages[]   = {0,          17,        2,          52,         25};
char *names[] = {"None",     "Mike",    "Billy",    "Tom",      "Stan"};
int  parent[] = {0 /*None*/, 3 /*Tom*/, 1 /*Mike*/, 0 /*None*/, 3 /*Tom*/};

Kasajian (talk) 09:57, 9 December 2009 (UTC)[reply]

Simpler to understand?

[edit]

Hi, I've a bit of a problem with the following statement:

Parallel arrays are simple to understand and use, and are often used where declaring a record is more trouble than it's worth.

I know that this is purely annecdotal, but I've worked in code that makes heavy use of parallel arrays instead of records (or similar data types), and it is a nightmare for anything but the most trivial. So, how exactly parallel arrays are simple to understand? How would one go about qualifying and quantifying such a statement? Maybe such a statement should be accompanied by some type of code sample comparisons (using parallel arrays and record types). Nevertheless, I'd be very hard press to find an example where, conceptually, the former is simpler to understand than the later. — Preceding unsigned comment added by Elnyka (talkcontribs) 21:36, 19 September 2011 (UTC)[reply]

SoA and AoS

[edit]

i'd just created an article SoA and AoS to explain these terms directly from the perspective of SIMD programming, but I later found this article after going on a linking-spree. A lot of the material is replicated, but presented slightly differently (from the exact perspective of SIMD).

What I was really after was good redirects for the terms AoS and SoA; and the new article defines and contrasts these two layouts.


Alternatively, could anyone suggest how these terms differ. e.g. "SoA explicitely refers to a struct of parallel arrays." 'parallel arrays could be globals or locals, or multiple fields per parallel array' etc. Are the terms really synonymous and intel just wanted a handy pair of contrasting acronyms.— Preceding unsigned comment added by Fmadd (talkcontribs) 00:59, 12 June 2016 (UTC)[reply]