[Avida-cvs] [avida-svn] r839 - in development/source: cpu tools
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Sat Jul 15 16:16:25 PDT 2006
Author: brysonda
Date: 2006-07-15 19:16:25 -0400 (Sat, 15 Jul 2006)
New Revision: 839
Modified:
development/source/cpu/cHardwareSMT.cc
development/source/cpu/cHardwareSMT.h
development/source/tools/tArray.h
Log:
Add support for marked memory spaces within SMT.
Modified: development/source/cpu/cHardwareSMT.cc
===================================================================
--- development/source/cpu/cHardwareSMT.cc 2006-07-15 21:37:38 UTC (rev 838)
+++ development/source/cpu/cHardwareSMT.cc 2006-07-15 23:16:25 UTC (rev 839)
@@ -130,7 +130,7 @@
}
cHardwareSMT::cHardwareSMT(cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
-: cHardwareBase(world, in_organism, in_m_inst_set), m_mem_array(1)
+: cHardwareBase(world, in_organism, in_m_inst_set), m_mem_array(1), m_mem_marks(1)
, m_mem_lbls(Pow(NUM_NOPS, MAX_MEMSPACE_LABEL) / MEM_LBLS_HASH_FACTOR)
, m_thread_lbls(Pow(NUM_NOPS, MAX_THREAD_LABEL) / THREAD_LBLS_HASH_FACTOR)
{
@@ -146,6 +146,8 @@
{
// Setup the memory...
m_mem_array.Resize(1);
+ m_mem_marks.Resize(1);
+ m_mem_marks[0] = false;
m_mem_lbls.ClearAll();
// We want to reset to have a single thread.
@@ -374,7 +376,7 @@
for (int i = 0; i < m_mem_array.GetSize(); i++) {
const cCPUMemory& mem = m_mem_array[i];
- fp << " Mem " << i << " (" << mem.GetSize() << "): " << mem.AsString() << endl;
+ fp << " Mem " << i << " (" << mem.GetSize() << ")[" << (m_mem_marks[i] ? '*':' ') << "]: " << mem.AsString() << endl;
}
fp.flush();
@@ -389,6 +391,8 @@
if (!m_mem_lbls.Find(hash_key, mem_space)) {
mem_space = m_mem_array.GetSize();
m_mem_array.Resize(mem_space + 1);
+ m_mem_marks.Resize(mem_space + 1);
+ m_mem_marks[mem_space] = false;
m_mem_lbls.Add(hash_key, mem_space);
}
@@ -447,8 +451,7 @@
// Search forwards for search_label from _after_ position pos in the
// memory. Return the first line _after_ the the found label. It is okay
// to find search label's match inside another label.
-int cHardwareSMT::FindLabel_Forward(const cCodeLabel& search_label,
- const cGenome& search_genome, int pos)
+int cHardwareSMT::FindLabel_Forward(const cCodeLabel& search_label, const cGenome& search_genome, int pos)
{
assert (pos < search_genome.GetSize() && pos >= 0);
@@ -528,8 +531,7 @@
// Search backwards for search_label from _before_ position pos in the
// memory. Return the first line _after_ the the found label. It is okay
// to find search label's match inside another label.
-int cHardwareSMT::FindLabel_Backward(const cCodeLabel & search_label,
- const cGenome & search_genome, int pos)
+int cHardwareSMT::FindLabel_Backward(const cCodeLabel& search_label, const cGenome& search_genome, int pos)
{
assert (pos < search_genome.GetSize());
@@ -831,9 +833,7 @@
-////////////////////////////
-// Instruction Helpers...
-////////////////////////////
+// -------- Instruction Helpers --------
inline int cHardwareSMT::FindModifiedStack(int default_stack)
{
@@ -1308,20 +1308,21 @@
{
ReadLabel(MAX_MEMSPACE_LABEL);
- if (GetLabel().GetSize() == 0) {
- GetHead(nHardware::HEAD_FLOW).Set(0, 0);
- } else {
- int mem_space_used = FindMemorySpaceLabel(GetLabel(), -1);
- if (mem_space_used == -1) return false;
- GetHead(nHardware::HEAD_FLOW).Set(0, mem_space_used);
- }
+ int mem_space_used = FindMemorySpaceLabel(GetLabel(), -1);
+ if (mem_space_used == -1) return false;
+ GetHead(nHardware::HEAD_FLOW).Set(0, mem_space_used);
return true;
}
bool cHardwareSMT::Inst_MemMark(cAvidaContext& ctx)
{
- // @DMB - todo
+ ReadLabel(MAX_MEMSPACE_LABEL);
+
+ int mem_space_used = FindMemorySpaceLabel(GetLabel(), -1);
+ if (mem_space_used == -1) return false;
+ m_mem_marks[mem_space_used] = !m_mem_marks[mem_space_used];
+
return true;
}
Modified: development/source/cpu/cHardwareSMT.h
===================================================================
--- development/source/cpu/cHardwareSMT.h 2006-07-15 21:37:38 UTC (rev 838)
+++ development/source/cpu/cHardwareSMT.h 2006-07-15 23:16:25 UTC (rev 839)
@@ -100,6 +100,7 @@
// Memory
tManagedPointerArray<cCPUMemory> m_mem_array;
+ tArray<bool> m_mem_marks;
tHashTable<int, int> m_mem_lbls;
// Threads
Modified: development/source/tools/tArray.h
===================================================================
--- development/source/tools/tArray.h 2006-07-15 21:37:38 UTC (rev 838)
+++ development/source/tools/tArray.h 2006-07-15 23:16:25 UTC (rev 839)
@@ -89,7 +89,7 @@
}
- void Resize(int new_size, const T & empty_value)
+ void Resize(int new_size, const T& empty_value)
{
int old_size = m_size;
Resize(new_size);
More information about the Avida-cvs
mailing list