diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 4fc7f865..2755d1ce 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -54,7 +54,7 @@ jobs: run: | docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_OPENMP \ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=g++ \ - -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_OPENMP=ON -DBUILD_TESTING=ON + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_OPENMP=ON -DBUILD_TESTING=ON -DKokkosFFT_INTERNAL_Kokkos=ON - name: Configure CMake for CUDA backend # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. @@ -62,7 +62,7 @@ jobs: run: | docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_CUDA \ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=${{env.CMAKE_CXX_COMPILER}} \ - -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_${{env.CUDA_ARCHITECTURES}}=ON -DBUILD_TESTING=ON + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_${{env.CUDA_ARCHITECTURES}}=ON -DBUILD_TESTING=ON -DKokkosFFT_INTERNAL_Kokkos=ON - name: Configure CMake for CUDA backend with HOST and DEVICE option # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. @@ -71,7 +71,7 @@ jobs: docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_CUDA_HOST_DEVICE \ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=${{env.CMAKE_CXX_COMPILER}} \ -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_${{env.CUDA_ARCHITECTURES}}=ON -DBUILD_TESTING=ON \ - -DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON + -DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON -DKokkosFFT_INTERNAL_Kokkos=ON - name: Build # Build your program with the given configuration @@ -80,11 +80,23 @@ jobs: docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake --build build_${backend} --config ${{env.BUILD_TYPE}} -j 2 done - - name: Test on CPUs + - name: Test for OpenMP backend # Execute tests defined by the CMake configuration. Testing on CPUs only run: | docker run -v ${{github.workspace}}:/work ${{ env.container }} ctest --output-on-failure --test-dir build_OPENMP -C ${{env.BUILD_TYPE}} + - name: Install test for OpenMP backend + run: | + docker run -v ${{github.workspace}}:/work ${{ env.container }} ./install_test/bin/install_cpu.sh /tmp + + - name: Install test for CUDA backend + run: | + for backend in ${{ env.backends }}; do + if [ ${backend} != "OPENMP" ]; then + docker run -v ${{github.workspace}}:/work ${{ env.container }} ./install_test/bin/install_cuda.sh /tmp ${backend} + fi + done + build_amd: # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. # You can convert this to a matrix build if you need cross-platform coverage. @@ -123,9 +135,13 @@ jobs: run: | docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_${{matrix.backend.name}} \ -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=${{env.CMAKE_CXX_COMPILER}} \ - -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_${{env.architecture}}=ON -DBUILD_TESTING=ON ${{matrix.backend.option}} + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_HIP=ON -DKokkosFFT_INTERNAL_Kokkos=ON -DKokkos_ARCH_${{env.architecture}}=ON -DBUILD_TESTING=ON ${{matrix.backend.option}} - name: Build # Build your program with the given configuration run: | - docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake --build build_${{matrix.backend.name}} --config ${{env.BUILD_TYPE}} -j 2 \ No newline at end of file + docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake --build build_${{matrix.backend.name}} --config ${{env.BUILD_TYPE}} -j 2 + + - name: Install test for HIP backend + run: | + docker run -v ${{github.workspace}}:/work ${{ env.container }} ./install_test/bin/install_hip.sh /tmp ${{matrix.backend.name}} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index bd7649fe..abe4edca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,11 +7,13 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake") # Options option(BUILD_EXAMPLES "Build kokkos-fft examples" ON) option(KokkosFFT_ENABLE_HOST_AND_DEVICE "Enable fft on both host and device" OFF) +option(KokkosFFT_INTERNAL_Kokkos "Build internal Kokkos instead of relying on external one" OFF) -find_package(Kokkos CONFIG) -if(NOT kokkos_FOUND) +if (NOT KokkosFFT_INTERNAL_Kokkos) + find_package(Kokkos REQUIRED) +else () add_subdirectory(tpls/kokkos) -endif() +endif () # Googletest include(CTest) @@ -22,8 +24,56 @@ if(BUILD_TESTING) endif() endif() +# Set directories used for install +include(GNUInstallDirs) +set(LIBDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) +set(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) +set(INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/${LIBDIR}) +set(KokkosFFT_EXPORT_TARGET "KokkosFFT-Targets") + add_subdirectory(common) add_subdirectory(fft) if(BUILD_EXAMPLES) add_subdirectory(examples) -endif() \ No newline at end of file +endif() + +# Installation +include(CMakePackageConfigHelpers) + +install( + TARGETS common fft + EXPORT ${KokkosFFT_EXPORT_TARGET} +) + +install( + EXPORT ${KokkosFFT_EXPORT_TARGET} + NAMESPACE KokkosFFT:: + DESTINATION ${INSTALL_LIBDIR} +) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/common/src/ ${CMAKE_CURRENT_SOURCE_DIR}/fft/src/ + DESTINATION ${INSTALL_INCLUDEDIR} +) + +install( + FILES ${CMAKE_SOURCE_DIR}/cmake/FindFFTW.cmake + DESTINATION ${INSTALL_LIBDIR} +) + +configure_package_config_file(cmake/KokkosFFTConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfig.cmake + INSTALL_DESTINATION ${INSTALL_LIBDIR} +) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfigVersion.cmake + VERSION 0.0.0 + COMPATIBILITY SameMajorVersion +) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/KokkosFFTConfigVersion.cmake + DESTINATION ${INSTALL_LIBDIR} +) \ No newline at end of file diff --git a/cmake/KokkosFFTConfig.cmake.in b/cmake/KokkosFFTConfig.cmake.in new file mode 100644 index 00000000..08a81f44 --- /dev/null +++ b/cmake/KokkosFFTConfig.cmake.in @@ -0,0 +1,29 @@ +@PACKAGE_INIT@ + +# Set and Check must go first else macro might be redefined by find_dependency ... +set_and_check(KokkosFFT_TARGET_FILE +"${PACKAGE_PREFIX_DIR}/@LIBDIR@/@KokkosFFT_EXPORT_TARGET@.cmake") + +include(CMakeFindDependencyMacro) +list(INSERT CMAKE_MODULE_PATH 0 "${PACKAGE_PREFIX_DIR}/@LIBDIR@") +find_dependency(Kokkos) + +if(@Kokkos_ENABLE_CUDA@) + find_dependency(CUDAToolkit COMPONENTS cufft) + if(@KokkosFFT_ENABLE_HOST_AND_DEVICE@) + find_dependency(FFTW MODULE) + endif() +elseif(@Kokkos_ENABLE_HIP@) + find_dependency(hipfft) + if(@KokkosFFT_ENABLE_HOST_AND_DEVICE@) + find_dependency(FFTW MODULE) + endif() +elseif(@Kokkos_ENABLE_OPENMP@) + find_dependency(FFTW MODULE) +elseif(@Kokkos_ENABLE_SERIAL@) + find_dependency(FFTW MODULE) +endif() + +include(${KokkosFFT_TARGET_FILE}) + +check_required_components(KokkosFFT) \ No newline at end of file diff --git a/common/src/CMakeLists.txt b/common/src/CMakeLists.txt index 9f59f4d3..d5682f0d 100644 --- a/common/src/CMakeLists.txt +++ b/common/src/CMakeLists.txt @@ -30,4 +30,7 @@ elseif(Kokkos_ENABLE_SERIAL) endif() target_compile_features(common INTERFACE cxx_std_17) -target_include_directories(common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) \ No newline at end of file +target_include_directories(common INTERFACE + $ + $ +) \ No newline at end of file diff --git a/examples/01_1DFFT/CMakeLists.txt b/examples/01_1DFFT/CMakeLists.txt index 19aa79a5..1040afde 100644 --- a/examples/01_1DFFT/CMakeLists.txt +++ b/examples/01_1DFFT/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(01_1DFFT 01_1DFFT.cpp) -target_link_libraries(01_1DFFT PUBLIC Kokkos::fft) \ No newline at end of file +target_link_libraries(01_1DFFT PUBLIC KokkosFFT::fft) \ No newline at end of file diff --git a/examples/02_2DFFT/CMakeLists.txt b/examples/02_2DFFT/CMakeLists.txt index 18c7d096..740eced1 100644 --- a/examples/02_2DFFT/CMakeLists.txt +++ b/examples/02_2DFFT/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(02_2DFFT 02_2DFFT.cpp) -target_link_libraries(02_2DFFT PUBLIC Kokkos::fft) \ No newline at end of file +target_link_libraries(02_2DFFT PUBLIC KokkosFFT::fft) \ No newline at end of file diff --git a/examples/03_NDFFT/CMakeLists.txt b/examples/03_NDFFT/CMakeLists.txt index 0dac1239..2dd0080b 100644 --- a/examples/03_NDFFT/CMakeLists.txt +++ b/examples/03_NDFFT/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(03_NDFFT 03_NDFFT.cpp) -target_link_libraries(03_NDFFT PUBLIC Kokkos::fft) \ No newline at end of file +target_link_libraries(03_NDFFT PUBLIC KokkosFFT::fft) \ No newline at end of file diff --git a/examples/04_batchedFFT/CMakeLists.txt b/examples/04_batchedFFT/CMakeLists.txt index 5fe03b30..be851125 100644 --- a/examples/04_batchedFFT/CMakeLists.txt +++ b/examples/04_batchedFFT/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(04_batchedFFT 04_batchedFFT.cpp) -target_link_libraries(04_batchedFFT PUBLIC Kokkos::fft) \ No newline at end of file +target_link_libraries(04_batchedFFT PUBLIC KokkosFFT::fft) \ No newline at end of file diff --git a/examples/05_1DFFT_HOST_DEVICE/CMakeLists.txt b/examples/05_1DFFT_HOST_DEVICE/CMakeLists.txt index c94d84f7..5baa8e2e 100644 --- a/examples/05_1DFFT_HOST_DEVICE/CMakeLists.txt +++ b/examples/05_1DFFT_HOST_DEVICE/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(05_1DFFT_HOST_DEVICE 05_1DFFT_HOST_DEVICE.cpp) -target_link_libraries(05_1DFFT_HOST_DEVICE PUBLIC Kokkos::fft) \ No newline at end of file +target_link_libraries(05_1DFFT_HOST_DEVICE PUBLIC KokkosFFT::fft) \ No newline at end of file diff --git a/examples/06_1DFFT_reuse_plans/CMakeLists.txt b/examples/06_1DFFT_reuse_plans/CMakeLists.txt index 61ec93eb..4eae3c65 100644 --- a/examples/06_1DFFT_reuse_plans/CMakeLists.txt +++ b/examples/06_1DFFT_reuse_plans/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(06_1DFFT_reuse_plans 06_1DFFT_reuse_plans.cpp) -target_link_libraries(06_1DFFT_reuse_plans PUBLIC Kokkos::fft) \ No newline at end of file +target_link_libraries(06_1DFFT_reuse_plans PUBLIC KokkosFFT::fft) \ No newline at end of file diff --git a/fft/src/CMakeLists.txt b/fft/src/CMakeLists.txt index 7d5a7e1f..269380bf 100644 --- a/fft/src/CMakeLists.txt +++ b/fft/src/CMakeLists.txt @@ -6,5 +6,8 @@ target_link_libraries(fft Kokkos::kokkos ) -target_include_directories(fft INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -add_library(Kokkos::fft ALIAS fft) \ No newline at end of file +target_include_directories(fft INTERFACE + $ + $ +) +add_library(KokkosFFT::fft ALIAS fft) \ No newline at end of file diff --git a/fft/unit_test/CMakeLists.txt b/fft/unit_test/CMakeLists.txt index 8582f118..eda9bcc6 100644 --- a/fft/unit_test/CMakeLists.txt +++ b/fft/unit_test/CMakeLists.txt @@ -2,13 +2,13 @@ add_executable(unit-tests-kokkos-fft-core Test_Main.cpp Test_Plans.cpp Test_Transform.cpp - Test_Helpers.cpp + Test_Helpers.cpp ) target_compile_features(unit-tests-kokkos-fft-core PUBLIC cxx_std_17) target_compile_options(unit-tests-kokkos-fft-core PUBLIC -std=c++17) -target_link_libraries(unit-tests-kokkos-fft-core PUBLIC Kokkos::fft GTest::gtest) +target_link_libraries(unit-tests-kokkos-fft-core PUBLIC KokkosFFT::fft GTest::gtest) # Enable GoogleTest include(GoogleTest) diff --git a/install_test/bin/install_cpu.sh b/install_test/bin/install_cpu.sh new file mode 100755 index 00000000..f0e4e4bc --- /dev/null +++ b/install_test/bin/install_cpu.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +args=$# +ROOT_DIR=$1 +WK_DIR=$(pwd) +TARGET="cpu" + +# Install Kokkos +export KOKKOS_INSTALL_PREFIX=${ROOT_DIR}/usr/local/kokkos_${TARGET} +export Kokkos_DIR=${KOKKOS_INSTALL_PREFIX}/lib/cmake/Kokkos +export KOKKOS_BUILD_DIR=build_Kokkos_${TARGET} + +export KOKKOSFFT_INSTALL_PREFIX=${ROOT_DIR}/usr/local/kokkosFFT_${TARGET} +export KokkosFFT_DIR=${KOKKOSFFT_INSTALL_PREFIX}/lib/cmake/kokkos-fft +export KOKKOSFFT_BUILD_DIR=build_KokkosFFT_${TARGET} + +export EXAMPLE_BUILD_DIR=build_example_${TARGET} + +# Install Kokkos +cd ${WK_DIR} +mkdir ${KOKKOS_BUILD_DIR} && cd ${KOKKOS_BUILD_DIR} + +# Get Kokkos from github repo and build +git clone https://github.com/kokkos/kokkos.git +cmake -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DKokkos_ENABLE_OPENMP=ON -DCMAKE_INSTALL_PREFIX=${KOKKOS_INSTALL_PREFIX} kokkos +cmake --build . -j 8 +cmake --install . + +# Install KokkosFFT +cd ${WK_DIR} +mkdir ${KOKKOSFFT_BUILD_DIR} && cd ${KOKKOSFFT_BUILD_DIR} +cmake -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DKokkos_ENABLE_OPENMP=ON -DCMAKE_INSTALL_PREFIX=${KOKKOSFFT_INSTALL_PREFIX} .. +cmake --build . -j 8 +cmake --install . + +# Try to build an example +# Build KokkosFFT code using installed KokkosFFT +cd ${WK_DIR} +mkdir ${EXAMPLE_BUILD_DIR} && cd ${EXAMPLE_BUILD_DIR} +cmake -DCMAKE_BUILD_TYPE=Release -DKokkos_ENABLE_OPENMP=ON ../install_test/src +cmake --build . -j 8 + +if [ $? -eq 0 ]; then + echo "*** install test: build SUCCESSFUL ***" +else + echo "*** install test: build FAILED ***" + exit 1; +fi \ No newline at end of file diff --git a/install_test/bin/install_cuda.sh b/install_test/bin/install_cuda.sh new file mode 100755 index 00000000..7efaf85f --- /dev/null +++ b/install_test/bin/install_cuda.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +args=$# +ROOT_DIR=$1 +WK_DIR=$(pwd) +TARGET=$2 +KOKKOS_TARGET=${TARGET} + +# Install Kokkos +export KOKKOS_INSTALL_PREFIX=${ROOT_DIR}/usr/local/kokkos_${KOKKOS_TARGET} +export Kokkos_DIR=${KOKKOS_INSTALL_PREFIX}/lib/cmake/Kokkos +export KOKKOS_BUILD_DIR=build_Kokkos_${KOKKOS_TARGET} + +export KOKKOSFFT_INSTALL_PREFIX=${ROOT_DIR}/usr/local/kokkosFFT_${TARGET} +export KokkosFFT_DIR=${KOKKOSFFT_INSTALL_PREFIX}/lib/cmake/kokkos-fft +export KOKKOSFFT_BUILD_DIR=build_KokkosFFT_${TARGET} + +export EXAMPLE_BUILD_DIR=build_example_${TARGET} +export CXX_COMPILER=${WK_DIR}/${KOKKOS_BUILD_DIR}/kokkos/bin/nvcc_wrapper + +# Install Kokkos if not exist +if [ ! -d ${Kokkos_DIR} ]; then + cd ${WK_DIR} + mkdir ${KOKKOS_BUILD_DIR} && cd ${KOKKOS_BUILD_DIR} + + # Get Kokkos from github repo and build + git clone https://github.com/kokkos/kokkos.git + cmake -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \ + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON \ + -DCMAKE_INSTALL_PREFIX=${KOKKOS_INSTALL_PREFIX} kokkos + + cmake --build . -j 8 + cmake --install . +fi + +# Install KokkosFFT +cd ${WK_DIR} +mkdir ${KOKKOSFFT_BUILD_DIR} && cd ${KOKKOSFFT_BUILD_DIR} +if [ $TARGET == "CUDA" ]; then + cmake -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \ + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON \ + -DCMAKE_INSTALL_PREFIX=${KOKKOSFFT_INSTALL_PREFIX} .. +else + cmake -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \ + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON \ + -DCMAKE_INSTALL_PREFIX=${KOKKOSFFT_INSTALL_PREFIX} -DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON .. +fi +cmake --build . -j 8 +cmake --install . + +# Try to build an example +# Build KokkosFFT code using installed KokkosFFT +cd ${WK_DIR} +mkdir ${EXAMPLE_BUILD_DIR} && cd ${EXAMPLE_BUILD_DIR} +cmake -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \ + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON ../install_test/src +cmake --build . -j 8 + +if [ $? -eq 0 ]; then + echo "*** install test: build SUCCESSFUL ***" +else + echo "*** install test: build FAILED ***" + exit 1; +fi \ No newline at end of file diff --git a/install_test/bin/install_hip.sh b/install_test/bin/install_hip.sh new file mode 100755 index 00000000..01e8c9fc --- /dev/null +++ b/install_test/bin/install_hip.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +args=$# +ROOT_DIR=$1 +WK_DIR=$(pwd) +TARGET=$2 +KOKKOS_TARGET=${TARGET} + +# Install Kokkos +export KOKKOS_INSTALL_PREFIX=${ROOT_DIR}/usr/local/kokkos_${KOKKOS_TARGET} +export Kokkos_DIR=${KOKKOS_INSTALL_PREFIX}/lib/cmake/Kokkos +export KOKKOS_BUILD_DIR=build_Kokkos_${KOKKOS_TARGET} + +export KOKKOSFFT_INSTALL_PREFIX=${ROOT_DIR}/usr/local/kokkosFFT_${TARGET} +export KokkosFFT_DIR=${KOKKOSFFT_INSTALL_PREFIX}/lib/cmake/kokkos-fft +export KOKKOSFFT_BUILD_DIR=build_KokkosFFT_${TARGET} + +export EXAMPLE_BUILD_DIR=build_example_${TARGET} + +# Install Kokkos if not exist +if [ ! -d ${Kokkos_DIR} ]; then + cd ${WK_DIR} + mkdir ${KOKKOS_BUILD_DIR} && cd ${KOKKOS_BUILD_DIR} + + # Get Kokkos from github repo and build + git clone https://github.com/kokkos/kokkos.git + cmake -DCMAKE_CXX_COMPILER=hipcc \ + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON \ + -DCMAKE_INSTALL_PREFIX=${KOKKOS_INSTALL_PREFIX} kokkos + + cmake --build . -j 8 + cmake --install . +fi + +# Install KokkosFFT +cd ${WK_DIR} +mkdir ${KOKKOSFFT_BUILD_DIR} && cd ${KOKKOSFFT_BUILD_DIR} +if [ $TARGET == "HIP" ]; then + cmake -DCMAKE_CXX_COMPILER=hipcc \ + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON \ + -DCMAKE_INSTALL_PREFIX=${KOKKOSFFT_INSTALL_PREFIX} .. +else + cmake -DCMAKE_CXX_COMPILER=hipcc \ + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON \ + -DCMAKE_INSTALL_PREFIX=${KOKKOSFFT_INSTALL_PREFIX} -DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON .. +fi +cmake --build . -j 8 +cmake --install . + +# Try to build an example +# Build KokkosFFT code using installed KokkosFFT +cd ${WK_DIR} +mkdir ${EXAMPLE_BUILD_DIR} && cd ${EXAMPLE_BUILD_DIR} +cmake -DCMAKE_CXX_COMPILER=hipcc \ + -DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON \ + ../install_test/src +cmake --build . -j 8 + +if [ $? -eq 0 ]; then + echo "*** install test: build SUCCESSFUL ***" +else + echo "*** install test: build FAILED ***" + exit 1; +fi \ No newline at end of file diff --git a/install_test/src/CMakeLists.txt b/install_test/src/CMakeLists.txt new file mode 100644 index 00000000..daea4cf6 --- /dev/null +++ b/install_test/src/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.21) +project(install-test LANGUAGES CXX) + +find_package(Kokkos CONFIG REQUIRED) +find_package(KokkosFFT CONFIG REQUIRED) + +message("KokkosFFT_TARGET_FILE: ${KokkosFFT_TARGET_FILE}") + +add_executable(install-test main.cpp) +target_compile_features(install-test PUBLIC cxx_std_17) +target_link_libraries(install-test PUBLIC Kokkos::kokkos KokkosFFT::fft) \ No newline at end of file diff --git a/install_test/src/main.cpp b/install_test/src/main.cpp new file mode 100644 index 00000000..a7117df9 --- /dev/null +++ b/install_test/src/main.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include + +using execution_space = Kokkos::DefaultExecutionSpace; +template +using View1D = Kokkos::View; + +int main(int argc, char* argv[]) { + Kokkos::initialize(argc, argv); + { + constexpr int n0 = 128; + const Kokkos::complex I(1.0, 1.0); + + // 1D C2C FFT (Forward and Backward) + View1D > xc2c("xc2c", n0); + View1D > xc2c_hat("xc2c_hat", n0); + View1D > xc2c_inv("xc2c_inv", n0); + + Kokkos::Random_XorShift64_Pool<> random_pool(12345); + Kokkos::fill_random(xc2c, random_pool, I); + + KokkosFFT::fft(execution_space(), xc2c, xc2c_hat); + KokkosFFT::ifft(execution_space(), xc2c_hat, xc2c_inv); + + // 1D R2C FFT + View1D xr2c("xr2c", n0); + View1D > xr2c_hat("xr2c_hat", n0 / 2 + 1); + Kokkos::fill_random(xr2c, random_pool, 1); + + KokkosFFT::rfft(execution_space(), xr2c, xr2c_hat); + + // 1D C2R FFT + View1D > xc2r("xr2c_hat", n0 / 2 + 1); + View1D xc2r_hat("xc2r", n0); + Kokkos::fill_random(xc2r, random_pool, I); + + KokkosFFT::irfft(execution_space(), xc2r, xc2r_hat); + } + Kokkos::finalize(); + + return 0; +} \ No newline at end of file