From 19bd9631ec9c998c4376589aae6b3f49806fa8b0 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Mon, 13 Jan 2025 18:53:15 +0900 Subject: [PATCH] Add initialization and finalization in examples --- examples/01_1DFFT/01_1DFFT.cpp | 2 ++ examples/02_2DFFT/02_2DFFT.cpp | 2 ++ examples/03_NDFFT/03_NDFFT.cpp | 2 ++ examples/04_batchedFFT/04_batchedFFT.cpp | 2 ++ examples/05_1DFFT_HOST_DEVICE/05_1DFFT_HOST_DEVICE.cpp | 2 ++ examples/06_1DFFT_reuse_plans/06_1DFFT_reuse_plans.cpp | 2 ++ examples/07_unmanaged_views/07_unmanaged_views.cpp | 2 ++ examples/08_inplace_FFT/08_inplace_FFT.cpp | 2 ++ install_test/as_library/hello.cpp | 4 +++- install_test/as_subdirectory/hello.cpp | 4 +++- 10 files changed, 22 insertions(+), 2 deletions(-) diff --git a/examples/01_1DFFT/01_1DFFT.cpp b/examples/01_1DFFT/01_1DFFT.cpp index 7eb92107..ec9f7c19 100644 --- a/examples/01_1DFFT/01_1DFFT.cpp +++ b/examples/01_1DFFT/01_1DFFT.cpp @@ -13,6 +13,7 @@ using View1D = Kokkos::View; int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { const int n0 = 128; const Kokkos::complex z(1.0, 1.0); @@ -44,6 +45,7 @@ int main(int argc, char* argv[]) { KokkosFFT::irfft(exec, xc2r, xc2r_hat); exec.fence(); } + KokkosFFT::finalize(); Kokkos::finalize(); return 0; diff --git a/examples/02_2DFFT/02_2DFFT.cpp b/examples/02_2DFFT/02_2DFFT.cpp index fc01b4a8..94779fea 100644 --- a/examples/02_2DFFT/02_2DFFT.cpp +++ b/examples/02_2DFFT/02_2DFFT.cpp @@ -13,6 +13,7 @@ using View2D = Kokkos::View; int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { const int n0 = 128, n1 = 128; const Kokkos::complex z(1.0, 1.0); @@ -44,6 +45,7 @@ int main(int argc, char* argv[]) { KokkosFFT::irfft2(exec, xc2r, xc2r_hat); exec.fence(); } + KokkosFFT::finalize(); Kokkos::finalize(); return 0; diff --git a/examples/03_NDFFT/03_NDFFT.cpp b/examples/03_NDFFT/03_NDFFT.cpp index 2c07ee84..72f9d013 100644 --- a/examples/03_NDFFT/03_NDFFT.cpp +++ b/examples/03_NDFFT/03_NDFFT.cpp @@ -15,6 +15,7 @@ using axis_type = KokkosFFT::axis_type; int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { const int n0 = 128, n1 = 128, n2 = 16; const Kokkos::complex z(1.0, 1.0); @@ -46,6 +47,7 @@ int main(int argc, char* argv[]) { KokkosFFT::irfftn(exec, xc2r, xc2r_hat, axis_type<3>{-3, -2, -1}); exec.fence(); } + KokkosFFT::finalize(); Kokkos::finalize(); return 0; diff --git a/examples/04_batchedFFT/04_batchedFFT.cpp b/examples/04_batchedFFT/04_batchedFFT.cpp index 7cad003d..9e5c53ff 100644 --- a/examples/04_batchedFFT/04_batchedFFT.cpp +++ b/examples/04_batchedFFT/04_batchedFFT.cpp @@ -13,6 +13,7 @@ using View3D = Kokkos::View; int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { const int n0 = 128, n1 = 128, n2 = 16; const Kokkos::complex z(1.0, 1.0); @@ -48,6 +49,7 @@ int main(int argc, char* argv[]) { /*axis=*/-1); exec.fence(); } + KokkosFFT::finalize(); Kokkos::finalize(); return 0; diff --git a/examples/05_1DFFT_HOST_DEVICE/05_1DFFT_HOST_DEVICE.cpp b/examples/05_1DFFT_HOST_DEVICE/05_1DFFT_HOST_DEVICE.cpp index 76437db2..979a2d02 100644 --- a/examples/05_1DFFT_HOST_DEVICE/05_1DFFT_HOST_DEVICE.cpp +++ b/examples/05_1DFFT_HOST_DEVICE/05_1DFFT_HOST_DEVICE.cpp @@ -16,6 +16,7 @@ using HostView1D = Kokkos::View; int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { const int n0 = 128; const Kokkos::complex z(1.0, 1.0); @@ -79,6 +80,7 @@ int main(int argc, char* argv[]) { host_exec.fence(); #endif } + KokkosFFT::finalize(); Kokkos::finalize(); return 0; diff --git a/examples/06_1DFFT_reuse_plans/06_1DFFT_reuse_plans.cpp b/examples/06_1DFFT_reuse_plans/06_1DFFT_reuse_plans.cpp index 0542755f..457fad26 100644 --- a/examples/06_1DFFT_reuse_plans/06_1DFFT_reuse_plans.cpp +++ b/examples/06_1DFFT_reuse_plans/06_1DFFT_reuse_plans.cpp @@ -13,6 +13,7 @@ using View1D = Kokkos::View; int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { const int n0 = 128; const Kokkos::complex z(1.0, 1.0); @@ -54,6 +55,7 @@ int main(int argc, char* argv[]) { irfft_plan.execute(xc2r, xc2r_hat); exec.fence(); } + KokkosFFT::finalize(); Kokkos::finalize(); return 0; diff --git a/examples/07_unmanaged_views/07_unmanaged_views.cpp b/examples/07_unmanaged_views/07_unmanaged_views.cpp index 9baf502d..6017a32e 100644 --- a/examples/07_unmanaged_views/07_unmanaged_views.cpp +++ b/examples/07_unmanaged_views/07_unmanaged_views.cpp @@ -25,6 +25,7 @@ using shape_type = KokkosFFT::shape_type; int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { const int n0 = 128, n1 = 128, n2 = 16; const Kokkos::complex z(1.0, 1.0); @@ -63,6 +64,7 @@ int main(int argc, char* argv[]) { KokkosFFT::Normalization::backward, shape); exec.fence(); } + KokkosFFT::finalize(); Kokkos::finalize(); return 0; diff --git a/examples/08_inplace_FFT/08_inplace_FFT.cpp b/examples/08_inplace_FFT/08_inplace_FFT.cpp index 7e17904d..1d5c6b1b 100644 --- a/examples/08_inplace_FFT/08_inplace_FFT.cpp +++ b/examples/08_inplace_FFT/08_inplace_FFT.cpp @@ -14,6 +14,7 @@ using RightView2D = Kokkos::View; int main(int argc, char *argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { const int n0 = 128, n1 = 128; const Kokkos::complex z(1.0, 1.0); @@ -69,6 +70,7 @@ int main(int argc, char *argv[]) { exec.fence(); } + KokkosFFT::finalize(); Kokkos::finalize(); return 0; diff --git a/install_test/as_library/hello.cpp b/install_test/as_library/hello.cpp index 9ef3ca8f..ec9f7c19 100644 --- a/install_test/as_library/hello.cpp +++ b/install_test/as_library/hello.cpp @@ -13,8 +13,9 @@ using View1D = Kokkos::View; int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { - constexpr int n0 = 128; + const int n0 = 128; const Kokkos::complex z(1.0, 1.0); // 1D C2C FFT (Forward and Backward) @@ -44,6 +45,7 @@ int main(int argc, char* argv[]) { KokkosFFT::irfft(exec, xc2r, xc2r_hat); exec.fence(); } + KokkosFFT::finalize(); Kokkos::finalize(); return 0; diff --git a/install_test/as_subdirectory/hello.cpp b/install_test/as_subdirectory/hello.cpp index 45b7d424..94779fea 100644 --- a/install_test/as_subdirectory/hello.cpp +++ b/install_test/as_subdirectory/hello.cpp @@ -13,8 +13,9 @@ using View2D = Kokkos::View; int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); + KokkosFFT::initialize(); { - constexpr int n0 = 128, n1 = 128; + const int n0 = 128, n1 = 128; const Kokkos::complex z(1.0, 1.0); // 2D C2C FFT (Forward and Backward) @@ -44,6 +45,7 @@ int main(int argc, char* argv[]) { KokkosFFT::irfft2(exec, xc2r, xc2r_hat); exec.fence(); } + KokkosFFT::finalize(); Kokkos::finalize(); return 0;