Difference between revisions of "SPEC CPU2006 benchmarks"

From gem5
Jump to: navigation, search
Line 31: Line 31:
 
For example:
 
For example:
 
     runspec --config=alpha.cfg --action=buld --tune=base bzip2
 
     runspec --config=alpha.cfg --action=buld --tune=base bzip2
 +
</pre>
 +
 +
 +
===== Expand M5 system call functions =====
 +
Four extra system call functions are needed by SPEC2006. The functions can be modified in:
 +
 +
 +
m5-stable-mt/src/arch/alpha/linux/process.cc
 +
<pre>
 +
/* 130 */ SyscallDesc("ftruncate", ftruncateFunc),
 +
/* 144 */ SyscallDesc("getrlimit",  ignoreFunc),
 +
/* 341 */ SyscallDesc("mremap", mremapFunc<AlphaLinux>),
 +
/* 367 */ SyscallDesc("getcwd", getcwdFunc),
 +
</pre>
 +
 +
m5-stable-mt/src/sim/syscall_emul.hh
 +
<pre>
 +
///Target getcwd() handler.
 +
SyscallReturn getcwdFunc(SyscallDesc *desc, int num,
 +
                              LiveProcess *p, ThreadContext *tc);
 +
 +
//A simple implementation
 +
template <class OS>
 +
SyscallReturn
 +
mremapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 +
{
 +
    Addr start = tc->getSyscallArg(0);
 +
    uint64_t length_old = tc->getSyscallArg(1);
 +
    uint64_t length_new = tc->getSyscallArg(2);
 +
 +
    if ((start  % TheISA::VMPageSize) != 0 ||
 +
        (length_new % TheISA::VMPageSize) != 0) {
 +
        warn("mremap failing: arguments not page-aligned: "
 +
            "start 0x%x length 0x%x",
 +
            start, length_new);
 +
        return -EINVAL;
 +
    }
 +
 +
    if (start != 0) {
 +
        warn("mremap: ignoring suggested map address 0x%x, using 0x%x",
 +
            start, p->mmap_end);
 +
    }
 +
 +
    // pick next address from our "mmap region"
 +
    if(length_old < length_new){
 +
      warn("mremap size  0x%x  %d -> %d",start,length_old,length_new);
 +
      start = p->mmap_end;
 +
      p->pTable->allocate(start, length_new-length_old);
 +
      p->mmap_end += (length_new-length_old);
 +
      start = tc->getSyscallArg(0);
 +
 +
    }else{
 +
      warn("mremap size  0x%x  %d -> %d",start,length_old,length_new);
 +
    }
 +
 +
    return start;
 +
}
 +
</pre>
 +
 +
 +
m5-stable-mt/src/sim/syscall_emul.cc
 +
<pre>
 +
SyscallReturn
 +
getcwdFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 +
{
 +
    char pathname[256];
 +
    int path_len = tc->getSyscallArg(1);
 +
    getcwd(pathname,path_len);
 +
    BufferArg path(tc->getSyscallArg(0), path_len);
 +
    strncpy((char *)path.bufferPtr(), pathname, path_len);
 +
 +
    path.copyOut(tc->getMemPort());
 +
 +
    return 0;
 +
}
 
</pre>
 
</pre>

Revision as of 13:02, 29 September 2008

This is a work in-progress. Everyone should feel free to extend this page with their experiences to help new users get started.


Input sets and Binaries

We can't provide the binaries or input files because of licensing restrictions, but It's not hard to build the binaries by yourself. In this short article, we will share our experiences about what we have done so far.

Build the cross-compiler for alpha machine

Download the crosstool-0.43.tar.gz from http://kegel.com/crosstool and modify these three lines in the demo-alpha.sh :

RESULT_TOP=where_you_want_to_put_the_compiler
GCC_LANGUAGES="c,c++,fortran"
eval `cat alpha.dat gcc-4.1.0-glibc-2.3.6.dat` sh all.sh --notest

Then follow the steps in the crosstool-howto page to build the cross compiler.

Build the SPEC2006 alpha binaries

Install the SPEC2006 from DVD and modify the CC, CXX, and FC in config/alpha.cfg.

For example:
    CC =  /home/mjwu/crosstool/gcc-4.1.0-glibc-2.3.6/alpha/bin/alpha-gcc
    CXX = /home/mjwu/crosstool/gcc-4.1.0-glibc-2.3.6/alpha/bin/alpha-g++
    FC =  /home/mjwu/crosstool/gcc-4.1.0-glibc-2.3.6/alpha/bin/alpha-gfortran

Then follow the instructions in the ./Docs/install-guide-unix.html to build the binaries

For example:
    runspec --config=alpha.cfg --action=buld --tune=base bzip2


Expand M5 system call functions

Four extra system call functions are needed by SPEC2006. The functions can be modified in:


m5-stable-mt/src/arch/alpha/linux/process.cc

 /* 130 */ SyscallDesc("ftruncate", ftruncateFunc),
 /* 144 */ SyscallDesc("getrlimit",  ignoreFunc),
 /* 341 */ SyscallDesc("mremap", mremapFunc<AlphaLinux>),
 /* 367 */ SyscallDesc("getcwd", getcwdFunc),

m5-stable-mt/src/sim/syscall_emul.hh

///Target getcwd() handler.
SyscallReturn getcwdFunc(SyscallDesc *desc, int num,
                               LiveProcess *p, ThreadContext *tc);

//A simple implementation
template <class OS>
SyscallReturn
mremapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
{
    Addr start = tc->getSyscallArg(0);
    uint64_t length_old = tc->getSyscallArg(1);
    uint64_t length_new = tc->getSyscallArg(2);

    if ((start  % TheISA::VMPageSize) != 0 ||
        (length_new % TheISA::VMPageSize) != 0) {
        warn("mremap failing: arguments not page-aligned: "
             "start 0x%x length 0x%x",
             start, length_new);
        return -EINVAL;
    }

    if (start != 0) {
        warn("mremap: ignoring suggested map address 0x%x, using 0x%x",
             start, p->mmap_end);
    }

    // pick next address from our "mmap region"
    if(length_old < length_new){
       warn("mremap size  0x%x  %d -> %d",start,length_old,length_new);
       start = p->mmap_end;
       p->pTable->allocate(start, length_new-length_old);
       p->mmap_end += (length_new-length_old);
       start = tc->getSyscallArg(0);

    }else{
       warn("mremap size  0x%x  %d -> %d",start,length_old,length_new);
    }

    return start;
}


m5-stable-mt/src/sim/syscall_emul.cc

SyscallReturn
getcwdFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
{
    char pathname[256];
    int path_len = tc->getSyscallArg(1);
    getcwd(pathname,path_len);
    BufferArg path(tc->getSyscallArg(0), path_len);
    strncpy((char *)path.bufferPtr(), pathname, path_len);

    path.copyOut(tc->getMemPort());

    return 0;
}