copy structure

General OpenMP discussion
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help: https://stackoverflow.com/questions/tagged/openmp
Locked
pdupre
Posts: 10
Joined: Wed Jan 11, 2017 7:21 am

copy structure

Post by pdupre »

Hello,

I have a structure that I partially set up before the parallel loop
I would like to have a new copy of this structure for each thread
because the loop is going to modify this structure.

How can I do that?
Thanks

pdupre
Posts: 10
Joined: Wed Jan 11, 2017 7:21 am

Re: copy structure

Post by pdupre »

If I can be more specific

I have
param_int_str param_ ;
I initialize the structure param_
This structure has a variable (another structure param) whose I get the elements through its address

param_str *ptr_param_ = &(param_.param) ;
only in the parallel loop.
This does not works.
I guess that when I enter in the loop I need to "copy" param_
(i.e. copy the structure param_ at another address as is), and then I could access to the
element param_.param (which is a dynamic structure)

MarkB
Posts: 808
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: copy structure

Post by MarkB »

Is the substructure dynamically allocated? And if, so when (before or during the parallel region)? What is the data-sharing attribute of the structure (shared/private/firstprivate) on the parallel region? Some sketch code would be helpful!

Locked