Skip to content

Commit

Permalink
more wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fifield committed Jan 26, 2024
1 parent 8b72b25 commit 28105e1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 46 deletions.
22 changes: 6 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ find_package(MLIR REQUIRED CONFIG)
find_package(AIE REQUIRED)
find_package(LibXAIE)
find_package(XRT)
find_package(hsa-runtime64)

message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
Expand Down Expand Up @@ -164,25 +165,14 @@ foreach(target ${AIR_RUNTIME_TARGETS})
TEST_EXCLUDE_FROM_MAIN true)
endforeach()

if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/runtime_lib/airhost/include
DESTINATION include/..
COMPONENT runtime_lib-headers
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp")

if(NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-runtime_lib-headers DEPENDS
runtime_lib-headers COMPONENT runtime_lib-headers)
endif()
endif()

add_subdirectory(python)
if(NOT AIR_RUNTIME_TEST_TARGET_VAL)
message(
"Skipping tests: No Runtime architecture found. Please configure AIR_RUNTIME_TARGETS."
"Skipping e2e tests: No Runtime architecture found. Please configure AIR_RUNTIME_TARGETS."
)
elseif(NOT hsa-runtime64_FOUND AND NOT XRT_FOUND)
message(
"Skipping e2e tests because cmake did not find hsa-runtime64 or XRT."
)
else()
add_subdirectory(test)
Expand Down
7 changes: 5 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ message(STATUS "Using AIRConfig.cmake in: ${AIR_DIR}")
option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON)
option(LLVM_BUILD_TOOLS "Build the LLVM tools. If OFF, just generate build targets." ON)

option(ENABLE_E2E_TESTS "Enable end-to-end testing" ON)
# ON: build and run end-to-end tests
# OFF: build only
option(ENABLE_RUN_AIRHOST_TESTS "Run end-to-end tests on vck5000 with libairhost" OFF)
option(ENABLE_RUN_XRT_TESTS "Run end-to-end tests on Ryzen AI with XRT" OFF)

set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
Expand All @@ -72,7 +75,7 @@ add_definitions(${LLVM_DEFINITIONS})

set(ENABLE_CHESS_TESTS ON CACHE BOOL "Enable backend tests using xchesscc")

if(ENABLE_E2E_TESTS)
if(ENABLE_RUN_AIRHOST_TESTS)
set(AIR_TEST_LIT_ARGS "-sv -j 1 --timeout 300 --time-tests --order=random")
else()
set(AIR_TEST_LIT_ARGS "-sv --timeout 300 --time-tests --order=random")
Expand Down
56 changes: 34 additions & 22 deletions test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,52 @@
# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.lit']

# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = []

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.air_obj_root, 'test')
air_runtime_lib = os.path.join(config.air_obj_root, "runtime_lib", config.test_arch)

config.substitutions.append(('%PATH%', config.environment['PATH']))
config.substitutions.append(('%shlibext', config.llvm_shlib_ext))
config.substitutions.append(('%PYTHON', config.python_executable))
config.substitutions.append(('%CLANG', "clang++ -fuse-ld=lld -DLIBXAIENGINEV2"))
config.substitutions.append(('%LIBXAIE_DIR%', config.libxaie_dir))
#config.substitutions.append(('%AIE_RUNTIME_DIR%', os.path.join(config.aie_obj_root, "runtime_lib", config.test_arch)))
config.substitutions.append(('%air_runtime_lib%', air_runtime_lib))
config.substitutions.append(('%airhost_libs%', "-I" + air_runtime_lib + "/airhost/include -L" + air_runtime_lib + "/airhost -Wl,--whole-archive -lairhost -Wl,-R{}/lib -Wl,-rpath,{}/lib -Wl,--whole-archive -Wl,--no-whole-archive -lpthread -lstdc++ -lsysfs -ldl -lrt -lelf".format(config.libxaie_dir, config.rocm_root)))
config.substitutions.append(('%AIE_RUNTIME_DIR%', os.path.join(config.aie_obj_root, "runtime_lib", config.test_arch)))
config.substitutions.append(('%HSA_DIR%', "{}".format(config.rocm_root)))

