Code Monkey home page Code Monkey logo

filter_bank's Introduction

filter_bank: optimization of filter bank function in Rust and C

Bart Massey

The code in filter-orig.rs here came from this Reddit thread. It apparently is an implementation of a piece of a DSP filter bank.

The Rust version here is my rewrite of that code to clean it up a bit. The C version was hand-translated from the rewritten Rust version. Both versions include very minimal tests that nothing was harmed in the process.

Build with make. Please check the Makefile for CPU type settings and C compiler options, and check the Cargo.toml for other Rust stuff. make clean to clean up, make test to run the tests: an assertion will happen if a test fails.

To summarize my results:

  • My Rust rewrite produced better code than the original.

  • rustc and clang-12 produced an essentially identical inner loop.

  • GCC 10.2 managed to use VFMA and VNFMA instructions to improve on the LLVM result somewhat, although the C standard maybe possibly does not allow this by default due IEEE standards… stuff. Use the fma feature with the Rust code to get a version that uses f32::mul_add() to get essentially the GCC inner loop.

  • None of the compilers managed to vectorize the code, which in retrospect is not surprising given its data dependencies in the inner loop.

  • On my recent machine (znver3) the inner loop is not unrolled. On my older machine (haswell) the inner loop is unrolled. The difference might be that the compiler CPU model detects no performance advantage from unrolling with the newer CPU.

filter_bank's People

Contributors

bartmassey avatar

Watchers

 avatar James Cloos avatar  avatar

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.