<?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 I just tried a practical in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983949#M5793</link>
    <description>&lt;P&gt;I just tried a practical example for four threads:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;PRE class="brush:fortran;"&gt;

!$OMP PARALLEL PRIVATE(k,id)

    !$OMP DO

    DO i = 1, 10

       count = i+5 

       print *,"id: ",OMP_GET_THREAD_NUM()," i    : ",i

       print *,"id: ",OMP_GET_THREAD_NUM()," count: ",count

    end do

    !$OMP END DO

    !$OMP END PARALLEL
&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Notice for the first thread 2, is 7 and the count for thread 2 should have been i+5 so 12 but the output is 14.&lt;/SPAN&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;PRE class="brush:cpp;"&gt;
Output:
 id:            2  i    :            7
 id:            1  i    :            4
 id:            0  i    :            1
 id:            3  i    :            9
 id:            2  count:           14
 id:            1  count:           13
 id:            0  count:           10
 id:            3  count:            7
 id:            2  i    :            8
 id:            1  i    :            5
 id:            0  i    :            2
 id:            3  i    :           10
 id:            2  count:           15
 id:            1  count:           15
 id:            0  count:           11
 id:            3  count:            8
 id:            1  i    :            6
 id:            0  i    :            3
 id:            1  count:            8
 id:            0  count:            8&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
	Ajay&lt;/P&gt;</description>
    <pubDate>Wed, 12 Feb 2014 22:35:00 GMT</pubDate>
    <dc:creator>Ajay_N_</dc:creator>
    <dc:date>2014-02-12T22:35:00Z</dc:date>
    <item>
      <title>Effeciently parallelizing the code in fortran</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983945#M5789</link>
      <description>&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;Hi,&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;I am trying to parallelize a certain section of my code which is written in fortran. The code snippet looks as below:&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color: rgb(96, 96, 96);"&gt;do i=1,array(K)&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;j = K&lt;BR /&gt;
	... if conditions on K...&lt;BR /&gt;
	....write and reads on j...&lt;BR /&gt;
	... do lot of things ...&lt;BR /&gt;
	K = K+1&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;So I tried to parallelize using the below code.. which was obviously not as it should have been&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;!$OMP PARALLEL DO PRIVATE(j)&lt;BR /&gt;
	do i=1,50&lt;BR /&gt;
	j = K&lt;BR /&gt;
	... if conditions on K...&lt;BR /&gt;
	....write and reads on j...&lt;BR /&gt;
	... do lot of things ...&lt;BR /&gt;
	K = K+1&lt;BR /&gt;
	!$OMP END PARALLEL DO&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color: rgb(96, 96, 96);"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;The obvious mistake being, all the threads race to the same K. What would be the best way to ensure every thread gets assigned an incremental K and the threads run in parallel.&lt;/P&gt;

&lt;P style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;Thanks&lt;BR /&gt;
	Ajay&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2014 17:57:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983945#M5789</guid>
      <dc:creator>Ajay_N_</dc:creator>
      <dc:date>2014-02-12T17:57:26Z</dc:date>
    </item>
    <item>
      <title>If work on K=1 is not</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983946#M5790</link>
      <description>&lt;P&gt;If work on K=1 is not dependent on the results of K=0, and work on K=2 is not dependent on the results of K=1, etc., then you should just express a mapping between the value of i and the value of j, rather than using the shared counter K.&lt;/P&gt;

