OpenMP的的任务任务调度点 [英] Task scheduling points of OpenMP tasks

查看:149
本文介绍了OpenMP的的任务任务调度点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code:

 的#pragma OMP并行
{
    OMP的#pragma单
    {
        为(节点* p值=头; P; P =对 - >接着)
        {
            preprocess(对);            OMP的#pragma任务
            过程(P);
        }
    }
}

我想知道做线程开始计算任务时。一旦任务使用#pragma OMP任务创建或创建的所有任务后,才?

编辑:

 为int *阵列=(INT *)malloc的...
OMP的#pragma并行
{
    OMP的#pragma单
    {
        而(...){
            preprocess(数组);            OMP的#pragma任务FIRSTPRIVATE(阵列)
            过程中(阵);
        }
    }
}


解决方案

在你的榜样,工作线程能够尽快,因为他们已经创建开始执行创建的任务。有没有必要在执行第一个任务之前等待创建各项任务的完成。

因此​​,基本上,第一个任务已经由生产者创建后,一名工人将它捡起并开始执行该任务。但是,注意,OpenMP运行时和编译器有这一定的自由。他们可能会推迟执行了一下,甚至执行到位的一些任务。

如果你想阅读有关的详细信息,您将需要通过在www.openmp.org OpenMP规范挖。这是一个有点难以阅读,但是它是信息的权威来源。

干杯,
        -Michael

I have the following code:

#pragma omp parallel
{
    #pragma omp single
    {
        for(node* p = head; p; p = p->next)
        {
            preprocess(p);

            #pragma omp task
            process(p);
        }
    }
}

I would like to know when do the threads start computing the tasks. As soon as the task is created with #pragma omp task or only after all tasks are created?

Edit:

int* array = (int*)malloc...
#pragma omp parallel
{
    #pragma omp single
    {
        while(...){
            preprocess(array);

            #pragma omp task firstprivate(array)
            process(array);
        }
    }
}

解决方案

In your example, the worker threads can start executing the created tasks as soon as they have been created. There's no need to wait for the completion of the creation of all tasks before the first task is executed.

So, basically, after the first task has been created by the producer, one worker will pick it up and start executing the task. However, be advised that the OpenMP runtime and compiler have certain freedom in this. They might defer execution a bit or even execute some of the tasks in place.

If you want to read up the details, you will need to dig through the OpenMP specification at www.openmp.org. It's a bit hard to read, but it is the definitive source of information.

Cheers, -michael

这篇关于OpenMP的的任务任务调度点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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