Skip to content

Commit

Permalink
50% of the way there
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Aug 20, 2024
1 parent eb62bc8 commit a25f441
Show file tree
Hide file tree
Showing 8 changed files with 274 additions and 212 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ jobs:
iree-install \
$PWD/llvm-aie \
/opt/xilinx/xrt \
/opt/Xilinx/Vitis/2024.2
/opt/Xilinx/Vitis/2024.2 \
--reset-npu-between-runs
- name: Printing IR from aie2xclbin
run: |
Expand Down
82 changes: 43 additions & 39 deletions build_tools/ci/cpu_comparison/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,16 @@ def __init__(
self.xrt_hash = "undetermined"
self.xrt_release = "undetermined"
self.peano_commit_hash = "undetermined"
xrt_bin_dir = xrt_dir / "bin"
xrt_smi_exe = xrt_bin_dir / "xrt-smi"
xrt_bin_dir = xrt_dir
if platform.system() != "Windows":
xrt_bin_dir /= "bin"
xrt_smi_exe = xrt_bin_dir / (
"xrt-smi" + ".exe" if platform.system() == "Windows" else ""
)
if not xrt_smi_exe.exists():
xrt_smi_exe = xrt_bin_dir / "xbutil"
xrt_smi_exe = xrt_bin_dir / (
"xbutil" + ".exe" if platform.system() == "Windows" else ""
)
if not xrt_smi_exe.exists():
raise RuntimeError(f"Neither xrt-smi nor xbutil found in {xrt_bin_dir}")

Expand Down Expand Up @@ -665,7 +671,7 @@ def run(self, config):
)


def getTestPartition():
def get_test_partition():
return [ConvolutionSet(), MatmulSet(), SmokeSet()]


