Topic: OpenMP in Simply Fortran

Hi Jeff,

    I'm learning OpenMP to parallel my project, mainly in large loops. I've learnt some basics of it and it seems straightforward. But I got problems.

   So here's what my code looks like (simplified):

   

 integer:: nz=1000,nb=1000,i,j
             real(8):: a(nz,nb),b(nz,nb) 

             !$OMP PARALLEL DO 
              
                 do j=1,nb
                     do i=1,nz
                        a(i,j)=b(i,j)^2+b(i,j)
                    end do 
                 end do 

              !$OMP END PRALLEL DO 

     With -fopenmp flag under project-fortran compiler, I get the following errors:
     

 D:\SkyDrive\CIES 1995-2007\simulate_fortran/./valuef_prOct4.f90:171: undefined reference to `GOMP_parallel_start'
D:\SkyDrive\CIES 1995-2007\simulate_fortran/./valuef_prOct4.f90:171: undefined reference to `GOMP_parallel_end'
D:\SkyDrive\CIES 1995-2007\simulate_fortran/./valuef_prOct4.f90:216: undefined reference to `GOMP_parallel_start'
D:\SkyDrive\CIES 1995-2007\simulate_fortran/./valuef_prOct4.f90:216: undefined reference to `GOMP_parallel_end'
build\valuef_prOct4.o:D:\SkyDrive\CIES 1995-2007\simulate_fortran/./valuef_prOct4.f90:171: undefined reference to `omp_get_num_threads'
build\valuef_prOct4.o:D:\SkyDrive\CIES 1995-2007\simulate_fortran/./valuef_prOct4.f90:171: undefined reference to `omp_get_thread_num'
build\valuef_prOct4.o:D:\SkyDrive\CIES 1995-2007\simulate_fortran/./valuef_prOct4.f90:216: undefined reference to `omp_get_num_threads'
build\valuef_prOct4.o:D:\SkyDrive\CIES 1995-2007\simulate_fortran/./valuef_prOct4.f90:216: undefined reference to `omp_get_thread_num'
collect2.exe: error: ld returned 1 exit status
Error(E42): Last command making (Project.exe) returned a bad status
Error(E02): Make execution terminated 

    It seems I need to specify number of threads? But this example neither specifies that. What could be wrong? Thanks a lot!

Best,
Wenya

2 (edited by wwang328 2015-10-06 17:20:38)

Re: OpenMP in Simply Fortran

Hi Jeff,

    I think I didn't put the -fopenmp flag in Linker. After having the flag, my test code of this example works. But my original code stopped working with the warning sign from Windows (PS: the code runs smoothly without paralleling)

   

 Project.exe has stopped working. A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available 

   This sounds sophisticated. Is it relate to the fact I'm in Win 10? Thanks a lot!

Best,
Wenya

Re: OpenMP in Simply Fortran

There is currently a known problem with Simply Fortran's OpenMP in Windows 10, which you can read about here.  Hopefully you're seeing this same problem, and it is related to initializing the pthreads library. The next version of Simply Fortran, currently in testing, eliminates the pthreads library entirely.

Jeff Armstrong
Approximatrix, LLC

4 (edited by wwang328 2015-10-07 17:48:42)

Re: OpenMP in Simply Fortran

Hi Jeff,

    Thanks for your thoughts, and that sounds something might happen along the way. However, what iā€˜m seeing might be related to the stack size limit issue, since the code can be compiled and ran if I reduce dimension of array to a large extent. Unfortunately, my project involves large array dimension in nature...

    Although I'm not familiar with computer science, I guess the stack size is memory alike. Google suggests to change the stack size of additional threads (other than the main thread) through

 GOMP_stacksize 

environment variable . How would one change that in SF under windows system? Most examples on the Internet either applies to C, or to Linux system and sounds elusive...

    Thanks a lot again for your input! I'm really benefiting greatly from this forum!

Wenya