Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
公告
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

A warning when i used omp language

Pemg-Yu_C_
初學者
8,838 檢視

Dear all:

Recently, i try to use openmp language through the Intel Visual Fortran.

Because i am a beginner of the parallel computing, i decided to make the do-loops faster by using multiprocessor.

I read a lot of information about the openmp, but had this warning when compiling.

warning #10247: explicit static allocation of locals specified, overriding OpenMP*'s implicit auto allocation

I really don't know where the problem is. 

If there are any suggestion, please help me.

Thank you very much

--------------------------------part of my program------------------------------------------------

!$omp parallel do default(shared) private(k,d_epsc,cgmci,Eta1)
       do k = 1,nsteel(i)       !the half of the section
            d_epsc=dd_defN(m)-zz_steel(k,i)*dd_defMy(m)+
     +      yy_steel(k,i)*dd_defMz(m)

            
          call FrontSteel(i,Fiber,Fbmat,d_epsc,cgmci,k,m,nsm,
     +           Eta1,time,repet,kfc,istep,nskip,secfail,ff_change)

!        computing axial force and bending moment of each fiber of the section 
        f11(k) = cgmci*aa_steel(k,i)
        fmy(k) = -cgmci*zz_steel(k,i)*aa_steel(k,i)
          fmz(k) = cgmci*yy_steel(k,i)*aa_steel(k,i)
 !        summation of axial force and bending moment of all fibers of the section 
        ss_sum11 = ss_sum11 + f11(k)
        ss_sum21 = ss_sum21 + fmy(k)
        ss_sum31 = ss_sum31 + fmz(k)

          f11(k)=0.
          fmy(k)=0.
        fmz(k)=0.
          d_epsc=0.


          end do      
      !$omp end parallel do

-----------------------------------------------------------------------------------------------------------------------

 

0 積分
1 解決方案
jimdempseyatthecove
榮譽貢獻者 III
8,805 檢視

I am guessing you are not using IMPLICIT NONE, if not, please add that to the top of your subroutine (then fix the declarations).

A second issue you have is the summations are going to have data races

!$omp parallel do default(shared) private(k,d_epsc,cgmci,Eta1) reduction(+:ss_sum11, ss_sum21, ss_sum31)

The reduction clause for operator +, provides for a private copy of the named variables, each zeroed, for use within the parallel region. On exit from the parallel region the operator + is performed in a thread safe manner to the shared variable in the scope outside the parallel region.

Jim Dempsey

在原始文章中檢視解決方案

30 回應
jimdempseyatthecove
榮譽貢獻者 III
8,806 檢視

I am guessing you are not using IMPLICIT NONE, if not, please add that to the top of your subroutine (then fix the declarations).

A second issue you have is the summations are going to have data races

!$omp parallel do default(shared) private(k,d_epsc,cgmci,Eta1) reduction(+:ss_sum11, ss_sum21, ss_sum31)

The reduction clause for operator +, provides for a private copy of the named variables, each zeroed, for use within the parallel region. On exit from the parallel region the operator + is performed in a thread safe manner to the shared variable in the scope outside the parallel region.

Jim Dempsey

Mark_Lewy
傑出貢獻者 I
6,578 檢視

I suspect you have explicitly set the /Qsave (Fortran->Data->Local Variable Storage = All Variables SAVE) compiler option.

The warning is output because /Oopenmp implies /Qauto (Local Variable Storage = Local Variables AUTOMATIC).

Pemg-Yu_C_
初學者
6,578 檢視

Dear Mr. Jim Dempsey

Thank you very much. Actually, i use IMPLICIT REAL*8 not the IMPLICIT NONE like you mentioned. I'll fix it immediately.

As about the data races condition, i am afraid that i didn't notice this problem. Once again, thank you very much.

I'll follow your suggestion to modify my program.

Pemg-Yu Chen 

Pemg-Yu_C_
初學者
6,578 檢視

Dear Mr.Mark Lewy

Thank you very much. Just like you mentioned, i used  the /Qsave (Fortran->Data->Local Variable Storage = All Variables SAVE) compiler option.

After change to the Local Variables AUTOMATIC , there is no any warning.

Thank you very much.

Pemg-Yu Chen

Pemg-Yu_C_
初學者
6,578 檢視

Dear all

I have another problem when i try to assign the number of threads.

I used "CALL omp_set_num_threads(4)" before the parallel region.

I also used the "USE omp_lib" at the head of my program.

There is an error message. 

error LNK2019: unresolved external symbol omp_set_num_threads referenced in function_Main

please give me some suggestion.

Thank you very much

Mark_Lewy
傑出貢獻者 I
6,578 檢視

Check if you have /Qopenmp (Fortran->Language->Process OpenMP Directives = Generate Parallel Code) set for the build configuration that produces LNK2019.  For example, if you set /Qopenmp for the Debug configuration only, you will also need to set it for the Release configuration (or use the All Configurations option for Configuration to set options that apply to all configurations).

Pemg-Yu_C_
初學者
6,578 檢視

Dear Mr. Mark Lewy

Yes, i already use the All Configurations option to set Fortran->Language->Process OpenMP Directives = Generate Parallel Code.

However, i still have the error message.

Pemg-Yu Chen

Mark_Lewy
傑出貢獻者 I
6,578 檢視

I think we would have to see what your project settings are.  Can you show us the command line settings for Fortran and Linker you are using?

