-
Notifications
You must be signed in to change notification settings - Fork 114
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
Update points example #212
Update points example #212
Conversation
example/points/Makefile.am
Outdated
@@ -7,12 +7,19 @@ if P4EST_ENABLE_BUILD_2D | |||
bin_PROGRAMS += example/points/p4est_points | |||
example_points_p4est_points_SOURCES = example/points/points2.c | |||
|
|||
bin_PROGRAMS += example/points/p4est_generate_points |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks; what about renaming to p4est_points_generate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok will do.
example/points/generate_points.c
Outdated
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifdef THREED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro THREED is unusual in all of p4est. Users might think that this is a convention they should copy in their own code. Is it possible to rely on P4_TO_P8 exclusively, like in the rest of p4est?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I will turn generate_points.c
into generate_points2.c
and generate_points3.c
and define P4_TO_P8 in the later.
example/points/Makefile.am
Outdated
LINT_CSOURCES += $(example_points_p4est_points_SOURCES) | ||
endif | ||
|
||
if P4EST_ENABLE_BUILD_3D | ||
bin_PROGRAMS += example/points/p8est_points | ||
example_points_p8est_points_SOURCES = example/points/points3.c | ||
|
||
bin_PROGRAMS += example/points/p8est_generate_points | ||
example_points_p8est_generate_points_SOURCES = example/points/generate_points.c | ||
example_points_p8est_generate_points_CPPFLAGS = -DTHREED $(AM_CPPFLAGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below comment; such a THREED macro is usually not necessary in how we write dimension-dependent code.
example/points/generate_points.c
Outdated
|
||
|
||
static void | ||
generate_points (const char *filename, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this file compile when MPIIO is not enabled (try --disable-mpiio)? This relates to libsc, where MPI_File_get_view etc. are defined with MPIIO, but have no correspondence without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, MPIIO is required. We can disable building this example when mpi-io is not available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine for now. @tim-griesbach do you see a way to abstract the MPI I/O status away in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can abstract the MPI I/O status away using the functions sc_io_open
, sc_io_write_at_all
, sc_io_read_at_all
and sc_io_close
since these functions work also without MPI I/O or even without MPI.
However, in points2.c
the number of points on reading is currently determined using the file size. Up to my understanding this does not work without MPI I/O in a general portable way by just relying on the C standard (cf. https://wiki.sei.cmu.edu/confluence/display/c/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file).
We can solve this problem by writing the number of points to the file. Assuming this adjustment we shall obtain code that produces equivalent files with and without MPI I/O.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want, I can adjust the code as described above.
Thanks; I've merged the prerequisites in libsc! I'm wondering whether the example itself may survive without MPIIO, just not the file generation -- is there a way? |
This sounds all good. If points works generally with a change to the file format and using |
I pushed changes to use the During testing my changes I observed different behavior of Therefore, I adjusted |
Would it be possible to rebase this branch on the latest develop without touching sc in the history? |
I think commit b571e91 should be modified not to update sc git submodule; then the rebase would be easier. |
> Would it be possible to rebase this branch on the latest develop without touching sc in the history?
I think commit b571e91 should be modified not to update sc git submodule; then the rebase would be easier.
Is it possible to fix this during the rebase? When basing on develop, the
sc submodule will always be the same at 04ec24f6869c08a7b76c14ce7684e9952.
|
a809c10
to
2980811
Compare
points2 and points3 were deactivate from cmake build system, with comments stating that there is points data file. Here we add an executable generate_points to create some example points data. - the difference is that now there only a single data file (not a data file per MPI process), - point data are written by executable generate_point2/generate_point3 and read by points2/points3 using MPI-IO, so this branch need an upto data version of libsc (at least branch update-mpiio) - by using mpi-io this executable is more flexible, we can change the number of mpi process easily (no need to regenerate input data points) Example of run: - mpirun -np 4 ./generate_points2 unit 8192 data2d - mpirun -np 4 ./points2 unit 10 10 data2d
- rename and split generate_points.c into generate_points2.c and generate_points3.c - make sure this example is built only if mpi-io is enabled
2980811
to
83f068d
Compare
Hi @cburstedde |
Thanks so much, I'll take a look! |
Thanks! This is all very nice now. You gave me some motivation to write some outstanding documentation as well, I hope you don't mind I pushed it onto your PR. I've also used the p4est partition formulas for reference, even though your formulas work just fine as well! I see that the generation of points is independent of the connectivity. I'm wondering whether we should do something about that, but otoh we may all have better things to do right now. I'm ready to merge as is. |
A note to @tim-griesbach: This example nicely demonstrates use of some sc_io functions. How hard would it be to introduce proper error handling, to make this example instructive and representative of safe I/O code in p4est? |
It should be easy to add in the case of an I/O error the conversion of the error code to an error string using Then we could print the error string to inform the user about the specific error. If an I/O error occurs we would still abort after printing the error string. |
Thanks all, I've updated #211 with the current status and ammerging now. |
Update points example
Following up on issue #211
Proposed changes:
Currently this can only be merged when companion MR cburstedde/libsc#128 which update MPI-IO routines in libsc is merge to.
The executable that generate point data file need these mpi-io routines in libsc.