Software Archive
Read-only legacy content
17060 Discussions

compiling a simple program

TK
Beginner
1,693 Views

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!

0 Kudos
11 Replies
Ravi_N_Intel
Employee
1,693 Views

Remove the following

 #pragma offload_attribute (target(none))

0 Kudos
TK
Beginner
1,693 Views

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

0 Kudos
Ravi_N_Intel
Employee
1,693 Views

for fortran programs use ifort

0 Kudos
TK
Beginner
1,693 Views

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.

0 Kudos
Ravi_N_Intel
Employee
1,693 Views

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

ifort -c -openmp test.f90

0 Kudos
TK
Beginner
1,693 Views

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.

0 Kudos
Ravi_N_Intel
Employee
1,693 Views

icc test.o test1.o

0 Kudos
Kevin_D_Intel
Employee
1,693 Views

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

0 Kudos
TK
Beginner
1,693 Views

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

0 Kudos
Ravi_N_Intel
Employee
1,693 Views

Yes. 

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

0 Kudos
TK
Beginner
1,693 Views

Ok, thanks!!!

0 Kudos
Reply