compiling a simple program

compiling a simple program

Bild des Benutzers TK

i have the following programs:

// test.f90

program test

implicit none

integer::i

integer,dimension(100)::arr

!dir$ attributes offload:mic :: calc

real,external::calc

!dir$ omp offload target(mic)

!$omp parallel do

do i=1,100

    arr(i)=calc(i)

end do

!$omp end parallel do

end program test

//test.c

#include <offload.h>

#pragma offload_attribute (target(mic))

float calc_(int *data)

{

 return *data+1;

}

#pragma offload_attribute (target(none))

if i try to compile the test.c as "icc -c test.c", it says: "error: target not recognized". can you show me how to compile above to programs and run? thanks!

12 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Ravi Narayanaswamy (Intel)

Remove the following

 #pragma offload_attribute (target(none))

Bild des Benutzers TK

Thanks Ravi. Also if I compile the test.f90 as "icc -c test.f90", it says "no action performed for file test.f90"?

Bild des Benutzers Ravi Narayanaswamy (Intel)

for fortran programs use ifort

Bild des Benutzers TK

Sorry, I did "ifort -c test.f90", it says "the omp offload directive must be followed by one of the OpenMP directives parallel, parallel sections, or parallel do". Thanks.

Bild des Benutzers Ravi Narayanaswamy (Intel)

To enable Openmp  you need to add the option -openmp to the command line

ifort -c -openmp test.f90

Bild des Benutzers TK

Thanks Ravi. Now, I renamed the test.f90 to test1.f90, after compiling I get "test1MIC.o" and "test1.o", also for test.c I get "testMIC.o" and "test.o". Now, how should I get the executable? Thanks.

Bild des Benutzers Ravi Narayanaswamy (Intel)

icc test.o test1.o

Bild des Benutzers Kevin Davis (Intel)

Your main is in Fortran, so as you noted create separate files (e.g. testC.c and testF.f90) then compile as follows:

icc -c -openmp testC.c

ifort -openmp testF.F testC.o

Bild des Benutzers TK

Thanks Kevin and Ravi. Then where testCMIC.o and testFMIC.o will be used? Thanks.

Bild des Benutzers Ravi Narayanaswamy (Intel)

Yes. 

 In the future you will not see xxxMIC.o   as they will be part of xxx.o

Bild des Benutzers TK

Ok, thanks!!!

Melden Sie sich an, um einen Kommentar zu hinterlassen.