LibreOffice Module tools (master) 1
cpuid.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 */
10
11#pragma once
12
13#include <sal/config.h>
14#include <tools/toolsdllapi.h>
16#include <rtl/ustring.hxx>
17
18/*
19
20Do NOT include this header in source files compiled with CPU-specific code.
21TODO: For the header to be safe that way, it should be free of any templates
22or inline functions, otherwise their possibly emitted copies compiled
23with the CPU-specific instructions might be chosen by the linker as the copy
24to keep.
25
26Also see the note at the top of simdsupport.hxx .
27
28*/
29
30namespace cpuid {
31
33{
34 NONE = 0x00,
35 HYPER = 0x01,
36 SSE2 = 0x02,
37 SSSE3 = 0x04,
38 SSE41 = 0x08,
39 SSE42 = 0x10,
40 AVX = 0x20,
41 AVX2 = 0x40,
42 AVX512F = 0x80
43};
44
45} // end cpuid
46
47namespace o3tl {
48 template<> struct typed_flags<cpuid::InstructionSetFlags> : is_typed_flags<cpuid::InstructionSetFlags, 0x0ff> {};
49}
50
51namespace cpuid {
52
56
60
64
67inline bool hasSSE2()
68{
70}
71
74inline bool hasSSSE3()
75{
77}
78
81inline bool hasAVX()
82{
84}
85
88inline bool hasAVX2()
89{
91}
92
95inline bool hasAVX512F()
96{
98}
99
102inline bool hasHyperThreading()
103{
105}
106
107} // end cpuid
108
109/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
NONE
Definition: cpuid.cxx:15
OUString instructionSetSupportedString()
Returns a string of supported instructions.
Definition: cpuid.cxx:118
bool isCpuInstructionSetSupported(InstructionSetFlags eInstructions)
Check if a certain instruction set is supported by the CPU at runtime.
Definition: cpuid.cxx:112
bool hasSSE2()
Check if SSE2 is supported by the CPU.
Definition: cpuid.hxx:67
bool hasAVX()
Check if AVX is supported by the CPU.
Definition: cpuid.hxx:81
bool hasAVX512F()
Check if AVX512F is supported by the CPU.
Definition: cpuid.hxx:95
bool hasSSSE3()
Check if SSSE3 is supported by the CPU.
Definition: cpuid.hxx:74
bool hasHyperThreading()
Check if Hyper Threading is supported.
Definition: cpuid.hxx:102
bool hasAVX2()
Check if AVX2 is supported by the CPU.
Definition: cpuid.hxx:88
InstructionSetFlags
Definition: cpuid.hxx:33
InstructionSetFlags getCpuInstructionSetFlags()
Get supported instruction set flags determined at runtime by probing the CPU.
Definition: cpuid.cxx:61
#define TOOLS_DLLPUBLIC
Definition: toolsdllapi.h:28