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() { return true; }
41 #else
42 bool CPLHaveRuntimeSSE();
43 #endif
44 #endif
45
46 #ifdef HAVE_SSSE3_AT_COMPILE_TIME
47 #if __SSSE3__
48 #define HAVE_INLINE_SSSE3
49 static bool inline CPLHaveRuntimeSSSE3()
50 {
51 #ifdef DEBUG
52 if( !CPLTestBool(CPLGetConfigOption("GDAL_USE_SSSE3", "YES")) )
53 return false;
54 #endif
55 return true;
56 }
57 #else
58 #if defined(__GNUC__) && !defined(DEBUG)
59 extern bool bCPLHasSSSE3;
60 static bool inline CPLHaveRuntimeSSSE3() { return bCPLHasSSSE3; }
61 #else
62 bool CPLHaveRuntimeSSSE3();
63 #endif
64 #endif
65 #endif
66
67 #ifdef HAVE_AVX_AT_COMPILE_TIME
68 #if __AVX__
69 #define HAVE_INLINE_AVX
70 static bool inline CPLHaveRuntimeAVX() { return true; }
71 #elif defined(__GNUC__)
72 extern bool bCPLHasAVX;
73 static bool inline CPLHaveRuntimeAVX() { return bCPLHasAVX; }
74 #else
75 bool CPLHaveRuntimeAVX();
76 #endif
77 #endif
78
80
81 #endif // CPL_CPU_FEATURES_H
CPLTestBool
bool CPLTestBool(const char *pszValue)
Test what boolean value contained in the string.
Definition: cpl_string.cpp:1542
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:1678