Skip to content

Commit

Permalink
Merge pull request #64 from CExA-project/install-test
Browse files Browse the repository at this point in the history
Install test
  • Loading branch information
yasahi-hpc authored Feb 29, 2024
2 parents e85a996 + 3a01923 commit 202bed0
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 63 deletions.
158 changes: 121 additions & 37 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
DOCKER_BUILDKIT: 1

jobs:
# run linter on the code
lint:
runs-on: ubuntu-latest
steps:
Expand All @@ -28,12 +29,14 @@ jobs:
extensions: 'hpp,cpp'
clangFormatVersion: 12

# check if Docker images should be recreated
check_docker_files:
uses: ./.github/workflows/__check_docker_files.yaml

with:
event_name: ${{ github.event_name }}

# build Docker images if necessary
build_base:
needs: check_docker_files

Expand All @@ -45,6 +48,7 @@ jobs:
image_suffix: ${{ needs.check_docker_files.outputs.image_suffix }}
image_tag: ${{ needs.check_docker_files.outputs.image_tag }}

# build project
build:
runs-on: ubuntu-latest

Expand All @@ -60,41 +64,62 @@ jobs:
backend:
- name: openmp
image: gcc
c_compiler: gcc
cxx_compiler: g++
cmake_flags: -DKokkos_ENABLE_OPENMP=ON
compiler:
c: gcc
cxx: g++
cmake_flags:
kokkos: -DKokkos_ENABLE_OPENMP=ON
kokkos_fft: ""
- name: threads
image: gcc
c_compiler: gcc
cxx_compiler: g++
cmake_flags: -DKokkos_ENABLE_THREADS=ON
compiler:
c: gcc
cxx: g++
cmake_flags:
kokkos: -DKokkos_ENABLE_THREADS=ON
kokkos_fft: ""
- name: serial
image: gcc
c_compiler: gcc
cxx_compiler: g++
cmake_flags: -DKokkos_ENABLE_SERIAL=ON
compiler:
c: gcc
cxx: g++
cmake_flags:
kokkos: -DKokkos_ENABLE_SERIAL=ON
kokkos_fft: ""
- name: cuda
image: nvcc
c_compiler: gcc
cxx_compiler: g++
cmake_flags: -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON
compiler:
c: gcc
cxx: g++
cmake_flags:
kokkos: -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON
kokkos_fft: ""
- name: hip
image: rocm
c_compiler: hipcc
cxx_compiler: hipcc
cmake_flags: -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON
compiler:
c: hipcc
cxx: hipcc
cmake_flags:
kokkos: -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON
kokkos_fft: -DKokkosFFT_ENABLE_ROCFFT=ON
- name: rocm
image: rocm
c_compiler: hipcc
cxx_compiler: hipcc
cmake_flags: -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON -DKokkosFFT_ENABLE_ROCFFT=ON
compiler:
c: hipcc
cxx: hipcc
cmake_flags:
kokkos: -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_VEGA90A=ON
kokkos_fft: ""
- name: sycl
image: intel
c_compiler: icx
cxx_compiler: icpx
# building for Intel PVC was unsuccessful without the proper device
# for now on, we simply use Intel GPU generic code
cmake_flags: -DKokkos_ENABLE_SYCL=ON -DKokkos_ARCH_INTEL_GEN=ON
compiler:
c: icx
cxx: icpx
cmake_flags:
# building for Intel PVC was unsuccessful without the proper
# device, so for now, we simply generate generic Intel GPU code
kokkos: -DKokkos_ENABLE_SYCL=ON -DKokkos_ARCH_INTEL_GEN=ON
kokkos_fft: ""
target:
- name: native
cmake_flags: ""
Expand Down Expand Up @@ -130,16 +155,16 @@ jobs:
run: |
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake -B build \
-DCMAKE_INSTALL_PREFIX=/work/install \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_C_COMPILER=${{ matrix.backend.c_compiler }} \
-DCMAKE_CXX_COMPILER=${{ matrix.backend.cxx_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.backend.compiler.c }} \
-DCMAKE_CXX_COMPILER=${{ matrix.backend.compiler.cxx }} \
-DCMAKE_CXX_STANDARD=17 \
-DKokkosFFT_ENABLE_EXAMPLES=ON \
-DKokkosFFT_ENABLE_TESTS=ON \
-DKokkosFFT_ENABLE_BENCHMARK=ON \
-DKokkosFFT_ENABLE_INTERNAL_KOKKOS=ON \
${{ matrix.backend.cmake_flags }} \
${{ matrix.backend.cmake_flags.kokkos }} \
${{ matrix.backend.cmake_flags.kokkos_fft }} \
${{ matrix.target.cmake_flags }}
- name: Build
Expand All @@ -160,25 +185,84 @@ jobs:
path: tests_${{ matrix.backend.name }}.tar
if: ${{ matrix.target.name == 'native' }}

