-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
48 lines (39 loc) · 1.58 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
project(dot_product_methods CXX)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})
option(LLVM_BITCODE OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fno-rtti -fno-exceptions -mavx")
set(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} -flto")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -ftree-vectorize -march=native -mtune=native")
else ()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fast -xHOST -ipo -qopt-report -qopt-report-phase=vec")
endif ()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(NOT LLVM_BITCODE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} -lc++abi")
endif()
set(CMAKE_AR "llvm-ar")
set(CMAKE_LD "llvm-ld")
set(CMAKE_NM "llvm-nm" )
set(CMAKE_OBJDUMP "llvm-objdump")
set(CMAKE_RANLIB "llvm-ranlib")
endif()
if(LLVM_BITCODE)
find_package(LLVM REQUIRED)
include(${CMAKE_SOURCE_DIR}/cmake/LLVMTools.cmake)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-use-cxa-atexit")
add_bitcode(dot_product dot_product.cpp)
add_custom_target(bench
COMMAND ${CMAKE_HOME_DIRECTORY}/scripts/bench.sh 1000 lli -O3 -ffast-math ${PROJECT_BINARY_DIR}/dot_product.bc
DEPENDS dot_product)
else()
add_executable(dot_product dot_product.cpp)
add_custom_target(bench
COMMAND ${CMAKE_HOME_DIRECTORY}/scripts/bench.sh 1000 ${PROJECT_BINARY_DIR}/dot_product
DEPENDS dot_product)
endif()