ifort: Static analysis for code that offloads

ifort: Static analysis for code that offloads

Is it possible yet to do static analysis of code that has offloaded sections? I'm trying to use iforts static analyser by compiling with the following flags:

ifort -g -O3 -fpp -xHost -align -ansi-alias -traceback -mcmodel=medium -openmp -diag-enable sc-concise

However this issues the error:

ifort: command line error: '-static' conflicts with '-mcmodel'

This works only when I add '-no-offload' or when I take away '-mc-model'. In the latter case it creates two inspector reports, but they don't seem to correspond to 1 for MIC and the other for Host. They both report the same things... Can anybody clarify these two things for me, please?

It would be great if there was a static analyser for offloading code. The two toughest things about debugging the code is finding either variables / functions that haven't been declared as offloadable in the code - the compiler doesn't always catch these, but you do at runtime with much less information with regards to where the thing was called. And the second is much worse - finding variables in offloaded sections that exist on the MIC side, but they are uninitialized because I overlooked doing the data transfer somewhere.

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

I am not aware of any specific support to analyze offload code using the -diag-enable static analysis options. The static analysis would still be helpful with offload disabled (-no-offload). I need to look into the mcmodel/static diagnostic further to understand that.

What is available for offload and might help is the static analysis of the offload code provided by -opt-report-phase=offload option.

Further, for the first scenario, when building your app, try adding the following option to the final link step: -offload-option,mic,ld,"--no-undefined"

The MIC executable is currently a shared library (which by the Linux standard default is allowed unresolved external references; however, --no-undefined link option disables this so it can help find variables in the first scenario at link-time vs. run-time.

That's useful, thanks. However with my code it tells me that there are undefined references to global variables that I swear aren't referenced in offloaded regions.

It's like the spurious warnings I was getting with version 13 of ifort (I'm pretty sure it's the exact same variables it's complaining about too...). It seems that if I have a module where if some of the global variables are declared as offloadable and the rest not, then it seems to get confused and when you include that module in an offloadable region and tries to add them all. Is it some subtlety with how fortran modules work and scope work in the language?

I'll see if I can't prepare another mini program to show this.

I thought of something else that could also help. OFFLOAD_REPORT=3 level diagnostics provide run-time analysis that includes data movement.

For this simple case:

program foo
integer,allocatable :: a(:)
!dir$ offload_transfer target(mic:0) in(a)
!dir$ offload_transfer target(mic:0) out(a)

A portion of the OFFLOAD_REPORT output is:

[Offload] [MIC 0] [Tag 0] [State]   Start target function __offload_entry_test_F90_6MAIN__
[Offload] [MIC 0] [Tag 0] [Var]     foo_$A_V$15  IN
[Offload] [MIC 0] [Tag 0] [Var]     foo_$A_V$15  IN
[Offload] [MIC 0] [Tag 0] [State]   Scatter copyin data
[Offload] [MIC 0] [Tag 0] [State]   Gather copyout data
[Offload] [MIC 0] [Tag 0] [State]   MIC->CPU copyout data   0

Post-processing or filtering can help build a run-time analysis of data/variable movement. Details below correspond to offloads at lines 6 and 9. The source file line number appears embedded with the routine name (i.e. 6MAIN and 9MAIN).

$ ./test | egrep "function|Var"
[Offload] [HOST]  [Tag 0] [State]   Initialize function __offload_entry_test_F90_6MAIN__
[Offload] [MIC 0] [Tag 0] [State]   Start target function __offload_entry_test_F90_6MAIN__
[Offload] [MIC 0] [Tag 0] [Var]     foo_$A_V$15  IN
[Offload] [MIC 0] [Tag 0] [Var]     foo_$A_V$15  IN
[Offload] [HOST]  [Tag 1] [State]   Initialize function __offload_entry_test_F90_9MAIN__
[Offload] [MIC 0] [Tag 1] [State]   Start target function __offload_entry_test_F90_9MAIN__
[Offload] [MIC 0] [Tag 1] [Var]     foo_$A_V$15  OUT
[Offload] [MIC 0] [Tag 1] [Var]     foo_$A_V$15  OUT


Leave a Comment

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