gem5-users@gem5.org

The gem5 Users mailing list

View all threads

m5.switchCpus for ARM starter_fs.py config

TH
Tran, Huy Dinh
Thu, Nov 2, 2023 8:33 PM

Hi gem5 team,

I'm currently using QPointshttps://github.com/bgodala/QPoints/ which helps create checkpoints for QEMU and these checkpoints can be later used for simulation in gem5. QPoints uses the starter_fs.py script from configs/example/arm/starter_fs.py which doesn't use stdlib and very old way of setting up the system for gem5. QPoints also uses a gem5 version that was 2 years ago. There has been a great amount of modifications to gem5 to make it compatible with QEMU checkpoints.

My task is to implement switching CPUs for this starter_fs.py script which I'm facing a lot of issues. I tried using the SimpleSwitchableProcessor() but I don't know how to connect that processor to the system. I also tried to use m5.switchCpus() and faced an error shown here:

build/ARM/sim/simulate.cc:107: info: Entering event queue @ 9943912964000.  Starting simulation...
switching cpus
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "build/ARM/python/m5/main.py", line 455, in main
File "/qpoints/gem5/configs/example/arm/my_fs.py", line 309, in <module>
main()
File "/qpoints/gem5/configs/example/arm/my_fs.py", line 297, in main
m5.switchCpus(root.system, switch_cpu_list)
File "build/ARM/python/m5/simulate.py", line 280, in switchCpus
File "build/ARM/python/m5/SimObject.py", line 1416, in getattr
AttributeError: object 'TimingSimpleCPU' has no attribute 'switchedOut'
(C++ object is not yet constructed, so wrapped C++ methods are unavailable.)

Here is my code for implementing m5.switchCpus:

switch_cpus = O3CPU(switched_out=True)
switch_cpus_1 = TimingSimpleCPU(switched_out=False)
switch_cpus.system = root.system
switch_cpus_1.system = root.system
switch_cpus.clk_domain = root.system.clk_domain
switch_cpus_1.clk_domain = root.system.clk_domain
switch_cpus.voltage_domain = root.system.voltage_domain
switch_cpus_1.voltage_domain = root.system.voltage_domain

while True:
    exit_event = m5.simulate(100000000)
    exit_cause = exit_event.getCause()

   switch_cpu_list = [(switch_cpus, switch_cpus_1) ]
   m5.switchCpus(root.system, switch_cpu_list)
exit_event = m5.simulate(100000000)
exit_cause = exit_event.getCause()
break
print(exit_event.getCause())

This old version of gem5 doesn't have stdlib for ArmBoard so implementing it in the simple modern way is not possible. Plus, the author of QPoints made a great effort to modify gem5 and the script to work with QEMU checkpoints so I feel like I have to use the modified starter_fs.py script that was provided.

Any guidance would be greatly appreciated!

Thanks,
Huy

Hi gem5 team, I'm currently using QPoints<https://github.com/bgodala/QPoints/> which helps create checkpoints for QEMU and these checkpoints can be later used for simulation in gem5. QPoints uses the starter_fs.py script from configs/example/arm/starter_fs.py which doesn't use stdlib and very old way of setting up the system for gem5. QPoints also uses a gem5 version that was 2 years ago. There has been a great amount of modifications to gem5 to make it compatible with QEMU checkpoints. My task is to implement switching CPUs for this starter_fs.py script which I'm facing a lot of issues. I tried using the SimpleSwitchableProcessor() but I don't know how to connect that processor to the system. I also tried to use m5.switchCpus() and faced an error shown here: build/ARM/sim/simulate.cc:107: info: Entering event queue @ 9943912964000. Starting simulation... switching cpus Traceback (most recent call last): File "<string>", line 1, in <module> File "build/ARM/python/m5/main.py", line 455, in main File "/qpoints/gem5/configs/example/arm/my_fs.py", line 309, in <module> main() File "/qpoints/gem5/configs/example/arm/my_fs.py", line 297, in main m5.switchCpus(root.system, switch_cpu_list) File "build/ARM/python/m5/simulate.py", line 280, in switchCpus File "build/ARM/python/m5/SimObject.py", line 1416, in __getattr__ AttributeError: object 'TimingSimpleCPU' has no attribute 'switchedOut' (C++ object is not yet constructed, so wrapped C++ methods are unavailable.) Here is my code for implementing m5.switchCpus: switch_cpus = O3CPU(switched_out=True) switch_cpus_1 = TimingSimpleCPU(switched_out=False) switch_cpus.system = root.system switch_cpus_1.system = root.system switch_cpus.clk_domain = root.system.clk_domain switch_cpus_1.clk_domain = root.system.clk_domain switch_cpus.voltage_domain = root.system.voltage_domain switch_cpus_1.voltage_domain = root.system.voltage_domain while True: exit_event = m5.simulate(100000000) exit_cause = exit_event.getCause()    switch_cpu_list = [(switch_cpus, switch_cpus_1) ]    m5.switchCpus(root.system, switch_cpu_list) exit_event = m5.simulate(100000000) exit_cause = exit_event.getCause() break print(exit_event.getCause()) This old version of gem5 doesn't have stdlib for ArmBoard so implementing it in the simple modern way is not possible. Plus, the author of QPoints made a great effort to modify gem5 and the script to work with QEMU checkpoints so I feel like I have to use the modified starter_fs.py script that was provided. Any guidance would be greatly appreciated! Thanks, Huy
B
bbruce@ucdavis.edu
Mon, Nov 13, 2023 1:29 PM

