Skip to content

Commit

Permalink
Added firesim install script. not fully tested yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Pemberton committed Dec 21, 2018
1 parent 6fac494 commit 6dc0021
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ firesim-software
This builds base images for several linux-based distros that work with qemu,
spike, and firesim.

## How to use:
# How to use:
All builds are controlled through json files. For example, br-disk.json will
build/run the disk-based buildroot distro.

Expand All @@ -28,6 +28,13 @@ Tl;Dr: images built with build.py will work on firesim, you just need to update
the symlinks in workloads/deploy/ and then run them as normal. This will be
intergrated more completely in future releases.

## Requirements
This project was written for python 3.4

python-requirements.txt and centos-requirements.txt are incomplete lists of
required packages for python3. If you find that you need a package not in those
lists, please file an issue.

# Gotcha's and potentially unintuitive behavior
## Incremental Builds
It can be very frustrating to accidentally rebuild a complex workload from
Expand All @@ -42,3 +49,4 @@ This means that you can still *lose changes to files that were specified in
your overlay of file list* if you rebuild the workload. You should also strive
to make your guest-init script as idempotent as possible (to avoid long delays
or destroying state on rebuild).

3 changes: 3 additions & 0 deletions centos-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python34
python34-devel

2 changes: 2 additions & 0 deletions python-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
psutil

7 changes: 7 additions & 0 deletions sw_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def main():
'clean', help="Removes build outputs of the provided config (img and bin). Does not affect logs or runOutputs.")
clean_parser.add_argument('config_files', metavar="config", nargs='+', help="Configuration file(s) to use.")

# Install Command
install_parser = subparsers.add_parser(
'install', help="Install this workload to firesim (create configs in firesim/deploy/workloads)")
install_parser.add_argument('config_files', metavar="config", nargs='+', help="Configuration file(s) to use.")

args = parser.parse_args()

# Load all the configs from the workload directory
Expand Down Expand Up @@ -125,6 +130,8 @@ def main():
deleteSafe(jCfg['bin'] + '-initramfs')
if 'img' in jCfg:
deleteSafe(jCfg['img'])
elif args.command == 'install':
wlutil.installWorkload(cfgPath, cfgs)
else:
log.error("No subcommand specified")
sys.exit(1)
Expand Down
1 change: 1 addition & 0 deletions wlutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
from .build import buildWorkload
from .launch import launchWorkload
from .test import testWorkload,testResult
from .install import installWorkload
from .config import ConfigManager
44 changes: 44 additions & 0 deletions wlutil/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
""" Install firesim-software stuff into firesim """

import json
from pathlib import Path
from .wlutil import *

# firesim workloads directory
fsWork = (Path(root_dir) / "../../deploy/workloads").resolve()

readmeTxt="""This workload was generated using firesim-software. See the following config
and workload directory for details:
"""

def installWorkload(cfgName, cfgs):
targetCfg = cfgs[cfgName]
if 'jobs' in targetCfg:
raise NotImplementedError("Jobs not currently supported by the install command")
if targetCfg['initramfs'] == True:
raise NotImplementedError("Initramfs-based builds not currently supported by the install command")

fsTargetDir = fsWork / targetCfg['name']

# Firesim config
fsCfg = {
"benchmark_name" : targetCfg['name'],
"common_bootbinary" : os.path.relpath(targetCfg['bin'], start=str(fsTargetDir)),
"common_rootfs" : os.path.relpath(targetCfg['img'], start=str(fsTargetDir)),
"common_simulation_outputs" : ["uartlog"],
}
if 'outputs' in targetCfg:
fsCfg["common_outputs"] = targetCfg['outputs']
if 'post_run_hook' in targetCfg:
fsCfg["post_run_hook"] = os.path.relpath(targetCfg['post_run_hook'], start=str(fsTargetDir))

if not fsTargetDir.exists():
fsTargetDir.mkdir()

with open(str(fsTargetDir / "README"), 'w') as readme:
readme.write(readmeTxt)
readme.write(os.path.relpath(targetCfg['cfg-file'], start=str(fsTargetDir)) + "\n")
readme.write(os.path.relpath(targetCfg['workdir'], start=str(fsTargetDir)) + "\n")

with open(str(fsWork / (targetCfg['name'] + '.json')), 'w') as fsCfgFile:
json.dump(fsCfg, fsCfgFile, indent='\t')

0 comments on commit 6dc0021

Please sign in to comment.