Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29390 ディスカッション

Local Data in Pure Subroutines

mattsdad
ビギナー
1,164件の閲覧回数

Will the local data inFortran's pure subroutines ever "cross wires" due to parallel read-modify-write in different threads?

0 件の賞賛
7 返答(返信)
Steven_L_Intel1
従業員
1,164件の閲覧回数

If you're using /parallel or OpenMP that is coded properly, there should not be a problem. Pure routines really aren't anything special in this regard.

mattsdad
ビギナー
1,164件の閲覧回数

Yes, I have an OMP PARALLEL DO loop. The loop index is used to specify a different element of an array. Only that specific element is passed into the pure subroutine. So all the affected data from outside the pure subroutine is preperly segreated by thread.

The real question is - does the locally declared data in the called subroutine need to have OMP directives to prevent interaction between threads?

Steven_L_Intel1
従業員
1,164件の閲覧回数
By default,. all variables are "automatic" (stack allocated) when OpenMP is used. So unless you did something that woild force static allocation (SAVE or initialization), nothing should need to be done.
mattsdad
ビギナー
1,164件の閲覧回数
Does the POINTER attribute cause a variable to be STATIC when there is no initialization?
Steven_L_Intel1
従業員
1,164件の閲覧回数
No.
mattsdad
ビギナー
1,164件の閲覧回数
Does theTARGET attribute cause a variable to be STATIC when there is no initialization?
Steven_L_Intel1
従業員
1,164件の閲覧回数
No. The only thing that forces static allocation for local variables is the SAVE attribute, either explicit or implicit. The only way you get SAVE implicitly is with initialization.
返信