1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 #include <sal/config.h>
14 #include <tools/toolsdllapi.h>
15 #include <o3tl/typed_flags_set.hxx>
16 #include <rtl/ustring.hxx>
20 Do NOT include this header in source files compiled with CPU-specific code.
21 TODO: For the header to be safe that way, it should be free of any templates
22 or inline functions, otherwise their possibly emitted copies compiled
23 with the CPU-specific instructions might be chosen by the linker as the copy
26 Also see the note at the top of simdsupport.hxx .
32 enum class InstructionSetFlags
48 template<> struct typed_flags
<cpuid::InstructionSetFlags
> : is_typed_flags
<cpuid::InstructionSetFlags
, 0x0ff> {};
53 /** Get supported instruction set flags determined at runtime by probing the CPU.
55 TOOLS_DLLPUBLIC InstructionSetFlags
getCpuInstructionSetFlags();
57 /** Check if a certain instruction set is supported by the CPU at runtime.
59 TOOLS_DLLPUBLIC
bool isCpuInstructionSetSupported(InstructionSetFlags eInstructions
);
61 /** Returns a string of supported instructions.
63 TOOLS_DLLPUBLIC OUString
instructionSetSupportedString();
65 /** Check if SSE2 is supported by the CPU
69 return isCpuInstructionSetSupported(InstructionSetFlags::SSE2
);
72 /** Check if SSSE3 is supported by the CPU
74 inline bool hasSSSE3()
76 return isCpuInstructionSetSupported(InstructionSetFlags::SSSE3
);
79 /** Check if AVX is supported by the CPU
83 return isCpuInstructionSetSupported(InstructionSetFlags::AVX
);
86 /** Check if AVX2 is supported by the CPU
90 return isCpuInstructionSetSupported(InstructionSetFlags::AVX2
);
93 /** Check if AVX512F is supported by the CPU
95 inline bool hasAVX512F()
97 return isCpuInstructionSetSupported(InstructionSetFlags::AVX512F
);
100 /** Check if Hyper Threading is supported
102 inline bool hasHyperThreading()
104 return isCpuInstructionSetSupported(InstructionSetFlags::HYPER
);
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */