-
Notifications
You must be signed in to change notification settings - Fork 48
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
add complex.hlsl #592
add complex.hlsl #592
Conversation
[CI]: Can one of the admins verify this patch? |
// Fast Fourier Transform | ||
template<typename T, uint32_t N> | ||
void fft_radix2(complex::complex_t<T> data[N], bool is_inverse) |
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.
make the is_inverse
a template parameter
assert(N<gl_SubgroupSize)
btw the data
need not be data[N]
, each invocation comes with its own register value and you can cooperatively exchange via the use of subgroupShuffleXor
(add it to https://github.com/Devsh-Graphics-Programming/Nabla/blob/master/include/nbl/builtin/hlsl/glsl_compat/subgroup_shuffle.hlsl please).
I mean the original GLSL code is here
https://github.com/Devsh-Graphics-Programming/Nabla/blob/master/include/nbl/builtin/glsl/subgroup/fft.glsl
a07e79f
to
ffbd843
Compare
I see a certain ladder of features, and each should have their own branch (so I can merge in order without having all comments addressed):
They can branch off each other. P.S. Let me know if you need "runtime" transcendental/special functions for |
Missing compound operators and template specializations for integer types. Arithmetic logic is off, different from the STL
// Cooley-Tukey | ||
assign_mul_complex<T> mul_assign; | ||
assign_div_complex<T> div_assign; | ||
for (uint32_t stride = 2; stride <= N; stride *= 2) |
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'd do a loop from stride=1
to stride=N/2
instead of 2->N
because that's the actual stride between your butterfly elements, what you have right now is a width
{ | ||
namespace subgroup | ||
{ | ||
// TODO: specialize subgorupShuffleXor to different Scalar types. As of right now this would only support 1-wide scalars (no vectors) |
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.
thats fine, lets do 1 channel at a time
|
||
|
||
template<typename Scalar, uint32_t SubgroupSize, bool inverse> | ||
void FFT(NBL_REF_ARG(complex_t<Scalar>) lo, NBL_REF_ARG(complex_t<Scalar>) hi) { |
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.
you need to document with comments what lo
and hi
are
const uint32_t doubleSubgroupSize = SubgroupSize << 1; | ||
// special first iteration | ||
if (! inverse) | ||
fft::DIX<Scalar, inverse>::radix2(fft::twiddle<Scalar, inverse>(glsl::gl_SubgroupID(), doubleSubgroupSize), lo, hi); |
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.
using DIX<Scalar,inverse>
when you're already inside an if (inverse)
or if (!inverse)
makes the code super unreadable, I'd use DIT or DIF directly
FFT_loop<Scalar, inverse>(stride, lo, hi); | ||
// Decimation in Frequency | ||
else | ||
for (uint32_t stride = SubgroupSize >> 1; stride > 0; stride >>= 1) | ||
FFT_loop<Scalar, inverse>(stride, lo, hi); |
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.
also substitute inverse
if you already know the value
Description
Start drafting complex.hlsl