[Avida-SVN] r3133 - in branches/interrupt/source: actions cpu main

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Fri Jan 23 06:51:56 PST 2009


Author: beckma24
Date: 2009-01-23 09:51:56 -0500 (Fri, 23 Jan 2009)
New Revision: 3133

Modified:
   branches/interrupt/source/actions/PrintActions.cc
   branches/interrupt/source/cpu/cHardwareCPU.cc
   branches/interrupt/source/main/cOrganism.cc
   branches/interrupt/source/main/cStats.cc
   branches/interrupt/source/main/cStats.h
Log:
Added PrintDemeInterrupt and PrintOrgsLocationAndInterrupt actions

Modified: branches/interrupt/source/actions/PrintActions.cc
===================================================================
--- branches/interrupt/source/actions/PrintActions.cc	2009-01-22 15:16:06 UTC (rev 3132)
+++ branches/interrupt/source/actions/PrintActions.cc	2009-01-23 14:51:56 UTC (rev 3133)
@@ -114,8 +114,9 @@
 STATS_OUT_FILE(PrintDemeOrgReactionData,    deme_org_reactions.dat  );
 STATS_OUT_FILE(PrintDemeCurrentTaskExeData,	deme_cur_task_exe.dat	);
 STATS_OUT_FILE(PrintDemeMigrationSuicidePoints,	deme_mig_suicide_points.dat	);
+STATS_OUT_FILE(PrintDemeInterrupt,					deme_interrupt.dat	);
+STATS_OUT_FILE(PrintOrgsLocationAndInterrupt,					orgs_locationAndInterrupt.dat	);
 
-
 STATS_OUT_FILE(PrintCurrentTaskCounts,      curr_task_counts.dat);
 STATS_OUT_FILE(PrintGermlineData,           germline.dat        );
 STATS_OUT_FILE(PrintPredicatedMessages,     messages.dat        );
@@ -2769,7 +2770,8 @@
   action_lib->Register<cActionPrintCurrentTaskCounts>("PrintCurrentTaskCounts");
   action_lib->Register<cActionPrintPerDemeGenPerFounderData>("PrintPerDemeGenPerFounderData");
   action_lib->Register<cActionPrintDemeMigrationSuicidePoints>("PrintDemeMigrationSuicidePoints");
-
+  action_lib->Register<cActionPrintDemeInterrupt>("PrintDemeInterrupt");
+  action_lib->Register<cActionPrintOrgsLocationAndInterrupt>("PrintOrgsLocationAndInterrupt");
 	
 
   //Coalescence Clade Actions

Modified: branches/interrupt/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareCPU.cc	2009-01-22 15:16:06 UTC (rev 3132)
+++ branches/interrupt/source/cpu/cHardwareCPU.cc	2009-01-23 14:51:56 UTC (rev 3133)
@@ -1025,14 +1025,6 @@
     fp << setfill(' ') << setbase(10) << endl;
   }
 	
-	if(m_world->GetConfig().INTERRUPT_ENABLED.Get() == 1) {
-		cLocalThread* currentThread = GetThread(GetCurThread());
-		if(currentThread->isInterrupted())
-			fp << "Interrupted: Saved IP " << (currentThread->pushedState.heads[0]).GetPosition() << endl;
-		else
-			fp << "NOT Interrupted " <<endl;
-	}
-	fp << "Queued messages: "<< m_organism->NumQueuedMessages() << endl;
   fp.flush();
 }
 

Modified: branches/interrupt/source/main/cOrganism.cc
===================================================================
--- branches/interrupt/source/main/cOrganism.cc	2009-01-22 15:16:06 UTC (rev 3132)
+++ branches/interrupt/source/main/cOrganism.cc	2009-01-23 14:51:56 UTC (rev 3133)
@@ -648,6 +648,20 @@
   for (int i = 0; i < m_hardware->GetOutputBuf().GetNumStored(); i++) fp << " 0x" << setw(8) << m_hardware->GetOutputBuf()[i];
   fp << endl;
   
+	
+	std::pair<int, int> pos = m_world->GetPopulation().GetDeme(GetOrgInterface().GetDemeID()).GetCellPosition(GetCellID());
+	fp << "Location: (" << pos.first << "," << pos.second << ")\n";
+	
+	if(m_world->GetConfig().INTERRUPT_ENABLED.Get() == 1) {
+		cLocalThread* currentThread = static_cast<cHardwareCPU*>(m_hardware)->GetThread(m_hardware->GetCurThread());
+		if(currentThread->isInterrupted())
+			fp << "Interrupted: Saved IP " << (currentThread->pushedState.heads[0]).GetPosition() << endl;
+		else
+			fp << "NOT Interrupted " <<endl;
+	}
+	fp << "Queued messages: "<< static_cast<int>(NumQueuedMessages()) << endl;
+	
+	
   fp << setfill(' ') << setbase(10);
     
   fp << "---------------------------" << endl;

