|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
viroxa
Joined: 28 Jul 2017 Posts: 78
|
Posted: Mon Aug 07, 2017 4:34 pm Post subject: Nested Implied DO LOOP - order of indices |
|
|
Good evening, everyone,
is the order of indices within an implied DO LOOP important, regarding performance?
Example: Order of icoun, jcoun, kcoun
Code: | ALLOCATE(bmatt(ndib1,ndib2,nlays))
! Assemble array bmatt - contains layerwise results
! Reshape is used, because implied DO LOOP returns 1D-array
bmatt=reshape([((assign_belem(...),jcoun=1,ndib1),kcoun=1,ndib2),icoun=1,nlays)],shape(bmatt)) |
Thanks! |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Mon Aug 07, 2017 5:34 pm Post subject: |
|
|
It might well be, depending on how often the assignment is performed and how many dimensions there are in the array.
Fortran uses "column major" ordering and the compiler may optimise the process of calculating the address of each element. For FTN95 further optimisation may be applied when using /opt on the command line.
I suggest that you run a simple timing test, wrapping the assignment in a do loop with (say) 10000 passes. This will give you a sensible speed comparison between different orderings and different compiler command lines options. |
|
Back to top |
|
|
viroxa
Joined: 28 Jul 2017 Posts: 78
|
Posted: Tue Aug 08, 2017 9:00 am Post subject: |
|
|
Thanks, I'll try that. |
|
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
|