-
Notifications
You must be signed in to change notification settings - Fork 8
Bluestein Algorithm #140
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
Bluestein Algorithm #140
Changes from all commits
6a6672f
a0b6218
d6dff45
74c8c80
386c98f
e4c8d27
6236bba
dbc0919
8de1139
69f674e
0f7f7cb
308351d
8d506bd
b530624
2d3c88a
67c3c7f
b23be66
4a92d8c
651edd1
9fd1566
c4e6549
3f982e7
ea1995e
c56475f
7e6dd9e
78e1372
730fecc
1be4afc
4cf6ca7
935477d
eae3341
1861125
63dd473
9ea81fe
2d70170
a07ec9c
8a8371d
310945f
c094e4d
12e618f
39d1632
a152e0d
80167b5
155d417
b40a91f
c935e73
5976144
93ab8a4
6fcb7d4
e4167ae
d78ac6f
5fe5eaa
8ea2076
a7034bb
3910c38
681c587
7c8b0c0
e1050c1
ff650b5
a57ada8
01cd4d4
32b5582
c6663d8
aed81cf
fbe0b3d
d96a158
4976174
b135650
ef62c2f
fca1a80
6f29039
c885293
6be4c6e
7a2afe8
75f55d9
b3a1cd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,76 @@ | ||||||
/*************************************************************************** | ||||||
* | ||||||
* Copyright (C) Codeplay Software Ltd. | ||||||
* | ||||||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
* you may not use this file except in compliance with the License. | ||||||
* You may obtain a copy of the License at | ||||||
* | ||||||
* http://www.apache.org/licenses/LICENSE-2.0 | ||||||
* | ||||||
* Unless required by applicable law or agreed to in writing, software | ||||||
* distributed under the License is distributed on an "AS IS" BASIS, | ||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
* See the License for the specific language governing permissions and | ||||||
* limitations under the License. | ||||||
* | ||||||
* Codeplay's portFFT | ||||||
* | ||||||
**************************************************************************/ | ||||||
|
||||||
#ifndef PORTFFT_COMMON_BLUESTEIN_HPP | ||||||
#define PORTFFT_COMMON_BLUESTEIN_HPP | ||||||
|
||||||
#include "portfft/common/host_fft.hpp" | ||||||
#include "portfft/defines.hpp" | ||||||
|
||||||
#include <complex> | ||||||
#include <sycl/sycl.hpp> | ||||||
|
||||||
namespace portfft { | ||||||
namespace detail { | ||||||
/** | ||||||
* Utility function to get the dft transform of the chirp signal | ||||||
* @tparam T Scalar Type | ||||||
* @param ptr Host Pointer containing the load/store modifiers. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* @param committed_size original problem size | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is original problem? |
||||||
* @param dimension_size padded size | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If padded size is the best description for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whichever name is better, this documentation should be improved. |
||||||
*/ | ||||||
template <typename T> | ||||||
void get_fft_chirp_signal(T* ptr, std::size_t committed_size, std::size_t dimension_size) { | ||||||
using complex_t = std::complex<T>; | ||||||
std::vector<complex_t> chirp_signal(dimension_size, 0); | ||||||
std::vector<complex_t> chirp_fft(dimension_size, 0); | ||||||
for (std::size_t i = 0; i < committed_size; i++) { | ||||||
double theta = M_PI * static_cast<double>(i * i) / static_cast<double>(committed_size); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
chirp_signal[i] = complex_t(static_cast<T>(std::cos(theta)), static_cast<T>(std::sin(theta))); | ||||||
} | ||||||
std::size_t num_zeros = dimension_size - 2 * committed_size + 1; | ||||||
for (std::size_t i = 0; i < committed_size; i++) { | ||||||
chirp_signal[committed_size + num_zeros + i - 1] = chirp_signal[committed_size - i]; | ||||||
} | ||||||
host_naive_dft(chirp_signal.data(), chirp_fft.data(), dimension_size); | ||||||
std::memcpy(ptr, reinterpret_cast<T*>(chirp_fft.data()), 2 * dimension_size * sizeof(T)); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Populates input modifiers required for bluestein | ||||||
* @tparam T Scalar Type | ||||||
* @param ptr Host Pointer containing the load/store modifiers. | ||||||
* @param committed_size committed problem length | ||||||
* @param dimension_size padded dft length | ||||||
*/ | ||||||
template <typename T> | ||||||
void populate_bluestein_input_modifiers(T* ptr, std::size_t committed_size, std::size_t dimension_size) { | ||||||
using complex_t = std::complex<T>; | ||||||
std::vector<complex_t> scratch(dimension_size, 0); | ||||||
for (std::size_t i = 0; i < committed_size; i++) { | ||||||
double theta = -M_PI * static_cast<double>(i * i) / static_cast<double>(committed_size); | ||||||
scratch[i] = complex_t(static_cast<T>(std::cos(theta)), static_cast<T>(std::sin(theta))); | ||||||
} | ||||||
std::memcpy(ptr, reinterpret_cast<T*>(scratch.data()), 2 * dimension_size * sizeof(T)); | ||||||
} | ||||||
} // namespace detail | ||||||
} // namespace portfft | ||||||
|
||||||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What magic numbers are being complained about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 2.0 here
I do not want to especially name it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should disable the check around the 1 line (stackoverflow).
This might alternatively be fixed by using the log2 with ints as suggested in another comment.