Lots of people want to bind processes to cores, so I added code to the m5 binary to do that.
Nate On Wed, Dec 3, 2008 at 5:14 PM, Nathan Binkert <[EMAIL PROTECTED]> wrote: > changeset 8ef4ad572a6b in /z/repo/m5 > details: http://repo.m5sim.org/m5?cmd=changeset;node=8ef4ad572a6b > description: > util/m5: Add a new function called pin to bind a program to a set of > cores. > This is not m5 specific and this currently only works in linux. > > diffstat: > > 1 file changed, 2 insertions(+) > util/m5/m5.c | 2 ++ > > diffs (57 lines): > > diff -r b50a557f93df -r 8ef4ad572a6b util/m5/m5.c > --- a/util/m5/m5.c Wed Dec 03 04:57:53 2008 -0800 > +++ b/util/m5/m5.c Wed Dec 03 04:57:54 2008 -0800 > @@ -27,6 +27,11 @@ > * > * Authors: Nathan Binkert > */ > + > +#ifdef linux > +#define _GNU_SOURCE > +#include <sched.h> > +#endif > > #include <inttypes.h> > #include <err.h> > @@ -168,6 +173,31 @@ > (param >> 12) & 0xfff, (param >> 0) & 0xfff); > } > > +#ifdef linux > +void > +do_pin(int argc, char *argv[]) > +{ > + if (argc < 2) > + usage(); > + > + cpu_set_t mask; > + CPU_ZERO(&mask); > + > + const char *sep = ","; > + char *target = strtok(argv[0], sep); > + while (target) { > + CPU_SET(atoi(target), &mask); > + target = strtok(NULL, sep); > + } > + > + if (sched_setaffinity(0, sizeof(cpu_set_t), &mask) < 0) > + err(1, "setaffinity"); > + > + execvp(argv[1], &argv[1]); > + err(1, "execvp failed!"); > +} > +#endif > + > struct MainFunc > { > char *name; > @@ -186,6 +216,9 @@ > { "loadsymbol", do_load_symbol, "<address> <symbol>" }, > { "initparam", do_initparam, "" }, > { "sw99param", do_sw99param, "" }, > +#ifdef linux > + { "pin", do_pin, "<cpu> <program> [args ...]" } > +#endif > }; > int numfuncs = sizeof(mainfuncs) / sizeof(mainfuncs[0]); > > _______________________________________________ > m5-dev mailing list > m5-dev@m5sim.org > http://m5sim.org/mailman/listinfo/m5-dev > > _______________________________________________ m5-dev mailing list m5-dev@m5sim.org http://m5sim.org/mailman/listinfo/m5-dev