[Avida-cvs] [Avida2-svn] r325 - in trunk: Avida2.xcodeproj source/bindings/Boost.Python source/cpu source/support
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Thu Sep 22 16:51:59 PDT 2005
Author: brysonda
Date: 2005-09-22 19:51:59 -0400 (Thu, 22 Sep 2005)
New Revision: 325
Added:
trunk/source/bindings/Boost.Python/hardware_tracer_smt.pyste
trunk/source/cpu/cHardwareTracer_SMT.h
Modified:
trunk/Avida2.xcodeproj/project.pbxproj
trunk/source/bindings/Boost.Python/CMakeLists.txt
trunk/source/cpu/cCPUTestInfo.cc
trunk/source/cpu/cHardwareSMT.cc
trunk/source/cpu/cHardwareStatusPrinter.cc
trunk/source/cpu/cHardwareStatusPrinter.h
trunk/source/support/genesis.smt
trunk/source/support/organism.smt
Log:
Implement SMT Hardware Tracing.
Modified: trunk/Avida2.xcodeproj/project.pbxproj
===================================================================
--- trunk/Avida2.xcodeproj/project.pbxproj 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/Avida2.xcodeproj/project.pbxproj 2005-09-22 23:51:59 UTC (rev 325)
@@ -414,6 +414,8 @@
706D330E0854A7B900D7DC8F /* organism.smt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = organism.smt; sourceTree = "<group>"; };
706D33100854A7D700D7DC8F /* genesis.smt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = genesis.smt; sourceTree = "<group>"; };
706D33270854A90D00D7DC8F /* inst_set.smt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = inst_set.smt; sourceTree = "<group>"; };
+ 707A687408E3750300576968 /* cHardwareTracer_SMT.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHardwareTracer_SMT.h; sourceTree = "<group>"; };
+ 707A68B808E37D5900576968 /* hardware_tracer_smt.pyste */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = hardware_tracer_smt.pyste; sourceTree = "<group>"; };
70C1EF4608C393BA00F50912 /* cCodeLabel.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCodeLabel.cc; sourceTree = "<group>"; };
70C1EF4708C393BA00F50912 /* cCodeLabel.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cCodeLabel.h; sourceTree = "<group>"; };
70C1EF5808C3948C00F50912 /* cCPUMemory.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCPUMemory.cc; sourceTree = "<group>"; };
@@ -1715,6 +1717,7 @@
DCC30C750762539A008F7A48 /* Boost.Python */ = {
isa = PBXGroup;
children = (
+ 707A68B808E37D5900576968 /* hardware_tracer_smt.pyste */,
70C1F11108C40D6100F50912 /* nHardwareCPU.pyste */,
70C1F10F08C40D2D00F50912 /* nHardwareCPU-fixups.cc */,
70C1F11008C40D2D00F50912 /* nHardwareCPU-fixups.h */,
@@ -1968,6 +1971,7 @@
DCC30F7C0762539D008F7A48 /* cpu */ = {
isa = PBXGroup;
children = (
+ 707A687408E3750300576968 /* cHardwareTracer_SMT.h */,
70C1F0FC08C40B1B00F50912 /* nHardwareCPU.h */,
70C1F0A808C3FF1800F50912 /* nHardware.h */,
70C1F06108C3CDEA00F50912 /* nHardware4Stack.h */,
Modified: trunk/source/bindings/Boost.Python/CMakeLists.txt
===================================================================
--- trunk/source/bindings/Boost.Python/CMakeLists.txt 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/source/bindings/Boost.Python/CMakeLists.txt 2005-09-22 23:51:59 UTC (rev 325)
@@ -156,6 +156,7 @@
hardware_cpu::${CMAKE_CURRENT_SOURCE_DIR}/hardware_base.pyste:${CMAKE_CURRENT_SOURCE_DIR}/hardware_cpu-fixups.hh # XXX XXX XXX
hardware_tracer::
hardware_tracer_cpu::
+ hardware_tracer_smt::
hardware_tracer_4stack::
hardware_tracer_test_cpu::
hardware_status_printer::
Added: trunk/source/bindings/Boost.Python/hardware_tracer_smt.pyste
===================================================================
--- trunk/source/bindings/Boost.Python/hardware_tracer_smt.pyste 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/source/bindings/Boost.Python/hardware_tracer_smt.pyste 2005-09-22 23:51:59 UTC (rev 325)
@@ -0,0 +1,6 @@
+
+Include("cHardwareSMT.h")
+
+cHardwareTracer_SMT = Class("cHardwareTracer_SMT", "cHardwareTracer_SMT.h")
+
+# vim: set ft=python:
Modified: trunk/source/cpu/cCPUTestInfo.cc
===================================================================
--- trunk/source/cpu/cCPUTestInfo.cc 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/source/cpu/cCPUTestInfo.cc 2005-09-22 23:51:59 UTC (rev 325)
@@ -24,8 +24,8 @@
, trace_execution(false)
, trace_task_order(false)
, use_random_inputs(false)
+ , m_tracer(NULL)
, org_array(max_tests)
- , m_tracer(NULL)
{
org_array.SetAll(NULL);
Clear();
Modified: trunk/source/cpu/cHardwareSMT.cc
===================================================================
--- trunk/source/cpu/cHardwareSMT.cc 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/source/cpu/cHardwareSMT.cc 2005-09-22 23:51:59 UTC (rev 325)
@@ -16,7 +16,7 @@
#include "cInstLibBase.h"
#include "cInstSet.h"
#include "cHardwareTracer.h"
-//#include "cHardwareTracer_4Stack.h"
+#include "cHardwareTracer_SMT.h"
#include "mutation.hh"
#include "mutation_lib.hh"
#include "mutation_macros.hh"
@@ -137,8 +137,8 @@
}
cHardwareSMT::cHardwareSMT(cOrganism* in_organism, cInstSet* in_inst_set)
- : cHardwareBase(in_organism, in_inst_set), m_mem_array(1),
- m_mem_lbls(pow(nHardwareSMT::NUM_NOPS, nHardwareSMT::MAX_MEMSPACE_LABEL) / nHardwareSMT::MEM_LBLS_HASH_FACTOR)
+: cHardwareBase(in_organism, in_inst_set), m_mem_array(1),
+m_mem_lbls(pow(nHardwareSMT::NUM_NOPS, nHardwareSMT::MAX_MEMSPACE_LABEL) / nHardwareSMT::MEM_LBLS_HASH_FACTOR)
{
m_functions = s_inst_slib->GetFunctions();
@@ -220,7 +220,7 @@
phenotype.IncTimeUsed();
const int num_inst_exec = (cConfig::GetThreadSlicingMethod() == 1) ? GetNumThreads() : 1;
-
+
for (int i = 0; i < num_inst_exec; i++) {
// Setup the hardware for the next instruction to be executed.
NextThread();
@@ -233,13 +233,13 @@
}
#endif
- // DDD - there is no cHardwareTracer_SMT -- Print the status of this CPU at each step...
- //if (m_tracer != NULL) {
- // if (cHardwareTracer_SMT* tracer = dynamic_cast<cHardwareTracer_SMT *>(m_tracer)) {
- // tracer->TraceHardware_SMT(*this);
- // }
- //}
-
+ // Print the status of this CPU at each step...
+ if (m_tracer != NULL) {
+ if (cHardwareTracer_SMT* tracer = dynamic_cast<cHardwareTracer_SMT *>(m_tracer)) {
+ tracer->TraceHardware_SMT(*this);
+ }
+ }
+
// Find the instruction to be executed
const cInstruction & cur_inst = IP().GetInst();
@@ -255,14 +255,14 @@
if (AdvanceIP() == true) IP().Advance();
} // if exec
} // Previous was executed once for each thread...
-
+
// Kill creatures who have reached their max num of instructions executed
const int max_executed = organism->GetMaxExecuted();
if ((max_executed > 0 && phenotype.GetTimeUsed() >= max_executed)
|| phenotype.GetToDie()) {
organism->Die();
}
-
+
organism->SetRunning(false);
}
@@ -342,15 +342,15 @@
bool prev_run_state = organism->GetIsRunning();
organism->SetRunning(true);
- // DDD - there is no cHardwareTracer_SMT -- Print the status of this CPU at each step...
- //if (m_tracer != NULL) {
- // if (cHardwareTracer_SMT* tracer = dynamic_cast<cHardwareTracer_SMT *>(m_tracer)) {
- // tracer->TraceHardware_SMTBonus(*this);
- // }
- //}
-
+ // Print the status of this CPU at each step...
+ if (m_tracer != NULL) {
+ if (cHardwareTracer_SMT* tracer = dynamic_cast<cHardwareTracer_SMT *>(m_tracer)) {
+ tracer->TraceHardware_SMTBonus(*this);
+ }
+ }
+
SingleProcess_ExecuteInst(inst);
-
+
organism->SetRunning(prev_run_state);
}
@@ -397,22 +397,13 @@
<< "F-Head:(" << GetHead(nHardware::HEAD_FLOW).GetMemSpace() << ", "
<< GetHead(nHardware::HEAD_FLOW).GetPosition() << ") "
<< "RL:" << GetReadLabel().AsString() << " "
- << endl;
+ << endl;
- fp << " Mem (" << GetMemory(0).GetSize() << "):"
- << " " << GetMemory(0).AsString()
- << endl;
- fp << " " << GetMemory(1).GetSize() << "):"
- << " " << GetMemory(1).AsString()
- << endl;
- fp << " " << GetMemory(2).GetSize() << "):"
- << " " << GetMemory(2).AsString()
- << endl;
- fp << " " << GetMemory(3).GetSize() << "):"
- << " " << GetMemory(3).AsString()
- << endl;
+ for (int i = 0; i < m_mem_array.GetSize(); i++) {
+ const cCPUMemory& mem = GetMemory(i);
+ fp << " Mem " << i << " (" << mem.GetSize() << "): " << mem.AsString() << endl;
+ }
-
fp.flush();
}
@@ -421,7 +412,7 @@
{
cCodeLabel& label = GetLabel();
if (label.GetSize() == 0) return 0;
-
+
int hash_key = label.AsInt(nHardwareSMT::NUM_NOPS);
if (!m_mem_lbls.Find(hash_key, mem_space)) {
mem_space = m_mem_array.GetSize();
Modified: trunk/source/cpu/cHardwareStatusPrinter.cc
===================================================================
--- trunk/source/cpu/cHardwareStatusPrinter.cc 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/source/cpu/cHardwareStatusPrinter.cc 2005-09-22 23:51:59 UTC (rev 325)
@@ -9,6 +9,7 @@
#include "cHardware4Stack.h"
#include "cHardwareBase.h"
#include "cHardwareCPU.h"
+#include "cHardwareSMT.h"
#include "cHardwareStatusPrinter.h"
#include "cInstSet.h"
#include "organism.hh"
@@ -17,60 +18,72 @@
#include <fstream>
-cHardwareStatusPrinter::cHardwareStatusPrinter(ostream &trace_fp)
-: m_trace_fp(trace_fp)
-{}
-
-const cString & cHardwareStatusPrinter::GetNextInstName(
- cHardwareCPU &hardware
-){
- return hardware.GetInstSet().GetName(hardware.IP().GetInst());
-}
-
-const cString & cHardwareStatusPrinter::GetNextInstName(
- cHardware4Stack &hardware
-){
- return hardware.GetInstSet().GetName(hardware.IP().GetInst());
-}
-
-cString cHardwareStatusPrinter::Bonus(const cString &next_name){
+cString cHardwareStatusPrinter::Bonus(const cString &next_name)
+{
return cStringUtil::Stringf("%s (bonus instruction)", next_name());
}
-void cHardwareStatusPrinter::PrintStatus(
- cHardwareBase &hardware,
- const cString &next_name
-){
+void cHardwareStatusPrinter::PrintStatus(cHardwareBase& hardware, const cString& next_name)
+{
cOrganism *organism = hardware.GetOrganism();
if(organism) organism->PrintStatus(m_trace_fp, next_name);
}
-void cHardwareStatusPrinter::TraceHardware_CPU(cHardwareCPU &hardware){
+// CPU
+const cString& cHardwareStatusPrinter::GetNextInstName(cHardwareCPU& hardware)
+{
+ return hardware.GetInstSet().GetName(hardware.IP().GetInst());
+}
+void cHardwareStatusPrinter::TraceHardware_CPU(cHardwareCPU &hardware)
+{
PrintStatus(hardware, GetNextInstName(hardware));
}
-void cHardwareStatusPrinter::TraceHardware_4Stack(cHardware4Stack &hardware){
+void cHardwareStatusPrinter::TraceHardware_CPUBonus(cHardwareCPU &hardware)
+{
+ PrintStatus(hardware, Bonus(GetNextInstName(hardware)));
+}
+
+// 4Stack
+const cString& cHardwareStatusPrinter::GetNextInstName(cHardware4Stack& hardware)
+{
+ return hardware.GetInstSet().GetName(hardware.IP().GetInst());
+}
+void cHardwareStatusPrinter::TraceHardware_4Stack(cHardware4Stack &hardware)
+{
PrintStatus(hardware, GetNextInstName(hardware));
}
-void cHardwareStatusPrinter::TraceHardware_CPUBonus(cHardwareCPU &hardware){
+void cHardwareStatusPrinter::TraceHardware_4StackBonus(cHardware4Stack &hardware)
+{
PrintStatus(hardware, Bonus(GetNextInstName(hardware)));
}
-void cHardwareStatusPrinter::TraceHardware_4StackBonus(cHardware4Stack &hardware){
+
+// SMT
+const cString& cHardwareStatusPrinter::GetNextInstName(cHardwareSMT& hardware)
+{
+ return hardware.GetInstSet().GetName(hardware.IP().GetInst());
+}
+void cHardwareStatusPrinter::TraceHardware_SMT(cHardwareSMT &hardware)
+{
+ PrintStatus(hardware, GetNextInstName(hardware));
+}
+void cHardwareStatusPrinter::TraceHardware_SMTBonus(cHardwareSMT &hardware)
+{
PrintStatus(hardware, Bonus(GetNextInstName(hardware)));
}
+
void cHardwareStatusPrinter::TraceHardware_TestCPU(
int time_used,
int time_allocated,
int size,
const cString &final_memory,
const cString &child_memory
-){
+)
+{
if (time_used == time_allocated) {
m_trace_fp << endl << "# TIMEOUT: No offspring produced." << endl;
- }
- else if (size == 0) {
+ } else if (size == 0) {
m_trace_fp << endl << "# ORGANISM DEATH: No offspring produced." << endl;
- }
- else {
+ } else {
m_trace_fp
<< endl << "# Final Memory: " << final_memory
<< endl << "# Child Memory: " << child_memory << endl;
Modified: trunk/source/cpu/cHardwareStatusPrinter.h
===================================================================
--- trunk/source/cpu/cHardwareStatusPrinter.h 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/source/cpu/cHardwareStatusPrinter.h 2005-09-22 23:51:59 UTC (rev 325)
@@ -16,6 +16,9 @@
#ifndef HARDWARE_TRACER_4STACK_HH
#include "cHardwareTracer_4Stack.h"
#endif
+#ifndef HARDWARE_TRACER_SMT_H
+#include "cHardwareTracer_SMT.h"
+#endif
#ifndef HARDWARE_TRACER_CPU_HH
#include "cHardwareTracer_CPU.h"
#endif
@@ -31,28 +34,31 @@
class cHardwareBase;
-class cHardwareCPU;
-class cHardware4Stack;
class cHardwareStatusPrinter :
public cHardwareTracer,
public cHardwareTracer_CPU,
public cHardwareTracer_4Stack,
+ public cHardwareTracer_SMT,
public cHardwareTracer_TestCPU
{
protected:
ostream &m_trace_fp;
protected:
- const cString & GetNextInstName(cHardwareCPU &hardware);
- const cString & GetNextInstName(cHardware4Stack &hardware);
+ const cString & GetNextInstName(cHardwareCPU& hardware);
+ const cString & GetNextInstName(cHardware4Stack& hardware);
+ const cString & GetNextInstName(cHardwareSMT& hardware);
cString Bonus(const cString &next_name);
- void PrintStatus(cHardwareBase &hardware, const cString &next_name);
+ void PrintStatus(cHardwareBase& hardware, const cString& next_name);
public:
- cHardwareStatusPrinter(ostream &trace_fp);
+ cHardwareStatusPrinter(ostream& trace_fp) : m_trace_fp(trace_fp) {;}
+
virtual void TraceHardware_CPU(cHardwareCPU &hardware);
virtual void TraceHardware_4Stack(cHardware4Stack &hardware);
+ virtual void TraceHardware_SMT(cHardwareSMT &hardware);
virtual void TraceHardware_CPUBonus(cHardwareCPU &hardware);
virtual void TraceHardware_4StackBonus(cHardware4Stack &hardware);
+ virtual void TraceHardware_SMTBonus(cHardwareSMT &hardware);
virtual void TraceHardware_TestCPU(
int time_used,
int time_allocated,
Added: trunk/source/cpu/cHardwareTracer_SMT.h
===================================================================
--- trunk/source/cpu/cHardwareTracer_SMT.h 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/source/cpu/cHardwareTracer_SMT.h 2005-09-22 23:51:59 UTC (rev 325)
@@ -0,0 +1,20 @@
+/*
+ * cHardwareSMT.h
+ * Avida2
+ *
+ * Created by David on 9/22/05.
+ * Copyright 2005 Michigan State University. All rights reserved.
+ *
+ */
+
+#ifndef HARDWARE_TRACER_SMT_H
+#define HARDWARE_TRACER_SMT_H
+
+class cHardwareSMT;
+struct cHardwareTracer_SMT {
+ virtual ~cHardwareTracer_SMT() { ; }
+ virtual void TraceHardware_SMT(cHardwareSMT &) = 0;
+ virtual void TraceHardware_SMTBonus(cHardwareSMT &) = 0;
+};
+
+#endif
Modified: trunk/source/support/genesis.smt
===================================================================
--- trunk/source/support/genesis.smt 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/source/support/genesis.smt 2005-09-22 23:51:59 UTC (rev 325)
@@ -34,7 +34,7 @@
# 3 = Place only in empty cells in neighborhood
# 4 = Replace random from entire population (Mass Action)
# 5 = Replace oldest in entire population (like Tierra)
-DEATH_METHOD 0 # 0 = Never die of old age.
+DEATH_METHOD 2 # 0 = Never die of old age.
# 1 = Die when inst executed = AGE_LIMIT (with deviation)
# 2 = Die when inst executed = length * AGE_LIMIT (+ dev.)
AGE_LIMIT 5000 # Modifies DEATH_METHOD
@@ -64,7 +64,7 @@
# mutations that occur during execution..
POINT_MUT_PROB 0.0 # Mutation rate (per-location per update)
-COPY_MUT_PROB 0.01 # Mutation rate (per copy).
+COPY_MUT_PROB 0.0075 # Mutation rate (per copy).
# mutations that occur on divide...
INS_MUT_PROB 0.0 # Insertion rate (per site, applied on divide).
Modified: trunk/source/support/organism.smt
===================================================================
--- trunk/source/support/organism.smt 2005-09-22 13:02:13 UTC (rev 324)
+++ trunk/source/support/organism.smt 2005-09-22 23:51:59 UTC (rev 325)
@@ -6,8 +6,6 @@
Push-Prev # 5: Move end position to Stack-A
SetMemory # 6: Place FLOW-head in memory space for offspring
Nop-A # - Memory space labeled Nop-A Nop-A Nop-A
-Nop-A
-Nop-A
Head-Move # 7: Move Write head to flow head position
Nop-C # 8:
Nop-C # 8:
@@ -95,8 +93,6 @@
Nop-C # 8:
Nop-C # 8:
Nop-C # 8:
-Nop-C # 8:
-Nop-C # 8:
Search # 9: Drop flow head at start of copy loop
Inst-Read # 10:
Inst-Write # 11:
More information about the Avida-cvs
mailing list