Community
cancel
Showing results for 
Search instead for 
Did you mean: 
王_子_
Beginner
94 Views

The use of FFTW3 on my Xeon phi card (MIC)

hello ,

        When i use the fftw3 in the MKL on the Intel Xeon Phi, i use the followed compile command :

         icpc -g -O0 -tbb -mkl=parallel -qoffload-option,mic,compiler,-I/opt/intel/mkl/include/fftw -MMD -MP -MF"src/fftw_test.d" -MT"src/fftw_test.d" -c -o "src/fftw_test.o" "../src/fftw_test.cpp"

         The error wiil be reported :

        error: *MIC* function "fftwf_init_threads" called in offload region must have been declared with compatible "target" attribute

        My question is ,the <fftw3.h>has been integrated the MKL, how can I use the FFTW3 on MIC ?

        Thanks !

0 Kudos
7 Replies
Ying_H_Intel
Employee
94 Views

Hello, 

What is your MIC processor type,  is it coprocessor  or host-type ? 

For quick start, you may run the FFTW3 test code directly on the MIC (native executable) and see if it can be run. 

From  your discription,  it seems you are working on  the Compiler Assisted Offload 

(which is supposed the MIC worked as coprocessor).  Here is some article for your reference  

https://software.intel.com/en-us/articles/intel-mkl-on-the-intel-xeon-phi-coprocessors  

All used FFTW3 function may be need to clarified in #pragma offload target(mic) regin. 

Anyway, could you please provide us your test code so we can test at our side. 

Best Regards,

Ying 

王_子_
Beginner
94 Views

Ying H. (Intel) wrote:

Hello, 

What is your MIC processor type,  is it coprocessor  or host-type ? 

For quick start, you may run the FFTW3 test code directly on the MIC (native executable) and see if it can be run. 

From  your discription,  it seems you are working on  the Compiler Assisted Offload 

(which is supposed the MIC worked as coprocessor).  Here is some article for your reference  

https://software.intel.com/en-us/articles/intel-mkl-on-the-intel-xeon-ph...  

All used FFTW3 function may be need to clarified in #pragma offload target(mic) regin. 

Anyway, could you please provide us your test code so we can test at our side. 

Best Regards,

Ying 

 

Thank you for your help !

My card is 5110p. And I use Compiler Assisted Offload .

I just install "parallel_studio_xe_2017_beta_update2" on host(cpu), I think that I may need to install MKL on MIC? because you want me to try native executable mode .

But when I try to install the whole software  : parallel_studio_xe_2017_beta_update2 on mic , the card say the space is not enough,when I install the MKL independently on mic , some error happened, i also try to install FFTW3 on mic , the configure file says it is an unknown host .

My test code is  simple as followed:

 

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/time.h>
#include "fftw3.h"
int main() {

    int N[2];
    N[0] = 4096 * 2;
    N[1] = 4096 * 2;
    fftwf_complex *in, *out;
    in = (fftwf_complex *) fftwf_malloc(N[0] * N[1] * sizeof(fftwf_complex));
    out = (fftwf_complex *) fftwf_malloc(N[0] * N[1] * sizeof(fftwf_complex));
    for (int x = 0; x < N[0] * N[1]; x++) {
        in[0] = x % 1000;
        in[1] = 0;
    }

#pragma offload target(mic:0) inout(out:length(N[0]*N[1])) \
                                      in(in:length(N[0]*N[1]))
    {
        struct timeval tv1, tv2;
        struct timezone tz;
        gettimeofday(&tv1, &tz);

        fftwf_plan temp;
        temp = fftwf_plan_dft_2d(N[0], N[1], in, out, FFTW_FORWARD,FFTW_ESTIMATE);

        for (int x = 0; x < 100; x++) {
            fftwf_execute(temp);

        }

        gettimeofday(&tv2, &tz);

        fftwf_destroy_plan(temp);
        printf(" pureFFT   FFT  tv_sec:  %d s \n", tv2.tv_sec - tv1.tv_sec);

    }

}

Ying_H_Intel
Employee
94 Views

Hi

Thanks for the details,  

No, you don't need to install parallel studio and MKL on MIC card.  You can build one exectuable file on your host machine, then copy it to mic machine and run. 

You can refer to  https://software.intel.com/en-us/articles/intel-mkl-on-the-intel-xeon-phi-coprocessors

 

https://software.intel.com/en-us/articles/intel-mkl-programming-models-for-intel-xeon-phi

for example, 

