Skip to content
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

Clarification question on "void planVulkanFFTAxis(VulkanFFTPlan* vulkanFFTPlan, uint32_t axis)" #4

Open
shuwang1 opened this issue Dec 31, 2021 · 1 comment

Comments

@shuwang1
Copy link

shuwang1 commented Dec 31, 2021

Hi Lichtso,

May I ask what the codes below are for?

void planVulkanFFTAxis(VulkanFFTPlan* vulkanFFTPlan, uint32_t axis) {
    VulkanFFTAxis* vulkanFFTAxis = &vulkanFFTPlan->axes[axis];

    {
        vulkanFFTAxis->stageCount = 31-__builtin_clz(vulkanFFTAxis->sampleCount); // Logarithm of base 2
        vulkanFFTAxis->stageRadix = (uint32_t*)malloc(sizeof(uint32_t) * vulkanFFTAxis->stageCount);
        uint32_t stageSize = vulkanFFTAxis->sampleCount;
        vulkanFFTAxis->stageCount = 0;
        while(stageSize > 1) {
            uint32_t radixIndex = SUPPORTED_RADIX_LEVELS;
            do {
                assert(radixIndex > 0);
                --radixIndex;
                vulkanFFTAxis->stageRadix[vulkanFFTAxis->stageCount] = 2<<radixIndex;
            } while(stageSize % vulkanFFTAxis->stageRadix[vulkanFFTAxis->stageCount] > 0);
            stageSize /= vulkanFFTAxis->stageRadix[vulkanFFTAxis->stageCount];
            ++vulkanFFTAxis->stageCount;
        }
    }


Thank you!

@Lichtso
Copy link
Owner

Lichtso commented Feb 8, 2023

It takes uint32_t axis and vulkanFFTPlan->axes[axis].sampleCount as input and then calculates stageCount and stageRadix[] from that.

The "stages" refer to the iterations in this algorithm: https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm

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

No branches or pull requests

2 participants