Hello everybody,
I have a complicated structure which a driver subroutine calls several user libraries. Many arguments need to be passed. To avoid the possibility of making a mistake, I decided to pack the arguments in a derived type structure and use pointers. I've noticed that this packing makes a big slow-down. I've made a working example with the two alternatives. working_example.f90 uses the derived type while the working_example_alt.f90 passes the arguments directly. The real system is much more complicated than this but this is representative of what happens.
I compile both with -O2 and use time to measure their performance:
p3tris@Odysseus:~/Desktop$ ifort -O2 -o test working_example_alt.f90 p3tris@Odysseus:~/Desktop$ time ./test real 0m0.003s user 0m0.000s sys 0m0.000s p3tris@Odysseus:~/Desktop$ ifort -O2 -o test working_example.f90 p3tris@Odysseus:~/Desktop$ time ./test real 0m0.210s user 0m0.204s sys 0m0.004s
I expected some overhead but not that significant... Is this normal? Is it due to the association or some optimizations are disabled or simply the passing of a derived type?
Thanks in advance,
Petros