Code Monkey home page Code Monkey logo

cufft_examples's Introduction

cufft examples

Examples to reproduce the problem that upsets me when implementing fft in paddle with cufft as a backend.

To be concise, I tried to follow the convention of reusing cufft plans via wrapping cufftHandles in a RAII-style class. Then use an LRUCache to hold instances of the wrapped cufftHandles.

But when using cufft in cuda 10.1.105 via dynamic loading(dlopen the shared library and dlsym the functions I need) instead of dynamic linking, I almost always get a segmentfault when cufftHandles wrer being destroyed.

However, using cufft in cuda 10.1.105 via dynamic linking is okay. Also, using cufft from higher versions of cuda via dynamic loading is okay, too.

I have not found the reasons for this, but this example reproduces what is described above.

to reproduce

  1. install several versions of cuda toolkit, cuda 10.1, and higher versions of cuda cuda 10.1 update 1, cuda 10.1 update 2 or cuda 11.4+.
  2. git clone this repo, checkout the dynload branch, build it with different versions of cuda and run ./cufft_plans in the build directory.
  3. check if it fails with a segmentfault.

how to build it

  1. a c++ compiler with c++14 support.
  2. cuda toolkit. To be able to use a wide range of cuda toolkit, you may need to install cuda driver of high enough version.
# build it
mkdir build
cd build
cmake ..
make 

# run it 
./cufft_plans

NOTE: make sure to clean the build directory after switching to another cuda toolkit version.

Results

Prime factor <= 127 means none of fft transformation dimension sizes have a prime factor larger than 127; prime factor > 127 means at least one of fft transformation dimension sizes has a prime factor larger than 127;

results dynamic load

Prime factor <= 127 prime factor > 127
10.1 origin segmentfault segmentfault
10.1 update 1 ok segmentfault
10.1 update2 ok segmentfault
10.2 ok segmentfault
11.0.3 segmenfault segmentfault
11.1.1 segmenfault segmenfault
11.2.2 ok ok
11.3 ok ok
11.4.1 ok ok

dynamic link

Prime factor <= 127 prime factor > 127
10.1 origin ok ok
10.1 update 1 ok ok
10.1 update2 ok ok
10.2 ok ok
11.0.3 ok ok
11.1.1 ok ok
11.2 ok ok
11.3.1 ok ok
11.4.1 ok ok

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.