Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements and fixes #1

Open
wants to merge 2 commits into
base: gottagofast
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,27 @@
import subprocess
import tempfile
from collections import defaultdict
from enum import Flag
from enum import IntFlag
from functools import partial

from elftools.elf.elffile import ELFFile
from elftools.elf.sections import SymbolTableSection
from tqdm.contrib.concurrent import process_map


class KeepLogType(Flag):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the change to IntFlag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though pt that it would be more convenient, as it also allows x & KeepLogType.STDERR if x is and int, but since we convert the arguments to KeepLogType anyways it has no real benefit.

class KeepLogType(IntFlag):
NONE = 0
STDOUT = 1
STDERR = 2
BOTH = 3
BOTH = STDOUT | STDERR


class TraceMode(IntFlag):
NONE = 0
INSTR = 1
MEM = 2
BOTH = INSTR | MEM


ETISS_CFG = """[StringConfigurations]
vp.elf_file={test_file}
Expand All @@ -33,8 +41,8 @@ class KeepLogType(Flag):
etiss.max_block_size=500

[BoolConfigurations]
simple_mem_system.print_dbus_access=true
jit.debug=true
{trace_mem_enable}simple_mem_system.print_dbus_access=true
{debug_jit_disable}jit.debug=false
jit.gcc.cleanup=true
jit.verify=false
etiss.exit_on_loop={exit_on_loop}
Expand All @@ -44,7 +52,7 @@ class KeepLogType(Flag):
plugin.filelogger.logmask=0xFFFFFFFF
plugin.filelogger.terminate_on_write=true

{trace_enable}[Plugin PrintInstruction]
{trace_instr_enable}[Plugin PrintInstruction]
"""


Expand Down Expand Up @@ -100,6 +108,8 @@ def run_test(test_args: "tuple[pathlib.Path, str, pathlib.Path]", args):
test_addrs[symbol.entry["st_value"]] = symbol.name

fname = (results_path / "config" / test_file.stem).with_suffix(".ini")
if args.debug_jit:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say this is not a problem to be solved here, LLVMJIT is rarely used anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can drop the assertion warning, but we need a way to disable the jit_debug because otherwise it wouldn’t be possible to run the tests against the LLVMJIT.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does LLVMJIT complain when this option is set? from what I see here https://github.com/tum-ei-eda/etiss/blob/b24bc484d1498d6cdc4587a4dbd246adce0e5f26/JITImpl/LLVM/src/LLVMJIT.cpp#L219 debug should be supported just fine...

assert args.jit != "llvm", "LLVMJIT does not support debug mode"
with open(fname, "w") as f:
f.write(
ETISS_CFG.format(
Expand All @@ -108,7 +118,9 @@ def run_test(test_args: "tuple[pathlib.Path, str, pathlib.Path]", args):
arch=arch,
logaddr=logaddr,
jit=args.jit.upper(),
trace_enable="" if args.trace else ";",
trace_instr_enable="" if args.trace & TraceMode.INSTR else ";",
trace_mem_enable="" if args.trace & TraceMode.MEM else ";",
debug_jit_disable="" if not args.debug_jit else ";",
exit_on_loop=str(args.exit_on_loop)
)
)
Expand Down Expand Up @@ -151,12 +163,14 @@ def main():
p.add_argument("--timeout", default=10, type=int, help="Timeout to complete a test run, exceeding the timeout marks the test as failed.")
p.add_argument("-j", "--threads", type=int, help="Number of parallel threads to start. Assume CPU core count if no value is provided.")
p.add_argument("--jit", choices=["tcc", "gcc", "llvm"], default="tcc", help="Which ETISS JIT compiler to use.")
p.add_argument("--keep-output", choices=[x.name.lower() for x in KeepLogType], default=KeepLogType.NONE.name.lower(), help="Save ETISS stdout/stderr to files")
p.add_argument("--trace", action="store_true", help="Generate an instruction trace. Helpful for debugging.")
p.add_argument("--keep-output", choices=[x.name.lower() for x in KeepLogType] + ["both"], default=KeepLogType.NONE.name.lower(), help="Save ETISS stdout/stderr to files")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest implementing this iteration with the __members__ property of enums.Flag: https://docs.python.org/3/library/enum.html#enum.EnumType.__members__

p.add_argument("--trace", choices=["none", "instr", "mem", "both"], default=TraceMode.NONE.name.lower(), help="Generate an instr/mem trace. Helpful for debugging.")
p.add_argument("--debug-jit", action="store_true", help="Enable jit.debug (gcc/tcc jit only)")
p.add_argument("--exit-on-loop", action="store_true", help="Instruct the simulator to terminate when a loop-to-self instruction sequence is detected.")

args = p.parse_args()
args.keep_output = KeepLogType[args.keep_output.upper()]
args.trace = TraceMode[args.trace.upper()]

begin = datetime.datetime.now().strftime("%y%m%d_%H%M%S")

Expand Down