All pastes #57706 Raw Edit

cache misses

public text v1 · immutable
#57706 ·published 2006-05-21 19:26 UTC
rendered paste body
int main(void) {
	matrix::point3 p(0.0,0.0,0.0);
	const int SIZE = 100000;
	matrix::point3* a = new matrix::point3[SIZE];
	matrix::point3* b = new matrix::point3[SIZE];
	for (int i = 0; i < SIZE; ++i) {
		a[i] = matrix::point3(i, i+1, i+2);
		b[i] = matrix::point3(i+3, i+4, i+5);
	}


        // loop doing the work - gives SIZE/2 cache misses
	for (int i =0; i < SIZE; i+=2) {
		a[i] = a[i] + b[i];
		a[i+1] = a[i+1] + b[i+1];
	}

	return 0;
}