<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: OpenMP issue: a threadprivate pointer doen't work when it h in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753452#M9181</link>
    <description>&lt;BR /&gt;I submitted this to the compiler team earlier; they are investigating now. Our internal tracking id is: CQ# DPD200118527. I will keep the thread updated as I learn more.</description>
    <pubDate>Thu, 05 Mar 2009 15:08:36 GMT</pubDate>
    <dc:creator>Kevin_D_Intel</dc:creator>
    <dc:date>2009-03-05T15:08:36Z</dc:date>
    <item>
      <title>OpenMP issue: a threadprivate pointer doen't work when it has the dimension attribute</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753440#M9169</link>
      <description>Hi,&lt;BR /&gt;I have a problem using OpenMP with the ifort compiler version 11.0.&lt;BR /&gt;Consider the following test program:&lt;BR /&gt;
&lt;PRE&gt;[plain]program test
  use mod_test, only: check
  implicit none
  integer,pointer,save :: p=&amp;gt;null()
  !$omp threadprivate(p)
  !$omp parallel
  allocate(p)
  call check(p)
  !$omp end parallel
end program test[/plain]&lt;/PRE&gt;
The program uses this module:&lt;BR /&gt;
&lt;PRE&gt;[plain]module mod_test
  implicit none
contains
  subroutine check(num)
    integer,pointer :: num
    if (associated(num)) write (*,*) 'associated'
  end subroutine check
end module mod_test[/plain]&lt;/PRE&gt;
On a 4-cpu machine this program prints the word 'associated' 4 times, as predicted.&lt;BR /&gt;If, however, the pointer p is given the 'dimension' attribute, only the first thread that executes the parallel region works as anticipated. In the last three threads the condition is evaluated as false. Here is the modified program that produces the error:&lt;BR /&gt;
&lt;PRE&gt;[plain]program test
  use mod_test, only: check
  implicit none
  integer,dimension(:),pointer,save :: p=&amp;gt;null()
  !$omp threadprivate(p)
  !$omp parallel
  allocate(p(1))
  call check(p)
  !$omp end parallel
end program test[/plain]&lt;/PRE&gt;
The program uses this module:&lt;BR /&gt;
&lt;PRE&gt;[plain]module mod_test
  implicit none
contains
  subroutine check(num)
    integer,dimension(:),pointer :: num
    if (associated(num)) write (*,*) 'associated'
  end subroutine check
end module mod_test[/plain]&lt;/PRE&gt;
Is this a compiler bug or what?&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 02 Mar 2009 14:25:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753440#M9169</guid>
      <dc:creator>ymost</dc:creator>
      <dc:date>2009-03-02T14:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753441#M9170</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
In my post I didn't use the 'insert cose' feature, and so the code was not very readable. I apologize - and I fixed the original post.&lt;BR /&gt;I would appreciate any help with my problem,&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Mar 2009 08:02:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753441#M9170</guid>
      <dc:creator>ymost</dc:creator>
      <dc:date>2009-03-03T08:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753442#M9171</link>
      <description>&lt;DIV style="margin: 0px; height: auto;"&gt;&lt;/DIV&gt;
