Skip to content
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

EPIC sdp2input/pvm2sdp refactoring + parallel reading optimization #176

Merged
merged 16 commits into from
Jan 24, 2024

Conversation

vasdommes
Copy link
Collaborator

  • Major refactoring of spd2input/pvm2sdp and related code, preparing the code to create a unified pmp2sdp executable handling all formats (.xml, .json, .m). As a byproduct, both sdp2input and pvm2sdp can now read all formats too.
  • remove spectrum --format option, now it's determined automatically.
  • New JSON parser allowing to skip array elements.
  • Fix File reading in sdp2input/pvm2sdp is not parallelized #150
    In old version, every process was reading all input files (and picking the matrices it needed). Now input files are distributed among processes according to compute_block_grid_mapping() algorithm (with file size used as a cost), similar to SDPB block distribution.
    Each group of processes gets one or more input files. Matrices from these files are distributed among the processes in a round-robin way.
  • Added more checks for Polynomial_Matrix_Program and output sdp blocks.

TODO: obsolete test files moved to outer_limits/toy/ directory, review and use or delete them!
TODO: test also sdp2functions
TODO: add realistic tests, e.g. using end-to-end data
…ates.

Previous message incorrectly assumed (procsPerNode/procGranularity) core groups per node.
In fact, big blocks can be assigned to big groups, containing more than procGranularity cores.
The actual number of core groups per node lies in [1, procsPerNode/procGranularity] range.
Introduced PMWP_File_Parse_Result and PMWP_SDP classes to handle parsing data.
(PMWP is Positive_Matrix_With_Prefactor used in json/mathematica input).

As a byproduct:
fix #152 spectrum not working in parallel
(fixed by treating local and global block indices more accurately)

TODO:
- Same refactoring for pvm2sdp
- More efficient IO parallelization, see #150
Introduced PVM_File_Parse_Result and PVM_SDP classes to handle parsing data.
(PVM is Polynomial_Vector_Matrix used in xml input).

Removed duplicated code from pvm2sdp

TODO:
- More efficient IO parallelization, see #150
- lots of code is duplicated for PVM and PMWP. We should deduplicate it, e.g. convert from one format to another when possible.
- Make new executables which can read both formats, i.e. combine pvm2sdp + sdp2input, pvm2functions + sdp2functions, spectrum --format).
Allows to use Verbosity in boost::program_options without conversion from int_verbosity.
TODO better and unified parser design - states, callbacks etc.
TODO optimize: skip matrices, avoid excessive copying
TODO remove spectrum format
TODO merge pvm2... and sdp2...
TODO update docs
Input file format is now determined automatically.
Also:
- added unit_tests for json
- return PMP_File_Parse_Result from read_json(), read_mathematica(), read_xml()
- Introduce PMP_File_Parse_Result::read() instead of constructor

TODO reuse the new parser in sdp2functions etc.
…b_util/block_mapping

The code will be reused by read_polynomial_matrix_program()
Parallelization algorithm:
- Input files are distributed among (groups of) processes via compute_block_grid_mapping()
- Within each group, matrices from input files are distributed in a round-robin way

TODO: since IO is often a bottleneck, we can reduce it:
root of each group copies file content to a shared memory window,
and other processes read it.
…nomial_Vector>

This is a simple std::vector<Polynomial> with function Zero().

On Expanse HPC, compilation of El::Matrix<std::vector<Polynomial> failed with
error: 'class std::vector<Polynomial>' has no member named 'Zero'

Zero() is (sometimes) called by El::MemZero() when allocating memory to matrix.
@vasdommes vasdommes added this to the 2.7.0 milestone Jan 23, 2024
@vasdommes vasdommes changed the title EPIC sdpinput/pmp2sdp refactoring + Fix #150 File reading in sdp2input/pvm2sdp is not parallelized EPIC sdp2input/pvm2sdp refactoring + Fix #150 File reading in sdp2input/pvm2sdp is not parallelized Jan 23, 2024
@vasdommes
Copy link
Collaborator Author

These plots show dramatic improvement of sdp2input reading time for GNY problems of different size (nmax=8, 18, 22). Timing data - from Expanse HPC.

Note that for large problems writing to zip archive becomes a bottleneck. It is done by a single process and cannot be parallelized.

image
image
image

@vasdommes vasdommes changed the title EPIC sdp2input/pvm2sdp refactoring + Fix #150 File reading in sdp2input/pvm2sdp is not parallelized EPIC sdp2input/pvm2sdp refactoring + parallel reading optimization Jan 24, 2024
@vasdommes vasdommes merged commit e226001 into master Jan 24, 2024
2 checks passed
@vasdommes vasdommes deleted the parallel-pmp-read branch January 24, 2024 05:36
vasdommes referenced this pull request in bharathr98/sdpb Feb 8, 2024
Copied over wscript, @vasdommes had already made a few changes from waf to cmake. Cleaned up, and added more TODOs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File reading in sdp2input/pvm2sdp is not parallelized
1 participant