diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -110,6 +110,9 @@ add_subdirectory(test) endif() if (MLIR_INCLUDE_INTEGRATION_TESTS) + set(INTEL_SDE_EXECUTABLE "" CACHE STRING + "If set, arch.-specific integration tests are run with Intel SDE.") + option(MLIR_RUN_AVX512_TESTS "Run AVX512 tests.") add_definitions(-DMLIR_INCLUDE_INTEGRATION_TESTS) add_subdirectory(integration_test) endif() diff --git a/mlir/integration_test/CMakeLists.txt b/mlir/integration_test/CMakeLists.txt --- a/mlir/integration_test/CMakeLists.txt +++ b/mlir/integration_test/CMakeLists.txt @@ -3,6 +3,7 @@ set(MLIR_INTEGRATION_TEST_DEPENDS FileCheck count not + lli mlir-cpu-runner mlir-opt mlir_runner_utils diff --git a/mlir/integration_test/Dialect/Vector/CPU/AVX512/lit.local.cfg b/mlir/integration_test/Dialect/Vector/CPU/AVX512/lit.local.cfg new file mode 100644 --- /dev/null +++ b/mlir/integration_test/Dialect/Vector/CPU/AVX512/lit.local.cfg @@ -0,0 +1,15 @@ +import sys + +# AVX512 tests must be enabled via build flag. +if config.mlir_run_avx512_tests != 'ON': + config.unsupported = True + +# No JIT on win32. +if sys.platform == 'win32': + config.unsupported = True + +if config.intel_sde_executable: + # Run test in emulator (Intel SDE). + config.substitutions.append(('%lli', config.intel_sde_executable + ' -tgl -- lli')) +else: + config.substitutions.append(('%lli', 'lli')) diff --git a/mlir/integration_test/Dialect/Vector/CPU/AVX512/test-vp2intersect-i32.mlir b/mlir/integration_test/Dialect/Vector/CPU/AVX512/test-vp2intersect-i32.mlir new file mode 100644 --- /dev/null +++ b/mlir/integration_test/Dialect/Vector/CPU/AVX512/test-vp2intersect-i32.mlir @@ -0,0 +1,52 @@ +// RUN: mlir-opt %s -convert-scf-to-std -convert-vector-to-llvm="enable-avx512" -convert-std-to-llvm | \ +// RUN: mlir-translate --avx512-mlir-to-llvmir | \ +// RUN: %lli --entry-function=entry --mattr="avx512bw,avx512vp2intersect" --dlopen=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext | \ +// RUN: FileCheck %s + +// Note: To run this test, your CPU ust support AVX512 vp2intersect. + +func @entry() -> i32 { + %i0 = constant 0 : i32 + %i1 = constant 1: i32 + %i2 = constant 2: i32 + %i3 = constant 7: i32 + %i4 = constant 12: i32 + %i5 = constant -10: i32 + %i6 = constant -219: i32 + + %v0 = vector.broadcast %i1 : i32 to vector<16xi32> + %v1 = vector.insert %i2, %v0[1] : i32 into vector<16xi32> + %v2 = vector.insert %i3, %v1[4] : i32 into vector<16xi32> + %v3 = vector.insert %i4, %v2[6] : i32 into vector<16xi32> + %v4 = vector.insert %i5, %v3[7] : i32 into vector<16xi32> + %v5 = vector.insert %i0, %v4[10] : i32 into vector<16xi32> + %v6 = vector.insert %i0, %v5[12] : i32 into vector<16xi32> + %v7 = vector.insert %i3, %v6[13] : i32 into vector<16xi32> + %v8 = vector.insert %i3, %v7[14] : i32 into vector<16xi32> + %v9 = vector.insert %i0, %v8[15] : i32 into vector<16xi32> + vector.print %v9 : vector<16xi32> + // CHECK: ( 1, 2, 1, 1, 7, 1, 12, -10, 1, 1, 0, 1, 0, 7, 7, 0 ) + + %w0 = vector.broadcast %i1 : i32 to vector<16xi32> + %w1 = vector.insert %i2, %w0[4] : i32 into vector<16xi32> + %w2 = vector.insert %i6, %w1[7] : i32 into vector<16xi32> + %w3 = vector.insert %i4, %w2[8] : i32 into vector<16xi32> + %w4 = vector.insert %i4, %w3[9] : i32 into vector<16xi32> + %w5 = vector.insert %i4, %w4[10] : i32 into vector<16xi32> + %w6 = vector.insert %i0, %w5[11] : i32 into vector<16xi32> + %w7 = vector.insert %i0, %w6[12] : i32 into vector<16xi32> + %w8 = vector.insert %i0, %w7[13] : i32 into vector<16xi32> + %w9 = vector.insert %i0, %w8[15] : i32 into vector<16xi32> + vector.print %w9 : vector<16xi32> + // CHECK: ( 1, 1, 1, 1, 2, 1, 1, -219, 12, 12, 12, 0, 0, 0, 1, 0 ) + + %k1, %k2 = avx512.vp2intersect %v9, %w9 : vector<16xi32> + + vector.print %k1 : vector<16xi1> + // CHECK: ( 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1 ) + + vector.print %k2 : vector<16xi1> + // CHECK: ( 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1 ) + + return %i0 : i32 +} diff --git a/mlir/integration_test/lit.site.cfg.py.in b/mlir/integration_test/lit.site.cfg.py.in --- a/mlir/integration_test/lit.site.cfg.py.in +++ b/mlir/integration_test/lit.site.cfg.py.in @@ -33,6 +33,8 @@ config.mlir_obj_root = "@MLIR_BINARY_DIR@" config.mlir_tools_dir = "@MLIR_TOOLS_DIR@" config.mlir_integration_test_dir = "@MLIR_INTEGRATION_TEST_DIR@" +config.intel_sde_executable = "@INTEL_SDE_EXECUTABLE@" +config.mlir_run_avx512_tests = "@MLIR_RUN_AVX512_TESTS@" # Support substitution of the tools_dir with user parameters. This is # used when we can't determine the tool dir at configuration time.