-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
104 lines (92 loc) · 3.44 KB
/
CMakeLists.txt
File metadata and controls
104 lines (92 loc) · 3.44 KB
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
# convwinograd CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
project(ConvWinograd VERSION 1.0 LANGUAGES C)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Add $ENV{LD_LIBRARY_PATH} to CMAKE_PREFIX_PATH
if (DEFINED ENV{LD_LIBRARY_PATH})
string(REPLACE ":" ";" LD_LIBRARY_PATH_AS_LIST $ENV{LD_LIBRARY_PATH})
list(APPEND CMAKE_PREFIX_PATH "${LD_LIBRARY_PATH_AS_LIST}")
endif ()
find_package(OpenMP REQUIRED)
# ========================================================================
# Find BLAS and record which version has been found
# ------------------------------------------------------------------------
set(SUPPORTED_VENDORS FLAME;Intel10_64ilp)
set(CBLAS_TYPES CBLAS;CBLAS)
if (BLA_VENDOR)
if (BLA_VENDOR STREQUAL "None")
set(CBLAS_TYPE "OURS")
else ()
foreach (VENDOR TYPE IN ZIP_LISTS SUPPORTED_VENDORS CBLAS_TYPES)
if (BLA_VENDOR STREQUAL ${VENDOR})
message(STATUS "Searching CBLAS for BLA_VENDOR=${BLA_VENDOR}...")
set(CBLAS_TYPE ${TYPE})
find_package(BLAS)
continue()
endif ()
endforeach ()
if (NOT CBLAS_TYPE)
message(SEND_ERROR "BLA_VENDOR '${BLA_VENDOR}' is not supported (see README.md)!")
else ()
if (BLAS_FOUND)
message(STATUS "...${CBLAS_TYPE} (${BLA_VENDOR}) found!")
else ()
message(SEND_ERROR "CBLAS for BLA_VENDOR=${BLA_VENDOR} not found!")
endif ()
endif ()
endif ()
else ()
message(STATUS "BLA_VENDOR not specified, search supported vendors...")
foreach (VENDOR TYPE IN ZIP_LISTS SUPPORTED_VENDORS CBLAS_TYPES)
set(BLA_VENDOR ${VENDOR})
set(CBLAS_TYPE ${TYPE})
find_package(BLAS)
if (BLAS_FOUND)
message(STATUS "...${CBLAS_TYPE} (${BLA_VENDOR}) found!")
break()
endif ()
endforeach ()
if (NOT BLAS_FOUND)
message(SEND_ERROR "CBLAS not found! Set -D BLA_VENDOR=None to force the bundled one.")
endif ()
endif ()
if (BLAS_FOUND)
add_compile_options(-DCBLAS_TYPE_${CBLAS_TYPE} -DBLA_VENDOR_${BLA_VENDOR})
if (BLAS_LIBRARIES)
list(GET BLAS_LIBRARIES 0 FIRST_BLAS_LIBRARY)
get_filename_component(FIRST_BLAS_LIBRARY_PATH ${FIRST_BLAS_LIBRARY} DIRECTORY)
include_directories(SYSTEM PUBLIC
"${FIRST_BLAS_LIBRARY_PATH}/../include"
"${FIRST_BLAS_LIBRARY_PATH}/../include/blis"
)
endif ()
endif ()
# ========================================================================
# ========================================================================
# Common compilation options and include directories
# ------------------------------------------------------------------------
# Common compilation options to all objects
add_compile_options(
-O3 -mtune=native -march=native
-ftree-vectorize
-fopenmp
-fPIC
)
# Include SYSTEM directories (no compilation warnings due to these)
include_directories(
SYSTEM PUBLIC
"${CMAKE_INSTALL_PREFIX}/include"
)
if (CMAKE_PREFIX_PATH)
include_directories(
SYSTEM PUBLIC
"${CMAKE_PREFIX_PATH}/include"
"${CMAKE_PREFIX_PATH}"
)
endif ()
# ========================================================================
add_subdirectory(src)
option(COMPILE_TESTS "Compile tests" OFF)
if (COMPILE_TESTS)
add_subdirectory(tests)
endif ()