The importance of alignment on a VAX

Eugene D. Brooks III brooks at lll-crg.ARPA
Mon Mar 18 03:37:48 AEST 1985


For those who think that aligment is not important on a VAX I suggest your
actually trying a code without alignment before makeing any claims that it
is not important.  The very simple example

	for(i = 0; i < NTIMES; i += 1) {
		fa = fb + fc;
		da = db + dc;
		ia = ib + ic;
	}

Where the variables f, d, i are floats, doubles and ints in static data
has a speed reduction of a factor of two if you take out the .align pseudos
and padd in some bytes to break alignment.  Alignmet if very important
as far as performance is concerned.

For those who want to read structures from files using a single read
the best course to follow is write the stuff into the file using the
same structure.  The padding for alignment is automatically taken care of.
If the padding cant be tolerated then the most portable course of action
is to read each data item into the structure seperately.  This will save you
a lot of headaches when moving your code from one machine to another.



More information about the Comp.lang.c mailing list