&lt;P&gt;However, if you must start processing K=0 before you can start processing K=1, and must start K=1 before you can start K=2, etc., then you should look into the ORDERED clause of OMP DO:&amp;nbsp;http://software.intel.com/en-us/node/466858&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2014 19:04:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983946#M5790</guid>
      <dc:creator>Andrey_Vladimirov</dc:creator>
      <dc:date>2014-02-12T19:04:07Z</dc:date>
    </item>
    <item>
      <title>Thanks Andrev,</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983947#M5791</link>
      <description>&lt;P&gt;Thanks Andrev,&lt;BR /&gt;
	&lt;BR /&gt;
	I was able to map j to values of i. Now I face a slightly different problem pertaining to openMP i think.&lt;BR /&gt;
	&lt;BR /&gt;
	&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;!$OMP PARALLEL DO PRIVATE(j)&lt;/SPAN&gt;&lt;BR style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;" /&gt;
	&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;do i=1,50&lt;BR /&gt;
	j = somefunction(i)&lt;BR /&gt;
	print thread_id, i&lt;BR /&gt;
	print thread_id, j&lt;BR /&gt;
	&lt;BR /&gt;
	&lt;BR /&gt;
	When you write a openMP like above, i noticed that say j gets computer for a value of i that is spawned by the next thread. Say the function is i+7&lt;BR /&gt;
	Example&lt;BR /&gt;
	Thread 0 i: 5&lt;BR /&gt;
	Thread 0 j: 9&lt;BR /&gt;
	Thread 1 i: 2&lt;BR /&gt;
	Thread 1 j: 11&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 18px;"&gt;Any reason why this should happen ?&lt;BR /&gt;
	&lt;BR /&gt;
	Thanks&lt;BR /&gt;
	Ajay&lt;/SPAN&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2014 21:16:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983947#M5791</guid>
      <dc:creator>Ajay_N_</dc:creator>
      <dc:date>2014-02-12T21:16:52Z</dc:date>
    </item>
    <item>
      <title>It is hard to say without a</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983948#M5792</link>
      <description>&lt;P&gt;It is hard to say without a reproducer code. Perhaps some variables that should have been private were declared or assumed shared. Here is a code that worked for me:&lt;/P&gt;

&lt;P&gt;[fortran]&lt;/P&gt;

&lt;P&gt;program omploop&lt;/P&gt;

&lt;P&gt;&amp;nbsp; include 'omp_lib.h'&lt;/P&gt;

&lt;P&gt;&amp;nbsp; integer :: i, j, thread_id&lt;/P&gt;

&lt;P&gt;&amp;nbsp; write(*,'(3A10)') "Thread", "i", "j"&lt;/P&gt;

&lt;P&gt;!$OMP PARALLEL DO PRIVATE(i, thread_id, j)&lt;BR /&gt;
	&amp;nbsp; do i = 1, 10&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thread_id = omp_get_thread_num()&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j = i_to_j(i)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; write(*,'(3I10)') thread_id, i, j&lt;BR /&gt;
	&amp;nbsp; end do&lt;/P&gt;

&lt;P&gt;contains&lt;/P&gt;

&lt;P&gt;&amp;nbsp; pure integer function i_to_j(i)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; integer, intent(in) :: i&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; i_to_j = i + 7&lt;BR /&gt;
	&amp;nbsp; end function i_to_j&lt;/P&gt;

&lt;P&gt;end program omploop&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	[/fortran]&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Compilation and execution:&lt;/P&gt;

&lt;P&gt;[bash]&lt;/P&gt;

&lt;P&gt;ifort&amp;nbsp; -openmp omploop.f90 -o omploop&lt;/P&gt;

&lt;P&gt;./omploop&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thread&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; j&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11&lt;BR /&gt;
	...&lt;/P&gt;

&lt;P&gt;[/bash]&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2014 22:32:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983948#M5792</guid>
      <dc:creator>Andrey_Vladimirov</dc:creator>
      <dc:date>2014-02-12T22:32:29Z</dc:date>
    </item>
    <item>
      <title>I just tried a practical</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983949#M5793</link>
      <description>&lt;P&gt;I just tried a practical example for four threads:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;PRE class="brush:fortran;"&gt;

!$OMP PARALLEL PRIVATE(k,id)

    !$OMP DO

    DO i = 1, 10

       count = i+5 

       print *,"id: ",OMP_GET_THREAD_NUM()," i    : ",i

       print *,"id: ",OMP_GET_THREAD_NUM()," count: ",count

    end do

    !$OMP END DO

    !$OMP END PARALLEL