As no one else has bitten, I'll say that I don't know how the result of this code could be predicted. Do you mean, is it a compiler bug that it doesn't give more diagnostics? OpenMP is notorious for not checking at compile time. That's one of the reasons for the Intel Thread Checker.&lt;BR /&gt;
&lt;PRE&gt;[cpp]|1 |I/O      |Error |1 |omp     |I/O operation at "ym2.f90":4 |"ym2.f9|"ym2.f9|
|  |data-race|      |  |parallel|conflicts with a prior I/O   |0":4   |0":4   |
|  |         |      |  |region  |operation at "ym2.f90":4     |       |       |[/cpp]&lt;/PRE&gt;
&lt;PRE&gt;[cpp]|1 |I/O      |Error |1 |omp     |I/O operation at "ym1.f90":4 |"ym1.f9|"ym1.f9|
|  |data-race|      |  |parallel|conflicts with a prior I/O   |0":4   |0":4   |
|  |         |      |  |region  |operation at "ym1.f90":4     |       |       |
[/cpp]&lt;/PRE&gt;
&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Mar 2009 14:27:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753442#M9171</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2009-03-03T14:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753443#M9172</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;I have been looking at this too.The OpenMP spec specifies special handling related to POINTER and ALLOCATABLE only when certain conditions do not hold, but I believe the second case should see the array pointer as associated by all threads the same as all threads see the pointer as associated in the first case. I will inquire with the developers and update the thread when I know more.</description>
      <pubDate>Tue, 03 Mar 2009 15:41:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753443#M9172</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2009-03-03T15:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753444#M9173</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;Try something like this:&lt;BR /&gt;
&lt;PRE&gt;[cpp]program test   
  use mod_test, only: check   
  implicit none   
  integer,dimenstion(:), pointer,save :: p=&amp;gt;null()   
  !$omp threadprivate(p)
  ! Above is in variable declarations of program test
  ! ...
  ! initialization portion of program test
  !$omp parallel
  nullify(p) ! shouldn't be required, used for work-around
  !$omp end parallel
  ! ...
  ! compute section of program test   
  !$omp parallel   
  allocate(p(1))   
  call check(p)   
  !$omp end parallel   
end program test  [/cpp]&lt;/PRE&gt;
&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Mar 2009 19:24:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753444#M9173</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2009-03-03T19:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753445#M9174</link>
      <description>&lt;STRONG&gt;Quoting - tim18:&lt;/STRONG&gt;&lt;BR /&gt;"...I don't know how the result of this code could be predicted..."&lt;BR /&gt;&lt;BR /&gt;To me it seems clear: there are 4 copies of the pointer p, one for each thread. Each one is being allocated and then tested for association, and it should always be associated.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Quoting - Kevin Davis (Intel):&lt;/STRONG&gt;&lt;BR /&gt;"...I will inquire with the developers and update the thread when I know more"&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Quoting - jimdempseyatthecove:&lt;/STRONG&gt;&lt;BR /&gt;"Try something like this:&lt;BR /&gt;...&lt;BR /&gt;!$omp parallel  &lt;BR /&gt;nullify(p) ! shouldn't be required, used for work-around  &lt;BR /&gt;!$omp end parallel&lt;BR /&gt;..."&lt;BR /&gt;&lt;BR /&gt;Thank you for your suggestion, it is true that in many occasions nullifying a pointer before using it can solve problems later on. Unfortunately, in this case this does not make any difference.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Mar 2009 09:02:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753445#M9174</guid>
      <dc:creator>ymost</dc:creator>
      <dc:date>2009-03-04T09:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753446#M9175</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;OK - Plan B&lt;BR /&gt;&lt;BR /&gt;Create a user defined type for holding thread private data.&lt;BR /&gt;&lt;BR /&gt;Inside this type place the pointer to allocatable array&lt;BR /&gt;&lt;BR /&gt;Create an instance of the defined type for holding thread private data as thread private&lt;BR /&gt; OR&lt;BR /&gt;Create a pointer to aninstance of the defined type for holding thread private data as thread private (and allocate in each thread).&lt;BR /&gt;&lt;BR /&gt;I have a Windows based Fortran program that does the latter so I know this works&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Mar 2009 16:29:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753446#M9175</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2009-03-04T16:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753447#M9176</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/233849"&gt;ymost&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;&lt;STRONG&gt;Quoting - tim18:&lt;/STRONG&gt;&lt;BR /&gt;"...I don't know how the result of this code could be predicted..."&lt;BR /&gt;&lt;BR /&gt;To me it seems clear: there are 4 copies of the pointer p, one for each thread. Each one is being allocated and then tested for association, and it should always be associated.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
