From ea67737b166fc6cb5fd98874fbd2b4639b2d7ecd Mon Sep 17 00:00:00 2001 From: Kern Handa Date: Thu, 9 Jan 2020 22:55:31 +0100 Subject: [mlir] mlir-cpu-runner test's cblas_interface should export functions on Windows This change fixes the build on Windows, so that cblas_interface.dll exports functions correctly and an implib is created and installed correctly. Currently, LLVM cannot be consumed on Windows after it has been installed in a location because cblas_interface.lib is not created/installed, thus failing the import check in `LLVMExports.cmake`. Differential Revision: https://reviews.llvm.org/D72384 --- mlir/test/mlir-cpu-runner/CMakeLists.txt | 2 +- mlir/test/mlir-cpu-runner/cblas_interface.cpp | 1 + mlir/test/mlir-cpu-runner/include/cblas.h | 6 +-- .../test/mlir-cpu-runner/include/cblas_interface.h | 58 ++++++++++++++++++++++ .../mlir-cpu-runner/include/mlir_runner_utils.h | 6 +-- 5 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 mlir/test/mlir-cpu-runner/include/cblas_interface.h (limited to 'mlir/test/mlir-cpu-runner') diff --git a/mlir/test/mlir-cpu-runner/CMakeLists.txt b/mlir/test/mlir-cpu-runner/CMakeLists.txt index 94f50a4..13aaa89 100644 --- a/mlir/test/mlir-cpu-runner/CMakeLists.txt +++ b/mlir/test/mlir-cpu-runner/CMakeLists.txt @@ -9,7 +9,7 @@ target_compile_definitions(cblas PRIVATE cblas_EXPORTS) 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/cblas_interface.cpp b/mlir/test/mlir-cpu-runner/cblas_interface.cpp index 5e3a00e..4065dc1 100644 --- a/mlir/test/mlir-cpu-runner/cblas_interface.cpp +++ b/mlir/test/mlir-cpu-runner/cblas_interface.cpp @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// +#include "include/cblas_interface.h" #include "include/cblas.h" #include #include diff --git a/mlir/test/mlir-cpu-runner/include/cblas.h b/mlir/test/mlir-cpu-runner/include/cblas.h index ccd316f..d365cd2 100644 --- a/mlir/test/mlir-cpu-runner/include/cblas.h +++ b/mlir/test/mlir-cpu-runner/include/cblas.h @@ -18,11 +18,11 @@ #else /* We are using this library */ #define MLIR_CBLAS_EXPORT __declspec(dllimport) -#endif -#endif +#endif // cblas_EXPORTS +#endif // MLIR_CBLAS_EXPORT #else #define MLIR_CBLAS_EXPORT -#endif +#endif // _WIN32 /// This reproduces a minimal subset of cblas to allow integration testing /// without explicitly requiring a dependence on an external library. diff --git a/mlir/test/mlir-cpu-runner/include/cblas_interface.h b/mlir/test/mlir-cpu-runner/include/cblas_interface.h new file mode 100644 index 0000000..a831281 --- /dev/null +++ b/mlir/test/mlir-cpu-runner/include/cblas_interface.h @@ -0,0 +1,58 @@ +//===- cblas_interface.h - Simple Blas subset interface -------------------===// +// +// Part of the MLIR 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_CBLAS_INTERFACE_H_ +#define MLIR_CPU_RUNNER_CBLAS_INTERFACE_H_ + +#include "mlir_runner_utils.h" + +#ifdef _WIN32 +#ifndef MLIR_CBLAS_INTERFACE_EXPORT +#ifdef cblas_interface_EXPORTS +/* We are building this library */ +#define MLIR_CBLAS_INTERFACE_EXPORT __declspec(dllexport) +#else +/* We are using this library */ +#define MLIR_CBLAS_INTERFACE_EXPORT __declspec(dllimport) +#endif // cblas_interface_EXPORTS +#endif // MLIR_CBLAS_INTERFACE_EXPORT +#else +#define MLIR_CBLAS_INTERFACE_EXPORT +#endif // _WIN32 + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_fill_viewf32_f32(StridedMemRefType *X, float f); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_fill_viewsxf32_f32(StridedMemRefType *X, float f); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_fill_viewsxsxf32_f32(StridedMemRefType *X, float f); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_copy_viewf32_viewf32(StridedMemRefType *I, + StridedMemRefType *O); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_copy_viewsxf32_viewsxf32(StridedMemRefType *I, + StridedMemRefType *O); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_copy_viewsxsxf32_viewsxsxf32(StridedMemRefType *I, + StridedMemRefType *O); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_dot_viewsxf32_viewsxf32_viewf32(StridedMemRefType *X, + StridedMemRefType *Y, + StridedMemRefType *Z); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_matmul_viewsxsxf32_viewsxsxf32_viewsxsxf32( + StridedMemRefType *A, StridedMemRefType *B, + StridedMemRefType *C); + +#endif // MLIR_CPU_RUNNER_CBLAS_INTERFACE_H_ diff --git a/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h b/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h index 768d08c..925e2b1 100644 --- a/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h +++ b/mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h @@ -20,11 +20,11 @@ #else /* We are using this library */ #define MLIR_RUNNER_UTILS_EXPORT __declspec(dllimport) -#endif -#endif +#endif // mlir_runner_utils_EXPORTS +#endif // MLIR_RUNNER_UTILS_EXPORT #else #define MLIR_RUNNER_UTILS_EXPORT -#endif +#endif // _WIN32 template struct StridedMemRefType; template -- cgit v1.1