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

            Bug ID: 127997
           Summary: [OpenMP] For PARAMETER (named constant): bogus "has
                    been referenced in offloaded code but hasn’t been
                    marked to be included in the offloaded code"
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: openmp, rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

OpenMP does not permit named constants in MAP clauses.

However, the following code - reduced from HecBench-Fortran's adamw-omp-fortran
fails with the error that the code has not been marked as used in the offload
code.

It seems as if those should be marked as
  declare target  local(...)
this makes it available on the offload side, but does not add it to the
offload_vars table.

It seems as if this testcase is somewhat related to PR95551:
- In that case, there is no named constant but likewise an array variable
  in read-only memory, created when expanding an array constructor.
In both cases, there is read-only memory that should not end up in a
map clause nor in the offload_vars table, but has to be available on the
(host and) offload side.

* * *

PR 71536 is also related - while it no longer gives an ICE, 
there is also no real point in having a 'const' variable in the
offload_vars table.

* * *

program main
  real, parameter :: exp_qmidpt(0:*) = [ 0.96875]
  call fused_4bit_kernel()
contains
  subroutine fused_4bit_kernel()
    integer :: block_id
    integer :: q_exp_left
    real :: mapped_value
    mapped_value = 43.
    !$omp target teams distribute firstprivate(mapped_value)
    do block_id = 0, 0
      q_exp_left = q_index_exp(mapped_value)
    end do
  end
  integer function q_index_exp(x)
    real, intent(in) :: x
    integer :: low
    low = 1
    if (exp_qmidpt(low - 1) < x) &
      q_index_exp = low
  end
end program main

Reply via email to