I've not found any reference to tell what a threadprivate directive outside a parallel region would do . It's not clear to me that it would take effect in the next, or all following, parallel regions.  Your intention may be clearer to you than to me or to the compiler.  I thought maybe your idea was the compiler should tell you what (if anything) is wrong with the source code. That's why I suggested attention to the race condition diagnosed by Thread Checker.&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Mar 2009 18:23:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753447#M9176</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2009-03-04T18:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753448#M9177</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/367365"&gt;tim18&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
I've not found any reference to tell what a threadprivate directive outside a parallel region would do . It's not clear to me that it would take effect in the next, or all following, parallel regions.  Your intention may be clearer to you than to me or to the compiler.  I thought maybe your idea was the compiler should tell you what (if anything) is wrong with the source code. That's why I suggested attention to the race condition diagnosed by Thread Checker.&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;??&lt;BR /&gt;&lt;BR /&gt;When you call a subroutine scalar variables are on stack (automatic vectors are on stack or descriptor on stack and data from heap)&lt;BR /&gt;&lt;BR /&gt;If this subroutine is called from a parallel region, each thread having its own stack will thus have a private copy of those stack variables while all using the same symbolic name.&lt;BR /&gt;&lt;BR /&gt;That I think you understand.&lt;BR /&gt;&lt;BR /&gt;Now wouldn't it be nice if each thread in a multi-threaded program could have a thread private data items that share the same name in all threads but in fact reference different data (same as stack model). You may want to place temp arrays in the thread private area or some sort of context information (e.g. pointer to some object owned by the thread).&lt;BR /&gt;&lt;BR /&gt;This thread private area is independent of entering or exiting !$OMP PARALLEL regions excepting for when the !$OMP PARALLEL region creates additional thread(s). When a thread is created, it gets a copy of the current state of the master threads thread private data.&lt;BR /&gt;&lt;BR /&gt;Care must be taken as a copy of the thread private data from the master thread may contain allocated arrays. It may not be polite for the 2nd thread or later thread to deallocate or disturb this array if the array was intended to be a private copy for the master thread. To help get around that consider using a pointer to the array which you can NULLIFY and/or allocate.&lt;BR /&gt;&lt;BR /&gt;Thread initialization of the thread private data area can be done once early in the program.&lt;BR /&gt;Caution, should you use nested parallel regions care must be taken for initialization of those threads private data as well.&lt;BR /&gt;&lt;BR /&gt;ThreadPrivate is a compiler directive not a runtime directive.&lt;BR /&gt;Symbols marked with threadprivate have a little more overhead in access. The runtime system maintains a pointer to the thread private data area. The compiler auto-magicly inserts an additional dereference via this pointer for thread private data.&lt;BR /&gt;&lt;BR /&gt;Experiment with thread private data as it can really help improve performance in areas where you want largethread scratch data arrays (too large for stack).&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Mar 2009 23:37:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753448#M9177</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2009-03-04T23:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753449#M9178</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/99850"&gt;jimdempseyatthecove&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; &lt;BR /&gt;OK - Plan B&lt;BR /&gt;&lt;BR /&gt;Create a user defined type for holding thread private data.&lt;BR /&gt;&lt;BR /&gt;Inside this type place the pointer to allocatable array&lt;BR /&gt;&lt;BR /&gt;Create an instance of the defined type for holding thread private data as thread private&lt;BR /&gt; OR&lt;BR /&gt;Create a pointer to aninstance of the defined type for holding thread private data as thread private (and allocate in each thread).&lt;BR /&gt;&lt;BR /&gt;I have a Windows based Fortran program that does the latter so I know this works&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;Great idea, and it worked! I used the first option you offered, since I didn't want to risk using a threadprivate pointer again. This way I get a de-facto threadprivate pointer without the risk, and that's great.&lt;BR /&gt;I actually conjured up my own workaround too: I added a threadprivate integer to hold the address of the pointer after it is allocated (I extracted the address using the 'loc' function), and referred to the correct address in every thread by using the 'pointer(a,b)' mechanism. I think I'll switch to your method, though, since it's more elegant than mine, and more importantly, my method is not portable since the loc function and pointer mechanism are specific to the Intel compiler.&lt;BR /&gt;Thanks a lot!&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN class="QuickWiki"&gt;Press &lt;STRONG class="QuickWiki"&gt;ENTER&lt;/STRONG&gt; to look up in Wiktionary or &lt;STRONG class="QuickWiki"&gt;CTRL+ENTER&lt;/STRONG&gt; to look up in Wikipedia&lt;/SPAN&gt;&lt;BR /&gt;&lt;INPUT id="QuickWikiInput" type="text" style="margin: 5px 0px 0px; width: 415px;" class="QuickWiki" /&gt;</description>
      <pubDate>Thu, 05 Mar 2009 07:37:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753449#M9178</guid>
      <dc:creator>ymost</dc:creator>
      <dc:date>2009-03-05T07:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753450#M9179</link>
      <description>&lt;DIV style="margin: 0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/367365"&gt;tim18&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; I've not found any reference to tell what a threadprivate directive outside a parallel region would do . It's not clear to me that it would take effect in the next, or all following, parallel regions.&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;A threadprivate directive can &lt;STRONG&gt;only&lt;/STRONG&gt; be used outside a parallel region. Quoting section 2.9.2 from the &lt;A title="OpenMP specification" href="http://www.openmp.org/mp-documents/spec30.pdf" target="_blank"&gt;OpenMP specification&lt;/A&gt;, page 84, line 34:&lt;BR /&gt;
