2

I have a pretty simple code fragment:

$acc data copy(a(:),b(:))
$acc kernels
$acc loop vector
do i=1,1000
  x = a(i)
  b(i) = sqrt(x)
enddo
$acc end kernels
$acc end data

And of course, I could dispense with x easily, but this is an example and x is the point of my question, which is: Does every thread here get its own copy of x automatically, or should I declare it private to keep the various threads from clobbering it?

bob.sacamento
  • 6,283
  • 10
  • 56
  • 115

1 Answers1

3

In OpenACC, scalars are firstprivate by default so typically there's no need to put them in a "private" clause. The only times you really need to use the "private" clause is for arrays or when a scalar "escapes" the compute region, such as being passed by reference to a device routine or it's value is used outside of the compute region.

Mat Colgrove
  • 5,441
  • 1
  • 10
  • 11
  • Thanks very much! BTW, do you know of any good documentation on OpenACC? – bob.sacamento Apr 22 '16 at 13:41
  • 1
    http://www.openacc.org/ is the best place to start. There's a "resources" section at the bottom of the main page that has several useful links. The "OpenACC Programming and Best Practices Guide" is a good place to start. – Mat Colgrove Apr 25 '16 at 15:32