| 1 |
+ |
#ifndef lint |
| 2 |
+ |
static const char RCSid[] = "$Id$"; |
| 3 |
+ |
#endif |
| 4 |
+ |
|
| 5 |
|
/* |
| 6 |
|
================================================================== |
| 7 |
|
Photon map diagnostic output and progress reports |
| 8 |
|
|
| 9 |
|
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
| 10 |
|
(c) Fraunhofer Institute for Solar Energy Systems, |
| 11 |
< |
Lucerne University of Applied Sciences & Arts |
| 11 |
> |
(c) Lucerne University of Applied Sciences and Arts, |
| 12 |
> |
supported by the Swiss National Science Foundation (SNSF, #147053) |
| 13 |
|
================================================================== |
| 14 |
|
|
| 15 |
|
$Id$ |
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
+ |
#include "pmap.h" |
| 21 |
|
#include "pmapdiag.h" |
| 22 |
|
#include "pmapdata.h" |
| 23 |
|
#include "standard.h" |
| 26 |
|
|
| 27 |
|
time_t repStartTime, repLastTime = 0; /* Time at start & last report */ |
| 28 |
|
unsigned long repProgress, /* Report progress counter */ |
| 29 |
< |
repComplete; /* Report completion count */ |
| 29 |
> |
repComplete, /* Report completion count */ |
| 30 |
> |
repEmitted; /* Num emitted photons */ |
| 31 |
|
|
| 32 |
|
|
| 26 |
– |
|
| 33 |
|
static char* biasCompStats (const PhotonMap *pmap, PhotonMapType type, |
| 34 |
|
char *stats) |
| 35 |
|
/* Dump bias compensation statistics */ |
| 37 |
|
unsigned avgBwidth; |
| 38 |
|
float avgErr; |
| 39 |
|
|
| 40 |
+ |
stats [0] = '\0'; |
| 41 |
+ |
|
| 42 |
|
/* Check if photon map is valid and bias compensated */ |
| 43 |
|
if (pmap && pmap -> maxGather > pmap -> minGather) { |
| 44 |
|
avgBwidth = pmap -> numDensity |
| 46 |
|
avgErr = pmap -> numDensity |
| 47 |
|
? sqrt(pmap -> rmsError / pmap -> numDensity) : 0; |
| 48 |
|
|
| 49 |
< |
sprintf(stats, "%d/%d/%d %s (%.1f/%.1f/%.1f%% error), ", |
| 49 |
> |
sprintf(stats, "%d/%d/%d %s photon bwidth (%.1f/%.1f/%.1f%% error), ", |
| 50 |
|
pmap -> minGathered, pmap -> maxGathered, avgBwidth, |
| 51 |
|
pmapName [type], |
| 52 |
|
100 * pmap -> minError, 100 * pmap -> maxError, 100 * avgErr); |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
+ |
#ifdef PMAP_OOC |
| 79 |
+ |
static char* oocCacheStats (const PhotonMap *pmap, PhotonMapType type, |
| 80 |
+ |
char *stats) |
| 81 |
+ |
/* Dump OOC I/O cache statistics */ |
| 82 |
+ |
{ |
| 83 |
+ |
const OOC_Cache *cache; |
| 84 |
+ |
stats [0] = '\0'; |
| 85 |
+ |
|
| 86 |
+ |
|
| 87 |
+ |
/* Check for photon map is valid and caching enabled */ |
| 88 |
+ |
if (pmap && (cache = pmap -> store.cache) && cache -> numReads) { |
| 89 |
+ |
sprintf(stats, "%ld %s photons cached in %d/%d pages " |
| 90 |
+ |
"(%.1f%% hit, %.1f%% rept, %.1f coll), ", |
| 91 |
+ |
(unsigned long)cache -> pageCnt * cache -> recPerPage, |
| 92 |
+ |
pmapName [type], cache -> pageCnt, cache -> numPages, |
| 93 |
+ |
100.0 * cache -> numHits / cache -> numReads, |
| 94 |
+ |
100.0 * cache -> numRept / cache -> numReads, |
| 95 |
+ |
(float)cache -> numColl / cache -> numReads); |
| 96 |
+ |
|
| 97 |
+ |
return stats; |
| 98 |
+ |
} |
| 99 |
+ |
|
| 100 |
+ |
return NULL; |
| 101 |
+ |
} |
| 102 |
+ |
|
| 103 |
+ |
|
| 104 |
+ |
|
| 105 |
+ |
void pmapOOCCacheReport (char *stats) |
| 106 |
+ |
/* Append full OOC I/O cache statistics to stats; interface to rpict's |
| 107 |
+ |
* report() */ |
| 108 |
+ |
{ |
| 109 |
+ |
char tmp [512]; |
| 110 |
+ |
unsigned t; |
| 111 |
+ |
|
| 112 |
+ |
stats [0] = '\0'; |
| 113 |
+ |
|
| 114 |
+ |
for (t = 0; t < NUM_PMAP_TYPES; t++) |
| 115 |
+ |
if (oocCacheStats(photonMaps [t], t, tmp)) |
| 116 |
+ |
strcat(stats, tmp); |
| 117 |
+ |
} |
| 118 |
+ |
#endif |
| 119 |
+ |
|
| 120 |
+ |
|
| 121 |
+ |
|
| 122 |
|
#ifndef NON_POSIX |
| 123 |
|
void pmapPreCompReport() |
| 124 |
|
/* Report global photon precomputation progress */ |
| 125 |
|
{ |
| 126 |
|
extern char *myhostname(); |
| 127 |
< |
float u, s; |
| 127 |
> |
float u, s, rtime, eta, progress; |
| 128 |
|
char tmp [512]; |
| 129 |
|
|
| 130 |
|
#ifdef BSD |
| 161 |
|
/* Append bias compensation stats */ |
| 162 |
|
biasCompStats(preCompPmap, PMAP_TYPE_PRECOMP, tmp); |
| 163 |
|
strcat(errmsg, tmp); |
| 164 |
< |
|
| 165 |
< |
sprintf(tmp, "%4.2f%% after %.3fu %.3fs %.3fr hours on %s\n", |
| 166 |
< |
100.0 * repProgress / repComplete, u / 3600, s / 3600, |
| 167 |
< |
(repLastTime - repStartTime) / 3600.0, myhostname()); |
| 164 |
> |
|
| 165 |
> |
rtime = (repLastTime - repStartTime) / 3600.0; |
| 166 |
> |
progress = (float)repProgress / repComplete; |
| 167 |
> |
eta = max(0, rtime * (progress > FTINY ? 1 / progress - 1 : 0)); |
| 168 |
> |
|
| 169 |
> |
sprintf( |
| 170 |
> |
tmp, "%4.2f%% after %.3fu %.3fs %.3fr hours on %s, ETA=%.3fh\n", |
| 171 |
> |
100 * progress, u / 3600, s / 3600, rtime, myhostname(), eta |
| 172 |
> |
); |
| 173 |
|
strcat(errmsg, tmp); |
| 174 |
|
|
| 175 |
|
eputs(errmsg); |
| 176 |
|
fflush(stderr); |
| 177 |
|
|
| 178 |
< |
#ifndef BSD |
| 178 |
> |
#ifdef SIGCONT |
| 179 |
|
signal(SIGCONT, pmapPreCompReport); |
| 180 |
|
#endif |
| 181 |
|
} |
| 186 |
|
/* Report photon distribution progress */ |
| 187 |
|
{ |
| 188 |
|
extern char *myhostname(); |
| 189 |
< |
float u, s; |
| 189 |
> |
float u, s, rtime, eta, progress; |
| 190 |
|
unsigned t; |
| 191 |
|
char tmp [512]; |
| 192 |
|
|
| 219 |
|
s = (tbuf.tms_stime + tbuf.tms_cstime) * period; |
| 220 |
|
#endif |
| 221 |
|
|
| 222 |
< |
sprintf(errmsg, "%lu emitted, ", repProgress); |
| 222 |
> |
sprintf(errmsg, "%lu emitted, ", repEmitted); |
| 223 |
|
|
| 224 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
| 225 |
|
if (photonMaps [t]) { |
| 226 |
< |
sprintf(tmp, "%lu %s, ", |
| 227 |
< |
photonMaps [t] -> heapEnd, pmapName [t]); |
| 226 |
> |
sprintf(tmp, "%lu %s, ", photonMaps [t] -> numPhotons, |
| 227 |
> |
pmapName [t]); |
| 228 |
|
strcat(errmsg, tmp); |
| 229 |
|
} |
| 230 |
|
|
| 231 |
< |
sprintf(tmp, "%4.2f%% after %.3fu %.3fs %.3fr hours on %s\n", |
| 232 |
< |
100.0 * repProgress / repComplete, u / 3600, s / 3600, |
| 233 |
< |
(repLastTime - repStartTime) / 3600.0, myhostname()); |
| 234 |
< |
|
| 231 |
> |
rtime = (repLastTime - repStartTime) / 3600.0; |
| 232 |
> |
progress = (float)repProgress / repComplete; |
| 233 |
> |
eta = max(0, rtime * (progress > FTINY ? 1 / progress - 1 : 0)); |
| 234 |
> |
|
| 235 |
> |
sprintf( |
| 236 |
> |
tmp, "%4.2f%% after %.3fu %.3fs %.3fr hours on %s, ETA=%.3fh\n", |
| 237 |
> |
100 * progress, u / 3600, s / 3600, rtime, myhostname(), eta |
| 238 |
> |
); |
| 239 |
> |
|
| 240 |
|
strcat(errmsg, tmp); |
| 241 |
|
eputs(errmsg); |
| 242 |
|
fflush(stderr); |
| 243 |
|
|
| 244 |
< |
#ifndef BSD |
| 244 |
> |
#ifndef SIGCONT |
| 245 |
|
signal(SIGCONT, pmapDistribReport); |
| 246 |
|
#endif |
| 247 |
|
} |
| 251 |
|
void pmapPreCompReport() |
| 252 |
|
/* Report global photon precomputation progress */ |
| 253 |
|
{ |
| 254 |
< |
char tmp [512]; |
| 254 |
> |
char tmp [512]; |
| 255 |
> |
float rtime, progress, eta; |
| 256 |
|
|
| 257 |
|
repLastTime = time(NULL); |
| 258 |
|
sprintf(errmsg, "%lu precomputed, ", repProgress); |
| 261 |
|
biasCompStats(preCompPmap, PMAP_TYPE_PRECOMP, tmp); |
| 262 |
|
strcat(errmsg, tmp); |
| 263 |
|
|
| 264 |
< |
sprintf(tmp, "%4.2f%% after %5.4f hours\n", |
| 265 |
< |
100.0 * repProgress / repComplete, |
| 266 |
< |
(repLastTime - repStartTime) / 3600.0); |
| 264 |
> |
rtime = (repLastTime - repStartTime) / 3600.0; |
| 265 |
> |
progress = (float)repProgress / repComplete; |
| 266 |
> |
eta = max(0, rtime * (progress > FTINY ? 1 / progress - 1 : 0)); |
| 267 |
> |
|
| 268 |
> |
sprintf( |
| 269 |
> |
tmp, "%4.2f%% after %5.4f hours, ETA=%.3fh\n", |
| 270 |
> |
100 * progress, rtime, eta |
| 271 |
> |
); |
| 272 |
|
strcat(errmsg, tmp); |
| 273 |
|
|
| 274 |
|
eputs(errmsg); |
| 280 |
|
void pmapDistribReport() |
| 281 |
|
/* Report photon distribution progress */ |
| 282 |
|
{ |
| 283 |
< |
char tmp [512]; |
| 283 |
> |
char tmp [512]; |
| 284 |
|
unsigned t; |
| 285 |
+ |
float rtime, progress, eta; |
| 286 |
|
|
| 287 |
|
repLastTime = time(NULL); |
| 288 |
< |
sprintf(errmsg, "%lu emitted, ", repProgress); |
| 288 |
> |
sprintf(errmsg, "%lu emitted, ", repEmitted); |
| 289 |
|
|
| 290 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
| 291 |
|
if (photonMaps [t]) { |
| 292 |
< |
sprintf(tmp, "%lu %s, ", |
| 293 |
< |
photonMaps [t] -> heapEnd, pmapName [t]); |
| 292 |
> |
sprintf(tmp, "%lu %s, ", photonMaps [t] -> numPhotons, |
| 293 |
> |
pmapName [t]); |
| 294 |
|
strcat(errmsg, tmp); |
| 295 |
|
} |
| 296 |
< |
|
| 297 |
< |
sprintf(tmp, "%4.2f%% after %5.4f hours\n", |
| 298 |
< |
100.0 * repProgress / repComplete, |
| 299 |
< |
(repLastTime - repStartTime) / 3600.0); |
| 296 |
> |
|
| 297 |
> |
rtime = (repLastTime - repStartTime) / 3600.0; |
| 298 |
> |
progress = (float)repProgress / repComplete; |
| 299 |
> |
eta = max(0, rtime * (progress > FTINY ? 1 / progress - 1 : 0)); |
| 300 |
> |
|
| 301 |
> |
sprintf( |
| 302 |
> |
tmp, "%4.2f%% after %5.4f hours, ETA=%.3fh\n", |
| 303 |
> |
100 * progress, rtime, eta |
| 304 |
> |
); |
| 305 |
|
strcat(errmsg, tmp); |
| 306 |
|
|
| 307 |
|
eputs(errmsg); |