Skip to content

Commit

Permalink
Add Kokkos in-tree building and configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Bylicki <[email protected]>
  • Loading branch information
jbylicki committed Jan 10, 2025
1 parent 925dd93 commit 96a4551
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ if(ENABLE_TESTS)
include(GoogleTest)
endif()

option(USE_GPL2 "Enable Kokkos-based DG-RePlAce algorithm" OFF)

add_subdirectory(src)
add_subdirectory(test)

Expand All @@ -193,7 +195,7 @@ if(BUILD_MAN)
COMMAND make clean && make preprocess && make all -j${PROCESSOR_COUNT}
WORKING_DIRECTORY ${OPENROAD_HOME}/docs
)

# Based on ${CMAKE_INSTALL_PREFIX}, we want to go to ${CMAKE_INSTALL_PREFIX}/share/man
install(DIRECTORY ${OPENROAD_HOME}/docs/cat DESTINATION ${OPENROAD_SHARE}/man)
install(DIRECTORY ${OPENROAD_HOME}/docs/html DESTINATION ${OPENROAD_SHARE}/man)
Expand Down
6 changes: 5 additions & 1 deletion etc/Build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cmakeOptions=""
cleanBefore=no
depsPrefixesFile=""
keepLog=no
use_gpl2=no
compiler=gcc

_help() {
Expand Down Expand Up @@ -111,7 +112,7 @@ while [ "$#" -gt 0 ]; do
;;
-deps-prefixes-file=*)
file="${1#-deps-prefixes-file=}"
if [[ ! -f "$file" ]]; then
if [[ ! -f "$file" ]]; then
echo "${file} does not exist" >&2
_help
fi
Expand All @@ -121,6 +122,9 @@ while [ "$#" -gt 0 ]; do
echo "${1} requires an argument" >&2
_help
;;
-use_gpl2)
cmakeOptions+=" -DUSE_GPL2=ON"
;;
-gpu)
cmakeOptions+=" -DGPU=ON"
;;
Expand Down
31 changes: 22 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,22 @@ endif()
find_package(Threads REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG ON)

find_package(Kokkos)

if (NOT Kokkos_FOUND)
if(USE_GPL2)
find_package(OpenMP REQUIRED)
set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "Set Kokkos OpenMP backend" FORCE)
if(GPU)
set(Kokkos_ENABLE_CUDA ON CACHE BOOL "Set Kokkos CUDA backend" FORCE)
set(Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "Enable Kokkos CUDA Lambda support" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_NO_CUDA")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14")
message(FATAL_ERROR "Detected version of GCC is not supported by NVCC. Consider using Clang or disabling GPU support.")
endif()
else()
set(Kokkos_ENABLE_CUDA OFF CACHE BOOL "Set Kokkos CUDA backend" FORCE)
set(Kokkos_ENABLE_CUDA_LAMBDA OFF CACHE BOOL "Enable Kokkos CUDA Lambda support" FORCE)
endif()
set(KokkosFFT_ENABLE_INTERNAL_KOKKOS ON CACHE BOOL "Use Kokkos-FFT to build Kokkos" FORCE)
else()
add_compile_options(
-Wp,-D_GLIBCXX_ASSERTIONS
)
Expand All @@ -295,7 +308,7 @@ add_subdirectory(dbSta)
add_subdirectory(rsz)
add_subdirectory(stt)
add_subdirectory(gpl)
if (Kokkos_FOUND)
if(USE_GPL2)
add_subdirectory(gpl2)
endif()
add_subdirectory(dpl)
Expand Down Expand Up @@ -325,7 +338,7 @@ add_subdirectory(par)
add_executable(openroad
${OPENROAD_SOURCE}
)
if (Kokkos_FOUND)
if(USE_GPL2)
target_compile_definitions(openroad PUBLIC ENABLE_KOKKOS)
endif()

Expand Down Expand Up @@ -390,11 +403,11 @@ target_link_libraries(openroad
${CMAKE_THREAD_LIBS_INIT}
)

if (Kokkos_FOUND)
if(USE_GPL2)
find_package(fmt REQUIRED)
target_link_libraries(openroad
gpl2
Kokkos::kokkos
KokkosFFT::fft
omp
fmt::fmt-header-only
)
Expand Down Expand Up @@ -472,8 +485,8 @@ if (Python3_FOUND AND BUILD_PYTHON)
dft_py
par_py
)
if (Kokkos_FOUND)
target_link_libraries(openroad gpl2_py Kokkos::kokkos)
if(USE_GPL2)
target_link_libraries(openroad gpl2_py KokkosFFT::fft)
endif()

else()
Expand Down
6 changes: 2 additions & 4 deletions src/gpl2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@
###############################################################################

include("openroad")
add_subdirectory(kokkos-fft)
find_package(Eigen3 REQUIRED)
find_package(OpenMP REQUIRED)
find_package(fmt REQUIRED)
find_package(Kokkos REQUIRED)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_NO_CUDA")
add_subdirectory(kokkos-fft)

swig_lib(NAME gpl2
NAMESPACE gpl2
Expand Down Expand Up @@ -80,7 +78,7 @@ target_link_libraries(gpl2
OpenSTA
rsz
grt
Kokkos::kokkos
omp
KokkosFFT::fft
fmt::fmt-header-only
)
Expand Down

0 comments on commit 96a4551

Please sign in to comment.