forked from karpathy/llama2.c
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
33 lines (26 loc) · 1.02 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
cmake_minimum_required(VERSION 3.16)
project(llama2)
set(CMAKE_CXX_STANDARD 17)
# Define an option for OpenMP support
option(USE_OPENMP "Use OpenMP for parallelism" OFF) # Default is not using OpenMP
# Set build type based on whether USE_OPENMP is turned on
if(USE_OPENMP)
set(CMAKE_BUILD_TYPE Release) # Set to Release if using OpenMP
else()
set(CMAKE_BUILD_TYPE Debug) # Otherwise, set to Debug
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)
include_directories(${CMAKE_SOURCE_DIR})
# If USE_OPENMP is turned on, find OpenMP and set additional flags
if(USE_OPENMP)
find_package(OpenMP REQUIRED) # Require OpenMP
if(OpenMP_CXX_FOUND)
add_definitions(-DUSE_OPENMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast -march=native") # Add Ofast and march=native
endif()
endif()
add_executable(run run.cpp)
# Link OpenMP if it was found and if USE_OPENMP is turned on
if(OpenMP_CXX_FOUND AND USE_OPENMP)
target_link_libraries(run PUBLIC OpenMP::OpenMP_CXX)
endif()