From 7110952440b996e3cba274e516a085c9dcef5861 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 28 Jul 2014 14:33:53 +0000 Subject: [PATCH] host: fix write_populations(). --- lb/hsrc/data.c | 23 +++++++++++++++-------- lb/hsrc/main.c | 4 ++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lb/hsrc/data.c b/lb/hsrc/data.c index a0482a7..675fe50 100644 --- a/lb/hsrc/data.c +++ b/lb/hsrc/data.c @@ -21,8 +21,7 @@ void fixsudo(const char *filename) /* write a (semi-) human-readable dump of the lattice */ -void write_populations(d2q9_block_t lattice[CORES_Y][CORES_X], - int core_x, int core_y, int iter) +void write_populations(d2q9_block_t lattice[CORES_Y][CORES_X], int iter) { FILE *file = fopen("populations.dat", "a"); if(!file) { @@ -30,13 +29,21 @@ void write_populations(d2q9_block_t lattice[CORES_Y][CORES_X], return; } - for(int y = 0; y < BLOCK_Y; y++) { - for(int x = 0; x < BLOCK_X; x++) { - fprintf(file, "%03d: [%02d,%02d]: ", iter, x, y); - for(int q = 0; q < 9; q++) { - fprintf(file, "%.5f\t", lattice[core_y][core_x][y][x][q]); + for(int cy = 0; cy < CORES_Y; cy++) { + for(int y = 0; y < BLOCK_Y; y++) { + for(int cx = 0; cx < CORES_X; cx++) { + for(int x = 0; x < BLOCK_X; x++) { + fprintf(file, "%3d: [%3d,%3d]: ", + iter, + cx * BLOCK_X + x, + cy * BLOCK_Y + y + ); + for(int q = 0; q < 9; q++) { + fprintf(file, "%.5f ", lattice[cy][cx][y][x][q]); + } + fprintf(file, "\n"); + } } - fprintf(file, "\n"); } } fprintf(file, "\n"); diff --git a/lb/hsrc/main.c b/lb/hsrc/main.c index 41ec1b1..7279891 100644 --- a/lb/hsrc/main.c +++ b/lb/hsrc/main.c @@ -14,7 +14,7 @@ /* helper functions */ void fixsudo(const char *filename); -void write_populations(d2q9_block_t lattice[CORES_Y][CORES_X], int core_x, int core_y, int iter); +void write_populations(d2q9_block_t lattice[CORES_Y][CORES_X], int iter); void write_image(d2q9_block_t lattice[CORES_Y][CORES_X], int iter); void write_animation(void); void write_timers(uint32_t timers[CORES_Y][CORES_X][TIMERS], uint32_t iter); @@ -103,7 +103,7 @@ int main() /* write data */ static uint32_t old0 = -1; if(states[0][0] != old0) { - write_populations(shm.lattice, 0, 0, states[0][0]); + write_populations(shm.lattice, states[0][0]); write_image(shm.lattice, states[0][0]); write_timers(shm.timers, states[0][0]); old0 = states[0][0]; -- 2.30.2