[Omp] Private the pointer (c/c++)

ThanhVu H. Nguyen - Gmail nguyenthanhvuh at gmail.com
Fri Jul 15 10:29:40 PDT 2005


Hi, I would like to private the values in memories by a pointer.  Would
it be possible to do so w/ openmp ?    Or I would have to create a
temporary array to hold its values which would take too much memory if
the array is large?  What is the elegant and common way to deal with
this ?  Thanks,  

Here's a quick example (which causes segfault :P)  


  int **ptr  = new int *[100] ;
  for (int i = 0 ; i < 100 ;++i){
    ptr[i] =  new int(i*10);
  }

#pragma omp parallel for private(ptr)  
  for (int i = 0 ; i < 2 ;++i){
    *ptr[10]=-1;   //my goal is to not have this affect the global. 
  }


  for (int i = 0 ; i < 100 ;++i){
    assert(*ptr[i]==i*10);
  }

-uu-:---F1  3.cc           Fri Jul 15 13:26 2.52   (C++ Abbrev)--L10--C0--Bot---

tvn,

ThanhVu H. Nguyen




More information about the Omp mailing list