Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/google/ruy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Jacob <benoitjacob@google.com>2020-10-15 20:34:19 +0300
committerCopybara-Service <copybara-worker@google.com>2020-10-15 20:34:44 +0300
commit503dd7899d6fdf784b7d37032a74575d89f60d04 (patch)
tree2085a853cf0d9f005c243973e0c661a2c8018e25
parent3c363dc10d06857ad489c034ebb3bbd6d273dfbd (diff)
Enable x86 SIMD code paths on MSVC 2019 and similarly-versioned Clang-CL.
Also add a missing #include. PiperOrigin-RevId: 337337611
-rw-r--r--ruy/kernel_x86.h7
-rw-r--r--ruy/platform.h4
2 files changed, 8 insertions, 3 deletions
diff --git a/ruy/kernel_x86.h b/ruy/kernel_x86.h
index 5681a43..3ad05bf 100644
--- a/ruy/kernel_x86.h
+++ b/ruy/kernel_x86.h
@@ -17,6 +17,7 @@ limitations under the License.
#define RUY_RUY_KERNEL_X86_H_
#include <cstdint>
+#include <cstring>
#include "ruy/kernel_common.h"
#include "ruy/mat.h"
@@ -262,7 +263,7 @@ inline __m256i mm256_shuffle_epi8(const __m256i&, const __m256i&) {
// Polyfill for _mm_storeu_si16(dst, v).
template <Path path>
inline void mm_storeu_si16(void* dst, __m128i v) {
-#if defined __clang__
+#if (defined __clang__) || (defined __MSC_VER)
_mm_storeu_si16(dst, v);
#else
// GCC 9 lacks support for __mm_storeu_si16.
@@ -273,7 +274,7 @@ inline void mm_storeu_si16(void* dst, __m128i v) {
// Polyfill for _mm_storeu_si32(dst, v).
template <Path path>
inline void mm_storeu_si32(void* dst, __m128i v) {
-#if defined __clang__
+#if (defined __clang__) || (defined __MSC_VER)
_mm_storeu_si32(dst, v);
#else
// GCC 9 lacks support for __mm_storeu_si32.
@@ -284,7 +285,7 @@ inline void mm_storeu_si32(void* dst, __m128i v) {
// Polyfill for _mm_loadu_si32(src).
template <Path path>
inline __m128i mm_loadu_si32(const void* src) {
-#if defined __clang__
+#if (defined __clang__) || (defined __MSC_VER)
return _mm_loadu_si32(src);
#else
// GCC 9 lacks support for _mm_loadu_si32.
diff --git a/ruy/platform.h b/ruy/platform.h
index c8bed3a..942feac 100644
--- a/ruy/platform.h
+++ b/ruy/platform.h
@@ -118,6 +118,10 @@ limitations under the License.
// Enable on recent versions of GCC. Might be possible
// to relax this version requirement.
#define RUY_PLATFORM_X86_ENHANCEMENTS 1
+// Things are working on MSVC 2019. This should also enable on sufficiently
+// recent Clang-CL.
+#elif defined(_MSC_VER) && (_MSC_VER >= 1920)
+#define RUY_PLATFORM_X86_ENHANCEMENTS 1
#else
#define RUY_PLATFORM_X86_ENHANCEMENTS 0
#endif