This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
174 lines (153 loc) · 6.64 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
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
include(CMakeDependentOption)
# euler version info
project(Euler CXX C)
option(WITH_TEST "Build with test cases" ON)
option(WITH_VNNI "With VNNI/INT8 support" OFF)
option(WITH_DPBF16 "With BF16 dot-product support" OFF)
option(ENABLE_USER_FP16 "User FP16 type support" OFF)
if (NOT DEFINED MT_RUNTIME)
set(MT_RUNTIME "omp")
endif()
STRING(TOLOWER "${MT_RUNTIME}" MT_RUNTIME)
# Build Euler version string
find_package (Git)
if (${GIT_FOUND})
# Get current branch
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE retval
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (${retval})
set(GIT_BRANCH "not-a-git-repo-branch")
endif ()
# Get current commit hash
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE retval
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (${retval})
set(GIT_COMMIT_HASH "not-a-git-repo-hash")
endif ()
else()
set(GIT_BRANCH "no-git-found-branch")
set(GIT_COMMIT_HASH "no-git-found-hash")
endif()
set(EULER_VERSION_MAJOR 0)
set(EULER_VERSION_MINOR 0)
set(EULER_VERSION_PATCH 1)
set(EULER_VERSION
"v${EULER_VERSION_MAJOR}.${EULER_VERSION_MINOR}.${EULER_VERSION_PATCH}+${GIT_BRANCH}.${GIT_COMMIT_HASH}")
message("-- Euler version: " ${EULER_VERSION})
cmake_policy(SET CMP0015 NEW)
cmake_policy(SET CMP0042 NEW)
# expose compiler info
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# general var
set(lib_name "el")
# set build type
if(CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} __build_type)
set (CMAKE_CXX_FLAGS_${__build_type} "")
endif()
# set build flags
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
message(STATUS "Build type is Debug")
set(__debug ON)
set(WITH_TEST ON)
elseif(${CMAKE_BUILD_TYPE} MATCHES "Profiling")
message(STATUS "Build type is Profiling")
set(__profiling ON)
endif()
include("cmake/flags.cmake")
# find src files
file (GLOB __euler_source
src/common/el_log.cpp
src/eld_conv.cpp
src/elx_conv.cpp
src/elx_conv_wino_trans_input.cpp
src/elx_conv_wino_trans_weights.cpp
src/elx_conv_wino_gemm.cpp
src/elx_conv_wino_trans_output.cpp
src/elx_conv_wino.cpp
src/elx_int8_conv_wino_gemm.cpp
src/elx_int8_conv_wino.cpp
src/elx_conv_direct_1x1.cpp
src/elx_int8_conv_direct_1x1.cpp
src/elx_conv_direct.cpp
src/elx_conv_direct_vmg.cpp
src/elx_int8_conv_direct.cpp
src/elx_deconv_direct.cpp
src/elx_int8_conv_direct_depthwise.cpp
src/elx_stream.cpp
src/elx_reorder.cpp
src/el_init.cpp)
set(KGEMM_GEN_DIR ${CMAKE_BINARY_DIR}/kgen)
set(BUILD_KGEMM_GEN_CMD ${KGEMM_GEN_DIR}/elk_gemm_gen.sh)
set(BUILD_U8S8_KGEMM_GEN_CMD ${KGEMM_GEN_DIR}/elk_u8s8_gemm_gen.sh)
set(BUILD_KCONV_GEN_CMD ${KGEMM_GEN_DIR}/elk_conv_gen.sh)
set(BUILD_U8S8_KCONV_GEN_CMD ${KGEMM_GEN_DIR}/elk_u8s8_conv_gen.sh)
set(BUILD_U8S8_DEPTHWISE_KCONV_GEN_CMD ${KGEMM_GEN_DIR}/elk_u8s8_depthwise_conv_gen.sh)
set(BUILD_VMG_KCONV_GEN_CMD ${KGEMM_GEN_DIR}/elk_vmg_conv_gen.sh)
set(BUILD_KGEMM_GEN_SRC1 ${KGEMM_GEN_DIR}/elk_gemm_binder.hxx)
set(BUILD_KGEMM_GEN_SRC2 ${KGEMM_GEN_DIR}/elk_u8s8_gemm_binder.hxx)
set(BUILD_KCONV_GEN_SRC1 ${KGEMM_GEN_DIR}/elk_conv_binder.hxx)
set(BUILD_KCONV_GEN_SRC2 ${KGEMM_GEN_DIR}/elk_u8s8_conv_binder.hxx)
set(BUILD_KCONV_GEN_SRC3 ${KGEMM_GEN_DIR}/elk_vmg_conv_binder.hxx)
set(BUILD_KCONV_GEN_SRC4 ${KGEMM_GEN_DIR}/elk_u8s8_depthwise_conv_binder.hxx)
set(KGEMM_GEN_CMD ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_gemm_gen.sh)
set(U8S8_KGEMM_GEN_CMD ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_u8s8_gemm_gen.sh)
set(KCONV_GEN_CMD ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_conv_gen.sh)
set(VMG_KCONV_GEN_CMD ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_vmg_conv_gen.sh)
set(U8S8_KCONV_GEN_CMD ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_u8s8_conv_gen.sh)
set(U8S8_DEPTHWISE_KCONV_GEN_CMD ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_u8s8_depthwise_conv_gen.sh)
set(KGEMM_GEN_SRC1 ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_gemm_binder.hxx)
set(KGEMM_GEN_SRC2 ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_u8s8_gemm_binder.hxx)
set(KCONV_GEN_SRC1 ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_conv_binder.hxx)
set(KCONV_GEN_SRC2 ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_u8s8_conv_binder.hxx)
set(KCONV_GEN_SRC3 ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_vmg_conv_binder.hxx)
set(KCONV_GEN_SRC4 ${CMAKE_HOME_DIRECTORY}/src/kernel/elk_u8s8_depthwise_conv_binder.hxx)
execute_process(COMMAND mkdir -p ${KGEMM_GEN_DIR})
configure_file(${KGEMM_GEN_CMD} ${BUILD_KGEMM_GEN_CMD} COPYONLY)
configure_file(${U8S8_KGEMM_GEN_CMD} ${BUILD_U8S8_KGEMM_GEN_CMD} COPYONLY)
configure_file(${KCONV_GEN_CMD} ${BUILD_KCONV_GEN_CMD} COPYONLY)
configure_file(${VMG_KCONV_GEN_CMD} ${BUILD_VMG_KCONV_GEN_CMD} COPYONLY)
configure_file(${U8S8_KCONV_GEN_CMD} ${BUILD_U8S8_KCONV_GEN_CMD} COPYONLY)
configure_file(${U8S8_DEPTHWISE_KCONV_GEN_CMD} ${BUILD_U8S8_DEPTHWISE_KCONV_GEN_CMD} COPYONLY)
configure_file(${KGEMM_GEN_SRC1} ${BUILD_KGEMM_GEN_SRC1} COPYONLY)
configure_file(${KGEMM_GEN_SRC2} ${BUILD_KGEMM_GEN_SRC2} COPYONLY)
configure_file(${KCONV_GEN_SRC1} ${BUILD_KCONV_GEN_SRC1} COPYONLY)
configure_file(${KCONV_GEN_SRC2} ${BUILD_KCONV_GEN_SRC2} COPYONLY)
configure_file(${KCONV_GEN_SRC3} ${BUILD_KCONV_GEN_SRC3} COPYONLY)
configure_file(${KCONV_GEN_SRC4} ${BUILD_KCONV_GEN_SRC4} COPYONLY)
execute_process(COMMAND ${BUILD_KGEMM_GEN_CMD} ${BUILD_KGEMM_GEN_SRC1}
${KGEMM_GEN_DIR} ${CMAKE_CXX_COMPILER} ${ENABLE_USER_FP16})
execute_process(COMMAND ${BUILD_U8S8_KGEMM_GEN_CMD} ${BUILD_KGEMM_GEN_SRC2}
${KGEMM_GEN_DIR} ${CMAKE_CXX_COMPILER} ${ENABLE_USER_FP16})
execute_process(COMMAND ${BUILD_KCONV_GEN_CMD} ${BUILD_KCONV_GEN_SRC1}
${KGEMM_GEN_DIR} ${CMAKE_CXX_COMPILER} ${ENABLE_USER_FP16})
execute_process(COMMAND ${BUILD_U8S8_KCONV_GEN_CMD} ${BUILD_KCONV_GEN_SRC2}
${KGEMM_GEN_DIR} ${CMAKE_CXX_COMPILER} ${ENABLE_USER_FP16})
execute_process(COMMAND ${BUILD_VMG_KCONV_GEN_CMD} ${BUILD_KCONV_GEN_SRC3}
${KGEMM_GEN_DIR} ${CMAKE_CXX_COMPILER} ${ENABLE_USER_FP16})
execute_process(COMMAND ${BUILD_U8S8_DEPTHWISE_KCONV_GEN_CMD} ${BUILD_KCONV_GEN_SRC4}
${KGEMM_GEN_DIR} ${CMAKE_CXX_COMPILER} ${ENABLE_USER_FP16})
file (GLOB __euler_gemm_kernel_source ${KGEMM_GEN_DIR}/*.cpp)
include_directories(AFTER . include src tests src/common)
link_directories(lib)
# build lib
add_library(${lib_name} SHARED ${__euler_source} ${__euler_gemm_kernel_source})
set_target_properties(${lib_name} PROPERTIES CXX_VISIBILITY_PRESET hidden)
if (MT_RUNTIME STREQUAL "tbb")
target_link_libraries(${lib_name} PUBLIC tbb)
elseif (MT_RUNTIME STREQUAL "omp")
target_link_libraries(${lib_name} PUBLIC iomp5)
endif()
target_link_libraries(${lib_name} PUBLIC rt)
if (WITH_TEST)
add_subdirectory(tests)
endif()