From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26301 invoked by alias); 9 Apr 2010 16:22:05 -0000 Received: (qmail 26246 invoked by uid 48); 9 Apr 2010 16:21:42 -0000 Date: Fri, 09 Apr 2010 16:22:00 -0000 Subject: [Bug libgomp/43706] New: scheduling two threads on one core leads to starvation X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "baeuml at kit dot edu" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-04/txt/msg00952.txt.bz2 The following code results in starvation if at least two OpenMP threads are assigned to one core. #include 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