gem5: codebase patched to compile with ag++

This changes allows us to compile the gem5 simulator with ag++. It
was tested with ag++ v0.8, built Apr 18 2013. Most of the changes
are preprocessor directives like #ifndef __puma which have been
inserted into the gem5 code. Unfortunately, a python script and a
SWIG input file have been patched, too.
Additionally, the CMake file has been updated. A single call to
"make" now invokes the ag++ (instead of the g++) compiler front
end. The new CMake target "gem5-allclean" should be used to clean
the current project when building FailGem5. In addition to cleaning
the Fail build directory, it also invokes "scons -c" in the gem5
build directory; that is, gem5 is cleaned as well.

Change-Id: I20a92f025f34f626b81e30f2c873baeba189f83b
This commit is contained in:
Adrian Böckenkamp
2013-05-16 15:35:28 +02:00
parent 95892e9688
commit f92557c2c2
21 changed files with 96 additions and 17 deletions

View File

@ -15,6 +15,10 @@ if(BUILD_GEM5)
# - make gem5_build_config configurable in CMake # - make gem5_build_config configurable in CMake
# (alternative: gem5_build_config is set based on the CMake build # (alternative: gem5_build_config is set based on the CMake build
# config, e.g., "Debug" or "Release") # config, e.g., "Debug" or "Release")
# - Ideally, there is no additional "gem5-clean" target. Instead,
# calling "make clean" should also invoke a clean command in the
# gem5 root dir. This seems easy for "make only" projects--things
# get shaky due to "scons".
# Enable ExternalProject CMake module # Enable ExternalProject CMake module
include(ExternalProject) include(ExternalProject)
@ -29,10 +33,15 @@ if(BUILD_GEM5)
SOURCE_DIR ${gem5_src_dir} SOURCE_DIR ${gem5_src_dir}
BINARY_DIR ${gem5_src_dir} BINARY_DIR ${gem5_src_dir}
# Build gem5 using scons build system: # Build gem5 using scons build system:
BUILD_COMMAND scons EXTRAS=${gem5_wrapper} ${gem5_build_config} -j${core_count} BUILD_COMMAND scons "CXX=${CMAKE_CXX_COMPILER} -p ${gem5_src_dir} --Xcompiler" EXTRAS=${gem5_wrapper} ${gem5_build_config} -j${core_count}
# Disable install step (for now) # Disable install step (for now)
INSTALL_COMMAND "" INSTALL_COMMAND ""
) )
add_custom_target(gem5-allclean
COMMAND @echo "Cleaning Fail* and gem5 ..."
COMMAND cd "${PROJECT_BINARY_DIR}/" && make clean
COMMAND cd "${gem5_src_dir}/" && scons -c
)
# Build "fail" library first (will be statically linked to gem5) # Build "fail" library first (will be statically linked to gem5)
add_dependencies(FailGem5_binary_external fail) add_dependencies(FailGem5_binary_external fail)

View File

@ -488,6 +488,9 @@ if main['GCC'] + main['SUNCC'] + main['ICC'] + main['CLANG'] > 1:
print 'Error: How can we have two at the same time?' print 'Error: How can we have two at the same time?'
Exit(1) Exit(1)
main['GCC'] = True
main['GCC_VERSION'] = '4.4.5'
# Set up default C++ compiler flags # Set up default C++ compiler flags
if main['GCC']: if main['GCC']:
main.Append(CCFLAGS=['-pipe']) main.Append(CCFLAGS=['-pipe'])
@ -496,14 +499,14 @@ if main['GCC']:
# Read the GCC version to check for versions with bugs # Read the GCC version to check for versions with bugs
# Note CCVERSION doesn't work here because it is run with the CC # Note CCVERSION doesn't work here because it is run with the CC
# before we override it from the command line # before we override it from the command line
gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False) # gcc_version = readCommand([main['CXX'], '-dumpversion'], exception=False)
main['GCC_VERSION'] = gcc_version # main['GCC_VERSION'] = gcc_version
if not compareVersions(gcc_version, '4.4.1') or \ # if not compareVersions(gcc_version, '4.4.1') or \
not compareVersions(gcc_version, '4.4.2'): # not compareVersions(gcc_version, '4.4.2'):
print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.' # print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.'
main.Append(CCFLAGS=['-fno-tree-vectorize']) # main.Append(CCFLAGS=['-fno-tree-vectorize'])
if compareVersions(gcc_version, '4.6') >= 0: # if compareVersions(gcc_version, '4.6') >= 0:
main.Append(CXXFLAGS=['-std=c++0x']) # main.Append(CXXFLAGS=['-std=c++0x'])
elif main['ICC']: elif main['ICC']:
pass #Fix me... add warning flags once we clean up icc warnings pass #Fix me... add warning flags once we clean up icc warnings
elif main['SUNCC']: elif main['SUNCC']:

