<?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 &amp;gt;&amp;gt;It is my understanding that in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Pointers-defined-in-modules-and-OpenMP/m-p/943220#M5080</link>
    <description>&lt;P&gt;&amp;gt;&amp;gt;It is my understanding&amp;nbsp;that p_mt is global in scope, and therefore should not be accessed from within a parallel loop. If I declare Loop as pure;&lt;/P&gt;

&lt;P&gt;It should not be modified without the cooperation of the other threads (e.g. with barrier or such).&lt;/P&gt;

&lt;P&gt;Trying to interpret your sketch, the corrective measure would be to place a pointer inside your subroutine&lt;/P&gt;

&lt;P&gt;[fortran]&lt;/P&gt;

&lt;P&gt;subroutine Loop&lt;BR /&gt;
	&amp;nbsp; use X&lt;BR /&gt;
	&amp;nbsp; type (mytype), pointer :: p_mt_local&lt;BR /&gt;
	&amp;nbsp; p_mt_local&amp;nbsp; =&amp;gt; GoGetOne()&lt;BR /&gt;
	&amp;nbsp; p_mt_local % x = 7.0&lt;BR /&gt;
	&amp;nbsp; ...&lt;BR /&gt;
	[/fortran]&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
    <pubDate>Sat, 21 Dec 2013 13:18:26 GMT</pubDate>
    <dc:creator>jimdempseyatthecove</dc:creator>
    <dc:date>2013-12-21T13:18:26Z</dc:date>
    <item>
      <title>Pointers defined in modules and OpenMP</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Pointers-defined-in-modules-and-OpenMP/m-p/943219#M5079</link>
      <description>&lt;P&gt;I am working with&amp;nbsp;a program (which I did not write) which has a pointer to a derived type in a module;&lt;/P&gt;

&lt;P&gt;[fortran]module X&lt;/P&gt;

&lt;P&gt;type mytype&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; integer x, y, z&lt;/P&gt;

&lt;P&gt;end type mytype&lt;/P&gt;

&lt;P&gt;type (mytype), pointer :: p_mt&lt;/P&gt;

&lt;P&gt;end module X [/fortran]&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;This module is accessed in a subroutine;&lt;/P&gt;

&lt;P&gt;[fortran]subroutine Loop&lt;/P&gt;

&lt;P&gt;use X&lt;/P&gt;

&lt;P&gt;p_mt&amp;nbsp; =&amp;gt; GoGetOne()&lt;/P&gt;

&lt;P&gt;p_mt % x = 7.0&lt;/P&gt;

&lt;P&gt;...[/fortran]&lt;/P&gt;

&lt;P&gt;So far, so good. However, subroutine Loop is accessed from with a parallel loop in another subroutine;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;[fortran]subroutine CallLoop()&lt;/P&gt;

&lt;P&gt;integer i&lt;/P&gt;

&lt;P&gt;!$OMP parallel do&lt;/P&gt;

&lt;P&gt;do i = 1 to 10000&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call Loop(i)&lt;/P&gt;

&lt;P&gt;enddo[/fortran]&lt;/P&gt;

&lt;P&gt;It is my understanding&amp;nbsp;that p_mt is global in scope, and therefore should not be accessed from within a parallel loop. If I declare Loop as pure;&lt;/P&gt;

&lt;P&gt;[fortran]pure subroutine Loop()[/fortran]&lt;/P&gt;

&lt;P&gt;the compiler flags the assignment of a value to&amp;nbsp;p_mt as an error.&lt;/P&gt;

&lt;P&gt;Am I missing something? Or is this a potential bug?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2013 16:35:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Pointers-defined-in-modules-and-OpenMP/m-p/943219#M5079</guid>
      <dc:creator>Jerome_B_Intel</dc:creator>
      <dc:date>2013-12-20T16:35:20Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;It is my understanding that</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Pointers-defined-in-modules-and-OpenMP/m-p/943220#M5080</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;It is my understanding&amp;nbsp;that p_mt is global in scope, and therefore should not be accessed from within a parallel loop. If I declare Loop as pure;&lt;/P&gt;

&lt;P&gt;It should not be modified without the cooperation of the other threads (e.g. with barrier or such).&lt;/P&gt;

&lt;P&gt;Trying to interpret your sketch, the corrective measure would be to place a pointer inside your subroutine&lt;/P&gt;

&lt;P&gt;[fortran]&lt;/P&gt;

