Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b6b1dd2
Modernise extract-target pass. Note how the location of the bounds wa…
gabrielrodcanal Jul 31, 2025
a62cba6
Add the signature of the offloaded function to the module calling the…
gabrielrodcanal Aug 1, 2025
cf99ae9
Fix location index. Now all the examples build
gabrielrodcanal Aug 1, 2025
b1c2ac1
Add upper bound to the offload function arguments. Otherwise the gene…
gabrielrodcanal Aug 1, 2025
c6c360f
Add pass that converts target function to HLS compatible format. Func…
gabrielrodcanal Aug 1, 2025
a7cf606
More modular design to remove the target operation
gabrielrodcanal Aug 1, 2025
a56dd6a
Keep only the top-level module to contain the HLS function - necessar…
gabrielrodcanal Aug 1, 2025
865e2b4
Merge branch 'main' into gabriel/target_to_hls
mesham Aug 3, 2025
58a649c
Dereference in the HLS pass not necessary anymore, as it is processed…
gabrielrodcanal Aug 4, 2025
c13fc06
Add scripts to generate LLVM IR compatible with Vitis HLS
gabrielrodcanal Aug 4, 2025
10b1893
Add option to trigger the generation of LLVM IR for Vitis HLS. This o…
gabrielrodcanal Aug 4, 2025
fa1bfb9
Add support for omp.parallel as a pipelined loop. Tested on ex4.F90
gabrielrodcanal Aug 5, 2025
fea7ad2
Add support for SIMD directive as an unrolled loop
gabrielrodcanal Aug 5, 2025
69c46d9
Merge branch 'main' into gabriel/target_to_hls
gabrielrodcanal Aug 6, 2025
0962050
Add option to print to target fpga-host
gabrielrodcanal Aug 6, 2025
ebc67ff
Register unregistered passes
gabrielrodcanal Aug 6, 2025
73291b2
extract-target must be now launched after lower-omp-target-data, sinc…
gabrielrodcanal Aug 6, 2025
e164950
extract-target now extracts the body of the kernel_create operation i…
gabrielrodcanal Aug 7, 2025
5271ff9
Simplify loop
gabrielrodcanal Aug 7, 2025
9efc806
Remove the removal of the omp.target operation in the target-to-hls p…
gabrielrodcanal Aug 7, 2025
ce0e724
Remove everything FPGA-specific: xftn options and bash files
gabrielrodcanal Aug 7, 2025
fdf5b70
Merge branch 'main' into gabriel/new_extract_target
gabrielrodcanal Aug 7, 2025
5889bf1
Remove function call in favour of device.kernel_create operation with…
gabrielrodcanal Aug 7, 2025
10b2aaf
Merge main into gabriel/new_extract_target
gabrielrodcanal Aug 8, 2025
1568041
Merge branch 'main' into gabriel/new_extract_target
gabrielrodcanal Aug 8, 2025
7fb953f
A device.create_kernel operation pointing to a device function lacks …
gabrielrodcanal Aug 8, 2025
5907152
Make `apply-target` extensible with new targets
dk949 Sep 2, 2025
5391118
classmethod should be specified before abstractmethod
dk949 Sep 2, 2025
f7197d1
added documentation for _get_cofnig
dk949 Sep 2, 2025
d52b9b5
Merge branch 'main' into david/extensible-target-config
dk949 Oct 30, 2025
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
21 changes: 19 additions & 2 deletions ftn/tools/ftn_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@

from xdsl.dialects.builtin import ModuleOp

from typing import IO

from ftn.transforms.rewrite_fir_to_core import RewriteFIRToCore
from ftn.transforms.merge_memref_deref import MergeMemRefDeref
from ftn.transforms.extract_target import ExtractTarget
from ftn.transforms.fpga.target_to_hls import TargetToHLSPass
from ftn.transforms.lower_omp_target_data import LowerOmpTargetDataPass
# from ftn.transforms.extract_target import ExtractTarget
from ftn.transforms.apply_target_config import ApplyTargetConfig
from ftn.transforms.omp_target_to_kernel import OmpTargetToKernelPass
# from ftn.transforms.isolate_target import IsolateTarget
# from psy.extract_stencil import ExtractStencil
# from ftn.transforms.tenstorrent.convert_to_tt import ConvertToTT
Expand All @@ -18,6 +23,7 @@

from xdsl.xdsl_opt_main import xDSLOptMain
from ftn.dialects import ftn_relative_cf
from ftn.dialects import device

import traceback

