Fill faces.neighbors and nodes.coordinates along columns (i.e., unit stride in MATLAB). This means non-unit (but constant, 2 or 3) stride in C whence memory pre-fetching will typically be helpful. The cost is a (large) memory "rewind" operation at the end of each column.

Signed-off-by: Bård Skaflestad <Bard.Skaflestad@sintef.no>
This commit is contained in:
Bård Skaflestad
2012-01-27 22:25:35 +00:00
committed by Bård Skaflestad
parent 982c04bcdb
commit a740a15d35

View File

@@ -89,9 +89,9 @@ fill_nodes(mxArray *nodes, struct processed_grid *grid)
nnodes = grid->number_of_nodes;
coords = mxGetPr(mxGetField(nodes, 0, "coords"));
for (i = 0; i < nnodes; ++i) {
for (j = 0; j < 3; ++j) {
coords[i + j*nnodes] = grid->node_coordinates[3*i + j];
for (j = 0; j < 3; ++j) {
for (i = 0; i < nnodes; ++i) {
*coords++ = grid->node_coordinates[3*i + j];
}
}
}
@@ -152,10 +152,11 @@ fill_faces(mxArray *faces, struct processed_grid *grid)
/* Fill faces.neighbors */
pi = mxGetData(mxGetField(faces, 0, "neighbors"));
for (f = 0; f < nf; f++) {
/* Add one for one-based indexing in M */
pi[f + 0*nf] = grid->face_neighbors[2*f + 0] + 1;
pi[f + 1*nf] = grid->face_neighbors[2*f + 1] + 1;
for (i = 0; i < 2; i++) {
for (f = 0; f < nf; f++) {
/* Add one for one-based indexing in M */
*pi++ = grid->face_neighbors[2*f + i] + 1;
}
}
/* Fill faces.nodePos */