This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gomp4] Questions about "declare target" and "target update" pragmas


Hi Jakub,

I discovered an issue related to global variables.
In this testcase the 'omp target' child fn uses the local copy of glob_var.
But the 'omp parallel' child fn tries to use the glob_var directly and therefore
crashes.

int glob_var;

void
foo (void)
{
  glob_var = 1;
  #pragma omp target map(to: glob_var)
    {
      glob_var = 2;
      #pragma omp parallel
        {
          glob_var = 3;
        }
    }
}

In the spec I found only that if a variable is not present in the enclosing
device data environment, then it is allocated in the device data environment
associated with the construct.  Effectively this means glob_var become a
non-global variable within the omp_target construct.  Then it's not quite clear
what type of glob_var should be in case target is not present and we fallback to
host execution.

Should we forbid 'omp target' to map global vars that are not defined as target?
Or force 'omp parallel' to use local copies inside the target regions?
(ICC reports an error about mapping glob_var for this testcase)

  -- Ilya


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]