Software Archive
Read-only legacy content
17060 토론

Offload example in fortran

vincent_b_
초급자
1,481 조회수

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 포인트
2 응답
Kevin_D_Intel
직원
1,481 조회수

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 포인트
vincent_b_
초급자
1,481 조회수

Thank you Kevin.
That works.

0 포인트
응답