[Avida-cvs] [Avida2-svn] r22 - trunk/source/cpu

ofria at myxo.css.msu.edu ofria at myxo.css.msu.edu
Wed Feb 23 13:51:24 PST 2005


Author: ofria
Date: 2005-02-23 16:51:24 -0500 (Wed, 23 Feb 2005)
New Revision: 22

Modified:
   trunk/source/cpu/hardware_4stack.cc
   trunk/source/cpu/hardware_cpu.cc
Log:
Incorporated speed ups posted on DigitalEvolution mailing list.


Modified: trunk/source/cpu/hardware_4stack.cc
===================================================================
--- trunk/source/cpu/hardware_4stack.cc	2005-02-18 01:26:49 UTC (rev 21)
+++ trunk/source/cpu/hardware_4stack.cc	2005-02-23 21:51:24 UTC (rev 22)
@@ -386,8 +386,10 @@
 #endif
     
     // Print the status of this CPU at each step...
-    const cString & next_name = inst_set->GetName(IP().GetInst())();
-    if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
+    if (trace_fp != NULL) {
+      const cString & next_name = inst_set->GetName(IP().GetInst())();
+      organism->PrintStatus(*trace_fp, next_name);
+    }
     
     // Find the instruction to be executed
     const cInstruction & cur_inst = IP().GetInst();
@@ -494,9 +496,11 @@
 
   // @CAO FIX PRINTING TO INDICATE THIS IS A BONUS
   // Print the status of this CPU at each step...
-  cString next_name = cStringUtil::Stringf("%s (bonus instruction)",
-					   inst_set->GetName(inst)());
-  if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
+  if (trace_fp != NULL) {
+    cString next_name = cStringUtil::Stringf("%s (bonus instruction)",
+					     inst_set->GetName(inst)());
+    organism->PrintStatus(*trace_fp, next_name);
+  }
     
   SingleProcess_ExecuteInst(inst);
 

Modified: trunk/source/cpu/hardware_cpu.cc
===================================================================
--- trunk/source/cpu/hardware_cpu.cc	2005-02-18 01:26:49 UTC (rev 21)
+++ trunk/source/cpu/hardware_cpu.cc	2005-02-23 21:51:24 UTC (rev 22)
@@ -461,12 +461,13 @@
 
   cPhenotype & phenotype = organism->GetPhenotype();
   phenotype.IncTimeUsed();
-  if (GetNumThreads() > 1) thread_time_used++;
+  const int num_threads = GetNumThreads();
+  if (num_threads > 1) thread_time_used++;
 
   // If we have threads turned on and we executed each thread in a single
   // timestep, adjust the number of instructions executed accordingly.
   const int num_inst_exec = (cConfig::GetThreadSlicingMethod() == 1) ?
-    GetNumThreads() : 1;
+    num_threads : 1;
   
   for (int i = 0; i < num_inst_exec; i++) {
     // Setup the hardware for the next instruction to be executed.
@@ -481,8 +482,10 @@
 #endif
     
     // Print the status of this CPU at each step...
-    const cString & next_name = inst_set->GetName(IP().GetInst())();
-    if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
+    if (trace_fp != NULL) {
+      const cString & next_name = inst_set->GetName(IP().GetInst())();
+      organism->PrintStatus(*trace_fp, next_name);
+    }
     
     // Find the instruction to be executed
     const cInstruction & cur_inst = IP().GetInst();
@@ -590,9 +593,11 @@
 
   // @CAO FIX PRINTING TO INDICATE THIS IS A BONUS
   // Print the status of this CPU at each step...
-  cString next_name = cStringUtil::Stringf("%s (bonus instruction)",
-					   inst_set->GetName(inst)());
-  if (trace_fp != NULL) organism->PrintStatus(*trace_fp, next_name);
+  if (trace_fp != NULL) {
+    cString next_name = cStringUtil::Stringf("%s (bonus instruction)",
+					     inst_set->GetName(inst)());
+    organism->PrintStatus(*trace_fp, next_name);
+  }
     
   SingleProcess_ExecuteInst(inst);
 




More information about the Avida-cvs mailing list