foreach() loop with MPI

272 views
Skip to first unread message

Ayoub Mansar

unread,
Nov 16, 2022, 8:56:23 AM11/16/22
to basilisk-fr
Hello everyone, 
I am using a basilisk program in which I store some data using a foreach() loop over cells, the problem is that it works fine on serial, but as soon as I run it with MPI on a cluster I noticed that it only loops over a square 3D piece of my domain and not all of it.
I tried to force it by using foreach(serial), but I get the same results.
Any thoughts on what is causing that ?
Thanks in advance !
Ayoub,

Ayoub Mansar

unread,
Nov 16, 2022, 11:06:00 AM11/16/22
to basilisk-fr
I'll be very gatreful if anyone has an indication about this, I've been stuck for too long.
Thank you 

Yi Dai

unread,
Nov 17, 2022, 7:31:55 AM11/17/22
to basilisk-fr
Hi Ayoub, 
Since there is no information about your foreach() loop, maybe Antoon's illustration can be help here: http://basilisk.fr/sandbox/Antoonvh/The_Tree-Grid_Structure_in_Basilisk#indexing-and-mpi-load-balancing

shine Sun

unread,
Nov 18, 2022, 4:57:29 AM11/18/22
to basilisk-fr
Hello  Ayoub,
The foreach() function loops over the cells within the domain of each MPI thread. Maybe you should output the result for each thread seperately.
Cheers!
Shine Sun

shine Sun

unread,
Nov 21, 2022, 8:55:26 AM11/21/22
to basilisk-fr
Hello Ayoub,
In my experience, I just specify the output file name with the pid() number and remember that every processor outputs its own domain cells. For example, 
sprintf(fp, "output_%d", pid());
foreach() {
  ...
}
And every processor will output its file correctly in my simulations.
Hope this helps!
Shine Sun

Ayoub Mansar

unread,
Nov 24, 2022, 3:54:13 AM11/24/22
to basilisk-fr
Hello Shine  and Dyzr,
It worked fine printing with pid() !
Thank you so much for your help,
Ayoub

Ning Wang

unread,
Feb 15, 2023, 11:12:27 AM2/15/23
to basilisk-fr
Hello Shine,  Ayoub and Dyzr,

When I output data and write it to a file, whether serial or parallel, I always get missing columns for certain rows of data in the file, e.g. the top and bottom rows of this row have 8 data, but this row only has 5
If you have any comments about this please send me a reply
Thank you
Ning Wang

2022年11月24日木曜日 16:54:13 UTC+8 ayoubm...@gmail.com:
bump.c
Reply all
Reply to author
Forward
0 new messages