Skip to content

Address issues with modified inputs for fftC2R functions. #2520

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

Merged
merged 1 commit into from
May 28, 2019

Conversation

umar456
Copy link
Member

@umar456 umar456 commented May 22, 2019

The fftC2R function was modifying the input array when the fftw library
was used. This was happening because the fftw library does not have
and algorithm that can compute the fft without modifying the input array.

This problem does not seem to be happening on the MKL based fft.

Fixes #2518 For the CPU backend. I haven't been able to reproduce this with
the cuda backend.

@@ -121,7 +121,7 @@ void fft_r2c(Param<Tc> out, const af::dim4 oDataDims, CParam<Tr> in,
plan = transform.create(rank, t_dims, (int)batch, (Tr *)in.get(), in_embed,
(int)istrides[0], (int)istrides[rank],
(ctype_t *)out.get(), out_embed, (int)ostrides[0],
(int)ostrides[rank], FFTW_ESTIMATE);
(int)ostrides[rank], FFTW_ESTIMATE | FFTW_PRESERVE_INPUT);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this flag alone enough to fix the problem? Why copy the array yet again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works in real to complex ffts. The complex 2 real function will return a NULL plan because FFTW does not have an algorithm for this.

FFTW_PRESERVE_INPUT specifies that an out-of-place transform must not change its input array. This is ordinarily the default, except for c2r and hc2r (i.e. complex-to-real) transforms for which FFTW_DESTROY_INPUT is the default. In the latter cases, passing FFTW_PRESERVE_INPUT will attempt to use algorithms that do not destroy the input, at the expense of worse performance; for multi-dimensional c2r transforms, however, no input-preserving algorithms are implemented and the planner will return NULL if one is requested.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes! I'm so glad ArrayFire has separate functions for in-place transforms and it is clear from the name of the function of what to expect.

@umar456 umar456 force-pushed the fft_fix branch 2 times, most recently from 80a4b22 to c2de685 Compare May 26, 2019 23:12
@umar456
Copy link
Member Author

umar456 commented May 26, 2019

Removed tests that were failing on CUDA 10.1. Should be added back once the bug is resolved.

@umar456 umar456 force-pushed the fft_fix branch 3 times, most recently from 4ad7b99 to 383486d Compare May 27, 2019 03:41
The fftC2R function was modifying the input array when the fftw library
was used. This was happening because the fftw library does not have
and algorithm that can compute the fft without modifying the input array.

This problem does not seem to be happening on the MKL based fft.
to_test_params);

// Does not work well with CUDA 10.1
// TEST_P(FFTC2R2D, Complex32ToRealInputsPreserved) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a major requirement, we should lean towards using DISABLED_ prefix for the test so that it is reported as disabled in ctest suite runs.

@9prady9 9prady9 merged commit 9e8061f into arrayfire:master May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

in v3.6.4 c2r FFT changes the value of the input
2 participants