Try to add Scotch library as a fallback instead of METIS in mesh partition
METIS is used for mesh partition in CGAL::METIS::partition_graph() and CGAL::METIS::partition_dual_graph().
I would be interesting to add variant using the scotch library to compare it against METIS.
Hello @sloriot, I am interested in contributing to CGAL & would like to work on this issue. Is anyone currently working on it, or can I take it up?
Hi @sloriot,
I would like to help implement the Scotch fallback for mesh partitioning.
Looking at how METIS is integrated in BGL/include/CGAL/boost/graph/METIS/ and Installation/cmake/modules/FindMETIS.cmake, my proposed approach would be:
- Add
Installation/cmake/modules/FindScotch.cmaketo detect Scotch headers (scotch.h) andlibscotch. - Implement
partition_graph()andpartition_dual_graph()underBGL/include/CGAL/boost/graph/Scotch/, converting CGAL graph / dual graph adjacency into Scotch's CSR format (SCOTCH_graphBuild/SCOTCH_graphPart). - Add a benchmark / comparison test referencing
BGL/examples/BGL_surface_mesh/surface_mesh_partition.cppto compare partition quality (edge cut) and runtime between METIS and Scotch.
Does this alignment look good to you, or do you have any specific preferences regarding the CMake configuration or API structure? If this is good, I can get started on this.
There is no need for a FindScotch.cmake but CGAL_Scotch_support.cmake. I think it does support cmake config mode.
About the code, I think I read that there is in Scotch a METIS compatibility API. So it should be rather easy using that API to get a first prototype.
@Ayush-CS-89112521 @vedpanvar You might want to coordinate to work together if you are interested in playing with this issue.
Thanks for the pointers @sloriot, using CGAL_Scotch_support.cmake and Scotch's METIS compatibility API makes complete sense.
@vedpanvar Happy to coordinate and work together on this! How would you like to split it up?
Hi @Ayush-CS-89112521,
Happy to collaborate on this!
Since @sloriot suggested using Scotch's METIS compatibility API, I think we can split the work as follows :)
I can investigate the METIS compatibility API, build a small prototype, and test whether Scotch works with CGAL's existing mesh partitioning functions.
And You could handle the CMake integration using CGAL_Scotch_support.cmake and the required linking configuration.
Once we both get done, we will integrate the changes and run the necessary tests for this issue.
& We can coordinate on a shared branch and submit a single PR with both contributions.
does this approach sounds good to you.!?
Hi @vedpanvar,
Sounds good to me! A joint PR is a great idea.
I am working on the CGAL_Scotch_support.cmake integration locally. You can go ahead with the prototype, and we can test and combine our changes together once you're ready!
Quick update: I've pushed the initial CGAL_Scotch_support.cmake integration to my branch here:
https://github.com/Ayush-CS-89112521/cgal/tree/scotch-cmake-support
@vedpanvar feel free to fetch it and build your prototype against it. Once ready, we can test and integrate everything together based on maintainer feedback!
hey @Ayush-CS-89112521 i have tested the Scotch compatibility path locally on MSYS2 UCRT64 using Scotch 7.0.12.
I successfully compiled and ran a minimal test that calls CGAL's actual partition_dual_graph() implementation on a two-triangle Surface_mesh. It linked against Scotch's METIS compatibility library and exited with code 0.
One important finding: Scotch's compatibility metis.h exposes METIS_PartMeshDual and METIS_SetDefaultOptions, but does not declare METIS_PartMeshNodal, which CGAL uses in partition_graph().
I haven't tested the CMake fallback yet and My next step is to verify your CGAL_Scotch_support.cmake module and try building the actual surface mesh partitioning example with METIS unavailable and Scotch installed.
This will help us to identify whether the current implementation is sufficient or not.!
8. Quick update: I've pushed the initial
CGAL_Scotch_support.cmakeintegration to my branch here: https://github.com/Ayush-CS-89112521/cgal/tree/scotch-cmake-support @vedpanvar feel free to fetch it and build your prototype against it. Once ready, we can test and integrate everything together based on maintainer feedback!
Looks good. Some comment: If Scotch supports config mode of cmake, then we don't need to have the else() part.
Thanks @sloriot and @vedpanvar for testing and feedback!
Regarding CMake Config Mode (@sloriot):
Scotch 7+ (MSYS2, vcpkg, and upstream CMake) provides ScotchConfig.cmake. The else() block was added because standard Debian/Ubuntu packages (libscotch-dev) still build without CMake configs. If CGAL prefers strictly config-driven modules, I'm happy to drop the else() block (or move it to a FindScotch.cmake if distro packages are desired). Please let me know your preferred direction.
Regarding METIS_PartMeshNodal & Example (@vedpanvar):
Scotch's compatibility layer implements METIS_PartMeshDual, but not METIS_PartMeshNodal.
CGAL::METIS::partition_dual_graph()powers thesurface_mesh_partitionexample. I've tested building and running this example with METIS disabled and Scotch enabled locally, and it runs and partitions cleanly.- For
partition_graph(), I've added a compile-timestatic_assertso users get an informative diagnostic instead of an undefined symbol link error.
I do see it libscotch-dev_7.0.17-2_amd64.deb for sid but not for the version in stable so it indeed makes sense.
Hey @Ayush-CS-89112521 i have completed and pushed my Scotch compatibility changes to my fork.
Branch: scotch-cpp-prototype
https://github.com/vedpanvar/cgal/tree/scotch-cpp-prototype
The changes include:
- Explicit Scotch header inclusion and removal of forced include.
- A clear compile-time diagnostic for
partition_graph()because Scotch doesn't provideMETIS_PartMeshNodal(). - Validation using Scotch 7.0.12, including the actual
partition_dual_graph()example.
I've committed and pushed everything. Let's coordinate on integrating this with your scotch-cmake-support branch and prepare our joint PR!