--- ray/src/rt/pmapdiag.c 2015/04/21 19:16:51 2.2 +++ ray/src/rt/pmapdiag.c 2016/05/17 17:39:47 2.7 @@ -1,13 +1,18 @@ +#ifndef lint +static const char RCSid[] = "$Id: pmapdiag.c,v 2.7 2016/05/17 17:39:47 rschregle Exp $"; +#endif + /* ================================================================== Photon map diagnostic output and progress reports Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) (c) Fraunhofer Institute for Solar Energy Systems, - Lucerne University of Applied Sciences & Arts + (c) Lucerne University of Applied Sciences and Arts, + supported by the Swiss National Science Foundation (SNSF, #147053) ================================================================== - $Id: pmapdiag.c,v 2.2 2015/04/21 19:16:51 greg Exp $ + $Id: pmapdiag.c,v 2.7 2016/05/17 17:39:47 rschregle Exp $ */ @@ -20,10 +25,10 @@ time_t repStartTime, repLastTime = 0; /* Time at start & last report */ unsigned long repProgress, /* Report progress counter */ - repComplete; /* Report completion count */ + repComplete, /* Report completion count */ + repEmitted; /* Num emitted photons */ - static char* biasCompStats (const PhotonMap *pmap, PhotonMapType type, char *stats) /* Dump bias compensation statistics */ @@ -31,6 +36,8 @@ static char* biasCompStats (const PhotonMap *pmap, Pho unsigned avgBwidth; float avgErr; + stats [0] = '\0'; + /* Check if photon map is valid and bias compensated */ if (pmap && pmap -> maxGather > pmap -> minGather) { avgBwidth = pmap -> numDensity @@ -38,7 +45,7 @@ static char* biasCompStats (const PhotonMap *pmap, Pho avgErr = pmap -> numDensity ? sqrt(pmap -> rmsError / pmap -> numDensity) : 0; - sprintf(stats, "%d/%d/%d %s (%.1f/%.1f/%.1f%% error), ", + sprintf(stats, "%d/%d/%d %s photon bwidth (%.1f/%.1f/%.1f%% error), ", pmap -> minGathered, pmap -> maxGathered, avgBwidth, pmapName [type], 100 * pmap -> minError, 100 * pmap -> maxError, 100 * avgErr); @@ -67,6 +74,50 @@ void pmapBiasCompReport (char *stats) +#ifdef PMAP_OOC + static char* oocCacheStats (const PhotonMap *pmap, PhotonMapType type, + char *stats) + /* Dump OOC I/O cache statistics */ + { + const OOC_Cache *cache; + stats [0] = '\0'; + + + /* Check for photon map is valid and caching enabled */ + if (pmap && (cache = pmap -> store.cache) && cache -> numReads) { + sprintf(stats, "%ld %s photons cached in %d/%d pages " + "(%.1f%% hit, %.1f%% rept, %.1f coll), ", + (unsigned long)cache -> pageCnt * cache -> recPerPage, + pmapName [type], cache -> pageCnt, cache -> numPages, + 100.0 * cache -> numHits / cache -> numReads, + 100.0 * cache -> numRept / cache -> numReads, + (float)cache -> numColl / cache -> numReads); + + return stats; + } + + return NULL; + } + + + + void pmapOOCCacheReport (char *stats) + /* Append full OOC I/O cache statistics to stats; interface to rpict's + * report() */ + { + char tmp [512]; + unsigned t; + + stats [0] = '\0'; + + for (t = 0; t < NUM_PMAP_TYPES; t++) + if (oocCacheStats(photonMaps [t], t, tmp)) + strcat(stats, tmp); + } +#endif + + + #ifndef NON_POSIX void pmapPreCompReport() /* Report global photon precomputation progress */ @@ -118,7 +169,7 @@ void pmapBiasCompReport (char *stats) eputs(errmsg); fflush(stderr); - #ifndef BSD + #ifdef SIGCONT signal(SIGCONT, pmapPreCompReport); #endif } @@ -162,12 +213,12 @@ void pmapBiasCompReport (char *stats) s = (tbuf.tms_stime + tbuf.tms_cstime) * period; #endif - sprintf(errmsg, "%lu emitted, ", repProgress); + sprintf(errmsg, "%lu emitted, ", repEmitted); for (t = 0; t < NUM_PMAP_TYPES; t++) if (photonMaps [t]) { - sprintf(tmp, "%lu %s, ", - photonMaps [t] -> heapEnd, pmapName [t]); + sprintf(tmp, "%lu %s, ", photonMaps [t] -> numPhotons, + pmapName [t]); strcat(errmsg, tmp); } @@ -179,7 +230,7 @@ void pmapBiasCompReport (char *stats) eputs(errmsg); fflush(stderr); - #ifndef BSD + #ifndef SIGCONT signal(SIGCONT, pmapDistribReport); #endif } @@ -216,12 +267,12 @@ void pmapBiasCompReport (char *stats) unsigned t; repLastTime = time(NULL); - sprintf(errmsg, "%lu emitted, ", repProgress); + sprintf(errmsg, "%lu emitted, ", repEmitted); for (t = 0; t < NUM_PMAP_TYPES; t++) if (photonMaps [t]) { - sprintf(tmp, "%lu %s, ", - photonMaps [t] -> heapEnd, pmapName [t]); + sprintf(tmp, "%lu %s, ", photonMaps [t] -> numPhotons, + pmapName [t]); strcat(errmsg, tmp); }