PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Pointer Restrict

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
THX 1138



Joined: 30 Jun 2011
Posts: 102

PostPosted: Wed Sep 21, 2011 12:01 pm    Post subject: Pointer Restrict Reply with quote

What is the purpose of the restrict modifier on pointers in c? Is the Msafeptr command also a way of accomlishing this?

THS 1138
Back to top
View user's profile
jtull



Joined: 30 Jun 2004
Posts: 395

PostPosted: Wed Sep 21, 2011 3:56 pm    Post subject: Reply with quote

The restriction is to allow optimizations that would not work if the arrays
that are 'pointed to' overlap.

In fortran, it is a rule that if you compile a routine like

subroutine foo(a,b,n)
real*4 a(n), b(n)

you cannot call
foo(c,c,n)
and expect it to work properly, using the same array twice,
or
foo(c, c(10), n)

cannot be guaranteed to work.

We add the C99 restrict attribute to allow us to use more
optimization techniques, because we know that the arrays sent
as arguments will never overlap.

-Msafeptr
in C tells the compiler there are no overlapping pointers, and so
we can optimize more.

dave
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group