Note that there are some explanatory texts on larger screens.

plurals
  1. POgfortran openmp no threading
    primarykey
    data
    text
    <p>I have a simple Fortran code, and despite the use of the <code>omp_set_num_threads()</code> subroutine, I cannot set number of threads, i.e. the output says that I use only 1 thread. I tried also with the <code>export OMP_NUM_THREADS=4</code> - no result. </p> <p>I have no idea what is wrong it that pice of code:</p> <pre><code> program test use omp_lib implicit none integer :: i, tnr,t call omp_set_num_threads( 4 ) t = omp_get_num_threads() write(*,*)'t:',t !$omp parallel !$omp do do i = 1, 20 tnr = omp_get_thread_num() write( *, * ) 'Thread', tnr, ':', i end do !$omp end do !$omp end parallel end program test </code></pre> <p>The output of that code is:</p> <pre><code> t: 1 Thread 0 : 1 Thread 0 : 2 Thread 0 : 3 Thread 0 : 4 Thread 0 : 5 Thread 0 : 6 Thread 0 : 7 Thread 0 : 8 Thread 0 : 9 Thread 0 : 10 Thread 0 : 11 Thread 0 : 12 Thread 0 : 13 Thread 0 : 14 Thread 0 : 15 Thread 0 : 16 Thread 0 : 17 Thread 0 : 18 Thread 0 : 19 Thread 0 : 20 </code></pre> <p>Thanks for any kind of tip!</p> <p>I use gentoo linux, the gcc-4.5.4 compiler has the <code>openmp</code> flag activated. The cpu is mobile core i7 2nd generation.</p> <p>ldd test:</p> <pre><code> linux-vdso.so.1 (0x00007fff85fce000) libgfortran.so.3 =&gt; /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/libgfortran.so.3 (0x00007fe310460000) libm.so.6 =&gt; /lib64/libm.so.6 (0x00007fe310169000) libgomp.so.1 =&gt; /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/libgomp.so.1 (0x00007fe30ff5b000) libgcc_s.so.1 =&gt; /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/libgcc_s.so.1 (0x00007fe30fd45000) libpthread.so.0 =&gt; /lib64/libpthread.so.0 (0x00007fe30fb28000) libc.so.6 =&gt; /lib64/libc.so.6 (0x00007fe30f77d000) librt.so.1 =&gt; /lib64/librt.so.1 (0x00007fe30f574000) /lib64/ld-linux-x86-64.so.2 (0x00007fe310749000) </code></pre> <p>gfortran -v</p> <pre><code> Using built-in specs. COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.4/gfortran COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.4/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.5.4/work/gcc-4.5.4/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.4 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.4 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.4/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.4/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --disable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.4/python --enable-checking=release --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with- bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.4 p1.0, pie-0.4.7' Thread model: posix gcc version 4.5.4 (Gentoo 4.5.4 p1.0, pie-0.4.7) </code></pre> <p>output of a testmp.f140t.optimized (the one before the *.statistics):</p> <pre><code>;; Function test (MAIN__) test () { struct __st_parameter_dt dt_parm.1; logical(kind=4) D.1545; struct __st_parameter_dt dt_parm.0; integer(kind=4) tnr; integer(kind=4) t; integer(kind=4) i; integer(kind=4) i.8; integer(kind=4) i.7; integer(kind=4) i.6; integer(kind=4) tnr.5; integer(kind=4) i.4; integer(kind=4) t.3; &lt;bb 2&gt;: omp_set_num_threads (&amp;C.1537); t.3_1 = omp_get_max_threads (); t = t.3_1; dt_parm.0.common.filename = &amp;"testmp.f"[1]{lb: 1 sz: 1}; dt_parm.0.common.line = 11; dt_parm.0.common.flags = 128; dt_parm.0.common.unit = 6; _gfortran_st_write (&amp;dt_parm.0); _gfortran_transfer_character (&amp;dt_parm.0, &amp;"t:"[1]{lb: 1 sz: 1}, 2); _gfortran_transfer_integer (&amp;dt_parm.0, &amp;t, 4); _gfortran_st_write_done (&amp;dt_parm.0); i = 1; i.4_2 = i; if (i.4_2 &lt;= 20) goto &lt;bb 3&gt;; else goto &lt;bb 5&gt;; &lt;bb 3&gt;: tnr.5_3 = omp_get_thread_num (); tnr = tnr.5_3; dt_parm.1.common.filename = &amp;"testmp.f"[1]{lb: 1 sz: 1}; dt_parm.1.common.line = 16; dt_parm.1.common.flags = 128; dt_parm.1.common.unit = 6; _gfortran_st_write (&amp;dt_parm.1); _gfortran_transfer_character (&amp;dt_parm.1, &amp;"Thread"[1]{lb: 1 sz: 1}, 6); _gfortran_transfer_integer (&amp;dt_parm.1, &amp;tnr, 4); _gfortran_transfer_character (&amp;dt_parm.1, &amp;":"[1]{lb: 1 sz: 1}, 1); _gfortran_transfer_integer (&amp;dt_parm.1, &amp;i, 4); _gfortran_st_write_done (&amp;dt_parm.1); i.6_4 = i; D.1545_5 = i.6_4 == 20; i.7_6 = i; i.8_7 = i.7_6 + 1; i = i.8_7; if (D.1545_5 != 0) goto &lt;bb 5&gt;; else goto &lt;bb 4&gt;; &lt;bb 4&gt;: goto &lt;bb 3&gt;; &lt;bb 5&gt;: return; } ;; Function main (main) main (integer(kind=4) argc, character(kind=1) * * argv) { static integer(kind=4) options.2[8] = {68, 255, 0, 0, 0, 1, 0, 1}; integer(kind=4) D.1552; &lt;bb 2&gt;: _gfortran_set_args (argc_1(D), argv_2(D)); _gfortran_set_options (8, &amp;options.2[0]); test (); D.1552_3 = 0; return D.1552_3; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload