Main Content

coder.fftw.StandaloneFFTW3Interface.getNumThreads

Class: coder.fftw.StandaloneFFTW3Interface
Namespace: coder.fftw

Return number of threads to use for FFTW library calls

Syntax

coder.fftw.StandaloneFFTW3Interface.getNumThreads()

Description

coder.fftw.StandaloneFFTW3Interface.getNumThreads() returns the number of threads to use for calls to a specific FFTW library.

An FFT library callback class that derives from a coder.fftw.StandaloneFFTW3Interface class specifies the FFTW library to use.

Examples

expand all

In a class that derives from coder.fft.StandaloneFFTW3Interface, implement a method getNumThreads that returns the number of threads for the FFTW library to use.

Use the getNumThreads method in this example coder.fftw.StandaloneFFTW3Interface class as a template.

% copyright 2017 The MathWorks, Inc.

classdef useMyFFTW < coder.fftw.StandaloneFFTW3Interface
     
    methods (Static)
        function th = getNumThreads
            coder.inline('always');
            th = int32(coder.const(1));
        end
                
        function updateBuildInfo(buildInfo, ctx)
            fftwLocation = '/usr/lib/fftw';
            includePath = fullfile(fftwLocation, 'include');
            buildInfo.addIncludePaths(includePath);
            libPath = fullfile(fftwLocation, 'lib');
            
            %Double
            libName1 = 'libfftw3-3';
            [~, libExt] = ctx.getStdLibInfo();
            libName1 = [libName1 libExt];
            addLinkObjects(buildInfo, libName1, libPath, 1000, true, true);
            
            %Single
             libName2 = 'libfftw3f-3';
            [~, libExt] = ctx.getStdLibInfo();
            libName2 = [libName2 libExt];
            addLinkObjects(buildInfo, libName2, libPath, 1000, true, true);
        end
    end           
end

In your getNumThreads method, set th to the number of threads that you want to use. For example, this code specifies three threads:

th = int32(coder.const(3))

Version History

Introduced in R2017b