Hi,
I have always thought that the TARGET statement is introduced as a tool to make sure that programmer does not point to a variable which should not be pointed to. I imagined that it only makes a difference during compile time. But...
Can it be that simply adding TARGET statement to ALLOCATABLE arrays declared in a module will generate any additional code hurting performance?
My colleagues run an experiment on our codebase. They took a module, where all ALLOCATABLE arrays for our solver are declared and inserted TARGET statement into each declaration. Everything was made “pointable” but no pointing was actually done. We currently do not use pointers at all.
! used to be module A real(8), allocatable :: B(:) end module A ! changed to module A real(8), allocatable, target :: B(:) end module A
Then, they run a series of large experiments on actual data and found that code with TARGET attribute took 1-6% more time to finish simulations.
Hence, the question: does compiler generate any additional/different instructions for ALLOCATABLE arrays with TARGET attribute?
Thank you for any thoughts on this.