Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install test #64

Merged
merged 37 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a592ee3
recover scripts for build tests as lib
Feb 20, 2024
4480922
rename scripts
Feb 20, 2024
3d0e7cf
Add install tests in CI
Feb 20, 2024
5399547
fix path
Feb 20, 2024
fb4cf79
fix typo in CMake
Feb 20, 2024
42899d7
fix permission
Feb 20, 2024
4183a6c
fix path
Feb 20, 2024
3d6b5e8
fix path
Feb 20, 2024
4196455
fix path
Feb 20, 2024
e605b72
fix path
Feb 20, 2024
b8fddfd
fix path
Feb 20, 2024
85beb88
fix CMake option
Feb 20, 2024
fee1f7a
rename work
Feb 20, 2024
ef6dba3
Fix kokkos version check
Feb 20, 2024
902216a
fix script
Feb 20, 2024
f1478c2
fix issues for GPU build
Feb 20, 2024
695bed8
Add compilers
Feb 21, 2024
add1553
Simplify version check
Feb 22, 2024
39bfd9b
Do not clone Kokkos from repo in install test
Feb 22, 2024
902a6a0
update workflow
Feb 22, 2024
f1ac396
copy kokkos
Feb 22, 2024
5e0cff6
git clone kokkos again
Feb 22, 2024
bd7cc39
Merge branch 'main' into install-test
Feb 27, 2024
1a5182e
update CI to handle rocfft
Feb 27, 2024
31bf604
fix kokkos path
Feb 27, 2024
c9d6240
Use separate variable for KokkosFFT configure options
pzehner Feb 28, 2024
80ade25
Use objects instead of plain variables
pzehner Feb 28, 2024
e1eb8bd
Separate build and install jobs
pzehner Feb 28, 2024
d46a952
Fix prepare as subdirectory
pzehner Feb 28, 2024
5706110
Install early
pzehner Feb 28, 2024
53bed57
Fix prepare as subdirectory
pzehner Feb 28, 2024
f8672d8
Fix install paths
pzehner Feb 28, 2024
829e7c6
Mutualize build backends
pzehner Feb 28, 2024
7506ef6
Run install job after build job
pzehner Feb 28, 2024
a90454f
Merge build and install jobs
pzehner Feb 28, 2024
de719d7
Lower CMake requirements on install tests and harmonize file names
pzehner Feb 28, 2024
3a01923
Remove test install script
pzehner Feb 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,19 @@ jobs:
path: tests_${{ matrix.backend.name }}.tar
if: ${{ matrix.target.name == 'native' }}

- name: Install
- name: Use KokkosFFT as a subdirectory in a CMake project
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
./install_test/as_subdirectory/as_subdirectory.sh /tmp ${{env.BUILD_TYPE}} ${{ matrix.backend.c_compiler }} ${{ matrix.backend.cxx_compiler }} \
${{ matrix.backend.cmake_flags }} ${{ matrix.target.cmake_flags }}
if: ${{ matrix.target.name == 'native' }}

- name: Configure and build test code
# Use the built and installed Kokkos FFT library to build a test code
- name: Use KokkosFFT as a library in a CMake project
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 }} \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_PREFIX_PATH=/work/install \
install_test
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 ))
./install_test/as_library/as_library.sh /tmp ${{env.BUILD_TYPE}} ${{ matrix.backend.c_compiler }} ${{ matrix.backend.cxx_compiler }} \
${{ matrix.backend.cmake_flags }} ${{ matrix.target.cmake_flags }}
if: ${{ matrix.target.name == 'native' }}

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 @@ -25,17 +25,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.23)
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)
94 changes: 94 additions & 0 deletions install_test/as_library/as_library.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

args=$#
WK_DIR=$(pwd)
ROOT_DIR=$1
BUILD_TYPE=$2
C_COMPILER=$3
CXX_COMPILER=$4

if [ $args -eq 5 ]; then
# CPU build
# e.g
# /tmp Release gcc g++ -DKokkos_ENABLE_THREADS=ON
BACKEND_FLAG=$5
TARGET_FLAG=$6
elif [ $args -eq 6 ]; then
# GPU build without target flag
# e.g.
# /tmp Release gcc g++ \
# -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON
BACKEND_FLAG0=$5
BACKEND_FLAG1=$6
BACKEND_FLAG="${BACKEND_FLAG0} ${BACKEND_FLAG1}"
TARGET_FLAG=$7
elif [ $args -eq 7 ]; then
# GPU build with target flag
# e.g.
# /tmp Release gcc g++ \
# -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON -DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON
BACKEND_FLAG0=$5
BACKEND_FLAG1=$6
BACKEND_FLAG="${BACKEND_FLAG0} ${BACKEND_FLAG1}"
TARGET_FLAG=$7
else
echo "*** Error: Number of arguments must be 5, 6 or 7 ***"
exit 1;
fi

