OpenMP任务依赖项:DAG调度

时间:2015-10-22 08:15:35

标签: openmp

OpenMP规范说:“在同一任务或兄弟任务的depend子句中使用的列表项必须指明相同的存储或不相交的存储。” (OpenMP 4.0规范,第117页,第14-15行)。

我不确定我是否正确理解了标准中的“不相交”描述。如果我使用数组来指定依赖项,例如:

int x[10];     //this is the data array which will be updated by various tasks (with dependencies)
int *tmp;      //max 3 dependencies, known at task creation time

#pragma omp parallel 
{ 
   #pragma omp single nowait
   {
      for(i=0; i<N; i++) {
          tmp = get_dependencies(i)         //for i=0 => tmp[0]=1, tmp[1]=3, tmp[2]=5  (the values 1,3,5 are actual dependencies)
                                            //for i=1 => tmp[0]=2, tmp[1]=3, tmp[2]=7
                                            //for i=2 => tmp[0]=0, tmp[1]=8, tmp[2]=9

          #pragma  omp task depend (inout:tmp[0], inout:tmp[1], inout:tmp[2] )       
          {
                        //task is going to updated values at x[ tmp[0] ],  x[ tmp[1] ],  x[ tmp[2] ]
          } 

      }
   }
}

所以我希望task1依赖于task0(因为x [tmp [1]],即x [3]将由task0更新,task1将使用,并且task2将独立。

或者我需要使用类似的东西吗?

 #pragma  omp task depend (inout:x[tmp[0]], inout:x[tmp[1]].....

OR

int *p = &x[tmp[0]];
int *q = &x[tmp[1]];
int *r = &x[tmp[2]];

 #pragma  omp task depend (inout:p[0], inout:q[0].....

1 个答案:

答案 0 :(得分:0)

好的..我在我们的应用程序中试过这个并且以下实现工作正常:

  #pragma  omp task depend (inout:x[tmp[0]], inout:x[tmp[1]].....

我假设&#34;脱节存储&#34;存储意味着使用&#34; x&#34;用于指定任务依赖项(不能使用指针来指定依赖项,如openmp论坛中所讨论的那样(请参阅第一个响应)here)。