Skip to content

Ariel Redirect IO

plavin edited this page Mar 31, 2022 · 16 revisions

The SPEC benchmark suite is a standard set of benchmarks used by academia and industry to evaluate processor designs. As such, we are interested in supporting it for SST.

If you examine the commands that SPEC executes, you'll see many of the benchmarks expect their input from stdin. (You can find these commands with specinvoke, as described in step 12 on this page.

However, Ariel does not support reading from standard input, but it shouldn't be hard to add it. Ariel take the executable as a parameter and forks it to begin its execution. We just need to set up the files before hand, as any student taking their first systems class would do.

Work Log

Support new args

How do we add an argument to Ariel? Let's use the apparg params for reference. We need add the param to the component interface. It seems the param should also exist in the pin3 frontend. So we'll also add the param there as well.

  • arielcpu.h - add the appstdin param
  • frontend/pin3/pin3frontend.h - add the appstdin param

We need only look at frontend/pin3/pin3frontend.{h,cc} from here on out.

pin3frontend.cc

  • Pin3Frontend::init calls forkPINChild during phase 0 of initialization. We don't want to mess with the launcher (which specifies the pin executable and the pintool. That leaves execute_args and execute_env to work with. Those parameters probably aren't a good place for our redirection stuff.

  • execute_args and execute_env are set in the constructor. We should make a new struct containing information on I/O redirects and also create it in the struct. Then, we will add it to the forkPINchild interface.

  • Pin3Frontend::forkPINChild

    • First builds a string full_execute_line. This line copies in the args from args.
    • full_execute_line is only used for debugging purposes
    • Next, fork() is called on line 333.
    • If everything goes well, the parent process returns the child pid on line 380, and the child process begins execution at 382.
    • execvp is called on 398 or execve is called on 497.
    • we should make our changes on line 383.
      • fd = creat, close(1), dup(fd), close(fd)

pin3frontend.h

The .h file needs the a struct containing redirect information. For now, it should include just the file names of the input and output files. If an input file is specified, we should check that it exists. We will create the output files if they don't exist, and overwrite the file in the case of >.

Plan

  • Add param to interface -> appstdin
  • Add struct to frontend .h file to hold redirect information -> std::string stdin_file
  • During Ariel init, put redirect info from param to struct -> line 74
  • Change interface to forkPINChild to accept struct
  • Use info in struct to redirect input
  • Test that file was opened successfully
  • Successful build after changes
  • Create simple program to test functionality
  • Clean up all the printf's starting with "Patrick"
  • Fix bug where infile is deleted and the sum is 0.
  • Do stdout
  • Do stderr
  • Support append for stdout and stderr.
  • Support for appending to stdout/stderr files

Questions / Notes

  • Where is there a copy of the interface Ariel in frontend/pin3/pin3frontend.h?

  • There is no warning/error if the command is too long (more than 16347 chars). In pin3frontend.cc:310-322. This should be fixed.

  • Calling output->fatal from the child doesn't seem to stop the simulation.

TODO

  • Add safety features for overwriting files

See Also

This feature is related to Command Parsing.