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

Efficiency of host association for derived-type variables

FlyingHermes
New Contributor I
456 Views
Hi,

I often heard that the use of derived-type variables in big computational procedures was less efficient than the use of variable based on intrinsic types.
However, I do not really know where does the difference appears.
Therefore, I do not know to which extent the use of derived-type variable will not affect the program efficiency.

For example, when accessing data through host association, is it slower if the data is stored in a derived type variable than if it was not ?
Is there a efficiency difference between this implementation

[fortran]Module MyModule
  private
  public MyType
  Type :: MyType
    real, dimenstion(1:10) :: Sub1
    real, dimenstion(1:10) :: Sub2
    real, dimenstion(1:10) :: Sub3
  End Type
End Module

Program
  use MyModule ,only: MyType
End Program[/fortran]

and this one:
[fortran]Module MyModule
  private
  public Sub1, Sub2, Sub3
  real, dimenstion(1:10) :: Sub1
  real, dimenstion(1:10) :: Sub2
  real, dimenstion(1:10) :: Sub3
End Module

Program
  use MyModule ,only: Sub1, Sub2, Sub3
End Program[/fortran]

Thanks
0 Kudos
1 Reply
Steven_L_Intel1
Employee
456 Views
Host association is resolved at compile-time, and should not have an effect on performance. I think also that it is an overly broad generalization to say that derived types hurt performance. A lot depends on how you use them, especially if you have arrays of derived type and try to use non-contiguous arrays of components.
0 Kudos
Reply