htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit 1a8e8e8f205b573a0a7e4251a9c12f9a36a1e0f2
parent f1c4a9deeccef5f8002e1be8258e101fdff37aa6
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu,  2 Aug 2018 15:27:19 +0200

Add a basic progress bar

Diffstat:
Msrc/htrdr_draw_radiance_sw.c | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/htrdr_draw_radiance_sw.c b/src/htrdr_draw_radiance_sw.c @@ -126,6 +126,8 @@ htrdr_draw_radiance_sw int32_t mcode; /* Morton code of the tile */ struct htrdr_buffer_layout layout; double pix_sz[2]; /* Pixel size in the normalized image plane */ + ATOMIC nsolved_tiles = 0; + ATOMIC progress = 0; ATOMIC res = RES_OK; ASSERT(htrdr && cam && buf); @@ -173,13 +175,22 @@ htrdr_draw_radiance_sw pix_sz[1] = 1.0 / (double)layout.height; #pragma omp parallel for schedule(static, 1/*chunck size*/) - for(mcode=0; mcode<(int32_t)ntiles; ++mcode) { + for(mcode=0; mcode<(int64_t)ntiles; ++mcode) { const int ithread = omp_get_thread_num(); struct ssp_rng* rng = rngs[ithread]; size_t tile_org[2]; size_t tile_sz[2]; + size_t pcent; + size_t n; res_T res_local = RES_OK; + n = (size_t)ATOMIC_INCR(&nsolved_tiles); + pcent = n * 100 / ntiles; + if((size_t)ATOMIC_CAS(&progress, pcent, pcent-1) == pcent-1) { + fprintf(stderr, "%c[2K\rProgress: %3lu%%", 27, (unsigned long)pcent); + fflush(stderr); + } + if(ATOMIC_GET(&res) != RES_OK) continue; /* Decode the morton code to retrieve the tile index */ @@ -203,6 +214,7 @@ htrdr_draw_radiance_sw continue; } } + fprintf(stderr, "\n"); exit: if(rng_proxy) SSP(rng_proxy_ref_put(rng_proxy));