3

I want to specify a #pragma omp task depend(...) clause on a variable reference through a pointer. This is possible in OmpSs and looks like:

#pragma omp task in(*var1) out(*var2)

Basically this is what I want to do in OpenMP 4.0, but the following code:

#pragma omp task depend(in: *var1) depend(out: *var2)

produces the following error :

error: expected identifier before ‘*’ token
    #pragma omp task depend(in: *var1) depend(out: *var2)

How can this be done in OpenMP 4.0?

Massimiliano
  • 7,842
  • 2
  • 47
  • 62
Aleksr9
  • 1,233
  • 2
  • 9
  • 7
  • One thing I always wondered about OmpSs is: how can they claim to extend OpenMP if they don't support `parallel` construct? – Massimiliano Jun 11 '14 at 07:31
  • 3
    @Massimiliano, from the OmpSs specification: _"The most notable difference from OmpSs to OpenMP is the absence of the parallel clause in order to specify where a parallel region starts and ends. This clause is required in OpenMP because it uses a fork-join execution model where the user must specify when parallelism starts and ends. OmpSs uses the model implemented by StarSs where parallelism is implicitly created when the application starts."_ It's more of an evolution than an extension in the usual sense. – Hristo Iliev Jun 11 '14 at 07:52
  • OpenMP 4.0 is not my department but it might be possible to use array sections instead, e.g. `depend(in: var1[:1]) depend(out: var2[:1])`. – Hristo Iliev Jun 11 '14 at 08:01
  • @HristoIliev I agree with your interpretation, but the quoting I usually find when reading about it is _"... our objective is to extend OpenMP with new directives to support asynchronous parallelism and heterogeneity (devices like GPUs)."_ Just to clarify: I quite like the project, but I wonder out of curiosity why they stress _extend_ when OpenMP compliant code is not granted to work – Massimiliano Jun 11 '14 at 08:04
  • 1
    @Massimiliano, I guess what they mean is they extend the _OpenMP model_ and not the _OpenMP specification_. Or they simply take a very arbitrary interpretation of what "extension" means :) – Hristo Iliev Jun 11 '14 at 08:14
  • @HristoIliev Fair enough :) – Massimiliano Jun 11 '14 at 08:15
  • @HristoIliev Sure they meant to extend the OpenMP model, but they could still do it supporting the `parallel` construct – Manolete Jan 20 '17 at 10:29

1 Answers1

3

As per Hristo Iliev's comment, the correct workaround is to consider your pointers to be arrays of size 1 :

#pragma omp task depend(in: var1[:1]) depend(out: var2[:1])

The array section syntax arr[lower bound : length] allowed in depend pragmas sets lower bound to 0 if omitted, and length to the array size if omitted (which is thus not permitted for pointer types).

Community
  • 1
  • 1
Cimbali
  • 11,012
  • 1
  • 39
  • 68