What i dont understand here is why do you need cpu switching for starter_fs.py. Couldn't you juse use starter_fs.py to get the checkpoints you need then load these checkopoints into a simulation which uses the stdlib?


They'll be no easy way of introducing stdlib code like SimpleSwitchableProcessor into the stdlib. I'd say generally you either use the stdlib or use the starter_fs.py script.


I’d advise looking at the source-code for SimpleSwitchableProcessor which should contain Python code to help you understsand how to setup a system with switchable cores. 

What i dont understand here is why do you need cpu switching for starter_fs.py. Couldn't you juse use starter_fs.py to get the checkpoints you need then load these checkopoints into a simulation which uses the stdlib? \ They'll be no easy way of introducing stdlib code like SimpleSwitchableProcessor into the stdlib. I'd say generally you either use the stdlib or use the starter_fs.py script. \ I’d advise looking at the source-code for SimpleSwitchableProcessor which should contain Python code to help you understsand how to setup a system with switchable cores. 
GT
Giacomo Travaglini
Mon, Nov 13, 2023 1:38 PM

Hi,

Did you call m5.instantiate before calling m5.simulate? (I don’t see it from the code snippet you posted)
Kind Regards

Giacomo

From: Tran, Huy Dinh via gem5-users gem5-users@gem5.org
Date: Thursday, 2 November 2023 at 20:33
To: gem5-users@gem5.org gem5-users@gem5.org
Cc: Tran, Huy Dinh huydinhtran@ku.edu
Subject: [gem5-users] m5.switchCpus for ARM starter_fs.py config
Hi gem5 team,

I'm currently using QPointshttps://github.com/bgodala/QPoints/ which helps create checkpoints for QEMU and these checkpoints can be later used for simulation in gem5. QPoints uses the starter_fs.py script from configs/example/arm/starter_fs.py which doesn't use stdlib and very old way of setting up the system for gem5. QPoints also uses a gem5 version that was 2 years ago. There has been a great amount of modifications to gem5 to make it compatible with QEMU checkpoints.

My task is to implement switching CPUs for this starter_fs.py script which I'm facing a lot of issues. I tried using the SimpleSwitchableProcessor() but I don't know how to connect that processor to the system. I also tried to use m5.switchCpus() and faced an error shown here:

build/ARM/sim/simulate.cc:107: info: Entering event queue @ 9943912964000.  Starting simulation...
switching cpus
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "build/ARM/python/m5/main.py", line 455, in main
File "/qpoints/gem5/configs/example/arm/my_fs.py", line 309, in <module>
main()
File "/qpoints/gem5/configs/example/arm/my_fs.py", line 297, in main
m5.switchCpus(root.system, switch_cpu_list)
File "build/ARM/python/m5/simulate.py", line 280, in switchCpus
File "build/ARM/python/m5/SimObject.py", line 1416, in getattr
AttributeError: object 'TimingSimpleCPU' has no attribute 'switchedOut'
(C++ object is not yet constructed, so wrapped C++ methods are unavailable.)

