forked from xcompact3d/x3d2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (55 loc) · 1.82 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
set(SRC
allocator.f90
backend.f90
common.f90
poisson_fft.f90
solver.f90
tdsops.f90
time_integrator.f90
omp/backend.f90
omp/common.f90
omp/kernels_dist.f90
omp/poisson_fft.f90
omp/sendrecv.f90
omp/exec_dist.f90
)
set(CUDASRC
cuda/allocator.f90
cuda/backend.f90
cuda/common.f90
cuda/exec_dist.f90
cuda/kernels/distributed.f90
cuda/kernels/complex.f90
cuda/kernels/reorder.f90
cuda/poisson_fft.f90
cuda/sendrecv.f90
cuda/tdsops.f90
)
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI" OR
${CMAKE_Fortran_COMPILER_ID} STREQUAL "NVHPC")
list(APPEND SRC ${CUDASRC})
endif()
add_library(x3d2 STATIC ${SRC})
target_include_directories(x3d2 INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
add_executable(xcompact xcompact.f90)
target_link_libraries(xcompact PRIVATE x3d2)
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "PGI" OR
${CMAKE_Fortran_COMPILER_ID} STREQUAL "NVHPC")
set(CMAKE_Fortran_FLAGS "-cpp -cuda")
set(CMAKE_Fortran_FLAGS_DEBUG "-g -O0 -traceback -Mbounds -Mchkptr -Ktrap=fp")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fast")
target_link_options(x3d2 INTERFACE "-cuda")
target_link_options(x3d2 INTERFACE "-lcufft")
target_compile_options(xcompact PRIVATE "-DCUDA")
# target_link_options(xcompact INTERFACE "-cuda")
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_Fortran_FLAGS "-cpp -std=f2008")
set(CMAKE_Fortran_FLAGS_DEBUG "-g -Og -Wall -Wpedantic -Werror -Wimplicit-interface -Wimplicit-procedure -Wno-unused-dummy-argument")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ffast-math")
endif()
find_package(OpenMP REQUIRED)
target_link_libraries(x3d2 PRIVATE OpenMP::OpenMP_Fortran)
target_link_libraries(xcompact PRIVATE OpenMP::OpenMP_Fortran)
find_package(MPI REQUIRED)
target_link_libraries(x3d2 PRIVATE MPI::MPI_Fortran)
target_link_libraries(xcompact PRIVATE MPI::MPI_Fortran)