Software Archive
Read-only legacy content
17061 Discussions

parallel_studio_xe_2015 NOT openmp 4.0 compliance?

Minh_H_
Beginner
957 Views

Hi,

The following code does not work as expected:

------------------------------------------------------------------------

MODULE  SIM_DATA
    !$OMP declare target (GX)
    !     DIR$ ATTRIBUTES OFFLOAD:mic :: GX
    REAL  GX
END MODULE  SIM_DATA

!DIR$ ATTRIBUTES OFFLOAD:mic :: test0
SUBROUTINE  test0(n, b)
    INTEGER n, b(n)
    print *,'test0',  b
END

!DIR$ ATTRIBUTES OFFLOAD:mic :: test1,test0
SUBROUTINE  test1(n, a, b)
USE  SIM_DATA
    IMPLICIT NONE
    
    INTEGER n, a(n), b(n,2)        
    print *, a   
    b(:,1) = a
    b(:,2) = a+ 5
    CALL test0(n,b(:,1))
    print *, 'GX: ', GX
END

PROGRAM  test_main
USE SIM_DATA
    IMPLICIT NONE
    INTEGER n,ai(3,2), b(3,4)
    !$OMP DECLARE TARGET  (test1)
    ai(:,1) = 3
    ai(:,2) = 4
    n = 3
    GX = 10
    !$OMP TARGET DATA MAP (to: GX)
    ! DIR$ OFFLOAD_TRANSFER TARGET(mic:0) IN(GX)
     
    !$OMP PARALLEL SECTIONS
    !$OMP SECTION
        !$OMP TARGET MAP(TO: n,ai(:,1)) MAP(FROM: b(:,1:2))    
        CALL test1(n,ai(:,1), b(:,1:2))        
        !$OMP end target
    !$OMP SECTION
        CALL test1(n,ai(:,2), b(:,3:4))
    !$OMP END PARALLEL SECTIONS    
    !$OMP END TARGET DATA
    print *, 'b='
    print *, b
    
END

------------------------------------------------------------------------------------

did not work as I expected, GX=0.0 inside MIC.

If I change as follows

   !   $OMP declare target (GX)

   !DIR$ ATTRIBUTES OFFLOAD:mic :: GX        !Intel's specific directive

    !   $OMP TARGET DATA MAP (to: GX)
    !DIR$ OFFLOAD_TRANSFER TARGET(mic:0) IN(GX)     !Intel's specific directive
the code works as I expected. So  is the compiler not OpenMP4.0 compliance or did I do something wrong?

My aim is to try to use the GLOBAL VARIABLE GX in SIM_DATA module.  Please help!

 

  

 

 

 

0 Kudos
1 Solution
Kevin_D_Intel
Employee
957 Views

Guidance from Development confirmed the compiler is compliant and that TARGET UPDATE is required here. They indicate with OpenMP 4.0:

  • If an object is already mapped then a MAP clause has no effect and is ignored.
  • If an object is declared with DECLARE TARGET in the global scope then the object is mapped from the start to the end of the program
  • To synchronize the data you must use TARGET UPDATE clause.

 

View solution in original post

0 Kudos
5 Replies
Kevin_D_Intel
Employee
957 Views

I *think* TARGET UPDATE is used instead of the TARGET DATA MAP/END TARGET directives but I will double check.

The program works when replacing this line:

!$OMP TARGET DATA MAP (to: GX)

With this line:

!$OMP TARGET UPDATE to(GX)

and also removing/commenting out the !$OMP END TARGET DATA

0 Kudos
Kevin_D_Intel
Employee
958 Views

Guidance from Development confirmed the compiler is compliant and that TARGET UPDATE is required here. They indicate with OpenMP 4.0:

  • If an object is already mapped then a MAP clause has no effect and is ignored.
  • If an object is declared with DECLARE TARGET in the global scope then the object is mapped from the start to the end of the program
  • To synchronize the data you must use TARGET UPDATE clause.

 

0 Kudos
Minh_H_
Beginner
957 Views

Hi  Kevin,

Many thanks.

Do you know any equivalent directive of OpenMP for

! DIR$ OFFLOAD BEGIN target(mic: 1)

I need to specify card-id? Is that possible with OpenMP 4?

   Thanks, M

 

0 Kudos
Kevin_D_Intel
Employee
957 Views

Neither implementation requires that you specify a card-id (i.e. target). Each uses a default in the absence of any specific target id being provided.

In OpenMP 4.0 the DEVICE() clause enables specifying a specific target id. The !$OMP TARGET / END TARGET directive pair is the equivalent of the !DIR$ OFFLOAD BEGIN / END directive pair, so the equivalent of your OFFLOAD BEGIN would be:

!$OMP TARGET DEVICE(1)
   <structured block>
!$OMP END TARGET

 

0 Kudos
Minh_H_
Beginner
957 Views

Hi Kevin,

Many thanks.

I have another question  posted on https://software.intel.com/en-us/forums/topic/537473. Why is the offload mode much slower than native mode?

Did I underestimate something in my post?

Many thanks, M

 

 

0 Kudos
Reply