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

Remove wait after onemkl dft calls #89

Merged
merged 5 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
6 changes: 6 additions & 0 deletions examples/01_1DFFT/01_1DFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,29 @@ int main(int argc, char* argv[]) {

Kokkos::Random_XorShift64_Pool<> random_pool(12345);
Kokkos::fill_random(xc2c, random_pool, I);
Kokkos::fence();
yasahi-hpc marked this conversation as resolved.
Show resolved Hide resolved

KokkosFFT::fft(execution_space(), xc2c, xc2c_hat);
KokkosFFT::ifft(execution_space(), xc2c_hat, xc2c_inv);
Kokkos::fence();
yasahi-hpc marked this conversation as resolved.
Show resolved Hide resolved

// 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);
Kokkos::fence();

KokkosFFT::rfft(execution_space(), xr2c, xr2c_hat);
Kokkos::fence();

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

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

Expand Down
6 changes: 6 additions & 0 deletions examples/02_2DFFT/02_2DFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,29 @@ int main(int argc, char* argv[]) {

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

KokkosFFT::fft2(execution_space(), xc2c, xc2c_hat);
KokkosFFT::ifft2(execution_space(), xc2c_hat, xc2c_inv);
Kokkos::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(xr2c, random_pool, 1);
Kokkos::fence();

KokkosFFT::rfft2(execution_space(), xr2c, xr2c_hat);
Kokkos::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(xc2r, random_pool, I);
Kokkos::fence();

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

Expand Down
6 changes: 6 additions & 0 deletions examples/03_NDFFT/03_NDFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,29 @@ int main(int argc, char* argv[]) {

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

KokkosFFT::fftn(execution_space(), xc2c, xc2c_hat);
KokkosFFT::ifftn(execution_space(), xc2c_hat, xc2c_inv);
Kokkos::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(xr2c, random_pool, 1);
Kokkos::fence();

KokkosFFT::rfftn(execution_space(), xr2c, xr2c_hat);
Kokkos::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(xc2r, random_pool, I);
Kokkos::fence();

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

Expand Down
6 changes: 6 additions & 0 deletions examples/04_batchedFFT/04_batchedFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,33 @@ int main(int argc, char* argv[]) {

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

KokkosFFT::fft(execution_space(), xc2c, xc2c_hat,
KokkosFFT::Normalization::backward, /*axis=*/-1);
KokkosFFT::ifft(execution_space(), xc2c_hat, xc2c_inv,
KokkosFFT::Normalization::backward, /*axis=*/-1);
Kokkos::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(xr2c, random_pool, 1);
Kokkos::fence();

KokkosFFT::rfft(execution_space(), xr2c, xr2c_hat,
KokkosFFT::Normalization::backward, /*axis=*/-1);
Kokkos::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(xc2r, random_pool, I);
Kokkos::fence();

KokkosFFT::irfft(execution_space(), xc2r, xc2r_hat,
KokkosFFT::Normalization::backward, /*axis=*/-1);
Kokkos::fence();
}
Kokkos::finalize();

Expand Down
9 changes: 9 additions & 0 deletions examples/05_1DFFT_HOST_DEVICE/05_1DFFT_HOST_DEVICE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,29 @@ int main(int argc, char* argv[]) {

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

KokkosFFT::fft(execution_space(), xc2c, xc2c_hat);
KokkosFFT::ifft(execution_space(), xc2c_hat, xc2c_inv);
Kokkos::fence();

// 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);
Kokkos::fence();

KokkosFFT::rfft(execution_space(), xr2c, xr2c_hat);
Kokkos::fence();

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

KokkosFFT::irfft(execution_space(), xc2r, xc2r_hat);
Kokkos::fence();

#ifdef ENABLE_HOST_AND_DEVICE
// FFTs on Host
Expand All @@ -56,20 +62,23 @@ int main(int argc, char* argv[]) {

KokkosFFT::fft(host_execution_space(), h_xc2c, h_xc2c_hat);
KokkosFFT::ifft(host_execution_space(), h_xc2c_hat, h_xc2c_inv);
Kokkos::fence();

// 1D R2C FFT
HostView1D<double> h_xr2c("h_xr2c", n0);
HostView1D<Kokkos::complex<double> > h_xr2c_hat("h_xr2c_hat", n0 / 2 + 1);

Kokkos::deep_copy(h_xr2c, xr2c);
KokkosFFT::rfft(host_execution_space(), h_xr2c, h_xr2c_hat);
Kokkos::fence();

// 1D C2R FFT
HostView1D<Kokkos::complex<double> > h_xc2r("h_xr2c_hat", n0 / 2 + 1);
HostView1D<double> h_xc2r_hat("h_xc2r", n0);

Kokkos::deep_copy(h_xc2r, xc2r);
KokkosFFT::irfft(host_execution_space(), h_xc2r, h_xc2r_hat);
Kokkos::fence();
#endif
}
Kokkos::finalize();
Expand Down
7 changes: 7 additions & 0 deletions examples/06_1DFFT_reuse_plans/06_1DFFT_reuse_plans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,40 @@ int main(int argc, char* argv[]) {

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

int axis = -1;
KokkosFFT::Impl::Plan fft_plan(execution_space(), xc2c, xc2c_hat,
KokkosFFT::Direction::forward, axis);
KokkosFFT::fft(execution_space(), xc2c, xc2c_hat, fft_plan);
Kokkos::fence();

KokkosFFT::Impl::Plan ifft_plan(execution_space(), xc2c_hat, xc2c_inv,
KokkosFFT::Direction::backward, axis);
KokkosFFT::ifft(execution_space(), xc2c_hat, xc2c_inv, ifft_plan);
Kokkos::fence();

// 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);
Kokkos::fence();

KokkosFFT::Impl::Plan rfft_plan(execution_space(), xr2c, xr2c_hat,
KokkosFFT::Direction::forward, axis);
KokkosFFT::rfft(execution_space(), xr2c, xr2c_hat, rfft_plan);
Kokkos::fence();

// 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);
Kokkos::fence();

KokkosFFT::Impl::Plan irfft_plan(execution_space(), xc2r, xc2r_hat,
KokkosFFT::Direction::backward, axis);
KokkosFFT::irfft(execution_space(), xc2r, xc2r_hat, irfft_plan);
Kokkos::fence();
}
Kokkos::finalize();

Expand Down
30 changes: 13 additions & 17 deletions fft/src/KokkosFFT_SYCL_transform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,41 @@ namespace Impl {
template <typename PlanType, typename... Args>
void _exec(PlanType& plan, float* idata, std::complex<float>* odata,
[[maybe_unused]] int direction, [[maybe_unused]] Args... args) {
auto r2c = oneapi::mkl::dft::compute_forward(plan, idata,
reinterpret_cast<float*>(odata));
r2c.wait();
[[maybe_unused]] auto r2c = oneapi::mkl::dft::compute_forward(
plan, idata, reinterpret_cast<float*>(odata));
}
yasahi-hpc marked this conversation as resolved.
Show resolved Hide resolved

template <typename PlanType, typename... Args>
void _exec(PlanType& plan, double* idata, std::complex<double>* odata,
[[maybe_unused]] int direction, [[maybe_unused]] Args... args) {
auto d2z = oneapi::mkl::dft::compute_forward(
[[maybe_unused]] auto d2z = oneapi::mkl::dft::compute_forward(
plan, idata, reinterpret_cast<double*>(odata));
d2z.wait();
}

template <typename PlanType, typename... Args>
void _exec(PlanType& plan, std::complex<float>* idata, float* odata,
[[maybe_unused]] int direction, [[maybe_unused]] Args... args) {
auto c2r = oneapi::mkl::dft::compute_backward(
[[maybe_unused]] auto c2r = oneapi::mkl::dft::compute_backward(
plan, reinterpret_cast<float*>(idata), odata);
c2r.wait();
}

template <typename PlanType, typename... Args>
void _exec(PlanType& plan, std::complex<double>* idata, double* odata,
[[maybe_unused]] int direction, [[maybe_unused]] Args... args) {
auto z2d = oneapi::mkl::dft::compute_backward(
[[maybe_unused]] auto z2d = oneapi::mkl::dft::compute_backward(
plan, reinterpret_cast<double*>(idata), odata);
z2d.wait();
}

template <typename PlanType, typename... Args>
void _exec(PlanType& plan, std::complex<float>* idata,
std::complex<float>* odata, [[maybe_unused]] int direction,
[[maybe_unused]] Args... args) {
if (direction == 1) {
auto c2c = oneapi::mkl::dft::compute_forward(plan, idata, odata);
c2c.wait();
[[maybe_unused]] auto c2c =
oneapi::mkl::dft::compute_forward(plan, idata, odata);
} else {
auto c2c = oneapi::mkl::dft::compute_backward(plan, idata, odata);
c2c.wait();
[[maybe_unused]] auto c2c =
oneapi::mkl::dft::compute_backward(plan, idata, odata);
}
}

Expand All @@ -60,11 +56,11 @@ void _exec(PlanType& plan, std::complex<double>* idata,
std::complex<double>* odata, [[maybe_unused]] int direction,
[[maybe_unused]] Args... args) {
if (direction == 1) {
auto z2z = oneapi::mkl::dft::compute_forward(plan, idata, odata);
z2z.wait();
[[maybe_unused]] auto z2z =
oneapi::mkl::dft::compute_forward(plan, idata, odata);
} else {
auto z2z = oneapi::mkl::dft::compute_backward(plan, idata, odata);
z2z.wait();
[[maybe_unused]] auto z2z =
oneapi::mkl::dft::compute_backward(plan, idata, odata);
}
}
} // namespace Impl
Expand Down
6 changes: 6 additions & 0 deletions install_test/as_library/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,29 @@ int main(int argc, char* argv[]) {

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

KokkosFFT::fft(execution_space(), xc2c, xc2c_hat);
KokkosFFT::ifft(execution_space(), xc2c_hat, xc2c_inv);
Kokkos::fence();

// 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);
Kokkos::fence();

KokkosFFT::rfft(execution_space(), xr2c, xr2c_hat);
Kokkos::fence();

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

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

Expand Down
6 changes: 6 additions & 0 deletions install_test/as_subdirectory/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,29 @@ int main(int argc, char* argv[]) {

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

KokkosFFT::fft2(execution_space(), xc2c, xc2c_hat);
KokkosFFT::ifft2(execution_space(), xc2c_hat, xc2c_inv);
Kokkos::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(xr2c, random_pool, 1);
Kokkos::fence();

KokkosFFT::rfft2(execution_space(), xr2c, xr2c_hat);
Kokkos::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(xc2r, random_pool, I);
Kokkos::fence();

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

Expand Down
Loading