The declare target construct and Dynamic/Nested Parallelism

Discuss the OpenMP 4.0 API Specifications released July 2013 (Read Only)
Locked
guraynet
Posts: 2
Joined: Thu Nov 07, 2013 6:42 am

The declare target construct and Dynamic/Nested Parallelism

Post by guraynet »

I've question is related with declare target construct of OpenMP and dynamic/nested parallelism feature of GPUs. OpenACC 2.0 supports dynamic parallelism in two ways; routine directive and using parallel/kernels directives in nested way. But using nested device directives such as target, teams or distribute is prohibited in OpenMP. But declare target directive seems to me similar with routine directive of openacc.

However it's not still clear semantic and its usage. My sample code is like this.

Code: Select all

#pragma omp declare target
void foo(){

  //work-1

 #pragma omp target teams distribute parallel for 
 for(...)
 {
    if(...){
       foo();
    {
      //work-2
    }
 }

 //work-3
}
#pragma omp end declare target

int main(){
//work 

foo();

}
In that example, I am expecting that function foo will be mapped as device function. but since it has target construct inside, compiler will transform this code in some way. My question is here, what will happen when the threads encounters foo function invocation inside of target construct?

Locked