&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Notice for the first thread 2, is 7 and the count for thread 2 should have been i+5 so 12 but the output is 14.&lt;/SPAN&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;PRE class="brush:cpp;"&gt;
Output:
 id:            2  i    :            7
 id:            1  i    :            4
 id:            0  i    :            1
 id:            3  i    :            9
 id:            2  count:           14
 id:            1  count:           13
 id:            0  count:           10
 id:            3  count:            7
 id:            2  i    :            8
 id:            1  i    :            5
 id:            0  i    :            2
 id:            3  i    :           10
 id:            2  count:           15
 id:            1  count:           15
 id:            0  count:           11
 id:            3  count:            8
 id:            1  i    :            6
 id:            0  i    :            3
 id:            1  count:            8
 id:            0  count:            8&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
	Ajay&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2014 22:35:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983949#M5793</guid>
      <dc:creator>Ajay_N_</dc:creator>
      <dc:date>2014-02-12T22:35:00Z</dc:date>
    </item>
    <item>
      <title>Sorry for the formatting, for</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983950#M5794</link>
      <description>&lt;P&gt;Sorry for the formatting, for some reason the code quotes dont seem to work for me !!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2014 22:36:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983950#M5794</guid>
      <dc:creator>Ajay_N_</dc:creator>
      <dc:date>2014-02-12T22:36:37Z</dc:date>
    </item>
    <item>
      <title>Right, you need to make</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983951#M5795</link>
      <description>&lt;P&gt;Right, you need to make "count" a private varible.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2014 22:39:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983951#M5795</guid>
      <dc:creator>Andrey_Vladimirov</dc:creator>
      <dc:date>2014-02-12T22:39:22Z</dc:date>
    </item>
    <item>
      <title>Hi Andrev, </title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983952#M5796</link>
      <description>&lt;P&gt;Hi Andrev,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;A follow up question. if there are global variables that I have made private to an openMP do loop. And there is a function that is being called within the do loop which makes use of the same global variables that I have made private. Please note that I am not passing the variables in the function, global variables are accessible to all the functions.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Does the function that is being called in the do loop get the private copy of the calling loop or does it behave unexpectedly? I am not making any changes to the called function.&lt;/P&gt;

&lt;P&gt;I think I am observing ambiguity for this case and is there a way to tackle this?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;Ajay&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2014 17:24:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983952#M5796</guid>
      <dc:creator>Ajay_N_</dc:creator>
      <dc:date>2014-02-14T17:24:52Z</dc:date>
    </item>
    <item>
      <title>Pass the private copy of the</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983953#M5797</link>
      <description>&lt;P&gt;Pass the private copy of the (otherwise) global variable as an argument. Not doing so results in the called routine using the actual global variable and not the thread's copy.&lt;/P&gt;

&lt;P&gt;If the(se) global variable(s) are thread specific, as opposed to being application global, and you are using global variables as a means to reduce the number of arguments, then consider either passing a reference to a thread context (containing the collection of variables you want specific to each thread) or use threadprivate variables. Threadprivate will have least impact on code.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2014 13:44:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983953#M5797</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-02-15T13:44:43Z</dc:date>
    </item>
    <item>
      <title>Hi Jim,</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983954#M5798</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;

&lt;P&gt;Thanks for the reply, yes the arguments are not being passed lets say because it was built that way by some one ! And there are lot of functions that I will have to go and make the change. Is there a way to make the section of the parallelized code ensure that the calling function gets a private copy without me going to all functions and make the changes?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Ajay&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2014 18:20:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983954#M5798</guid>
      <dc:creator>Ajay_N_</dc:creator>
      <dc:date>2014-02-17T18:20:46Z</dc:date>
    </item>
    <item>
      <title>The only way to do this is to</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983955#M5799</link>
      <description>&lt;P&gt;The only way to do this is to declare the variables as threadprivate (global) variables. These variables have global namespace but thread local address space.&lt;/P&gt;

&lt;P&gt;module temp&lt;BR /&gt;
	real(8) :: A(3),B(3),C(3)&lt;BR /&gt;
	!$OMP THREADPRIVATE(A,B,C)&lt;BR /&gt;
	...&lt;BR /&gt;
	end module temp&lt;BR /&gt;
	...&lt;BR /&gt;
	subroutine usingTemp(X,F)&lt;BR /&gt;
	use temp&lt;BR /&gt;
	real :: X(3)&lt;BR /&gt;
	A=X ! copies X&amp;nbsp;to threadprivate A&lt;BR /&gt;
	...&lt;BR /&gt;
	end subroutine usingTemp&lt;BR /&gt;
	&lt;BR /&gt;
	subroutine foo&lt;BR /&gt;
	!$OMP PARALLEL DO&lt;BR /&gt;
	do i=1,nObjs&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; call usingTemp(Obj(i)%pos) ! pass in objects position&lt;/P&gt;