- name: Install
# consume the project in a dummy project
# ideally, this part should be executed in a different job using almost
# the same `matrix` (minus `target`) as the `build` job and having the
# same `needs` and `if` as the `test` job; this would however make a
# duplicated and error-prone `matrix`, and sharing a `matrix` between
# jobs is currently not possible with GitHub Actions (neither directly,
# nor using YAML anchors, other options were too cumbersome when writing
# this); consequently, this part is just here for now

- name: Prepare as subdirectory
run: |
# prepare kokkos
git clone ./tpls/kokkos ./install_test/as_subdirectory/tpls/kokkos
# prepare kokkos-fft
git clone . ./install_test/as_subdirectory/tpls/kokkos-fft
- name: Configure and build test project as subdirectory
run: |
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake --install build
cmake -B install_test/as_subdirectory/build \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_C_COMPILER=${{ matrix.backend.compiler.c }} \
-DCMAKE_CXX_COMPILER=${{ matrix.backend.compiler.cxx }} \
-DCMAKE_CXX_STANDARD=17 \
${{ matrix.backend.cmake_flags.kokkos }} \
${{ matrix.backend.cmake_flags.kokkos_fft }} \
${{ matrix.target.cmake_flags }} \
install_test/as_subdirectory
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake --build install_test/as_subdirectory/build
- name: Configure and build test code
# Use the built and installed Kokkos FFT library to build a test code
- name: Configure, build and install Kokkos as library
run: |
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake -B build_test \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DCMAKE_C_COMPILER=${{ matrix.backend.c_compiler }} \
-DCMAKE_CXX_COMPILER=${{ matrix.backend.cxx_compiler }} \
cmake -B build_kokkos \
-DCMAKE_INSTALL_PREFIX=/work/install \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_C_COMPILER=${{ matrix.backend.compiler.c }} \
-DCMAKE_CXX_COMPILER=${{ matrix.backend.compiler.cxx }} \
-DCMAKE_CXX_STANDARD=17 \
${{ matrix.backend.cmake_flags.kokkos }} \
tpls/kokkos
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake --build build_kokkos -j $(( $(nproc) * 2 + 1 ))
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake --install build_kokkos
- name: Configure, build and install KokkosFFT as library
run: |
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake -B build_kokkos_fft \
-DCMAKE_INSTALL_PREFIX=/work/install\
-DCMAKE_PREFIX_PATH=/work/install \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_C_COMPILER=${{ matrix.backend.compiler.c }} \
-DCMAKE_CXX_COMPILER=${{ matrix.backend.compiler.cxx }} \
-DCMAKE_CXX_STANDARD=17 \
${{ matrix.backend.cmake_flags.kokkos_fft }} \
${{ matrix.target.cmake_flags }}
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake --build build_kokkos_fft -j $(( $(nproc) * 2 + 1 ))
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake --install build_kokkos_fft
- name: Configure and build test project as library
run: |
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake -B install_test/as_library/build \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_PREFIX_PATH=/work/install \
install_test
-DCMAKE_C_COMPILER=${{ matrix.backend.compiler.c }} \
-DCMAKE_CXX_COMPILER=${{ matrix.backend.compiler.cxx }} \
-DCMAKE_CXX_STANDARD=17 \
install_test/as_library
docker run -v ${{ github.workspace }}:/work ghcr.io/cexa-project/kokkos-fft/base_${{ matrix.backend.image }}_${{ needs.check_docker_files.outputs.image_suffix }}:${{ needs.check_docker_files.outputs.image_tag }} \
cmake --build build_test -j $(( $(nproc) * 2 + 1 ))
cmake --build install_test/as_library/build -j $(( $(nproc) * 2 + 1 ))
# test the project
test:
runs-on: ${{ matrix.backend.runner }}

