[Avida-SVN] r1109 - in development: Avida.xcodeproj source/analyze source/cpu source/main
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Fri Dec 1 22:53:57 PST 2006
Author: brysonda
Date: 2006-12-02 01:53:56 -0500 (Sat, 02 Dec 2006)
New Revision: 1109
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/analyze/cMutationalNeighborhood.cc
development/source/cpu/cHardwareCPU.cc
development/source/main/cInstSet.h
development/source/main/cOrganism.cc
development/source/main/cTaskContext.h
Log:
Addressed a possible cause of the consistency bug introduced into cHardwareCPU at r1100. Call to GetAddlTimeUsed was using cur_inst reference that is not guaranteed to be valid after instruction execution (i.e. after a divide instruction, the genome may be truncated, etc.).
Also cleaned up code that was causing a few warnings.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2006-11-30 21:05:30 UTC (rev 1108)
+++ development/Avida.xcodeproj/project.pbxproj 2006-12-02 06:53:56 UTC (rev 1109)
@@ -547,8 +547,6 @@
7054A1B409A810CB00038658 /* cAnalyzeJobWorker.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeJobWorker.cc; sourceTree = "<group>"; };
7057886F0A21FE8D00E85D8E /* cFixedBlock.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cFixedBlock.cc; sourceTree = "<group>"; };
705788700A21FE8D00E85D8E /* cFixedCoords.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cFixedCoords.cc; sourceTree = "<group>"; };
- 705788710A21FE8D00E85D8E /* nTemplateTests.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = nTemplateTests.cc; sourceTree = "<group>"; };
- 705788720A21FE8D00E85D8E /* nTemplateTests.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nTemplateTests.h; sourceTree = "<group>"; };
705ABB170A8A6A6000A6A80E /* EnvironmentActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnvironmentActions.h; sourceTree = "<group>"; };
705ABB180A8A6A6000A6A80E /* EnvironmentActions.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnvironmentActions.cc; sourceTree = "<group>"; };
705ACD4C0A13FED4002D5BA0 /* PrintActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintActions.h; sourceTree = "<group>"; };
@@ -1567,8 +1565,6 @@
703CA3760A5073CD00AB4DB4 /* SConscript */,
7057886F0A21FE8D00E85D8E /* cFixedBlock.cc */,
705788700A21FE8D00E85D8E /* cFixedCoords.cc */,
- 705788710A21FE8D00E85D8E /* nTemplateTests.cc */,
- 705788720A21FE8D00E85D8E /* nTemplateTests.h */,
700E11BC0A0815B600B604CD /* cDataEntry.cc */,
70B08B9008FB2E6B00FC65FE /* cTools.cc */,
70B08B9108FB2E6B00FC65FE /* cWeightedIndex.cc */,
Modified: development/source/analyze/cMutationalNeighborhood.cc
===================================================================
--- development/source/analyze/cMutationalNeighborhood.cc 2006-11-30 21:05:30 UTC (rev 1108)
+++ development/source/analyze/cMutationalNeighborhood.cc 2006-12-02 06:53:56 UTC (rev 1109)
@@ -350,7 +350,7 @@
// @TODO - Do post relative fitness determination for target task counts
sPendingTarget* pend = NULL;
- while (pend = m_pending.Pop()) {
+ while ((pend = m_pending.Pop())) {
double fitness = m_fitness[pend->site][pend->inst];
if (fitness == 0.0)
Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc 2006-11-30 21:05:30 UTC (rev 1108)
+++ development/source/cpu/cHardwareCPU.cc 2006-12-02 06:53:56 UTC (rev 1109)
@@ -498,34 +498,25 @@
// Find the instruction to be executed
const cInstruction& cur_inst = IP().GetInst();
- // cout << "cHardwareCPU: " << cur_inst.GetOp() << " " << cur_inst.GetSymbol() << endl;
- if (cur_inst.GetOp() > 26) {
- cout << "cHardwareCPU1: " << cur_inst.GetOp() << " " << cur_inst.GetSymbol() << endl;
- }
// Test if costs have been paid and it is okay to execute this now...
const bool exec = SingleProcess_PayCosts(ctx, cur_inst);
- if (cur_inst.GetOp() > 26) {
- cout << "cHardwareCPU2: " << cur_inst.GetOp() << " " << cur_inst.GetSymbol() << endl;
- }
// Now execute the instruction...
if (exec == true) {
+ // NOTE: This call based on the cur_inst must occur prior to instruction
+ // execution, because this instruction reference may be invalid after
+ // certain classes of instructions (namely divide instructions) @DMB
+ const int addl_time_cost = m_inst_set->GetAddlTimeCost(cur_inst);
+
SingleProcess_ExecuteInst(ctx, cur_inst);
- if (cur_inst.GetOp() > 26) {
- cout << "cHardwareCPU3: " << cur_inst.GetOp() << " " << cur_inst.GetSymbol() << endl;
- }
// Some instruction (such as jump) may turn m_advance_ip off. Usually
// we now want to move to the next instruction in the memory.
if (m_advance_ip == true) IP().Advance();
// Pay the additional death_cost of the instruction now
- if (cur_inst.GetOp() > 26) {
- cout << "cHardwareCPU4: " << cur_inst.GetOp() << " " << cur_inst.GetSymbol() << endl;
- }
- phenotype.IncTimeUsed(m_inst_set->GetAddlTimeCost(cur_inst));
-
+ phenotype.IncTimeUsed(addl_time_cost);
} // if exec
} // Previous was executed once for each thread...
@@ -2755,8 +2746,6 @@
organism->DoOutput(ctx, value);
// Immediately half the merit of the current organism, never going below 1
- double bone = organism->GetPhenotype().GetCurBonus();
- double mere = organism->GetPhenotype().GetMerit().GetDouble();
double new_merit = organism->GetPhenotype().GetMerit().GetDouble();
new_merit /= 2;
if (new_merit < 1) new_merit = 1;
Modified: development/source/main/cInstSet.h
===================================================================
--- development/source/main/cInstSet.h 2006-11-30 21:05:30 UTC (rev 1108)
+++ development/source/main/cInstSet.h 2006-12-02 06:53:56 UTC (rev 1109)
@@ -79,13 +79,7 @@
const cString& GetName(const cInstruction& inst) const { return GetName(inst.GetOp()); }
int GetCost(const cInstruction& inst) const { return m_lib_name_map[inst.GetOp()].cost; }
int GetFTCost(const cInstruction& inst) const { return m_lib_name_map[inst.GetOp()].ft_cost; }
- // int GetAddlTimeCost(const cInstruction& inst) const { return m_lib_name_map[inst.GetOp()].addl_time_cost; }
- int GetAddlTimeCost(const cInstruction& inst) const { if (inst.GetOp() > 30) {
- cout << "cInstSet.h " << inst.GetOp() << " " << inst.GetSymbol() << endl;
- } else {
- return m_lib_name_map[inst.GetOp()].addl_time_cost;
- }
- }
+ int GetAddlTimeCost(const cInstruction& inst) const { return m_lib_name_map[inst.GetOp()].addl_time_cost; }
double GetProbFail(const cInstruction& inst) const { return m_lib_name_map[inst.GetOp()].prob_fail; }
int GetRedundancy(const cInstruction& inst) const { return m_lib_name_map[inst.GetOp()].redundancy; }
int GetLibFunctionIndex(const cInstruction& inst) const { return m_lib_name_map[inst.GetOp()].lib_fun_id; }
Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc 2006-11-30 21:05:30 UTC (rev 1108)
+++ development/source/main/cOrganism.cc 2006-12-02 06:53:56 UTC (rev 1109)
@@ -47,6 +47,7 @@
, output_buf(OUTPUT_BUF_SIZE)
, send_buf(SEND_BUF_SIZE)
, receive_buf(RECEIVE_BUF_SIZE)
+ , received_messages(RECEIVED_MESSAGES_SIZE)
, sent_value(0)
, sent_active(false)
, test_receive_pos(0)
@@ -56,7 +57,6 @@
, inbox(0)
, sent(0)
, m_net(NULL)
- , received_messages(RECEIVED_MESSAGES_SIZE)
, is_running(false)
{
// Initialization of structures...
Modified: development/source/main/cTaskContext.h
===================================================================
--- development/source/main/cTaskContext.h 2006-11-30 21:05:30 UTC (rev 1108)
+++ development/source/main/cTaskContext.h 2006-12-02 06:53:56 UTC (rev 1109)
@@ -41,8 +41,8 @@
const tList<tBuffer<int> >& other_outputs, bool in_net_valid, int in_net_completed,
bool in_on_divide = false, tBuffer<int>* in_received_messages = NULL)
: input_buffer(inputs), output_buffer(outputs), other_input_buffers(other_inputs),
- other_output_buffers(other_outputs), net_valid(in_net_valid), net_completed(in_net_completed),
- on_divide(in_on_divide), received_messages(in_received_messages), logic_id(0), task_entry(NULL)
+ other_output_buffers(other_outputs), net_valid(in_net_valid), net_completed(in_net_completed), received_messages(in_received_messages), logic_id(0),
+ on_divide(in_on_divide), task_entry(NULL)
{
}
More information about the Avida-cvs
mailing list