View File

@ -582,12 +582,23 @@ class FloatRegOperand(Operand):
func = 'setFloatRegOperandBits' func = 'setFloatRegOperandBits'
if self.write_code != None: if self.write_code != None:
return self.buildWriteCode(func) return self.buildWriteCode(func)
wb = ''' # (DanceOS hack begin...
{ if self.ctype == 'int32_t' or self.ctype == 'int16_t':
%s final_val = %s; print "Applying Fail* hack in %s@%s ... :-)" % \
xc->%s(this, %d, final_val);\n (__file__, inspect.currentframe().f_lineno)
if (traceData) { traceData->setData(final_val); } wb = '''
}''' % (self.ctype, self.base_name, func, self.dest_reg_idx) {
%s final_val = %s;
xc->%s(this, %d, final_val);\n
if (traceData) { traceData->setData((%s)final_val); }
}''' % (self.ctype, self.base_name, func, self.dest_reg_idx, "u%s" % self.ctype)
else: # ...DanceOS hack end)
wb = '''
{
%s final_val = %s;
xc->%s(this, %d, final_val);\n
if (traceData) { traceData->setData(final_val); }
}''' % (self.ctype, self.base_name, func, self.dest_reg_idx)
return wb return wb
class ControlRegOperand(Operand): class ControlRegOperand(Operand):

View File

@ -101,14 +101,18 @@ void
CompoundFlag::enable() CompoundFlag::enable()
{ {
SimpleFlag::enable(); SimpleFlag::enable();
#ifndef __puma // DanceOS (error: no matching function for call to `mem_fun')
for_each(_kids.begin(), _kids.end(), mem_fun(&Flag::enable)); for_each(_kids.begin(), _kids.end(), mem_fun(&Flag::enable));
#endif
} }
void void
CompoundFlag::disable() CompoundFlag::disable()
{ {
SimpleFlag::disable(); SimpleFlag::disable();
#ifndef __puma // DanceOS (error: no matching function for call to `mem_fun')
for_each(_kids.begin(), _kids.end(), mem_fun(&Flag::disable)); for_each(_kids.begin(), _kids.end(), mem_fun(&Flag::disable));
#endif
} }
struct AllFlags : public Flag struct AllFlags : public Flag

View File

@ -102,7 +102,10 @@ string
EthAddr::string() const EthAddr::string() const
{ {
stringstream stream; stringstream stream;
// DanceOS modification
#ifndef __puma
stream << *this; stream << *this;
#endif
return stream.str(); return stream.str();
} }

View File

@ -69,6 +69,7 @@ class Random
value = genrand() & (int8_t)-1; value = genrand() & (int8_t)-1;
} }
#ifndef __puma // DanceOS (redefinition of `_random')
void void
_random(int16_t &value) _random(int16_t &value)
{ {
@ -86,6 +87,7 @@ class Random
{ {
value = (int64_t)genrand() << 32 | (int64_t)genrand(); value = (int64_t)genrand() << 32 | (int64_t)genrand();
} }
#endif // DanceOS
void void
_random(uint8_t &value) _random(uint8_t &value)
@ -136,6 +138,7 @@ class Random
return static_cast<int8_t>(min + genrand(diff)); return static_cast<int8_t>(min + genrand(diff));
} }
#ifndef __puma // DanceOS (redefinition of `_random')
int16_t int16_t
_random(int16_t min, int16_t max) _random(int16_t min, int16_t max)
{ {
@ -156,6 +159,7 @@ class Random
uint64_t diff = max - min; uint64_t diff = max - min;
return static_cast<int64_t>(min + genrand(diff)); return static_cast<int64_t>(min + genrand(diff));
} }
#endif // DanceOS
uint8_t uint8_t
_random(uint8_t min, uint8_t max) _random(uint8_t min, uint8_t max)

View File

@ -264,7 +264,10 @@ operator-(const Time &l, const Time &r)
inline std::ostream & inline std::ostream &
operator<<(std::ostream &out, const Time &time) operator<<(std::ostream &out, const Time &time)
{ {
// DanceOS modification
#ifndef __puma
out << time.date(); out << time.date();
#endif
return out; return out;
} }

View File

@ -355,6 +355,8 @@ DefaultCommit<Impl>::setROB(ROB *rob_ptr)
rob = rob_ptr; rob = rob_ptr;
} }
#ifndef __puma // DanceOS (left operand of `->' not pointer to class object)
template <class Impl> template <class Impl>
void void
DefaultCommit<Impl>::initStage() DefaultCommit<Impl>::initStage()
@ -1342,6 +1344,8 @@ DefaultCommit<Impl>::markCompletedInsts()
} }
} }
#endif // !__puma (DanceOS)
template <class Impl> template <class Impl>
bool bool
DefaultCommit<Impl>::robDoneSquashing() DefaultCommit<Impl>::robDoneSquashing()