Here is my code for implementing m5.switchCpus:

switch_cpus = O3CPU(switched_out=True)
switch_cpus_1 = TimingSimpleCPU(switched_out=False)
switch_cpus.system = root.system
switch_cpus_1.system = root.system
switch_cpus.clk_domain = root.system.clk_domain
switch_cpus_1.clk_domain = root.system.clk_domain
switch_cpus.voltage_domain = root.system.voltage_domain
switch_cpus_1.voltage_domain = root.system.voltage_domain

while True:
    exit_event = m5.simulate(100000000)
    exit_cause = exit_event.getCause()

   switch_cpu_list = [(switch_cpus, switch_cpus_1) ]
   m5.switchCpus(root.system, switch_cpu_list)
exit_event = m5.simulate(100000000)
exit_cause = exit_event.getCause()
break
print(exit_event.getCause())

This old version of gem5 doesn't have stdlib for ArmBoard so implementing it in the simple modern way is not possible. Plus, the author of QPoints made a great effort to modify gem5 and the script to work with QEMU checkpoints so I feel like I have to use the modified starter_fs.py script that was provided.

Any guidance would be greatly appreciated!

Thanks,
Huy

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Hi, Did you call m5.instantiate before calling m5.simulate? (I don’t see it from the code snippet you posted) Kind Regards Giacomo From: Tran, Huy Dinh via gem5-users <gem5-users@gem5.org> Date: Thursday, 2 November 2023 at 20:33 To: gem5-users@gem5.org <gem5-users@gem5.org> Cc: Tran, Huy Dinh <huydinhtran@ku.edu> Subject: [gem5-users] m5.switchCpus for ARM starter_fs.py config Hi gem5 team, I'm currently using QPoints<https://github.com/bgodala/QPoints/> which helps create checkpoints for QEMU and these checkpoints can be later used for simulation in gem5. QPoints uses the starter_fs.py script from configs/example/arm/starter_fs.py which doesn't use stdlib and very old way of setting up the system for gem5. QPoints also uses a gem5 version that was 2 years ago. There has been a great amount of modifications to gem5 to make it compatible with QEMU checkpoints. My task is to implement switching CPUs for this starter_fs.py script which I'm facing a lot of issues. I tried using the SimpleSwitchableProcessor() but I don't know how to connect that processor to the system. I also tried to use m5.switchCpus() and faced an error shown here: build/ARM/sim/simulate.cc:107: info: Entering event queue @ 9943912964000. Starting simulation... switching cpus Traceback (most recent call last): File "<string>", line 1, in <module> File "build/ARM/python/m5/main.py", line 455, in main File "/qpoints/gem5/configs/example/arm/my_fs.py", line 309, in <module> main() File "/qpoints/gem5/configs/example/arm/my_fs.py", line 297, in main m5.switchCpus(root.system, switch_cpu_list) File "build/ARM/python/m5/simulate.py", line 280, in switchCpus File "build/ARM/python/m5/SimObject.py", line 1416, in __getattr__ AttributeError: object 'TimingSimpleCPU' has no attribute 'switchedOut' (C++ object is not yet constructed, so wrapped C++ methods are unavailable.) Here is my code for implementing m5.switchCpus: switch_cpus = O3CPU(switched_out=True) switch_cpus_1 = TimingSimpleCPU(switched_out=False) switch_cpus.system = root.system switch_cpus_1.system = root.system switch_cpus.clk_domain = root.system.clk_domain switch_cpus_1.clk_domain = root.system.clk_domain switch_cpus.voltage_domain = root.system.voltage_domain switch_cpus_1.voltage_domain = root.system.voltage_domain while True: exit_event = m5.simulate(100000000) exit_cause = exit_event.getCause()    switch_cpu_list = [(switch_cpus, switch_cpus_1) ]    m5.switchCpus(root.system, switch_cpu_list) exit_event = m5.simulate(100000000) exit_cause = exit_event.getCause() break print(exit_event.getCause()) This old version of gem5 doesn't have stdlib for ArmBoard so implementing it in the simple modern way is not possible. Plus, the author of QPoints made a great effort to modify gem5 and the script to work with QEMU checkpoints so I feel like I have to use the modified starter_fs.py script that was provided. Any guidance would be greatly appreciated! Thanks, Huy IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.