[Avida-cvs] [avida-svn] r626 - in development/source: cpu main

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Apr 21 20:13:45 PDT 2006


Author: brysonda
Date: 2006-04-21 23:13:45 -0400 (Fri, 21 Apr 2006)
New Revision: 626

Modified:
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareSMT.cc
   development/source/cpu/cHardwareSMT.h
   development/source/main/cAvidaConfig.h
   development/source/main/cPopulationInterface.cc
Log:
Add facing based network style, along with new config option to select.   Add SMT rotate instructions.

NOTE:  Fixed basic HardwareCPU rotate right instruction so that the first rotate is in the correct direction (was the same as left, even though the rotate label search was going in the correct direction).   This will affect the output of runs that relied on rotate-r.

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2006-04-18 20:14:07 UTC (rev 625)
+++ development/source/cpu/cHardwareCPU.cc	2006-04-22 03:13:45 UTC (rev 626)
@@ -2517,7 +2517,8 @@
         neighbor->GetHardware().GetType() == GetType()) {
       
       // If this facing has the full label, stop here.
-      cHardwareCPU & cur_hardware = (cHardwareCPU &) neighbor->GetHardware();
+      // @DMB - Warning: this is assuming homogenous hardware within the population
+      cHardwareCPU & cur_hardware = static_cast<cHardwareCPU&>(neighbor->GetHardware());
       if (cur_hardware.FindFullLabel( GetLabel() ).InMemory()) return true;
     }
     
@@ -2537,7 +2538,7 @@
   ReadLabel();
   
   // Always rotate at least once.
-  organism->Rotate(-1);
+  organism->Rotate(1);
   
   // If there is no label, then the one rotation was all we want.
   if (!GetLabel().GetSize()) return true;

Modified: development/source/cpu/cHardwareSMT.cc
===================================================================
--- development/source/cpu/cHardwareSMT.cc	2006-04-18 20:14:07 UTC (rev 625)
+++ development/source/cpu/cHardwareSMT.cc	2006-04-22 03:13:45 UTC (rev 626)
@@ -93,7 +93,9 @@
     cInstEntry("Net-Get", &cHardwareSMT::Inst_NetGet), // 39
     cInstEntry("Net-Send", &cHardwareSMT::Inst_NetSend), // 40
     cInstEntry("Net-Receive", &cHardwareSMT::Inst_NetReceive), // 41
-    cInstEntry("Net-Last", &cHardwareSMT::Inst_NetLast) // 42
+    cInstEntry("Net-Last", &cHardwareSMT::Inst_NetLast), // 42
+    cInstEntry("Rotate-Left", &cHardwareSMT::Inst_RotateLeft), // 43
+    cInstEntry("Rotate-Right", &cHardwareSMT::Inst_RotateRight) // 44
   };
 	
   const int n_size = sizeof(s_n_array)/sizeof(cNOPEntry);
@@ -1643,3 +1645,31 @@
   Stack(dst).Push(organism->NetLast());
   return true;
 }
+
+//43
+bool cHardwareSMT::Inst_RotateLeft(cAvidaContext& ctx)
+{
+  const int num_neighbors = organism->GetNeighborhoodSize();
+  
+  // If this organism has no neighbors, ignore rotate.
+  if (num_neighbors == 0) return false;
+  
+  // Always rotate at least once.
+  organism->Rotate(-1);
+  
+  return true;
+}
+
+//44
+bool cHardwareSMT::Inst_RotateRight(cAvidaContext& ctx)
+{
+  const int num_neighbors = organism->GetNeighborhoodSize();
+  
+  // If this organism has no neighbors, ignore rotate.
+  if (num_neighbors == 0) return false;
+  
+  // Always rotate at least once.
+  organism->Rotate(1);
+  
+  return true;
+}

Modified: development/source/cpu/cHardwareSMT.h
===================================================================
--- development/source/cpu/cHardwareSMT.h	2006-04-18 20:14:07 UTC (rev 625)
+++ development/source/cpu/cHardwareSMT.h	2006-04-22 03:13:45 UTC (rev 626)
@@ -297,6 +297,8 @@
   bool Inst_NetSend(cAvidaContext& ctx);        // 40
   bool Inst_NetReceive(cAvidaContext& ctx);     // 41
   bool Inst_NetLast(cAvidaContext& ctx);        // 42
+  bool Inst_RotateLeft(cAvidaContext& ctx);     // 43
+  bool Inst_RotateRight(cAvidaContext& ctx);    // 44
 };
 
 

Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h	2006-04-18 20:14:07 UTC (rev 625)
+++ development/source/main/cAvidaConfig.h	2006-04-22 03:13:45 UTC (rev 626)
@@ -263,6 +263,7 @@
   CONFIG_ADD_VAR(NET_ENABLED, bool, 0, "Enable Network Communication Support");
   CONFIG_ADD_VAR(NET_DROP_PROB, double, 0.0, "Message drop rate");
   CONFIG_ADD_VAR(NET_MUT_PROB, double, 0.0, "Message corruption probability");
+  CONFIG_ADD_VAR(NET_STYLE, int, 0, "Communication Style.  0 = Random Next, 1 = Receiver Facing");
 #endif
   
   void Load(const cString & filename);

Modified: development/source/main/cPopulationInterface.cc
===================================================================
--- development/source/main/cPopulationInterface.cc	2006-04-18 20:14:07 UTC (rev 625)
+++ development/source/main/cPopulationInterface.cc	2006-04-22 03:13:45 UTC (rev 626)
@@ -126,13 +126,29 @@
   cPopulationCell& cell = m_world->GetPopulation().GetCell(m_cell_id);
   assert(cell.IsOccupied());
   
-  const int num_neighbors = cell.ConnectionList().GetSize();
-  for (int i = 0; i < num_neighbors; i++) {
-    cell.ConnectionList().CircNext();
+  switch(m_world->GetConfig().NET_STYLE.Get())
+  {
+  case 1: // Receiver Facing
+    {
+      cOrganism* cur_neighbor = cell.ConnectionList().GetFirst()->GetOrganism();
+      cOrgSinkMessage* msg = NULL;
+      if (cur_neighbor != NULL && (msg = cur_neighbor->NetPop()) != NULL) return msg;
+    }
+    break;
     
-    cOrganism* cur_neighbor = cell.ConnectionList().GetFirst()->GetOrganism();
-    cOrgSinkMessage* msg = NULL;
-    if (cur_neighbor != NULL && (msg = cur_neighbor->NetPop()) != NULL ) return msg;
+  case 0: // Random Next - First Available
+  default:
+    {
+      const int num_neighbors = cell.ConnectionList().GetSize();
+      for (int i = 0; i < num_neighbors; i++) {
+        cell.ConnectionList().CircNext();
+        
+        cOrganism* cur_neighbor = cell.ConnectionList().GetFirst()->GetOrganism();
+        cOrgSinkMessage* msg = NULL;
+        if (cur_neighbor != NULL && (msg = cur_neighbor->NetPop()) != NULL ) return msg;
+      }
+    }
+    break;
   }
   
   return NULL;




More information about the Avida-cvs mailing list