&lt;PRE&gt;[plain]The threadprivate directive must appear in the declaration section of a scoping unit in which the common block or variable is declared.[/plain]&lt;/PRE&gt;
The declaration section can never be in a parallel region. The threadprivate directive changes the status of the variable for &lt;STRONG&gt;all &lt;/STRONG&gt;consecutive parallel regions that have the same number of threads. Notice also that the first version of the program I attached works perfectly, it is only the addition of the 'dimension' attribute that causes the error, and this is probably a compiler bug.</description>
      <pubDate>Thu, 05 Mar 2009 07:56:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753450#M9179</guid>
      <dc:creator>ymost</dc:creator>
      <dc:date>2009-03-05T07:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753451#M9180</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/233849"&gt;ymost&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin: 0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;A threadprivate directive can &lt;STRONG&gt;only&lt;/STRONG&gt; be used outside a parallel region. Quoting section 2.9.2 from the &lt;A title="OpenMP specification" href="http://www.openmp.org/mp-documents/spec30.pdf" target="_blank"&gt;OpenMP specification&lt;/A&gt;, page 84, line 34:&lt;BR /&gt;
&lt;/EM&gt;&lt;PRE&gt;&lt;EM&gt;[plain]The threadprivate directive must appear in the declaration section of a scoping unit in which the common block or variable is declared.[/plain]&lt;/EM&gt;&lt;/PRE&gt;
The declaration section can never be in a parallel region. The threadprivate directive changes the status of the variable for &lt;STRONG&gt;all &lt;/STRONG&gt;consecutive parallel regions that have the same number of threads. Notice also that the first version of the program I attached works perfectly, it is only the addition of the 'dimension' attribute that causes the error, and this is probably a compiler bug.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
Now that you mention it, Intel Fortran does have different rules about placement of threadprivate directives than some other compilers. This definitely annoys customers, but I think it is on account of those other compilers not following the specification about threadprivate following the last COMMON. If you can show that this is in violation of the standard, it would be a good subject for a problem report. However, I can't agree with you about no declarations in parallel regions. How would you have any subroutine calls in parallel regions under your proposed restriction? How would you implement the requirement of the specification that the threadprivate appear in each compilation unit, where applicable? Maybe you didn't mean that.&lt;BR /&gt;Your first version didn't work perfectly for me, as I showed.&lt;BR /&gt;The standard does prescribe persistence of threadprivate values between compatible parallel regions, but I don't see that it calls for threadprivate directives from outside a parallel region to apply. &lt;BR /&gt;If you would file a problem report on premier.intel.com, you should be able to get an answer from the Intel experts on OpenMP.&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Mar 2009 14:38:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753451#M9180</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2009-03-05T14:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753452#M9181</link>
      <description>&lt;BR /&gt;I submitted this to the compiler team earlier; they are investigating now. Our internal tracking id is: CQ# DPD200118527. I will keep the thread updated as I learn more.</description>
      <pubDate>Thu, 05 Mar 2009 15:08:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753452#M9181</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2009-03-05T15:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753453#M9182</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;tim18,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;However, I can't agree with you about no declarations in parallel regions.&lt;BR /&gt;&lt;BR /&gt;Thread private data is static data owned within the thread context&lt;BR /&gt;seperate from static data owned by the process&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;How would you have any subroutine calls in parallel regions under your proposed restriction?&lt;BR /&gt;&lt;BR /&gt;A subroutine may be called from within a parallel region or from sequential section.&lt;BR /&gt;A subroutine cannot be declared from within a parallel region.&lt;BR /&gt;&lt;BR /&gt;For most thread private data use the stack&lt;BR /&gt;&lt;BR /&gt;Make sure you include automatic on any arrays (vectors) as you may forget an option switch and get burned with a long debug session.&lt;BR /&gt;&lt;BR /&gt;For SAVE variables, yes, you need to declare these with threadprivate attribute.&lt;BR /&gt;&lt;BR /&gt;Note: A subroutine declared array such as&lt;BR /&gt;&lt;BR /&gt;"real :: temp(10)" may or may not be stored on the stack.&lt;BR /&gt;You CANNOT tell by looking at the source code.&lt;BR /&gt;&lt;BR /&gt;"real, automatic :: temp(10)" will be on the stack&lt;BR /&gt;or at least the array descriptor will be on the stack&lt;BR /&gt;(when all automatic arrays are heap arrays)&lt;BR /&gt;&lt;BR /&gt;"real, allocatable :: temp(:)" the array descriptor may or may not be stored on the stack.&lt;BR /&gt;You CANNOT tell by looking at the source code.&lt;BR /&gt;&lt;BR /&gt;"real, automatic, allocatable :: temp(:)" the array descriptor will be stored on the stack.&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Mar 2009 18:06:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753453#M9182</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2009-03-05T18:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753454#M9183</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/367365"&gt;tim18&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; ...However, I can't agree with you about no declarations in parallel regions. How would you have any subroutine calls in parallel regions under your proposed restriction? How would you implement the requirement of the specification that the threadprivate appear in each compilation unit, where applicable? Maybe you didn't mean that.&lt;BR /&gt;Your first version didn't work perfectly for me, as I showed.&lt;BR /&gt;The standard does prescribe persistence of threadprivate values between compatible parallel regions, but I don't see that it calls for threadprivate directives from outside a parallel region to apply. &lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;Indeed my statement was inaccurate. I should have said a threadprivate directive cannot appear inside the &lt;STRONG&gt;lexical&lt;/STRONG&gt; extent of a parallel region, i.e. it can appear in a subroutine called from a parallel region. Still, the threadprivate directive must always appear in the declaration section of any scoping unit, and it can (and often does) appear outside any parallel region at all. It is used exactly in this way in the examples given in the &lt;A title="OpenMP specification" href="http://www.openmp.org/mp-documents/spec30.pdf"&gt;OpenMP specification&lt;/A&gt; itself. Also, a quick example can show that it cannot be used inside the lexical extent of a parallel region:&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;[plain]program test&lt;BR /&gt;  implicit none&lt;BR /&gt;  integer,save :: num&lt;BR /&gt;  !$omp threadprivate(num)&lt;BR /&gt;  !$omp parallel&lt;BR /&gt;  &lt;BR /&gt;  ! --- code ---&lt;BR /&gt;&lt;BR /&gt;  !$omp end parallel&lt;BR /&gt;end program test[/plain]&lt;/PRE&gt;
