Very large size of DLL

Very large size of DLL

Hi All,

I'm using Intel Visual Fortran to compile a DLL library. The library itself works fine, but unfortunately the size of the library is very large, over a 100 Megabyte. Note that this is the size when debugging is disabled. 

I tried to figure out why our libraries are soo large and came up with the following example:

module ExampleMod
 implicit none
 private
 type :: DataType
 real, dimension(1000000) :: array
 real :: scalar = 1
 end type DataType
contains
 subroutine DataTypeDoSomething(this) 
 class(DataType), intent(inout) :: this
 this%array(1) = 0
 end subroutine DataTypeDoSomething
 subroutine DoSomething1(dat)
 !DEC$ ATTRIBUTES DLLEXPORT :: DoSomething1
 type(DataType) :: dat
 call DataTypeDoSomething(dat)
 end subroutine DoSomething1
 ! subroutine DoSomething2(dat)
 ! !DEC$ ATTRIBUTES DLLEXPORT :: DoSomething2
 ! type(DataType) :: dat
 ! call DataTypeDoSomething(dat)
 ! end subroutine DoSomething2
 ! 
 ! 
 ! subroutine DoSomething3(dat)
 ! !DEC$ ATTRIBUTES DLLEXPORT :: DoSomething3
 ! type(DataType) :: dat
 ! call DataTypeDoSomething(dat)
 ! end subroutine DoSomething3
 ! 
 !
 ! subroutine DoSomething4(dat)
 ! !DEC$ ATTRIBUTES DLLEXPORT :: DoSomething1
 ! type(DataType) :: dat
 ! call DataTypeDoSomething(dat)
 ! end subroutine DoSomething4
end module ExampleMod

The above code compiles into a library of approximately 4 Megabyte. A few interesting remarks:

  • The size of the DLL is approximately the same as the size of one instance of Type(DataType). 
  • If the subroutines DoSomething2, DoSomething3 and DoSomething4 are uncommented then the size of the DLL increases to approx 16 Megabytes. Note that this is approximately 4 times the size of an instance of Type(DataType).

So apparently every time a function is added to the DLL that uses Type(DataType), an additional 4 megabytes are added to the DLL. To me it seems that this is a bug in the compiler or linker.

Has anyone else seen this issue? Will it be solved in a next release of Intel Visual Fortan?

Best regards,Erik

PS1: The problem only occurs when using the object oriented features of Fortran. When class(DataType) is replaced with type(DataType) in the subroutine DataTypeDoSomething, the size of the DLL is only a few kilobytes, even when DoSomething2, DoSomething3 and DoSomething4 are uncommented.

PS2: When the line "real :: scalar = 1" is replaced with "real :: scalar" then the size of the DLL is also only a few kilobytes. 

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I can reproduce this in the 13.1 compiler, but it seems that we fixed in in the version 14.0 compiler coming out in September. With that version, the size doesn't grow with the additional routines.

Steve - Intel Developer Support

I understand correctly, the size will still be much smaller, but still substantial, since the dll in the new version for this example will still hold one instance of Type(DataType).

Correct - since you have an initialization in the type, the compiler constructs a "template" for the initialization and this is large in your case. You'll get just one of these in the new version. You might want to consider an allocatable component and allocate it to the desired size, rather than putting in a fixed size.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today