Why is openMP cancellation construct not cancelling the worksharing region?

耗尽温柔 提交于 2019-12-24 03:42:56

问题


i was expecting that variable "i" will reach a maximum value of 11 and then the "for" worksharing region will be cancelled ,code is:

omp_set_num_threads(11);

#pragma omp parallel
{

    #pragma omp for
    for(i=0;i<9999;i++){
        printf("%d by %d \n",i,omp_get_thread_num());

        if(i>11)   //2
        {
            #pragma omp cancel for 
        }

    }//for

}//parallel omp pragma

but the variable i was holding max value of 9998 which i suppose means that worksharing region was not cancelled.


回答1:


Cancellation is disabled by default, mostly for performance reasons. You must specifically enable cancellation support by setting the cancel-var ICV to true. The only way to do so is to set the environment variable OMP_CANCELLATION to true, e.g.:

$ OMP_CANCELLATION=true ... ./omp_executable ...


来源:https://stackoverflow.com/questions/22173656/why-is-openmp-cancellation-construct-not-cancelling-the-worksharing-region

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!