if(config.enable_e2e_tests):
if config.hsa_dir:
# Getting the path to the ROCm directory. hsa-runtime64 points to the cmake
# directory so need to go up three directories
rocm_root = os.path.join(config.hsa_dir, "..", "..", "..")
print("Found ROCm:", rocm_root)
config.substitutions.append(('%HSA_DIR%', "{}".format(rocm_root)))
config.substitutions.append(('%airhost_libs%',
" -I" + air_runtime_lib + "/airhost/include" +
" -L" + air_runtime_lib + "/airhost -Wl,--whole-archive -lairhost" +
" -Wl,-R{}/lib -Wl,-rpath,{}/lib -Wl,--whole-archive" +
" -Wl,--no-whole-archive -lpthread -lstdc++ -lsysfs -ldl -lrt -lelf".format(config.libxaie_dir, config.rocm_root)))
else:
print("ROCm not found")
config.excludes.append('airhost')

if config.enable_run_airhost_tests:
config.substitutions.append(('%run_on_board', "sudo"))
else:
config.substitutions.append(('%run_on_board', "echo"))

run_on_ipu = "echo"
xrt_flags = ""
# XRT
if config.xrt_lib_dir:
print("xrt found at", os.path.dirname(config.xrt_lib_dir))
xrt_flags = "-I{} -L{} -luuid -lxrt_coreutil".format(
config.xrt_include_dir, config.xrt_lib_dir
)
config.available_features.add("xrt")

run_on_ipu = "echo"
try:
xbutil = os.path.join(config.xrt_bin_dir, "xbutil")
result = subprocess.run(
Expand All @@ -82,22 +98,18 @@
except:
print("Failed to run xbutil")
pass
config.substitutions.append(("%run_on_ipu", run_on_ipu))
config.substitutions.append(("%xrt_flags", xrt_flags))
config.substitutions.append(("%XRT_DIR", config.xrt_dir))
else:
print("xrt not found")
config.substitutions.append(("%run_on_ipu", run_on_ipu))
config.substitutions.append(("%xrt_flags", xrt_flags))
config.substitutions.append(("%XRT_DIR", config.xrt_dir))
config.excludes.append('xrt')

llvm_config.with_system_environment(
['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP'])

llvm_config.use_default_substitutions()

# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['Inputs', 'Examples', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt', 'lit.cfg.py']

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

Expand All @@ -112,11 +124,11 @@
llvm_config.with_environment('PATH', config.aie_tools_dir, append_path=True)
llvm_config.with_environment('PATH', config.air_tools_dir, append_path=True)

#test if LM_LICENSE_FILE valid
if(config.enable_chess_tests):
# test if LM_LICENSE_FILE valid
if config.enable_chess_tests:
import shutil
result = None
if(config.vitis_root):
if config.vitis_root:
result = shutil.which("xchesscc")

import subprocess
Expand All @@ -138,7 +150,7 @@
print("WARNING: no valid xchess license that is required by some of the lit tests")


if(config.vitis_root):
if config.vitis_root:
llvm_config.with_environment('CARDANO', config.vitis_aietools_dir)
llvm_config.with_environment('VITIS', config.vitis_root)

Expand All @@ -160,6 +172,6 @@

llvm_config.add_tool_substitutions(tools, tool_dirs)

if(config.enable_e2e_tests):
if config.enable_run_airhost_tests:
lit_config.parallelism_groups["board"] = 1
config.parallelism_group = "board"
11 changes: 5 additions & 6 deletions test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ config.air_runtime_lib_obj_root = "@AIR_BINARY_DIR@/runtime_lib"
# test_exec_root: The root path where tests should be run.
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"

# Getting the path to the ROCm directory. hsa-runtime64
# points to the cmake directory so need to go up
# three directories
config.rocm_root = "@hsa-runtime64_DIR@/../../../"
config.hsa_dir = "@hsa-runtime64_DIR@"

# pass on vitis settings
config.enable_chess_tests = lit.util.pythonize_bool("@ENABLE_CHESS_TESTS@")
config.enable_e2e_tests = lit.util.pythonize_bool("@ENABLE_E2E_TESTS@")
config.enable_run_airhost_tests = lit.util.pythonize_bool("@ENABLE_RUN_AIRHOST_TESTS@")
config.enable_run_xrt_tests = lit.util.pythonize_bool("@ENABLE_RUN_XRT_TESTS@")

# pass on vitis settings
config.vitis_root = "@VITIS_ROOT@"
config.vitis_aietools_dir = "@VITIS_AIETOOLS_DIR@"
config.libxaie_dir = "@XILINX_XAIE_DIR@"
Expand Down

0 comments on commit 28105e1

Please sign in to comment.