<?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: Improving execution speed with derived types in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841695#M59664</link>
    <description>&lt;P&gt;Try the following and report back the timings&lt;/P&gt;
&lt;P&gt;use base_database&lt;BR /&gt;!&lt;BR /&gt;implicit none&lt;BR /&gt;!&lt;BR /&gt;integer :: i, j, k, cyc&lt;BR /&gt;! vvv add&lt;BR /&gt;integer :: iCachPopulate&lt;BR /&gt;real :: start_time, end_time&lt;BR /&gt;real(kind=real_acc) :: othird&lt;BR /&gt;! vvv add replace 'typPar' with your par type&lt;BR /&gt;type(typePar), pointer :: pPar&lt;BR /&gt;!&lt;BR /&gt;othird = 1.0/3.0&lt;BR /&gt;!&lt;BR /&gt;! vvv add loop to prime the processor chache&lt;BR /&gt;! vvv on first iteration. Get timing on second iteration&lt;BR /&gt;do iCachPopulate=1,2&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; do j=1,3&lt;BR /&gt; do k=1,3&lt;BR /&gt; par(i)%sigma(k,j) = par(i)%sigma(k,j) +othird*par(i)%rho*par(i)%rod(k,j)&lt;BR /&gt; enddo&lt;BR /&gt; enddo&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;! vvv add end of processor cache prime&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;! vvv change "test" to "test 1"&lt;BR /&gt;write(*,*) 'Time elapsed for derived test 1 = ',end_time-start_time&lt;BR /&gt;!&lt;BR /&gt;! Next do above test with removing (k,j) to test&lt;BR /&gt;! implicit array computation speed&lt;BR /&gt;!&lt;BR /&gt;! vvv add loop to prime the processor chache&lt;BR /&gt;! vvv on first iteration. Get timing on second iteration&lt;BR /&gt;do iCachPopulate=1,2&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; par(i)%sigma = par(i)%sigma +othird*par(i)%rho*par(i)%rod&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;! vvv add end of processor cache prime&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;! vvv change "test" to "test 2"&lt;BR /&gt;write(*,*) 'Time elapsed for derived test 2 = ',end_time-start_time&lt;BR /&gt;!&lt;BR /&gt;! Next do above test with pointer to par&lt;BR /&gt;! implicit array computation speed&lt;BR /&gt;!&lt;BR /&gt;! vvv add loop to prime the processor chache&lt;BR /&gt;! vvv on first iteration. Get timing on second iteration&lt;BR /&gt;do iCachPopulate=1,2&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; pPar =&amp;gt; par(i)&lt;BR /&gt; pPar%sigma = pPar%sigma +othird*pPar%rho*pPar%rod&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;! vvv add end of processor cache prime&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;! vvv change "test" to "test 3"&lt;BR /&gt;write(*,*) 'Time elapsed for derived test 3 = ',end_time-start_time&lt;BR /&gt;!&lt;BR /&gt;! vvv add loop to prime the processor chache&lt;BR /&gt;! vvv on first iteration. Get timing on second iteration&lt;BR /&gt;do iCachPopulate=1,2&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; do j=1,3&lt;BR /&gt; do k=1,3&lt;BR /&gt; p_sigma(k,j,i) = p_sigma(k,j,i) + othird*p_rho(i)*p_rod(k,j,i)&lt;BR /&gt; enddo&lt;BR /&gt; enddo&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;! vvv add end of processor cache prime&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;write(*,*) 'Time elapsed for array test = ',end_time-start_time&lt;BR /&gt;!&lt;BR /&gt;End&lt;BR /&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 21 Sep 2005 23:46:38 GMT</pubDate>
    <dc:creator>jim_dempsey</dc:creator>
    <dc:date>2005-09-21T23:46:38Z</dc:date>
    <item>
      <title>Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841688#M59657</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Hi,&lt;/DIV&gt;
&lt;DIV&gt;
&lt;P&gt;&lt;SPAN&gt;I am investigating ways to improve the execution speed of a fortran90 program. This program uses a derived data type that defines for each particle all the values known at the particle.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;I have been testing ideas in a small programs, and see a significant speed difference between standard arrays (faster) and the derived type (slower) in the following routine&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt;
&lt;P&gt;&lt;B&gt;&lt;SPAN&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;use base_database
!
implicit none
!
integer :: i, j, k, cyc
real :: start_time, end_time
real(kind=real_acc) :: othird
!
othird = 1.0/3.0
!
call cpu_time(start_time)
!
do cyc=1,ncycle
 do i=istart, iend
  do j=1,3
   do k=1,3
    par(i)%sigma(k,j) = par(i)%sigma(k,j) +othird*par(i)%rho*par(i)%rod(k,j)
   enddo
  enddo
 enddo
