Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Implementation of unlimited polymorphic types

$
0
0

How are unlimited polymorphic types implemented in Intel Fortran?

The obvious impolementation would be as two C poiinters, one pointing to a structure describing the target type and the other pointing to the target data.

It looks like gfortran uses this appproach: https://gcc.gnu.org/wiki/OOP#Internal_Representation

With this approach I would expect the following types to have the same storage size:

  type class_ptr_type
    class(*), pointer :: ptr => null()
  end type class_ptr_type

  type class_cptr_type
    type(c_ptr) :: data_type = c_null_ptr
    type(c_ptr) :: data = c_null_ptr
  end type class_cptr_type

With Intel Fortran the types have storage sizes of 16 words and 2 words respectively.

With gfortran 4.9.2 the both have storage sizes of 2 words.

Does Intel Fortran include a structure describing the type in every type(class_ptr_type) object?

I can see that this may avoid one pointer dereference and may have better cache usage poperties but the 8x increase in storage seems a high price to pay.

The attached code illlustrates the use of these types.

Nick

 

AttachmentSize
Downloadapplication/octet-streamprog.f901.44 KB

Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>