2019-03-30 13:10:12 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import re
|
|
|
|
import subprocess
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
import lit.formats
|
|
|
|
import lit.util
|
|
|
|
|
|
|
|
from lit.llvm import llvm_config
|
|
|
|
from lit.llvm.subst import ToolSubst
|
|
|
|
from lit.llvm.subst import FindTool
|
|
|
|
|
|
|
|
# Configuration file for the 'lit' test runner.
|
|
|
|
|
|
|
|
# name: The name of this test suite.
|
|
|
|
config.name = 'MLIR'
|
|
|
|
|
|
|
|
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
|
|
|
|
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
Initial boiler-plate for python bindings.
Summary:
* Native '_mlir' extension module.
* Python mlir/__init__.py trampoline module.
* Lit test that checks a message.
* Uses some cmake configurations that have worked for me in the past but likely needs further elaboration.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D83279
2020-07-07 14:05:46 +08:00
|
|
|
config.suffixes = ['.td', '.mlir', '.toy', '.ll', '.tc', '.py']
|
2019-03-30 13:10:12 +08:00
|
|
|
|
|
|
|
# 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.mlir_obj_root, 'test')
|
|
|
|
|
|
|
|
config.substitutions.append(('%PATH%', config.environment['PATH']))
|
2019-05-21 04:25:35 +08:00
|
|
|
config.substitutions.append(('%shlibext', config.llvm_shlib_ext))
|
2020-04-23 01:52:07 +08:00
|
|
|
config.substitutions.append(("%mlir_src_root", config.mlir_src_root))
|
2019-03-30 13:10:12 +08:00
|
|
|
|
|
|
|
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.
|
Initial boiler-plate for python bindings.
Summary:
* Native '_mlir' extension module.
* Python mlir/__init__.py trampoline module.
* Lit test that checks a message.
* Uses some cmake configurations that have worked for me in the past but likely needs further elaboration.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D83279
2020-07-07 14:05:46 +08:00
|
|
|
config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt',
|
|
|
|
'lit.cfg.py', 'lit.site.cfg.py']
|
2019-03-30 13:10:12 +08:00
|
|
|
|
|
|
|
# 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.mlir_obj_root, 'test')
|
|
|
|
|
|
|
|
# Tweak the PATH to include the tools dir.
|
|
|
|
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
|
|
|
|
|
|
|
|
tool_dirs = [config.mlir_tools_dir, config.llvm_tools_dir]
|
|
|
|
tools = [
|
2019-05-18 06:03:39 +08:00
|
|
|
'mlir-opt',
|
|
|
|
'mlir-tblgen',
|
|
|
|
'mlir-translate',
|
|
|
|
'mlir-edsc-builder-api-test',
|
2019-03-30 13:10:12 +08:00
|
|
|
]
|
2019-04-03 01:02:07 +08:00
|
|
|
|
|
|
|
# The following tools are optional
|
|
|
|
tools.extend([
|
Initial boiler-plate for python bindings.
Summary:
* Native '_mlir' extension module.
* Python mlir/__init__.py trampoline module.
* Lit test that checks a message.
* Uses some cmake configurations that have worked for me in the past but likely needs further elaboration.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D83279
2020-07-07 14:05:46 +08:00
|
|
|
ToolSubst('%PYTHON', config.python_executable),
|
2019-04-03 01:02:07 +08:00
|
|
|
ToolSubst('toy-ch1', unresolved='ignore'),
|
2019-04-03 04:11:20 +08:00
|
|
|
ToolSubst('toy-ch2', unresolved='ignore'),
|
2019-04-04 10:16:32 +08:00
|
|
|
ToolSubst('toy-ch3', unresolved='ignore'),
|
2019-04-05 09:31:31 +08:00
|
|
|
ToolSubst('toy-ch4', unresolved='ignore'),
|
2019-04-09 14:00:49 +08:00
|
|
|
ToolSubst('toy-ch5', unresolved='ignore'),
|
2020-02-19 22:11:22 +08:00
|
|
|
ToolSubst('%cuda_wrapper_library_dir', config.cuda_wrapper_library_dir, unresolved='ignore'),
|
2020-03-27 17:20:05 +08:00
|
|
|
ToolSubst('%linalg_test_lib_dir', config.linalg_test_lib_dir, unresolved='ignore'),
|
|
|
|
ToolSubst('%mlir_runner_utils_dir', config.mlir_runner_utils_dir, unresolved='ignore'),
|
[mlir][gpu] Introduce mlir-rocm-runner.
Summary:
`mlir-rocm-runner` is introduced in this commit to execute GPU modules on ROCm
platform. A small wrapper to encapsulate ROCm's HIP runtime API is also inside
the commit.
Due to behavior of ROCm, raw pointers inside memrefs passed to `gpu.launch`
must be modified on the host side to properly capture the pointer values
addressable on the GPU.
LLVM MC is used to assemble AMD GCN ISA coming out from
`ConvertGPUKernelToBlobPass` to binary form, and LLD is used to produce a shared
ELF object which could be loaded by ROCm HIP runtime.
gfx900 is the default target be used right now, although it could be altered via
an option in `mlir-rocm-runner`. Future revisions may consider using ROCm Agent
Enumerator to detect the right target on the system.
Notice AMDGPU Code Object V2 is used in this revision. Future enhancements may
upgrade to AMDGPU Code Object V3.
Bitcode libraries in ROCm-Device-Libs, which implements math routines exposed in
`rocdl` dialect are not yet linked, and is left as a TODO in the logic.
Reviewers: herhut
Subscribers: mgorny, tpr, dexonsmith, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, llvm-commits
Tags: #mlir, #llvm
Differential Revision: https://reviews.llvm.org/D80676
2020-05-21 05:07:49 +08:00
|
|
|
ToolSubst('%rocm_wrapper_library_dir', config.rocm_wrapper_library_dir, unresolved='ignore'),
|
Initial boiler-plate for python bindings.
Summary:
* Native '_mlir' extension module.
* Python mlir/__init__.py trampoline module.
* Lit test that checks a message.
* Uses some cmake configurations that have worked for me in the past but likely needs further elaboration.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D83279
2020-07-07 14:05:46 +08:00
|
|
|
ToolSubst('%vulkan_wrapper_library_dir', config.vulkan_wrapper_library_dir, unresolved='ignore'),
|
2019-04-03 01:02:07 +08:00
|
|
|
])
|
|
|
|
|
2019-03-30 13:10:12 +08:00
|
|
|
llvm_config.add_tool_substitutions(tools, tool_dirs)
|
2020-06-12 08:34:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
# FileCheck -enable-var-scope is enabled by default in MLIR test
|
|
|
|
# This option avoids to accidentally reuse variable across -LABEL match,
|
|
|
|
# it can be explicitly opted-in by prefixing the variable name with $
|
|
|
|
config.environment['FILECHECK_OPTS'] = "-enable-var-scope"
|
2020-06-19 11:21:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
# LLVM can be configured with an empty default triple
|
|
|
|
# by passing ` -DLLVM_DEFAULT_TARGET_TRIPLE="" `.
|
|
|
|
# This is how LLVM filters tests that require the host target
|
|
|
|
# to be available for JIT tests.
|
|
|
|
if config.target_triple:
|
|
|
|
config.available_features.add('default_triple')
|
Initial boiler-plate for python bindings.
Summary:
* Native '_mlir' extension module.
* Python mlir/__init__.py trampoline module.
* Lit test that checks a message.
* Uses some cmake configurations that have worked for me in the past but likely needs further elaboration.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes
Tags: #mlir
Differential Revision: https://reviews.llvm.org/D83279
2020-07-07 14:05:46 +08:00
|
|
|
|
|
|
|
# Add the python path for both the source and binary tree.
|
|
|
|
# Note that presently, the python sources come from the source tree and the
|
|
|
|
# binaries come from the build tree. This should be unified to the build tree
|
|
|
|
# by copying/linking sources to build.
|
|
|
|
if config.enable_bindings_python:
|
|
|
|
llvm_config.with_environment('PYTHONPATH', [
|
|
|
|
os.path.join(config.mlir_src_root, "lib", "Bindings", "Python"),
|
|
|
|
os.path.join(config.mlir_obj_root, "lib", "Bindings", "Python"),
|
|
|
|
], append_path=True)
|