On Thu, Aug 25, 2022 at 12:38 PM Alexandre Halbach < alexandre.halb...@gmail.com> wrote:
> Hello, > > I am using the metis package provided by the latest petsc version, using > --download-metis (Linux, 32 bits). This question is arguably more a metis > issue but since metis is used in petsc and mumps this seems relevant to ask > here too. > > I systematically get a segmentation fault on this metis version (didn't > try others) when I partition even simple and not too large graphs ( O(5 > millions)). I tried a lot of cases as well as both the 32 and 64 bits > version of petsc and also increasing ulimit (on Linux). > Here is the shortest possible representative example with that problem > (c++). I double checked it and I hope there is no mistake in this example. > The below example constructs the containers for a 1D line graph (n > vertices connected by edges one by one as in a chain. Both end vertices > only have a single neighbor while all other vertices have two neighbors). > Either this is something I am doing wrong or there is a bug in at least > the metis version proposed in petsc. > > Here is the example producing a segfault. If you don't get a segfault try > a 10 millions or more vertices graph. > You are exceeding the stack space. I will rewrite to malloc() and take a look. Thanks, Matt > Thank you for your help and your great work! > > Alex > > > #include "metis.h" > > int main(void) > { > // Number of vertices: > int n = 1000000; > // Addresses should for example be [0 1 3 5 7 8] for 5 vertices > idx_t addresses[n+1]; > addresses[0] = 0; addresses[1] = 1; > for (int i = 2; i < n; i++) > addresses[i] = addresses[i-1] + 2; > addresses[n] = addresses[n-1]+1; > > // Connected vertices should for example be [1 0 2 1 3 2 4 3] for 5 > vertices > idx_t connectivities[2*(n-1)]; > connectivities[0] = 1; > for (int i = 1; i < n-1; i++) > { > connectivities[2*i-1] = i-1; > connectivities[2*i+0] = i+1; > } > connectivities[2*(n-1)-1] = connectivities[2*(n-1)-2]-1; > > idx_t nvtxs = n; > idx_t nEdges = n-1; > > idx_t metisOptions[METIS_NOPTIONS]; > METIS_SetDefaultOptions(metisOptions); > metisOptions[METIS_OPTION_NUMBERING] = 0; // c numbering (start at 0) > > idx_t ncon = 1; > idx_t nParts = 2; > idx_t objval; > idx_t part[nvtxs]; > > int ret = METIS_PartGraphRecursive ( &nvtxs, &ncon, addresses, > connectivities, NULL, NULL, NULL, &nParts, NULL, NULL, metisOptions, > &objval, part ); > } > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>