summaryrefslogtreecommitdiff
path: root/caffe2/perfkernels
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2017-11-20 16:10:41 -0800
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2017-11-20 16:17:51 -0800
commit335c7dc6812ae8224a96d73f9f41d725be658ff0 (patch)
tree677c472ac198ce99850c36c6ec7c52b25c3daf28 /caffe2/perfkernels
parentad3e619198bf2f8d0b1968380b57745c2c49271f (diff)
downloadpytorch-335c7dc6812ae8224a96d73f9f41d725be658ff0.tar.gz
pytorch-335c7dc6812ae8224a96d73f9f41d725be658ff0.tar.bz2
pytorch-335c7dc6812ae8224a96d73f9f41d725be658ff0.zip
Fix perfkernel compile error on clang 3.8
Summary: Closes #1483. Closes https://github.com/caffe2/caffe2/pull/1489 Reviewed By: bddppq Differential Revision: D6376107 Pulled By: pietern fbshipit-source-id: 892f74d67629609ed82c991cfd94508cf8e23c29
Diffstat (limited to 'caffe2/perfkernels')
-rw-r--r--caffe2/perfkernels/cvtsh_ss_bugfix.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/caffe2/perfkernels/cvtsh_ss_bugfix.h b/caffe2/perfkernels/cvtsh_ss_bugfix.h
index 8d3a7026f8..4353b85965 100644
--- a/caffe2/perfkernels/cvtsh_ss_bugfix.h
+++ b/caffe2/perfkernels/cvtsh_ss_bugfix.h
@@ -16,11 +16,21 @@
#pragma once
+// Apple clang was fixed in 8.1
#if defined(__apple_build_version__) && ((__clang_major__ < 8) || ((__clang_major__ == 8) && (__clang_minor__ < 1)))
+#define __APPLE_NEED_FIX 1
+#endif
+
+// Regular clang was fixed in 3.9
+#if defined(__clang__) && (__clang_major__ < 4) && (__clang__minor__ < 9)
+#define __CLANG_NEED_FIX 1
+#endif
+
+#if __APPLE_NEED_FIX || __CLANG_NEED_FIX
#include <emmintrin.h>
-// This version of apple clang has a bug that _cvtsh_ss is not defined, see
+// This version of clang has a bug that _cvtsh_ss is not defined, see
// https://reviews.llvm.org/D16177
static __inline float
__attribute__((__always_inline__, __nodebug__, __target__("f16c")))
@@ -31,7 +41,10 @@ _cvtsh_ss(unsigned short a)
return r[0];
}
-#endif // defined(__APPLE__) && (__clang_major__ < 8)
+#endif // __APPLE_NEED_FIX || __CLANG_NEED_FIX
+
+#undef __APPLE_NEED_FIX
+#undef __CLANG_NEED_FIX
#ifdef _MSC_VER