-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
121 lines (89 loc) · 4.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
# Check cmake version.
cmake_minimum_required (VERSION 2.8)
# Project specification.
project (GSKS)
set (GSKS_VERSION_MAJOR 1)
set (GSKS_VERSION_MINOR 1)
set (GSKS_VERSION_PATCH 0)
set (GSKS_VERSION ${GSKS_VERSION_MAJOR}.${GSKS_VERSION_MINOR}.${GSKS_VERSION_PATCH})
# Configure the path structure.
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_RELEASE_POSTFIX "")
set (CMAKE_DEBUG_POSTFIX "-debug")
# Turn on testing.
ENABLE_TESTING()
# Decide architecture
set (GSKS_ARCH_MAJOR $ENV{GSKS_ARCH_MAJOR})
set (GSKS_ARCH_MINOR $ENV{GSKS_ARCH_MINOR})
set (GSKS_ARCH ${GSKS_ARCH_MAJOR}/${GSKS_ARCH_MINOR})
# Compiler Options (GSKS can use Intel or GNU compilers.)
if ($ENV{GSKS_USE_INTEL} MATCHES "true")
set (CMAKE_C_COMPILER icc )
set (CMAKE_CXX_COMPILER icpc)
set (GSKS_CFLAGS "-O3 -qopenmp -mavx -Werror -Wall -pedantic")
set (CMAKE_EXE_LINKER_FLAGS "-lpthread -qopenmp -lm")
else ($ENV{GSKS_USE_INTEL} MATCHES "true")
set (CMAKE_C_COMPILER gcc)
set (CMAKE_CXX_COMPILER g++)
set (GSKS_CFLAGS "-O3 -fopenmp -mavx")
set (CMAKE_EXE_LINKER_FLAGS "-lpthread -fopenmp -lm")
endif ($ENV{GSKS_USE_INTEL} MATCHES "true")
if ($ENV{GSKS_USE_VML} MATCHES "true")
if ($ENV{GSKS_USE_INTEL} MATCHES "true")
set (GSKS_CFLAGS "${GSKS_CFLAGS} -DUSE_VML")
endif ($ENV{GSKS_USE_INTEL} MATCHES "true")
endif ($ENV{GSKS_USE_VML} MATCHES "true")
if ($ENV{GSKS_MIC_AVX512} MATCHES "true")
if ($ENV{GSKS_USE_INTEL} MATCHES "true")
set (GSKS_CFLAGS "${GSKS_CFLAGS} -xMIC-AVX512 -DGSKS_MIC_AVX512")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lmemkind")
endif ($ENV{GSKS_USE_INTEL} MATCHES "true")
endif ($ENV{GSKS_MIC_AVX512} MATCHES "true")
if ($ENV{GSKS_USE_BLAS} MATCHES "true")
set (GSKS_CFLAGS "${GSKS_CFLAGS} -DUSE_BLAS")
endif ($ENV{GSKS_USE_BLAS} MATCHES "true")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSKS_CFLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GSKS_CFLAGS}")
# Linking infos.
if (($ENV{GSKS_USE_BLAS} MATCHES "true") OR ($ENV{GSKS_USE_VML} MATCHES "true"))
if ($ENV{GSKS_USE_INTEL} MATCHES "true")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mkl=parallel")
else ($ENV{GSKS_USE_INTEL} MATCHES "true")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lblas")
endif ($ENV{GSKS_USE_INTEL} MATCHES "true")
endif (($ENV{GSKS_USE_BLAS} MATCHES "true") OR ($ENV{GSKS_USE_VML} MATCHES "true"))
# Software dependencies.
set (MKL_DIR $ENV{GSKS_MKL_DIR})
# Headers.
include_directories ("include" "${CMAKE_SOURCE_DIR}/micro_kernel/${GSKS_ARCH}" "${MKL_DIR}/include")
file (GLOB GSKS_HDRS ${CMAKE_SOURCE_DIR}/include/*)
install (FILES ${GSKS_HDRS} DESTINATION ${CMAKE_BINARY_DIR}/include)
# Library dependencies
file (GLOB FRAME_CC_SRC ${CMAKE_SOURCE_DIR}/frame/*.c)
file (GLOB FRAME_CXX_SRC ${CMAKE_SOURCE_DIR}/frame/*.cpp)
file (GLOB KERNEL_SRC ${CMAKE_SOURCE_DIR}/micro_kernel/${GSKS_ARCH}/*.c)
# Build the static library.
add_library (gsks ${FRAME_CC_SRC} ${FRAME_CXX_SRC} ${KERNEL_SRC})
# Build the executable files.
add_executable (test_dgsks.x ${CMAKE_SOURCE_DIR}/test/test_dgsks.c)
target_link_libraries(test_dgsks.x gsks)
add_executable (test_dgsks_list.x ${CMAKE_SOURCE_DIR}/test/test_dgsks_list.cpp)
target_link_libraries(test_dgsks_list.x gsks)
# Install shell script
file (GLOB GSKS_SCRIPTS ${CMAKE_SOURCE_DIR}/test/*.sh)
install (FILES ${GSKS_SCRIPTS} DESTINATION ${CMAKE_BINARY_DIR}/bin)
# Report
message ("===================================================")
message ("Version =${GSKS_VERSION}")
message ("Source =${CMAKE_SOURCE_DIR}")
message ("Target =${CMAKE_BINARY_DIR}")
message ("GSKS_ARCH =${GSKS_ARCH}")
message ("CC =${CMAKE_C_COMPILER}")
message ("CFLAGS =${CMAKE_C_FLAGS}")
message ("CXX =${CMAKE_CXX_COMPILER}")
message ("CXXFLAGS =${CMAKE_CXX_FLAGS}")
message ("Linker =${CMAKE_EXE_LINKER_FLAGS}")
message ("MKLDIR =${MKL_DIR}")
message ("===================================================")