Skip to content

Commit

Permalink
Properly support MPI/No MPI option. CMake cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Prather committed Dec 8, 2023
1 parent fc4689f commit 14c9852
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ set(Kokkos_ENABLE_CUDA_CONSTEXPR ON CACHE BOOL "KHARMA Override")
set(Kokkos_ENABLE_HWLOC OFF CACHE BOOL "KHARMA Override") # Possible speed improvement?
set(Kokkos_ENABLE_AGGRESSIVE_VECTORIZATION ON CACHE BOOL "KHARMA Override")

# For including the current git revision in the exe
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
git_describe_working_tree(GIT_VERSION --tags)
Expand All @@ -53,10 +54,6 @@ else()
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
endif()

# OpenMP is usually used host-side. We're letting Parthenon/Kokkos
# find it though, as sometimes we require disabling it fully
#find_package(OpenMP REQUIRED)

# Build Parthenon
add_subdirectory(external/parthenon)
include_directories(external/parthenon/src)
Expand Down
22 changes: 12 additions & 10 deletions kharma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,16 @@ else()
endif()

# OPTIONS
# These are almost universally performance trade-offs
# These are almost universally performance trade-offs,
# or disabling features that need dependencies.
# TODO is there any way to make compile options less painful in CMake?
option(FUSE_FLUX_KERNELS "Bundle the usual four flux calculation kernels (floors,R,L,apply) into one" ON)
option(FUSE_FLOOR_KERNELS "Bundle applying the floors and ceilings into one kernel" ON)
option(FAST_CARTESIAN "Break operation in curved spacetimes to make Cartesian Minkowski space computations faster" OFF)
option(KHARMA_DISABLE_IMPLICIT "Disable the implicit solver, which requires bundled kokkos-kernels. Default false" OFF)
option(KHARMA_DISABLE_CLEANUP "Disable the magnetic field cleanup module, which requires recent Parthenon. Default false" OFF)
option(KHARMA_TRACE "Compile with tracing: print entry and exit of important functions. Default false" OFF)

if(FUSE_FLUX_KERNELS)
target_compile_definitions(${EXE_NAME} PUBLIC FUSE_FLUX_KERNELS=1)
else()
Expand All @@ -108,13 +113,11 @@ else()
target_compile_definitions(${EXE_NAME} PUBLIC FUSE_FLOOR_KERNELS=0)
endif()
if(FAST_CARTESIAN)
message("Compiling for Cartesian coordinates only. GRMHD will be disabled!")
target_compile_definitions(${EXE_NAME} PUBLIC FAST_CARTESIAN=1)
else()
target_compile_definitions(${EXE_NAME} PUBLIC FAST_CARTESIAN=0)
endif()
option(KHARMA_DISABLE_IMPLICIT "Disable the implicit solver, which requires bundled kokkos-kernels. Default false" OFF)
option(KHARMA_DISABLE_CLEANUP "Disable the magnetic field cleanup module, which requires recent Parthenon. Default false" OFF)
option(KHARMA_TRACE "Compile with tracing: print entry and exit of important functions" OFF)
if(KHARMA_DISABLE_IMPLICIT)
message("Compiling without the implicit solver. Extended GRMHD will be disabled!")
target_compile_definitions(${EXE_NAME} PUBLIC DISABLE_IMPLICIT=1)
Expand All @@ -134,14 +137,13 @@ if(KHARMA_TRACE)
else()
target_compile_definitions(${EXE_NAME} PUBLIC TRACE=0)
endif()
option(KHARMA_DISABLE_IMPLICIT "Compile the implicit solver, requiring kokkos-kernels. Default true" OFF)
option(KHARMA_TRACE "Compile with tracing: print entry and exit of important functions" OFF)
if(KHARMA_DISABLE_IMPLICIT)
message("Compiling without the implicit solver. Extended GRMHD will be disabled!")
target_compile_definitions(${EXE_NAME} PUBLIC ENABLE_IMPLICIT=0)
if(KHARMA_DISABLE_MPI)
message("Compiling without MPI!")
target_compile_definitions(${EXE_NAME} PUBLIC ENABLE_MPI=0)
else()
target_compile_definitions(${EXE_NAME} PUBLIC ENABLE_IMPLICIT=1)
target_compile_definitions(${EXE_NAME} PUBLIC ENABLE_MPI=1)
endif()

# FLAGS
if(CMAKE_BUILD_TYPE)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
Expand Down
2 changes: 1 addition & 1 deletion kharma/decs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ inline int MPIRank()
}
inline int MPIBarrier()
{
#if MPI_PARALLEL
#if ENABLE_MPI
return MPI_Barrier(MPI_COMM_WORLD);
#else
return 0;
Expand Down

0 comments on commit 14c9852

Please sign in to comment.