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.
|
2021-05-19 21:10:28 +08:00
|
|
|
config.suffixes = ['.td', '.mlir', '.toy', '.ll', '.tc', '.py', '.yaml', '.test']
|
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',
|
2021-04-22 05:33:04 +08:00
|
|
|
'mlir-lsp-server',
|
2020-08-05 20:36:16 +08:00
|
|
|
'mlir-capi-ir-test',
|
2020-11-04 05:38:34 +08:00
|
|
|
'mlir-capi-pass-test',
|
2021-02-03 03:09:45 +08:00
|
|
|
'mlir-cpu-runner',
|
2021-05-19 21:10:28 +08:00
|
|
|
'mlir-linalg-ods-yaml-gen',
|
2021-02-03 03:09:45 +08:00
|
|
|
'mlir-reduce',
|
2019-03-30 13:10:12 +08:00
|
|
|
]
|
2019-04-03 01:02:07 +08:00
|
|
|
|
|
|
|
# The following tools are optional
|
|
|
|
tools.extend([
|
|
|
|
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-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][mlir-spirv-cpu-runner] A SPIR-V cpu runner prototype
This patch introduces a SPIR-V runner. The aim is to run a gpu
kernel on a CPU via GPU -> SPIRV -> LLVM conversions. This is a first
prototype, so more features will be added in due time.
- Overview
The runner follows similar flow as the other runners in-tree. However,
having converted the kernel to SPIR-V, we encode the bind attributes of
global variables that represent kernel arguments. Then SPIR-V module is
converted to LLVM. On the host side, we emulate passing the data to device
by creating in main module globals with the same symbolic name as in kernel
module. These global variables are later linked with ones from the nested
module. We copy data from kernel arguments to globals, call the kernel
function from nested module and then copy the data back.
- Current state
At the moment, the runner is capable of running 2 modules, nested one in
another. The kernel module must contain exactly one kernel function. Also,
the runner supports rank 1 integer memref types as arguments (to be scaled).
- Enhancement of JitRunner and ExecutionEngine
To translate nested modules to LLVM IR, JitRunner and ExecutionEngine were
altered to take an optional (default to `nullptr`) function reference that
is a custom LLVM IR module builder. This allows to customize LLVM IR module
creation from MLIR modules.
Reviewed By: ftynse, mravishankar
Differential Revision: https://reviews.llvm.org/D86108
2020-10-23 22:46:18 +08:00
|
|
|
ToolSubst('%spirv_wrapper_library_dir', config.spirv_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'),
|
2021-02-23 08:56:01 +08:00
|
|
|
ToolSubst('%mlir_integration_test_dir', config.mlir_integration_test_dir, unresolved='ignore'),
|
2019-04-03 01:02:07 +08:00
|
|
|
])
|
2021-10-03 09:24:07 +08:00
|
|
|
|
|
|
|
python_executable = config.python_executable
|
|
|
|
# Python configuration with sanitizer requires some magic preloading. This will only work on clang/linux.
|
|
|
|
# TODO: detect Darwin/Windows situation (or mark these tests as unsupported on these platforms).
|
|
|
|
if "asan" in config.available_features and "Linux" in config.host_os:
|
|
|
|
python_executable = f"LD_PRELOAD=$({config.host_cxx} -print-file-name=libclang_rt.asan-{config.host_arch}.so) {config.python_executable}"
|
|
|
|
tools.extend([
|
|
|
|
ToolSubst('%PYTHON', python_executable, unresolved='ignore'),
|
|
|
|
])
|
|
|
|
|
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 $
|
2020-10-31 05:25:49 +08:00
|
|
|
config.environment['FILECHECK_OPTS'] = "-enable-var-scope --allow-unused-prefixes=false"
|
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', [
|
2021-07-23 03:57:41 +08:00
|
|
|
os.path.join(config.mlir_obj_root, 'python_packages', 'mlir_core'),
|
|
|
|
os.path.join(config.mlir_obj_root, 'python_packages', 'mlir_test'),
|
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
|
|
|
], append_path=True)
|
2021-07-15 10:13:30 +08:00
|
|
|
|
|
|
|
if config.enable_assertions:
|
|
|
|
config.available_features.add('asserts')
|
|
|
|
else:
|
|
|
|
config.available_features.add('noasserts')
|