Bit subscriptions, RAM columnwise layouts
BCS
ao at pathlink.com
Sat Dec 13 13:10:09 PST 2008
Reply to Benjamin,
> Reply to bearophile,
>
>> So today the caches have changed a little how optimal code has to be
>> written in C. The authors say that a downside of C is that it forces
>> the programmer to do such memory layout manually, and today this may
>> lead to less performance.
>>
> Darn you, now I'm going to need to wright a column struct array
> template that takes a struct and stripes the columns.
>
> OTOH this is going to be fun...
>
Done:
http://www.dsource.org/projects/scrapple/browser/trunk/columns/columns.d
not to fancy but supports code like this:
struct Foo
{
float k;
int i;
uint j;
void print(){writef("%s, %s, %s\n", k, i, j);}
}
Foo foo;
Columns!(Foo) FooCol;
FooCol.length = 10;
for(int i = 0; i < 10; i++)
{
foo.k = 3.14 * i;
foo.i = -3 - i;
FooCol[i] = foo;
FooCol[i].j = 5 + i;
}
foreach(float f; FooCol.k) writef("%s ", f); writef(\n);
foreach(int i; FooCol.i) writef("%s ", i); writef(\n);
foreach(uint u; FooCol.j) writef("%s ", u); writef(\n);
FooCol[3].FullItem.print();
More information about the Digitalmars-d
mailing list