remove #pragma offload target(mic:0) inout(out:length(N[0]*N[1])) \
                                      in(in:length(N[0]*N[1]))
    {

}

then compile it as  https://software.intel.com/en-us/articles/tuning-the-intel-mkl-dft-functions-performance-on-intel-xe...

icc –O3 –mmic -static-intel -mkl test.c –o test.exe  (static link all of MKL libraries). 

then scp the test.exe (maybe some auxiliary library like libiomp5.so etc) to MIC and run on it. 

Best Regards,
Ying

王_子_
Beginner
94 Views

Ying H. (Intel) wrote:

Hi

Thanks for the details,  

No, you don't need to install parallel studio and MKL on MIC card.  You can build one exectuable file on your host machine, then copy it to mic machine and run. 

You can refer to  https://software.intel.com/en-us/articles/intel-mkl-on-the-intel-xeon-ph...

 

https://software.intel.com/en-us/articles/intel-mkl-programming-models-f...

for example, 

remove #pragma offload target(mic:0) inout(out:length(N[0]*N[1])) \
                                      in(in:length(N[0]*N[1]))
    {

}

then compile it as  https://software.intel.com/en-us/articles/tuning-the-intel-mkl-dft-functions-performance-on-intel-xe...

icc –O3 –mmic -static-intel -mkl test.c –o test.exe  (static link all of MKL libraries). 

then scp the test.exe (maybe some auxiliary library like libiomp5.so etc) to MIC and run on it. 

Best Regards,
Ying

 

Thanks for your patient ! 

I try the mmic option and the code  really work on native mode on MIC . However , I have many cpp file in the project and I need use Compiler Assisted Offload to accelerate the whole project. 

So I want to  know when I use the Compiler Assisted Offload mode ,  do I need to  install the MKL on MIC to avoid the mentioned before error ?

error: *MIC* function "fftwf_init_threads" called in offload region must have been declared with compatible "target" attribute ;

Or I have other choice to avoid the erorr?

 
Ying_H_Intel
Employee
94 Views

Hi 

Nice to know native model works.

back to original problem, if you'd like to use the FFTW function in  the Compiler Assisted Offload mode.  then it required 

All used FFTW3 function need to be declared in #pragma offload target(mic) region. I will check with MKL developer. 

You may tried to add such declaration and see if it works. 

The error (in compile)  should not related to MKL on MIC or not (run-time).   So you don't need to install MKL on MIC.  and when static link. no MKL library needed on MIC.

Best Regards,
Ying  

王_子_
Beginner
94 Views

Ying H. (Intel) wrote:

Hi 

Nice to know native model works.

back to original problem, if you'd like to use the FFTW function in  the Compiler Assisted Offload mode.  then it required 

All used FFTW3 function need to be declared in #pragma offload target(mic) region. I will check with MKL developer. 

You may tried to add such declaration and see if it works. 

The error (in compile)  should not related to MKL on MIC or not (run-time).   So you don't need to install MKL on MIC.  and when static link. no MKL library needed on MIC.

Best Regards,
Ying  

I am very happy to tell you that I have been solved the problem through this website,and I want to let more people know it :

https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor

When I  select the MKL and some detail info , it lists the advise including compile options and link line. 

Although the FFTW not been mentioned ,but I add some simple option , the  Compiler Assisted Offload mode worked.

The compile command is :

icpc -I${MKLROOT}/include/fftw -qoffload-attribute-target=mic -qoffload-option,mic,compiler," -L${MKLROOT}/lib/mic -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread" -c fftw_test.cpp -o FFT.o

The link command is :

icpc FFT.o -I/opt/intel/mkl/include/fftw -L${MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -liomp5 -qoffload-attribute-target=mic -qoffload-option,mic,compiler," -L${MKLROOT}/lib/mic -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -liomp5 " -lrt -qopenmp -ldl -o FFT
 
PS: the link option about the mic is not mentioned by the guide ,I add it by myself because some library like fftw may need it .
PPS : Thank you for your help and your patience ! And I find that I use FFT by FFTW3 on mic does not have good performance comparing with GPU-CUFFT, as for this respect ,do you have any data or result that we can discuss ?
Yours sincerely !
Ying_H_Intel
Employee
94 Views

Hello,

Nice to know you solve the problem by link advisor  https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor.

Right, you need to add -qoffload-attribute-target=mic  in your command line.  We only have some FFT performance in MKL main page  https://software.intel.com/en-us/intel-mkl/, you may refer them.

Best Regard,

Ying

Reply