On 4/21/21 10:16 PM, Jakub Jelinek wrote:
> On Wed, Apr 21, 2021 at 08:53:54PM +0100, Jonathan Wakely wrote:
>>>> What would be IMHO a good idea would be to use configure test for
>>>> #include <thread>
>>>> int t = std::thread::hardware_concurrency ();
>>>> and in that case use that as a fallback to the previous implementation,
>>>> that will be strictly an improvement.
>>>
>>> That does not make sense to me. Original motivation was removal of the 
>>> complicated
>>> implementation with a C++ standard function.
> 
> The reason it is larger and more complicated is that it answers a different
> question than std::thread::hardware_concurrency().
> hardware_concurrency() says how many threads the hw has available, if we
> wanted just that, you could just keep the sysconf call.
> The current implementation answers the question how many threads can this
> process and its children be scheduled on.
> Consider some NUMA box with hundreds of threads, but where it might
> be desirable to keep specific compilations limited to some cores and do
> other compilations or whatever else on other cores.
> 
> Sure, hardware_concurrency() answer is better than no information about the
> concurrency at all.  But I don't really see the costs of the current
> implementation, it is < 100 lines of code that have been written once and
> it is unlikely they will need changing - at this point the interfaces are
> fairly stable, haven't been changed on the glibc side for years.  It is true
> that when it was introduced in glibc, there have been 2 big changes to it
> soon.

All right, I understand that hardware_concurrency doesn't match exactly our 
needs.
Thus I'm going to install the following patch that removes the FIXME.

Thanks for help with that,
Martin

> 
>       Jakub
> 

>From dbe87a4229126829e0a912e9928c82b8dde7b51c Mon Sep 17 00:00:00 2001
From: Martin Liska <mli...@suse.cz>
Date: Thu, 22 Apr 2021 09:14:28 +0200
Subject: [PATCH] Remove not feasible FIXME

gcc/ChangeLog:

	* lto-wrapper.c: Remove FIXME about usage of
	hardware_concurrency. The function is not on par with
	what we have now.
---
 gcc/lto-wrapper.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 0b626d7c811..49894e4fc61 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1304,8 +1304,6 @@ init_num_threads (void)
 #endif
 }
 
-/* FIXME: once using -std=c++11, we can use std::thread::hardware_concurrency.  */
-
 /* Test and return reason why a jobserver cannot be detected.  */
 
 static const char *
-- 
2.31.1

Reply via email to