[llvm-dev] OpenMP: pragma cancel for

Gurunath Kadam via llvm-dev llvm-dev at lists.llvm.org
Sun Nov 13 11:35:06 PST 2016


I am trying to implement following code:
---------------------------------------------------------------------------------------------------------
#pragma omp parallel private(i, piold, err) shared(pi, threshold_err)
{
#pragma omp for reduction(+:pi) schedule (static)
  for (i = 0; i < 10000000 ; i++){
        piold = pi;
        pi += (((i&1) == false) ? 1.0 : -1.0)/(2*i+1);
        err = fabs(pi-piold);
        if ( err < threshold_err){
#pragma omp cancel for
        }

  }
}
-------------------------------------------------------------------------------------------------------------
Although with if statement removed, code takes 11 seconds, while with it in
it takes forever and I ave to abort the code.

I am using LLVM3.9/CLANG4.0.

Is cancel for implemented in LLVM? I use a small code to see that and
omp_get_cancellation() returns true for export OMP_CANCELLATION=true
directive.

Thank you.

-Gurunath
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161113/c94136d1/attachment.html>


More information about the llvm-dev mailing list