Pemg-Yu_C_
初學者
6,578 檢視

Dear Mr. Mark Lewy

Here are the command line settings for fortran:

/nologo /debug:full /Od /Qsave /iface:cvf /module:"Debug/" /object:"Debug/" /Fd"Debug\vc100.pdb" /traceback /check:bounds /libs:static /threads /dbglibs /c

and the command line settings for linker:

/OUT:"Debug/20100619_n_15_3D_10_CYW6.exe" /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"C:\Users\SAM\Desktop\Parallel(origion)\Debug\20100619_n_15_3D_10_CYW6.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"Debug/20100619_n_15_3D_10_CYW6.pdb" /STACK:100000000,100000000 kernel32.lib

Thank you very much

Mark_Lewy
傑出貢獻者 I
6,578 檢視

I can't see /Qopenmp in your Fortran settings.  It looks like you switched OpenMP off to remove the warning about the clash with /Qsave which means the OpenMP library doesn't get pulled in when you link, hence the unresolved symbol.

Pemg-Yu_C_
初學者
6,578 檢視

Dear Mr. Mark Lewy

I set again the Fortran->Language->Process OpenMP Directives = Generate Parallel Code, but it still has the error message.

Here are the command line settings for fortran:

/nologo /debug:full /Od /Qopenmp /Qsave /iface:cvf /module:"Debug/" /object:"Debug/" /Fd"Debug\vc100.pdb" /traceback /check:bounds /libs:static /threads /dbglibs /c

and the command line settings for linker:

/OUT:"Debug/20100619_n_15_3D_10_CYW6.exe" /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"C:\Users\SAM\Desktop\Parallel(origion)\Debug\20100619_n_15_3D_10_CYW6.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"Debug/20100619_n_15_3D_10_CYW6.pdb" /STACK:100000000,100000000 kernel32.lib

Thank you very much

Lorri_M_Intel
員工
6,578 檢視

Is your call to omp_set_num_threads in the MAIN program, or in a subroutine called by the MAIN program?

The "use omp_lib" statement needs to be in the same program unit that is making the call to omp_set_num_threads.  It is not enough to put it in the MAIN program when a different subroutine is making the call.

Also, if you could show the exact error message that might be helpful too.   I was able to reproduce a failure when I removed the "use omp_lib" statement from my tiny program, but the error message was this one:

error LNK2019: unresolved external symbol _OMP_SET_NUM_THREADS@4 referenced in function _MAIN__
 

               --Lorri

 

jimdempseyatthecove
榮譽貢獻者 III
6,578 檢視

Write a simple program, see if it works, then look at what is different or same.

program foo
  use omp_lib
  implicit none
!$omp parallel
  write(*,*) omp_get_thread_num()
!$omp end parallel
call omp_set_num_threads(4)
!$omp parallel
  write(*,*) omp_get_thread_num()
!$omp end parallel
end program foo

Jim Dempsey

Pemg-Yu_C_
初學者
6,578 檢視

Dear Miss Lorri Menard

Yes, I call the omp_set_num_threads in  a subroutine called by the MAIN program, and i only put "USE OMP_LIB" in the main program.

After following your suggestion to put the "USE OMP_LIB" in the subroutine, there is no any error message.

Thank you very much

Pemg-Yu Chen

Pemg-Yu_C_
初學者
6,578 檢視

Dear Mr.Jim Dempsey

Yes, i wrote the program that you suggested, it did work.

There is no any error message after following the suggestion of Miss Lorri Menard.

Thank you very much.

Pemg-Yu Chen

Pemg-Yu_C_
初學者
6,578 檢視

Dear all

Thank your suggestions. There is no any error message while compiling.

However, when i start to debug, there is something wrong.

"program exception - stack overflow"

Pemg-Yu Chen

TimP
榮譽貢獻者 III
6,578 檢視

I'll assume you resolved the reduction bug which Jim pointed out.

Growth of stack usage is a frequent aspect of parallelization, even when you set a reasonable value for OMP_NUM_THREADS.  By default, if HyperThreading is detected, the number of threads will be set to 2 per core, even though that is likely to be excessive (unless your only goal is to max out the meter graph).  Note Jim's advice to start with a reasonable value.

Requirement to set the stack limit (by /link /stack: option or by editbin) is not surprising.

If you are using 32-bit mode, OMP_STACK_SIZE is preset to 2MB (4MB in 64-bit mode).  That's the local stack per thread.  Evidently, there are more limitations in parallel scaling in 32-bit mode.

Pemg-Yu_C_
初學者
6,578 檢視

Dear all:

Thank for your suggestions. I tried to modify my program by following Mr.Jim and Mr.Tim Prince.

However, I still had some problem.

If i didn't define the Stack Size, it will show the error "Stack Overflow".

If I defined a big number as the stack size, it still can't run.

I can't explain the problem exactly, so i updated some picture and the subroutine.

Thank you very much for your suggestions.

Pemg-Yu Chen

 

 

TimP
榮譽貢獻者 III
6,578 檢視

I get a corrupted file for the source code.  Perhaps there are unusual character sets.

Pemg-Yu_C_
初學者
6,347 檢視

Dear Mr. Tim Prince

The code is just the subroutine of my program, i use the notepad to save the code.

I save the code again through the fortran.

Thank you very much.

Pemg-Yu Chen

回覆