blob: c5b383b20de0c93eb68da7614d3582b86caf2abd (
plain)
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
|
cmake_minimum_required(VERSION 3.10)
project(SweepLB LANGUAGES CXX)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(SIMD_MODE "AVX256" CACHE STRING "Generate either AVX256 or AVX512 instructions")
option(USE_SIMD_CELL_LIST "Generate gather / scatter instructions for cell list processing" OFF)
if(NOT SIMD_MODE)
set(SIMD_MODE "AVX256")
endif()
set(CXX_FLAGS "-O3 -march=native -mtune=native")
if(${SIMD_MODE} MATCHES "AVX256")
message("Selecting AVX256")
set(SIMD_MODE_FLAGS "-mavx2")
elseif(${SIMD_MODE} MATCHES "AVX512")
message("Selecting AVX512")
add_compile_definitions(ENABLE_AVX512)
set(SIMD_MODE_FLAGS "-mavx512f -mavx512dq")
else()
message(FATAL_ERROR "Invalid SIMD mode, choose either AVX256 or AVX512")
endif()
if(USE_SIMD_CELL_LIST)
message("Enabling SIMD cell list processing.")
add_compile_definitions(SIMD_CELL_LIST)
endif()
set(CMAKE_CXX_FLAGS "${CXX_FLAGS} ${SIMD_MODE_FLAGS}")
message("Using flags \"${CMAKE_CXX_FLAGS}\"")
include_directories(
src/
)
find_package(OpenMP)
set(EXAMPLES ldc box channel)
set(PRECISIONS float double)
set(PATTERNS sss ps)
foreach(example IN LISTS EXAMPLES)
foreach(precision IN LISTS PRECISIONS)
foreach(pattern IN LISTS PATTERNS)
set(generated_name ${example}_${precision}_${pattern})
string(TOUPPER ${pattern} pattern)
add_executable(${generated_name} ${example}.cpp)
target_compile_definitions(${generated_name}
PRIVATE
SWEEPLB_PRECISION=${precision}
SWEEPLB_PATTERN=${pattern})
target_compile_features(${generated_name}
PRIVATE cxx_std_20)
target_link_libraries(
${generated_name}
PUBLIC
rt)
if(OpenMP_CXX_FOUND)
target_link_libraries(
${generated_name}
PUBLIC
OpenMP::OpenMP_CXX
)
endif()
endforeach()
endforeach()
endforeach()
|