public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "grg-webvisible+gcc.gnu.org at ai dot mit.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgomp/109452] New: omp_init_lock_with_hint() and omp_init_nest_lock_with_hint() are undefined
Date: Sat, 08 Apr 2023 20:34:02 +0000	[thread overview]
Message-ID: <bug-109452-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109452
           Summary: omp_init_lock_with_hint() and
                    omp_init_nest_lock_with_hint() are undefined
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: grg-webvisible+gcc.gnu.org at ai dot mit.edu
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

omp_init_lock_with_hint() and omp_init_nest_lock_with_hint() appear to be
declared but not defined:

    #include <omp.h>
    int main() {
        omp_lock_t lock;
        omp_init_lock_with_hint(&lock, omp_sync_hint_none);
    }

compiled with:

    gcc -fopenmp main.cpp

fails to link:

    In function `main':
    main.cpp:(.text+0x15): undefined reference to `omp_init_lock_with_hint'
    collect2: error: ld returned 1 exit status

on v12.1.0:

    GNU C++17 (GCC) version 12.1.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 12.1.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP

Adding extra link options like -lgomp and -lpthread and -static does not help,
nor does using a different omp_sync_hint (and none of these should in fact
help).  Also confirmed with v11.3.0 and v9.5.0.

As a sanity check, the non-hint version works fine:

    #include <omp.h>
    int main() {
        omp_lock_t lock;
        omp_init_lock(&lock);
    }

These results are consistent with the observation that all of the init...lock
versions ({with and without hints} x {with and without nesting}) are declared
in omp.h, while only the versions without hints are defined in
gcc/libgomp/lock.c

omp_init_lock_with_hint() and omp_init_nest_lock_with_hint() are part of the
OpenMP 4.5 spec (Nov 2015), which is documented as being fully supported since
gcc v6.

The expedient solution of course would be to define in gcc/libgomp/lock.c the
two init...with_hint functions to ignore the hint and call their corresponding
unhinted init functions, e.g:

    void omp_init_lock_with_hint(omp_lock_t *lock, omp_sync_hint_t)
    {
        omp_init_lock(lock);
    }

    void omp_init_nest_lock_with_hint(omp_nest_lock_t *lock, omp_sync_hint_t)
    {
        omp_init_nest_lock(lock);
    }

Combined with the appropriate alias magic in the various
gcc/libgomp/config/*/lock.c files.

It would be particularly impressive to actually use the hints to make the locks
faster, but that's a larger project which probably deserves its own Bugz
entry...

             reply	other threads:[~2023-04-08 20:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-08 20:34 grg-webvisible+gcc.gnu.org at ai dot mit.edu [this message]
2024-05-30 21:24 ` [Bug libgomp/109452] " burnus at gcc dot gnu.org
2024-06-03 22:25 ` reachrajesh747 at gmail dot com
2024-06-06 14:50 ` burnus at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109452-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).