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

Parameterized derived type

Espen_M_
Beginner
408 Views

I have a question about the newly implemented parameterized derived types language feature:

If I use a KIND type parameter when specifying array DIMENSIONs of a DT component, and write special (typically type-bound) procedures for this PDT that operate on the said array component, will the compiler be able to optimize performance in any way due to array dimensions being known at compile time for all instances of the type?

Of course one could do the same without PDTs by just using a (global) PARAMETER in the declaration of the array dummy arguments and the array variables, but I guess that it would be much easier for the compiler til reason about this when it is "formalized" through a DT..?

PS: the array(-component)s I'm talking about here would typically be small; in the range 2x2 to 16x16

PS2: really looking forward to finally use PDTs!!!!

0 Kudos
3 Replies
Steven_L_Intel1
Employee
408 Views

Yes, you can do that. It's even an example in the standard (Note 4.23 in F2008). For optimization, it's no different than using a PARAMETER in the bounds expression.

0 Kudos
Espen_M_
Beginner
408 Views

Can I interpret your reply to imply that procedures with array arguments of given/constant shape are actually optimized compared to if assume-shape dummies were used?

And, as we're on the subject; is there a difference (in speed/overhead/?) between assumed-shape and explicit-shape (where array bounds are passed as arguments) dummies?

0 Kudos
Steven_L_Intel1
Employee
408 Views

Anytime information is deferred to run-time, there's a performance penalty. How large that is depends a lot on the application. Explicit shape arrays with bounds as dummy arguments are barely different from assumed-shape (except that the compiler knows the stride is always 1.)

0 Kudos
Reply