Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28435 Discussions

A Pseudo paramter: Can I give a hint to the compiler on the size of integers?

haugboel
Beginner
256 Views
I am running different numerical astrophysics codes, developing
on my laptop and running on an SGI Altix machine.

I know, from testing, that if I declare the central integers of the experiment, fx. nx,ny,nz, the size of our box, as parameters, the compiler can do a much better job in optimizing the code.

Fx a static declaration would be:
integer, paramter :: nx=155,ny=155,nz=155
real, dimension(nx,ny,nz) :: density, energy,velx,vely,velz

But for testing scalability, and not recompiling all the time, I need to keep the size of the experiment as an input paramter. Then the above lines are:

integer :: nx,ny,nz
real, dimension(:,:,:), allocatable :: density, energy,velx,vely,velz

call read_params(nx,ny,nz)

allocate(density(nx,ny,nz),energy(nx,ny,nz),...)

and typically I loose up to 20% in performance. On big experiments (think 512^3) size matters, but it is a pain (and error prone) to maintain two code branches, when you are a small group with continious active development.

My question is: Do there exist a compiler directive, such that a hint can be given about the size of scalar variables?
Say, something like:

!$DEC SIZE OF(nx=155,ny=155,nz=155)
integer :: nx,ny,nz
real, dimension(:,:,:), allocatable :: density, energy,velx,vely,velz

such that the loop optimizer of the compiler (and in general the compiler) optimise the code under the assumption that nx,ny,nz take these values. Ie,
such that the code runs at optimal speed for these specific values.
Definetly, when optimising loops of the form:

do iz=1,nz
...
enddo

the compiler, as it is now, somehow has to guess at some value for the trip count of the loop. The above directive would allow it to make an educated guess.

I would then have the convenience, when developing, of a flexible code, while at the same time gain full speed in a production run.

I have been looking for this kind of directive; am I looking in vain,
or does it exist? (or can I do something similar, it is not an option to put
a directive in front of every loop. We are talking 40.000 lines of code)
If the directive doesn't exist. I suggest it would be a great option to have in future releases, at least from a performance point of view.

TIA

Troels Haugboelle
0 Kudos
0 Replies
Reply