Skip to content

Commit

Permalink
Upstream moved to using black for formatting months ago so e.g., four…
Browse files Browse the repository at this point in the history
… space indents like is generally considered "pythonic".
  • Loading branch information
makslevental committed Sep 6, 2023
1 parent dae0939 commit dc353ba
Show file tree
Hide file tree
Showing 6 changed files with 1,229 additions and 632 deletions.
6 changes: 3 additions & 3 deletions python/aie/compiler/aiecc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

"""aie compiler driver for MLIR tools"""

__author__ = 'Stephen Neuendorffer'
__email__ = '[email protected]'
__author__ = "Stephen Neuendorffer"
__email__ = "[email protected]"
__versioninfo__ = (0, 1, 0)
__version__ = '.'.join(str(v) for v in __versioninfo__) + 'dev'
__version__ = ".".join(str(v) for v in __versioninfo__) + "dev"

__all__ = []
313 changes: 178 additions & 135 deletions python/aie/compiler/aiecc/cl_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,160 +6,202 @@
# (c) Copyright 2021 Xilinx Inc.

import argparse
import os
import shlex
import sys
import shutil

from aie.compiler.aiecc.configure import *


def parse_args(args=None):
if (args is None):
if args is None:
args = sys.argv[1:]
parser = argparse.ArgumentParser(prog='aiecc')
parser.add_argument('filename',
metavar="file",
help='MLIR file to compile')
parser.add_argument('--sysroot',
metavar="sysroot",
default="",
help='sysroot for cross-compilation')
parser.add_argument('--tmpdir',
metavar="tmpdir",
default=None,
help='directory used for temporary file storage')
parser.add_argument('-v',
dest="verbose",
default=False,
action='store_true',
help='Trace commands as they are executed')
parser.add_argument('--vectorize',
dest="vectorize",
default=False,
action='store_true',
help='Enable MLIR vectorization')
parser.add_argument('--xbridge',
dest="xbridge",
default=aie_link_with_xchesscc,
action='store_true',
help='Link using xbridge')
parser.add_argument('--no-xbridge',
dest="xbridge",
default=not aie_link_with_xchesscc,
action='store_false',
help='Link using peano')
parser.add_argument('--aiesim',
dest="aiesim",
default=False,
action='store_true',
help='Generate aiesim Work folder')
parser.add_argument('--no-aiesim',
dest="aiesim",
default=False,
action='store_false',
help='Do not generate aiesim Work folder')
parser.add_argument('--xchesscc',
dest="xchesscc",
default=aie_compile_with_xchesscc,
action='store_true',
help='Compile using xchesscc')
parser.add_argument('--no-xchesscc',
dest="xchesscc",
default=not aie_compile_with_xchesscc,
action='store_false',
help='Compile using peano')
parser.add_argument('--peano',
dest="peano_install_dir",
default=peano_install_dir,
help='Root directory where peano compiler is installed')
parser.add_argument('--compile',
dest="compile",
default=not aie_disable_compile,
action='store_true',
help='Enable compiling of AIE code')
parser.add_argument('--no-compile',
dest="compile",
default=aie_disable_compile,
action='store_false',
help='Disable compiling of AIE code')
parser.add_argument('--host-target',
dest="host_target",
default=host_architecture,
help='Target architecture of the host program')
parser.add_argument('--compile-host',
dest="compile_host",
default=not host_disable_compile,
action='store_true',
help='Enable compiling of the host program')
parser.add_argument('--no-compile-host',
dest="compile_host",
default=host_disable_compile,
action='store_false',
help='Disable compiling of the host program')
parser.add_argument('--link',
dest="link",
default=not aie_disable_link,
action='store_true',
help='Enable linking of AIE code')
parser.add_argument('--no-link',
dest="link",
default=aie_disable_link,
action='store_false',
help='Disable linking of AIE code')
parser.add_argument("host_args",
action='store',
help='arguments for host compiler',
nargs=argparse.REMAINDER)
parser.add_argument('-j',
dest="nthreads",
default=4,
action='store',
help='Compile with max n-threads in the machine (default is 4). An argument of zero corresponds to the maximum number of threads on the machine.')
parser.add_argument('--profile',
dest="profiling",
default=False,
action='store_true',
help='Profile commands to find the most expensive executions.')
parser.add_argument('--unified',
dest="unified",
default=aie_unified_compile,
action='store_true',
help='Compile all cores together in a single process')
parser.add_argument('--no-unified',
dest="unified",
default=not aie_unified_compile,
action='store_false',
help='Compile cores independently in separate processes')
parser.add_argument('-n',
dest="execute",
default=True,
action='store_false',
help='Disable actually executing any commands.')
parser.add_argument('--progress',
dest="progress",
default=False,
action='store_true',
help='Show progress visualization')
parser = argparse.ArgumentParser(prog="aiecc")
parser.add_argument("filename", metavar="file", help="MLIR file to compile")
parser.add_argument(
"--sysroot", metavar="sysroot", default="", help="sysroot for cross-compilation"
)
parser.add_argument(
"--tmpdir",
metavar="tmpdir",
default=None,
help="directory used for temporary file storage",
)
parser.add_argument(
"-v",
dest="verbose",
default=False,
action="store_true",
help="Trace commands as they are executed",
)
parser.add_argument(
"--vectorize",
dest="vectorize",
default=False,
action="store_true",
help="Enable MLIR vectorization",
)
parser.add_argument(
"--xbridge",
dest="xbridge",
default=aie_link_with_xchesscc,
action="store_true",
help="Link using xbridge",
)
parser.add_argument(
"--no-xbridge",
dest="xbridge",
default=not aie_link_with_xchesscc,
action="store_false",
help="Link using peano",
)
parser.add_argument(
"--aiesim",
dest="aiesim",
default=False,
action="store_true",
help="Generate aiesim Work folder",
)
parser.add_argument(
"--no-aiesim",
dest="aiesim",
default=False,
action="store_false",
help="Do not generate aiesim Work folder",
)
parser.add_argument(
"--xchesscc",
dest="xchesscc",
default=aie_compile_with_xchesscc,
action="store_true",
help="Compile using xchesscc",
)
parser.add_argument(
"--no-xchesscc",
dest="xchesscc",
default=not aie_compile_with_xchesscc,
action="store_false",
help="Compile using peano",
)
parser.add_argument(
"--peano",
dest="peano_install_dir",
default=peano_install_dir,
help="Root directory where peano compiler is installed",
)
parser.add_argument(
"--compile",
dest="compile",
default=not aie_disable_compile,
action="store_true",
help="Enable compiling of AIE code",
)
parser.add_argument(
"--no-compile",
dest="compile",
default=aie_disable_compile,
action="store_false",
help="Disable compiling of AIE code",
)
parser.add_argument(
"--host-target",
dest="host_target",
default=host_architecture,
help="Target architecture of the host program",
)
parser.add_argument(
"--compile-host",
dest="compile_host",
default=not host_disable_compile,
action="store_true",
help="Enable compiling of the host program",
)
parser.add_argument(
"--no-compile-host",
dest="compile_host",
default=host_disable_compile,
action="store_false",
help="Disable compiling of the host program",
)
parser.add_argument(
"--link",
dest="link",
default=not aie_disable_link,
action="store_true",
help="Enable linking of AIE code",
)
parser.add_argument(
"--no-link",
dest="link",
default=aie_disable_link,
action="store_false",
help="Disable linking of AIE code",
)
parser.add_argument(
"host_args",
action="store",
help="arguments for host compiler",
nargs=argparse.REMAINDER,
)
parser.add_argument(
"-j",
dest="nthreads",
default=4,
action="store",
help="Compile with max n-threads in the machine (default is 4). An argument of zero corresponds to the maximum number of threads on the machine.",
)
parser.add_argument(
"--profile",
dest="profiling",
default=False,
action="store_true",
help="Profile commands to find the most expensive executions.",
)
parser.add_argument(
"--unified",
dest="unified",
default=aie_unified_compile,
action="store_true",
help="Compile all cores together in a single process",
)
parser.add_argument(
"--no-unified",
dest="unified",
default=not aie_unified_compile,
action="store_false",
help="Compile cores independently in separate processes",
)
parser.add_argument(
"-n",
dest="execute",
default=True,
action="store_false",
help="Disable actually executing any commands.",
)
parser.add_argument(
"--progress",
dest="progress",
default=False,
action="store_true",
help="Show progress visualization",
)

opts = parser.parse_args(args)
return opts


def strip_host_args_for_aiesim(args):
parser = argparse.ArgumentParser(prog='aiecc')
parser.add_argument('-o',
metavar="output",
default="",
help='output file')
parser = argparse.ArgumentParser(prog="aiecc")
parser.add_argument("-o", metavar="output", default="", help="output file")

opts = parser.parse_known_args(args)
return opts[1]


def _positive_int(arg):
return _int(arg, 'positive', lambda i: i > 0)
return _int(arg, "positive", lambda i: i > 0)


def _non_negative_int(arg):
return _int(arg, 'non-negative', lambda i: i >= 0)
return _int(arg, "non-negative", lambda i: i >= 0)


def _int(arg, kind, pred):
Expand All @@ -175,6 +217,7 @@ def _int(arg, kind, pred):

def _case_insensitive_regex(arg):
import re

try:
return re.compile(arg, re.IGNORECASE)
except re.error as reason:
Expand Down
Loading

0 comments on commit dc353ba

Please sign in to comment.