Modified: branches/interrupt/source/main/cStats.cc
===================================================================
--- branches/interrupt/source/main/cStats.cc	2009-01-22 15:16:06 UTC (rev 3132)
+++ branches/interrupt/source/main/cStats.cc	2009-01-23 14:51:56 UTC (rev 3133)
@@ -28,6 +28,8 @@
 #include "cDataFile.h"
 #include "cEnvironment.h"
 #include "cGenotype.h"
+#include "cHardwareCPU.h" // for class cLocalThread.h
+//TODO: move cLocalThread to its own header file.
 #include "cHardwareManager.h"
 #include "cInstSet.h"
 #include "cPopulation.h"
@@ -1936,9 +1938,57 @@
   df.Endl();
 }
 
+void cStats::PrintDemeInterrupt(const cString& filename){
+  cDataFile& df = m_world->GetDataFile(filename);
+	df.WriteComment("Interrupt model stats averaged over all demes");
+	df.WriteComment("Assumes each organism only contains a single thread!");
+	df.WriteTimeStamp();
+	
+	df.Write(m_update,   "Update");
+	unsigned int numInterrupted = 0;
+	int numDemes = m_world->GetPopulation().GetNumDemes();
+  for(int i=0; i<numDemes; ++i) {
+    cDeme& deme = m_world->GetPopulation().GetDeme(i);
+		for(int j = 0; j < deme.GetSize() ; ++j) {
+			cOrganism* org = deme.GetOrganism(j);
+			if(org != NULL) {
+				cLocalThread* currentThread = static_cast<cHardwareCPU*>(org->GetHardware(false))->GetThread(org->GetHardware(false)->GetCurThread());
+				if(currentThread->isInterrupted()) {
+					++numInterrupted;
+				}
+			}
+		}
+  }
+	df.Write((static_cast<double>(numInterrupted)/numDemes), "Organisms interrupted per deme" );
+  df.Endl();
+}
 
+void cStats::PrintOrgsLocationAndInterrupt(const cString& filename){
+	cDataFile& df = m_world->GetDataFile(filename);
+	df.WriteComment("Organism interrupt data use to make large scale movie");
+	df.WriteComment("Assumes each organism only contains a single thread!");
+	df.WriteTimeStamp();
+	
+	int numDemes = m_world->GetPopulation().GetNumDemes();
+  for(int i=0; i<numDemes; ++i) {
+    cDeme& deme = m_world->GetPopulation().GetDeme(i);
+		for(int j = 0; j < deme.GetSize() ; ++j) {
+			cOrganism* org = deme.GetOrganism(j);
+			if(org != NULL) {
+				int absolute_cell_ID = org->GetCellID();				
+				std::pair<int, int> pos = deme.GetCellPosition(absolute_cell_ID);  
+				cLocalThread* currentThread = static_cast<cHardwareCPU*>(org->GetHardware(false))->GetThread(org->GetHardware(false)->GetCurThread());
+				df.Write(m_update,   "Update");
+				df.Write(org->GetID(), "Organism ID" );
+				df.Write(pos.first, "X coordinate" );
+				df.Write(pos.second, "Y coordinate" );
+				df.Write(currentThread->isInterrupted(), "In organisms interruped?" );
+				df.Endl();
+			}
+		}
+  }
+}
 
-
 void cStats::CompeteDemes(const std::vector<double>& fitness) {
   m_deme_fitness = fitness;
 }

Modified: branches/interrupt/source/main/cStats.h
===================================================================
--- branches/interrupt/source/main/cStats.h	2009-01-22 15:16:06 UTC (rev 3132)
+++ branches/interrupt/source/main/cStats.h	2009-01-23 14:51:56 UTC (rev 3133)
@@ -842,7 +842,8 @@
   void PrintCurrentTaskCounts(const cString& filename);
   void PrintPerDemeGenPerFounderData(const cString& filename);
 	void PrintDemeMigrationSuicidePoints(const cString& filename);
-
+	void PrintDemeInterrupt(const cString& filename);
+	void PrintOrgsLocationAndInterrupt(const cString& filename);
 	
 
 




More information about the Avida-cvs mailing list