OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
mumps_metis.c
Go to the documentation of this file.
1/*
2 *
3 * This file is part of MUMPS 5.5.1, released
4 * on Tue Jul 12 13:17:24 UTC 2022
5 *
6 *
7 * Copyright 1991-2022 CERFACS, CNRS, ENS Lyon, INP Toulouse, Inria,
8 * Mumps Technologies, University of Bordeaux.
9 *
10 * This version of MUMPS is provided to you free of charge. It is
11 * released under the CeCILL-C license
12 * (see doc/CeCILL-C_V1-en.txt, doc/CeCILL-C_V1-fr.txt, and
13 * https://cecill.info/licences/Licence_CeCILL-C_V1-en.html)
14 *
15 */
16#include <stdio.h> /* For NULL constant (stddef.h) and debug printings */
17#include "mumps_metis.h"
18#if defined(parmetis) || defined(parmetis3)
19/*PARMETIS*/
20#if defined(parmetis3)
21/* Provide prototype by hand. This is because we are not sure
22 * at compilation/preprocessing time whether we use a 32-bit
23 * or a 64-bit metis */
24 void ParMETIS_V3_NodeND(MUMPS_INT *first, MUMPS_INT *vertloctab, MUMPS_INT *edgeloctab, MUMPS_INT *numflag, MUMPS_INT *options, MUMPS_INT *order, MUMPS_INT *sizes, MPI_Comm *Ccomm);
25#else
26#include "metis.h"
27#include "parmetis.h" /* Prototypes from parmetis.h will be used */
28#endif
29void MUMPS_CALL
30MUMPS_PARMETIS(MUMPS_INT *first, MUMPS_INT *vertloctab,
31 MUMPS_INT *edgeloctab, MUMPS_INT *numflag,
32 MUMPS_INT *options, MUMPS_INT *order,
33 MUMPS_INT *sizes, MUMPS_INT *comm,
34 MUMPS_INT *ierr)
35{
36 MPI_Comm int_comm;
37 int iierr;
38 int_comm = MPI_Comm_f2c(*comm);
39#if defined(parmetis3)
40 ParMETIS_V3_NodeND(first, vertloctab, edgeloctab, numflag, options, order, sizes, &int_comm);
41#elif defined(parmetis)
42# if (IDXTYPEWIDTH == 32)
43 *ierr=0;
44 iierr=ParMETIS_V3_NodeND(first, vertloctab, edgeloctab, numflag, options, order, sizes, &int_comm);
45 if(iierr != METIS_OK)
46 *ierr=1;
47# else
48 /* SHOULD NEVER BE CALLED */
49 printf("** Error: ParMETIS version >= 4, IDXTYPE WIDTH !=64, but MUMPS_PARMETIS_64 was called\n");
50 *ierr=1;
51# endif
52#endif
53 return;
54}
55#endif
56#if defined(parmetis) || defined(metis) || defined(parmetis3) || defined(metis4)
57#if defined(metis4) || defined(parmetis3) /* parmetis3 comes with metis4 */
58/* Provide prototype by hand. This is because we are not sure
59 * at compilation/preprocessing time whether we use a 32-bit
60 * or a 64-bit metis */
61void METIS_PartGraphKway(int *, MUMPS_INT *, MUMPS_INT *, MUMPS_INT *, MUMPS_INT *, int *, int *, int *, int *, int *, MUMPS_INT *);
62#else
63/* Prototype properly defined in metis.h
64 * One can rely on IDXTYPEWIDTH to know at compilation/preprocessing
65 * time whether we use a 32-bit or a 64-bit metis */
66#include "metis.h"
67#endif
68/* Interface for metis k-way partitioning with standard ints */
69void MUMPS_CALL
70MUMPS_METIS_KWAY(MUMPS_INT *n, MUMPS_INT *iptr,
71 MUMPS_INT *jcn, MUMPS_INT *k,
72 MUMPS_INT *part)
73/* n -- the size of the graph to be partitioned
74 iptr -- pointer to the beginning of each node's adjacency list
75 jcn -- jcn[iptr[i]:iptr[i+1]-1] contains the list of neighbors of node i
76 k -- the number of parts
77 part -- part[i] is the part node i belongs to */
78 {
79#if defined(metis4) || defined(parmetis3)
80 MUMPS_INT numflag, edgecut, wgtflag, options[8];
81 options[0] = 0;
82 /* unweighted partitioning */
83 wgtflag = 0;
84 /* Use 1-based fortran numbering */
85 numflag = 1;
86/* void METIS_PartGraphKway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); */
87 METIS_PartGraphKway(n, iptr, jcn,
88 NULL, NULL, &wgtflag,
89 &numflag, k,
90 options, &edgecut,
91 part);
92#else /* METIS >= 5 */
93 int ierr;
94# if (IDXTYPEWIDTH == 32)
95 MUMPS_INT ncon, edgecut, options[40];
96 ierr=METIS_SetDefaultOptions(options);
97 options[0] = 0;
98 /* Use 1-based fortran numbering */
99 options[17] = 1;
100 ncon = 1;
101 ierr = METIS_PartGraphKway(n, &ncon, iptr, jcn,
102 NULL, NULL, NULL,
103 k, NULL, NULL, options,
104 &edgecut, part);
105# else
106 /* SHOULD NEVER BE CALLED */
107 printf("** Error: METIS version >= 4, IDXTYPE WIDTH !=32, but MUMPS_METIS_KWAY was called\n");
108 ierr=1;
109# endif
110#endif
111 return;
112 }
113/* Interface for metis k-way partitioning with standard ints and weights on vertices*/
114void MUMPS_CALL
115MUMPS_METIS_KWAY_AB(MUMPS_INT *n, MUMPS_INT *iptr,
116 MUMPS_INT *jcn, MUMPS_INT *k,
117 MUMPS_INT *part, MUMPS_INT *vwgt)
118/* n -- the size of the graph to be partitioned
119 iptr -- pointer to the beginning of each node's adjacency list
120 jcn -- jcn[iptr[i]:iptr[i+1]-1] contains the list of neighbors of node i
121 k -- the number of parts
122 part -- part[i] is the part node i belongs to
123 vwgt -- weights of the vertices*/
124 {
125#if defined(metis4) || defined(parmetis3)
126 MUMPS_INT numflag, edgecut, wgtflag, options[8];
127 options[0] = 0;
128 /* unweighted partitioning */
129 wgtflag = 0;
130 /* Use 1-based fortran numbering */
131 numflag = 1;
132/* void METIS_PartGraphKway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); */
133 METIS_PartGraphKway(n, iptr, jcn,
134 vwgt, NULL, &wgtflag,
135 &numflag, k,
136 options, &edgecut,
137 part);
138#else /* METIS >= 5 */
139 int ierr;
140# if (IDXTYPEWIDTH == 32)
141 MUMPS_INT ncon, edgecut, options[40];
142 ierr=METIS_SetDefaultOptions(options);
143 options[0] = 0;
144 /* Use 1-based fortran numbering */
145 options[17] = 1;
146 ncon = 1;
147 ierr = METIS_PartGraphKway(n, &ncon, iptr, jcn,
148 vwgt, NULL, NULL,
149 k, NULL, NULL, options,
150 &edgecut, part);
151# else
152 /* SHOULD NEVER BE CALLED */
153 printf("** Error: METIS version >= 4, IDXTYPE WIDTH !=32, but MUMPS_METIS_KWAY_AB was called\n");
154 ierr=1;
155# endif
156#endif
157 return;
158 }
159#endif
int METIS_PartGraphKway(int *NELEM, int *NCOND, int *XADJ, int *ADJNCY, int *IWD, int *vsize, int *ADJWGT2, int *NNODE, float *tpwgts, float *UBVEC, int *OPTIONS, int *NEC, int *CEP)
LIBSEQ_INT MPI_Comm
Definition mpi.h:50
#define MUMPS_INT
#define MUMPS_CALL
n