From: "H.J. Lu" <hjl.tools@gmail.com>
To: sgk@troutmask.apl.washington.edu
Cc: Lipeng Zhu via Fortran <fortran@gcc.gnu.org>,
gcc-patches@gcc.gnu.org, tianyou.li@intel.com,
pan.deng@intel.com, lipeng.zhu@intel.com
Subject: Re: [PATCH] libgfortran: Replace mutex with rwlock
Date: Tue, 27 Dec 2022 08:33:58 -0800 [thread overview]
Message-ID: <CAMe9rOoU3ooV5+UoB69WgE8NipeJSWHe52x=-H=a4cSSTaR_Xw@mail.gmail.com> (raw)
In-Reply-To: <Y6jxbjgLNHV7VB+G@troutmask.apl.washington.edu>
On Sun, Dec 25, 2022 at 4:58 PM Steve Kargl via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Wed, Dec 21, 2022 at 07:27:11PM -0500, Lipeng Zhu via Fortran wrote:
> > This patch try to introduce the rwlock and split the read/write to
> > unit_root tree and unit_cache with rwlock instead of the mutex to
> > increase CPU efficiency. In the get_gfc_unit function, the percentage
> > to step into the insert_unit function is around 30%, in most instances,
> > we can get the unit in the phase of reading the unit_cache or unit_root
> > tree. So split the read/write phase by rwlock would be an approach to
> > make it more parallel.
> >
> > BTW, the IPC metrics can increase from 0.25 to 2.2 in the Intel
> > SRP server with 220 cores. The benchmark we used is
> > https://github.com/rwesson/NEAT
> >
>
> The patch fails bootstrap on x86_64-*-freebsd.
>
> gmake[6]: Entering directory '/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/src/c++17'
> /bin/sh ../../libtool --tag CXX --tag disable-shared --mode=compile /home/kargl/gcc/obj/./gcc/xgcc -shared-libgcc -B/home/kargl/gcc/obj/./gcc -nostdinc++ -L/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/src -L/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/src/.libs -L/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/libsupc++/.libs -B/home/kargl/work/x86_64-unknown-freebsd14.0/bin/ -B/home/kargl/work/x86_64-unknown-freebsd14.0/lib/ -isystem /home/kargl/work/x86_64-unknown-freebsd14.0/include -isystem /home/kargl/work/x86_64-unknown-freebsd14.0/sys-include -fno-checking -I/home/kargl/gcc/gcc/libstdc++-v3/../libgcc -I/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/x86_64-unknown-freebsd14.0 -I/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include -I/home/kargl/gcc/gcc/libstdc++-v3/libsupc++ -std=gnu++17 -nostdinc++ -prefer-pic -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=floating_from_chars.lo -fimplicit-templates -g -O2 -c -o floating_from_chars.lo ../../../../../gcc/libstdc++-v3/src/c++17/floating_from_chars.cc
> libtool: compile: /home/kargl/gcc/obj/./gcc/xgcc -shared-libgcc -B/home/kargl/gcc/obj/./gcc -nostdinc++ -L/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/src -L/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/src/.libs -L/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/libsupc++/.libs -B/home/kargl/work/x86_64-unknown-freebsd14.0/bin/ -B/home/kargl/work/x86_64-unknown-freebsd14.0/lib/ -isystem /home/kargl/work/x86_64-unknown-freebsd14.0/include -isystem /home/kargl/work/x86_64-unknown-freebsd14.0/sys-include -fno-checking -I/home/kargl/gcc/gcc/libstdc++-v3/../libgcc -I/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/x86_64-unknown-freebsd14.0 -I/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include -I/home/kargl/gcc/gcc/libstdc++-v3/libsupc++ -std=gnu++17 -nostdinc++ -D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=floating_from_chars.lo -fimplicit-templates -g -O2 -c ../../../../../gcc/libstdc++-v3/src/c++17/floating_from_chars.cc -fPIC -DPIC -D_GLIBCXX_SHARED -o floating_from_chars.o
> In file included from /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/memory_resource:40,
> from ../../../../../gcc/libstdc++-v3/src/c++17/floating_from_chars.cc:37:
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex: In function 'int std::__glibcxx_rwlock_rdlock(pthread_rwlock**)':
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:80:3: error: call of overloaded '__gthrw_pthread_rwlock_rdlock(pthread_rwlock**&)' is ambiguous
> 80 | _GLIBCXX_GTHRW(rwlock_rdlock)
> | ^
> In file included from /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/x86_64-unknown-freebsd14.0/bits/gthr.h:148,
> from /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/bits/std_mutex.h:41,
> from /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:41:
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:80:3: note: candidate: 'int std::__gthrw_pthread_rwlock_rdlock(pthread_rwlock**)'
> 80 | _GLIBCXX_GTHRW(rwlock_rdlock)
> | ^~~~~~~~~~~~~~
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/x86_64-unknown-freebsd14.0/bits/gthr-default.h:140:1: note: candidate: 'int __gthrw_pthread_rwlock_rdlock(pthread_rwlock**)'
> 140 | __gthrw(pthread_rwlock_rdlock)
> | ^~~~~~~
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex: In function 'int std::__glibcxx_rwlock_tryrdlock(pthread_rwlock**)':
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:81:3: error: call of overloaded '__gthrw_pthread_rwlock_tryrdlock(pthread_rwlock**&)' is ambiguous
> 81 | _GLIBCXX_GTHRW(rwlock_tryrdlock)
> | ^
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:81:3: note: candidate: 'int std::__gthrw_pthread_rwlock_tryrdlock(pthread_rwlock**)'
> 81 | _GLIBCXX_GTHRW(rwlock_tryrdlock)
> | ^~~~~~~~~~~~~~
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/x86_64-unknown-freebsd14.0/bits/gthr-default.h:141:1: note: candidate: 'int __gthrw_pthread_rwlock_tryrdlock(pthread_rwlock**)'
> 141 | __gthrw(pthread_rwlock_tryrdlock)
> | ^~~~~~~
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex: In function 'int std::__glibcxx_rwlock_wrlock(pthread_rwlock**)':
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:82:3: error: call of overloaded '__gthrw_pthread_rwlock_wrlock(pthread_rwlock**&)' is ambiguous
> 82 | _GLIBCXX_GTHRW(rwlock_wrlock)
> | ^
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:82:3: note: candidate: 'int std::__gthrw_pthread_rwlock_wrlock(pthread_rwlock**)'
> 82 | _GLIBCXX_GTHRW(rwlock_wrlock)
> | ^~~~~~~~~~~~~~
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/x86_64-unknown-freebsd14.0/bits/gthr-default.h:142:1: note: candidate: 'int __gthrw_pthread_rwlock_wrlock(pthread_rwlock**)'
> 142 | __gthrw(pthread_rwlock_wrlock)
> | ^~~~~~~
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex: In function 'int std::__glibcxx_rwlock_trywrlock(pthread_rwlock**)':
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:83:3: error: call of overloaded '__gthrw_pthread_rwlock_trywrlock(pthread_rwlock**&)' is ambiguous
> 83 | _GLIBCXX_GTHRW(rwlock_trywrlock)
> | ^
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:83:3: note: candidate: 'int std::__gthrw_pthread_rwlock_trywrlock(pthread_rwlock**)'
> 83 | _GLIBCXX_GTHRW(rwlock_trywrlock)
> | ^~~~~~~~~~~~~~
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/x86_64-unknown-freebsd14.0/bits/gthr-default.h:143:1: note: candidate: 'int __gthrw_pthread_rwlock_trywrlock(pthread_rwlock**)'
> 143 | __gthrw(pthread_rwlock_trywrlock)
> | ^~~~~~~
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex: In function 'int std::__glibcxx_rwlock_unlock(pthread_rwlock**)':
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:84:3: error: call of overloaded '__gthrw_pthread_rwlock_unlock(pthread_rwlock**&)' is ambiguous
> 84 | _GLIBCXX_GTHRW(rwlock_unlock)
> | ^
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/shared_mutex:84:3: note: candidate: 'int std::__gthrw_pthread_rwlock_unlock(pthread_rwlock**)'
> 84 | _GLIBCXX_GTHRW(rwlock_unlock)
> | ^~~~~~~~~~~~~~
> /home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/include/x86_64-unknown-freebsd14.0/bits/gthr-default.h:144:1: note: candidate: 'int __gthrw_pthread_rwlock_unlock(pthread_rwlock**)'
> 144 | __gthrw(pthread_rwlock_unlock)
> | ^~~~~~~
> gmake[6]: *** [Makefile:585: floating_from_chars.lo] Error 1
> gmake[6]: Leaving directory '/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/src/c++17'
> gmake[5]: *** [Makefile:784: all-recursive] Error 1
> gmake[5]: Leaving directory '/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3/src'
> gmake[4]: *** [Makefile:576: all-recursive] Error 1
> gmake[4]: Leaving directory '/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3'
> gmake[3]: *** [Makefile:501: all] Error 2
> gmake[3]: Leaving directory '/home/kargl/gcc/obj/x86_64-unknown-freebsd14.0/libstdc++-v3'
> gmake[2]: *** [Makefile:18284: all-stage1-target-libstdc++-v3] Error 2
> gmake[2]: Leaving directory '/home/kargl/gcc/obj'
> gmake[1]: *** [Makefile:26171: stage1-bubble] Error 2
> gmake[1]: Leaving directory '/home/kargl/gcc/obj'
> gmake: *** [Makefile:26524: bootstrap] Error 2
>
> --
> steve
libstdc++ implements shared mutex with pthread_rwlock, which can conflict
with the pthread_rwlock usage in libgcc. Lipeng, please limit the
pthread_rwlock
usage in libgcc only when __cplusplus isn't defined.
--
H.J.
next prev parent reply other threads:[~2022-12-27 16:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 0:27 Lipeng Zhu
2022-12-26 0:57 ` Steve Kargl
2022-12-27 16:33 ` H.J. Lu [this message]
2022-12-28 10:00 ` Zhu, Lipeng
2022-12-22 2:19 Lipeng Zhu
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='CAMe9rOoU3ooV5+UoB69WgE8NipeJSWHe52x=-H=a4cSSTaR_Xw@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=lipeng.zhu@intel.com \
--cc=pan.deng@intel.com \
--cc=sgk@troutmask.apl.washington.edu \
--cc=tianyou.li@intel.com \
/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).