summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt72
1 files changed, 72 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..c5b383b
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,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()