non-variables in data-sharing clause list

General OpenMP discussion

non-variables in data-sharing clause list

Postby brg » Fri Feb 29, 2008 3:48 am

As I understand it OpenMP does not allow for list elements of data-sharing clauses, for example, to be anything other than a variable name. I was wondering if there are technical reasons for this restriction or just one of simplictly?

As an example consider the following contrived code:
Code: Select all
   typedef struct _Foo {
      int x; int y;
   }   Foo;

   Foo foo;
   int a[n];

   a[0] = foo.x;
   ...

   #pragma omp for private(a[0]) ...
    for() 
    {
         ...
           ... a[0] ...
    }


I can see that one issue here might be the problem that the compiler will need to match the expression (symboliclly) a[0] within the scope of of the directive, replacing with a reference to the privatized value of foo.x, however, this does not seem too difficult a task. Of course, it is not necessarally that nice to look at and in this case we might consider adding an aliasing directive giving something like:
Code: Select all
   #pragma omp alias (ax:a[0])
   a[0] = foo.x;
   ...

   #pragma omp for private(ax) ...
    for() 
    {
         ...
           ... ax ...
    }


The problem with this is that ax is not part of the original source and thus the above program no longer compiles when the directives are not taken into account.

Ben
brg
 
Posts: 1
Joined: Fri Feb 29, 2008 3:29 am

Re: non-variables in data-sharing clause list

Postby ejd » Fri Feb 29, 2008 9:36 am

I would say simplicity would be the primary reason. The OpenMP spec is complicated enough as it is without introducing aliasing. Also, the idea, as you have already mentioned, was to try and make it easy for people to incrementally change their programs from serial to parallel while maintaining their serial program. True, a user can write a program that can only run in parallel. However, having the ability to run a program both serially and in parallel has been high on the list of things the ARB has tried to maintain.

Up to now, allowing array elements or structure elements has also not been something that anyone has been pushing for. While it is easy to come up with a contrived example of using this feature, no one has shown a good use for the feature. New items are added to the spec only as people have shown a need for the new feature.

That said, there are items like min/max reduction and arrays passed to subroutines in C, that have been shown to be good things to add, that haven't been. The OpenMP Language Committee has spent many hours debating how to add these features and thus far have not been able to come to a conclusion. It is just recently (V3.0) that the conical form of the for loop has been allowed to expand to include unsigned integers. The original thinking was that it should be consistent across languages and Fortran did not support unsigned integers, so it was not allowed. More recently, the ARB has decided that language specific features should be acknowledged and used.

Please note that I am not representing the ARB and these are my own opinions.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot] and 5 guests