From 94997a9be2443786c927d553883f7bba06cc4ce5 Mon Sep 17 00:00:00 2001 From: Matthias Knorr Date: Wed, 16 Oct 2024 13:01:58 +0200 Subject: [PATCH] Fix hipFFT-plan_*2z examples The hipFFT examples had a small memory leak due to using hipfftCreate before using hipfftPlan*d, which expects the plan not to be allocated beforehand. --- Libraries/hipFFT/plan_d2z/main.cpp | 7 ++----- Libraries/hipFFT/plan_z2z/main.cpp | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Libraries/hipFFT/plan_d2z/main.cpp b/Libraries/hipFFT/plan_d2z/main.cpp index a1dc6183..9d068e1e 100644 --- a/Libraries/hipFFT/plan_d2z/main.cpp +++ b/Libraries/hipFFT/plan_d2z/main.cpp @@ -76,13 +76,10 @@ void fft_example(const int dimension, const int size = 8) // 4. Copy host to device HIP_CHECK(hipMemcpy(d_input, input.data(), n_total * sizeof(*d_input), hipMemcpyHostToDevice)); - // 5. Create FFT plan - - // 5a. Allocate plan handle + // 5. Define FFT plan hipfftHandle plan; - HIPFFT_CHECK(hipfftCreate(&plan)); - // 5b. Create {1, 2, 3}-dimensional plan + // 5a. Create {1, 2, 3}-dimensional plan switch(dimension) { case 1: HIPFFT_CHECK(hipfftPlan1d(&plan, n[0], hipfftType::HIPFFT_D2Z, 1)); break; diff --git a/Libraries/hipFFT/plan_z2z/main.cpp b/Libraries/hipFFT/plan_z2z/main.cpp index 081ebd45..5d8127d7 100644 --- a/Libraries/hipFFT/plan_z2z/main.cpp +++ b/Libraries/hipFFT/plan_z2z/main.cpp @@ -71,13 +71,10 @@ void fft_example(const int dimension, const int size = 4, const int direction = // 4. Copy host to device HIP_CHECK(hipMemcpy(d_input, input.data(), n_total * sizeof(*d_input), hipMemcpyHostToDevice)); - // 5. Create FFT plan - - // 5a. Allocate plan handle + // 5. Define FFT plan hipfftHandle plan; - HIPFFT_CHECK(hipfftCreate(&plan)); - // 5b. Create {1, 2, 3}-dimensional plan + // 5a. Create {1, 2, 3}-dimensional plan switch(dimension) { case 1: HIPFFT_CHECK(hipfftPlan1d(&plan, n[0], hipfftType::HIPFFT_Z2Z, 1)); break;