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 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef CPL_CPU_FEATURES_H
14#define CPL_CPU_FEATURES_H
15
16#include "cpl_port.h"
17#include "cpl_string.h"
18
20
21#ifdef HAVE_SSE_AT_COMPILE_TIME
22#if (defined(_M_X64) || defined(__x86_64))
23#define HAVE_INLINE_SSE
24
25static bool inline CPLHaveRuntimeSSE()
26{
27 return true;
28}
29#else
30bool CPLHaveRuntimeSSE();
31#endif
32#endif
33
34#ifdef HAVE_SSSE3_AT_COMPILE_TIME
35#if __SSSE3__
36#define HAVE_INLINE_SSSE3
37
38static bool inline CPLHaveRuntimeSSSE3()
39{
40#ifdef DEBUG
41 if (!CPLTestBool(CPLGetConfigOption("GDAL_USE_SSSE3", "YES")))
42 return false;
43#endif
44 return true;
45}
46#else
47#if defined(__GNUC__) && !defined(DEBUG)
48extern bool bCPLHasSSSE3;
49
50static bool inline CPLHaveRuntimeSSSE3()
51{
52 return bCPLHasSSSE3;
53}
54#else
55bool CPLHaveRuntimeSSSE3();
56#endif
57#endif
58#endif
59
60#ifdef HAVE_AVX_AT_COMPILE_TIME
61#if __AVX__
62#define HAVE_INLINE_AVX
63
64static bool inline CPLHaveRuntimeAVX()
65{
66 return true;
67}
68#elif defined(__GNUC__)
69extern bool bCPLHasAVX;
70
71static bool inline CPLHaveRuntimeAVX()
72{
73 return bCPLHasAVX;
74}
75#else
76bool CPLHaveRuntimeAVX();
77#endif
78#endif
79
81
82#endif // CPL_CPU_FEATURES_H
const char * CPLGetConfigOption(const char *, const char *)
Get the value of a configuration option.
Definition: cpl_conv.cpp:1680
Core portability definitions for CPL.
Various convenience functions for working with strings and string lists.
bool CPLTestBool(const char *pszValue)
Test what boolean value contained in the string.
Definition: cpl_string.cpp:1542