From 2dcac776428fbc1fa7197762a9e56d47222d1e2c Mon Sep 17 00:00:00 2001 From: Jan Bylicki Date: Fri, 10 Jan 2025 18:14:53 +0100 Subject: [PATCH] Moved Kokkos/Kokkos-fft to be primarly handled via DependencyInstaller Signed-off-by: Jan Bylicki --- .gitmodules | 3 -- etc/DependencyInstaller.sh | 103 +++++++++++++++++++++++++------------ src/CMakeLists.txt | 34 +++++++----- src/gpl2/CMakeLists.txt | 5 +- src/gpl2/kokkos-fft | 1 - 5 files changed, 96 insertions(+), 50 deletions(-) delete mode 160000 src/gpl2/kokkos-fft diff --git a/.gitmodules b/.gitmodules index 9ef2d24dec8..f277be90f53 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "src/abc"] path = third-party/abc url = ../../The-OpenROAD-Project/abc.git -[submodule "src/gpl2/kokkos-fft"] - path = src/gpl2/kokkos-fft - url = https://github.com/kokkos/kokkos-fft.git diff --git a/etc/DependencyInstaller.sh b/etc/DependencyInstaller.sh index 1a102428382..37ef3b9bf39 100755 --- a/etc/DependencyInstaller.sh +++ b/etc/DependencyInstaller.sh @@ -75,6 +75,7 @@ _installCommonDev() { spdlogVersion=1.15.0 gtestVersion=1.13.0 gtestChecksum="a1279c6fb5bf7d4a5e0d0b2a4adb39ac" + kokkosfftVersion="2c616d29a7ad0c390259efeb9224115bfa6910fd" rm -rf "${baseDir}" @@ -153,6 +154,25 @@ _installCommonDev() { fi CMAKE_PACKAGE_ROOT_ARGS+=" -D Eigen3_ROOT=$(realpath $eigenPrefix) " + kokkosfftPrefix=${PREFIX:-"/usr/local"} + if [[ ! -d ${kokkosfftPrefix}/include/kokkos ]]; then + cd "${baseDir}" + git clone --recurse-submodules https://github.com/kokkos/kokkos-fft + cd kokkos-fft + git checkout ${kokkosfftVersion} + git submodule update --recursive + ARGS_KOKKOSFFT=" -DCMAKE_BUILD_TYPE=Release -DKokkos_ENABLE_OPENMP=ON -DKokkosFFT_ENABLE_INTERNAL_KOKKOS=ON" + if [[ -n $(which nvcc) ]]; then + # Older version of g++ is needed for compatibility with NVCC + ARGS_KOKKOSFFT+=" -DKokkos_ENABLE_CUDA=ON -DCMAKE_CXX_COMPILER=g++-10" + fi + ${cmakePrefix}/bin/cmake -DCMAKE_INSTALL_PREFIX="${kokkosfftPrefix}" ${ARGS_KOKKOSFFT} -B build + ${cmakePrefix}/bin/cmake --build build -j $(nproc) --target install + else + echo "KokkosFFT already installed." + fi + CMAKE_PACKAGE_ROOT_ARGS+=" -D Kokkos_ROOT=$(realpath $kokkosfftPrefix) " + # cudd cuddPrefix=${PREFIX:-"/usr/local"} if [[ ! -f ${cuddPrefix}/include/cudd.h ]]; then @@ -315,7 +335,7 @@ _installUbuntuCleanUp() { _installUbuntuPackages() { export DEBIAN_FRONTEND="noninteractive" apt-get -y update - apt-get -y install --no-install-recommends tzdata + apt-get -y install --no-install-recommends tzdata pciutils apt-get -y install --no-install-recommends \ automake \ autotools-dev \ @@ -335,6 +355,8 @@ _installUbuntuPackages() { libffi-dev \ libgomp1 \ libomp-dev \ + libfftw3-dev\ + libfmt-dev \ libpcre2-dev \ libpcre3-dev \ libreadline-dev \ @@ -360,6 +382,10 @@ _installUbuntuPackages() { packages+=("libpython3.8") fi + if [[ -n $(lspci -vnnn | grep -i vga.*nvidia*) ]]; then + packages+=("nvidia-cuda-dev" "nvidia-cuda-toolkit" "g++-10") + fi + # Chose QT libraries if _versionCompare $1 -ge 22.04; then packages+=( @@ -449,36 +475,42 @@ _installOpenSusePackages() { zypper refresh zypper -n update zypper -n install -t pattern devel_basis - zypper -n install \ - binutils \ - clang \ - gcc \ - gcc11-c++ \ - git \ - groff \ - gzip \ - lcov \ - libffi-devel \ - libgomp1 \ - libomp11-devel \ - libpython3_6m1_0 \ - libqt5-creator \ - libqt5-qtbase \ - libqt5-qtstyleplugins \ - libstdc++6-devel-gcc8 \ - llvm \ - pandoc \ - pcre-devel \ - pcre2-devel \ - python3-devel \ - python3-pip \ - qimgv \ - readline-devel \ - tcl \ - tcl-devel \ - tcllib \ - wget \ - zlib-devel + zypper -n --gpg-auto-import-keys \ + --plus-repo https://download.opensuse.org/repositories/games/$(grep ^VERSION= /etc/os-release | sed 's/VERSION="\(.*\)"/\1/g') \ + --plus-repo https://download.opensuse.org/repositories/Education/$(grep ^VERSION= /etc/os-release | sed 's/VERSION="\(.*\)"/\1/g')\ + install \ + binutils \ + clang \ + fftw3-devel\ + gcc \ + gcc11-c++ \ + git \ + groff \ + gzip \ + lcov \ + libffi-devel \ + libgomp1 \ + libomp11-devel \ + libfmt11 \ + libpython3_6m1_0 \ + libqt5-creator \ + libqt5-qtbase \ + libqt5-qtstyleplugins \ + libstdc++6-devel-gcc8 \ + llvm \ + pandoc \ + pcre-devel \ + pcre2-devel \ + python3-devel \ + python3-pip \ + qimgv \ + readline-devel \ + tcl \ + tcl-devel \ + tcllib \ + unzip \ + wget \ + zlib-devel update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 50 update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 50 @@ -542,7 +574,7 @@ _installDebianCleanUp() { _installDebianPackages() { export DEBIAN_FRONTEND="noninteractive" apt-get -y update - apt-get -y install --no-install-recommends tzdata + apt-get -y install --no-install-recommends tzdata pciutils if [[ $1 == rodete ]]; then tclver=8.6 else @@ -565,6 +597,8 @@ _installDebianPackages() { lcov \ libffi-dev \ libgomp1 \ + libfftw3-dev\ + libfmt-dev \ libomp-dev \ libpcre2-dev \ libpcre3-dev \ @@ -580,6 +614,11 @@ _installDebianPackages() { wget \ zlib1g-dev + if [[ -n $(lspci -vnnn | grep -i vga.*nvidia*) ]]; then + apt-get -y install --no-install-recommends nvidia-cuda-dev nvidia-cuda-toolkit g++-10 + fi + + if [[ $1 == 10 ]]; then apt-get install -y --no-install-recommends \ libpython3.7 \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf3ca5da77d..be92206f571 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -271,19 +271,30 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) 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.") + find_package(Kokkos) + find_package(KokkosFFT) + if(NOT (${Kokkos_FOUND} AND ${KokkosFFT_FOUND})) + include(FetchContent) + FetchContent_Populate( + kokkos-fft + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/gpl2/kokkos-fft + GIT_REPOSITORY https://github.com/kokkos/kokkos-fft + GIT_TAG origin/main + ) + 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() - 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) + set(KokkosFFT_ENABLE_INTERNAL_KOKKOS ON CACHE BOOL "Use Kokkos-FFT to build Kokkos" 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 @@ -408,7 +419,6 @@ if(USE_GPL2) target_link_libraries(openroad gpl2 KokkosFFT::fft - omp fmt::fmt-header-only ) endif() diff --git a/src/gpl2/CMakeLists.txt b/src/gpl2/CMakeLists.txt index 43d4f2eb0f6..8d821457006 100644 --- a/src/gpl2/CMakeLists.txt +++ b/src/gpl2/CMakeLists.txt @@ -38,7 +38,9 @@ find_package(Eigen3 REQUIRED) find_package(OpenMP REQUIRED) find_package(fmt REQUIRED) -add_subdirectory(kokkos-fft) +if(NOT (${Kokkos_FOUND} AND ${KokkosFFT_FOUND})) + add_subdirectory(kokkos-fft) +endif() swig_lib(NAME gpl2 NAMESPACE gpl2 @@ -78,7 +80,6 @@ target_link_libraries(gpl2 OpenSTA rsz grt - omp KokkosFFT::fft fmt::fmt-header-only ) diff --git a/src/gpl2/kokkos-fft b/src/gpl2/kokkos-fft deleted file mode 160000 index 2c616d29a7a..00000000000 --- a/src/gpl2/kokkos-fft +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2c616d29a7ad0c390259efeb9224115bfa6910fd