enddo
!
call cpu_time(end_time)
!
write(*,*) 'Time elapsed for derived test = ',end_time-start_time
!
call cpu_time(start_time)
!
do cyc=1,ncycle
 do i=istart, iend
  do j=1,3
   do k=1,3
    p_sigma(k,j,i) = p_sigma(k,j,i) + othird*p_rho(i)*p_rod(k,j,i)
   enddo
  enddo
 enddo
enddo
!
call cpu_time(end_time)
!
write(*,*) 'Time elapsed for array test = ',end_time-start_time
!
End&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="Arial"&gt;Sigma and rod are 3 by 3 arrays held at each particle i. All the p_ arrays and the par data type are allocatable and all the real variables are set to double precision (real_acc). The number of particles can be large, over 100,000.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="Arial"&gt;I believe that the difference is due to the way the values are held in memory, with the derived data types being non-contiguous.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="Arial"&gt;Is there a way to speed up this type of operation and get closer to the standard array speed, while using derived data types?&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="Arial"&gt;James&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT face="Arial"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 19 Sep 2005 23:46:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841688#M59657</guid>
      <dc:creator>jcac</dc:creator>
      <dc:date>2005-09-19T23:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841689#M59658</link>
      <description>&lt;DIV&gt;F90/F95 has implicit do's for many operations on arrays&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;array = 0. ! zeros all elements in array&lt;/DIV&gt;
&lt;DIV&gt;array3 = array1 + array2 ! sums each cell.&lt;/DIV&gt;
&lt;DIV&gt;array3 = array1 + array2 * scale ! applies scale to all cells too&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Try changing&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt; do j=1,3&lt;BR /&gt; do k=1,3&lt;BR /&gt; par(i)%sigma(k,j) = par(i)%sigma(k,j) +othird*par(i)%rho*par(i)%rod(k,j)&lt;BR /&gt; enddo&lt;BR /&gt; enddo&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;to&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt; par(i)%sigma = par(i)%sigma +othird*par(i)%rho*par(i)%rod&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Please report back as to improvement if any&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Jim Dempsey&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 Sep 2005 01:31:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841689#M59658</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-09-20T01:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841690#M59659</link>
      <description>&lt;DIV&gt;Jim,&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Thank you for the suggestion. I have tried it out and it is actually slightly slower.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;The results from the program are:&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Time for derived type test: 1.703125 seconds&lt;BR /&gt;Time for modified test: 1.765265 seconds&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;For comparison the array takes 0.46875 seconds&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;These timings are for 100 cycles with 100,000 particles. The test machine is a laptop with a Pentium M 2.0GHz processor running Windows XP. I am using the version 9.0 compiler, as I am new to it I am just using the default settings for the Release version.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;James&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 Sep 2005 15:38:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841690#M59659</guid>
      <dc:creator>jcac</dc:creator>
      <dc:date>2005-09-20T15:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841691#M59660</link>
      <description>Have you checked whether the inner loops are unrolled?  If the compiler doesn't unroll as fully in the derived type case, you could check whether unrolling the source code helps.  If so, you might file a problem report.</description>
      <pubDate>Tue, 20 Sep 2005 19:12:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841691#M59660</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2005-09-20T19:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841692#M59661</link>
      <description>&lt;DIV&gt;I am not sure how to check for loop unrolling other than in the source. I have tried unrolling the inner loops, replacing&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;PRE&gt;  do j=1,3
   do k=1,3
    par(i)%sigma(k,j) = par(i)%sigma(k,j) + othird*par(i)%rho*par(i)%rod(k,j)
   enddo
  enddo&lt;/PRE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;with&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;PRE&gt;    par(i)%sigma(1,1) = par(i)%sigma(1,1) + othird*par(i)%rho*par(i)%rod(1,1)
    par(i)%sigma(2,1) = par(i)%sigma(2,1) + othird*par(i)%rho*par(i)%rod(2,1)
    par(i)%sigma(3,1) = par(i)%sigma(3,1) + othird*par(i)%rho*par(i)%rod(3,1)
    par(i)%sigma(1,2) = par(i)%sigma(1,2) + othird*par(i)%rho*par(i)%rod(1,2)
    par(i)%sigma(2,2) = par(i)%sigma(2,2) + othird*par(i)%rho*par(i)%rod(2,2)
    par(i)%sigma(3,2) = par(i)%sigma(3,2) + othird*par(i)%rho*par(i)%rod(3,2)
    par(i)%sigma(1,3) = par(i)%sigma(1,3) + othird*par(i)%rho*par(i)%rod(1,3)
    par(i)%sigma(2,3) = par(i)%sigma(2,3) + othird*par(i)%rho*par(i)%rod(2,3)
    par(i)%sigma(3,3) = par(i)%sigma(3,3) + othird*par(i)%rho*par(i)%rod(3,3)&lt;/PRE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;and the run time is identical for both cases to the accuracy of the cpu_time function, which seems to be 1/64 seconds.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;James&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 Sep 2005 21:34:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841692#M59661</guid>
      <dc:creator>jcac</dc:creator>
      <dc:date>2005-09-20T21:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841693#M59662</link>
      <description>&lt;P&gt;In addition to using array syntax try adding a pointer to your class&lt;/P&gt;