&lt;P&gt;The caveat here is the thread private variables are thread private. i.e. they are not global singularities, they are global multiplicities.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2014 22:39:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983955#M5799</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-02-17T22:39:41Z</dc:date>
    </item>
    <item>
      <title>Hi Jim,</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983956#M5800</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;

&lt;P&gt;Thanks for your example, but my case is probably a little different.&amp;nbsp;&lt;BR /&gt;
	gloabl header file header.f90&lt;BR /&gt;
	integer :: X;&lt;BR /&gt;
	&lt;BR /&gt;
	Main function:&lt;BR /&gt;
	do i=1,n:&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; call subroutine(i)&lt;BR /&gt;
	end do&lt;BR /&gt;
	&lt;BR /&gt;
	function subroutine:&lt;BR /&gt;
	X = some function on (i)&lt;BR /&gt;
	&lt;BR /&gt;
	Now the issue is I want X to have a private copy when called within an openmp thread:&lt;BR /&gt;
	&lt;BR /&gt;
	!$OMP PARALLEL DO (private X)&lt;/P&gt;

&lt;P&gt;only ensures X is private within the do loop but not on the called functions. The moment a function is called from the openMP &amp;nbsp;thread, the function accesses the global variable.&amp;nbsp;&lt;BR /&gt;
	I know passing the variables solves this issue, but I am trying to parallelize an already existing code which is very huge and looking for a quick workaround if possible !&lt;BR /&gt;
	&lt;BR /&gt;
	Thanks&lt;BR /&gt;
	Ajay&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2014 21:20:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983956#M5800</guid>
      <dc:creator>Ajay_N_</dc:creator>
      <dc:date>2014-03-05T21:20:31Z</dc:date>
    </item>
    <item>
      <title>If you make X treadprivate,</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983957#M5801</link>
      <description>&lt;P&gt;If you make X treadprivate, as outlined earlier, each thread, including the main thread, will have a global variable X that is private to that thread. When the X's are truly independent then there will be no issue.&amp;nbsp;The only issue you may have is that you may be required to reduce the multiple instances of X&amp;nbsp;into a preferred choice for use by the thread outside the region. An example of this could be constructed out of finding the minimum X in an array (using the threadprivate global X's).&lt;/P&gt;

&lt;P&gt;gloabl header file header.f90&lt;BR /&gt;
	integer :: X;&lt;BR /&gt;
	!$OMP THREADPRIVATE(X)&lt;BR /&gt;
	----&lt;BR /&gt;
	integer :: Xcopy ! in source with main function&lt;/P&gt;

&lt;P&gt;Main function:&lt;BR /&gt;
	Xcopy = 999999 ! some value on the other side of the solution HUGE(X)&lt;BR /&gt;
	!$OMP PARALLEL&lt;BR /&gt;
	!$OMP DO&lt;BR /&gt;
	do i=1,n:&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; call subroutine(i)&lt;BR /&gt;
	end do&lt;BR /&gt;
	!$OMP CRITICAL ! or !$OMP ATOMIC for newer version of OpenMP&amp;nbsp;&lt;BR /&gt;
	if(X&amp;nbsp;.lt. Xcopy) Xcopy = X&lt;BR /&gt;
	!$OMP END CRITICAL&lt;BR /&gt;
	!$OMP END PARALLEL&lt;BR /&gt;
	X = Xcopy&lt;/P&gt;

&lt;P&gt;function subroutine:&lt;BR /&gt;
	X = some function on (I) ! X is threadprivate&lt;/P&gt;

&lt;P&gt;Note, newer versions of OpenMP may have a MIN and MAX reduction operator&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2014 13:53:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983957#M5801</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2014-03-06T13:53:09Z</dc:date>
    </item>
    <item>
      <title>Thank you so much !! I did</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983958#M5802</link>
      <description>&lt;P&gt;Thank you so much !! I did not think threadprivate and private are different until now. I thought both were same !! Will experiment with this a bit more.&lt;/P&gt;

&lt;P&gt;Thank you again.&lt;BR /&gt;
	Ajay&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2014 16:55:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Effeciently-parallelizing-the-code-in-fortran/m-p/983958#M5802</guid>
      <dc:creator>Ajay_N_</dc:creator>
      <dc:date>2014-03-07T16:55:01Z</dc:date>
    </item>
  </channel>
</rss>