View File

@ -214,6 +214,8 @@ DefaultDecode<Impl>::checkStall(ThreadID tid) const
return ret_val; return ret_val;
} }
#ifndef __puma // DanceOS (left operand of `->' not pointer to class object)
template<class Impl> template<class Impl>
inline bool inline bool
DefaultDecode<Impl>::fetchInstsValid() DefaultDecode<Impl>::fetchInstsValid()
@ -759,3 +761,5 @@ DefaultDecode<Impl>::decodeInsts(ThreadID tid)
wroteToTimeBuffer = true; wroteToTimeBuffer = true;
} }
} }
#endif // !__puma (DanceOS)

View File

@ -826,6 +826,8 @@ DefaultFetch<Impl>::squash(const TheISA::PCState &newPC,
cpu->removeInstsNotInROB(tid); cpu->removeInstsNotInROB(tid);
} }
#ifndef __puma // DanceOS (left operand of `->' not pointer to class object)
template <class Impl> template <class Impl>
void void
DefaultFetch<Impl>::tick() DefaultFetch<Impl>::tick()
@ -1514,6 +1516,8 @@ DefaultFetch<Impl>::lsqCount()
return InvalidThreadID; return InvalidThreadID;
} }
#endif // !__puma (DanceOS)
template<class Impl> template<class Impl>
ThreadID ThreadID
DefaultFetch<Impl>::branchCount() DefaultFetch<Impl>::branchCount()

View File

@ -281,6 +281,8 @@ DefaultIEW<Impl>::regStats()
wbRate = writebackCount / cpu->numCycles; wbRate = writebackCount / cpu->numCycles;
} }
#ifndef __puma // DanceOS (left operand of `->' not pointer to class object)
template<class Impl> template<class Impl>
void void
DefaultIEW<Impl>::initStage() DefaultIEW<Impl>::initStage()
@ -1668,3 +1670,5 @@ DefaultIEW<Impl>::checkMisprediction(DynInstPtr &inst)
} }
} }
} }
#endif // !__puma (DanceOS)

View File

@ -1116,6 +1116,8 @@ InstructionQueue<Impl>::violation(DynInstPtr &store,
memDepUnit[store->threadNumber].violation(store, faulting_load); memDepUnit[store->threadNumber].violation(store, faulting_load);
} }
#ifndef __puma // DanceOS (left operand of `->' not pointer to class object)
template <class Impl> template <class Impl>
void void
InstructionQueue<Impl>::squash(ThreadID tid) InstructionQueue<Impl>::squash(ThreadID tid)
@ -1136,6 +1138,8 @@ InstructionQueue<Impl>::squash(ThreadID tid)
memDepUnit[tid].squash(squashedSeqNum[tid], tid); memDepUnit[tid].squash(squashedSeqNum[tid], tid);
} }
#endif // !__puma (DanceOS)
template <class Impl> template <class Impl>
void void
InstructionQueue<Impl>::doSquash(ThreadID tid) InstructionQueue<Impl>::doSquash(ThreadID tid)

View File

@ -335,6 +335,8 @@ DefaultRename<Impl>::takeOverFrom()
} }
} }
#ifndef __puma // DanceOS (left operand of `->' not pointer to class object)
template <class Impl> template <class Impl>
void void
DefaultRename<Impl>::squash(const InstSeqNum &squash_seq_num, ThreadID tid) DefaultRename<Impl>::squash(const InstSeqNum &squash_seq_num, ThreadID tid)
@ -1338,6 +1340,8 @@ DefaultRename<Impl>::checkSignalsAndUpdate(ThreadID tid)
return false; return false;
} }
#endif // !__puma (DanceOS)
template<class Impl> template<class Impl>
void void
DefaultRename<Impl>::serializeAfter(InstQueue &inst_list, ThreadID tid) DefaultRename<Impl>::serializeAfter(InstQueue &inst_list, ThreadID tid)

View File

@ -41,8 +41,9 @@ ConfigFile::ConfigFile( string filename, string delimiter,
std::ifstream in( filename.c_str() ); std::ifstream in( filename.c_str() );
if( !in ) throw file_not_found( filename ); if( !in ) throw file_not_found( filename );
#ifndef __puma
in >> (*this); in >> (*this);
#endif
} }

View File

