Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

Pointing to concurrent variables

$
0
0

Hi,

I'ld like to ask if it's save to point to concurrent variables outside a concurrent construct and use the pointer inside the concurrent construct. E.g.:

...
integer :: m,n
integer, target :: i, k
integer, pointer :: ip, kp
real :: mat(m0,n0)
...
if (something) then
   ip => i
   kp => k
   m=m0;n=n0
else
   ip => k
   kp => i
   m=n0;n=m0
end if
...
do concurrent(k=1:n)
   ...
   do i=1,m
      mat(ip,kp)=...
   end do
end do
...

I've read somewhere:

If a pointer is used in an iteration other than in the case of pointer assignment, allocation, or nullification, it must either be previously pointer associated during that iteration or must not have its pointer association changed during any other iteration. A pointer that has its pointer association changed in more than one iteration has an undefined association status when the construct terminates.

If I understood this correctly, then I do not change the association status in any iteration and so the code above should be legit. On the other hand this seems a bit strange to me, because this implicates that the compiler probably has to replicate also the pointer (even if it never changes within a iteration) and to reassign it to its newly created (also replicated), previously defined target. This would further mean, that the compiler has to check all present pointers if they may be assigned to any iteration-local variable and if so, to set them iteration-local too and to reassign them. This looks like a lot of work to me...
A solution to my understanding problem might be if the compiler would treat the pointer more like an alias and substitutes the actual variable back before expanding them into any concurrent context...

Thanks for any help!

 


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>