| 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$ |
| 25 |
|
|
| 26 |
|
time_t repStartTime, repLastTime = 0; /* Time at start & last report */ |
| 27 |
|
unsigned long repProgress, /* Report progress counter */ |
| 28 |
< |
repComplete; /* Report completion count */ |
| 28 |
> |
repComplete, /* Report completion count */ |
| 29 |
> |
repEmitted; /* Num emitted photons */ |
| 30 |
|
|
| 31 |
|
|
| 26 |
– |
|
| 32 |
|
static char* biasCompStats (const PhotonMap *pmap, PhotonMapType type, |
| 33 |
|
char *stats) |
| 34 |
|
/* Dump bias compensation statistics */ |
| 36 |
|
unsigned avgBwidth; |
| 37 |
|
float avgErr; |
| 38 |
|
|
| 39 |
+ |
stats [0] = '\0'; |
| 40 |
+ |
|
| 41 |
|
/* Check if photon map is valid and bias compensated */ |
| 42 |
|
if (pmap && pmap -> maxGather > pmap -> minGather) { |
| 43 |
|
avgBwidth = pmap -> numDensity |
| 45 |
|
avgErr = pmap -> numDensity |
| 46 |
|
? sqrt(pmap -> rmsError / pmap -> numDensity) : 0; |
| 47 |
|
|
| 48 |
< |
sprintf(stats, "%d/%d/%d %s (%.1f/%.1f/%.1f%% error), ", |
| 48 |
> |
sprintf(stats, "%d/%d/%d %s photon bwidth (%.1f/%.1f/%.1f%% error), ", |
| 49 |
|
pmap -> minGathered, pmap -> maxGathered, avgBwidth, |
| 50 |
|
pmapName [type], |
| 51 |
|
100 * pmap -> minError, 100 * pmap -> maxError, 100 * avgErr); |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
+ |
#ifdef PMAP_OOC |
| 78 |
+ |
static char* oocCacheStats (const PhotonMap *pmap, PhotonMapType type, |
| 79 |
+ |
char *stats) |
| 80 |
+ |
/* Dump OOC I/O cache statistics */ |
| 81 |
+ |
{ |
| 82 |
+ |
const OOC_Cache *cache; |
| 83 |
+ |
stats [0] = '\0'; |
| 84 |
+ |
|
| 85 |
+ |
|
| 86 |
+ |
/* Check for photon map is valid and caching enabled */ |
| 87 |
+ |
if (pmap && (cache = pmap -> store.cache) && cache -> numReads) { |
| 88 |
+ |
sprintf(stats, "%ld %s photons cached in %d/%d pages " |
| 89 |
+ |
"(%.1f%% hit, %.1f%% rept, %.1f coll), ", |
| 90 |
+ |
(unsigned long)cache -> pageCnt * cache -> recPerPage, |
| 91 |
+ |
pmapName [type], cache -> pageCnt, cache -> numPages, |
| 92 |
+ |
100.0 * cache -> numHits / cache -> numReads, |
| 93 |
+ |
100.0 * cache -> numRept / cache -> numReads, |
| 94 |
+ |
(float)cache -> numColl / cache -> numReads); |
| 95 |
+ |
|
| 96 |
+ |
return stats; |
| 97 |
+ |
} |
| 98 |
+ |
|
| 99 |
+ |
return NULL; |
| 100 |
+ |
} |
| 101 |
+ |
|
| 102 |
+ |
|
| 103 |
+ |
|
| 104 |
+ |
void pmapOOCCacheReport (char *stats) |
| 105 |
+ |
/* Append full OOC I/O cache statistics to stats; interface to rpict's |
| 106 |
+ |
* report() */ |
| 107 |
+ |
{ |
| 108 |
+ |
char tmp [512]; |
| 109 |
+ |
unsigned t; |
| 110 |
+ |
|
| 111 |
+ |
stats [0] = '\0'; |
| 112 |
+ |
|
| 113 |
+ |
for (t = 0; t < NUM_PMAP_TYPES; t++) |
| 114 |
+ |
if (oocCacheStats(photonMaps [t], t, tmp)) |
| 115 |
+ |
strcat(stats, tmp); |
| 116 |
+ |
} |
| 117 |
+ |
#endif |
| 118 |
+ |
|
| 119 |
+ |
|
| 120 |
+ |
|
| 121 |
|
#ifndef NON_POSIX |
| 122 |
|
void pmapPreCompReport() |
| 123 |
|
/* Report global photon precomputation progress */ |
| 169 |
|
eputs(errmsg); |
| 170 |
|
fflush(stderr); |
| 171 |
|
|
| 172 |
< |
#ifndef BSD |
| 172 |
> |
#ifdef SIGCONT |
| 173 |
|
signal(SIGCONT, pmapPreCompReport); |
| 174 |
|
#endif |
| 175 |
|
} |
| 213 |
|
s = (tbuf.tms_stime + tbuf.tms_cstime) * period; |
| 214 |
|
#endif |
| 215 |
|
|
| 216 |
< |
sprintf(errmsg, "%lu emitted, ", repProgress); |
| 216 |
> |
sprintf(errmsg, "%lu emitted, ", repEmitted); |
| 217 |
|
|
| 218 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
| 219 |
|
if (photonMaps [t]) { |
| 220 |
< |
sprintf(tmp, "%lu %s, ", |
| 221 |
< |
photonMaps [t] -> heapEnd, pmapName [t]); |
| 220 |
> |
sprintf(tmp, "%lu %s, ", photonMaps [t] -> numPhotons, |
| 221 |
> |
pmapName [t]); |
| 222 |
|
strcat(errmsg, tmp); |
| 223 |
|
} |
| 224 |
|
|
| 230 |
|
eputs(errmsg); |
| 231 |
|
fflush(stderr); |
| 232 |
|
|
| 233 |
< |
#ifndef BSD |
| 233 |
> |
#ifndef SIGCONT |
| 234 |
|
signal(SIGCONT, pmapDistribReport); |
| 235 |
|
#endif |
| 236 |
|
} |
| 267 |
|
unsigned t; |
| 268 |
|
|
| 269 |
|
repLastTime = time(NULL); |
| 270 |
< |
sprintf(errmsg, "%lu emitted, ", repProgress); |
| 270 |
> |
sprintf(errmsg, "%lu emitted, ", repEmitted); |
| 271 |
|
|
| 272 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
| 273 |
|
if (photonMaps [t]) { |
| 274 |
< |
sprintf(tmp, "%lu %s, ", |
| 275 |
< |
photonMaps [t] -> heapEnd, pmapName [t]); |
| 274 |
> |
sprintf(tmp, "%lu %s, ", photonMaps [t] -> numPhotons, |
| 275 |
> |
pmapName [t]); |
| 276 |
|
strcat(errmsg, tmp); |
| 277 |
|
} |
| 278 |
|
|