Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile based on present architecture #127

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
28 changes: 21 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,32 @@ 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")
if (NOT FLAGS_SET)
set(CMAKE_Fortran_FLAGS "-cpp -cuda" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_DEBUG "-g -O0 -traceback -Mbounds -Mchkptr -Ktrap=fp" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fast -gpu=ccnative" CACHE STRING "" FORCE)
set(FLAGS_SET 1 CACHE INTERNAL "")
endif()
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fast -gpu=ccnative")
target_link_options(x3d2 INTERFACE "-cuda")
target_link_options(x3d2 INTERFACE "-cudalib=cufftmp")

target_compile_options(xcompact PRIVATE "-DCUDA")
elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_Fortran_FLAGS "-cpp -std=f2018")
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")
if (NOT FLAGS_SET)
message("CMAKE_Fortran_FLAGS: ${CMAKE_Fortran_FLAGS}")
message("CMAKE_Fortran_FLAGS_DEBUG: ${CMAKE_Fortran_FLAGS_DEBUG}")
message("CMAKE_Fortran_FLAGS_RELEASE: ${CMAKE_Fortran_FLAGS_RELEASE}")

#set(CMAKE_Fortran_FLAGS "-cpp -std=f2018 -fallow-argument-mismatch" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_DEBUG "-g -Og -Wall -Wpedantic -Werror -Wimplicit-interface -Wimplicit-procedure -Wno-unused-dummy-argument" CACHE STRING "" FORCE)
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ffast-math -march=native" CACHE STRING "" FORCE)

message("CMAKE_Fortran_FLAGS: ${CMAKE_Fortran_FLAGS}")
message("CMAKE_Fortran_FLAGS_DEBUG: ${CMAKE_Fortran_FLAGS_DEBUG}")
message("CMAKE_Fortran_FLAGS_RELEASE: ${CMAKE_Fortran_FLAGS_RELEASE}")
set(FLAGS_SET 1 CACHE INTERNAL "")
endif()
endif()

find_package(OpenMP REQUIRED)
Expand Down
Loading