diff options
author | Kern Handa <kern.handa@gmail.com> | 2020-01-09 22:55:31 +0100 |
---|---|---|
committer | Alex Zinenko <zinenko@google.com> | 2020-01-09 22:55:46 +0100 |
commit | ea67737b166fc6cb5fd98874fbd2b4639b2d7ecd (patch) | |
tree | 8d0c29f4d127f0098c1d89675ca3bf6938ae6d92 /mlir/test | |
parent | 8c387cbea76b169f1f8ecc7693797e96567ed896 (diff) | |
download | llvm-ea67737b166fc6cb5fd98874fbd2b4639b2d7ecd.zip llvm-ea67737b166fc6cb5fd98874fbd2b4639b2d7ecd.tar.gz llvm-ea67737b166fc6cb5fd98874fbd2b4639b2d7ecd.tar.bz2 |
[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
Diffstat (limited to 'mlir/test')
-rw-r--r-- | mlir/test/mlir-cpu-runner/CMakeLists.txt | 2 | ||||
-rw-r--r-- | mlir/test/mlir-cpu-runner/cblas_interface.cpp | 1 | ||||
-rw-r--r-- | mlir/test/mlir-cpu-runner/include/cblas.h | 6 | ||||
-rw-r--r-- | mlir/test/mlir-cpu-runner/include/cblas_interface.h | 58 | ||||
-rw-r--r-- | mlir/test/mlir-cpu-runner/include/mlir_runner_utils.h | 6 |
5 files changed, 66 insertions, 7 deletions
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 <assert.h> #include <iostream> 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<float, 0> *X, float f); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_fill_viewsxf32_f32(StridedMemRefType<float, 1> *X, float f); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_fill_viewsxsxf32_f32(StridedMemRefType<float, 2> *X, float f); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_copy_viewf32_viewf32(StridedMemRefType<float, 0> *I, + StridedMemRefType<float, 0> *O); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_copy_viewsxf32_viewsxf32(StridedMemRefType<float, 1> *I, + StridedMemRefType<float, 1> *O); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_copy_viewsxsxf32_viewsxsxf32(StridedMemRefType<float, 2> *I, + StridedMemRefType<float, 2> *O); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_dot_viewsxf32_viewsxf32_viewf32(StridedMemRefType<float, 1> *X, + StridedMemRefType<float, 1> *Y, + StridedMemRefType<float, 0> *Z); + +extern "C" MLIR_CBLAS_INTERFACE_EXPORT void +linalg_matmul_viewsxsxf32_viewsxsxf32_viewsxsxf32( + StridedMemRefType<float, 2> *A, StridedMemRefType<float, 2> *B, + StridedMemRefType<float, 2> *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 <typename T, int N> struct StridedMemRefType; template <typename StreamType, typename T, int N> |