Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Shashi_K_
Beginner
43 Views

ippSetNumThreads fails to create threads

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
Employee
43 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

 

Reply