[Avida-SVN] r3044 - development/source/cpu

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Mon Dec 15 07:41:12 PST 2008


Author: brysonda
Date: 2008-12-15 10:41:12 -0500 (Mon, 15 Dec 2008)
New Revision: 3044

Modified:
   development/source/cpu/cHardwareBase.cc
   development/source/cpu/cHardwareBase.h
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
   development/source/cpu/cHardwareExperimental.cc
   development/source/cpu/cHardwareExperimental.h
   development/source/cpu/cHardwareGX.cc
   development/source/cpu/cHardwareGX.h
   development/source/cpu/cHardwareSMT.cc
   development/source/cpu/cHardwareSMT.h
   development/source/cpu/cHardwareTransSMT.cc
   development/source/cpu/cHardwareTransSMT.h
Log:
Some cHardwareBase code cleanup.

Modified: development/source/cpu/cHardwareBase.cc
===================================================================
--- development/source/cpu/cHardwareBase.cc	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareBase.cc	2008-12-15 15:41:12 UTC (rev 3044)
@@ -70,7 +70,7 @@
   internalReset();
 }
 
-int cHardwareBase::GetExecutedSize(const int parent_size)
+int cHardwareBase::calcExecutedSize(const int parent_size)
 {
   int executed_size = 0;
   const cCPUMemory& memory = GetMemory();
@@ -120,7 +120,7 @@
   // Count the number of lines executed in the parent, and make sure the
   // specified fraction has been reached.
   
-  const int executed_size = GetExecutedSize(parent_size);
+  const int executed_size = calcExecutedSize(parent_size);
   const int min_exe_lines = static_cast<int>(parent_size * m_world->GetConfig().MIN_EXE_LINES.Get());
   if (executed_size < min_exe_lines) {
     m_organism->Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR,
@@ -132,7 +132,7 @@
   int copied_size = parent_size;
   if (!using_repro) {
     // Normal organisms check to see how much was copied
-    copied_size = GetCopiedSize(parent_size, child_size); // Fails for REPRO organisms
+    copied_size = calcCopiedSize(parent_size, child_size); // Fails for REPRO organisms
     const int min_copied = static_cast<int>(child_size * m_world->GetConfig().MIN_COPIED_LINES.Get());
   
     if (copied_size < min_copied) {
@@ -812,6 +812,7 @@
   return true;
 }
 
+
 // @JEB Check implicit repro conditions -- meant to be called at the end of SingleProcess
 void cHardwareBase::CheckImplicitRepro(cAvidaContext& ctx, bool exec_last_inst)         
 {  
@@ -836,6 +837,7 @@
   return false;
 }
 
+
 bool cHardwareBase::Inst_DoubleEnergyUsage(cAvidaContext& ctx)
 {
   m_organism->GetPhenotype().DoubleEnergyUsage();
@@ -860,6 +862,7 @@
   return true;
 }
 
+
 // This method will test to see if all costs have been paid associated
 // with executing an instruction and only return true when that instruction
 // should proceed.
@@ -929,6 +932,7 @@
 
 
 //! Called when the organism that owns this CPU has received a flash from a neighbor.
-void cHardwareBase::ReceiveFlash() {
+void cHardwareBase::ReceiveFlash()
+{
   m_world->GetDriver().RaiseFatalException(1, "Method cHardwareBase::ReceiveFlash must be overriden.");
 }

Modified: development/source/cpu/cHardwareBase.h
===================================================================
--- development/source/cpu/cHardwareBase.h	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareBase.h	2008-12-15 15:41:12 UTC (rev 3044)
@@ -90,6 +90,7 @@
   }
   virtual ~cHardwareBase() { ; }
 
+  
   // --------  Organism  ---------
   cOrganism* GetOrganism() { return m_organism; }
   const cInstSet& GetInstSet() { return *m_inst_set; }
@@ -170,14 +171,17 @@
   virtual bool TriggerMutations(cAvidaContext& ctx, int trigger);
   virtual bool TriggerMutations(cAvidaContext& ctx, int trigger, cHeadCPU& cur_head);
 
+  
   // --------  Input/Output Buffers  --------
   virtual tBuffer<int>& GetInputBuf();
   virtual tBuffer<int>& GetOutputBuf();
   
+  
   // --------  State Transfer  --------
   virtual void InheritState(cHardwareBase& in_hardware){ ; }
   
-  //alarm
+  
+  // --------  Alarm  --------
   virtual bool Jump_To_Alarm_Label(int jump_label) { return false; }
   
 
@@ -187,44 +191,52 @@
 
   
 protected:
+  // --------  Core Execution Methods  --------
+  bool SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst);
   virtual void internalReset() = 0;
   
-  // --------  No-Operation Instruction --------
+  
+  // --------  No-Operation Instruction  --------
   bool Inst_Nop(cAvidaContext& ctx);  // A no-operation instruction that does nothing! 
   
-  // -------- Implicit Repro Check/Instruction -------- @JEB
+  
+  // --------  Implicit Repro Check/Instruction  -------- @JEB
   void CheckImplicitRepro(cAvidaContext& ctx, bool exec_last_inst = false);
   virtual bool Inst_Repro(cAvidaContext& ctx);
 
-  // --------  Execution Speed Instruction --------
+  
+  // --------  Execution Speed Instruction  --------
   bool Inst_DoubleEnergyUsage(cAvidaContext& ctx);
   bool Inst_HalfEnergyUsage(cAvidaContext& ctx);
   bool Inst_DefaultEnergyUsage(cAvidaContext& ctx);
 	
 
   
-  // --------  Mutation Helper Methods --------
+  // --------  Mutation Helper Methods  --------
   bool doUniformMutation(cAvidaContext& ctx, cCPUMemory& genome);
   void doUniformCopyMutation(cAvidaContext& ctx, cHeadCPU& head);
   void doSlipMutation(cAvidaContext& ctx, cCPUMemory& genome, int from = -1);
   
 
-  virtual int GetExecutedSize(const int parent_size);
-  virtual int GetCopiedSize(const int parent_size, const int child_size) = 0;  
+  // --------  Organism Execution Property Calculation  --------
+  virtual int calcExecutedSize(const int parent_size);
+  virtual int calcCopiedSize(const int parent_size, const int child_size) = 0;  
   
+  
+  // --------  Division Support Methods  --------
   bool Divide_CheckViable(cAvidaContext& ctx, const int parent_size, const int child_size, bool using_repro = false);
   unsigned Divide_DoExactMutations(cAvidaContext& ctx, double mut_multiplier = 1.0, const int pointmut = INT_MAX);
   bool Divide_TestFitnessMeasures1(cAvidaContext& ctx);
   
+
+  // --------  Mutation Triggers  --------
   void TriggerMutations_Body(cAvidaContext& ctx, int type, cCPUMemory& target_memory, cHeadCPU& cur_head);
   bool TriggerMutations_ScopeGenome(cAvidaContext& ctx, const cMutation* cur_mut,
 																		cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);
   bool TriggerMutations_ScopeLocal(cAvidaContext& ctx, const cMutation* cur_mut,
 																	 cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);
   int TriggerMutations_ScopeGlobal(cAvidaContext& ctx, const cMutation* cur_mut,
-																	 cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);
-  
-  virtual bool SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst);
+																	 cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);  
 };
 
 

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareCPU.cc	2008-12-15 15:41:12 UTC (rev 3044)
@@ -1394,7 +1394,7 @@
   return true;
 }
 
