<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated on Sun, 08 Nov 2009 14:16:46 -0800 -->
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <atom:link href="http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/feed" rel="self" type="application/rss+xml" />
    <title>Intel Software Network - <![CDATA[ OpenMP issue: a threadprivate pointer doen&#39;t work when it has the dimension attribute ]]> feed</title>
    <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <div style="margin:0px;"></div>
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.<br />I would appreciate any help with my problem,<br />Thanks<br /> ]]></description>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Tue, 03 Mar 2009 00:02:12 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <div style="margin: 0px; height: auto;"></div>
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.<br />
<pre name="code" class="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     |       |       |</pre>
<pre name="code" class="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     |       |       |
</pre>
<br /> ]]></description>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Tue, 03 Mar 2009 06:38:19 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <div style="margin:0px;"></div>
<br />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>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Tue, 03 Mar 2009 07:41:11 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <div style="margin:0px;"></div>
<br />Try something like this:<br />
<pre name="code" class="cpp">program test   
  use mod_test, only: check   
  implicit none   
  integer,dimenstion(:), pointer,save :: p=&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  </pre>
<br />Jim Dempsey<br /> ]]></description>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Tue, 03 Mar 2009 11:24:49 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <strong>Quoting - tim18:</strong><br />"...I don't know how the result of this code could be predicted..."<br /><br />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.<br /><br /><br /><strong>Quoting - Kevin Davis (Intel):</strong><br />"...I will inquire with the developers and update the thread when I know more"<br /><br />Thanks!<br /><br /><strong>Quoting - jimdempseyatthecove:</strong><br />"Try something like this:<br />...<br />!$omp parallel  <br />nullify(p) ! shouldn't be required, used for work-around  <br />!$omp end parallel<br />..."<br /><br />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.<br /><br /><br /> ]]></description>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Wed, 04 Mar 2009 01:02:56 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <div style="margin:0px;"></div>
<br />OK - Plan B<br /><br />Create a user defined type for holding thread private data.<br /><br />Inside this type place the pointer to allocatable array<br /><br />Create an instance of the defined type for holding thread private data as thread private<br />  OR<br />Create a pointer to an instance of the defined type for holding thread private data as thread private (and allocate in each thread).<br /><br />I have a Windows based Fortran program that does the latter so I know this works<br /><br />Jim Dempsey<br /> ]]></description>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Wed, 04 Mar 2009 08:29:04 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <div style="margin:0px;">
<div id="quote_reply" style="width: 100%; margin-top: 5px;">
<div style="margin-left:2px;margin-right:2px;">Quoting - <a href="/en-us/profile/233849">ymost</a></div>
<div style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"><em><strong>Quoting - tim18:</strong><br />"...I don't know how the result of this code could be predicted..."<br /><br />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.<br /><br /></em></div>
</div>
</div>
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.<br /> ]]></description>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Wed, 04 Mar 2009 10:23:47 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <div style="margin:0px;">
<div id="quote_reply" style="margin-top: 5px; width: 100%;">
<div style="margin-left:2px;margin-right:2px;">Quoting - <a href="/en-us/profile/367365">tim18</a></div>
<div style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"><em>
<div style="margin:0px;"></div>
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.<br /></em></div>
</div>
</div>
<br />??<br /><br />When you call a subroutine scalar variables are on stack (automatic vectors are on stack or descriptor on stack and data from heap)<br /><br />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.<br /><br />That I think you understand.<br /><br />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).<br /><br />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.<br /><br />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.<br /><br />Thread initialization of the thread private data area can be done once early in the program.<br />Caution, should you use nested parallel regions care must be taken for initialization of those threads private data as well.<br /><br />ThreadPrivate is a compiler directive not a runtime directive.<br />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.<br /><br />Experiment with thread private data as it can really help improve performance in areas where you want large thread scratch data arrays (too large for stack).<br /><br />Jim Dempsey<br /> ]]></description>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Wed, 04 Mar 2009 15:37:19 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <div style="margin:0px;">
<div id="quote_reply" style="width: 100%; margin-top: 5px;">
<div style="margin-left:2px;margin-right:2px;">Quoting - <a href="/en-us/profile/99850">jimdempseyatthecove</a></div>
<div style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"><em> <br />OK - Plan B<br /><br />Create a user defined type for holding thread private data.<br /><br />Inside this type place the pointer to allocatable array<br /><br />Create an instance of the defined type for holding thread private data as thread private<br /> OR<br />Create a pointer to an instance of the defined type for holding thread private data as thread private (and allocate in each thread).<br /><br />I have a Windows based Fortran program that does the latter so I know this works<br /><br />Jim Dempsey<br /></em></div>
</div>
</div>
<br />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.<br />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.<br />Thanks a lot!<br /> <br /><span class="QuickWiki">Press <strong class="QuickWiki">ENTER</strong> to look up in Wiktionary or <strong class="QuickWiki">CTRL+ENTER</strong> to look up in Wikipedia</span><br /><input id="QuickWikiInput" type="text" style="margin: 5px 0px 0px; width: 415px;" class="QuickWiki" /> ]]></description>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Wed, 04 Mar 2009 23:37:28 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
    <item>
      <title>Re: OpenMP issue: a threadprivate pointer doen&amp;#39;t work when it has the dimension attribute</title>
      <description><![CDATA[ <div style="margin: 0px;">
<div id="quote_reply" style="width: 100%; margin-top: 5px;">
<div style="margin-left:2px;margin-right:2px;">Quoting - <a href="/en-us/profile/367365">tim18</a></div>
<div style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"><em> 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.<br /></em></div>
</div>
</div>
<br />A threadprivate directive can <strong>only</strong> be used outside a parallel region. Quoting section 2.9.2 from the <a title="OpenMP specification" href="http://www.openmp.org/mp-documents/spec30.pdf" target="_blank">OpenMP specification</a>, page 84, line 34:<br />
<pre name="code" class="plain">The threadprivate directive must appear in the declaration section of a scoping unit in which the common block or variable is declared.</pre>
The declaration section can never be in a parallel region. The threadprivate directive changes the status of the variable for <strong>all </strong>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>
      <link>http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</link>
      <pubDate>Wed, 04 Mar 2009 23:56:53 -0800</pubDate>
      <guid isPermaLink="true">http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/64009/</guid>
      <category>ISN General</category>
    </item>
  </channel></rss>