blob: 968def53996f256d87a1385499d1e5b130789289 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/* Chrysalide - Outil d'analyse de fichiers binaires
* cpu.c - obtention d'indications de fonctionnalités liées au CPU
*
* Copyright (C) 2022 Cyrille Bagard
*
* This file is part of Chrysalide.
*
* Chrysalide is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Chrysalide is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Chrysalide. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cpu.h"
/******************************************************************************
* *
* Paramètres : - *
* *
* Description : Indique les capacités de calculs parallèles anticipées. *
* *
* Retour : Fonctionnalités disponibles lors de la compilation. *
* *
* Remarques : - *
* *
******************************************************************************/
CPUSMIDFeature get_supported_cpu_smid_feature(void)
{
CPUSMIDFeature result; /* Indications à retourner */
result = CSF_NONE;
/**
* $ gcc -mavx512f -dM -E - < /dev/null | grep AVX
* #define __AVX512F__ 1
* #define __AVX__ 1
* #define __AVX2__ 1
*/
#ifdef __AVX2__
result |= CSF_AVX2;
#endif
#ifdef __AVX512F__
result |= CSF_AVX512;
#endif
return result;
}
/******************************************************************************
* *
* Paramètres : - *
* *
* Description : Indique les capacités de calculs parallèles sollicitables. *
* *
* Retour : Fonctionnalités disponibles dans l'environnement. *
* *
* Remarques : - *
* *
******************************************************************************/
CPUSMIDFeature get_avalaible_cpu_smid_feature(void)
{
CPUSMIDFeature result; /* Indications à retourner */
result = CSF_NONE;
/**
* Cf. Documentations suivantes :
* - https://www.intel.com/content/dam/develop/external/us/en/documents/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family.pdf
* - https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html
*/
__builtin_cpu_init();
if (__builtin_cpu_supports("ssse3"))
result |= CSF_AVX2;
if (__builtin_cpu_supports("avx512f"))
result |= CSF_AVX512;
return result;
}
|