slothy-optimizer / slothy

Assembly super-optimization via constraint solving
https://slothy-optimizer.github.io/slothy/
Other
167 stars 10 forks source link

Problem with SW pipelining + splitting heuristic #94

Open dop-amin opened 1 month ago

dop-amin commented 1 month ago

If we run the splitting heuristic on a loop with SW pipelining enabled, the subsequent optimization of the preamble fails.

INFO:fnt_257_dilithium_m7:Optimizing loop _fnt_3_4_5_6 (292 instructions) ...
INFO:fnt_257_dilithium_m7._fnt_3_4_5_6.slothy:Objective: minimize cycles
INFO:fnt_257_dilithium_m7._fnt_3_4_5_6.slothy:Invoking external constraint solver (OR-Tools CP-SAT v9.7.2996) ...
INFO:fnt_257_dilithium_m7._fnt_3_4_5_6.slothy:[11.7401s]: Found 1 solutions so far... objective (minimize cycles): currently 0.0, bound 0.0
INFO:fnt_257_dilithium_m7._fnt_3_4_5_6.slothy:Closer than 1 stalls to theoretical optimum... stop
INFO:fnt_257_dilithium_m7._fnt_3_4_5_6.slothy:OPTIMAL, wall time: 11.774099 s
INFO:fnt_257_dilithium_m7._fnt_3_4_5_6.slothy:Booleans in result: 418
INFO:fnt_257_dilithium_m7._fnt_3_4_5_6.slothy.selfcheck:OK!
Traceback (most recent call last):
  File "/Users/amin/git/public/pqmx/slothy/example.py", line 2445, in <module>
    main()
  File "/Users/amin/git/public/pqmx/slothy/example.py", line 2439, in main
    run_example(e, debug=args.debug, dry_run=args.dry_run,
  File "/Users/amin/git/public/pqmx/slothy/example.py", line 2435, in run_example
    ex.run(**kwargs)
  File "/Users/amin/git/public/pqmx/slothy/example.py", line 163, in run
    self.core(slothy, *self.extra_args)
  File "/Users/amin/git/public/pqmx/slothy/example.py", line 1638, in core
    slothy.optimize_loop("_fnt_3_4_5_6")
  File "/Users/amin/git/public/pqmx/slothy/slothy/core/slothy.py", line 418, in optimize_loop
    Heuristics.periodic(body, logger, c)
  File "/Users/amin/git/public/pqmx/slothy/slothy/core/heuristics.py", line 360, in periodic
    preamble = res_preamble.code
AttributeError: 'list' object has no attribute 'code'

Likely a bug in _split_inner because it's not returning a result object when the body is empty.