<?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 Hi, in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124979#M132597</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thanks. After adding omp_get_thread_num() the output is:&lt;/P&gt;
&lt;PRE class="brush:bash; class-name:dark;"&gt;          1        23453246234752
 @@@@@@@@@@@@@@@@@@@
           2           1        23453246234752
           4           1        23453246234752
           6           1        23453246234752
           5           1        23453246234752
           7           1        23453246234752
           3           1        23453246234752
           1           1        23453246234752
           1           1        23453246234752
           0           1        23453246234752
           0           1        23453246234752
 @@@@@@@@@@@@@@@@@@@
        23453246230720
       140733095199120
        23446830436112
        23451147206288
       140733095199120
        23440169873296
        23449050046096
        23442267033488
        23453244366352
        23453244366352
        23444615843600&lt;/PRE&gt;

&lt;P&gt;So it looks as if all 8 threads access the same array.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2019 13:03:02 GMT</pubDate>
    <dc:creator>may_ka</dc:creator>
    <dc:date>2019-07-10T13:03:02Z</dc:date>
    <item>
      <title>derived type with allocatable compoents in omp firstprivate clause ... still a bad idea?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124977#M132595</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i was chasing data race conditions in an omp environment and found that having a derived type with allocatable components the culprit. According to google there was once a problem but I wonder whether it is still virulent.&lt;/P&gt;&lt;P&gt;Here is an example code:&lt;/P&gt;
&lt;PRE class="brush:fortran; class-name:dark;"&gt;Module rrr
  Type :: aaa
    real(kind=8), allocatable :: b(:,:)
  end type aaa
contains
  Subroutine Subrrr(a)
    real(kind=8), intent(inout) :: a(:,:)
    write(*,*) loc(a)
  end Subroutine Subrrr
  Subroutine Subzzz(a)
    type(aaa), intent(inout) :: a(:)
    integer :: i
    do i=1,size(a)
      write(*,*) i,loc(a(i)%b)
    end do
  end Subroutine Subzzz
end Module rrr
Program test
  use rrr, only: subrrr, aaa, subzzz
  real(kind=8), allocatable :: x(:,:)
  integer :: i
  type(aaa), allocatable :: y(:)
  allocate(y(1))
  do i=1,size(y)
    allocate(y(i)%b(20,20),source=0.0D0)
    write(*,*) i,loc(y(i)%b)
  end do
  write(*,*) "@@@@@@@@@@@@@@@@@@@"
  !$omp parallel do firstprivate(y)
  Do i=1,10
    call subzzz(y)
  end Do
  !$omp end parallel do
  write(*,*) "@@@@@@@@@@@@@@@@@@@"
  allocate(x(20,20),source=0.0D0)
  write(*,*) loc(x)
  !$omp parallel do firstprivate(x)
  Do i=1,10
    call subrrr(x)
  end Do
  !$omp end parallel do
end Program test&lt;/PRE&gt;

&lt;P&gt;When compiled with ifort 17.08 or 19.04 and the -qopenmp flag only the ouptut is&lt;/P&gt;

&lt;PRE class="brush:bash; class-name:dark;"&gt;          1        23209329389632
 @@@@@@@@@@@@@@@@@@@
           1        23209329389632
           1        23209329389632
           1        23209329389632
           1        23209329389632
           1        23209329389632
           1        23209329389632
           1        23209329389632
           1        23209329389632
           1        23209329389632
           1        23209329389632
 @@@@@@@@@@@@@@@@@@@
        23209329385600
       140720494867472
        23194232672272
        23202940038928
        23207230320272
        23192018079760
        23200742231824
        23209327480336
        23205037198992
        23196430479248
        23198527639440&lt;/PRE&gt;

&lt;P&gt;when compiled with "gfortran -fopenmp" the output is:&lt;/P&gt;

&lt;PRE class="brush:bash; class-name:dark;"&gt;          1       94311007887248
 @@@@@@@@@@@@@@@@@@@
           1       94311007930896
           1       22394831899520
           1       22394764790656
           1       22394764791344
           1       94311007932272
           1       22394496355200
           1       22394630572928
           1       22394362137472
           1       22393422613376
           1       22394295028608
 @@@@@@@@@@@@@@@@@@@
       94311007932272
       22394831900208
       22394764791344
       22394362137472
       22394764791344
       94311007935488
       22394295028608
       22394496355200
       94311007935488
       22393422613376
       22394630572928&lt;/PRE&gt;