&lt;P&gt;type(YourParType), pointer :: pPar&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;do i=istart, iend&lt;/P&gt;
&lt;P&gt; pPar =&amp;gt; par(i)&lt;/P&gt;
&lt;DIV&gt; pPar%sigma = pPar%sigma +othird*pPar%rho*pPar%rod&lt;/DIV&gt;
&lt;DIV&gt;end do&lt;BR /&gt;
&lt;/DIV&gt;
&lt;DIV&gt;The compiler should have optimized out the indexing...&lt;/DIV&gt;
&lt;DIV&gt;unless you had range checking enabled&lt;/DIV&gt;
&lt;DIV&gt;Note, you may need t add "target" where you declare your &lt;PRE&gt;"par(:)"&lt;/PRE&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Jim Dempsey&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Message Edited by sblionel on &lt;SPAN class="date_text"&gt;09-20-2005&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;04:25 PM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2005 00:50:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841693#M59662</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-09-21T00:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841694#M59663</link>
      <description>&lt;P&gt;dimension p_sigma(9*imax), p_rod(9*imax), p_rho(imax)&lt;/P&gt;
&lt;P&gt;real*8 oprho&lt;/P&gt;
&lt;P&gt;integer icount, ,jcount&lt;/P&gt;
&lt;P&gt;do cyc=1,ncycle&lt;BR /&gt;icount=(istart-2)*9&lt;BR /&gt; do i=istart, iend&lt;BR /&gt; icount=icount+9&lt;BR /&gt; oprho=othird*p_rho(i)&lt;BR /&gt; do jk=1,9&lt;BR /&gt; jcount=jk+icount&lt;BR /&gt; p_sigma(jcount) = p_sigma(jcount) + oprho*p_rod(jcount)&lt;BR /&gt; enddo&lt;BR /&gt; enddo&lt;BR /&gt;enddo&lt;/P&gt;
&lt;P&gt;The heart of the loop contains one real multiply, one real add and one integer add and a single array index calculation. This should be faster.&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Sep 2005 03:00:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841694#M59663</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2005-09-21T03:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841695#M59664</link>
      <description>&lt;P&gt;Try the following and report back the timings&lt;/P&gt;