@ -103,7 +103,9 @@ T OrionConfig::get(const string& key_) const
it = m_params_map.find(key_); it = m_params_map.find(key_);
if (it == m_params_map.end()) if (it == m_params_map.end())
{ {
#ifndef __puma // error: invalid operand to binary `<<'
std::cerr << key_ << " NOT FOUND!" << std::endl; std::cerr << key_ << " NOT FOUND!" << std::endl;
#endif
throw key_not_found(key_); throw key_not_found(key_);
} }
return string_as_T<T>(it->second); return string_as_T<T>(it->second);
@ -138,8 +140,10 @@ inline bool OrionConfig::string_as_T<bool>(const string& str_)
} }
else else
{ {
#ifndef __puma
std::cerr << "Invalid bool value: '" << str_ << std::cerr << "Invalid bool value: '" << str_ <<
"'. Treated as FALSE." << std::endl; "'. Treated as FALSE." << std::endl;
#endif
ret = false; ret = false;
} }
return ret; return ret;

View File

@ -58,7 +58,9 @@ inline void disableAllListeners() { ListenSocket::disableAll(); }
inline void inline void
seedRandom(uint64_t seed) seedRandom(uint64_t seed)
{ {
#ifndef __puma // DanceOS
random_mt.init(seed); random_mt.init(seed);
#endif
} }
%} %}

View File

@ -114,9 +114,12 @@ class InstRecord
void setData(uint16_t d) { data.as_int = d; data_status = DataInt16; } void setData(uint16_t d) { data.as_int = d; data_status = DataInt16; }
void setData(uint8_t d) { data.as_int = d; data_status = DataInt8; } void setData(uint8_t d) { data.as_int = d; data_status = DataInt8; }
// DanceOS modification
#ifndef __puma // bug #375
void setData(int64_t d) { setData((uint64_t)d); } void setData(int64_t d) { setData((uint64_t)d); }
void setData(int32_t d) { setData((uint32_t)d); } void setData(int32_t d) { setData((uint32_t)d); }
void setData(int16_t d) { setData((uint16_t)d); } void setData(int16_t d) { setData((uint16_t)d); }
#endif
void setData(int8_t d) { setData((uint8_t)d); } void setData(int8_t d) { setData((uint8_t)d); }
void setData(double d) { data.as_double = d; data_status = DataDouble; } void setData(double d) { data.as_double = d; data_status = DataDouble; }

View File

@ -198,7 +198,9 @@ Process::openInputFile(const string &filename)
if (fd == -1) { if (fd == -1) {
perror(NULL); perror(NULL);
#ifndef __puma // DanceOS (invalid operand to binary `<<')
cerr << "unable to open \"" << filename << "\" for reading\n"; cerr << "unable to open \"" << filename << "\" for reading\n";
#endif
fatal("can't open input file"); fatal("can't open input file");
} }
@ -213,7 +215,9 @@ Process::openOutputFile(const string &filename)
if (fd == -1) { if (fd == -1) {
perror(NULL); perror(NULL);
#ifndef __puma // DanceOS (invalid operand to binary `<<')
cerr << "unable to open \"" << filename << "\" for writing\n"; cerr << "unable to open \"" << filename << "\" for writing\n";
#endif
fatal("can't open output file"); fatal("can't open output file");
} }

View File

@ -796,7 +796,8 @@ cloneFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ctc->clearArchRegs(); ctc->clearArchRegs();
// Arch-specific cloning code // Arch-specific cloning code
#if THE_ISA == ALPHA_ISA or THE_ISA == X86_ISA // #if THE_ISA == ALPHA_ISA or THE_ISA == X86_ISA
#if THE_ISA == ALPHA_ISA || THE_ISA == X86_ISA // DanceOS: "or" replaced with "||"
// Cloning the misc. regs for these archs is enough // Cloning the misc. regs for these archs is enough
TheISA::copyMiscRegs(tc, ctc); TheISA::copyMiscRegs(tc, ctc);
#elif THE_ISA == SPARC_ISA #elif THE_ISA == SPARC_ISA

View File

@ -934,6 +934,7 @@ fstatfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
return -EBADF; return -EBADF;
struct statfs hostBuf; struct statfs hostBuf;
int fstatfs(int fd, struct statfs *buf); // DanceOS (added forward decl.)
int result = fstatfs(fd, &hostBuf); int result = fstatfs(fd, &hostBuf);
if (result < 0) if (result < 0)

View File

@ -72,7 +72,9 @@ class VPtr
return; return;
FSTranslatingPortProxy &proxy = tc->getVirtProxy(); FSTranslatingPortProxy &proxy = tc->getVirtProxy();
#ifndef __puma // DanceOS (no matching function for call to `readBlob')
proxy.readBlob(ptr, buffer, sizeof(T)); proxy.readBlob(ptr, buffer, sizeof(T));
#endif
} }
bool bool