&lt;P&gt;So it looks as if when compiled with ifort, the array y(i)%b is not copied, where as when using gfortran it is.&lt;/P&gt;
&lt;P&gt;Any idea?&lt;/P&gt;
&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 11:27:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124977#M132595</guid>
      <dc:creator>may_ka</dc:creator>
      <dc:date>2019-07-10T11:27:12Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;So it looks as if when</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124978#M132596</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;So it looks as if when compiled with ifort, the array y(i)%b is not copied, where as when using gfortran it is&lt;/P&gt;&lt;P&gt;On line 14, add to the write , omp_get_thread_num()&lt;/P&gt;&lt;P&gt;IOW the parallel do loop might not have had chunk size of 1.&lt;/P&gt;&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 12:52:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124978#M132596</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2019-07-10T12:52:57Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124979#M132597</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thanks. After adding omp_get_thread_num() the output is:&lt;/P&gt;
&lt;PRE class="brush:bash; class-name:dark;"&gt;          1        23453246234752
 @@@@@@@@@@@@@@@@@@@
           2           1        23453246234752
           4           1        23453246234752
           6           1        23453246234752
           5           1        23453246234752
           7           1        23453246234752
           3           1        23453246234752
           1           1        23453246234752
           1           1        23453246234752
           0           1        23453246234752
           0           1        23453246234752
 @@@@@@@@@@@@@@@@@@@
        23453246230720
       140733095199120
        23446830436112
        23451147206288
       140733095199120
        23440169873296
        23449050046096
        23442267033488
        23453244366352
        23453244366352
        23444615843600&lt;/PRE&gt;

&lt;P&gt;So it looks as if all 8 threads access the same array.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 13:03:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124979#M132597</guid>
      <dc:creator>may_ka</dc:creator>
      <dc:date>2019-07-10T13:03:02Z</dc:date>
    </item>
    <item>
      <title>The workaround might be:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124980#M132598</link>
      <description>&lt;P&gt;The workaround might be:&lt;/P&gt;
&lt;PRE class="brush:fortran; class-name:dark;"&gt;Module rrr
  !$ use omp_lib
  Type :: aaa
    real(kind=8), allocatable :: b(:,:)
  end type aaa
contains
  Subroutine Subzzz(a)
    type(aaa), intent(inout) :: a(:)
    integer :: i
    do i=1,size(a)
      write(*,*) omp_get_thread_num(),i,loc(a(i)%b)
    end do
  end Subroutine Subzzz
end Module rrr
Program test
  use rrr, only: aaa, subzzz
  integer :: i
  type(aaa), allocatable :: y(:)
  write(*,*) "@@@@@@@@@@@@@@@@@@@"
  !$omp parallel private(y)
  allocate(y(1))
  Do i=1,size(y)
    allocate(y(i)%b(20,20),source=0.0D0)
  end Do
  !$omp do
  Do i=1,10
    call subzzz(y)
  end Do
  !$omp end do
  !$omp end parallel
end Program test&lt;/PRE&gt;

&lt;P&gt;with the ouput changing to&lt;/P&gt;

&lt;PRE class="brush:bash; class-name:dark;"&gt;           0           1        23439116902528
           6           1        23439116513344
           5           1        23439116382272
           0           1        23439116902528
           4           1        23439116480576
           3           1        23439116447808
           1           1        23439116415040
           1           1        23439116415040
           2           1        23439116546112
           7           1        23439116316736&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 13:08:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124980#M132598</guid>
      <dc:creator>may_ka</dc:creator>
      <dc:date>2019-07-10T13:08:53Z</dc:date>
    </item>
    <item>
      <title>FWIW, there used to be an</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124981#M132599</link>
      <description>&lt;P&gt;FWIW, there used to be an issue with earlier compilers where private(a) on an unallocated array a would not (necessarily) present an unallocated array a&amp;nbsp;inside the parallel region. The work around was to use firstprivate(a) with the unallocated array a (thus copying the unallocated array descriptor). I do not recall which version fixed this issue.&lt;/P&gt;&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 17:56:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124981#M132599</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2019-07-10T17:56:30Z</dc:date>
    </item>
    <item>
      <title>Thanks Jim.
cheers</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124982#M132600</link>
      <description>&lt;P&gt;Thanks Jim.&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 07:24:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/derived-type-with-allocatable-compoents-in-omp-firstprivate/m-p/1124982#M132600</guid>
      <dc:creator>may_ka</dc:creator>
      <dc:date>2019-07-14T07:24:04Z</dc:date>
    </item>
  </channel>
</rss>