&lt;P&gt;use base_database&lt;BR /&gt;!&lt;BR /&gt;implicit none&lt;BR /&gt;!&lt;BR /&gt;integer :: i, j, k, cyc&lt;BR /&gt;! vvv add&lt;BR /&gt;integer :: iCachPopulate&lt;BR /&gt;real :: start_time, end_time&lt;BR /&gt;real(kind=real_acc) :: othird&lt;BR /&gt;! vvv add replace 'typPar' with your par type&lt;BR /&gt;type(typePar), pointer :: pPar&lt;BR /&gt;!&lt;BR /&gt;othird = 1.0/3.0&lt;BR /&gt;!&lt;BR /&gt;! vvv add loop to prime the processor chache&lt;BR /&gt;! vvv on first iteration. Get timing on second iteration&lt;BR /&gt;do iCachPopulate=1,2&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; do j=1,3&lt;BR /&gt; do k=1,3&lt;BR /&gt; par(i)%sigma(k,j) = par(i)%sigma(k,j) +othird*par(i)%rho*par(i)%rod(k,j)&lt;BR /&gt; enddo&lt;BR /&gt; enddo&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;! vvv add end of processor cache prime&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;! vvv change "test" to "test 1"&lt;BR /&gt;write(*,*) 'Time elapsed for derived test 1 = ',end_time-start_time&lt;BR /&gt;!&lt;BR /&gt;! Next do above test with removing (k,j) to test&lt;BR /&gt;! implicit array computation speed&lt;BR /&gt;!&lt;BR /&gt;! vvv add loop to prime the processor chache&lt;BR /&gt;! vvv on first iteration. Get timing on second iteration&lt;BR /&gt;do iCachPopulate=1,2&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; par(i)%sigma = par(i)%sigma +othird*par(i)%rho*par(i)%rod&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;! vvv add end of processor cache prime&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;! vvv change "test" to "test 2"&lt;BR /&gt;write(*,*) 'Time elapsed for derived test 2 = ',end_time-start_time&lt;BR /&gt;!&lt;BR /&gt;! Next do above test with pointer to par&lt;BR /&gt;! implicit array computation speed&lt;BR /&gt;!&lt;BR /&gt;! vvv add loop to prime the processor chache&lt;BR /&gt;! vvv on first iteration. Get timing on second iteration&lt;BR /&gt;do iCachPopulate=1,2&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; pPar =&amp;gt; par(i)&lt;BR /&gt; pPar%sigma = pPar%sigma +othird*pPar%rho*pPar%rod&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;! vvv add end of processor cache prime&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;! vvv change "test" to "test 3"&lt;BR /&gt;write(*,*) 'Time elapsed for derived test 3 = ',end_time-start_time&lt;BR /&gt;!&lt;BR /&gt;! vvv add loop to prime the processor chache&lt;BR /&gt;! vvv on first iteration. Get timing on second iteration&lt;BR /&gt;do iCachPopulate=1,2&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; do j=1,3&lt;BR /&gt; do k=1,3&lt;BR /&gt; p_sigma(k,j,i) = p_sigma(k,j,i) + othird*p_rho(i)*p_rod(k,j,i)&lt;BR /&gt; enddo&lt;BR /&gt; enddo&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;! vvv add end of processor cache prime&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;write(*,*) 'Time elapsed for array test = ',end_time-start_time&lt;BR /&gt;!&lt;BR /&gt;End&lt;BR /&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Sep 2005 23:46:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841695#M59664</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-09-21T23:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841696#M59665</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Thank you for your suggestions.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Pointers are a capability of fortran 90 that I am not familiar with and so had not tried.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Jim, the timings for test 1 and test 2 are identical to the tests they are derived from. Test 3 is slightly slower than test 2. In the code you give I am not clear on the likely benefit of the cache populate step. I am running each loop through a number of cycles in order to increase the execution time to a point where useful comparisons can be done with the cpu_time function. Also the space required to store the sigma array for every particle is over seven megabytes in this case, which I assume exceeds any cache size.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;In the main program that I am looking to improve, derived data type are used as they make it much easier to maintin and modify. These features are more important in this case than raw execution speed. However given that, it would be useful to make the program run as fast as possible as large analyses can run for hours to days. Minimising the number of operations inside loops is one of the exercises that will be done. My interest is in whether the speed penalty from using derived types can be reduced, or is it an inevitable consequence of the choice to use them.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;My understanding is that the reason for the speed difference between derived types and basic arrays is that in the derived type the sigma and rod tensors for particle i and i+1 are not held in adjacent memory locations and so any cache is not being used as efficiently. I had wondered if I could make an array of pointers that pointed to just the sigma or rod components, and work on these. But from the compile errors when I tried this I see that you are not allowed to make individual components of a derived type a target.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I have downloaded a trial version of the vtune analyser which I hope will help me with these comparisons, once I learn how to use it.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;James&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Sep 2005 17:11:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841696#M59665</guid>
      <dc:creator>jcac</dc:creator>
      <dc:date>2005-09-22T17:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841697#M59666</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Canyou not also skip the inner j,k loops if abs(p_rho(i)) is less than some small quantity?&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Sep 2005 19:24:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841697#M59666</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2005-09-22T19:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841698#M59667</link>
      <description>Tony, I'm not an expert on optimization, but AFAIK this sort of "optimization" is a frequent error. Namely, it is usually faster for the processor to evaluate a simple expression, because it can pipeline it into FP part of the processor separately of the normal exectution flow. Any kind of test ivolves jumping, interferes with control flow and thus kills performance. Check for yourself:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;program FloatTest&lt;BR /&gt;&lt;BR /&gt;integer, parameter:: IMAX = 10000000&lt;BR /&gt;&lt;BR /&gt;real x(IMAX)&lt;BR /&gt;&lt;BR /&gt;do i=1,IMAX&lt;BR /&gt;   call random_number(x(i))&lt;BR /&gt;   if (x(i).lt.0.5) x(i) = 0.&lt;BR /&gt;end do&lt;BR /&gt;&lt;BR /&gt;call cpu_time(time0)&lt;BR /&gt;y = 0.&lt;BR /&gt;do i=1,IMAX&lt;BR /&gt;   y = y + x(i)*(x(i)-1)+x(i)&lt;BR /&gt;end do&lt;BR /&gt;call cpu_time(time1)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;write(*,*) "time =", time1-time0&lt;BR /&gt;write(*,*) y&lt;BR /&gt;&lt;BR /&gt;call cpu_time(time0)&lt;BR /&gt;&lt;BR /&gt;y = 0.&lt;BR /&gt;do i=1,IMAX&lt;BR /&gt;   if (x(i).gt.0.) y = y + x(i)*(x(i)-1)+x(i)&lt;BR /&gt;end do&lt;BR /&gt;call cpu_time(time1)&lt;BR /&gt;&lt;BR /&gt;write(*,*) "time =", time1-time0&lt;BR /&gt;write(*,*) y&lt;BR /&gt;&lt;BR /&gt;end program&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.xeffort.com" target="_blank"&gt;Jugoslav&lt;/A&gt;</description>
      <pubDate>Thu, 22 Sep 2005 20:10:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841698#M59667</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2005-09-22T20:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841699#M59668</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Out of interest I compiled the same program on another system and found that the speed difference as much less pronounced, with the arraycase being only 5-10% faster.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;The system was aCompaq Alpha,running TRU64 UNIX and using the Compaq f90 compiler with the -fast flag.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;So the actual difference between the derived typeand array operations seems to be strongly dependent on the compiler/OS/hardware combination.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;James&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Sep 2005 21:33:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841699#M59668</guid>
      <dc:creator>jcac</dc:creator>
      <dc:date>2005-09-22T21:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841700#M59669</link>
      <description>&lt;DIV&gt;But the possible saving each time is 9 executions of the arithmetic expression+address assignments, not one. Anyway, it was just a suggestion....its suitabilitydepends of course on the frequency of zeros in one of the arrays..&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 Sep 2005 22:50:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841700#M59669</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2005-09-22T22:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841701#M59670</link>
      <description>&lt;P&gt;James, I ran a few test indicating the derived type is faster than the 3 dimensioned arrays. Don't entirely know why. Here is my test code:&lt;/P&gt;
