This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
47 lines (39 loc) · 1.68 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
cmake_minimum_required(VERSION 3.7)
project(sixtyfour LANGUAGES C)
option(CUDA_BUILD "Build with CUDA Support" ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_C_FLAGS "-fPIC -Wall -Wextra")
set(CMAKE_C_FLAGS_DEBUG "-ggdb")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(SOURCES neon.c workpool.c output.c naive.c multicore.c avx512.c sse.c avx.c timing.c sixtyfour.c)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
set_source_files_properties(sse.c PROPERTIES COMPILE_FLAGS "-msse4")
set_source_files_properties(avx.c PROPERTIES COMPILE_FLAGS "-mavx2")
set_source_files_properties(avx512.c PROPERTIES COMPILE_FLAGS "-mavx512f -mavx512bw")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
set_source_files_properties(neon.c PROPERTIES COMPILE_FLAGS "-march=armv8-a")
else()
message(FATAL_ERROR "Probably an unsupported architecture; but try it anyway!")
endif()
if(CUDA_BUILD)
enable_language("CUDA")
if(CMAKE_CUDA_COMPILER)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -arch=sm_35")
foreach(arch 35;50;52;60;61;70;75 )
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode=arch=compute_${arch},code=sm_${arch}")
endforeach()
set(CUDA_HOST_COMPILATION_CPP OFF)
message(STATUS "Building with CUDA support")
add_definitions(-DCUDA_BUILD)
list(APPEND SOURCES gpu.cu gpu_multicore.cu gpu_common.cu)
else()
message(FATAL_ERROR "Enabled CUDA but no CUDA support found. Try doing: `CUDACXX=/usr/local/cuda/bin/nvcc cmake ..` ")
endif()
else()
message(STATUS "Building WITHOUT CUDA support")
list(APPEND SOURCES gpu_stub.c)
endif()
add_executable(sixtyfour ${SOURCES})
target_link_libraries(sixtyfour pthread)