-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
116 lines (103 loc) · 5.04 KB
/
Copy pathCMakeLists.txt
File metadata and controls
116 lines (103 loc) · 5.04 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
cmake_minimum_required(VERSION 3.10)
project(UAAMG LANGUAGES CXX)
# C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Release build
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
# Global include path
include_directories(${CMAKE_SOURCE_DIR}/include)
# Subdirectories
add_subdirectory(src)
add_subdirectory(test)
# CUDA solver (optional — requires nvcc and GPU)
# Build with: CUDACXX=/usr/local/cuda/bin/nvcc cmake ..
if(DEFINED ENV{CUDACXX} OR DEFINED CMAKE_CUDA_COMPILER)
enable_language(CUDA)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES "60;70;75;80;86;89;90")
endif()
message(STATUS "CUDA enabled — building GPU solver")
add_subdirectory(src/solver/cuda)
# GPU unit / benchmark tests (moved out of src/solver/cuda)
add_subdirectory(test/cuda)
# GPU Karman benchmark (2D)
add_executable(test_karman_bench_gpu test/integration/test_karman_bench_gpu.cu)
set_target_properties(test_karman_bench_gpu PROPERTIES
LINKER_LANGUAGE CUDA
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"
)
target_link_libraries(test_karman_bench_gpu PRIVATE lfm_lib cuda_uaamg_lib cuda_cg_lib)
target_include_directories(test_karman_bench_gpu PRIVATE
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/test
)
# GPU Karman benchmark (3D)
add_executable(test_karman_bench_3d_gpu test/integration/test_karman_bench_3d_gpu.cu)
set_target_properties(test_karman_bench_3d_gpu PROPERTIES
LINKER_LANGUAGE CUDA
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"
)
target_link_libraries(test_karman_bench_3d_gpu PRIVATE lfm_lib cuda_uaamg_lib cuda_cg_lib)
target_include_directories(test_karman_bench_3d_gpu PRIVATE
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/test
)
# GPU-solver LFM Karman runner (CPU sim loop, GPU Poisson solve)
add_executable(run_karman_long_gpu tools/run_karman_long_gpu.cu)
set_target_properties(run_karman_long_gpu PROPERTIES
LINKER_LANGUAGE CUDA
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"
)
target_link_libraries(run_karman_long_gpu PRIVATE lfm_lib cuda_uaamg_lib cuda_cg_lib)
target_include_directories(run_karman_long_gpu PRIVATE ${CMAKE_SOURCE_DIR}/include)
# ── Unified INPUT-file-driven launcher for ALL GPU 3D LFM scenes ──
# One binary replaces the former per-scene runners (run_vortex_ring_*,
# run_*_collision_*, run_delta_wing_*, run_collision_paper, plus the CPU
# reconnection/trefoil demos): the scenario + every parameter come from an
# INI file (see inputs/*.in). Scenarios: vortex_ring | vortex_collision |
# collision_paper | delta_wing | vortex_reconnection | trefoil_knot.
# ./build/cfdsim inputs/vortex_collision.in
# collision_paper's author cross-check (raw IC load, velocity dump) lives on
# as the ic_dir= / dump_vel= knobs.
# CUDA build: compile the .cpp as CUDA (nvcc) so it can drive the GPU-resident
# simulator. HAVE_CUDA enables the GPU backend; runs on GPU by default
# (backend=auto), with a CPU fallback when no device is present.
# cfdsim.cpp is just main(); make_simulator_3d.cpp builds the GPU/CPU
# simulator, so it needs nvcc too. Both compile as CUDA in this build.
add_executable(cfdsim src/cfdsim.cpp src/simulator/make_simulator_3d.cpp)
set_source_files_properties(src/cfdsim.cpp src/simulator/make_simulator_3d.cpp
PROPERTIES LANGUAGE CUDA)
set_target_properties(cfdsim PROPERTIES
LINKER_LANGUAGE CUDA
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"
)
target_compile_definitions(cfdsim PRIVATE HAVE_CUDA)
target_link_libraries(cfdsim PRIVATE cuda_lfm_3d_lib cuda_uaamg_3d_lib cuda_cg_3d_lib lfm_lib)
target_include_directories(cfdsim PRIVATE ${CMAKE_SOURCE_DIR}/include)
# GPU Karman validate (Cd/Cl/St)
add_executable(test_karman_validate_gpu test/integration/test_karman_validate_gpu.cu)
set_target_properties(test_karman_validate_gpu PROPERTIES
LINKER_LANGUAGE CUDA
CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}"
)
target_link_libraries(test_karman_validate_gpu PRIVATE lfm_lib cuda_uaamg_lib cuda_cg_lib)
target_include_directories(test_karman_validate_gpu PRIVATE
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/test
)
else()
message(STATUS "CUDA not enabled — building cfdsim as a CPU-only binary")
message(STATUS " To build with GPU support: CUDACXX=/usr/local/cuda/bin/nvcc cmake ..")
# CPU-only cfdsim: the SAME sources, compiled by the C++ compiler (no nvcc).
# Without HAVE_CUDA make_simulator_3d.cpp pulls in no CUDA headers, so
# backend=auto/gpu both resolve to the host LFMSimulator3D. GPU optional.
add_executable(cfdsim src/cfdsim.cpp src/simulator/make_simulator_3d.cpp)
target_link_libraries(cfdsim PRIVATE lfm_lib)
target_include_directories(cfdsim PRIVATE ${CMAKE_SOURCE_DIR}/include)
endif()