&lt;P&gt;! Test2.f90 &lt;BR /&gt;module base_database&lt;/P&gt;
&lt;P&gt;type typeOldPar&lt;BR /&gt;real(8) :: rho,sigma(3,3),rod(3,3)&lt;BR /&gt;end type typeOldPar&lt;/P&gt;
&lt;P&gt;type typeNewPar&lt;BR /&gt;sequence&lt;BR /&gt;real(8) :: sigma(3,3) ! Offset = 0 (+ 9*8 = 72 = 4.5*16)&lt;BR /&gt;real(8) :: rho ! Offset = 72 (+ 8 = 80 = 5*16)&lt;BR /&gt;real(8) :: rod(3,3) ! Offset = 80 (+ 9*8 = 152 = 9.5*16)&lt;BR /&gt;real(8) :: padd ! Offset = 152 (+8 = 160)&lt;BR /&gt;end type typeNewPar&lt;BR /&gt;type(typeOldPar), allocatable :: par(:)&lt;BR /&gt;type(typeNewPar), allocatable :: parNew(:)&lt;BR /&gt;real(8), allocatable :: p_sigma(:,:,:), p_rho(:), p_rod(:,:,:)&lt;BR /&gt;end module base_database&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;!DEC$ ATTRIBUTES FORCEINLINE :: ComputeNewSigmaArray&lt;BR /&gt;subroutine ComputeNewSigmaArray(p)&lt;BR /&gt;use base_database&lt;BR /&gt;!&lt;BR /&gt;implicit none&lt;BR /&gt; type(typeNewPar) :: p&lt;BR /&gt; real(8), parameter :: othird = 1.0D0 / 3.0D0&lt;BR /&gt; real(8) :: scale&lt;BR /&gt; scale = othird*p%rho&lt;BR /&gt; p%sigma = p%sigma +scale*p%rod&lt;BR /&gt;end subroutine ComputeNewSigmaArray&lt;/P&gt;
&lt;P&gt;!DEC$ ATTRIBUTES FORCEINLINE :: ComputeNewSigma3x3&lt;BR /&gt;subroutine ComputeNewSigma3x3(p)&lt;BR /&gt;use base_database&lt;BR /&gt;!&lt;BR /&gt;implicit none&lt;BR /&gt; type(typeNewPar) :: p&lt;BR /&gt; real(8), parameter :: othird = 1.0D0 / 3.0D0&lt;BR /&gt; real(8) :: scale&lt;BR /&gt; integer :: i,j&lt;BR /&gt; scale = othird*p%rho&lt;BR /&gt; do j=1,3&lt;BR /&gt; do i=1,3&lt;BR /&gt; p%sigma(i,j) = p%sigma(i,j) +scale*p%rod(i,j)&lt;BR /&gt; end do&lt;BR /&gt; end do&lt;BR /&gt;end subroutine ComputeNewSigma3x3&lt;/P&gt;
&lt;P&gt;program Test2&lt;/P&gt;
&lt;P&gt;use base_database&lt;BR /&gt;!&lt;BR /&gt;implicit none&lt;BR /&gt;!&lt;BR /&gt;integer :: i, j, k, cyc&lt;BR /&gt;real :: start_time, end_time&lt;BR /&gt; real(8), parameter :: othird = 1.0D0 / 3.0D0&lt;BR /&gt;integer :: istart, iend, ncycle, rcycle, ircycle&lt;BR /&gt;istart = 1&lt;BR /&gt;iend = 100000&lt;BR /&gt;ncycle = 100&lt;BR /&gt;rcycle = 3&lt;BR /&gt;allocate(par(iend))&lt;BR /&gt;allocate(parNew(iend))&lt;BR /&gt;allocate(p_sigma(3,3,iend))&lt;BR /&gt;allocate(p_rho(iend))&lt;BR /&gt;allocate(p_rod(3,3,iend))&lt;BR /&gt;!&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; par(i)%sigma = 0.&lt;BR /&gt; par(i)%rho = 0.&lt;BR /&gt; par(i)%rod(k,j) = 0.&lt;BR /&gt; parNew(i)%sigma = 0.&lt;BR /&gt; parNew(i)%rho = 0.&lt;BR /&gt; parNew(i)%rod(k,j) = 0.&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;do ircycle = 1, rcycle&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; do j=1,3&lt;BR /&gt; do k=1,3&lt;BR /&gt; par(i)%sigma(k,j) = par(i)%sigma(k,j) +othird*par(i)%rho*par(i)%rod(k,j)&lt;BR /&gt; enddo&lt;BR /&gt; enddo&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;!&lt;BR /&gt;write(*,*) 'Time elapsed for derived test 1 = ',end_time-start_time&lt;BR /&gt;enddo&lt;BR /&gt;!DEC$ IF(0)&lt;BR /&gt;On a P4 530 with other threads running&lt;BR /&gt;Time elapsed for derived test 1 = 0.7031250&lt;BR /&gt;Time elapsed for derived test 1 = 0.7656250&lt;BR /&gt;Time elapsed for derived test 1 = 0.7343750&lt;BR /&gt;!DEC$ ENDIF&lt;BR /&gt;!&lt;BR /&gt;do ircycle = 1, rcycle&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; call ComputeNewSigmaArray(parNew(i))&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;!&lt;BR /&gt;write(*,*) 'Time elapsed for derived test 2 = ',end_time-start_time&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;!DEC$ IF(0)&lt;BR /&gt;On a P4 530 with other threads running&lt;BR /&gt;Time elapsed for derived test 2 = 1.000000&lt;BR /&gt;Time elapsed for derived test 2 = 1.015625&lt;BR /&gt;Time elapsed for derived test 2 = 1.078125&lt;BR /&gt;!DEC$ ENDIF&lt;BR /&gt;do ircycle = 1, rcycle&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; call ComputeNewSigma3x3(parNew(i))&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;!&lt;BR /&gt;write(*,*
) 'Time elapsed for derived test 3 = ',end_time-start_time&lt;BR /&gt;enddo&lt;BR /&gt;!DEC$ IF(0)&lt;BR /&gt;On a P4 530 with other threads running&lt;BR /&gt;Time elapsed for derived test 3 = 1.000000&lt;BR /&gt;Time elapsed for derived test 3 = 0.9843750&lt;BR /&gt;Time elapsed for derived test 3 = 1.031250&lt;BR /&gt;!DEC$ ENDIF&lt;BR /&gt;!&lt;BR /&gt;do ircycle = 1, rcycle&lt;BR /&gt;call cpu_time(start_time)&lt;BR /&gt;!&lt;BR /&gt;do cyc=1,ncycle&lt;BR /&gt;do i=istart, iend&lt;BR /&gt; do j=1,3&lt;BR /&gt; do k=1,3&lt;BR /&gt; p_sigma(k,j,i) = p_sigma(k,j,i) + othird*p_rho(i)*p_rod(k,j,i)&lt;BR /&gt; enddo&lt;BR /&gt; enddo&lt;BR /&gt;enddo&lt;BR /&gt;enddo&lt;BR /&gt;!&lt;BR /&gt;call cpu_time(end_time)&lt;BR /&gt;!&lt;BR /&gt;write(*,*) 'Time elapsed for array test = ',end_time-start_time&lt;BR /&gt;enddo&lt;BR /&gt;!DEC$ IF(0)&lt;BR /&gt;On a P4 530 with other threads running&lt;BR /&gt;Time elapsed for array test = 1.703125&lt;BR /&gt;Time elapsed for array test = 1.703125&lt;BR /&gt;Time elapsed for array test = 1.718750&lt;BR /&gt;!DEC$ ENDIF&lt;BR /&gt;!&lt;BR /&gt;stop&lt;BR /&gt;end program Test2&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 23 Sep 2005 11:51:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841701#M59670</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-09-23T11:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841702#M59671</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Jim,&lt;/P&gt;
&lt;P&gt;What compiler version and flags are you using?&lt;/P&gt;
&lt;P&gt;I am using Version 9.0.2713.2002 integrated with Visual Studio .NET 2002. I built your code as a new console project, using the default Release settings and got the following:&lt;/P&gt;
&lt;P&gt;Time elapsed for derived test 1 = 1.703125&lt;BR /&gt;Time elapsed for derived test 1 = 1.671875&lt;BR /&gt;Time elapsed for derived test 1 = 1.671875&lt;/P&gt;
&lt;P&gt;Time elapsed for derived test 2 = 1.687500&lt;BR /&gt;Time elapsed for derived test 2 = 1.687500&lt;BR /&gt;Time elapsed for derived test 2 = 1.687500&lt;/P&gt;
&lt;P&gt;Time elapsed for derived test 3 = 1.640625&lt;BR /&gt;Time elapsed for derived test 3 = 1.656250&lt;BR /&gt;Time elapsed for derived test 3 = 1.640625&lt;/P&gt;
&lt;P&gt;Time elapsed for array test = 1.312500&lt;BR /&gt;Time elapsed for array test = 1.296875&lt;BR /&gt;Time elapsed for array test = 1.281250&lt;/P&gt;
&lt;DIV&gt;I did experiment with some options, for example /Qipo speeds up the array but not the derived type:&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Time elapsed for derived test 1 = 1.703125&lt;BR /&gt;Time elapsed for derived test 1 = 1.656250&lt;BR /&gt;Time elapsed for derived test 1 = 1.640625&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Time elapsed for derived test 2 = 1.703125&lt;BR /&gt;Time elapsed for derived test 2 = 1.687500&lt;BR /&gt;Time elapsed for derived test 2 = 1.671875&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Time elapsed for derived test 3 = 1.640625&lt;BR /&gt;Time elapsed for derived test 3 = 1.656250&lt;BR /&gt;Time elapsed for derived test 3 = 1.640625&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Time elapsed for array test = 1.093750&lt;BR /&gt;Time elapsed for array test = 1.078125&lt;BR /&gt;Time elapsed for array test = 1.078125&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;What I am not sure is why the array test with your program is slower than in mine, I need to investigate this more.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I had to make a change to compile your program, the (j,k) had to be removed from rod when initializing the variables, otherwise I received a compile error.&lt;/DIV&gt;</description>
      <pubDate>Fri, 23 Sep 2005 20:07:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841702#M59671</guid>
      <dc:creator>jcac</dc:creator>
      <dc:date>2005-09-23T20:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841703#M59672</link>
      <description>A hint to those posting code.  If you are using MSIE, then use the button for source and a box pops up.  Otherwise, put &lt;PRE&gt; and &lt;/PRE&gt; tags around the source in order to prevent punctuation to be interpreted as smileys.</description>
      <pubDate>Fri, 23 Sep 2005 20:38:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841703#M59672</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2005-09-23T20:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841704#M59673</link>
      <description>&lt;P&gt;Compiler options:&lt;BR /&gt;/nologo /Zi /O3 /QaxP /QxP /fpp /fpe:0 /module:"$(INTDIR)/" &lt;BR /&gt;/object:"$(INTDIR)/" /traceback /libs:static /dbglibs /c&lt;/P&gt;
