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
25 static bool inline CPLHaveRuntimeSSE()
26{
27 return true;
28}
29#else
30 bool CPLHaveRuntimeSSE();
31#endif
32#endif
33
34#ifdef USE_NEON_OPTIMIZATIONS
35 static bool inline CPLHaveRuntimeSSSE3()
36{
37 return true;
38}
39#elif defined(HAVE_SSSE3_AT_COMPILE_TIME)
40#if __SSSE3__
41#define HAVE_INLINE_SSSE3
42
43 static bool inline CPLHaveRuntimeSSSE3()
44{
45#ifdef DEBUG
46 if (!CPLTestBool(CPLGetConfigOption("GDAL_USE_SSSE3", "YES")))
47 return false;
48#endif
49 return true;
50}
51#else
52#if defined(__GNUC__) && !defined(DEBUG)
53 extern bool bCPLHasSSSE3;
54
55 static bool inline CPLHaveRuntimeSSSE3()
56{
57 return bCPLHasSSSE3;
58}
59#else
60 bool CPLHaveRuntimeSSSE3();
61#endif
62#endif
63#endif
64
65#ifdef HAVE_AVX_AT_COMPILE_TIME
66#if __AVX__
67#define HAVE_INLINE_AVX
68
69 static bool inline CPLHaveRuntimeAVX()
70{
71 return true;
72}
73#elif defined(__GNUC__)
74 extern bool bCPLHasAVX;
75
76 static bool inline CPLHaveRuntimeAVX()
77{
78 return bCPLHasAVX;
79}
80#else
81 bool CPLHaveRuntimeAVX();
82#endif
83#endif
84
86
87#endif // CPL_CPU_FEATURES_H
cpl_port.h
Core portability definitions for CPL.
cpl_string.h
Various convenience functions for working with strings and string lists.