Expand Down
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ set(KOKKOSFFT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(KOKKOSFFT_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(KOKKOSFFT_VERSION_PATCH ${PROJECT_VERSION_PATCH})

set(KOKKOS_REQUIRED_VERSION "4.2.00")
set(KOKKOS_REQUIRED_VERSION 4.2.0)

if (NOT KokkosFFT_ENABLE_INTERNAL_KOKKOS)
# First check, Kokkos is added as subdirectory or not
if(NOT TARGET Kokkos::kokkos)
find_package(Kokkos REQUIRED)
find_package(Kokkos ${KOKKOS_REQUIRED_VERSION} REQUIRED)
endif()

# Kokkos version check
include(Kokkos_Version_Check)
check_minimum_required_kokkos(${KOKKOS_REQUIRED_VERSION})
else ()
add_subdirectory(tpls/kokkos)
endif ()
Expand Down
11 changes: 0 additions & 11 deletions cmake/Kokkos_Version_Check.cmake

This file was deleted.

9 changes: 0 additions & 9 deletions install_test/CMakeLists.txt

This file was deleted.

8 changes: 8 additions & 0 deletions install_test/as_library/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.22)
project(kokkos-fft-as-library LANGUAGES CXX)

find_package(Kokkos CONFIG REQUIRED)
find_package(KokkosFFT CONFIG REQUIRED)

add_executable(hello-kokkos-fft hello.cpp)
target_link_libraries(hello-kokkos-fft PUBLIC Kokkos::kokkos KokkosFFT::fft)
File renamed without changes.
8 changes: 8 additions & 0 deletions install_test/as_subdirectory/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.22)
project(kokkos-fft-as-subdirectory LANGUAGES CXX)

add_subdirectory(tpls/kokkos)
add_subdirectory(tpls/kokkos-fft)

add_executable(hello-kokkos-fft hello.cpp)
target_link_libraries(hello-kokkos-fft PUBLIC Kokkos::kokkos KokkosFFT::fft)
44 changes: 44 additions & 0 deletions install_test/as_subdirectory/hello.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <Kokkos_Core.hpp>
#include <Kokkos_Complex.hpp>
#include <Kokkos_Random.hpp>
#include <KokkosFFT.hpp>

using execution_space = Kokkos::DefaultExecutionSpace;
template <typename T>
using View2D = Kokkos::View<T**, execution_space>;

int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
{
constexpr int n0 = 128, n1 = 128;
const Kokkos::complex<double> I(1.0, 1.0);

// 2D C2C FFT (Forward and Backward)
View2D<Kokkos::complex<double> > xc2c("xc2c", n0, n1);
View2D<Kokkos::complex<double> > xc2c_hat("xc2c_hat", n0, n1);
View2D<Kokkos::complex<double> > xc2c_inv("xc2c_inv", n0, n1);

Kokkos::Random_XorShift64_Pool<> random_pool(12345);
Kokkos::fill_random(xc2c, random_pool, I);

KokkosFFT::fft2(execution_space(), xc2c, xc2c_hat);
KokkosFFT::ifft2(execution_space(), xc2c_hat, xc2c_inv);

// 2D R2C FFT
View2D<double> xr2c("xr2c", n0, n1);
View2D<Kokkos::complex<double> > xr2c_hat("xr2c_hat", n0, n1 / 2 + 1);
Kokkos::fill_random(xr2c, random_pool, 1);

KokkosFFT::rfft2(execution_space(), xr2c, xr2c_hat);

// 2D C2R FFT
View2D<Kokkos::complex<double> > xc2r("xr2c_hat", n0, n1 / 2 + 1);
View2D<double> xc2r_hat("xc2r", n0, n1);
Kokkos::fill_random(xc2r, random_pool, I);

KokkosFFT::irfft2(execution_space(), xc2r, xc2r_hat);
}
Kokkos::finalize();

return 0;
}

0 comments on commit 202bed0

Please sign in to comment.