forked from dpiparo/vdt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
218 lines (180 loc) · 7.09 KB
/
CMakeLists.txt
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
# VDT Math Library
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project (Vdt)
#-------------------------------------------------------------------------------
# Include the defaults
include ( CMakeDefaults.txt )
#-------------------------------------------------------------------------------
# configuration options -- you may change them when running cmake ==============
# with 'cmake -D <OPT>=<value> .'
option( DIAG "Build in diagnostic mode - all diagnostic exes (default cache entry: OFF)" OFF)
option( AVX "Use AVX instruction set (default cache entry: OFF)" OFF)
option( AVX2 "Use AVX2 instruction set (default cache entry: OFF)" OFF)
option( FMA "Use FMA instruction set (default cache entry: OFF)" OFF)
option( USERFLAGS "Pass arbitrary flags to the compiler")
option( SSE "Use SSE instruction set (default cache entry: ON)" ON)
option( NEON "Use NEON instruction set (default cache entry: OFF)" OFF)
option( BUILD_SHARED_LIBS "Build libraries as SHARED instead of STATIC (default cache entry: ON)" ON)
option( PRELOAD "Create in the library the symbols to preload the library (default cache entry: OFF)" OFF)
option( USE_VC "Use Vc library - requires symlink to Vc from ${CMAKE_SOURCE_DIR} (default cache entry: OFF)" OFF)
option( DEBUG "Compile library with debug symbols (default is OFF)" OFF)
message(${CMAKE_CXX_COMPILER_ID})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
message(FATAL_ERROR "VDT requires GCC version >= 4.8")
set(COMP_IS_GCC TRUE)
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "VDT requires AppleClang version >= 5.0")
endif()
set(COMP_IS_CLANG TRUE)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
message(FATAL_ERROR "VDT requires Clang version >= 3.3")
endif()
set(COMP_IS_CLANG TRUE)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0)
message(FATAL_ERROR "VDT requires ICC >= 15.0")
set(COMP_IS_ICC TRUE)
endif()
else()
message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang, ICC and GCC.")
endif()
# SIMD and FMA instructions set-------------------------------------------------
if (NEON)
message(STATUS "Using NEON instructions!")
set(PACKED_INSTR "-mfpu=neon ")
else()
if (SSE AND (NOT (AVX OR AVX2) ))
message(STATUS "Using SSE instructions!")
set(PACKED_INSTR "-msse")
endif ()
if (AVX AND (NOT AVX2))
message(STATUS "Using AVX instructions!")
set (PACKED_INSTR "-mavx")
if(CMAKE_COMPILER_IS_ICC)
set(PACKED_INSTR "-xavx")
endif()
endif ()
if (AVX2)
message(STATUS "Using AVX2 instructions!")
set (PACKED_INSTR "-mavx2")
if(CMAKE_COMPILER_IS_ICC)
set(PACKED_INSTR "-xavx2")
endif()
endif ()
if (FMA)
message(STATUS "Using FMA instructions!")
set (FMA_INSTR "-mfma")
endif ()
endif()
# To use svml at CERN ----------------------------------------------------------
set (INTEL_SVML_FLAGS "")
if (SVML)
message (STATUS "Linking SVML library")
set (INTEL_SVML_FLAGS "-mveclibabi=svml -L/afs/cern.ch/sw/IntelSoftware/linux/x86_64/Compiler/11.1/072/lib/intel64/ -lsvml -lirc")
endif (SVML)
# Vc setup ---------------------------------------------------------------------
if(USE_VC)
message(STATUS "VC usage is turned on now, if you do not intend to use it, run 'cmake -D USE_VC=0 .'")
set (VC_SYMLINK_MSG "To use Vc you must have a (symlink) 'Vc' leading to the Vc rootdir in your ${CMAKE_SOURCE_DIR}")
#check for files
set (VC_LIB_NAME "${CMAKE_SOURCE_DIR}/Vc/libVc.a")
set (VC_HEADER_NAME "${CMAKE_SOURCE_DIR}/Vc/include/Vc/Vc")
if(NOT EXISTS ${VC_LIB_NAME})
message(STATUS "Vc lib not found at ${VC_LIB_NAME}, turning off Vc usage")
message(STATUS ${VC_SYMLINK_MSG})
change_option(USE_VC 0)
endif(NOT EXISTS ${VC_LIB_NAME})
if (EXISTS ${VC_LIB_NAME})
if(NOT EXISTS ${VC_HEADER_NAME})
message(STATUS "Vc header not found at ${VC_HEADER_NAME}, turning off Vc usage")
message(STATUS ${VC_SYMLINK_MSG})
change_option(USE_VC 0)
endif(NOT EXISTS ${VC_HEADER_NAME})
endif(EXISTS ${VC_LIB_NAME})
link_directories( ${CMAKE_SOURCE_DIR}/Vc )
endif(USE_VC)
# set compiler options =========================================================
if(DIAG)
# Library for time measurement: OSx and Linux
set (LIBTIMING "rt")
# do not set it if on OSx
if (APPLE AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
set (LIBTIMINGAPPLE "-framework Carbon")
endif ()
endif(DIAG)
#-------------------------------------------------------------------------------
# Compiler optimisations
set (VECT_OPT "-Ofast")
if (CMAKE_COMPILER_IS_ICC)
set (VECT_OPT "")
endif()
if (${COMP_IS_GCC})
set (VECTORIZER_VERBOSITY "-ftree-vectorizer-verbose=0")
set (INLINE_OPT " --param vect-max-version-for-alias-checks=50 --param inline-unit-growth=150")
endif()
set (CPP11_OPT "-std=c++11")
set (VERBOSITY_OPT "-Winline")
# set it for clang until it understands __always_inline
set (CLANG_INLINE_DEFINE "")
if (${COMP_IS_CLANG})
set (CLANG_INLINE_DEFINE "-D__extern_always_inline=inline")
endif()
# compiler dependent changes ---------------------------------------------------
if(${COMP_IS_ICC})
set (VECTORIZER_VERBOSITY "")
set (INLINE_OPT "")
endif()
set (WARNING_FLAGS "-W -Wall -Werror -Wno-error=unused-parameter")
if (DEBUG)
set (DEBUG_FLAGS " -g")
message(STATUS "Adding debugging symbols")
endif ()
set (COMMON_FLAGS "${CPP11_OPT} ${INTEL_SVML_FLAGS} ${PACKED_INSTR} ${FMA_INSTR} ${INLINE_OPT} ${WARNING_FLAGS} ${DEBUG_FLAGS} ${CLANG_INLINE_DEFINE}")
if (USERFLAGS)
set (COMMON_FLAGS "${COMMON_FLAGS} ${USERFLAGS}")
endif()
set (LIB_FLAGS "${VERBOSITY_OPT} ${VECT_OPT} ${VECTORIZER_VERBOSITY} ${COMMON_FLAGS}")
set (DIAG_FLAGS "${LIBTIMINGAPPLE} ${VECT_OPT} ${COMMON_FLAGS}")
# Locations ====================================================================
# Location of executables
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin )
# Location of sources
set( SRC_DIR ${CMAKE_SOURCE_DIR}/src )
# Location of library
set( LIB_DIR ${CMAKE_SOURCE_DIR}/lib )
# Common Includes
set (INC_DIR ${CMAKE_SOURCE_DIR}/include )
#-------------------------------------------------------------------------------
add_subdirectory( src )
add_subdirectory( lib )
if (DIAG)
message("DIAG option is now on, building diagnostic programs")
add_subdirectory( progs )
add_subdirectory( progs/units )
else(DIAG)
message("DIAG option is now off, building library only")
endif(DIAG)
#-------------------------------------------------------------------------------
# Installation
# Install location
INSTALL(FILES
include/asin.h
include/atan.h
include/tanh.h
include/atan2.h
include/cos.h
include/exp.h
include/identity.h
include/inv.h
include/log.h
include/sincos.h
include/sin.h
include/sqrt.h
include/tan.h
include/vdtcore_common.h
include/vdtMath.h
DESTINATION include/vdt)