Eight Useful Bytes
struct particle {
double x, y, z;
double vx, vy, vz;
unsigned id;
};
static struct particle p[100000];
double centroid_x(void) {
double t = 0.0;
for (int i = 0; i < 100000; i++) t += p[i].x;
return t / 100000.0;
}
sizeof(struct particle) is 56 (six doubles, one unsigned, four bytes of tail padding for 8-byte alignment). Cache lines are 64 bytes and the array is far larger than any cache.
How many bytes does centroid_x pull in from memory?
Sign in to answer questions and track your progress
Sign In