compiling a simple program

compiling a simple program

i have the following programs:

// test.f90

program test

implicit none



!dir$ attributes offload:mic :: calc


!dir$ omp offload target(mic)

!$omp parallel do

do i=1,100


end do

!$omp end parallel do

end program test


#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 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Remove the following

 #pragma offload_attribute (target(none))

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

for fortran programs use ifort

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.

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

ifort -c -openmp test.f90

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.

icc test.o test1.o

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

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


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

Ok, thanks!!!

Leave a Comment

Please sign in to add a comment. Not a member? Join today