# Install Kokkos
export KOKKOS_INSTALL_PREFIX=${ROOT_DIR}/usr/local/kokkos
export KOKKOS_BUILD_DIR=build_Kokkos

export KOKKOSFFT_INSTALL_PREFIX=${ROOT_DIR}/usr/local/kokkosFFT
export KOKKOSFFT_BUILD_DIR=build_KokkosFFT

export EXAMPLE_BUILD_DIR=build_example

# Install Kokkos
# Get Kokkos from tpls/kokkos and build
cd ${WK_DIR}
mkdir ${KOKKOS_BUILD_DIR} && cd ${KOKKOS_BUILD_DIR}
cp -r ../tpls/kokkos .
cmake -DCMAKE_INSTALL_PREFIX=${KOKKOS_INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_STANDARD=17 \
${BACKEND_FLAG} kokkos

cmake --build . -j 8
cmake --install .

# Install KokkosFFT on pre-installbed Kokkos
cd ${WK_DIR}
mkdir ${KOKKOSFFT_BUILD_DIR} && cd ${KOKKOSFFT_BUILD_DIR}
cmake -DCMAKE_PREFIX_PATH=${KOKKOS_INSTALL_PREFIX} \
-DCMAKE_INSTALL_PREFIX=${KOKKOSFFT_INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_STANDARD=17 \
${TARGET_FLAG} ..

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_PREFIX_PATH="${KOKKOS_INSTALL_PREFIX};${KOKKOSFFT_INSTALL_PREFIX}" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_STANDARD=17 \
../install_test/as_library
cmake --build . -j 8

if [ $? -eq 0 ]; then
echo "*** KokkosFFT as library test: build SUCCESSFUL ***"
else
echo "*** KokkosFFT as library test: build FAILED ***"
exit 1;
fi
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.23)
project(kokkos-fft-as-subdirectory LANGUAGES CXX)

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

add_executable(hello-kokkos-fft hello_again.cpp)
target_link_libraries(hello-kokkos-fft PUBLIC Kokkos::kokkos KokkosFFT::fft)
75 changes: 75 additions & 0 deletions install_test/as_subdirectory/as_subdirectory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

args=$#
WK_DIR=/tmp/kokkos_fft_as_subdirectory
SRC_DIR=/work
ROOT_DIR=$1
BUILD_TYPE=$2
C_COMPILER=$3
CXX_COMPILER=$4

if [ $args -eq 5 ]; then
# CPU build
# e.g
# /tmp Release gcc g++ -DKokkos_ENABLE_THREADS=ON
# TARGET_FLAG is empty
BACKEND_FLAG=$5
TARGET_FLAG=$6
elif [ $args -eq 6 ]; then
# GPU build without target flag
# e.g.
# /tmp Release gcc g++ \
# -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON
# TARGET_FLAG is empty
BACKEND_FLAG0=$5
BACKEND_FLAG1=$6
BACKEND_FLAG="${BACKEND_FLAG0} ${BACKEND_FLAG1}"
TARGET_FLAG=$7
elif [ $args -eq 7 ]; then
# GPU build with target flag
# e.g.
# /tmp Release gcc g++ \
# -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_AMPERE80=ON -DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON
BACKEND_FLAG0=$5
BACKEND_FLAG1=$6
BACKEND_FLAG="${BACKEND_FLAG0} ${BACKEND_FLAG1}"
TARGET_FLAG=$7
else
echo "*** Error: Number of arguments must be 5, 6 or 7 ***"
exit 1;
fi

# Make work directory (Project directory)
mkdir -p ${WK_DIR} && cd ${WK_DIR}

# Copy CMakeLists.txt and hello.cpp
cp ${SRC_DIR}/install_test/as_subdirectory/* .

# Prepare Kokkos and KokkosFFT under tpls
mkdir tpls && cd tpls

# Prepare tpls/kokkos
git clone https://github.com/kokkos/kokkos.git

# Copy KokkosFFT under tpls/kokkos-fft
cp -r ${SRC_DIR} kokkos-fft
pzehner marked this conversation as resolved.
Show resolved Hide resolved

# Try to build an example
# Build KokkosFFT code using Kokkos and KokkosFFT as submodules

export EXAMPLE_BUILD_DIR=build_example
cd ${WK_DIR}
mkdir ${EXAMPLE_BUILD_DIR} && cd ${EXAMPLE_BUILD_DIR}
cmake -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
${BACKEND_FLAG} \
${TARGET_FLAG} ..

cmake --build . -j 8

if [ $? -eq 0 ]; then
echo "*** KokkosFFT as subdirectory test: build SUCCESSFUL ***"
else
echo "*** KokkosFFT as subdirectory test: build FAILED ***"
exit 1;
fi
44 changes: 44 additions & 0 deletions install_test/as_subdirectory/hello_again.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;
}
Loading