-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array pointers in event messages? #129
Comments
You are correct, dynamic memory pointers are not dereferenced when they are shared between PEs. You'll have to write your own serializer and deserializers to pack and unpack into a static-memory byte array in the event struct. These have to be made for any dynamic memory in your event structs and said functions will have to be called at every event handler. It's better to entirely avoid dynamic memory in events. @caitlinross might have more insight about this and alternatives. |
I understand. Assuming that exchanging event messages with a pointer array between LPs in different PEs is not an option, is it possible to enforce that LPs (of the same type) in different PEs produce the same sequence of integers in RNG functions such as tw_rand_integer()? In case this is possible, I can have the specific LP that returns event messages with pointer array in the same PE as the requester, and my problem would be solved. |
I think it should be possible to do that. You'll need to utilize multiple RNGs in each LP - as you wouldn't want to force every LP's main RNG to have the same seed. What I'm imagining is that each LP would have two RNGs, one default one with a ROSS generated seed and one separate RNG with an identical seed as all other LPs used for your workaround. How exactly this would be done is not something I'm very familiar with. Might consider checking out this page from the wiki on the topic I'll check with others in the research group tomorrow about this. |
Neil is correct that you won't be able to send anything referenced by pointers through an event to another PE, without having someway to handle it. I think your RNG approach sounds like it's probably the way to go in this case. And I agree with Neil that you'll want multiple RNGs for each LP, with one being dedicated to your usual RNG use, and one for just producing this same sequence of integers on each LP. He's also right that you can use the default ROSS generated seed for one and for the other, use the identical seed on all LPs. So the basic idea of what you'll want to do in code: g_tw_nRNG_per_lp++; // default is 1
tw_define_lps(<whatever you usually pass in here>);
for (tw_lpid id = 0; id < g_tw_nlp; id++)
{
// so rng[0] would keep the default ROSS seed
// rng[1] would be the one that is the same on each LP
tw_rand_initial_seed(&g_tw_lp[id]->rng[1], <seed>);
} And that should be all you need! |
This alternative worked just fine. Thanks! |
Happy to hear it! |
Is it possible to have an array pointer into an event message?
E.g.:
typedef struct _message
{
event_type type;
int *array;
} message_t
When doing something like this example, I face a segmentation fault when the message is exchanged between LPs in different PEs. I think that only the pointer address is being sent.
The text was updated successfully, but these errors were encountered: