- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a module file which collects lots of small subroutines. They must be inlined otherwise the overall perfermance of my code will be greatly degraded. Although from the computing time, I can find out if all these small subroutines are inlined, I do need a more straitfarward way to see it.
To illustrate the problem, I have two files, one is the main the other contains a module:
file 1
---------------------
program testinline
use subs
implicit none
integer :: x(10), y(10)
integer :: i
real(8) :: t1, t2
call cpu_time(t1)
DO i=1, 100000000
call sub1(10,x,y)
ENDDO
call cpu_time(t2)
print *, 'time =', t2-t1
call cpu_time(t1)
DO i=1, 100000000
y = x + 1
ENDDO
call cpu_time(t2)
print *, 'time =', t2-t1
stop
end program testinline
---------------------
file 2
---------------------
module subs
implicit none
contains
subroutine sub1(n,x,y)
integer :: n
integer :: x(n)
integer :: y(n)
y = x + 1
end subroutine
end module subs
---------------------
I knowunless Iturn Interprocedural Optimization (/Qipo) on, otherwise the compiler will not inline the subroutine in the module file.
My question is thathow do I know it without writing a small testing code like this. For example, if /Qipo is off, I can generate asm files together with the source code, so I can look into the asm files and know if the compiler expands the subroutine calls. But with /Qipo on, asm files are not generated.
Many thanks.
I have a module file which collects lots of small subroutines. They must be inlined otherwise the overall perfermance of my code will be greatly degraded. Although from the computing time, I can find out if all these small subroutines are inlined, I do need a more straitfarward way to see it.
To illustrate the problem, I have two files, one is the main the other contains a module:
file 1
---------------------
program testinline
use subs
implicit none
integer :: x(10), y(10)
integer :: i
real(8) :: t1, t2
call cpu_time(t1)
DO i=1, 100000000
call sub1(10,x,y)
ENDDO
call cpu_time(t2)
print *, 'time =', t2-t1
call cpu_time(t1)
DO i=1, 100000000
y = x + 1
ENDDO
call cpu_time(t2)
print *, 'time =', t2-t1
stop
end program testinline
---------------------
file 2
---------------------
module subs
implicit none
contains
subroutine sub1(n,x,y)
integer :: n
integer :: x(n)
integer :: y(n)
y = x + 1
end subroutine
end module subs
---------------------
I knowunless Iturn Interprocedural Optimization (/Qipo) on, otherwise the compiler will not inline the subroutine in the module file.
My question is thathow do I know it without writing a small testing code like this. For example, if /Qipo is off, I can generate asm files together with the source code, so I can look into the asm files and know if the compiler expands the subroutine calls. But with /Qipo on, asm files are not generated.
Many thanks.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a compiler directives that inlines a subroutine "unless it will cause errors". Just add
"!DEC$ ATTRIBUTES FORCEINLINE :: sub1" just after "subroutine sub1(n,x,y)".
"!DEC$ ATTRIBUTES FORCEINLINE :: sub1" just after "subroutine sub1(n,x,y)".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you enable optimization reports, you should be able to see mentions that either the routine was inlined or perhaps, as it would be in your sample case here, eliminated (since nothing is ever done with the results from sub1). In Visual Studio, this is under Diagnostics.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page