Skip to content

Commit

Permalink
remove unnecessary barriers from examples (#162)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuuichi Asahi <[email protected]>
  • Loading branch information
yasahi-hpc and Yuuichi Asahi authored Oct 9, 2024
1 parent 0d3a662 commit 00b831d
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 48 deletions.
5 changes: 0 additions & 5 deletions examples/01_1DFFT/01_1DFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,21 @@ int main(int argc, char* argv[]) {
Kokkos::Random_XorShift64_Pool<> random_pool(12345);
execution_space exec;
Kokkos::fill_random(exec, xc2c, random_pool, z);
exec.fence();

KokkosFFT::fft(exec, xc2c, xc2c_hat);
KokkosFFT::ifft(exec, xc2c_hat, xc2c_inv);
exec.fence();

// 1D R2C FFT
View1D<double> xr2c("xr2c", n0);
View1D<Kokkos::complex<double> > xr2c_hat("xr2c_hat", n0 / 2 + 1);
Kokkos::fill_random(exec, xr2c, random_pool, 1);
exec.fence();

KokkosFFT::rfft(exec, xr2c, xr2c_hat);
exec.fence();

// 1D C2R FFT
View1D<Kokkos::complex<double> > xc2r("xr2c_hat", n0 / 2 + 1);
View1D<double> xc2r_hat("xc2r", n0);
Kokkos::fill_random(exec, xc2r, random_pool, z);
exec.fence();

KokkosFFT::irfft(exec, xc2r, xc2r_hat);
exec.fence();
Expand Down
5 changes: 0 additions & 5 deletions examples/02_2DFFT/02_2DFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,21 @@ int main(int argc, char* argv[]) {
Kokkos::Random_XorShift64_Pool<> random_pool(12345);
execution_space exec;
Kokkos::fill_random(exec, xc2c, random_pool, z);
exec.fence();

KokkosFFT::fft2(exec, xc2c, xc2c_hat);
KokkosFFT::ifft2(exec, xc2c_hat, xc2c_inv);
exec.fence();

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

KokkosFFT::rfft2(exec, xr2c, xr2c_hat);
exec.fence();

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

KokkosFFT::irfft2(exec, xc2r, xc2r_hat);
exec.fence();
Expand Down
5 changes: 0 additions & 5 deletions examples/03_NDFFT/03_NDFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,21 @@ int main(int argc, char* argv[]) {
Kokkos::Random_XorShift64_Pool<> random_pool(12345);
execution_space exec;
Kokkos::fill_random(exec, xc2c, random_pool, z);
exec.fence();

KokkosFFT::fftn(exec, xc2c, xc2c_hat, axis_type<3>{-3, -2, -1});
KokkosFFT::ifftn(exec, xc2c_hat, xc2c_inv, axis_type<3>{-3, -2, -1});
exec.fence();

// 3D R2C FFT
View3D<double> xr2c("xr2c", n0, n1, n2);
View3D<Kokkos::complex<double> > xr2c_hat("xr2c_hat", n0, n1, n2 / 2 + 1);
Kokkos::fill_random(exec, xr2c, random_pool, 1);
exec.fence();

KokkosFFT::rfftn(exec, xr2c, xr2c_hat, axis_type<3>{-3, -2, -1});
exec.fence();

// 3D C2R FFT
View3D<Kokkos::complex<double> > xc2r("xr2c_hat", n0, n1, n2 / 2 + 1);
View3D<double> xc2r_hat("xc2r", n0, n1, n2);
Kokkos::fill_random(exec, xc2r, random_pool, z);
exec.fence();

KokkosFFT::irfftn(exec, xc2r, xc2r_hat, axis_type<3>{-3, -2, -1});
exec.fence();
Expand Down
5 changes: 0 additions & 5 deletions examples/04_batchedFFT/04_batchedFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,24 @@ int main(int argc, char* argv[]) {
Kokkos::Random_XorShift64_Pool<> random_pool(12345);
execution_space exec;
Kokkos::fill_random(exec, xc2c, random_pool, z);
exec.fence();

KokkosFFT::fft(exec, xc2c, xc2c_hat, KokkosFFT::Normalization::backward,
/*axis=*/-1);
KokkosFFT::ifft(exec, xc2c_hat, xc2c_inv,
KokkosFFT::Normalization::backward, /*axis=*/-1);
exec.fence();

// 1D batched R2C FFT
View3D<double> xr2c("xr2c", n0, n1, n2);
View3D<Kokkos::complex<double> > xr2c_hat("xr2c_hat", n0, n1, n2 / 2 + 1);
Kokkos::fill_random(exec, xr2c, random_pool, 1);
exec.fence();

KokkosFFT::rfft(exec, xr2c, xr2c_hat, KokkosFFT::Normalization::backward,
/*axis=*/-1);
exec.fence();

// 1D batched C2R FFT
View3D<Kokkos::complex<double> > xc2r("xr2c_hat", n0, n1, n2 / 2 + 1);
View3D<double> xc2r_hat("xc2r", n0, n1, n2);
Kokkos::fill_random(exec, xc2r, random_pool, z);
exec.fence();

KokkosFFT::irfft(exec, xc2r, xc2r_hat, KokkosFFT::Normalization::backward,
/*axis=*/-1);
Expand Down
5 changes: 0 additions & 5 deletions examples/05_1DFFT_HOST_DEVICE/05_1DFFT_HOST_DEVICE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,21 @@ int main(int argc, char* argv[]) {
Kokkos::Random_XorShift64_Pool<> random_pool(12345);
execution_space exec;
Kokkos::fill_random(exec, xc2c, random_pool, z);
exec.fence();

KokkosFFT::fft(exec, xc2c, xc2c_hat);
KokkosFFT::ifft(exec, xc2c_hat, xc2c_inv);
exec.fence();

// 1D R2C FFT
View1D<double> xr2c("xr2c", n0);
View1D<Kokkos::complex<double> > xr2c_hat("xr2c_hat", n0 / 2 + 1);
Kokkos::fill_random(exec, xr2c, random_pool, 1);
exec.fence();

KokkosFFT::rfft(exec, xr2c, xr2c_hat);
exec.fence();

// 1D C2R FFT
View1D<Kokkos::complex<double> > xc2r("xr2c_hat", n0 / 2 + 1);
View1D<double> xc2r_hat("xc2r", n0);
Kokkos::fill_random(exec, xc2r, random_pool, z);
exec.fence();

KokkosFFT::irfft(exec, xc2r, xc2r_hat);
exec.fence();
Expand Down
6 changes: 0 additions & 6 deletions examples/06_1DFFT_reuse_plans/06_1DFFT_reuse_plans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,29 @@ int main(int argc, char* argv[]) {
Kokkos::Random_XorShift64_Pool<> random_pool(12345);
execution_space exec;
Kokkos::fill_random(exec, xc2c, random_pool, z);
exec.fence();

int axis = -1;
KokkosFFT::Impl::Plan fft_plan(exec, xc2c, xc2c_hat,
KokkosFFT::Direction::forward, axis);
KokkosFFT::Impl::fft_exec_impl(fft_plan, xc2c, xc2c_hat);
exec.fence();

KokkosFFT::Impl::Plan ifft_plan(exec, xc2c_hat, xc2c_inv,
KokkosFFT::Direction::backward, axis);
KokkosFFT::Impl::fft_exec_impl(ifft_plan, xc2c_hat, xc2c_inv);
exec.fence();

// 1D R2C FFT
View1D<double> xr2c("xr2c", n0);
View1D<Kokkos::complex<double> > xr2c_hat("xr2c_hat", n0 / 2 + 1);
Kokkos::fill_random(exec, xr2c, random_pool, 1);
exec.fence();

KokkosFFT::Impl::Plan rfft_plan(exec, xr2c, xr2c_hat,
KokkosFFT::Direction::forward, axis);
KokkosFFT::Impl::fft_exec_impl(rfft_plan, xr2c, xr2c_hat);
exec.fence();

// 1D C2R FFT
View1D<Kokkos::complex<double> > xc2r("xc2r_hat", n0 / 2 + 1);
View1D<double> xc2r_hat("xc2r", n0);
Kokkos::fill_random(exec, xc2r, random_pool, z);
exec.fence();

KokkosFFT::Impl::Plan irfft_plan(exec, xc2r, xc2r_hat,
KokkosFFT::Direction::backward, axis);
Expand Down
1 change: 0 additions & 1 deletion examples/07_unmanaged_views/07_unmanaged_views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ int main(int argc, char* argv[]) {
Kokkos::Random_XorShift64_Pool<> random_pool(12345);
execution_space exec;
Kokkos::fill_random(exec, xc2c, random_pool, z);
exec.fence();

KokkosFFT::fftn(exec, xc2c, xc2c_hat, axis_type<3>{-3, -2, -1},
KokkosFFT::Normalization::backward, shape);
Expand Down
11 changes: 3 additions & 8 deletions install_test/as_library/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
{
constexpr int n0 = 128;
const Kokkos::complex<double> I(1.0, 1.0);
const Kokkos::complex<double> z(1.0, 1.0);

// 1D C2C FFT (Forward and Backward)
View1D<Kokkos::complex<double> > xc2c("xc2c", n0);
Expand All @@ -24,27 +24,22 @@ int main(int argc, char* argv[]) {

Kokkos::Random_XorShift64_Pool<> random_pool(12345);
execution_space exec;
Kokkos::fill_random(exec, xc2c, random_pool, I);
exec.fence();
Kokkos::fill_random(exec, xc2c, random_pool, z);

KokkosFFT::fft(exec, xc2c, xc2c_hat);
KokkosFFT::ifft(exec, xc2c_hat, xc2c_inv);
exec.fence();

// 1D R2C FFT
View1D<double> xr2c("xr2c", n0);
View1D<Kokkos::complex<double> > xr2c_hat("xr2c_hat", n0 / 2 + 1);
Kokkos::fill_random(exec, xr2c, random_pool, 1);
exec.fence();

KokkosFFT::rfft(exec, xr2c, xr2c_hat);
exec.fence();

// 1D C2R FFT
View1D<Kokkos::complex<double> > xc2r("xr2c_hat", n0 / 2 + 1);
View1D<double> xc2r_hat("xc2r", n0);
Kokkos::fill_random(exec, xc2r, random_pool, I);
exec.fence();
Kokkos::fill_random(exec, xc2r, random_pool, z);

KokkosFFT::irfft(exec, xc2r, xc2r_hat);
exec.fence();
Expand Down
11 changes: 3 additions & 8 deletions install_test/as_subdirectory/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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);
const Kokkos::complex<double> z(1.0, 1.0);

// 2D C2C FFT (Forward and Backward)
View2D<Kokkos::complex<double> > xc2c("xc2c", n0, n1);
Expand All @@ -24,27 +24,22 @@ int main(int argc, char* argv[]) {

Kokkos::Random_XorShift64_Pool<> random_pool(12345);
execution_space exec;
Kokkos::fill_random(exec, xc2c, random_pool, I);
exec.fence();
Kokkos::fill_random(exec, xc2c, random_pool, z);

KokkosFFT::fft2(exec, xc2c, xc2c_hat);
KokkosFFT::ifft2(exec, xc2c_hat, xc2c_inv);
exec.fence();

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

KokkosFFT::rfft2(exec, xr2c, xr2c_hat);
exec.fence();

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

KokkosFFT::irfft2(exec, xc2r, xc2r_hat);
exec.fence();
Expand Down

0 comments on commit 00b831d

Please sign in to comment.