https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98476

            Bug ID: 98476
           Summary: OpenMP offload syntax restriction
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xw111luoye at gmail dot com
  Target Milestone: ---

C version code works. The corresponding Fortran version is blocked by the
compiler errror.

C version:
#include <stdio.h>

int main()
{
  int a[1];
  int* b = a;
  a[0] = 0;
  #pragma omp target enter data map(to:b[:1])
  #pragma omp target data use_device_ptr(b)
  {
    #pragma omp target is_device_ptr(b)
    {
      b[0] = 1;
    }
  }
  printf("value before exit data %d\n", b[0]);
  #pragma omp target exit data map(from:b[:1])
  printf("value after exit data %d\n", b[0]);
  return 0;
}


Fortran version, XL fortran compiler works with this case.
program abc
  implicit none
  integer a

  a = 0
  call test(a)

contains
  subroutine test(a)
    implicit none
    integer a

  !$omp target enter data map(to:a)
  !$omp target data use_device_ptr(a)
  ! Error: TARGET DATA must contain at least one MAP clause at (1)
  ! after adding map(to: a), the second printout is still wrong.
  !$omp target is_device_ptr(a)
    a = 1
  !$omp end target
  !$omp end target data
  write(6,*) "before exit data a = ", a
  !$omp target exit data map(from:a)
  write(6,*) "after exit data a = ", a

  endsubroutine
end program

Reply via email to