MCPcopy Create free account
hub / github.com/devosoft/avida / ProcessStepSpeculative

Method ProcessStepSpeculative

avida-core/source/main/cPopulation.cc:5731–5779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5729
5730
5731void cPopulation::ProcessStepSpeculative(cAvidaContext& ctx, double step_size, int cell_id)
5732{
5733 assert(step_size > 0.0);
5734 assert(cell_id < cell_array.GetSize());
5735
5736 // If cell_id is negative, no cell could be found -- stop here.
5737 if (cell_id < 0) return;
5738
5739 cPopulationCell& cell = GetCell(cell_id);
5740 assert(cell.IsOccupied()); // Unoccupied cell getting processor time!
5741
5742 cOrganism* cur_org = cell.GetOrganism();
5743 cHardwareBase* hw = cell.GetHardware();
5744
5745 if (cell.GetSpeculativeState()) {
5746 // We have already executed this instruction, just decrement the counter
5747 cell.DecSpeculative();
5748 } else {
5749 // Execute the actual instruction
5750 if (hw->SingleProcess(ctx)) {
5751 // Speculatively execute additional instructions
5752 int spec_count = 0;
5753 while (spec_count < 32) {
5754 if (hw->SingleProcess(ctx, true)) spec_count++;
5755 else break;
5756 }
5757 cell.SetSpeculativeState(spec_count);
5758 m_world->GetStats().AddSpeculative(spec_count);
5759 }
5760 }
5761
5762 // Deme specific
5763 if (GetNumDemes() > 1) {
5764 for(int i = 0; i < GetNumDemes(); i++) GetDeme(i).Update(step_size);
5765
5766 cDeme& deme = GetDeme(GetCell(cell_id).GetDemeID());
5767 deme.IncTimeUsed(cur_org->GetPhenotype().GetMerit().GetDouble());
5768 CheckImplicitDemeRepro(deme, ctx);
5769 }
5770
5771 if (cur_org->GetPhenotype().GetToDelete() == true) {
5772 cur_org->GetHardware().DeleteMiniTrace(print_mini_trace_reacs);
5773 delete cur_org;
5774 cur_org = NULL;
5775 }
5776
5777 m_world->GetStats().IncExecuted();
5778 resource_count.Update(step_size);
5779}
5780
5781// Loop through all the demes getting stats and doing calculations
5782// which must be done on a deme by deme basis.

Callers

nothing calls this directly

Calls 15

IsOccupiedMethod · 0.80
GetHardwareMethod · 0.80
GetSpeculativeStateMethod · 0.80
DecSpeculativeMethod · 0.80
SetSpeculativeStateMethod · 0.80
AddSpeculativeMethod · 0.80
GetToDeleteMethod · 0.80
DeleteMiniTraceMethod · 0.80
IncExecutedMethod · 0.80
GetSizeMethod · 0.45
GetOrganismMethod · 0.45
SingleProcessMethod · 0.45

Tested by

no test coverage detected