&lt;P&gt;subroutine Loop&lt;BR /&gt;
	&amp;nbsp; use X&lt;BR /&gt;
	&amp;nbsp; type (mytype), pointer :: p_mt_local&lt;BR /&gt;
	&amp;nbsp; p_mt_local&amp;nbsp; =&amp;gt; GoGetOne()&lt;BR /&gt;
	&amp;nbsp; p_mt_local % x = 7.0&lt;BR /&gt;
	&amp;nbsp; ...&lt;BR /&gt;
	[/fortran]&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2013 13:18:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Pointers-defined-in-modules-and-OpenMP/m-p/943220#M5080</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2013-12-21T13:18:26Z</dc:date>
    </item>
    <item>
      <title>You Dec 26</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Pointers-defined-in-modules-and-OpenMP/m-p/943221#M5081</link>
      <description>&lt;DIV class="privatemsg-message-column"&gt;
	&lt;DIV class="privatemsg-message-information"&gt;&lt;SPAN class="privatemsg-author-name"&gt;&lt;STRONG&gt;&lt;FONT size="2"&gt;You&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN class="privatemsg-message-date"&gt;&lt;FONT color="#777777" size="2"&gt;Dec 26&lt;/FONT&gt;&lt;/SPAN&gt;

		&lt;UL class="privatemsg-message-actions links inline"&gt;
			&lt;LI&gt;&lt;A href="http://software.intel.com/en-us/messages/delete/20028/20028"&gt;Delete&lt;/A&gt;&lt;/LI&gt;
		&lt;/UL&gt;
	&lt;/DIV&gt;

	&lt;DIV class="privatemsg-message-body"&gt;
		&lt;P&gt;Jim,&lt;/P&gt;

		&lt;P&gt;&amp;nbsp;&lt;/P&gt;

		&lt;P&gt;&amp;nbsp;&amp;nbsp; Your understanding agrees with mine, as does your proposed solution. My problem is that I must first convince the owners of the code that it is broken, before they will agree to a fix. For various reasons, it will not do to fix it unilaterally myself.&lt;/P&gt;

		&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; The obvious solution is to put in some code to&amp;nbsp;catch a race condition, where one thread modifies the pointer while another is using it. I have tried very hard to do that, without success, which leads me to wonder whether I am overlooking something. For example, perhaps OpenMP is making a private copy of the pointer, as it would do for a parallelized loop variable. It sounds like you are not aware of any such feature.&lt;/P&gt;

		&lt;P&gt;&amp;nbsp; Are you aware of any document that deals with this case specifically? If not, what documents lead to your conclusion that the pointer is global in scope?&lt;/P&gt;

		&lt;P&gt;&amp;nbsp;&lt;/P&gt;

		&lt;P&gt;&amp;nbsp;&lt;/P&gt;

		&lt;SECTION class="field field-name-field-forum-topic field-type-node-reference field-label-above"&gt;
			&lt;H2 class="field-label"&gt;Forum Topic:&lt;/H2&gt;

			&lt;DIV class="field-items"&gt;
				&lt;DIV class="field-item even"&gt;&lt;A href="http://software.intel.com/en-us/forums/topic/497699"&gt;Pointers defined in modules and OpenMP&lt;/A&gt;&lt;/DIV&gt;
			&lt;/DIV&gt;
		&lt;/SECTION&gt;
	&lt;/DIV&gt;
&lt;/DIV&gt;

&lt;DIV class="clearfix"&gt;&amp;nbsp;&lt;/DIV&gt;

&lt;P&gt;&lt;A name="privatemsg-mid-20029"&gt;&lt;/A&gt;&lt;/P&gt;

&lt;DIV class="privatemsg-message privatemsg-message-2 privatemsg-message-odd privatemsg-message-last" id="privatemsg-mid-20029"&gt;
	&lt;DIV class="privatemsg-author-avatar"&gt;
		&lt;DIV class="user-picture"&gt;&lt;A href="http://software.intel.com/en-us/user/100158" title="View user profile."&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.intel.com/skins/images/7B13F55A7CE623EF42E69096FA81A3A1/2021_redesign/images/image_not_found.png" /&gt;&lt;/span&gt;&lt;/A&gt;&lt;/DIV&gt;
	&lt;/DIV&gt;

	&lt;DIV class="privatemsg-message-column"&gt;
		&lt;DIV class="privatemsg-message-information"&gt;&lt;SPAN class="privatemsg-author-name"&gt;&lt;A about="/en-us/user/100158" class="username" datatype="" href="http://software.intel.com/en-us/user/100158" property="foaf:name" title="View user profile." typeof="sioc:UserAccount" lang=""&gt;&lt;STRONG&gt;&lt;FONT size="2"&gt;jimdempseyatthecove&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class="privatemsg-message-date"&gt;&lt;FONT color="#777777" size="2"&gt;16:46&lt;/FONT&gt;&lt;/SPAN&gt;

			&lt;UL class="privatemsg-message-actions links inline"&gt;
				&lt;LI&gt;&lt;A href="http://software.intel.com/en-us/messages/delete/20028/20029"&gt;Delete&lt;/A&gt;&lt;/LI&gt;
			&lt;/UL&gt;
		&lt;/DIV&gt;

		&lt;DIV class="privatemsg-message-body"&gt;
			&lt;P&gt;The problem is not technically a race condition.&lt;/P&gt;

			&lt;P&gt;Rather it is a case of using code that is suitable for single threaded use, yet unsuitable for multi-threaded use. The fact that the code works fine in single threaded mode does not assure the same code is multi-threaded safe. In this case it is not multi-thread safe.&lt;/P&gt;

			&lt;P&gt;To the owners of the code: Either affect changes to make the code multi-thread safe, or keep to a single thread model.&lt;/P&gt;

			&lt;P&gt;By the way, the "GoGetOne()" has to be thread safe as well.&lt;/P&gt;

			&lt;P&gt;&amp;gt;&amp;gt;perhaps OpenMP is making a private copy of the pointer&lt;/P&gt;

			&lt;P&gt;Not possible in your original sketch code. You call a subroutine that USEs the module p_mt.&lt;/P&gt;

			&lt;P&gt;You could make the pointer threadprivate, however, this will not fix GoGetOne, nor will it fix other potential issues. An example is the subroutine Loop is a search and you wish to terminate the search with p_mp =&amp;gt; the first found item.&lt;/P&gt;

			&lt;P&gt;This should have been posted in open forum so others can learn from the discussion.&lt;/P&gt;

			&lt;P&gt;Jim Dempsey&lt;/P&gt;

			&lt;P&gt;&amp;nbsp;&lt;/P&gt;
		&lt;/DIV&gt;
	&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 27 Dec 2013 01:04:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Pointers-defined-in-modules-and-OpenMP/m-p/943221#M5081</guid>
      <dc:creator>Jerome_B_Intel</dc:creator>
      <dc:date>2013-12-27T01:04:07Z</dc:date>
    </item>
  </channel>
</rss>

