为什么openMP取消构造不取消工作共享区域? [英] Why is openMP cancellation construct not cancelling the worksharing region?

查看:112
本文介绍了为什么openMP取消构造不取消工作共享区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

i期望变量"i"将达到最大值11,然后将取消"for"工作共享区域,代码为:

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

但是变量i的最大值为9998,我想这意味着工作共享区域没有被取消.

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

推荐答案

默认情况下,取消功能处于禁用状态,主要是出于性能方面的考虑.您必须通过将 cancel-var ICV设置为true来专门启用取消支持.唯一的方法是将环境变量OMP_CANCELLATION设置为true,例如:

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 ...

这篇关于为什么openMP取消构造不取消工作共享区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