提交 bf534270 编写于 作者: L liaogang

Fix bugs on SIMD flags and unit test

上级 5c480d6f
...@@ -28,10 +28,6 @@ limitations under the License. */ ...@@ -28,10 +28,6 @@ limitations under the License. */
namespace paddle { namespace paddle {
/// init simd instance
static InitFunction __init_simd_flags(
[]{ SIMDFlags::instance(); }, std::numeric_limits<int>::max());
SIMDFlags::SIMDFlags() { SIMDFlags::SIMDFlags() {
unsigned int cpuInfo[4]; unsigned int cpuInfo[4];
// CPUID: https://en.wikipedia.org/wiki/CPUID // CPUID: https://en.wikipedia.org/wiki/CPUID
......
...@@ -24,17 +24,17 @@ public: ...@@ -24,17 +24,17 @@ public:
static SIMDFlags* instance(); static SIMDFlags* instance();
inline bool isSSE() { return simd_flags_ & SIMD_SSE; } inline bool isSSE() const { return simd_flags_ & SIMD_SSE; }
inline bool isSSE2() { return simd_flags_ & SIMD_SSE2; } inline bool isSSE2() const { return simd_flags_ & SIMD_SSE2; }
inline bool isSSE3() { return simd_flags_ & SIMD_SSE3; } inline bool isSSE3() const { return simd_flags_ & SIMD_SSE3; }
inline bool isSSSE3() { return simd_flags_ & SIMD_SSSE3; } inline bool isSSSE3() const { return simd_flags_ & SIMD_SSSE3; }
inline bool isSSE41() { return simd_flags_ & SIMD_SSE41; } inline bool isSSE41() const { return simd_flags_ & SIMD_SSE41; }
inline bool isSSE42() { return simd_flags_ & SIMD_SSE42; } inline bool isSSE42() const { return simd_flags_ & SIMD_SSE42; }
inline bool isFMA3() { return simd_flags_ & SIMD_FMA3; } inline bool isFMA3() const { return simd_flags_ & SIMD_FMA3; }
inline bool isFMA4() { return simd_flags_ & SIMD_FMA4; } inline bool isFMA4() const { return simd_flags_ & SIMD_FMA4; }
inline bool isAVX() { return simd_flags_ & SIMD_AVX; } inline bool isAVX() const { return simd_flags_ & SIMD_AVX; }
inline bool isAVX2() { return simd_flags_ & SIMD_AVX2; } inline bool isAVX2() const { return simd_flags_ & SIMD_AVX2; }
inline bool isAVX512() { return simd_flags_ & SIMD_AVX512;} inline bool isAVX512()const { return simd_flags_ & SIMD_AVX512;}
private: private:
enum simd_t { enum simd_t {
......
...@@ -20,14 +20,14 @@ using namespace paddle; // NOLINT ...@@ -20,14 +20,14 @@ using namespace paddle; // NOLINT
TEST(SIMDFlags, gccTest) { TEST(SIMDFlags, gccTest) {
#if (defined(__GNUC__) || defined(__GNUG__)) && !(defined(__clang__)) #if (defined(__GNUC__) || defined(__GNUG__)) && !(defined(__clang__))
CHECK(__builtin_cpu_supports("sse") == HAS_SSE); CHECK(!__builtin_cpu_supports("sse") != HAS_SSE);
CHECK(__builtin_cpu_supports("sse2") == HAS_SSE2); CHECK(!__builtin_cpu_supports("sse2") != HAS_SSE2);
CHECK(__builtin_cpu_supports("sse3") == HAS_SSE3); CHECK(!__builtin_cpu_supports("sse3") != HAS_SSE3);
CHECK(__builtin_cpu_supports("ssse3") == HAS_SSSE3); CHECK(!__builtin_cpu_supports("ssse3") != HAS_SSSE3);
CHECK(__builtin_cpu_supports("sse4.1")== HAS_SSE41); CHECK(!__builtin_cpu_supports("sse4.1")!= HAS_SSE41);
CHECK(__builtin_cpu_supports("sse4.2")== HAS_SSE42); CHECK(!__builtin_cpu_supports("sse4.2")!= HAS_SSE42);
CHECK(__builtin_cpu_supports("avx") == HAS_AVX); CHECK(!__builtin_cpu_supports("avx") != HAS_AVX);
CHECK(__builtin_cpu_supports("avx2") == HAS_AVX2); CHECK(!__builtin_cpu_supports("avx2") != HAS_AVX2);
#endif #endif
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册