Expand All @@ -27,13 +33,23 @@ def register_all_passes(self):
super().register_all_passes()
self.register_pass("rewrite-fir-to-core", lambda: RewriteFIRToCore)
self.register_pass("merge-memref-deref", lambda: MergeMemRefDeref)
self.register_pass("extract-target", lambda: ExtractTarget)
self.register_pass("target-to-hls", lambda: TargetToHLSPass)
self.register_pass("lower-omp-target-data", lambda: LowerOmpTargetDataPass)
# self.register_pass("extract-target", lambda: ExtractTarget)
self.register_pass("apply-target", lambda: ApplyTargetConfig)
self.register_pass("omp-target-to-kernel", lambda: OmpTargetToKernelPass)
# self.register_pass("isolate-target", lambda: IsolateTarget)
# self.register_pass("convert-to-tt", lambda: ConvertToTT)

def register_all_targets(self):
def _output_fpga_host(prog: ModuleOp, output: IO[str]):
from ftn.dialects.fpga.host_printer import HostPrinter

printer = HostPrinter(stream=output)
printer.print(prog)

super().register_all_targets()
self.available_targets["fpga-host"] = _output_fpga_host

def setup_pipeline(self):
super().setup_pipeline()
Expand All @@ -50,6 +66,7 @@ def register_all_arguments(self, arg_parser: argparse.ArgumentParser):
def register_all_dialects(self):
super().register_all_dialects()
self.ctx.load_dialect(ftn_relative_cf.Ftn_relative_cf)
self.ctx.load_dialect(device.Device)

@staticmethod
def get_passes_as_dict() -> Dict[str, Callable[[ModuleOp], None]]:
Expand Down
59 changes: 44 additions & 15 deletions ftn/transforms/apply_target_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass
from abc import ABC, abstractmethod

from xdsl.context import Context
from xdsl.dialects import builtin, dlti
Expand All @@ -7,16 +8,32 @@
from ftn.dialects import device


class TenstorrentConfiguration:
def get():
class TargetConfiguration(ABC):
@classmethod
@abstractmethod
def get(cls) -> dlti.TargetDeviceSpecAttr: ...

@classmethod
@abstractmethod
def _memory_subsystem(cls) -> dlti.MapAttr: ...

@classmethod
@abstractmethod
def _compute_subsystem(cls) -> dlti.MapAttr: ...


class TenstorrentConfiguration(TargetConfiguration):
@classmethod
def get(cls):
return dlti.TargetDeviceSpecAttr(
{
"memory": TenstorrentConfiguration._memory_subsystem(),
"compute": TenstorrentConfiguration._compute_subsystem(),
"memory": cls._memory_subsystem(),
"compute": cls._compute_subsystem(),
}
)

def _memory_subsystem():
@classmethod
def _memory_subsystem(cls):
config = {
"DRAM": {
"kind": device.MemoryKindAttr(device.MemoryKind.DDR),
Expand All @@ -25,7 +42,8 @@ def _memory_subsystem():
}
return dlti.MapAttr(config)

def _compute_subsystem():
@classmethod
def _compute_subsystem(cls):
config = {
"architecture_type": device.ArchitectureKindAttr(
device.ArchitectureKind.MANYCORE
Expand Down Expand Up @@ -53,16 +71,18 @@ def _compute_subsystem():
return dlti.MapAttr(config)


class U280Configuration:
def get():
class U280Configuration(TargetConfiguration):
@classmethod
def get(cls):
return dlti.TargetDeviceSpecAttr(
{
"memory": U280Configuration._memory_subsystem(),
"compute": U280Configuration._compute_subsystem(),
"memory": cls._memory_subsystem(),
"compute": cls._compute_subsystem(),
}
)

def _memory_subsystem():
@classmethod
def _memory_subsystem(cls):
config = {
"DRAM": {
"kind": device.MemoryKindAttr(device.MemoryKind.DDR),
Expand All @@ -76,7 +96,8 @@ def _memory_subsystem():
}
return dlti.MapAttr(config)

def _compute_subsystem():
@classmethod
def _compute_subsystem(cls):
config = {
"architecture_type": device.ArchitectureKindAttr(
device.ArchitectureKind.FPGA
Expand Down Expand Up @@ -153,14 +174,22 @@ def generate_system_config(self, accelerator_name, accelerator_config):
}
)

def _get_config(self) -> dlti.TargetDeviceSpecAttr:
"""
Get the device spec for the current `self.taregt`

If overriding this function, make sure to *not* specify `name` field again
"""
if config := SYSTEM_CONFIGURATIONS.get(self.target):
return config.get()
raise ValueError(f"No such target configuration {self.target}")

def apply(self, ctx: Context, op: builtin.ModuleOp) -> None:
op.attributes["omp.target_triples"] = builtin.ArrayAttr(
[builtin.StringAttr(self.target)]
)

assert self.target in SYSTEM_CONFIGURATIONS.keys()

config = SYSTEM_CONFIGURATIONS[self.target].get()
config = self._get_config()

op.attributes["dlti.target_system_spec"] = self.generate_system_config(
self.target, config
Expand Down
Loading