Expand Down Expand Up @@ -730,9 +736,10 @@ def all_tests(
verify_determinism()

# Verify a very basic script runs before running the more complex tests
shell_out(["pwd"], verbose=config.verbose)
if platform.system() != "Windows":
shell_out(["pwd"], verbose=config.verbose)

partition = getTestPartition()
partition = get_test_partition()
partition_names = [p.name for p in partition]
map_to_partition = {p.name: p for p in partition}
if "All" in test_set:
Expand Down Expand Up @@ -773,54 +780,48 @@ def all_tests(
parser.add_argument("iree_install_dir", type=abs_path)
parser.add_argument("peano_install_dir", type=abs_path)
parser.add_argument("xrt_dir", type=abs_path)
parser.add_argument("vitis_dir", type=abs_path)
parser.add_argument("--vitis-dir", type=abs_path)

# TODO(newling) make bool options boolean, not integer (tried but had issues)
parser.add_argument(
"--return_on_fail",
"--return-on-fail",
nargs="?",
default=1,
type=int,
help=(
"If 0, then the script will continue running even if a test fails, "
"enumerating all failures. Otherwise the script will exit on the first failure."
help=dedent(
"""
If 0, then the script will continue running even if a test fails,
enumerating all failures. Otherwise the script will exit on the first failure.
"""
),
)

parser.add_argument(
"--verbose",
nargs="?",
default=1,
type=int,
help="If 0, then print statements are suppressed, otherwise they are printed.",
)
parser.add_argument("--verbose", action="store_true")

parser.add_argument(
"--reset_npu_between_runs",
nargs="?",
default=1,
type=int,
"--reset-npu-between-runs",
action="store_true",
help=(
"If 0 then the NPU is not reset between runs, otherwise it is reset. "
"If passed then the NPU is not reset between runs, otherwise it is reset. "
"Resetting between runs can in theory help avoid certain types of "
"errors in parts of the stack which these tests are not designed to catch."
),
)

parser.add_argument(
"--do_not_run_aie",
nargs="?",
default=0,
type=int,
help=(
"If 1, then the AIE backend will not be run. This is useful for "
"ensuring that everything up to the AIE run and numerical comparison "
"is working correctly, for example if you are not on a device with "
"working AIE HW and runtime."
"--do-not-run-aie",
action="store_true",
help=dedent(
"""
If passed, then the AIE backend will not be run. This is useful for
ensuring that everything up to the AIE run and numerical comparison
is working correctly, for example if you are not on a device with
working AIE HW and runtime."
"""
),
)

partition = getTestPartition()
partition = get_test_partition()
partition_names = [p.name for p in partition]
partition_names_and_all = partition_names + ["All"]
help_string = (
Expand All @@ -829,19 +830,22 @@ def all_tests(
)

parser.add_argument(
"--test_set",
"--test-set",
type=str,
help=help_string,
default="All",
)

parser.add_argument(
"--additional_aie_compilation_flags",
"--additional-aie-compilation-flags",
type=str,
help=(
"Additional flags to pass to the AIE compiler, for all tests. "
"Example, do print the IR between passes during compilation you might have: "
' --additional_aie_compilation_flags="--mlir-print-ir-before-all --mlir-print-ir-module-scope --aie2xclbin-print-ir-before-all --aie2xclbin-print-ir-module-scope"'
help=dedent(
"""
Additional flags to pass to the AIE compiler, for all tests.
Example, do print the IR between passes during compilation you might have:
--additional_aie_compilation_flags="--mlir-print-ir-before-all --mlir-print-ir-module-scope
--aie2xclbin-print-ir-before-all --aie2xclbin-print-ir-module-scope"'
"""
),
default="",
)
Expand Down
4 changes: 2 additions & 2 deletions build_tools/download_peano.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

RELEASE=19.0.0.2024081918+69415c19
pip download -q llvm_aie==$RELEASE -f https://github.com/Xilinx/llvm-aie/releases/expanded_assets/nightly
unzip -q llvm_aie*whl
pip download llvm_aie==$RELEASE -f https://github.com/Xilinx/llvm-aie/releases/expanded_assets/nightly
unzip llvm_aie*whl
40 changes: 23 additions & 17 deletions cmake/iree_aie_xrt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

if(TARGET iree-aie-xclbinutil)
if(TARGET iree_aie_xrt_iree-aie-xclbinutil)
return()
endif()

Expand Down Expand Up @@ -134,32 +134,38 @@ list(REMOVE_ITEM _xclbinutil_srcs "${_xclbinutil_source_dir}/SectionSmartNic.cxx
# and then --add-replace-section:MEM_TOPOLOGY won't work...
# XRT/src/runtime_src/tools/xclbinutil/SectionMemTopology.cxx#L26-L41
# TODO(max): and for whatever reason -WL,--whole-archive doesn't work
add_executable(iree-aie-xclbinutil ${_xclbinutil_srcs})
set(IREE_PACKAGE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(IREE_PACKAGE_ROOT_PREFIX "iree::aie::xrt")
iree_cc_binary(
NAME
# if you rename this be sure to update the if(...) return up top
# otherwise this script will be entered twice and you'll get a confusing error like
# "can't do add_executable; target already exists"
iree-aie-xclbinutil
SRCS
${_xclbinutil_srcs}
COPTS
$<$<PLATFORM_ID:Linux>:-fexceptions -frtti>
$<$<PLATFORM_ID:Windows>:/EHsc /GR>
DEFINES
BOOST_BIND_GLOBAL_PLACEHOLDERS
INSTALL_COMPONENT
IREETools-Runtime
PUBLIC
)

target_compile_definitions(iree-aie-xclbinutil
PRIVATE
-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
set(THREADS_PREFER_PTHREAD_FLAG ON)
target_link_libraries(iree-aie-xclbinutil
target_link_libraries(iree_aie_xrt_iree-aie-xclbinutil
PRIVATE
Threads::Threads
$<BUILD_LOCAL_INTERFACE:${IREE_AIE_BOOST_LIBS}>
$<$<PLATFORM_ID:Linux>:$<BUILD_LOCAL_INTERFACE:transformcdo>>)
target_include_directories(iree-aie-xclbinutil
target_include_directories(iree_aie_xrt_iree-aie-xclbinutil
PRIVATE ${XRT_BINARY_DIR}/gen
${IREE_XRT_SOURCE_DIR}/runtime_src/core/include
${_xclbinutil_source_dir})
target_compile_options(iree-aie-xclbinutil
PRIVATE
$<$<PLATFORM_ID:Linux>:-fexceptions -frtti>
$<$<PLATFORM_ID:Windows>:/EHsc /GR>)
set_target_properties(iree-aie-xclbinutil
set_target_properties(iree_aie_xrt_iree-aie-xclbinutil
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/tools")
iree_install_targets(
TARGETS iree-aie-xclbinutil
COMPONENT IREETools-Runtime
EXPORT_SET Runtime
)

# ##############################################################################
# xrt_coreutil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ iree_cc_library(
)

if(IREE_AMD_AIE_ENABLE_XRT_DRIVER)
add_dependencies(iree_target_amd-aie_Target_AIETargets iree-aie-xclbinutil)
add_dependencies(iree_target_amd-aie_Target_AIETargets iree_aie_xrt_iree-aie-xclbinutil)
endif()

iree_cc_library(
Expand Down
Loading

0 comments on commit a25f441

Please sign in to comment.