-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from CExA-project/reuse-plan
Reuse plan
- Loading branch information
Showing
8 changed files
with
945 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,11 +82,15 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
env: | ||
backends: HIP HIP_HOST_DEVICE | ||
#backends: HIP HIP_HOST_DEVICE | ||
architecture: VEGA90A | ||
CMAKE_CXX_COMPILER: hipcc | ||
container: amd_env | ||
|
||
strategy: | ||
matrix: | ||
backend: [ {name: HIP, option: ""}, {name: HIP_HOST_DEVICE, option: "-DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON"} ] | ||
|
||
steps: | ||
- name: Free Disk Space (Ubuntu) | ||
uses: jlumbroso/[email protected] | ||
|
@@ -107,22 +111,25 @@ jobs: | |
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: | | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_HIP \ | ||
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 | ||
-DCMAKE_CXX_STANDARD=17 -DKokkos_ENABLE_HIP=ON -DKokkos_ARCH_${{env.architecture}}=ON -DBUILD_TESTING=ON ${{matrix.backend.option}} | ||
- name: Configure CMake for HIP 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. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: | | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_HIP_HOST_DEVICE \ | ||
-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 \ | ||
-DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON | ||
#- name: Configure CMake for HIP 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. | ||
# # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
# run: | | ||
# docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake -B build_HIP_HOST_DEVICE \ | ||
# -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 \ | ||
# -DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON | ||
|
||
- name: Build | ||
# Build your program with the given configuration | ||
run: | | ||
for backend in ${{ env.backends }}; do | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake --build build_${backend} --config ${{env.BUILD_TYPE}} -j 2 | ||
done | ||
docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake --build build_${{matrix.backend.name}} --config ${{env.BUILD_TYPE}} -j 2 | ||
#run: | | ||
# for backend in ${{ env.backends }}; do | ||
# docker run -v ${{github.workspace}}:/work ${{ env.container }} cmake --build build_${backend} --config ${{env.BUILD_TYPE}} -j 2 | ||
# done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <Kokkos_Core.hpp> | ||
#include <Kokkos_Complex.hpp> | ||
#include <Kokkos_Random.hpp> | ||
#include <KokkosFFT.hpp> | ||
|
||
using execution_space = Kokkos::DefaultExecutionSpace; | ||
template <typename T> using View1D = Kokkos::View<T*, execution_space>; | ||
|
||
int main( int argc, char* argv[] ) { | ||
Kokkos::initialize( argc, argv ); | ||
{ | ||
constexpr int n0 = 128; | ||
const Kokkos::complex<double> I(1.0, 1.0); | ||
|
||
// 1D C2C FFT (Forward and Backward) | ||
View1D<Kokkos::complex<double> > xc2c("xc2c", n0); | ||
View1D<Kokkos::complex<double> > xc2c_hat("xc2c_hat", n0); | ||
View1D<Kokkos::complex<double> > xc2c_inv("xc2c_inv", n0); | ||
|
||
Kokkos::Random_XorShift64_Pool<> random_pool(12345); | ||
Kokkos::fill_random(xc2c, random_pool, I); | ||
|
||
int axis = -1; | ||
KokkosFFT::Impl::Plan fft_plan(execution_space(), xc2c, xc2c_hat, KokkosFFT::Impl::Direction::Forward, axis); | ||
KokkosFFT::fft(execution_space(), xc2c, xc2c_hat, fft_plan); | ||
|
||
KokkosFFT::Impl::Plan ifft_plan(execution_space(), xc2c_hat, xc2c_inv, KokkosFFT::Impl::Direction::Backward, axis); | ||
KokkosFFT::ifft(execution_space(), xc2c_hat, xc2c_inv, ifft_plan); | ||
|
||
// 1D R2C FFT | ||
View1D<double> xr2c("xr2c", n0); | ||
View1D<Kokkos::complex<double> > xr2c_hat("xr2c_hat", n0/2+1); | ||
Kokkos::fill_random(xr2c, random_pool, 1); | ||
|
||
KokkosFFT::Impl::Plan rfft_plan(execution_space(), xr2c, xr2c_hat, KokkosFFT::Impl::Direction::Forward, axis); | ||
KokkosFFT::rfft(execution_space(), xr2c, xr2c_hat, rfft_plan); | ||
|
||
// 1D C2R FFT | ||
View1D<Kokkos::complex<double> > xc2r("xc2r_hat", n0/2+1); | ||
View1D<double> xc2r_hat("xc2r", n0); | ||
Kokkos::fill_random(xc2r, random_pool, I); | ||
|
||
KokkosFFT::Impl::Plan irfft_plan(execution_space(), xc2r, xc2r_hat, KokkosFFT::Impl::Direction::Backward, axis); | ||
KokkosFFT::irfft(execution_space(), xc2r, xc2r_hat, irfft_plan); | ||
} | ||
Kokkos::finalize(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_executable(06_1DFFT_reuse_plans 06_1DFFT_reuse_plans.cpp) | ||
target_link_libraries(06_1DFFT_reuse_plans PUBLIC Kokkos::fft) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import numpy as np | ||
|
||
if __name__ == '__main__': | ||
n0 = 128 | ||
|
||
# 1D C2C FFT (Forward and Backward) | ||
xc2c = np.random.rand(n0) + 1j * np.random.rand(n0) | ||
xc2c_hat = np.fft.fft(xc2c) | ||
xc2c_inv = np.fft.ifft(xc2c_hat) | ||
|
||
# 1D R2C FFT | ||
xr2c = np.random.rand(n0) | ||
xr2c_hat = np.fft.rfft(xr2c) | ||
|
||
# 1D C2R FFT | ||
xc2r = np.random.rand(n0//2+1) | ||
xc2r_hat = np.fft.irfft(xc2r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.