/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include #include "paddle/utils/CpuId.h" #include "paddle/utils/Logging.h" #include "paddle/utils/Util.h" using namespace paddle; // NOLINT TEST(SIMDFlags, gccTest) { #if (defined(__GNUC__) || defined(__GNUG__)) && !(defined(__clang__)) CHECK(__builtin_cpu_supports("sse") == HAS_SSE); CHECK(__builtin_cpu_supports("sse2") == HAS_SSE2); CHECK(__builtin_cpu_supports("sse3") == HAS_SSE3); CHECK(__builtin_cpu_supports("ssse3")== HAS_SSSE3); CHECK(__builtin_cpu_supports("sse4.1")== HAS_SSE41); CHECK(__builtin_cpu_supports("sse4.2")== HAS_SSE42); CHECK(__builtin_cpu_supports("fma3")== HAS_FMA3); CHECK(__builtin_cpu_supports("fma4")== HAS_FMA4); CHECK(__builtin_cpu_supports("avx")== HAS_AVX); CHECK(__builtin_cpu_supports("avx2")== HAS_AVX2); CHECK(__builtin_cpu_supports("avx512f")== HAS_AVX512); #endif } TEST(SIMDFlags, normalPrint) { auto simd = SIMDFlags::instance(); LOG(INFO) << "Has SSE2: " << std::boolalpha << simd->isSSE2(); LOG(INFO) << "Has SSE3: " << std::boolalpha << simd->isSSE3(); LOG(INFO) << "Has SSSE3: " << std::boolalpha << simd->isSSSE3(); LOG(INFO) << "Has SSE4.1: " << std::boolalpha << simd->isSSE41(); LOG(INFO) << "Has SSE4.2: " << std::boolalpha << simd->isSSE42(); LOG(INFO) << "Has FMA3: " << std::boolalpha << simd->isFMA3(); LOG(INFO) << "Has FMA4: " << std::boolalpha << simd->isFMA4(); LOG(INFO) << "Has AVX: " << std::boolalpha << simd->isAVX(); LOG(INFO) << "Has AVX2: " << std::boolalpha << simd->isAVX2(); LOG(INFO) << "Has AVX512: " << std::boolalpha << simd->isAVX512(); } int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); paddle::initMain(argc, argv); return RUN_ALL_TESTS(); }