From fcfd3a281c1d6ffd40e4acc430eba448fa6c8423 Mon Sep 17 00:00:00 2001 From: Nicolas Vasilache Date: Thu, 27 Feb 2020 09:51:15 -0500 Subject: [PATCH] [mlir] NFC - Move runner utils from mlir-cpu-runner to ExecutionEngine Runner utils are useful beyond just CPU and hiding them within the test directory makes it unnecessarily harder to reuse in other projects. --- .../mlir/ExecutionEngine/RunnerUtils.h} | 9 +++++---- mlir/lib/ExecutionEngine/CMakeLists.txt | 9 +++++++++ .../ExecutionEngine/RunnerUtils.cpp} | 4 ++-- mlir/test/CMakeLists.txt | 2 +- mlir/test/mlir-cpu-runner/CMakeLists.txt | 3 --- mlir/test/mlir-cpu-runner/include/cblas.h | 2 +- mlir/test/mlir-cpu-runner/include/cblas_interface.h | 2 +- 7 files changed, 19 insertions(+), 12 deletions(-) rename mlir/{test/mlir-cpu-runner/include/mlir_runner_utils.h => include/mlir/ExecutionEngine/RunnerUtils.h} (98%) rename mlir/{test/mlir-cpu-runner/mlir_runner_utils.cpp => lib/ExecutionEngine/RunnerUtils.cpp} (96%) diff --git a/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h similarity index 98% rename from mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h rename to mlir/include/mlir/ExecutionEngine/RunnerUtils.h index a10317a..13d44d9 100644 --- a/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h +++ b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h @@ -1,12 +1,13 @@ -//===- mlir_runner_utils.h - Utils for debugging MLIR CPU execution -------===// +//===- RunnerUtils.h - Utils for debugging MLIR execution -----------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#ifndef MLIR_CPU_RUNNER_MLIRUTILS_H_ -#define MLIR_CPU_RUNNER_MLIRUTILS_H_ + +#ifndef EXECUTIONENGINE_RUNNERUTILS_H_ +#define EXECUTIONENGINE_RUNNERUTILS_H_ #include #include @@ -291,4 +292,4 @@ extern "C" MLIR_RUNNER_UTILS_EXPORT void print_close(); extern "C" MLIR_RUNNER_UTILS_EXPORT void print_comma(); extern "C" MLIR_RUNNER_UTILS_EXPORT void print_newline(); -#endif // MLIR_CPU_RUNNER_MLIRUTILS_H_ +#endif // EXECUTIONENGINE_RUNNERUTILS_H_ diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt index 9e145ec..d826062 100644 --- a/mlir/lib/ExecutionEngine/CMakeLists.txt +++ b/mlir/lib/ExecutionEngine/CMakeLists.txt @@ -1,3 +1,9 @@ +set(LLVM_OPTIONAL_SOURCES + ExecutionEngine.cpp + RunnerUtils.cpp + OptUtils.cpp + ) + llvm_map_components_to_libnames(outlibs "nativecodegen" "IPO") add_llvm_library(MLIRExecutionEngine ExecutionEngine.cpp @@ -27,3 +33,6 @@ target_link_libraries(MLIRExecutionEngine LLVMTransformUtils ${outlibs}) + +add_llvm_library(MLIRRunnerUtils SHARED RunnerUtils.cpp) +target_compile_definitions(MLIRRunnerUtils PRIVATE mlir_runner_utils_EXPORTS) diff --git a/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp b/mlir/lib/ExecutionEngine/RunnerUtils.cpp similarity index 96% rename from mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp rename to mlir/lib/ExecutionEngine/RunnerUtils.cpp index 984d29d..9ba29ff 100644 --- a/mlir/test/mlir-cpu-runner/mlir_runner_utils.cpp +++ b/mlir/lib/ExecutionEngine/RunnerUtils.cpp @@ -1,4 +1,4 @@ -//===- mlir_runner_utils.cpp - Utils for MLIR CPU execution ---------------===// +//===- RunnerUtils.cpp - Utils for MLIR CPU execution ---------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "include/mlir_runner_utils.h" +#include "mlir/ExecutionEngine/RunnerUtils.h" #include #include diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt index e008bd6..b78b095 100644 --- a/mlir/test/CMakeLists.txt +++ b/mlir/test/CMakeLists.txt @@ -40,7 +40,7 @@ set(MLIR_TEST_DEPENDS mlir-translate cblas cblas_interface - mlir_runner_utils + MLIRRunnerUtils ) if(LLVM_BUILD_EXAMPLES) diff --git a/mlir/test/mlir-cpu-runner/CMakeLists.txt b/mlir/test/mlir-cpu-runner/CMakeLists.txt index 13aaa89..a9d45f0 100644 --- a/mlir/test/mlir-cpu-runner/CMakeLists.txt +++ b/mlir/test/mlir-cpu-runner/CMakeLists.txt @@ -1,7 +1,6 @@ set(LLVM_OPTIONAL_SOURCES cblas.cpp cblas_interface.cpp - mlir_runner_utils.cpp ) add_llvm_library(cblas SHARED cblas.cpp) @@ -11,5 +10,3 @@ add_llvm_library(cblas_interface SHARED cblas_interface.cpp) target_link_libraries(cblas_interface PRIVATE cblas) target_compile_definitions(cblas_interface PRIVATE cblas_interface_EXPORTS) -add_llvm_library(mlir_runner_utils SHARED mlir_runner_utils.cpp) -target_compile_definitions(mlir_runner_utils PRIVATE mlir_runner_utils_EXPORTS) diff --git a/mlir/test/mlir-cpu-runner/include/cblas.h b/mlir/test/mlir-cpu-runner/include/cblas.h index 3699e99..2b57091 100644 --- a/mlir/test/mlir-cpu-runner/include/cblas.h +++ b/mlir/test/mlir-cpu-runner/include/cblas.h @@ -8,7 +8,7 @@ #ifndef MLIR_CPU_RUNNER_CBLAS_H_ #define MLIR_CPU_RUNNER_CBLAS_H_ -#include "mlir_runner_utils.h" +#include "mlir/ExecutionEngine/RunnerUtils.h" #ifdef _WIN32 #ifndef MLIR_CBLAS_EXPORT diff --git a/mlir/test/mlir-cpu-runner/include/cblas_interface.h b/mlir/test/mlir-cpu-runner/include/cblas_interface.h index 8329220..50edbe7 100644 --- a/mlir/test/mlir-cpu-runner/include/cblas_interface.h +++ b/mlir/test/mlir-cpu-runner/include/cblas_interface.h @@ -8,7 +8,7 @@ #ifndef MLIR_CPU_RUNNER_CBLAS_INTERFACE_H_ #define MLIR_CPU_RUNNER_CBLAS_INTERFACE_H_ -#include "mlir_runner_utils.h" +#include "mlir/ExecutionEngine/RunnerUtils.h" #ifdef _WIN32 #ifndef MLIR_CBLAS_INTERFACE_EXPORT -- 2.7.4