&lt;P&gt;I made some additional tests in the program&lt;/P&gt;
&lt;P&gt;Original derived type loop&lt;BR /&gt;Time elapsed for derived test par(i)%sigma(k,j) = 0.7500000&lt;BR /&gt;Time elapsed for derived test par(i)%sigma(k,j) = 0.8125000&lt;BR /&gt;Time elapsed for derived test par(i)%sigma(k,j) = 0.7500000&lt;/P&gt;
&lt;P&gt;The call to the inlined function as in prior test code&lt;BR /&gt;Time elapsed for derived test ComputeNewSigmaArray = 1.015625&lt;BR /&gt;Time elapsed for derived test ComputeNewSigmaArray = 1.031250&lt;BR /&gt;Time elapsed for derived test ComputeNewSigmaArray = 1.046875&lt;/P&gt;
&lt;P&gt;Bringing the contents of the above inlined funciton into line by hand&lt;BR /&gt;Time elapsed for derived test p%sigma = 1.109375&lt;BR /&gt;Time elapsed for derived test p%sigma = 1.109375&lt;BR /&gt;Time elapsed for derived test p%sigma = 1.062500&lt;BR /&gt;??^^ I was suprised this ran slightly slower than having the compiler inline the code&lt;/P&gt;
&lt;P&gt;Results of call to inlined function&lt;BR /&gt;Time elapsed for derived test ComputeNewSigma3x3 = 1.093750&lt;BR /&gt;Time elapsed for derived test ComputeNewSigma3x3 = 1.093750&lt;BR /&gt;Time elapsed for derived test ComputeNewSigma3x3 = 0.9531250&lt;/P&gt;
&lt;P&gt;Bringing the contents of the above inlined funciton into line by hand&lt;BR /&gt;Time elapsed for derived test p%sigma(k,j) = 1.078125&lt;BR /&gt;Time elapsed for derived test p%sigma(k,j) = 1.093750&lt;BR /&gt;Time elapsed for derived test p%sigma(k,j) = 0.9843750&lt;/P&gt;
&lt;P&gt;Time elapsed for array test = 1.703125&lt;BR /&gt;Time elapsed for array test = 1.843750&lt;BR /&gt;Time elapsed for array test = 1.765625&lt;/P&gt;
&lt;P&gt;Interestingly the intuitive actions of creating local temps for scale and a pointer to the derived type element interfered with the compiler's optimizations - so much for intuition.&lt;/P&gt;
&lt;P&gt;This is a good example of why some time must be invested in examining the performance impact of different methods. In particular if this function is going to consume 10's, 100's, 1000's hours of processor time.&lt;/P&gt;
&lt;P&gt;This may be a good candidate for using a dual core processor with OpenMP.&lt;BR /&gt;From my experience with OpenMP on my P4 530 with HT is that FPU intensive applications run slower. I am looking at replacing my motherboard and processor with something with true MP capabilities. &lt;/P&gt;
&lt;P&gt;Im my case my application on the P4 530 will take several months to complete the corse level computations. A dual or quad processor system, each with dual cores looks tantilizing (at least until I look at the cost). On the low end a Dual Core P4 840. On the high end a Quad Xeon or Quad Opteron system. But more likely something in between (dual processor each with dual core).&lt;/P&gt;
&lt;P&gt;My simulation is a tension structure built with tethers. One configuraiton has 6 tethers the other has 8. The tether end points are connectd to mass objects. I am simulating what could be called a compound pendulum with flexible and interconnected arms. A non-trivial computation. The purpose of the computation is a preliminary engineering study of a second generation space elevator. &lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;BR /&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 23 Sep 2005 22:48:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841704#M59673</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-09-23T22:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841705#M59674</link>
      <description>&lt;P&gt;RE: (k,j) on initialization&lt;/P&gt;
