Quantcast
Channel: Intel® Software - Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1175

OpenMP task depend pointers and structs

$
0
0

I have got the following code:

int foo(pm_t* t_lb){
  int i;
  int BLOCK=4;
#pragma omp task default(none) shared(t_lb, BLOCK)  private(i) \
  depend (inout: t_lb->a)

  {
    for (i=1;i < 1000 + BLOCK; i++){
      
      t_lb->a[i] =1.0f; 
    }
  }
}
int main(){
  
  pm_t* pm = NULL;
  pm = (pm_t*)calloc(1,sizeof(pm_t));
  
  
  pm->a = (double*)malloc(1000*sizeof(double));

#pragma omp parallel
  {
    /* Obtain thread number */
    int tid = omp_get_thread_num();
    printf("Hello World from thread = %d\n", tid);
    
#pragma omp master
    {
      foo(pm);
    }
  }
  
  return 0;
  
}

The structs:

typedef struct st pm_t;

struct st {
  double* a;
  double* t_b;
};

If this is compiled with Intel 17.0.2.174 I get:

tasks.c(10): error: invalid entity for this variable list in omp clause
    depend (inout: t_lb->a)

However I can compile it if I change the depend list to 

depend (inout: t_lb)

This happens with the Intel and GNU compilers but it does not produce an error or warning with the Cray compiler. 

I guess my question is, is this a bug in the Intel/GNU compilers or they just follow the OpenMP standard rules? 

 

Zone: 


Viewing all articles
Browse latest Browse all 1175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>