[Omp] Working with threadprivate elements of structs

Breshears, Clay clay.breshears at intel.com
Fri Jan 9 15:45:04 PST 2004


I need to have a threadprivate array that is pointed to by a
threadprivate struct.  How do I declare and initialize these so they all
refer to the correct versions?

In a C code, I have an array that needs to be threadprivate.  The
original serial code also includes a struct (used as a descriptor to
carry additional information about the array and its contents) that is
also used as a parameter to some function calls.  The fields of the
descriptor instances are statically initialized at declaration time.
For example, the serial code looks something like:

ct_data static_ltree[100];

typedef struct tree_desc {
   ct_data *tree;
   int max_length;
   int max_code;
} tree_desc;

tree_desc l_desc = {static_ltree, MAX_LEN, 0};

If I put in pragmas to set static_ltree and l_desc to be threadprivate,
how can I guarantee that each thread's copy of static_ltree will be
pointed to by that same thread's copy of l_desc?  Do I need to use a
"dummy" parallel region to access static_ltree and initialize l_desc in
parallel to make sure the desired linkage occurs?  Does the static
initialization of l_desc suffice to hook things up correctly?  Is there
a better or simpler way?

Thanks in advance for any help or advice.

						clay
--
Clay Breshears   
Parallel Applications Engineer
KAI Software Labs, a division of Intel Americas, Inc.   
phone: 217-403-4206  fax: 217-403-4399

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openmp.org/pipermail/omp/attachments/20040109/66eadd10/attachment.html


More information about the Omp mailing list