[Avida-SVN] r1616 - in development/source: drivers main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sat May 26 14:16:49 PDT 2007


Author: brysonda
Date: 2007-05-26 17:16:49 -0400 (Sat, 26 May 2007)
New Revision: 1616

Modified:
   development/source/drivers/cDefaultRunDriver.cc
   development/source/main/cPopulation.cc
   development/source/main/cStats.cc
   development/source/main/cStats.h
Log:
Add tracking of the number of active threads, along with display on the running states from avida command line.

Modified: development/source/drivers/cDefaultRunDriver.cc
===================================================================
--- development/source/drivers/cDefaultRunDriver.cc	2007-05-26 15:03:33 UTC (rev 1615)
+++ development/source/drivers/cDefaultRunDriver.cc	2007-05-26 21:16:49 UTC (rev 1616)
@@ -120,7 +120,8 @@
       cout << "UD: " << setw(6) << stats.GetUpdate() << "  "
         << "Gen: " << setw(9) << setprecision(7) << stats.SumGeneration().Average() << "  "
         << "Fit: " << setw(9) << setprecision(7) << stats.GetAveFitness() << "  "
-        << "Size: " << population.GetNumOrganisms()
+        << "Orgs: " << setw(6) << population.GetNumOrganisms() << "  "
+        << "Thrd: " << stats.GetNumThreads()
         << endl;
     }
     

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2007-05-26 15:03:33 UTC (rev 1615)
+++ development/source/main/cPopulation.cc	2007-05-26 21:16:49 UTC (rev 1616)
@@ -1614,6 +1614,7 @@
   int num_no_birth = 0;
   int num_multi_thread = 0;
   int num_single_thread = 0;
+  int num_threads = 0;
   int num_modified = 0;
   
   // Maximums...
@@ -1706,16 +1707,15 @@
     // Increment the counts for all qualities the organism has...
     if (phenotype.ParentTrue()) num_breed_true++;
     if (phenotype.IsParasite()) num_parasites++;
-    if( phenotype.GetNumDivides() == 0 ) num_no_birth++;
-    if(phenotype.IsMultiThread()) num_multi_thread++;
+    if (phenotype.GetNumDivides() == 0) num_no_birth++;
+    if (phenotype.IsMultiThread()) num_multi_thread++;
     else num_single_thread++;
+    
     if(phenotype.IsModified()) num_modified++;    
     
-    // Hardware specific collections...
-    if (organism->GetHardware().GetType() == HARDWARE_TYPE_CPU_ORIGINAL) {
-      cHardwareBase & hardware = organism->GetHardware();
-      stats.SumMemSize().Add(hardware.GetMemory().GetSize());
-    }
+    cHardwareBase& hardware = organism->GetHardware();
+    stats.SumMemSize().Add(hardware.GetMemory().GetSize());
+    num_threads += hardware.GetNumThreads();
     
     // Increment the age of this organism.
     organism->GetPhenotype().IncAge();
@@ -1726,6 +1726,7 @@
   stats.SetNumParasites(num_parasites);
   stats.SetNumSingleThreadCreatures(num_single_thread);
   stats.SetNumMultiThreadCreatures(num_multi_thread);
+  stats.SetNumThreads(num_threads);
   stats.SetNumModified(num_modified);
   
   stats.SetMaxMerit(max_merit.GetDouble());

Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc	2007-05-26 15:03:33 UTC (rev 1615)
+++ development/source/main/cStats.cc	2007-05-26 21:16:49 UTC (rev 1616)
@@ -93,6 +93,10 @@
   , num_executed(0)
   , num_parasites(0)
   , num_no_birth_creatures(0)
+  , num_single_thread_creatures(0)
+  , num_multi_thread_creatures(0)
+  , m_num_threads(0)
+  , num_modified(0)
   , num_genotypes_last(1)
   , tot_organisms(0)
   , tot_genotypes(0)

Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h	2007-05-26 15:03:33 UTC (rev 1615)
+++ development/source/main/cStats.h	2007-05-26 21:16:49 UTC (rev 1616)
@@ -195,6 +195,7 @@
   int num_no_birth_creatures;
   int num_single_thread_creatures;
   int num_multi_thread_creatures;
+  int m_num_threads;
   int num_modified;
 
   int num_genotypes_last;
@@ -336,6 +337,7 @@
   inline void SetNumNoBirthCreatures(int in_num_no_birth_creatures);
   inline void SetNumSingleThreadCreatures(int in_num_single_thread_creatures);
   inline void SetNumMultiThreadCreatures(int in_num_multi_thread_creatures);
+  inline void SetNumThreads(int in_num_threads) { m_num_threads = in_num_threads; }
   inline void SetNumModified(int in_num_modified);
 
   void SetMaxFitness(double in_max_fitness) { max_fitness = in_max_fitness; }
@@ -496,6 +498,7 @@
   int GetNumNoBirthCreatures() const{ return num_no_birth_creatures; }
   int GetNumSingleThreadCreatures() const { return num_single_thread_creatures; }
   int GetNumMultiThreadCreatures() const { return num_multi_thread_creatures; }
+  int GetNumThreads() const { return m_num_threads; }
   int GetNumModified() const { return num_modified;}
 
   int GetTotCreatures() const       { return tot_organisms; }




More information about the Avida-cvs mailing list