void Worker::ProcessIterations(PPM* engine) { u_int64_t photonPerIteration = engine->photonsFirstIteration; uint iterationCount; resetRayBuffer(); UpdateBBox(); LookupSetHitPoints(hitPointsStaticInfo_iterationCopy, hitPoints_iterationCopy); uint iter = 0; double previousIterTime = WallClockTime(); fprintf(stdout, "iteration, photons_iter, photons_total, photons_sec, total_time, radius, device\n"); while (iter < config->max_iters) { ++iter; double start = WallClockTime(); iterationCount = engine->IncIteration(); if (engine->GetIterationNumber() > MAX_ITERATIONS) { break; } photonPerIteration = engine->photonsFirstIteration; #if defined USE_SPPMPA || defined USE_SPPM BuildHitPoints(iterationCount); UpdateBBox(); #endif #if defined USE_SPPM || defined USE_PPM if (iterationCount == 1) InitRadius(iterationCount); #else InitRadius(iterationCount); #endif updateDeviceHitPoints(); ReHash(currentPhotonRadius2);//argument ignored in non-PA updateDeviceLookupAcc(); photonPerIteration = AdvancePhotonPath(photonPerIteration); getDeviceHitpoints(); #if defined USE_PPM AccumulateFluxPPM(iterationCount, photonPerIteration); #endif #if defined USE_SPPM AccumulateFluxSPPM(iterationCount, photonPerIteration); #endif #if defined USE_SPPMPA AccumulateFluxSPPMPA(iterationCount, photonPerIteration); #endif #if defined USE_PPMPA AccumulateFluxPPMPA(iterationCount, photonPerIteration); #endif UpdateSampleFrameBuffer(photonPerIteration); /** * iteration lock required in PhotonTracedTotal */ engine->incPhotonTracedTotal(photonPerIteration); //PushHitPoints(); profiler->additeratingTime(WallClockTime() - start); profiler->addIteration(1); if (profiler->iterationCount % 100 == 0) profiler->printStats(deviceID); // if (iterationCount % 50 == 0) // engine->SaveImpl(to_string<uint> (iterationCount, std::dec) + engine->fileName); #if defined USE_SPPM || defined USE_PPM const float radius = hitPoints_iterationCopy[0].accumPhotonRadius2; #else const float radius = currentPhotonRadius2; #endif const double time = WallClockTime(); const double totalTime = time - engine->startTime; const double iterTime = time - previousIterTime; // const float itsec = engine->GetIterationNumber() / totalTime; const uint photonTotal = engine->getPhotonTracedTotal(); const float photonSec = photonTotal / (totalTime * 1000.f); fprintf(stdout, "%d, %lu, %u, %f, %f, %f, %f, %d\n", iterationCount, photonPerIteration, photonTotal, photonSec, iterTime, totalTime, radius, getDeviceID()); previousIterTime = time; } }
void Worker::ProcessIterations(PPM* engine) { u_int64_t photonPerIteration = engine->photonsFirstIteration; uint iterationCount; resetRayBuffer(); UpdateBBox(); while (!boost::this_thread::interruption_requested()) { double start = WallClockTime(); if (engine->GetIterationNumber() > config->max_iters) { break; } iterationCount = engine->IncIteration(); photonPerIteration = engine->photonsFirstIteration; // #if defined USE_SPPMPA || defined USE_SPPM BuildHitPoints(iterationCount); UpdateBBox(); // #endif // #if defined USE_SPPM || defined USE_PPM // if (iterationCount == 1) // InitRadius(iterationCount); // #else InitRadius(iterationCount); // #endif updateDeviceHitPoints(); #ifndef REBUILD_HASH if (iterationCount == 1) #endif ReHash(currentPhotonRadius2);//argument ignored in non-PA #ifndef REBUILD_HASH if (iterationCount == 1) #endif updateDeviceLookupAcc(); photonPerIteration = AdvancePhotonPath(photonPerIteration); // #if defined USE_PPM // getDeviceHitpoints(); // AccumulateFluxPPM(iterationCount, photonPerIteration); // #endif // #if defined USE_SPPM // AccumulateFluxSPPM(iterationCount, photonPerIteration); // #endif // #if defined USE_SPPMPA AccumulateFluxSPPMPA(iterationCount, photonPerIteration); // #endif // #if defined USE_PPMPA // AccumulateFluxPPMPA(iterationCount, photonPerIteration); // getDeviceHitpoints(); // #endif UpdateSampleFrameBuffer(photonPerIteration); /** * iteration lock required in PhotonTracedTotal */ engine->incPhotonTracedTotal(photonPerIteration); profiler->additeratingTime(WallClockTime() - start); profiler->addIteration(1); //if (profiler->iterationCount % 20 == 0) // profiler->printStats(deviceID); //if (iterationCount % 100 == 0) // engine->SaveImpl(to_string<uint> (iterationCount, std::dec) + engine->fileName); printf("iteration %d finished\n", iterationCount); } //profiler->printStats(deviceID); }