From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14653 invoked by alias); 15 Oct 2014 23:15:13 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 14640 invoked by uid 89); 15 Oct 2014 23:15:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f170.google.com Received: from mail-ig0-f170.google.com (HELO mail-ig0-f170.google.com) (209.85.213.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 15 Oct 2014 23:15:10 +0000 Received: by mail-ig0-f170.google.com with SMTP id hn15so94983igb.5 for ; Wed, 15 Oct 2014 16:15:08 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.128.170 with SMTP id np10mr976496igb.42.1413414908172; Wed, 15 Oct 2014 16:15:08 -0700 (PDT) Received: by 10.50.2.69 with HTTP; Wed, 15 Oct 2014 16:15:08 -0700 (PDT) In-Reply-To: References: Date: Wed, 15 Oct 2014 23:15:00 -0000 Message-ID: Subject: Re: Compiling for single-threaded use (implicit threading support difference in 4.9.1 vs. 4.8.1) From: leon zadorin To: gcc-help Cc: Jonathan Wakely , Johan Alfredsson Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00094.txt.bz2 On Wed, Oct 15, 2014 at 10:40 PM, Marc Glisse wrote: > On Wed, 15 Oct 2014, Jonathan Wakely wrote: > >> On 14 October 2014 18:29, Johan Alfredsson wrote: >>> >>> As my application is single-threaded, I don't want to pay the >>> performance penalty of mutexes etc. Hence, my question is if it is >>> possible to explicitly request gcc to compile my application in >>> single-threaded mode. >> >> >> It should happen automatically, there's no way to request it because >> there should be no need. > > > Well, I would quite like a compilation flag -fI-promise-not-to-use-threads, > that would automatically turn atomics into plain variables with regular > operations, turn TLS into regular memory, remove locks, etc, and perform all > the optimizations this enables. It isn't quite the same as a runtime test > that only skips a few mutexes in the library. Yeah, that would be awesome :) I would love to get a feel for how gcc is currently poised with respect to devoting development resources towards retaining single-thread optimizations based of command-line switches... I guess with limited resources (developers' time et. al.) this may need to be seen in perspective... although, personally, I would love to see aggressive single-thread optimizations wherever possible (e.g. programmer setting a "green light" switch for single-threaded assumptions, even on c++{11,14} code with assumptions that it doesn't use any of the "multi-threaded" features of the language) :) :) :) As far as I know of this stuff, the non-gcc llvm/clang has just introduced -mthread-model=single to clang (and -thread-model=single with -loweratomic being available to "opt" bitcode optimizer previously already for quite some time)... however, at this time, mostly appears to be implemented for ARM-based architectures... but this is taking me outside the GCC context...