gem5-users@gem5.org

The gem5 Users mailing list

View all threads

Using m5_switchcpu in SE mode

T
Tod
Wed, Jan 11, 2017 6:14 AM

Hello,

I am using SE mode and I want to make some kind of fast-forwarding to my ROI.

My aim is to use atomic cpu model in the beginning and right before my ROI switch the cpu to detailed and then back to atomic after the ROI.

Inside m5op.h, the declaration of switch cpu command is as following:

void m5_switchcpu(void);

How can I specify cpu types while using this m5op from within my benchmark?

OR

What is the right way to do it?

Best Regards,

Tod-

JL
Jason Lowe-Power
Sun, Jan 15, 2017 8:24 PM

Hi Tod,

This is a good question, and it isn't documented anywhere very clearly.

The main way to support switching CPUs, is to use the Python config files.
At a high-level your config file should look something like this:

<Create the system> m5.simulate() <switch cpus> m5.simulate()

First, you create your system as normal, but you create two pairs of CPUs
the atomic CPU and the CPU you want to use for detailed simulation. When
creating the CPU for detailed simulation you need to mark it as
"switched_out".

Next, you start running the simulation (m5.simulate() in the Python config
file). At some point, you should exit the simulation. There are a number of
ways to do this and the m5_switchcpu magic instruction is one of them. You
can also exit based on some ROI number, if your application uses the gem5
magic instructions for ROI. Or, you can even exit by hitting ctrl-C.

When the simulation exits, you can figure out the "reason" for the exit
with "exit_event.getCause()". If this is the reason you expect (e.g., the
ROI number has been hit), then you can call the switch CPU function in your
Python config file (m5.switchCpus()).

Once the CPUs have been switched, you can restart the simulation by calling
m5.simulate() again.

By controlling all of this in Python, you have a lot of flexibility in what
you can do. In fact, you can even have more than 2 CPU types if you want.
For instance, my sampling library uses 3 types of CPUs, KVM for
fast-forwarding, atomic to warm up the caches, and detailed for running the
detailed simulation.

You can see examples of how to use all these function in my sampling code
on github:
https://github.com/powerjg/gem5/blob/devel/simplefs/configs/myconfigs/system/system.py.
This should be pretty well documented and give you a good idea of how to
flexibly use the features.

Cheers,
Jason

On Sat, Jan 14, 2017 at 5:21 AM Tod <sarilian(a)hanmail.net> wrote:

Hello,

I am using SE mode and I want to make some kind of fast-forwarding to my
ROI.

My aim is to use atomic cpu model in the beginning and right before my ROI
switch the cpu to detailed and then back to atomic after the ROI.

Inside m5op.h, the declaration of switch cpu command is as following:

void m5_switchcpu(void);

How can I specify cpu types while using this m5op from within my benchmark?

OR

What is the right way to do it?

Best Regards,

Tod-


gem5-users mailing list
gem5-users(a)gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

--

Jason

Hi Tod, This is a good question, and it isn't documented anywhere very clearly. The main way to support switching CPUs, is to use the Python config files. At a high-level your config file should look something like this: <Create the system> m5.simulate() <switch cpus> m5.simulate() First, you create your system as normal, but you create two pairs of CPUs the atomic CPU and the CPU you want to use for detailed simulation. When creating the CPU for detailed simulation you need to mark it as "switched_out". Next, you start running the simulation (m5.simulate() in the Python config file). At some point, you should exit the simulation. There are a number of ways to do this and the m5_switchcpu magic instruction is one of them. You can also exit based on some ROI number, if your application uses the gem5 magic instructions for ROI. Or, you can even exit by hitting ctrl-C. When the simulation exits, you can figure out the "reason" for the exit with "exit_event.getCause()". If this is the reason you expect (e.g., the ROI number has been hit), then you can call the switch CPU function in your Python config file (m5.switchCpus()). Once the CPUs have been switched, you can restart the simulation by calling m5.simulate() again. By controlling all of this in Python, you have a lot of flexibility in what you can do. In fact, you can even have more than 2 CPU types if you want. For instance, my sampling library uses 3 types of CPUs, KVM for fast-forwarding, atomic to warm up the caches, and detailed for running the detailed simulation. You can see examples of how to use all these function in my sampling code on github: https://github.com/powerjg/gem5/blob/devel/simplefs/configs/myconfigs/system/system.py. This should be pretty well documented and give you a good idea of how to flexibly use the features. Cheers, Jason On Sat, Jan 14, 2017 at 5:21 AM Tod <sarilian(a)hanmail.net> wrote: > Hello, > > > I am using SE mode and I want to make some kind of fast-forwarding to my > ROI. > > My aim is to use atomic cpu model in the beginning and right before my ROI > switch the cpu to detailed and then back to atomic after the ROI. > > > Inside m5op.h, the declaration of switch cpu command is as following: > > > *void m5_switchcpu(void);* > > How can I specify cpu types while using this m5op from within my benchmark? > > OR > > What is the right way to do it? > > > Best Regards, > > Tod- > _______________________________________________ > gem5-users mailing list > gem5-users(a)gem5.org > http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users -- Jason