jcduell_at_lbl_dot_gov
Date: Mon Dec 05 2005 - 10:58:41 PST
On Sun, Dec 04, 2005 at 08:21:26AM -0600, Steve Reinhardt wrote: > > typedef struct { > int a; > int b; > } gink; > > typedef struct { > int a; > int b; > shared gink *c; // private ptr to shared object > shared gink *shared d; // shared ptr to shared object > shared int *e; // private ptr to shared object > shared int *shared f; // shared ptr to shared object > } gink2; > > shared gink2 aa[10][THREADS]; > shared gink2 *shared cc[10][THREADS]; > Having played with variations on this theme, it appears that UPC > doesn't support a member of a structure that's a shared pointer to a > shared object. Is this so? Since UPC, like C, makes some guarantees about memory layout within structs, it can't create a struct in which some members are shared and some aren't. So the 'shared' keyword is illegal for a member declaration, unless it qualifies a type that is pointed to. But this doesn't mean you can't have shared structs--you just have to make the entire struct shared. You've done this already, here: shared gink2 aa[10][THREADS]; Each struct in aa can be accessed by any thread, and any 'c' member can be manipulated by any thread. So in effect 'c' *is* a 'shared gink *shared'. Does that suffice for your purposes, or are you running into type issues (i.e. do you need to treat the address of 'c' fields as 'shared gink *shared')? -- Jason Duell Future Technologies Group <jcduell_at_lbl_dot_gov> Computational Research Division Tel: +1-510-495-2354 Lawrence Berkeley National Laboratory