public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/43706]  New: scheduling two threads on one core leads to starvation
@ 2010-04-09 16:22 baeuml at kit dot edu
  2010-04-09 16:22 ` [Bug libgomp/43706] " baeuml at kit dot edu
                   ` (23 more replies)
  0 siblings, 24 replies; 32+ messages in thread
From: baeuml at kit dot edu @ 2010-04-09 16:22 UTC (permalink / raw)
  To: gcc-bugs

The following code results in starvation if at least two OpenMP threads are
assigned to one core.

#include <cstdio>

int main()
{
    while (true) {
        #pragma omp parallel for
        for (int ii = 0; ii < 1000; ++ii) {
            int s = ii;
        }
        printf(".");
    }

    return 0;
}

Compiled with
> g++ -fopenmp -save-temps -o test test.cpp

and ran with
> GOMP_CPU_AFFINITY="0 1 2" ./test

on a quad-core (Q9550) system results in veeery slow progress.


However,
> GOMP_CPU_AFFINITY="0 1 2 3" ./test
runs as expected.

This happens also, if cpu affinity is not explicitly given, but some of the
cores are busy with other processes. In this case it also helps to explicitly
assign each thread to one core with GOMP_CPU_AFFINITY="0 1 2 3".

> gcc -v
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.4
--enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/
--with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap
--with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --program-suffix=-4.4
--enable-linux-futex --without-system-libunwind --with-arch-32=i586
--with-tune=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.4.1 [gcc-4_4-branch revision 150839] (SUSE Linux)


-- 
           Summary: scheduling two threads on one core leads to starvation
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: baeuml at kit dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43706


^ permalink raw reply	[flat|nested] 32+ messages in thread
[parent not found: <bug-43706-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2012-01-12 20:34 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-09 16:22 [Bug libgomp/43706] New: scheduling two threads on one core leads to starvation baeuml at kit dot edu
2010-04-09 16:22 ` [Bug libgomp/43706] " baeuml at kit dot edu
2010-04-09 18:34 ` pinskia at gcc dot gnu dot org
2010-04-09 20:55 ` baeuml at kit dot edu
2010-04-09 22:11 ` mika dot fischer at kit dot edu
2010-04-20 10:23 ` jakub at gcc dot gnu dot org
2010-04-20 10:49 ` jakub at gcc dot gnu dot org
2010-04-20 12:23 ` mika dot fischer at kit dot edu
2010-04-20 15:38 ` jakub at gcc dot gnu dot org
2010-04-21 14:01 ` jakub at gcc dot gnu dot org
2010-04-21 14:01 ` jakub at gcc dot gnu dot org
2010-04-21 14:06 ` jakub at gcc dot gnu dot org
2010-04-21 14:07 ` jakub at gcc dot gnu dot org
2010-04-21 14:23 ` mika dot fischer at kit dot edu
2010-04-23 14:17 ` singler at kit dot edu
2010-04-30  8:53 ` jakub at gcc dot gnu dot org
2010-07-02  1:39 ` solar-gcc at openwall dot com
2010-07-30 14:00 ` johnfb at mail dot utexas dot edu
2010-08-13 15:48 ` singler at kit dot edu
2010-08-24 11:07 ` solar-gcc at openwall dot com
2010-08-24 11:41 ` jakub at gcc dot gnu dot org
2010-08-24 12:18 ` solar-gcc at openwall dot com
2010-08-30  8:41 ` singler at kit dot edu
2010-09-01 16:38 ` jakub at gcc dot gnu dot org
2010-09-05 11:37 ` solar-gcc at openwall dot com
     [not found] <bug-43706-4@http.gcc.gnu.org/bugzilla/>
2010-11-09 16:33 ` solar-gcc at openwall dot com
2010-11-12  8:21 ` singler at kit dot edu
2010-11-12 11:44 ` solar-gcc at openwall dot com
2010-11-15  9:14 ` singler at kit dot edu
2010-12-02 14:31 ` jakub at gcc dot gnu.org
2010-12-16 13:03 ` rguenth at gcc dot gnu.org
2012-01-12 20:34 ` pinskia at gcc dot gnu.org

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).