OpenMP C programs deadlock immediately after starting when OMP_NUM_THREADS is > 1. For example, the following simple code just hangs:
#include <stdio.h> main() { int i; #pragma omp parallel for private(i) for (i = 0; i < 100; i++) printf("Thread = %d.\n", omp_get_thread_num()); } This occurs on MacOS X 10.4.5 with gcc version: Using built-in specs. Target: powerpc-apple-darwin8.4.0 Configured with: /opt/local/var/db/dports/build/_opt_local_var_db_dports_sources_rsync.rsync.darwinports.org_dpupdate_dports_lang_gcc42/work/gcc-4.2-20060204/configure --prefix=/opt/local --enable-languages=c,c++,java,objc,fortran --libdir=/opt/local/lib/gcc42 --includedir=/opt/local/include/gcc42 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-dp-4.2 --with-gxx-include-dir=/opt/local/include/gcc42/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --disable-multilib Thread model: posix gcc version 4.2.0 20060204 (experimental) Also it appears that when -fopenmp switch is used, gcc does not automatically include -lgomp but this has to be done by hand. -- Summary: OpenMP program deadlocks when executed Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: eloranta at jyu dot fi http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26456