diff --git a/mlir/test/CAPI/execution_engine.c b/mlir/test/CAPI/execution_engine.c --- a/mlir/test/CAPI/execution_engine.c +++ b/mlir/test/CAPI/execution_engine.c @@ -9,7 +9,7 @@ /* RUN: mlir-capi-execution-engine-test 2>&1 | FileCheck %s */ -/* REQUIRES: native +/* REQUIRES: host-supports-jit */ #include "mlir-c/Conversion.h" diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt --- a/mlir/test/CMakeLists.txt +++ b/mlir/test/CMakeLists.txt @@ -74,6 +74,8 @@ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py MAIN_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py + PATHS + "CURRENT_TOOLS_DIR" ) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in diff --git a/mlir/test/lit.cfg.py b/mlir/test/lit.cfg.py --- a/mlir/test/lit.cfg.py +++ b/mlir/test/lit.cfg.py @@ -124,3 +124,24 @@ config.available_features.add('asserts') else: config.available_features.add('noasserts') + +def have_host_jit_feature_support(feature_name): + clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir) + + if not clang_repl_exe: + return False + + try: + clang_repl_cmd = subprocess.Popen( + [clang_repl_exe, '--host-supports-' + feature_name], stdout=subprocess.PIPE) + except OSError: + print('could not exec clang-repl') + return False + + clang_repl_out = clang_repl_cmd.stdout.read().decode('ascii') + clang_repl_cmd.wait() + + return 'true' in clang_repl_out + +if have_host_jit_feature_support('jit'): + config.available_features.add('host-supports-jit') diff --git a/mlir/test/lit.site.cfg.py.in b/mlir/test/lit.site.cfg.py.in --- a/mlir/test/lit.site.cfg.py.in +++ b/mlir/test/lit.site.cfg.py.in @@ -32,6 +32,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" config.llvm_host_triple = '@LLVM_HOST_TRIPLE@' config.host_arch = "@HOST_ARCH@" +config.clang_tools_dir = lit_config.substitute(path(r"@CURRENT_TOOLS_DIR@")) config.mlir_src_root = "@MLIR_SOURCE_DIR@" config.mlir_obj_root = "@MLIR_BINARY_DIR@" config.mlir_runner_utils_dir = "@MLIR_RUNNER_UTILS_DIR@" diff --git a/mlir/test/mlir-cpu-runner/lit.local.cfg b/mlir/test/mlir-cpu-runner/lit.local.cfg --- a/mlir/test/mlir-cpu-runner/lit.local.cfg +++ b/mlir/test/mlir-cpu-runner/lit.local.cfg @@ -9,7 +9,7 @@ config.unsupported = True # Requires native execution. -if 'native' not in config.available_features: +if 'host-supports-jit' not in config.available_features: config.unsupported = True config.available_features.add( diff --git a/mlir/test/python/execution_engine.py b/mlir/test/python/execution_engine.py --- a/mlir/test/python/execution_engine.py +++ b/mlir/test/python/execution_engine.py @@ -1,5 +1,5 @@ # RUN: %PYTHON %s 2>&1 | FileCheck %s -# REQUIRES: native +# REQUIRES: host-supports-jit import gc, sys from mlir.ir import * from mlir.passmanager import * diff --git a/mlir/unittests/ExecutionEngine/Invoke.cpp b/mlir/unittests/ExecutionEngine/Invoke.cpp --- a/mlir/unittests/ExecutionEngine/Invoke.cpp +++ b/mlir/unittests/ExecutionEngine/Invoke.cpp @@ -30,6 +30,13 @@ #include "gmock/gmock.h" +// SPARC currently lacks JIT support. +#ifdef __sparc__ +#define SKIP_WITHOUT_JIT(x) DISABLED_##x +#else +#define SKIP_WITHOUT_JIT(x) x +#endif + using namespace mlir; // The JIT isn't supported on Windows at that time @@ -54,7 +61,7 @@ return pm.run(module); } -TEST(MLIRExecutionEngine, AddInteger) { +TEST(MLIRExecutionEngine, SKIP_WITHOUT_JIT(AddInteger)) { std::string moduleStr = R"mlir( func.func @foo(%arg0 : i32) -> i32 attributes { llvm.emit_c_interface } { %res = arith.addi %arg0, %arg0 : i32 @@ -80,7 +87,7 @@ ASSERT_EQ(result, 42 + 42); } -TEST(MLIRExecutionEngine, SubtractFloat) { +TEST(MLIRExecutionEngine, SKIP_WITHOUT_JIT(SubtractFloat)) { std::string moduleStr = R"mlir( func.func @foo(%arg0 : f32, %arg1 : f32) -> f32 attributes { llvm.emit_c_interface } { %res = arith.subf %arg0, %arg1 : f32 @@ -106,7 +113,7 @@ ASSERT_EQ(result, 42.f); } -TEST(NativeMemRefJit, ZeroRankMemref) { +TEST(NativeMemRefJit, SKIP_WITHOUT_JIT(ZeroRankMemref)) { OwningMemRef a({}); a[{}] = 42.; ASSERT_EQ(*a->data, 42); @@ -136,7 +143,7 @@ EXPECT_EQ(&elt, &(a[{}])); } -TEST(NativeMemRefJit, RankOneMemref) { +TEST(NativeMemRefJit, SKIP_WITHOUT_JIT(RankOneMemref)) { int64_t shape[] = {9}; OwningMemRef a(shape); int count = 1; @@ -176,7 +183,7 @@ } } -TEST(NativeMemRefJit, BasicMemref) { +TEST(NativeMemRefJit, SKIP_WITHOUT_JIT(BasicMemref)) { constexpr int k = 3; constexpr int m = 7; // Prepare arguments beforehand. @@ -236,7 +243,7 @@ #if __has_feature(memory_sanitizer) #define MAYBE_JITCallback DISABLED_JITCallback #else -#define MAYBE_JITCallback JITCallback +#define MAYBE_JITCallback SKIP_WITHOUT_JIT(JITCallback) #endif TEST(NativeMemRefJit, MAYBE_JITCallback) { constexpr int k = 2;