[Openmp-dev] Is omp construct valid in a simd routine.

Narayanaswamy, Ravi via Openmp-dev openmp-dev at lists.llvm.org
Mon Nov 16 10:57:28 PST 2020


Is this example valid


int counter;

#pragma omp declare simd simdlen(16)

void __attribute__((noinline)) foo(bool isSIMD){

  if (!isSIMD) {

    #pragma omp parallel num_threads(1)

      printf("%d\n", counter);

  } else {

    printf("%d\n", counter);

  }

}



void bar() {

  foo(false); // Is the user wrong to expect this call to foo honor "#pragma omp parallel" in foo?

}



void baz() {

  #pragma omp simd

  for(int i = 0; i < 32; i++)

    foo(true); // Is it the compiler's responsibility to ignore the "#pragma omp parallel" inside foo() for this call?

}


The spec says

The execution of the function or subroutine, when called from a SIMD loop, cannot result in the

execution of an OpenMP construct except for an ordered construct with the simd clause or an

atomic construct.
Thanks
Ravi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20201116/ba149dac/attachment.html>


More information about the Openmp-dev mailing list