&lt;BR /&gt;This code works fine, with the expected behaviour of the variable num having a separate copy for each thread. However:&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;[plain]program test&lt;BR /&gt;  implicit none&lt;BR /&gt;  integer,save :: num&lt;BR /&gt;  !$omp parallel&lt;BR /&gt;  !$omp threadprivate(num)&lt;BR /&gt;  &lt;BR /&gt;  ! --- code ---&lt;BR /&gt;&lt;BR /&gt;  !$omp end parallel&lt;BR /&gt;end program test[/plain]&lt;/PRE&gt;
&lt;BR /&gt;This code produces a compilation error: "error #6236: A specification statement cannot appear in the executable section."&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Apr 2009 08:43:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753454#M9183</guid>
      <dc:creator>ymost</dc:creator>
      <dc:date>2009-04-01T08:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753455#M9184</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;Consider the !$omp threadprivate(num) as a data declaration statement that is a band-aid for a missing Fortran keyword. i.e. Fortran should have "integer, save, threadprivate :: num" (or threadprivate could implicitly include save and "integer,threadprivate :: num" would suffice).&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Apr 2009 12:55:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753455#M9184</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2009-04-01T12:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753456#M9185</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/335337"&gt;Kevin Davis (Intel)&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;&lt;BR /&gt;I submitted this to the compiler team earlier; they are investigating now. Our internal tracking id is: CQ# DPD200118527. I will keep the thread updated as I learn more.&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;Development indicates for case 2 (pointer declaration with &lt;STRONG&gt;dimension(:)&lt;/STRONG&gt; attribute) the compiler generates incorrect accesses to the thread-private variable, p. They indicate this only manifests itself when the legacy implementation of thread-private variables is used, and that specifying compatibility mode (by using option &lt;STRONG&gt;openmp-threadprivate compat&lt;/STRONG&gt;) produces correct code.&lt;BR /&gt;&lt;BR /&gt;They still plan to fix the issue in a future release; however, offered &lt;STRONG&gt;openmp-threadprivate compat&lt;/STRONG&gt; as a work around.&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Jul 2009 19:11:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753456#M9185</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2009-07-04T19:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen't work when it h</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753457#M9186</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/335337"&gt;Kevin Davis (Intel)&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;Development indicates for case 2 (pointer declaration with &lt;STRONG&gt;dimension(:)&lt;/STRONG&gt; attribute) the compiler generates incorrect accesses to the thread-private variable, p. They indicate this only manifests itself when the legacy implementation of thread-private variables is used, and that specifying compatibility mode (by using option &lt;STRONG&gt;openmp-threadprivate compat&lt;/STRONG&gt;) produces correct code.&lt;BR /&gt;&lt;BR /&gt;They still plan to fix the issue in a future release; however, offered &lt;STRONG&gt;openmp-threadprivate compat&lt;/STRONG&gt; as a work around.&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;Thank you, the '-openmp-threadprivate compat' flag solves the problem!&lt;BR /&gt;However, it reveals another bug which is manifested in a different section of my code. I have posted it in a &lt;A href="http://software.intel.com/en-us/forums/showthread.php?t=69795"&gt;new discussion&lt;/A&gt;.&lt;BR /&gt;</description>
      <pubDate>Tue, 10 Nov 2009 13:03:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/OpenMP-issue-a-threadprivate-pointer-doen-t-work-when-it-has-the/m-p/753457#M9186</guid>
      <dc:creator>ymost</dc:creator>
      <dc:date>2009-11-10T13:03:29Z</dc:date>
    </item>
  </channel>
</rss>

