 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Thu Oct 30, 2014 12:26 pm Post subject: |
|
|
Dan,
You could try something like the following, although I got a stack overflow with copies of test(k)%arr being placed on the stack with calls to report_size. This might be a problem for more general use of these arrays.
Code: | module test_mod
type dan_array
real*4, allocatable, dimension(:,:,:) :: arr
end type dan_array
!
type (dan_array) test(7)
!
contains
subroutine report_size ( k, arr)
integer*4 k
real*4, dimension(:,:,:) :: arr
write (*,10) ' Element ',k,' size=', size (arr), ' b1=',ubound(arr,1), ' b2=',ubound(arr,2), ' b3=',ubound(arr,3)
10 format (a,i0,a,b'z,zzz,zzz,zz#',3(a,b'zzz,zz#') )
end subroutine report_size
end module test_mod
use test_mod
!
integer k, sum_size
!
allocate ( test(1)%arr(1000,1000,1) )
allocate ( test(2)%arr(1000,1000,2) )
allocate ( test(3)%arr(100,100,3) )
allocate ( test(4)%arr(10,10,4) )
allocate ( test(5)%arr(1,1,5) )
allocate ( test(6)%arr(10000,1000,6) )
allocate ( test(7)%arr(1000,1000,7) )
!
sum_size = 0
do k = 1,7
if ( k/=6) &
call report_size ( k, test(k)%arr ) ! call fails as test(k)%arr is copied to stack
write (*,*) 'Element',k,' size=', size (test(k)%arr), ubound(test(k)%arr,1), ubound(test(k)%arr,2)
sum_size = sum_size + size (test(k)%arr)
end do
write (*,11) sum_size
11 format ('Total size = ',b'z,zzz,zzz,zz#')
!
end
|
|
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2927 Location: South Pole, Antarctica
|
Posted: Thu Oct 30, 2014 9:12 pm Post subject: |
|
|
John, Thanks for the demo. Before, like 10 years back, such Fortran-90 tricks did not work well, so i am very careful to move with them. What do you mean placed in the stack causing overflow? The same code but without allocate? Can you please also check if it overflows on Ifort/gFortran since you have tried many different Fortran compilers recently? I may use this code with the future FTNpro, it may save me on RAM  |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Thu Oct 30, 2014 10:46 pm Post subject: |
|
|
The following change reports the memory address of test(k)%arr, indicating that a duplicate is being provided. gFortran reports the same address, indicating that this stack copy is not required. Code: | module test_mod
type dan_array
real*4, allocatable, dimension(:,:,:) :: arr
end type dan_array
!
type (dan_array) test(7)
!
contains
subroutine report_size ( k, arr)
integer*4 k
real*4, dimension(:,:,:) :: arr
write (*,10) ' Element ',k,' size=', size (arr), ' b1=',ubound(arr,1), ' b2=',ubound(arr,2), ' b3=',ubound(arr,3)
write (*,12) ' Start address= ',loc(arr(1,1,1)), loc(arr)
10 format (a,i0,a,b'z,zzz,zzz,zz#',3(a,b'zzz,zz#') )
12 format (a,2(b'z,zzz,zzz,zz#'))
end subroutine report_size
end module test_mod
use test_mod
!
integer k, sum_size
!
allocate ( test(1)%arr(1000,1000,1) )
allocate ( test(2)%arr(1000,1000,2) )
allocate ( test(3)%arr(100,100,3) )
allocate ( test(4)%arr(10,10,4) )
allocate ( test(5)%arr(1,1,5) )
allocate ( test(6)%arr(10000,1000,6) )
allocate ( test(7)%arr(1000,1000,7) )
!
sum_size = 0
do k = 1,7
if ( k/=6) &
call report_size ( k, test(k)%arr ) ! call fails as test(k)%arr is copied to stack
write (*,12) ' Start address= ',loc(test(k)%arr(1,1,1))
write (*,10) ' Element ',k,' size=', size (test(k)%arr), ' b1=',ubound(test(k)%arr,1), ' b2=',ubound(test(k)%arr,2)
sum_size = sum_size + size (test(k)%arr)
end do
write (*,11) sum_size
10 format (a,i0,a,b'z,zzz,zzz,zz#',3(a,b'zzz,zz#') )
11 format ('Total size = ',b'z,zzz,zzz,zz#')
12 format (a,2(b'z,zzz,zzz,zz#'))
!
end
|
After all these years of using FTN95, I still don't know how to change the stack size. can someone give an example of changing the stack. I compiled and linked with : ftn95 dan_array /link |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2927 Location: South Pole, Antarctica
|
Posted: Fri Oct 31, 2014 6:37 pm Post subject: |
|
|
Your intuition was right. That was easy, just remove the workaround condition for k=6 and link (minimum is stack:240000000 which is exactly the size of the largest k=6 array is enough with /nocheck option. With /debug /undef it has to be larger)
ftn95 arr.f95
slink arr.obj /stack:1000000000 /3gb
Why this large array goes to stack with /3gb by the way? Hope in the future 64bit compiler there will be no damn stack at all 
Last edited by DanRRight on Sat Nov 01, 2014 7:49 am; edited 1 time in total |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Sat Nov 01, 2014 4:15 am Post subject: |
|
|
Dan,
I presume the stack value you gave is decimal. I could not find documentation that confirms this, as the example I found in
Win32 platform > Using the linker > Reference > Interactive mode only
gives the examples in hex.
Do you know where hex octal and decimal syntax is described.
I think I once suggested that 240m or 240000k should be supported in stead of 240000000, as I get lost in all the zeros.
Anyway, this does give an example of how to manage variable sizes and moving to 64-bit will not mean that we can ignore the memory usage.
As I have described previously, when you run out of physical memory, everything appears to stop. When it first happens, you think it is like the blue screen system crash. I shut down the PC and then had to check all the disks!
I've found that moving from 2gb to 4gb then 8gb then 16gb does not dramatically change the types of problems you can solve, although it does make it a bit easier and a bit faster.
John |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2927 Location: South Pole, Antarctica
|
Posted: Sat Nov 01, 2014 1:05 pm Post subject: |
|
|
And imagine 9 more zeros with 64bit compiler? LOL Does Intel use stack by the way?
There are types of problems which look crippled in 32bit and ones which are not even possible with 32bits as they need minimum 16GB like some our 3D PIC plasma simulations. If you use less than that the numerical fluctuations are so large that they create fake physics reality.
Intel's Knight Landing processor with 72 64bit cores combined with the future Silverfrost 64bit FTNXX supporting OpenMP would be great home supercomputer i think |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8217 Location: Salford, UK
|
Posted: Sun Nov 02, 2014 9:56 am Post subject: |
|
|
John
I have lost the thread. What is "this"? |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2403 Location: Yateley, Hants, UK
|
Posted: Sun Nov 02, 2014 1:25 pm Post subject: |
|
|
"This" is the 64 bit Clearwin+ for other compilers, and to John, yes, it is bundled with the PE.
Eddie |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|