Skip to content

Commit

Permalink
Add initialization and finalization in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuuichi Asahi committed Jan 13, 2025
1 parent 284a0fb commit 19bd963
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/01_1DFFT/01_1DFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using View1D = Kokkos::View<T*, execution_space>;

int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
KokkosFFT::initialize();
{
const int n0 = 128;
const Kokkos::complex<double> z(1.0, 1.0);
Expand Down Expand Up @@ -44,6 +45,7 @@ int main(int argc, char* argv[]) {
KokkosFFT::irfft(exec, xc2r, xc2r_hat);
exec.fence();
}
KokkosFFT::finalize();
Kokkos::finalize();

return 0;
Expand Down
2 changes: 2 additions & 0 deletions examples/02_2DFFT/02_2DFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using View2D = Kokkos::View<T**, execution_space>;

int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
KokkosFFT::initialize();
{
const int n0 = 128, n1 = 128;
const Kokkos::complex<double> z(1.0, 1.0);
Expand Down Expand Up @@ -44,6 +45,7 @@ int main(int argc, char* argv[]) {
KokkosFFT::irfft2(exec, xc2r, xc2r_hat);
exec.fence();
}
KokkosFFT::finalize();
Kokkos::finalize();

return 0;
Expand Down
2 changes: 2 additions & 0 deletions examples/03_NDFFT/03_NDFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ using axis_type = KokkosFFT::axis_type<DIM>;

int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
KokkosFFT::initialize();
{
const int n0 = 128, n1 = 128, n2 = 16;
const Kokkos::complex<double> z(1.0, 1.0);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions examples/04_batchedFFT/04_batchedFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using View3D = Kokkos::View<T***, execution_space>;

int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
KokkosFFT::initialize();
{
const int n0 = 128, n1 = 128, n2 = 16;
const Kokkos::complex<double> z(1.0, 1.0);
Expand Down Expand Up @@ -48,6 +49,7 @@ int main(int argc, char* argv[]) {
/*axis=*/-1);
exec.fence();
}
KokkosFFT::finalize();
Kokkos::finalize();

return 0;
Expand Down
2 changes: 2 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 @@ -16,6 +16,7 @@ using HostView1D = Kokkos::View<T*, host_execution_space>;

int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
KokkosFFT::initialize();
{
const int n0 = 128;
const Kokkos::complex<double> z(1.0, 1.0);
Expand Down Expand Up @@ -79,6 +80,7 @@ int main(int argc, char* argv[]) {
host_exec.fence();
#endif
}
KokkosFFT::finalize();
Kokkos::finalize();

return 0;
Expand Down
2 changes: 2 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 @@ -13,6 +13,7 @@ using View1D = Kokkos::View<T*, execution_space>;

int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
KokkosFFT::initialize();
{
const int n0 = 128;
const Kokkos::complex<double> z(1.0, 1.0);
Expand Down Expand Up @@ -54,6 +55,7 @@ int main(int argc, char* argv[]) {
irfft_plan.execute(xc2r, xc2r_hat);
exec.fence();
}
KokkosFFT::finalize();
Kokkos::finalize();

return 0;
Expand Down
2 changes: 2 additions & 0 deletions examples/07_unmanaged_views/07_unmanaged_views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ using shape_type = KokkosFFT::shape_type<DIM>;

int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
KokkosFFT::initialize();
{
const int n0 = 128, n1 = 128, n2 = 16;
const Kokkos::complex<double> z(1.0, 1.0);
Expand Down Expand Up @@ -63,6 +64,7 @@ int main(int argc, char* argv[]) {
KokkosFFT::Normalization::backward, shape);
exec.fence();
}
KokkosFFT::finalize();
Kokkos::finalize();

return 0;
Expand Down
2 changes: 2 additions & 0 deletions examples/08_inplace_FFT/08_inplace_FFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ using RightView2D = Kokkos::View<T **, Kokkos::LayoutRight, execution_space>;

int main(int argc, char *argv[]) {
Kokkos::initialize(argc, argv);
KokkosFFT::initialize();
{
const int n0 = 128, n1 = 128;
const Kokkos::complex<double> z(1.0, 1.0);
Expand Down Expand Up @@ -69,6 +70,7 @@ int main(int argc, char *argv[]) {

exec.fence();
}
KokkosFFT::finalize();
Kokkos::finalize();

return 0;
Expand Down
4 changes: 3 additions & 1 deletion install_test/as_library/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ using View1D = Kokkos::View<T*, execution_space>;

int main(int argc, char* argv[]) {
Kokkos::initialize(argc, argv);
KokkosFFT::initialize();
{
constexpr int n0 = 128;
const int n0 = 128;
const Kokkos::complex<double> z(1.0, 1.0);

// 1D C2C FFT (Forward and Backward)
Expand Down Expand Up @@ -44,6 +45,7 @@ int main(int argc, char* argv[]) {
KokkosFFT::irfft(exec, xc2r, xc2r_hat);
exec.fence();
}
KokkosFFT::finalize();
Kokkos::finalize();

return 0;
Expand Down
4 changes: 3 additions & 1 deletion install_test/as_subdirectory/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ using View2D = Kokkos::View<T**, execution_space>;

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<double> z(1.0, 1.0);

// 2D C2C FFT (Forward and Backward)
Expand Down Expand Up @@ -44,6 +45,7 @@ int main(int argc, char* argv[]) {
KokkosFFT::irfft2(exec, xc2r, xc2r_hat);
exec.fence();
}
KokkosFFT::finalize();
Kokkos::finalize();

return 0;
Expand Down

0 comments on commit 19bd963

Please sign in to comment.