Bit subscriptions, RAM columnwise layouts

BCS ao at
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...


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);

More information about the Digitalmars-d mailing list