Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1769957

Summary: libgomp for rhel7 system gcc misses GOMP_loop_maybe_nonmonotonic_runtime_next
Product: Red Hat Developer Toolset Reporter: Alexandra Petlanová Hájková <ahajkova>
Component: gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED ERRATA QA Contact: Alexandra Petlanová Hájková <ahajkova>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: DTS 9.1 RHEL 7CC: fweimer, jakub, law, mcermak, mnewsome, ohudlick, tborcin
Target Milestone: rc   
Target Release: 9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: devtoolset-9-gcc-9.1.1-2.5.el7 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-12-10 07:49:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
reproducer none

Description Alexandra Petlanová Hájková 2019-11-07 19:13:54 UTC
Created attachment 1633783 [details]
reproducer

Description of problem:
trying to compile the reproducer with devtoolset-9-gcc fails due to GOMP_loop_maybe_nonmonotonic_runtime_next missing in system gcc's libgomp

Version-Release number of selected component (if applicable):
devtoolset-9-gcc-9.1.1-2.4.el7
gcc-4.8.5-39.el7

How reproducible:
gcc -O3 --openmp -o micro2 micro2.c -std=c99

Actual results:
opt/rh/devtoolset-9/root/usr/libexec/gcc/s390x-redhat-linux/9/ld: /tmp/cckcDjZq.o: in function `runtime_bench._omp_fn.0':
micro2.c:(.text+0x1fe): undefined reference to `GOMP_loop_maybe_nonmonotonic_runtime_next'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/s390x-redhat-linux/9/ld: micro2.c:(.text+0x236): undefined reference to `GOMP_loop_maybe_nonmonotonic_runtime_next'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/s390x-redhat-linux/9/ld: /tmp/cckcDjZq.o: in function `runtime_bench':
micro2.c:(.text+0x4c2): undefined reference to `GOMP_parallel_loop_maybe_nonmonotonic_runtime'

Comment 3 Marek Polacek 2019-11-13 16:36:32 UTC
QE testcase:

__attribute__((noipa)) int
foo (unsigned long long l)
{
  unsigned long long r;
  asm ("" : "=g" (r) : "0" (l));
  return r;
}

int
main ()
{
  int i, a[64];
  unsigned long long l;
  volatile unsigned long long n = 1;
  volatile unsigned long long m = 64;
  #pragma omp parallel
  {
    #pragma omp for schedule (runtime)
    for (i = 0; i < 64; i++)
      a[i] = i;
    #pragma omp barrier
    #pragma omp for schedule (nonmonotonic, runtime)
    for (i = 0; i < 64; i++)
      a[i] += i;
    #pragma omp barrier
    #pragma omp for schedule (runtime)
    for (l = 0; l < m; l += n)
      a[foo (l)] += l;
    #pragma omp barrier
    #pragma omp for schedule (nonmonotonic, runtime)
    for (l = 0; l < m; l += n)
      a[foo (l)] += l;
  }
  #pragma omp parallel for schedule (runtime)
  for (i = 0; i < 64; i++)
    a[i] += i;
  #pragma omp parallel for schedule (nonmonotonic, runtime)
  for (i = 0; i < 64; i++)
    a[i] += i;
  for (i = 0; i < 64; i++)
    if (a[i] != 6 * i)
      __builtin_abort ();
  return 0;
}

Comment 4 Marek Polacek 2019-11-13 16:42:46 UTC
A patch for DTS 9: we will create a static library and add a linker script linking that library along with the system libgomp.so.

/* Copyright (C) 2019 Free Software Foundation, Inc.
   Contributed by Jakub Jelinek <jakub>.

   This file is part of the GNU Offloading and Multi Processing Library
   (libgomp).
  
   Libgomp is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   more details.

   Under Section 7 of GPL version 3, you are granted additional
   permissions described in the GCC Runtime Library Exception, version
   3.1, as published by the Free Software Foundation.

   You should have received a copy of the GNU General Public License and
   a copy of the GCC Runtime Library Exception along with this program;
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   <http://www.gnu.org/licenses/>.  */

/* Remapping of nonmonotonic runtime schedule and maybe nonmonotonic runtime
   schedule loop entrypoints (the used by GCC 9 and later for runtime
   schedule without monotonic or nonmonotonic modifiers).
   RHEL 7 libgomp only implements the GOMP*loop*runtime* entrypoints without
   nonmonotonic in the names, which always implement monotonic scheduling,
   but the library doesn't implement any other scheduling, even in GCC 9
   and monotonic scheduling is a valid implementation of non-monotonic
   scheduling.  */

#include <stdbool.h>

typedef unsigned long long ull;
extern bool GOMP_loop_runtime_start (long, long, long, long *, long *);
extern bool GOMP_loop_runtime_next (long *, long *);
extern void GOMP_parallel_loop_runtime (void (*)(void *), void *,
					unsigned, long, long, long,
					unsigned);
extern bool GOMP_loop_ull_runtime_start (bool, ull, ull, ull, ull *, ull *);
extern bool GOMP_loop_ull_runtime_next (ull *, ull *);
#define alias(x, y) __typeof (x) y __attribute__((alias (#x)))

#pragma GCC visibility push(hidden)

bool
GOMP_loop_nonmonotonic_runtime_start (long start, long end, long incr,
				      long *istart, long *iend)
{
  return GOMP_loop_runtime_start (start, end, incr, istart, iend);
}
alias (GOMP_loop_nonmonotonic_runtime_start,
       GOMP_loop_maybe_nonmonotonic_runtime_start);

bool
GOMP_loop_nonmonotonic_runtime_next (long *istart, long *iend)
{
  return GOMP_loop_runtime_next (istart, iend);
}
alias (GOMP_loop_nonmonotonic_runtime_next,
       GOMP_loop_maybe_nonmonotonic_runtime_next);

void
GOMP_parallel_loop_nonmonotonic_runtime (void (*fn)(void *), void *data,
					 unsigned num_threads, long start,
					 long end, long incr, unsigned flags)
{
  return GOMP_parallel_loop_runtime (fn, data, num_threads, start,
				     end, incr, flags);
}
alias (GOMP_parallel_loop_nonmonotonic_runtime,
       GOMP_parallel_loop_maybe_nonmonotonic_runtime);

bool
GOMP_loop_ull_nonmonotonic_runtime_start (bool up, ull start, ull end,
					  ull incr, ull *istart, ull *iend)
{
  return GOMP_loop_ull_runtime_start (up, start, end, incr, istart, iend);
}
alias (GOMP_loop_ull_nonmonotonic_runtime_start,
       GOMP_loop_ull_maybe_nonmonotonic_runtime_start);

bool
GOMP_loop_ull_nonmonotonic_runtime_next (ull *istart, ull *iend)
{
  return GOMP_loop_ull_runtime_next (istart, iend);
}
alias (GOMP_loop_ull_nonmonotonic_runtime_next,
       GOMP_loop_ull_maybe_nonmonotonic_runtime_next);

#pragma  GCC visibility pop

Comment 12 errata-xmlrpc 2019-12-10 07:49:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2019:4134