Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

heat-tx: C updates to match the Go version.

  • Loading branch information...
commit a0f52a98d45b564c7b7b46d7cc6ea1aebc76cdf7 1 parent bf73c2c
@samuelkgutierrez samuelkgutierrez authored
Showing with 8 additions and 9 deletions.
  1. +1 −1  apps/heat-tx/c/Makefile
  2. +7 −8 apps/heat-tx/c/heat-tx.c
View
2  apps/heat-tx/c/Makefile
@@ -42,7 +42,7 @@
all: heat-tx
-CFLAGS = -Wall -Wextra -O1
+CFLAGS = -Wall -Wextra -Ofast
heat-tx: heat-tx.c
View
15 apps/heat-tx/c/heat-tx.c
@@ -357,6 +357,7 @@ run_simulation(simulation_t *sim)
uint64_t t_max = sim->params->max_t;
mesh_t *new_mesh = sim->new_mesh;
mesh_t *old_mesh = sim->old_mesh;
+ double *nci, *oci, *ocip, *ocin;
printf("o starting simulation...\n");
for (t = 0; t < t_max; ++t) {
@@ -364,15 +365,13 @@ run_simulation(simulation_t *sim)
printf(". starting iteration %"PRIu64" of %"PRIu64"\n", t, t_max);
}
for (i = 1; i < nx - 1; ++i) {
+ nci = new_mesh->cells[i];
+ oci = old_mesh->cells[i];
+ ocip = old_mesh->cells[i - 1];
+ ocin = old_mesh->cells[i + 1];
for (j = 1; j < ny - 1; ++j) {
- new_mesh->cells[i][j] =
- old_mesh->cells[i][j] +
- (cdtods2 *
- (old_mesh->cells[i + 1][j] +
- old_mesh->cells[i - 1][j] -
- 4.0 * old_mesh->cells[i][j] +
- old_mesh->cells[i][j + 1] +
- old_mesh->cells[i][j - 1]));
+ nci[j] = oci[j] + (cdtods2 * (ocin[j] + ocip[j] - 4.0 *
+ oci[j] + oci[j + 1] + oci[j - 1]));
}
}
/* swap the mesh pointers */
Please sign in to comment.
Something went wrong with that request. Please try again.