Skip to content

Commit

Permalink
Modify Kyber NTT example
Browse files Browse the repository at this point in the history
  • Loading branch information
dop-amin committed Oct 2, 2024
1 parent 0e5001e commit c518581
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,30 +202,34 @@ def __init__(self, var="", arch=Arch_Armv7M, target=Target_CortexM7, timeout=Non

def core(self, slothy):
slothy.config.inputs_are_outputs = True
# slothy.config.constraints.allow_reordering = False
# slothy.config.constraints.allow_renaming = False
# slothy.config.constraints.functional_only = True
slothy.config.variable_size = True
# slothy.config.constraints.stalls_first_attempt = 4
# slothy.config.constraints.stalls_minimum_attempt = 4

slothy.config.outputs = ["flags", "hint_spEga0", "hint_spEge0", "hint_spEgi0", "hint_spEgo0", "hint_spEgu0", "hint_spEka1", "hint_spEke1", "hint_spEki1", "hint_spEko1", "hint_spEku1", "hint_spEma0", "hint_spEme0", "hint_spEmi0", "hint_spEmo0", "hint_spEmu0", "hint_spEsa1", "hint_spEse1", "hint_spEsi1", "hint_spEso1", "hint_spEsu1", "hint_spEbe0", "hint_spEbi0", "hint_spEbo0", "hint_spEbu0", "hint_spEba0", "hint_spEga1", "hint_spEge1", "hint_spEgi1", "hint_spEgo1", "hint_spEgu1", "hint_spEka0", "hint_spEke0", "hint_spEki0", "hint_spEko0", "hint_spEku0", "hint_spEma1", "hint_spEme1", "hint_spEmi1", "hint_spEmo1", "hint_spEmu1", "hint_spEsa0", "hint_spEse0", "hint_spEsi0", "hint_spEso0", "hint_spEsu0", "hint_spEbe1", "hint_spEbi1", "hint_spEbo1", "hint_spEbu1", "hint_spEba1"]
slothy.config.reserved_regs = ["sp", "r13"]
slothy.config.locked_registers = ["sp", "r13"]

slothy.config.with_llvm_mca = True
slothy.config.llvm_mca_full = True

slothy.config.split_heuristic = True
slothy.config.split_heuristic_preprocess_naive_interleaving = True
slothy.config.split_heuristic_factor = 8
slothy.config.split_heuristic_repeat = 2
slothy.config.split_heuristic_optimize_seam = 4
slothy.config.split_heuristic_stepsize = 0.05
if "part" not in self.name:
slothy.config.outputs = ["flags", "hint_spEga0", "hint_spEge0", "hint_spEgi0", "hint_spEgo0", "hint_spEgu0", "hint_spEka1", "hint_spEke1", "hint_spEki1", "hint_spEko1", "hint_spEku1", "hint_spEma0", "hint_spEme0", "hint_spEmi0", "hint_spEmo0", "hint_spEmu0", "hint_spEsa1", "hint_spEse1", "hint_spEsi1", "hint_spEso1", "hint_spEsu1", "hint_spEbe0", "hint_spEbi0", "hint_spEbo0", "hint_spEbu0", "hint_spEba0", "hint_spEga1", "hint_spEge1", "hint_spEgi1", "hint_spEgo1", "hint_spEgu1", "hint_spEka0", "hint_spEke0", "hint_spEki0", "hint_spEko0", "hint_spEku0", "hint_spEma1", "hint_spEme1", "hint_spEmi1", "hint_spEmo1", "hint_spEmu1", "hint_spEsa0", "hint_spEse0", "hint_spEsi0", "hint_spEso0", "hint_spEsu0", "hint_spEbe1", "hint_spEbi1", "hint_spEbo1", "hint_spEbu1", "hint_spEba1"]

slothy.config.split_heuristic = True
slothy.config.split_heuristic_preprocess_naive_interleaving = True
slothy.config.split_heuristic_repeat = 2
slothy.config.split_heuristic_optimize_seam = 4
slothy.config.split_heuristic_stepsize = 0.05
if not "old" in self.name:
slothy.config.split_heuristic_factor = 8

slothy.optimize(start="slothy_start_round0", end="slothy_end_round0")
slothy.config.outputs = ["flags", "hint_r0Aba0", "hint_r0Aba1", "hint_r0Abe0", "hint_r0Abe1", "hint_r0Abi0", "hint_r0Abi1", "hint_r0Abo0", "hint_r0Abo1", "hint_r0Abu0", "hint_r0Abu1", "hint_r0Aga0", "hint_r0Aga1", "hint_r0Age0", "hint_r0Age1", "hint_r0Agi0", "hint_r0Agi1", "hint_r0Ago0", "hint_r0Ago1", "hint_r0Agu0", "hint_r0Agu1", "hint_r0Aka0", "hint_r0Aka1", "hint_r0Ake0", "hint_r0Ake1", "hint_r0Aki0", "hint_r0Aki1", "hint_r0Ako0", "hint_r0Ako1", "hint_r0Aku0", "hint_r0Aku1", "hint_r0Ama0", "hint_r0Ama1", "hint_r0Ame0", "hint_r0Ame1", "hint_r0Ami0", "hint_r0Ami1", "hint_r0Amo0", "hint_r0Amo1", "hint_r0Amu0", "hint_r0Amu1", "hint_r0Asa0", "hint_r0Asa1", "hint_r0Ase0", "hint_r0Ase1", "hint_r0Asi0", "hint_r0Asi1", "hint_r0Aso0", "hint_r0Aso1", "hint_r0Asu0", "hint_r0Asu1"]
slothy.optimize(start="slothy_start_round1", end="slothy_end_round1")
slothy.optimize(start="slothy_start_round0", end="slothy_end_round0")
slothy.config.outputs = ["flags", "hint_r0Aba0", "hint_r0Aba1", "hint_r0Abe0", "hint_r0Abe1", "hint_r0Abi0", "hint_r0Abi1", "hint_r0Abo0", "hint_r0Abo1", "hint_r0Abu0", "hint_r0Abu1", "hint_r0Aga0", "hint_r0Aga1", "hint_r0Age0", "hint_r0Age1", "hint_r0Agi0", "hint_r0Agi1", "hint_r0Ago0", "hint_r0Ago1", "hint_r0Agu0", "hint_r0Agu1", "hint_r0Aka0", "hint_r0Aka1", "hint_r0Ake0", "hint_r0Ake1", "hint_r0Aki0", "hint_r0Aki1", "hint_r0Ako0", "hint_r0Ako1", "hint_r0Aku0", "hint_r0Aku1", "hint_r0Ama0", "hint_r0Ama1", "hint_r0Ame0", "hint_r0Ame1", "hint_r0Ami0", "hint_r0Ami1", "hint_r0Amo0", "hint_r0Amo1", "hint_r0Amu0", "hint_r0Amu1", "hint_r0Asa0", "hint_r0Asa1", "hint_r0Ase0", "hint_r0Ase1", "hint_r0Asi0", "hint_r0Asi1", "hint_r0Aso0", "hint_r0Aso1", "hint_r0Asu0", "hint_r0Asu1"]
slothy.optimize(start="slothy_start_round1", end="slothy_end_round1")
else:
slothy.config.split_heuristic_factor = 22

slothy.optimize(start="slothy_start", end="slothy_end")
else:
slothy.config.outputs = ['hint_sp\\()\\mDa0', 'hint_sp\\()\\mDa1', 'hint_sp\\()\\mDo0', 'hint_sp\\()\\mDo1', 'r10', 'hint_sp\\()\\mDi0', 'r14', 'flags']
slothy.optimize(start="slothy_start", end="slothy_end")


class Example0(Example):
Expand Down Expand Up @@ -1441,7 +1445,12 @@ def core(self, slothy):
slothy.config.with_llvm_mca = True
slothy.config.llvm_mca_full = True
slothy.config.constraints.stalls_first_attempt = 3

slothy.config.variable_size = True

slothy.optimize(start="layer123_start", end="layer123_end")
# slothy.optimize(start="layer456_start", end="layer456_end")
# slothy.optimize(start="layer78_start", end="layer78_end")
slothy.rename_function("pqcrystals_dilithium_invntt_tomont", "pqcrystals_dilithium_invntt_tomont2")
#############################################################################################

Expand All @@ -1459,9 +1468,6 @@ def __init__(self, var="", arch=Arch_Armv7M, target=Target_CortexM7, timeout=Non
super().__init__(infile, name, rename=True, arch=arch, target=target, timeout=timeout, funcname=funcname)

def core(self, slothy):
slothy.config.constraints.allow_reordering = True
slothy.config.constraints.allow_renaming = True
slothy.config.constraints.functional_only = True
slothy.config.outputs = ["r0", "r14"]
slothy.config.inputs_are_outputs = True

Expand Down Expand Up @@ -1622,7 +1628,9 @@ def main():
fft_fixedpoint_radix4(),

ExampleDummy(),
ExampleKeccak(var="m7")
ExampleKeccak(var="old"),
ExampleKeccak(var="m7"),
ExampleKeccak(var="part")
]

all_example_names = [e.name for e in examples]
Expand Down

0 comments on commit c518581

Please sign in to comment.