Giter Site home page Giter Site logo

vulkanfft's Introduction

All Linux macOS Windows
Build Status Build Status Linux Build Status macOS Build Status Windows

Vulkan Fast Fourier Transform

Note: A more recent and more complete alternative was released.

This library can calculate a multidimensional Discrete Fourier Transform on the GPU using the Vulkan API. However, in most cases you probably want a different library, because Vulkan does not change much about the GPU computations, but is a lot more complex than other APIs. Alternatives are based on OpenGL, OpenCL or CUDA for example. Some reasons to use this library anyway are:

  • You already have a Vulkan application and just need a FFT implementation
  • You want to reduce CPU load, because Vulkan is meant do exactly that
  • You are on a platform where other options are worse or just not supported (e.g. OpenGL on MacOS)
  • You are just here for the CLI and don't care about Vulkan

Command Line Interface

Note that many small invocations are very inefficient, because the startup costs of Vulkan are very high. So the CLI is only useful for transforming big data sets and testing. Also, only the library is supported on windows, not the CLI.

Options

  • -x width Samples in x direction
  • -y height Samples in y direction
  • -z depth Samples in z direction
  • --inverse Calculate the IDFT
  • --input raw / ascii / png / exr Input encoding
  • --output raw / ascii / png / exr Output encoding
  • --device index Vulkan device to use
  • --list-devices List Vulkan devices
  • --measure-time Measure time spent in setup, upload, computation, download and teardown

Example Invocations

vulkanfft -x 16 -y 16 --input ascii --output png --inverse < test.txt > test.png
vulkanfft -x 16 -y 16 --input png --output ascii < test.png

Dependencies

  • cmake 3.11
  • Vulkan Runtime 1.0
  • Vulkan SDK 1.2.141.2 (to compile GLSL to SPIR-V)
  • xxd (to inline SPIR-V in C)
  • libpng 1.6.0 (optional, only needed for CLI)
  • libopenexr 2.5.2 (optional, only needed for CLI)

Current Features & Limitations

  • Dimensions
    • Only 1D, 2D, 3D
    • No higher dimensions
  • Direction & Scale
    • Forward / backward (inverse)
    • No normalized / unnormalized switch independent of direction
  • Sample Count / Size
    • Only POT (power of two)
    • No prime factorization
  • Memory Layout
    • Only buffers (row-major order)
    • No samplers / images / textures (2D tiling)
    • Only interleaved complex float
    • No separation of real and imaginary parts
  • Bit-Depth & Data Types
    • Only 32 bit complex floats
    • No real only mode
    • No 8, 16, 64, 128 bit floats or integers
  • Parallelization / SIMD
    • Only radix 2, 4, 8
    • No higher radix
  • Memory Requirements
    • 2*n because of swap buffers for Stockham auto-sort algorithm
    • No reordering and in-place operation
  • Memorization & Profiling
    • Only cold planning
    • No memorization or warm planning / wisdom profiling
  • Related Extras
    • No convolution

vulkanfft's People

Contributors

lichtso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vulkanfft's Issues

VulkanFFT v.s regular openGL based FFT implementation

Hello Lichtso,

Regarding your comment,
However, in most cases you probably want a different library, because Vulkan does not change much about the GPU computations, but is a lot more complex than other APIs.

Do you mean your VulkanFFT may be slower than regular openGL based FFT? Though I haven't been able to compare your VulkanFFT with other openGL based FFT implementations yet, I am curious to understand the potential performance difference.

Thank you for the great work!

Successfully built for Android NDK by specifying path to glslangValidator

Hello,

I was successfully able to build this project for the Android NDK 20.1 with the following cmake invocation:

$ export NDK_DIR=$HOME/Android/Sdk/ndk/20.1.5948944
mkdir -p build && cd build && cmake .. \
              -DCMAKE_TOOLCHAIN_FILE=$NDK_DIR/build/cmake/android.toolchain.cmake \
              -DVulkan_LIBRARY=$NDK_DIR/platforms/android-24/arch-arm64/usr/lib/libvulkan.so
              -DVulkan_INCLUDE_DIR=$NDK_DIR/sysroot/usr/include \
              -DANDROID_PLATFORM=24 \
              -DANDROID_ABI=arm64-v8a

The only special thing I had to do was replace ${VULKAN_SDK}/bin/glslangValidator with $HOME/Android/Sdk/emulator/lib64/vulkan/glslangValidator in CMakeLists.txt.

Is this any use as an upstream contribution? Perhaps make a GLSLANG_VALIDATOR_PATH configurable or something of that nature.

glslangValidator: Error -Os not available; optimizer not linked (use -h for usage)

make failed after a seemly successful cmake ../ . The error info is:

glslangValidator: Error -Os not available; optimizer not linked (use -h for usage)

Below is the complete output.

~/VulkanFFT/build$ make
[ 12%] Generating radix4.hex
/bin/glslangValidator: Error -Os not available; optimizer not linked (use -h for usage)
make[2]: *** [CMakeFiles/radix4ShaderModuleTarget.dir/build.make:61: radix4.hex] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/radix4ShaderModuleTarget.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Below is CMake output

VulkanFFT/build$ cmake ../
-- The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Vulkan: /usr/lib/x86_64-linux-gnu/libvulkan.so  
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found suitable version "1.6.37", minimum required is "1.6.0") 
-- Configuring done
-- Generating done
-- Build files have been written to: ~/VulkanFFT/build

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

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.