[PATCH] D72384: [mlir] mlir-cpu-runner test's cblas_interface should export functions on Windows

Kern Handa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 20:17:26 PST 2020


kernhanda created this revision.
kernhanda added reviewers: ftynse, mehdi_amini, schweitz, jpienaar.
kernhanda added a project: LLVM.
Herald added subscribers: llvm-commits, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, rriddle, mgorny.
kernhanda added a comment.

I don't have commit access, so someone else will have to submit this.


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`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72384

Files:
  mlir/test/mlir-cpu-runner/CMakeLists.txt
  mlir/test/mlir-cpu-runner/cblas_interface.cpp
  mlir/test/mlir-cpu-runner/include/cblas_interface.h


Index: mlir/test/mlir-cpu-runner/include/cblas_interface.h
===================================================================
--- /dev/null
+++ mlir/test/mlir-cpu-runner/include/cblas_interface.h
@@ -0,0 +1,57 @@
+//===- 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
+#endif
+#else
+#define MLIR_CBLAS_INTERFACE_EXPORT
+#endif
+
+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_
Index: mlir/test/mlir-cpu-runner/cblas_interface.cpp
===================================================================
--- mlir/test/mlir-cpu-runner/cblas_interface.cpp
+++ 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>
Index: mlir/test/mlir-cpu-runner/CMakeLists.txt
===================================================================
--- mlir/test/mlir-cpu-runner/CMakeLists.txt
+++ mlir/test/mlir-cpu-runner/CMakeLists.txt
@@ -9,7 +9,7 @@
 
 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)
-


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72384.236750.patch
Type: text/x-patch
Size: 3461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200108/85826f0d/attachment.bin>


More information about the llvm-commits mailing list