&lt;P&gt;Oops&lt;/P&gt;
&lt;P&gt;Funny thing my compiler did not balk at this (using uninitialized variable). Thanks for the catch. The bug got in there with a lazy cut/paste. The improper initialization will not adversely affect the results of the test runs.&lt;/P&gt;
&lt;DIV&gt;Jim Dempsey&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 23 Sep 2005 22:53:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841705#M59674</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-09-23T22:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841706#M59675</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Changing the compile flags by adding /O3 and adding the processor specific options, /QaxB /QxB, in my case, I did see a speed up for the first test.&lt;/P&gt;
&lt;P&gt;Time elapsed for derived test 1 = 0.6875000&lt;BR /&gt;Time elapsed for derived test 1 = 0.5312500&lt;BR /&gt;Time elapsed for derived test 1 = 0.5156250&lt;/P&gt;
&lt;P&gt;Time elapsed for derived test 2 = 1.687500&lt;BR /&gt;Time elapsed for derived test 2 = 1.671875&lt;BR /&gt;Time elapsed for derived test 2 = 1.671875&lt;/P&gt;
&lt;P&gt;Time elapsed for derived test 3 = 1.625000&lt;BR /&gt;Time elapsed for derived test 3 = 1.625000&lt;BR /&gt;Time elapsed for derived test 3 = 1.640625&lt;/P&gt;
&lt;P&gt;Time elapsed for array test = 1.062500&lt;BR /&gt;Time elapsed for array test = 1.062500&lt;BR /&gt;Time elapsed for array test = 1.046875&lt;/P&gt;
&lt;P&gt;I did also try compiling it with each module/routine split into a different file and saw a speed increase for test 1 and the array tests, tests 2 and 3 were not significantly altered:&lt;BR /&gt;&lt;BR /&gt;Time elapsed for derived test 1 = 0.3125000&lt;BR /&gt;Time elapsed for derived test 1 = 0.2187500&lt;BR /&gt;Time elapsed for derived test 1 = 0.2031250&lt;/P&gt;
&lt;P&gt;Time elapsed for array test = 0.2968750&lt;BR /&gt;Time elapsed for array test = 0.2968750&lt;BR /&gt;Time elapsed for array test = 0.2968750&lt;/P&gt;
&lt;P&gt;For now it seems that I do not need to make any basic changes within the FORTRAN language to speed up the derived types. Once I have completed the algorithm and code optimisations I will clearly have to carefully look at the different compiler options.&lt;/P&gt;
&lt;P&gt;In the longer term I am looking at implementing a parallel version. However it will have to be based on MPI as it is almost certain that the computing facilities available to mein the future willbe distributed memory systems.&lt;/P&gt;
&lt;P&gt;The main code I am working on is a meshless solver for transient solid, structural and fluid mechanics problems. As there is a lot of commonality with the n-body/SPH codes developed for astrophysics simulations, I can learn a lot from the MPI implementations that have been done for that area.&lt;/P&gt;
&lt;P&gt;James&lt;BR /&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 26 Sep 2005 21:13:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841706#M59675</guid>
      <dc:creator>jcac</dc:creator>
      <dc:date>2005-09-26T21:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Improving execution speed with derived types</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841707#M59676</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt;In the longer term I am looking at implementing a parallel version. However it will have to be based on MPI as it is almost certain that the computing facilities available to mein the future willbe distributed memory systems.&amp;lt;&amp;lt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;DIV&gt;Many mid-range workstations (will) have dual core capabilities so I wouldn't discound adding a little OpenMP along with MPI. You can do both.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Jim Dempsey&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 27 Sep 2005 04:08:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Improving-execution-speed-with-derived-types/m-p/841707#M59676</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2005-09-27T04:08:59Z</dc:date>
    </item>
  </channel>
</rss>

