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

Linking Fortran with C (with IPO)

inthecrossfire
Beginner
999 Views
I have a section of Fortran code that repeatedly calls a C function. I'm wondering if there is any way to inline this function call as I'm fairly sure that the call overhead is hurting performance.And unfortunately I can't just move the logic into Fortran code as the C code contains specific SSE.

When I try using IPO and force-inline I'm given the following in the opt-report (level 1 for IPO). What does NOFORCE mean here?

INLINING REPORT: (main_solver_) [9/125=7.2%]
-> (NOFORCE): solve_(9) (isz = 111) (sz = 130 (30+100))

Is this concept at all possible?

I'm using ifort v11.1 and icc v11.1 to compile the Fortran and C respectively and then using ifort to link.
0 Kudos
4 Replies
TimP
Honored Contributor III
999 Views
If your versions of icc and ifort match (xilink will check this and complain if not), IPO should work the same as it does between separately compiled ipo objects made by one compiler or the other. It should reduce call overhead. I suppose it's not possible to be fully in-lined across languages; I haven't tried this to know if that message is the usual one when you do this (it may be warning you that force-inline can't be fully implemented).
0 Kudos
inthecrossfire
Beginner
999 Views
I checked the disassembly and there is still a function call there so it doesn't appear to be working. Just to test it, I tried linking using ICC as well but that gave the same result. Maybe it's not possible to inline across languages like this.
0 Kudos
inthecrossfire
Beginner
999 Views
Just in case anyone wants to look at it in more detail, here is a simple example of a Fortran program calling a C function to initialise a value. I've included the Makefile as well which dumps out an opt-report with IPO listings.

example-crossipo.zip
[bash]<;-1:-1;IPO;;0>
WHOLE PROGRAM (SAFE) [EITHER METHOD]: TRUE

WHOLE PROGRAM (SEEN) [TABLE METHOD]: TRUE

WHOLE PROGRAM (READ) [OBJECT READER METHOD]: TRUE

INLINING OPTION VALUES:
  -inline-factor: 100
  -inline-min-size: 30
  -inline-max-size: 230
  -inline-max-total-size: 2000
  -inline-max-per-routine: disabled
  -inline-max-per-compile: disabled



INLINING REPORT: (MAIN__) [1/2=50.0%]

  -> for_write_seq_lis_xmit(EXTERN)
  -> for_write_seq_lis(EXTERN)
  -> (NOFORCE): setval_(1) (isz = 0) (sz = 5 (3+2))
  -> for_set_reentrancy(EXTERN)



INLINING REPORT: (setval_) [2/2=100.0%]
[/bash]
0 Kudos
inthecrossfire
Beginner
999 Views
Just tried this with icc v12.1 and ifort v12.1. It also gives the same NOFORCE message.
0 Kudos
Reply