[Avida-SVN] r1696 - in development: . Avida.xcodeproj source/actions source/main source/tools
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Tue Jun 19 19:14:19 PDT 2007
Author: brysonda
Date: 2007-06-19 22:14:19 -0400 (Tue, 19 Jun 2007)
New Revision: 1696
Modified:
development/Avida.xcodeproj/project.pbxproj
development/CMakeLists.txt
development/source/actions/PrintActions.cc
development/source/main/cPhenotype.cc
development/source/main/cPopulation.cc
development/source/tools/cRandom.h
development/source/tools/tVector.h
Log:
"Fix" sexual reproduction tests on PowerPC platforms (including Linux based PowerPCs). The birth chamber code presents an opportunity to used the fast fused-multiply-add instruction found on PowerPC (and other RISC architectures). This is problematic in that the result of the multiply is not rounded prior to the add, yielding a variance from IEEE 754 floating point. While the result is technically more accurate, it results in different behavior from other platforms. The solution is to pass GCC the -mno-fused-madd flag. This instructs GCC to not use the operation on any platform that provides it, but rather perform the multiply and add operations separately.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2007-06-19 16:53:17 UTC (rev 1695)
+++ development/Avida.xcodeproj/project.pbxproj 2007-06-20 02:14:19 UTC (rev 1696)
@@ -173,6 +173,7 @@
7049F3710A66AD7E00640512 /* default-sex-classic.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F36D0A66AD7E00640512 /* default-sex-classic.org */; };
7049F3720A66AD7E00640512 /* default-smt.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F36E0A66AD7E00640512 /* default-smt.org */; };
7049F3730A66AD7E00640512 /* default-transsmt.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F36F0A66AD7E00640512 /* default-transsmt.org */; };
+ 704C21DC0C28C3980038F1A5 /* libtcmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 70AA941909D486AE006A24C8 /* libtcmalloc.a */; };
70658C5A085DF67D00486BED /* libncurses.5.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 70658C59085DF67D00486BED /* libncurses.5.4.dylib */; };
70AA941A09D486CA006A24C8 /* system-alloc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCF50209CFB0B400924128 /* system-alloc.cc */; };
70AA941B09D486CB006A24C8 /* tcmalloc-logging.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCF57F09CFBD3D00924128 /* tcmalloc-logging.cc */; };
@@ -182,7 +183,6 @@
70B6514F0BEA6FCC002472ED /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 701EF27E0BEA5D2300DAE168 /* main.cc */; };
70B651B70BEA9AEC002472ED /* unit-tests in CopyFiles */ = {isa = PBXBuildFile; fileRef = 70B6514C0BEA6FAD002472ED /* unit-tests */; };
70DCAC9C097AF7C0002F8733 /* primitive.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCAC9B097AF7C0002F8733 /* primitive.cc */; };
- 70DCF66C09D4DE6500924128 /* libtcmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 70AA941909D486AE006A24C8 /* libtcmalloc.a */; };
/* End PBXBuildFile section */
/* Begin PBXBuildRule section */
@@ -338,7 +338,7 @@
700AE91B09DB65F200A073FD /* cTaskContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cTaskContext.h; sourceTree = "<group>"; };
700E11BC0A0815B600B604CD /* cDataEntry.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cDataEntry.cc; sourceTree = "<group>"; };
700E28CF0859FFD700CF158A /* tObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tObjectFactory.h; sourceTree = "<group>"; };
- 700E2B83085DE50C00CF158A /* avida-viewer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "avida-viewer"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 700E2B83085DE50C00CF158A /* avida-viewer */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = "avida-viewer"; sourceTree = BUILT_PRODUCTS_DIR; };
7013845F09028B3E0087ED2E /* cAvidaConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cAvidaConfig.h; sourceTree = "<group>"; };
7013846009028B3E0087ED2E /* cAvidaConfig.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cAvidaConfig.cc; sourceTree = "<group>"; };
701384A10902A16F0087ED2E /* defs.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = defs.h; sourceTree = "<group>"; };
@@ -844,8 +844,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 70DCF66C09D4DE6500924128 /* libtcmalloc.a in Frameworks */,
7023ECA80C0A437200362B9C /* libavida-core.a in Frameworks */,
+ 704C21DC0C28C3980038F1A5 /* libtcmalloc.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2081,7 +2081,9 @@
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
PREBINDING = NO;
WARNING_CFLAGS = (
+ "-Wall",
"-Wextra",
+ "-Wno-unused-parameter",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
"-Wconversion",
@@ -2107,7 +2109,7 @@
GCC_STRICT_ALIASING = YES;
GCC_UNROLL_LOOPS = YES;
PER_ARCH_CFLAGS_i386 = "-DCOMPILE_ARCH=\\\"Intel\\\"";
- PER_ARCH_CFLAGS_ppc = "-DCOMPILE_ARCH=\\\"G4-G5\\\" -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -ftree-loop-linear -fsched-interblock -fgcse-sm";
+ PER_ARCH_CFLAGS_ppc = "-DCOMPILE_ARCH=\\\"G4-G5\\\" -mno-fused-madd -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -ftree-loop-linear -fsched-interblock -fgcse-sm";
SEPARATE_STRIP = YES;
WARNING_CFLAGS = (
"-Wextra",
@@ -2241,6 +2243,7 @@
OTHER_CFLAGS = (
"$(OTHER_CFLAGS_QUOTED_1)",
"-mpowerpc-gpopt",
+ "-mno-fused-madd",
"-falign-loops-max-skip=15",
"-falign-jumps-max-skip=15",
"-falign-loops=16",
@@ -2280,12 +2283,17 @@
);
GCC_STRICT_ALIASING = YES;
GCC_UNROLL_LOOPS = YES;
- OTHER_CFLAGS = "-falign-loops=16";
+ OTHER_CFLAGS = (
+ "-mno-fused-madd",
+ "-falign-loops=16",
+ );
PER_ARCH_CFLAGS_i386 = "-DCOMPILE_ARCH=\\\"Intel\\\"";
PER_ARCH_CFLAGS_ppc = "-DCOMPILE_ARCH=\\\"G4-G5\\\"";
PREBINDING = NO;
WARNING_CFLAGS = (
+ "-Wall",
"-Wextra",
+ "-Wno-unused-parameter",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
"-Wconversion",
@@ -2461,7 +2469,7 @@
GCC_STRICT_ALIASING = YES;
GCC_UNROLL_LOOPS = YES;
PER_ARCH_CFLAGS_i386 = "-DCOMPILE_ARCH=\\\"Intel\\\"";
- PER_ARCH_CFLAGS_ppc = "-DCOMPILE_ARCH=\\\"G4-G5\\\" -mpowerpc-gpopt -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -ftree-loop-linear -fsched-interblock -fgcse-sm";
+ PER_ARCH_CFLAGS_ppc = "-DCOMPILE_ARCH=\\\"G4-G5\\\" -mpowerpc-gpopt -mno-fused-madd -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -ftree-loop-linear -fsched-interblock -fgcse-sm";
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
SEPARATE_STRIP = YES;
Modified: development/CMakeLists.txt
===================================================================
--- development/CMakeLists.txt 2007-06-19 16:53:17 UTC (rev 1695)
+++ development/CMakeLists.txt 2007-06-20 02:14:19 UTC (rev 1696)
@@ -35,7 +35,7 @@
SET(COMPILER_OPTIMIZATION_FLAGS "-ffast-math -fno-rtti -funroll-loops -fstrict-aliasing -OPT:Olimit=0")
ELSE (CMAKE_CXX_COMPILER MATCHES ".*pathCC.*")
SET(COMPILER_WARNING_FLAGS "-Wextra -Wno-unknown-pragmas -Wconversion -Wno-trigraphs")
- SET(COMPILER_OPTIMIZATION_FLAGS "-ffast-math -fno-rtti -funroll-loops -fstrict-aliasing -ftree-vectorize -fvisibility-inlines-hidden")
+ SET(COMPILER_OPTIMIZATION_FLAGS "-mno-fused-madd -ffast-math -fno-rtti -funroll-loops -fstrict-aliasing -ftree-vectorize -fvisibility-inlines-hidden")
ENDIF (CMAKE_CXX_COMPILER MATCHES ".*pathCC.*")
# Four types of c++ compilations:
Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc 2007-06-19 16:53:17 UTC (rev 1695)
+++ development/source/actions/PrintActions.cc 2007-06-20 02:14:19 UTC (rev 1696)
@@ -1177,7 +1177,6 @@
//Gather data objects
cPopulation& pop = m_world->GetPopulation();
const int update = m_world->GetStats().GetUpdate();
- const double generation = m_world->GetStats().SumGeneration().Average();
map< int, tArray<cOrganism*> > org_map; //Map of ccladeID to array of organism IDs
map< int, tArray<cGenotype*> > gen_map; //Map of ccladeID to array of genotype IDs
@@ -1293,7 +1292,6 @@
///Gather data objects
cPopulation& pop = m_world->GetPopulation();
const int update = m_world->GetStats().GetUpdate();
- const double generation = m_world->GetStats().SumGeneration().Average();
map< int, tArray<cOrganism*> > org_map; //Map of ccladeID to array of organism IDs
map< int, tArray<cGenotype*> > gen_map; //Map of ccladeID to array of genotype IDs
@@ -1374,8 +1372,6 @@
static const cString GetDescription() { return "Arguments: [filename = \"GenomicSiteEntropyData.datcd \"] [use_gap = false]";}
void Process(cAvidaContext& ctx){
- const int update = m_world->GetStats().GetUpdate();
- const double generation = m_world->GetStats().SumGeneration().Average();
const int num_insts = m_world->GetNumInstructions();
tArray<cString> aligned; //This will hold all of our aligned sequences
Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc 2007-06-19 16:53:17 UTC (rev 1695)
+++ development/source/main/cPhenotype.cc 2007-06-20 02:14:19 UTC (rev 1696)
@@ -50,14 +50,14 @@
, cur_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
, cur_sense_count(m_world->GetStats().GetSenseSize())
, sensed_resources(m_world->GetEnvironment().GetResourceLib().GetSize())
+ , promoter_last_inst_terminated(false)
, last_task_count(m_world->GetEnvironment().GetNumTasks())
- , last_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())
, last_task_quality(m_world->GetEnvironment().GetNumTasks())
, last_task_value(m_world->GetEnvironment().GetNumTasks())
, last_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
+ , last_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())
, last_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
, last_sense_count(m_world->GetStats().GetSenseSize())
- , promoter_last_inst_terminated(false)
{
}
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2007-06-19 16:53:17 UTC (rev 1695)
+++ development/source/main/cPopulation.cc 2007-06-20 02:14:19 UTC (rev 1696)
@@ -71,10 +71,10 @@
, schedule(NULL)
, resource_count(world->GetEnvironment().GetResourceLib().GetSize())
, birth_chamber(world)
+, numAsleep(0)
, environment(world->GetEnvironment())
, num_organisms(0)
, sync_events(false)
-, numAsleep(0)
{
// Avida specific information.
world_x = world->GetConfig().WORLD_X.Get();
@@ -82,7 +82,6 @@
int num_demes = m_world->GetConfig().NUM_DEMES.Get();
const int num_cells = world_x * world_y;
const int geometry = world->GetConfig().WORLD_GEOMETRY.Get();
- const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
if(m_world->GetConfig().ENERGY_CAP.Get() == -1)
m_world->GetConfig().ENERGY_CAP.Set(INT_MAX);
@@ -106,6 +105,9 @@
}
// Error checking for demes vs. non-demes setup.
+#ifdef DEBUG
+ const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
+#endif
if(num_demes > 0) {
assert(birth_method != POSITION_CHILD_FULL_SOUP_ELDEST);
assert(birth_method != POSITION_CHILD_FULL_SOUP_ELDEST);
@@ -309,7 +311,6 @@
}
}
- double old_fitness = parent_genotype->GetFitness();
// Do any statistics on the parent that just gave birth...
parent_genotype->AddGestationTime( parent_phenotype.GetGestationTime() );
parent_genotype->AddFitness( parent_phenotype.GetFitness() );
@@ -903,7 +904,6 @@
// Determine which demes should be replicated.
const int num_demes = GetNumDemes();
- cRandom & random = m_world->GetRandom();
// Loop through all candidate demes...
for (int deme_id = 0; deme_id < num_demes; deme_id++) {
Modified: development/source/tools/cRandom.h
===================================================================
--- development/source/tools/cRandom.h 2007-06-19 16:53:17 UTC (rev 1695)
+++ development/source/tools/cRandom.h 2007-06-20 02:14:19 UTC (rev 1696)
@@ -25,6 +25,8 @@
#include <climits>
#include <cmath>
+#define DEBUG_CRANDOM
+
/**
* A versatile and fast pseudo random number generator.
**/
@@ -43,6 +45,10 @@
int inext;
int inextp;
int ma[56];
+
+ // Members & functions for stat functions
+ double expRV; // Exponential Random Variable for the randNormal function
+
#ifdef DEBUG_CRANDOM
long m_call_count;
#endif
@@ -50,8 +56,7 @@
// Constants ////////////////////////////////////////////////////////////////
// Statistical Approximation
static const unsigned int _BINOMIAL_TO_NORMAL; //if < n*p*(1-p)
- static const unsigned int _BINOMIAL_TO_POISSON; //if < n && !Normal approx
- // Engine
+ static const unsigned int _BINOMIAL_TO_POISSON; //if < n && !Normal approx Engine
static const unsigned int _RAND_MBIG;
static const unsigned int _RAND_MSEED;
// Number Generation
@@ -59,8 +64,6 @@
static const double _RAND_mP_FAC;
static const double _RAND_uP_FAC;
- // Members & functions for stat functions
- double expRV; // Exponential Random Variable for the randNormal function
// Internal functions
Modified: development/source/tools/tVector.h
===================================================================
--- development/source/tools/tVector.h 2007-06-19 16:53:17 UTC (rev 1695)
+++ development/source/tools/tVector.h 2007-06-20 02:14:19 UTC (rev 1696)
@@ -131,7 +131,7 @@
}
void RemoveAt(int idx) {
- int i, j;
+ int i;
if(idx >= 0 && idx < Size()) {
T *newdata = new T[Capacity()];
for(i = 0; i < idx; i++) {
More information about the Avida-cvs
mailing list