-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
52 lines (41 loc) · 1.7 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
cmake_minimum_required(VERSION 3.5)
project(xllm LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread --std=c++17 -O2 -march=native")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread --std=c++17 -march=native")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
option(USE_CUDA "use cuda" OFF)
message(STATUS "USE_CUDA: ${USE_CUDA}")
if (USE_CUDA)
enable_language(CUDA)
add_compile_definitions(USE_CUDA) # 添加预处理宏:USE_CUDA
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -g -G")
add_compile_options(-ldl)
include_directories(include/cuda)
message(${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
set(XLLM_CUDA_SOURCES src/cuda/cudadevice.cpp src/cuda/xllm-cuda.cu)
set(XLLM_LINKED_LIBS ${XLLM_LINKED_LIBS} cublas)
link_directories(/usr/local/cuda/lib64)
set(CMAKE_CUDA_ARCHITECTURES "${CUDA_ARCHITECTURES}")
endif()
set(XLLM_CXX_SOURCES src/param.cpp src/data.cpp src/xllm.cpp src/model.cpp
src/cpu/cpudevice.cpp src/executor.cpp src/device.cpp)
find_package(OpenMP)
include_directories(include)
include_directories(include/cpu)
add_library(xllm OBJECT ${XLLM_CXX_SOURCES} ${XLLM_CUDA_SOURCES})
target_link_libraries(xllm PUBLIC ${XLLM_LINKED_LIBS} OpenMP::OpenMP_CXX)
add_executable(main main.cpp)
target_link_libraries(main xllm)
add_executable(benchmark benchmark/benchmark.cpp)
target_link_libraries(benchmark xllm)
add_executable(benchmark_batch benchmark/benchmark_batch.cpp)
target_link_libraries(benchmark_batch xllm)
add_executable(quant src/quant.cpp)
target_link_libraries(quant xllm)
option(DEVELOPMENT OFF)
if (${DEVELOPMENT})
message(STATUS "DEVELOPMENT MODE ON")
add_subdirectory(tests)
endif ()