From a84fc38a36dfabfe0c5328189d88672bd829e3b1 Mon Sep 17 00:00:00 2001 From: "Rojas Chaves, Jose" Date: Mon, 26 May 2025 15:34:23 +0000 Subject: [PATCH] Fixing no hbm for new isa_spec --- .../assembler/instructions/cinst/csyncm.py | 4 + .../assembler/isa_spec/cinst/__init__.py | 638 ------------ .../assembler/isa_spec/minst/__init__.py | 152 --- .../assembler/isa_spec/xinst/__init__.py | 919 ------------------ .../hec-assembler-tools/he_link.py | 5 + .../linker/steps/program_linker.py | 8 +- 6 files changed, 13 insertions(+), 1713 deletions(-) delete mode 100644 assembler_tools/hec-assembler-tools/assembler/isa_spec/cinst/__init__.py delete mode 100644 assembler_tools/hec-assembler-tools/assembler/isa_spec/minst/__init__.py delete mode 100644 assembler_tools/hec-assembler-tools/assembler/isa_spec/xinst/__init__.py diff --git a/assembler_tools/hec-assembler-tools/assembler/instructions/cinst/csyncm.py b/assembler_tools/hec-assembler-tools/assembler/instructions/cinst/csyncm.py index 18485c88..ce57054c 100644 --- a/assembler_tools/hec-assembler-tools/assembler/instructions/cinst/csyncm.py +++ b/assembler_tools/hec-assembler-tools/assembler/instructions/cinst/csyncm.py @@ -13,6 +13,10 @@ class Instruction(CInstruction): https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_csyncm.md """ + @classmethod + def get_throughput(cls) -> int: + return cls._OP_DEFAULT_THROUGHPUT + @classmethod def _get_OP_NAME_ASM(cls) -> str: """ diff --git a/assembler_tools/hec-assembler-tools/assembler/isa_spec/cinst/__init__.py b/assembler_tools/hec-assembler-tools/assembler/isa_spec/cinst/__init__.py deleted file mode 100644 index 6e827e85..00000000 --- a/assembler_tools/hec-assembler-tools/assembler/isa_spec/cinst/__init__.py +++ /dev/null @@ -1,638 +0,0 @@ -from .. import ISASpecInstruction - -class BLoad(ISASpecInstruction): - """ - Represents a `bload` instruction. - - This instruction loads metadata from scratchpad to register file. - - For more information, check the `bload` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_bload.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 5. - """ - return 5 - -class BOnes(ISASpecInstruction): - """ - Represents a `bones` instruction. - - The `bones` instruction loads metadata of identity (one) from the scratchpad to the register file. - - For more information, check the `bones` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_bones.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 5. - """ - return 5 - -class Exit(ISASpecInstruction): - """ - Represents an `cexit` instruction. - - This instruction terminates execution of a HERACLES program. - - For more information, check the `cexit` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_cexit.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 - -class CLoad(ISASpecInstruction): - """ - Represents a `cload` instruction. - - This instruction loads a single polynomial residue from scratchpad into a register. - - For more information, check the `cload` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_cload.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 4. - """ - return 4 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 4. - """ - return 4 - -class Nop(ISASpecInstruction): - """ - Represents a `nop` instruction. - - This instruction adds desired amount of idle cycles in the Cfetch flow. - - For more information, check the `nop` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_nop.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 - -class CStore(ISASpecInstruction): - """ - Represents a `cstore` instruction. - - This instruction fetchs a single polynomial residue from the intermediate data buffer and store back to SPAD. - - For more information, check the `cstore` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_cstore.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 5. - """ - return 5 - -class CSyncM(ISASpecInstruction): - """ - Represents a `csyncm` instruction. - - Wait instruction similar to a barrier that stalls the execution of CINST - queue until the specified instruction from MINST queue has completed. - - For more information, check the `csyncm` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_csyncm.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 - -class iFetch(ISASpecInstruction): - """ - Represents an `ifetch` instruction. - - This instruction fetchs a bundle of instructions from the XINST queue and send it to the CE for execution. - - For more information, check the `ifetch` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_ifetch.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 5. - """ - return 5 - -class KGLoad(ISASpecInstruction): - """ - Represents a `kgload` instruction. - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 4. - """ - return 4 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 40. - """ - return 40 - -class KGSeed(ISASpecInstruction): - """ - Represents a `kgseed` instruction. - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 - -class KGStart(ISASpecInstruction): - """ - Represents a `kgstart` instruction. - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 40. - """ - return 40 - -class NLoad(ISASpecInstruction): - """ - Represents a `nload` instruction. - - This instruction loads metadata (for NTT/iNTT routing mapping) from - scratchpad into a special routing table register. - - For more information, check the `nload` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_nload.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 4. - """ - return 4 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 4. - """ - return 4 - -class XInstFetch(ISASpecInstruction): - """ - Represents an `xinstfetch` instruction. - - Fetches instructions from the HBM and sends it to the XINST queue. - - For more information, check the `xinstfetch` Specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/cinst/cinst_xinstfetch.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 \ No newline at end of file diff --git a/assembler_tools/hec-assembler-tools/assembler/isa_spec/minst/__init__.py b/assembler_tools/hec-assembler-tools/assembler/isa_spec/minst/__init__.py deleted file mode 100644 index 463df89b..00000000 --- a/assembler_tools/hec-assembler-tools/assembler/isa_spec/minst/__init__.py +++ /dev/null @@ -1,152 +0,0 @@ -from .. import ISASpecInstruction - -class MLoad(ISASpecInstruction): - """ - Represents an `mload` instruction, inheriting from ISASpecInstruction. - - This instruction loads a single polynomial residue from local memory to scratchpad. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/minst/minst_mload.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands for the instruction. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands for the instruction. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 - -class MStore(ISASpecInstruction): - """ - Represents an `mstore` instruction, inheriting from ISASpecInstruction. - - This instruction stores a single polynomial residue from scratchpad to local memory. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/minst/minst_mstore.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands for the instruction. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands for the instruction. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 - -class MSyncC(ISASpecInstruction): - """ - Represents an MSyncC instruction, inheriting from ISASpecInstruction. - - Wait instruction similar to a barrier that stalls the execution of MINST - queue until the specified instruction from CINST queue has completed. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/minst/minst_msyncc.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands for the instruction. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands for the instruction. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 \ No newline at end of file diff --git a/assembler_tools/hec-assembler-tools/assembler/isa_spec/xinst/__init__.py b/assembler_tools/hec-assembler-tools/assembler/isa_spec/xinst/__init__.py deleted file mode 100644 index 0fd3e554..00000000 --- a/assembler_tools/hec-assembler-tools/assembler/isa_spec/xinst/__init__.py +++ /dev/null @@ -1,919 +0,0 @@ -from assembler.common.decorators import * -from .. import ISASpecInstruction - -class Add(ISASpecInstruction): - """ - Represents an `add` instruction. - - This instructions adds two polynomials stored in the register file and - store the result in a register. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_add.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 2. - """ - return 2 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class Copy(ISASpecInstruction): - """ - Represents a Copy instruction. - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class Exit(ISASpecInstruction): - """ - Represents an `exit` instruction. - - This instruction terminates execution of an instruction bundle. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_exit.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 - -class iNTT(ISASpecInstruction): - """ - Represents an `intt` instruction. - - The Inverse Number Theoretic Transform (iNTT), converts NTT form to positional form. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_intt.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 2. - """ - return 2 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 3. - """ - return 3 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class irShuffle(ISASpecInstruction): - """ - Represents an irShuffle instruction with special latency properties. - - Properties: - SpecialLatency: Indicates the first increment at which another irshuffle instruction - can be scheduled within `SpecialLatencyMax` latency. - SpecialLatencyMax: Cannot enqueue any other irshuffle instruction within this latency - unless it is in `SpecialLatencyIncrement`. - SpecialLatencyIncrement: Can only enqueue any other irshuffle instruction - within `SpecialLatencyMax` only in increments of this value. - """ - - @classproperty - def SpecialLatency(cls): - """ - Special latency (indicates the first increment at which another irshuffle instruction - can be scheduled within `SpecialLatencyMax` latency). - - Returns: - int: The special latency increment. - """ - return cls.SpecialLatencyIncrement - - @classproperty - def SpecialLatencyMax(cls): - """ - Special latency maximum (cannot enqueue any other irshuffle instruction within this latency - unless it is in `SpecialLatencyIncrement`). - - Returns: - int: The special latency maximum, which is 17. - """ - return 17 - - @classproperty - def SpecialLatencyIncrement(cls): - """ - Special latency increment (can only enqueue any other irshuffle instruction - within `SpecialLatencyMax` only in increments of this value). - - Returns: - int: The special latency increment, which is 5. - """ - return 5 - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 2. - """ - return 2 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 2. - """ - return 2 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 23. - """ - return 23 - -class Mac(ISASpecInstruction): - """ - Represents a `mac` instruction. - - Element-wise polynomial multiplication and accumulation. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_mac.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 2. - """ - return 2 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class Maci(ISASpecInstruction): - """ - Represents a `maci` instruction. - - Element-wise polynomial scaling by an immediate value and accumulation. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_maci.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class Move(ISASpecInstruction): - """ - Represents a `move` instruction. - - This instruction copies data from one register to a different one. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_move.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class Mul(ISASpecInstruction): - """ - Represents a `mul` instruction. - - This instructions performs element-wise polynomial multiplication. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_mul.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 2. - """ - return 2 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class Muli(ISASpecInstruction): - """ - Represents a Muli instruction. - - This instruction performs element-wise polynomial scaling by an immediate value. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_muli.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class Nop(ISASpecInstruction): - """ - Represents a `nop` instruction. - - This instruction adds a desired amount of idle cycles to the compute flow. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_nop.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 0. - """ - return 0 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 0. - """ - return 0 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 1. - """ - return 1 - -class NTT(ISASpecInstruction): - """ - Represents an `ntt` instruction (Number Theoretic Transform). - Converts positional form to NTT form. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_ntt.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 2. - """ - return 2 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 3. - """ - return 3 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class rShuffle(ISASpecInstruction): - """ - Represents an rShuffle instruction with special latency properties. - - Properties: - SpecialLatency: Indicates the first increment at which another rshuffle instruction - can be scheduled within `SpecialLatencyMax` latency. - SpecialLatencyMax: Cannot enqueue any other rshuffle instruction within this latency - unless it is in `SpecialLatencyIncrement`. - SpecialLatencyIncrement: Can only enqueue any other rshuffle instruction - within `SpecialLatencyMax` only in increments of this value. - """ - - @classproperty - def SpecialLatency(cls): - """ - Special latency (indicates the first increment at which another rshuffle instruction - can be scheduled within `SpecialLatencyMax` latency). - - Returns: - int: The special latency increment. - """ - return cls.SpecialLatencyIncrement - - @classproperty - def SpecialLatencyMax(cls): - """ - Special latency maximum (cannot enqueue any other rshuffle instruction within this latency - unless it is in `SpecialLatencyIncrement`). - - Returns: - int: The special latency maximum, which is 17. - """ - return 17 - - @classproperty - def SpecialLatencyIncrement(cls): - """ - Special latency increment (can only enqueue any other rshuffle instruction - within `SpecialLatencyMax` only in increments of this value). - - Returns: - int: The special latency increment, which is 5. - """ - return 5 - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 2. - """ - return 2 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 2. - """ - return 2 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 23. - """ - return 23 - -class Sub(ISASpecInstruction): - """ - Represents a `sub` instruction. - - Element-wise polynomial subtraction. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_sub.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 2. - """ - return 2 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class twiNTT(ISASpecInstruction): - """ - Represents a `twintt` instruction. - - This instruction performs on-die generation of twiddle factors for the next stage of iNTT. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_twintt.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class twNTT(ISASpecInstruction): - """ - Represents a `twntt` instruction. - - This instruction performs on-die generation of twiddle factors for the next stage of NTT. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_twntt.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 - -class xStore(ISASpecInstruction): - """ - Represents an `xstore` instruction. - - This instruction transfers data from a register into the intermediate data buffer for subsequent transfer into SPAD. - - For more information, check the specification: - https://github.com/IntelLabs/hec-assembler-tools/blob/master/docsrc/inst_spec/xinst/xinst_xstore.md - """ - - @classmethod - def _get_numDests(cls) -> int: - """ - Gets the number of destination operands. - - Returns: - int: The number of destination operands, which is 1. - """ - return 1 - - @classmethod - def _get_numSources(cls) -> int: - """ - Gets the number of source operands. - - Returns: - int: The number of source operands, which is 1. - """ - return 1 - - @classmethod - def _get_throughput(cls) -> int: - """ - Gets the throughput of the instruction. - - Returns: - int: The throughput, which is 1. - """ - return 1 - - @classmethod - def _get_latency(cls) -> int: - """ - Gets the latency of the instruction. - - Returns: - int: The latency, which is 6. - """ - return 6 \ No newline at end of file diff --git a/assembler_tools/hec-assembler-tools/he_link.py b/assembler_tools/hec-assembler-tools/he_link.py index b68439fe..880f6c5f 100644 --- a/assembler_tools/hec-assembler-tools/he_link.py +++ b/assembler_tools/hec-assembler-tools/he_link.py @@ -41,6 +41,7 @@ from assembler.common.run_config import static_initializer from assembler.common.config import GlobalConfig from assembler.memory_model import mem_info +from assembler.isa_spec import SpecConfig from linker import loader from linker.steps import variable_discovery from linker.steps import program_linker @@ -327,6 +328,8 @@ def parse_args(): help=("List of input prefixes, including full path. For an input prefix, linker will " "assume three files exist named `input_prefixes[i] + '.minst'`, " "`input_prefixes[i] + '.cinst'`, and `input_prefixes[i] + '.xinst'`.")) + parser.add_argument("--isa_spec", default="", dest="isa_spec_file", + help=("Input ISA specification (.json) file.")) parser.add_argument("-im", "--input_mem_file", dest="input_mem_file", required=True, help=("Input memory mapping file associated with the resulting program. " "Specifies the names for input, output, and metadata variables for the full program. " @@ -357,9 +360,11 @@ def parse_args(): return args if __name__ == "__main__": + module_dir = os.path.dirname(__file__) module_name = os.path.basename(__file__) args = parse_args() + args.isa_spec_file = SpecConfig.initialize_isa_spec(module_dir, args.isa_spec_file) config = LinkerRunConfig(**vars(args)) # convert argsparser into a dictionary if args.verbose > 0: diff --git a/assembler_tools/hec-assembler-tools/linker/steps/program_linker.py b/assembler_tools/hec-assembler-tools/linker/steps/program_linker.py index d1377e39..6f6c1999 100644 --- a/assembler_tools/hec-assembler-tools/linker/steps/program_linker.py +++ b/assembler_tools/hec-assembler-tools/linker/steps/program_linker.py @@ -2,7 +2,7 @@ from linker import MemoryModel from linker.instructions import minst, cinst, xinst from assembler.common.config import GlobalConfig -from assembler.isa_spec import cinst as ISACInst +from assembler.instructions import cinst as ISACInst class LinkedProgram: """ @@ -188,13 +188,13 @@ def __updateCInsts(self, kernel_cinstrs: list): if isinstance(cinstr, cinst.CNop): # Add the missing cycles to any cnop we encounter up to this point - cinstr.cycles += (csyncm_count * ISACInst.CSyncM.Throughput) + cinstr.cycles += (csyncm_count * ISACInst.CSyncm.get_throughput()) csyncm_count = 0 # Idle cycles to account for the csyncm have been added if isinstance(cinstr, (cinst.IFetch, cinst.NLoad, cinst.BLoad)): if csyncm_count > 0: # Extra cycles needed before scheduling next bundle - cinstr_nop = cinst.CNop([i, cinst.CNop.name, str(csyncm_count * ISACInst.CSyncM.Throughput - 1)]) # Subtract 1 because cnop n, waits for n+1 cycles + cinstr_nop = cinst.CNop([i, cinst.CNop.name, str(csyncm_count * ISACInst.CSyncm.get_throughput() - 1)]) # Subtract 1 because cnop n, waits for n+1 cycles kernel_cinstrs.insert(i, cinstr_nop) csyncm_count = 0 # Idle cycles to account for the csyncm have been added i += 1 @@ -224,7 +224,7 @@ def __updateCInsts(self, kernel_cinstrs: list): # # replace instruction by cnop # kernel_cinstrs.pop(i) # if current_bundle > 0: - # cinstr_nop = cinst.CNop([i, cinst.CNop.name, str(ISACInst.CSyncM.Throughput)]) # Subtract 1 because cnop n, waits for n+1 cycles + # cinstr_nop = cinst.CNop([i, cinst.CNop.name, str(ISACInst.CSyncm.get_throughput())]) # Subtract 1 because cnop n, waits for n+1 cycles # kernel_cinstrs.insert(i, cinstr_nop) # # i += 1 # next instruction