Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

ippSetNumThreads fails to create threads

Shashi_K_
Beginner
275 Views

We are using IPP 7.0.

I have a small console application in which I am calling the FFT function from here

https://software.intel.com/en-us/articles/how-to-use-intel-ipp-s-1d-fourier-transform-functions

When i call ippSetNumThreads(10); and get the number of threads using ppGetNumThreads(&origTh); its returning 10.

However when my FFT is running if i monitor number of threads in task manager i only see one thread.

Dont understand why. Please help.

Shashi

 

void IPPFFT()
{
	    //Set the size
    const int N=128;
    const int order=(int)(log((double)N)/log(2.0));

    // Spec and working buffers
    IppsFFTSpec_C_32fc *pFFTSpec=0;
    Ipp8u *pFFTSpecBuf, *pFFTInitBuf, *pFFTWorkBuf;

    // Allocate complex buffers
    Ipp32fc *pSrc=ippsMalloc_32fc(N);
    Ipp32fc *pDst=ippsMalloc_32fc(N); 

    // Query to get buffer sizes
    int sizeFFTSpec,sizeFFTInitBuf,sizeFFTWorkBuf;
    ippsFFTGetSize_C_32fc(order, IPP_FFT_NODIV_BY_ANY, 
        ippAlgHintAccurate, &sizeFFTSpec, &sizeFFTInitBuf, &sizeFFTWorkBuf);

    // Alloc FFT buffers
    pFFTSpecBuf = ippsMalloc_8u(sizeFFTSpec);
    pFFTInitBuf = ippsMalloc_8u(sizeFFTInitBuf);
    pFFTWorkBuf = ippsMalloc_8u(sizeFFTWorkBuf);

    // Initialize FFT
    ippsFFTInit_C_32fc(&pFFTSpec, order, IPP_FFT_NODIV_BY_ANY, 
        ippAlgHintAccurate, pFFTSpecBuf, pFFTInitBuf);
    if (pFFTInitBuf) ippFree(pFFTInitBuf);

    // Do the FFT
    ippsFFTFwd_CToC_32fc(pSrc,pDst,pFFTSpec,pFFTWorkBuf);


    //check results
    ippsFFTInv_CToC_32fc(pDst,pDst,pFFTSpec,pFFTWorkBuf);
    int OK=1;
    for (int i=0;i<N;i++) {
        pDst.re/=(Ipp32f)N;
        pDst.im/=(Ipp32f)N;
        if ((abs(pSrc.re-pDst.re)>.001) || 

            (abs(pSrc.im-pDst.im)>.001) ) 
        {
            OK=0;break;
        }
    }
    puts(OK==1?"FFT OK":"FFT Fail");

    if (pFFTWorkBuf) ippFree(pFFTWorkBuf);
    if (pFFTSpecBuf) ippFree(pFFTSpecBuf);

    ippFree(pSrc);
    ippFree(pDst);

}
int _tmain(int argc, _TCHAR* argv[])
{
	
	//ipp
	int origTh = 0;
	ippGetNumThreads(&origTh);
	printf("NumThreads = %d", origTh);
	getch();

	ippSetNumThreads(10);

	ippGetNumThreads(&origTh);
	printf("NumThreads = %d", origTh);
	getch();

	IPPFFT();

	getch();
		
	return 0;


}

 

0 Kudos
1 Reply
Chao_Y_Intel
Moderator
275 Views

Hi Shashi,

1D FFT can not get good performance improvement regarding the threading.  128 is too small to get good performance with the threading.

You can check these two posting the 1D FFT threading performance discussion:
https://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/283657
https://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/385354

Basically, the  FFT is threaded for fit into shared L2 cases only. For small orders OMP overhead is greater than benefit, for large orders (out-of-cache) memory effects play negative role so customers investigation is right there is no any threading for order 19 and above.

Thanks,
Chao

 

0 Kudos
Reply