[Avida-SVN] r2080 - in development: Avida.xcodeproj source/cpu
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Sun Sep 9 08:40:20 PDT 2007
Author: brysonda
Date: 2007-09-09 11:40:20 -0400 (Sun, 09 Sep 2007)
New Revision: 2080
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/cpu/cHardwareSMT.h
development/source/cpu/cHardwareTransSMT.h
development/source/cpu/cHeadCPU.cc
Log:
Performance tweak in cHeadCPU::Adjust. Perform integer division only when necessary.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2007-09-08 23:20:06 UTC (rev 2079)
+++ development/Avida.xcodeproj/project.pbxproj 2007-09-09 15:40:20 UTC (rev 2080)
@@ -212,23 +212,6 @@
};
/* End PBXBuildRule section */
-/* Begin PBXBuildStyle section */
- B516AF180C91DC7700023D53 /* Development */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = NO;
- };
- name = Development;
- };
- B516AF190C91DC7700023D53 /* Deployment */ = {
- isa = PBXBuildStyle;
- buildSettings = {
- COPY_PHASE_STRIP = YES;
- };
- name = Deployment;
- };
-/* End PBXBuildStyle section */
-
/* Begin PBXContainerItemProxy section */
56F555DA0C3B36FC00E2E929 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
@@ -1796,12 +1779,6 @@
DCC30C4D0762532C008F7A48 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
- buildSettings = {
- };
- buildStyles = (
- B516AF180C91DC7700023D53 /* Development */,
- B516AF190C91DC7700023D53 /* Deployment */,
- );
hasScannedForEncodings = 0;
mainGroup = DCC30C490762532C008F7A48;
productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;
Modified: development/source/cpu/cHardwareSMT.h
===================================================================
--- development/source/cpu/cHardwareSMT.h 2007-09-08 23:20:06 UTC (rev 2079)
+++ development/source/cpu/cHardwareSMT.h 2007-09-09 15:40:20 UTC (rev 2080)
@@ -358,9 +358,9 @@
inline int cHardwareSMT::GetStack(int depth, int stack_id, int in_thread) const
{
- if(stack_id<0 || stack_id > NUM_STACKS) stack_id=0;
+ if (stack_id<0 || stack_id > NUM_STACKS) stack_id=0;
- if(in_thread==-1)
+ if (in_thread==-1)
in_thread=m_cur_thread;
return Stack(stack_id, in_thread).Get(depth);
@@ -368,8 +368,8 @@
inline cCPUStack& cHardwareSMT::Stack(int stack_id)
{
- if(stack_id >= NUM_STACKS) stack_id = 0;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id >= NUM_STACKS) stack_id = 0;
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[m_cur_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -377,8 +377,8 @@
inline const cCPUStack& cHardwareSMT::Stack(int stack_id) const
{
- if(stack_id >= NUM_STACKS) stack_id = 0;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id >= NUM_STACKS) stack_id = 0;
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[m_cur_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -386,10 +386,10 @@
inline cCPUStack& cHardwareSMT::Stack(int stack_id, int in_thread)
{
- if(stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
- if(in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
+ if (stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
+ if (in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[in_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -397,10 +397,10 @@
inline const cCPUStack& cHardwareSMT::Stack(int stack_id, int in_thread) const
{
- if(stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
- if(in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
+ if (stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
+ if (in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[in_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -408,8 +408,8 @@
inline int cHardwareSMT::NormalizeMemSpace(int mem_space) const
{
- if(mem_space >= m_mem_array.GetSize())
- mem_space %= m_mem_array.GetSize();
+ assert(mem_space >= 0);
+ if (mem_space >= m_mem_array.GetSize()) mem_space %= m_mem_array.GetSize();
return mem_space;
}
Modified: development/source/cpu/cHardwareTransSMT.h
===================================================================
--- development/source/cpu/cHardwareTransSMT.h 2007-09-08 23:20:06 UTC (rev 2079)
+++ development/source/cpu/cHardwareTransSMT.h 2007-09-09 15:40:20 UTC (rev 2080)
@@ -358,9 +358,9 @@
inline int cHardwareTransSMT::GetStack(int depth, int stack_id, int in_thread) const
{
- if(stack_id<0 || stack_id > NUM_STACKS) stack_id=0;
+ if (stack_id<0 || stack_id > NUM_STACKS) stack_id=0;
- if(in_thread==-1)
+ if (in_thread==-1)
in_thread=m_cur_thread;
return Stack(stack_id, in_thread).Get(depth);
@@ -368,8 +368,8 @@
inline cCPUStack& cHardwareTransSMT::Stack(int stack_id)
{
- if(stack_id >= NUM_STACKS) stack_id = 0;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id >= NUM_STACKS) stack_id = 0;
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[m_cur_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -377,8 +377,8 @@
inline const cCPUStack& cHardwareTransSMT::Stack(int stack_id) const
{
- if(stack_id >= NUM_STACKS) stack_id = 0;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id >= NUM_STACKS) stack_id = 0;
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[m_cur_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -386,10 +386,10 @@
inline cCPUStack& cHardwareTransSMT::Stack(int stack_id, int in_thread)
{
- if(stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
- if(in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
+ if (stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
+ if (in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[in_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -397,10 +397,10 @@
inline const cCPUStack& cHardwareTransSMT::Stack(int stack_id, int in_thread) const
{
- if(stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
- if(in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
+ if (stack_id >= NUM_STACKS || stack_id < 0) stack_id = 0;
+ if (in_thread >= m_threads.GetSize() || in_thread < 0) in_thread = m_cur_thread;
- if(stack_id < NUM_LOCAL_STACKS)
+ if (stack_id < NUM_LOCAL_STACKS)
return m_threads[in_thread].local_stacks[stack_id];
else
return m_global_stacks[stack_id % NUM_LOCAL_STACKS];
@@ -408,8 +408,8 @@
inline int cHardwareTransSMT::NormalizeMemSpace(int mem_space) const
{
- if(mem_space >= m_mem_array.GetSize())
- mem_space %= m_mem_array.GetSize();
+ assert(mem_space >= 0);
+ if (mem_space >= m_mem_array.GetSize()) mem_space %= m_mem_array.GetSize();
return mem_space;
}
Modified: development/source/cpu/cHeadCPU.cc
===================================================================
--- development/source/cpu/cHeadCPU.cc 2007-09-08 23:20:06 UTC (rev 2079)
+++ development/source/cpu/cHeadCPU.cc 2007-09-09 15:40:20 UTC (rev 2080)
@@ -35,8 +35,9 @@
void cHeadCPU::Adjust()
{
+ assert(m_mem_space >= 0);
// Ensure that m_mem_space is valid
- m_mem_space %= m_hardware->GetNumMemSpaces();
+ if (m_mem_space >= m_hardware->GetNumMemSpaces()) m_mem_space %= m_hardware->GetNumMemSpaces();
const int mem_size = GetMemory().GetSize();
More information about the Avida-cvs
mailing list