GDAL

cpl_cpu_features.h
1 /******************************************************************************
2 *
3 * Project: CPL - Common Portability Library
4 * Purpose: Prototypes, and definitions for of CPU features detection
5 * Author: Even Rouault, <even dot rouault at spatialys dot com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2016, Even Rouault <even dot rouault at spatialys dot com>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 ****************************************************************************/
28
29 #ifndef CPL_CPU_FEATURES_H
30 #define CPL_CPU_FEATURES_H
31
32 #include "cpl_port.h"
33 #include "cpl_string.h"
34
36
37 #ifdef HAVE_SSE_AT_COMPILE_TIME
38 #if (defined(_M_X64) || defined(__x86_64))
39 #define HAVE_INLINE_SSE
40 static bool inline CPLHaveRuntimeSSE()
41 {
42 return true;
43 }
44 #else
45 bool CPLHaveRuntimeSSE();
46 #endif
47 #endif
48
49 #ifdef HAVE_SSSE3_AT_COMPILE_TIME
50 #if __SSSE3__
51 #define HAVE_INLINE_SSSE3
52 static bool inline CPLHaveRuntimeSSSE3()
53 {
54 #ifdef DEBUG
55 if (!CPLTestBool(CPLGetConfigOption("GDAL_USE_SSSE3", "YES")))
56 return false;
57 #endif
58 return true;
59 }
60 #else
61 #if defined(__GNUC__) && !defined(DEBUG)
62 extern bool bCPLHasSSSE3;
63 static bool inline CPLHaveRuntimeSSSE3()
64 {
65 return bCPLHasSSSE3;
66 }
67 #else
68 bool CPLHaveRuntimeSSSE3();
69 #endif
70 #endif
71 #endif
72
73 #ifdef HAVE_AVX_AT_COMPILE_TIME
74 #if __AVX__
75 #define HAVE_INLINE_AVX
76 static bool inline CPLHaveRuntimeAVX()
77 {
78 return true;
79 }
80 #elif defined(__GNUC__)
81 extern bool bCPLHasAVX;
82 static bool inline CPLHaveRuntimeAVX()
83 {
84 return bCPLHasAVX;
85 }
86 #else
87 bool CPLHaveRuntimeAVX();
88 #endif
89 #endif
90
92
93 #endif // CPL_CPU_FEATURES_H
CPLTestBool
bool CPLTestBool(const char *pszValue)
Test what boolean value contained in the string.
Definition: cpl_string.cpp:1558
cpl_string.h
cpl_port.h
CPLGetConfigOption
const char * CPLGetConfigOption(const char *, const char *)
Get the value of a configuration option.
Definition: cpl_conv.cpp:1688