gem5 icon indicating copy to clipboard operation
gem5 copied to clipboard

util: when -re flag is passed, multisim doesn't redirect simerr and simout to the same directory as stats.txt

Open erin-le opened this issue 1 year ago • 0 comments

Note

I used the bug reporting template, but is more like something that hasn't been implemented. I am opening this issue for future reference.

Describe the issue When you run simulations with multisim and pass the -re flag to redirect standard output and standard error into text files, the files are placed directly into the m5out directory instead of being put into the directories for specific simulations within m5out.

The simout and simerr files are also named Spawn_gem5PoolWorker-[some int]_simerr.txt rather than by their ids, and the gem5 command in the simout files also does not contain the simulation id. It is therefore not possible to determine which simerr and simout files correspond to which simulations.

Affects version gem5 version 24.0, stable

gem5 Modifications None

To Reproduce Steps to reproduce the behavior. Please assume starting from a clean repository:

  1. Compile gem5 with command
scons build/ALL/gem5.opt
  1. Create a configuration script that uses multisim and run it with the following command:
build/ALL/gem5.opt -re -m gem5.utils.multisim path/to/configuration/script

Here is a configuration script that can be used:

# Copyright (c) 2021 The Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""
Copied from x86-ubuntu-run.py
"""

"""
This script utilizes the X86DemoBoard to run a simple Ubunutu boot. The script
will boot the the OS to login before exiting the simulation.

A detailed terminal output can be found in `m5out/system.pc.com_1.device`.

**Warning:** The X86DemoBoard uses the Timing CPU. The boot may take
considerable time to complete execution.
`configs/example/gem5_library/x86-ubuntu-run-with-kvm.py` can be referenced as
an example of booting Ubuntu with a KVM CPU.

Usage
-----

scons build/X86/gem5.opt ./build/X86/gem5.opt configs/example/gem5_library/x86-ubuntu-run.py

"""
import m5
from gem5.prebuilt.demo.x86_demo_board import X86DemoBoard
from gem5.resources.resource import obtain_resource
from gem5.simulate.simulator import Simulator
from gem5.simulate.exit_event import ExitEvent
import gem5.utils.multisim as multisim

x86_boot = ["x86-ubuntu-24.04-boot-no-systemd", "x86-ubuntu-24.04-boot-with-systemd"]

multisim.set_num_processes(2)

for workload in x86_boot:
    # Here we setup the board. The prebuilt X86DemoBoard allows for Full-System X86
    # simulation.
    board = X86DemoBoard()

    board.set_workload(

        obtain_resource(workload)
    )

    # We exepect that ROI ends with `workend` or `simulate() limit reached`.
    def handle_workend():
        print("Dump stats at the end of the ROI!")
    
        m5.stats.dump()
        yield False
    

    def handle_workbegin():
        print("Done booting Linux")
        print("Resetting stats at the start of ROI!")
    
        m5.stats.reset()

        yield False
    
    def exit_event_handler():
        print("first exit event: Kernel booted")
        yield False
        print("second exit event: In after boot")
        yield False
        print("third exit event: After run script")
        yield False
        yield True


    id=workload.replace(".", "-")
    multisim.add_simulator(
        Simulator(
        board=board,
        on_exit_event={
            ExitEvent.WORKBEGIN: handle_workbegin(),
            ExitEvent.WORKEND: handle_workend(),
            ExitEvent.EXIT: exit_event_handler()
        },
        )
    )

Output

When you open the m5out directory, there should be a number of simerr and simout files that have names that start with "Spawn_gem5PoolWorker-".

Expected behavior

For the simerr.txt and simout.txt for a particular simulation to be outputted to the same directory as stats.txt.

Host Operating System Ubuntu 22.04

Host ISA ARM

Compiler used c++17

erin-le avatar Aug 09 '24 23:08 erin-le