Software Archive
Read-only legacy content
17061 Discussions

Offload example in fortran

vincent_b_
Beginner
494 Views

Hi,

I'm trying this simple fortran offload example and I don't understand why it gives me this error :

main_offload1.f90(26): warning #8535: A procedure called in an OFFLOAD region must have the OFFLOAD:TARGET attribute.   [SQUAROOT]
        call squaroot(a,b,c,N)
-------------^
main_offload1.f90(26): warning #8535: *MIC* A procedure called in an OFFLOAD region must have the OFFLOAD:TARGET attribute.   [SQUAROOT]
        call squaroot(a,b,c,N)
-------------^

Here is the code:

!dir$ attributes offload:mic :: squaroot
        SUBROUTINE squaroot(a,b,c,N)
        REAL, DIMENSION(N,N) :: a, b, c
        INTEGER :: N
        DO j = 1, N
                DO i = 1, N
                        a(i,j) = SQRT( b(i,j) * c(i,j) )
                        write (*,*) a(i,j)
                END DO
        END DO
        END

        PROGRAM MAIN
!dir$ attributes offload:mic ::   a, b, c
        REAL, DIMENSION(:,:), ALLOCATABLE :: a, b, c
        INTEGER :: N
        N = 10
        ALLOCATE (a(N,N), b(N,N), c(N,N))
        DO j = 1, N
                DO i = 1, N
                        c(i,j) = (i+j*N)
                        b(i,j) = c(i,j)
                END DO
        END DO
!dir$ offload target(mic) in(a,b:length(N*N)) inout(c:length(N*N))
        call squaroot(a,b,c,N)
        DEALLOCATE (a,b,c)
        END

Thanks you.

0 Kudos
2 Replies
Kevin_D_Intel
Employee
494 Views

You must to declare the routine used within the offload region both at the point of definition and within the scope used. So, in the main program scope, add squaroot to attributes directive you already have.

0 Kudos
vincent_b_
Beginner
494 Views

Thank you Kevin.
That works.

0 Kudos
Reply