Skip to content

Commit

Permalink
Add NO_LOG option to SLOTHY scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hanno-becker committed Mar 15, 2024
1 parent bef2aaf commit 51f3fde
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 9 deletions.
3 changes: 3 additions & 0 deletions paper/scripts/slothy_dilithium_ntt_a55.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ LOG_DIR=logs
mkdir -p $LOG_DIR

REDIRECT_OUTPUT="--log --logdir=${LOG_DIR}"
if [ "$NO_LOG" = "Y" ]; then
REDIRECT_OUTPUT=""
fi
if [ "$SILENT" = "Y" ]; then
REDIRECT_OUTPUT="${REDIRECT_OUTPUT} --silent"
fi
Expand Down
3 changes: 3 additions & 0 deletions paper/scripts/slothy_dilithium_ntt_a72.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ LOG_DIR=logs
mkdir -p $LOG_DIR

REDIRECT_OUTPUT="--log --logdir=${LOG_DIR}"
if [ "$NO_LOG" = "Y" ]; then
REDIRECT_OUTPUT=""
fi
if [ "$SILENT" = "Y" ]; then
REDIRECT_OUTPUT="${REDIRECT_OUTPUT} --silent"
fi
Expand Down
3 changes: 3 additions & 0 deletions paper/scripts/slothy_fft.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ LOG_DIR=logs
mkdir -p $LOG_DIR

REDIRECT_OUTPUT="--log --logdir=${LOG_DIR}"
if [ "$NO_LOG" = "Y" ]; then
REDIRECT_OUTPUT=""
fi
if [ "$SILENT" = "Y" ]; then
REDIRECT_OUTPUT="${REDIRECT_OUTPUT} --silent"
fi
Expand Down
4 changes: 4 additions & 0 deletions paper/scripts/slothy_kyber_ntt_a55.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ LOG_DIR=logs
mkdir -p $LOG_DIR

REDIRECT_OUTPUT="--log --logdir=${LOG_DIR}"
if [ "$NO_LOG" = "Y" ]; then
REDIRECT_OUTPUT=""
fi

if [ "$SILENT" = "Y" ]; then
REDIRECT_OUTPUT="${REDIRECT_OUTPUT} --silent"
fi
Expand Down
3 changes: 3 additions & 0 deletions paper/scripts/slothy_kyber_ntt_a72.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ LOG_DIR=logs
mkdir -p $LOG_DIR

REDIRECT_OUTPUT="--log --logdir=${LOG_DIR}"
if [ "$NO_LOG" = "Y" ]; then
REDIRECT_OUTPUT=""
fi
if [ "$SILENT" = "Y" ]; then
REDIRECT_OUTPUT="${REDIRECT_OUTPUT} --silent"
fi
Expand Down
21 changes: 12 additions & 9 deletions paper/scripts/slothy_ntt_helium.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, infile, name=None, funcname=None, suffix="opt",
def core(self, slothy):
slothy.optimize()

def run(self, silent=False):
def run(self, silent=False, no_log=False):
logdir = "logs"

handlers = []
Expand All @@ -80,13 +80,14 @@ def run(self, silent=False):
h_info.addFilter(lambda r: r.levelno == logging.INFO)
handlers.append(h_info)

# By default, use time stamp and input file
file_base = os.path.basename(self.outfile_full).replace('.','_')
logfile = f"slothy_log_{int(time.time())}_{file_base}.log"
logfile = f"{logdir}/{logfile}"
h_log = logging.FileHandler(logfile)
h_log.setLevel(logging.DEBUG)
handlers.append(h_log)
if no_log is False:
# By default, use time stamp and input file
file_base = os.path.basename(self.outfile_full).replace('.','_')
logfile = f"slothy_log_{int(time.time())}_{file_base}.log"
logfile = f"{logdir}/{logfile}"
h_log = logging.FileHandler(logfile)
h_log.setLevel(logging.DEBUG)
handlers.append(h_log)

logging.basicConfig(
level = logging.INFO,
Expand Down Expand Up @@ -281,6 +282,8 @@ def main():
help=f"The list of examples to be run, comma-separated list from {all_example_names}."
)
parser.add_argument("--iterations", type=int, default=1)
parser.add_argument("--no-log", default=False, action='store_true',
help="Don't store logfiles")
parser.add_argument("--silent", default=False, action='store_true',
help="""Silent mode: Only print warnings and errors""")

Expand All @@ -299,7 +302,7 @@ def run_example(name, silent=False):
break
if ex == None:
raise Exception(f"Could not find example {name} (known: {list(e.name for e in examples)}")
ex.run(silent=silent)
ex.run(silent=silent, no_log=args.no_log)

for e in todo:
for _ in range(iterations):
Expand Down
3 changes: 3 additions & 0 deletions paper/scripts/slothy_ntt_helium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ ARGS=""
if [ "$SILENT" = "Y" ]; then
ARGS="$ARGS --silent"
fi
if [ "$NO_LOG" = "Y" ]; then
ARGS="$ARGS --no-log"
fi

export PYTHONPATH=../../

Expand Down
3 changes: 3 additions & 0 deletions paper/scripts/slothy_sqmag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ LOG_DIR=logs
mkdir -p $LOG_DIR

REDIRECT_OUTPUT="--log --logdir=${LOG_DIR}"
if [ "$NO_LOG" = "Y" ]; then
REDIRECT_OUTPUT=""
fi
if [ "$SILENT" = "Y" ]; then
REDIRECT_OUTPUT="${REDIRECT_OUTPUT} --silent"
fi
Expand Down
3 changes: 3 additions & 0 deletions paper/scripts/slothy_x25519.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ LOG_DIR=logs
mkdir -p $LOG_DIR

REDIRECT_OUTPUT="--log --logdir=${LOG_DIR}"
if [ "$NO_LOG" = "Y" ]; then
REDIRECT_OUTPUT=""
fi
if [ "$SILENT" = "Y" ]; then
REDIRECT_OUTPUT="${REDIRECT_OUTPUT} --silent"
fi
Expand Down

0 comments on commit 51f3fde

Please sign in to comment.