-int cHardwareCPU::GetCopiedSize(const int parent_size, const int child_size)
+int cHardwareCPU::calcCopiedSize(const int parent_size, const int child_size)
 {
   int copied_size = 0;
   for (int i = parent_size; i < parent_size + child_size; i++) {

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareCPU.h	2008-12-15 15:41:12 UTC (rev 3044)
@@ -224,7 +224,7 @@
   void internalReset();
   
   
-  int GetCopiedSize(const int parent_size, const int child_size);
+  int calcCopiedSize(const int parent_size, const int child_size);
   
   bool Divide_Main(cAvidaContext& ctx, const int divide_point, const int extra_lines=0, double mut_multiplier=1);
   bool Divide_MainRS(cAvidaContext& ctx, const int divide_point, const int extra_lines=0, double mut_multiplier=1); //AWC 06/29/06

Modified: development/source/cpu/cHardwareExperimental.cc
===================================================================
--- development/source/cpu/cHardwareExperimental.cc	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareExperimental.cc	2008-12-15 15:41:12 UTC (rev 3044)
@@ -925,7 +925,7 @@
   return true;
 }
 
-int cHardwareExperimental::GetCopiedSize(const int parent_size, const int child_size)
+int cHardwareExperimental::calcCopiedSize(const int parent_size, const int child_size)
 {
   int copied_size = 0;
   for (int i = parent_size; i < parent_size + child_size; i++) {

Modified: development/source/cpu/cHardwareExperimental.h
===================================================================
--- development/source/cpu/cHardwareExperimental.h	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareExperimental.h	2008-12-15 15:41:12 UTC (rev 3044)
@@ -349,7 +349,7 @@
   bool Allocate_Default(const int new_size);
   bool Allocate_Main(cAvidaContext& ctx, const int allocated_size);
   
-  int GetCopiedSize(const int parent_size, const int child_size);
+  int calcCopiedSize(const int parent_size, const int child_size);
   
   
   // --------  Division Support  -------

Modified: development/source/cpu/cHardwareGX.cc
===================================================================
--- development/source/cpu/cHardwareGX.cc	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareGX.cc	2008-12-15 15:41:12 UTC (rev 3044)
@@ -1200,7 +1200,7 @@
   return true;
 }
 
-int cHardwareGX::GetExecutedSize(const int parent_size)
+int cHardwareGX::calcExecutedSize(const int parent_size)
 {
 /* @JEB - not really relevant to GX
   int executed_size = 0;
@@ -1213,7 +1213,7 @@
   return parent_size;
 }
 
-int cHardwareGX::GetCopiedSize(const int parent_size, const int child_size)
+int cHardwareGX::calcCopiedSize(const int parent_size, const int child_size)
 {
   return parent_size;
 

Modified: development/source/cpu/cHardwareGX.h
===================================================================
--- development/source/cpu/cHardwareGX.h	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareGX.h	2008-12-15 15:41:12 UTC (rev 3044)
@@ -298,8 +298,8 @@
   void internalReset();
   
     
-  int GetExecutedSize(const int parent_size);
-  int GetCopiedSize(const int parent_size, const int child_size);
+  int calcExecutedSize(const int parent_size);
+  int calcCopiedSize(const int parent_size, const int child_size);
   bool Divide_Main(cAvidaContext& ctx);
   void InjectCode(const cGenome& injection, const int line_num);
   bool HeadCopy_ErrorCorrect(cAvidaContext& ctx, double reduction);

Modified: development/source/cpu/cHardwareSMT.cc
===================================================================
--- development/source/cpu/cHardwareSMT.cc	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareSMT.cc	2008-12-15 15:41:12 UTC (rev 3044)
@@ -822,7 +822,7 @@
 }
 
 
-int cHardwareSMT::GetCopiedSize(const int parent_size, const int child_size)
+int cHardwareSMT::calcCopiedSize(const int parent_size, const int child_size)
 {
   int copied_size = 0;
   const cCPUMemory& memory = m_mem_array[m_cur_child];
@@ -912,7 +912,7 @@
   if (m_mem_array.GetSize() <= mem_space_used) return false;
   	
   // Make sure this divide will produce a viable offspring.
-  m_cur_child = mem_space_used; // save current child memory space for use by dependent functions (e.g. GetCopiedSize())
+  m_cur_child = mem_space_used; // save current child memory space for use by dependent functions (e.g. calcCopiedSize())
   if (!Divide_CheckViable(ctx, m_mem_array[0].GetSize(), write_head_pos)) return false;
   
   // Since the divide will now succeed, set up the information to be sent to the new organism

Modified: development/source/cpu/cHardwareSMT.h
===================================================================
--- development/source/cpu/cHardwareSMT.h	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareSMT.h	2008-12-15 15:41:12 UTC (rev 3044)
@@ -183,7 +183,7 @@
   void internalReset();
   
   
-	int GetCopiedSize(const int parent_size, const int child_size);
+	int calcCopiedSize(const int parent_size, const int child_size);
   
   bool Divide_Main(cAvidaContext& ctx, double mut_multiplier = 1.0);
   void Inject_DoMutations(cAvidaContext& ctx, double mut_multiplier, cCPUMemory& injected_code);

Modified: development/source/cpu/cHardwareTransSMT.cc
===================================================================
--- development/source/cpu/cHardwareTransSMT.cc	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareTransSMT.cc	2008-12-15 15:41:12 UTC (rev 3044)
@@ -826,7 +826,7 @@
 }
 
 
-int cHardwareTransSMT::GetCopiedSize(const int parent_size, const int child_size)
+int cHardwareTransSMT::calcCopiedSize(const int parent_size, const int child_size)
 {
   int copied_size = 0;
   const cCPUMemory& memory = m_mem_array[m_cur_child];
@@ -916,7 +916,7 @@
   if (m_mem_array.GetSize() <= mem_space_used) return false;
   	
   // Make sure this divide will produce a viable offspring.
-  m_cur_child = mem_space_used; // save current child memory space for use by dependent functions (e.g. GetCopiedSize())
+  m_cur_child = mem_space_used; // save current child memory space for use by dependent functions (e.g. calcCopiedSize())
   if (!Divide_CheckViable(ctx, m_mem_array[0].GetSize(), write_head_pos)) return false;
   
   // Since the divide will now succeed, set up the information to be sent to the new organism

Modified: development/source/cpu/cHardwareTransSMT.h
===================================================================
--- development/source/cpu/cHardwareTransSMT.h	2008-12-15 15:21:09 UTC (rev 3043)
+++ development/source/cpu/cHardwareTransSMT.h	2008-12-15 15:41:12 UTC (rev 3044)
@@ -181,7 +181,7 @@
   void internalReset();
   
   
-  int GetCopiedSize(const int parent_size, const int child_size);
+  int calcCopiedSize(const int parent_size, const int child_size);
   
   bool Divide_Main(cAvidaContext& ctx, double mut_multiplier = 1.0);
   void Inject_DoMutations(cAvidaContext& ctx, double mut_multiplier, cCPUMemory& injected_code);




More information about the Avida-cvs mailing list