blob: db53dd576763663dd731d7b32bf8a964f90d0bf7 (
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
cmake_minimum_required(VERSION 2.8)
project(ffts C ASM)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# default build type is Debug which means no optimization
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif(NOT CMAKE_BUILD_TYPE)
# common options
option(ENABLE_NEON
"Enables the use of NEON instructions." OFF
)
option(ENABLE_VFP
"Enables the use of VFP instructions." OFF
)
option(DISABLE_DYNAMIC_CODE
"Disables the use of dynamic machine code generation." OFF
)
option(ENABLE_RUNTIME_DYNAMIC_CODE
"Enables the runtime generation of dynamic machine code." ON
)
option(ENABLE_SHARED
"Enable building a shared library." OFF
)
include(CheckCSourceCompiles)
include(CheckIncludeFile)
include(CheckSymbolExists)
include(CMakePushCheckState)
add_definitions(-DFFTS_CMAKE_GENERATED)
# check existence of various headers
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
check_include_file(unistd.h HAVE_UNISTD_H)
if(HAVE_STDINT_H)
add_definitions(-DHAVE_STDINT_H)
endif(HAVE_STDINT_H)
if(HAVE_STDLIB_H)
add_definitions(-DHAVE_STDLIB_H)
endif(HAVE_STDLIB_H)
if(HAVE_STRING_H)
add_definitions(-DHAVE_STRING_H)
endif(HAVE_STRING_H)
if(HAVE_SYS_MMAN_H)
add_definitions(-DHAVE_SYS_MMAN_H)
endif(HAVE_SYS_MMAN_H)
if(HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif(HAVE_UNISTD_H)
# Determinate if we are cross-compiling
if(NOT CMAKE_CROSSCOMPILING)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
# Determinate what floating-point hardware
# (or hardware emulation) is available
#
cmake_push_check_state()
# Try to execute quietly without messages
set(CMAKE_REQUIRED_QUIET 1)
# Test compilation with -mfpu=neon
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mfpu=neon")
check_symbol_exists(exit stdlib.h NEON_AVAILABLE)
if(NOT NEON_AVAILABLE)
cmake_reset_check_state()
# Test compilation with -mfpu=vfp
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mfpu=vfp")
check_symbol_exists(exit stdlib.h VFP_AVAILABLE)
if(NOT VFP_AVAILABLE)
message(WARNING "FFTS is using 'soft' FPU")
else()
message("FFTS is using 'vfp' FPU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfp")
set(ENABLE_NEON 0)
set(ENABLE_VFP 1)
endif(NOT SOFTFP_AVAILABLE)
else()
message("FFTS is using 'neon' FPU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon")
set(ENABLE_NEON 1)
set(ENABLE_VFP 0)
endif(NOT NEON_AVAILABLE)
# Determinate float ABI if NEON or VFP is used
if(NEON_AVAILABLE OR VFP_AVAILABLE)
cmake_push_check_state()
# Test compilation with -mfloat-abi=hard
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mfloat-abi=hardfp")
check_symbol_exists(exit stdlib.h HARDFP_AVAILABLE)
if(NOT HARDFP_AVAILABLE)
cmake_reset_check_state()
# Test compilation with -mfloat-abi=hard
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mfloat-abi=softfp")
check_symbol_exists(exit stdlib.h SOFTFP_AVAILABLE)
if(NOT SOFTFP_AVAILABLE)
# Most likely development libraries are missing
message(WARNING "FFTS is using 'soft' float ABI")
else()
message("FFTS is using 'softfp' float ABI")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp")
endif(NOT SOFTFP_AVAILABLE)
else()
message(WARNING "FFTS is using 'hard' float ABI")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard")
endif(NOT HARDFP_AVAILABLE)
cmake_pop_check_state()
endif(NEON_AVAILABLE OR VFP_AVAILABLE)
cmake_pop_check_state()
else()
# check if the platform has support for SSE intrinsics
check_include_file(xmmintrin.h HAVE_XMMINTRIN_H)
if(HAVE_XMMINTRIN_H)
add_definitions(-DHAVE_SSE)
endif(HAVE_XMMINTRIN_H)
# check if the platform has support for SSE2 intrinsics
check_include_file(emmintrin.h HAVE_EMMINTRIN_H)
if(HAVE_EMMINTRIN_H)
add_definitions(-DHAVE_SSE2)
endif(HAVE_EMMINTRIN_H)
# check if the platform has support for SSE3 intrinsics
check_include_file(pmmintrin.h HAVE_PMMINTRIN_H)
if(HAVE_PMMINTRIN_H)
add_definitions(-DHAVE_PMMINTRIN_H)
add_definitions(-DHAVE_SSE3)
else()
# check if the platform has specific intrinsics
check_include_file(intrin.h HAVE_INTRIN_H)
if(HAVE_INTRIN_H)
check_c_source_compiles("
#include<intrin.h>
int main(int argc, char** argv)
{
(void) argv;
(void) argc;
return _mm_movemask_ps(_mm_moveldup_ps(_mm_set_ss(1.0f)));
}" HAVE__MM_MOVELDUP_PS
)
if(HAVE__MM_MOVELDUP_PS)
# assume that we have all SSE3 intrinsics
add_definitions(-DHAVE_INTRIN_H)
add_definitions(-DHAVE_SSE3)
endif(HAVE__MM_MOVELDUP_PS)
endif(HAVE_INTRIN_H)
endif(HAVE_PMMINTRIN_H)
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
else()
# Check if we can always use detection code above?
endif(NOT CMAKE_CROSSCOMPILING)
# compiler settings
if(MSVC)
# enable all warnings but also disable some..
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /wd4127")
add_definitions(-D_USE_MATH_DEFINES)
elseif(CMAKE_COMPILER_IS_GNUCC)
include(CheckLibraryExists)
# enable all warnings
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
# some systems need libm for some of the math functions to work
check_library_exists(m pow "" HAVE_LIBM)
if(HAVE_LIBM)
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
list(APPEND FFTS_EXTRA_LIBRARIES m)
endif(HAVE_LIBM)
if(HAVE_EMMINTRIN_H)
add_definitions(-msse2)
elseif(HAVE_XMMINTRIN_H)
add_definitions(-msse)
endif(HAVE_EMMINTRIN_H)
endif(MSVC)
include_directories(include)
include_directories(src)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(FFTS_HEADERS
include/ffts.h
)
set(FFTS_SOURCES
src/ffts_attributes.h
src/ffts.c
src/ffts_internal.h
src/ffts_nd.c
src/ffts_nd.h
src/ffts_real.h
src/ffts_real.c
src/ffts_real_nd.c
src/ffts_real_nd.h
src/ffts_trig.c
src/ffts_trig.h
src/ffts_static.c
src/ffts_static.h
src/macros.h
src/patterns.c
src/patterns.h
src/types.h
)
if(ENABLE_NEON)
if(DISABLE_DYNAMIC_CODE)
list(APPEND FFTS_SOURCES
src/neon_static_f.s
src/neon_static_i.s
)
else()
list(APPEND FFTS_SOURCES
src/neon.s
)
endif(DISABLE_DYNAMIC_CODE)
add_definitions(-DHAVE_NEON)
elseif(ENABLE_VFP)
if(NOT DISABLE_DYNAMIC_CODE)
list(APPEND FFTS_SOURCES
src/vfp.s
)
endif(NOT DISABLE_DYNAMIC_CODE)
add_definitions(-DHAVE_VFP)
elseif(HAVE_XMMINTRIN_H)
add_definitions(-DHAVE_SSE)
list(APPEND FFTS_SOURCES
src/macros-sse.h
)
if(NOT DISABLE_DYNAMIC_CODE)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND FFTS_SOURCES
src/codegen_sse.h
)
else()
message(WARNING "Dynamic code is only supported with x64, disabling dynamic code.")
set(DISABLE_DYNAMIC_CODE ON)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
endif(NOT DISABLE_DYNAMIC_CODE)
endif(ENABLE_NEON)
if(DISABLE_DYNAMIC_CODE)
add_definitions(-DDYNAMIC_DISABLED)
else()
list(APPEND FFTS_SOURCES
src/codegen.c
src/codegen.h
)
endif(DISABLE_DYNAMIC_CODE)
add_library(ffts_static
${FFTS_HEADERS}
${FFTS_SOURCES}
)
add_executable(ffts_test
tests/test.c
)
target_link_libraries(ffts_test
ffts_static
${FFTS_EXTRA_LIBRARIES}
)
|