1 /*
2 *
3 * This file is part of MUMPS 5.1.2, released
4 * on Mon Oct 2 07:37:01 UTC 2017
5 *
6 *
7 * Copyright 1991-2017 CERFACS, CNRS, ENS Lyon, INP Toulouse, Inria,
8 * 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 * http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html
13 *
14 */
15 #include <stdio.h> /* For NULL constant (stddef.h) and debug printings */
16 #include "mumps_metis64.h"
17 #if defined(parmetis) || defined(parmetis3)
18 /*PARMETIS*/
19 #if defined(parmetis3)
20 /* Provide prototype by hand. This is because we are not sure
21 * at compilation/preprocessing time whether we use a 32-bit
22 * or a 64-bit metis */
23 void ParMETIS_V3_NodeND(MUMPS_INT8 *first, MUMPS_INT8 *vertloctab, MUMPS_INT8 *edgeloctab, MUMPS_INT *numflag, MUMPS_INT *options, MUMPS_INT8 *order, MUMPS_INT8 *sizes, MPI_Comm *Ccomm);
24 #else
25 #include "metis.h"
26 #include "parmetis.h" /* Prototypes from parmetis.h will be used */
27 #endif
28 void MUMPS_CALL
MUMPS_PARMETIS_64(MUMPS_INT8 * first,MUMPS_INT8 * vertloctab,MUMPS_INT8 * edgeloctab,MUMPS_INT * numflag,MUMPS_INT * options,MUMPS_INT8 * order,MUMPS_INT8 * sizes,MUMPS_INT * comm,MUMPS_INT * ierr)29 MUMPS_PARMETIS_64(MUMPS_INT8 *first, MUMPS_INT8 *vertloctab,
30 MUMPS_INT8 *edgeloctab,
31 #if defined(parmetis3)
32 MUMPS_INT *numflag, MUMPS_INT *options,
33 #else
34 MUMPS_INT8 *numflag, MUMPS_INT8 *options,
35 #endif
36 MUMPS_INT8 *order,
37 MUMPS_INT8 *sizes, MUMPS_INT *comm,
38 MUMPS_INT *ierr)
39 {
40 MPI_Comm int_comm;
41 #if defined(parmetis)
42 # if (IDXTYPEWIDTH == 64)
43 int iierr;
44 #endif
45 #endif
46 int_comm = MPI_Comm_f2c(*comm);
47 #if defined(parmetis3)
48 /* Prototype may not match with 32-bit integers and Parmetis3 */
49 ParMETIS_V3_NodeND(first, vertloctab, edgeloctab, numflag, options, order, sizes, &int_comm);
50 #elif defined(parmetis)
51 # if (IDXTYPEWIDTH == 64)
52 *ierr=0;
53 iierr=ParMETIS_V3_NodeND(first, vertloctab, edgeloctab, numflag, options, order, sizes, &int_comm);
54 if(iierr != METIS_OK)
55 *ierr=1;
56 # else
57 /* SHOULD NEVER BE CALLED */
58 printf("** Error: ParMETIS version >= 4, IDXTYPE WIDTH !=64, but MUMPS_PARMETIS_64 was called\n");
59 *ierr=1;
60 # endif
61 #endif
62 return;
63 }
64 #endif
65 #if defined(parmetis) || defined(metis) || defined(parmetis3) || defined(metis4)
66 #if defined(metis4) || defined(parmetis3) /* parmetis3 comes with metis4 */
67 /* Provide prototype by hand. This is because we are not sure
68 * at compilation/preprocessing time whether we use a 32-bit
69 * or a 64-bit metis */
70 void METIS_PartGraphKway(int *, MUMPS_INT8 *, MUMPS_INT8 *, MUMPS_INT8 *, MUMPS_INT8 *, int *, int *, int *, int *, int *, MUMPS_INT8 *);
71 #else
72 /* Prototype properly defined in metis.h
73 * One can rely on IDXTYPEWIDTH to know at compilation/preprocessing
74 * time whether we use a 32-bit or a 64-bit metis */
75 #include "metis.h"
76 #endif
77 /* Interface for metis k-way partitioning with 64-bit ints */
78 void MUMPS_CALL
MUMPS_METIS_KWAY_64(MUMPS_INT8 * n,MUMPS_INT8 * iptr,MUMPS_INT8 * jcn,MUMPS_INT8 * k,MUMPS_INT8 * part)79 MUMPS_METIS_KWAY_64(MUMPS_INT8 *n, MUMPS_INT8 *iptr,
80 MUMPS_INT8 *jcn, MUMPS_INT8 *k,
81 MUMPS_INT8 *part)
82 /* n -- the size of the graph to be partitioned
83 iptr -- pointer to the beginning of each node's adjacency list
84 jcn -- jcn[iptr[i]:iptr[i+1]-1] contains the list of neighbors of node i
85 k -- the number of parts
86 part -- part[i] is the part node i belongs to */
87 /* SELECTIVE I8 FIXME: add an argument *ierr, check it on exit */
88 {
89 #if defined(metis4) || defined(parmetis3)
90 MUMPS_INT numflag, edgecut, wgtflag, options[8];
91 MUMPS_INT kINT, nINT;
92 options[0] = 0;
93 /* unweighted partitioning */
94 wgtflag = 0;
95 /* Use 1-based fortran numbering */
96 numflag = 1;
97 /* n and k are MUMPS_INT */
98 nINT=(MUMPS_INT)(*n);
99 kINT=(MUMPS_INT)(*k);
100 /* void METIS_PartGraphKway(int *, idxtype *, idxtype *, idxtype *, idxtype *, int *, int *, int *, int *, int *, idxtype *); */
101 METIS_PartGraphKway(&nINT, iptr, jcn,
102 NULL, NULL, &wgtflag,
103 &numflag, &kINT,
104 options, &edgecut,
105 part);
106 #else /* METIS >= 5 */
107 int ierr;
108 # if (IDXTYPEWIDTH == 64)
109 MUMPS_INT8 ncon, edgecut, options[40];
110 ierr=METIS_SetDefaultOptions(options);
111 options[0] = 0;
112 /* Use 1-based fortran numbering */
113 options[17] = 1;
114 ncon = 1;
115 ierr = METIS_PartGraphKway(n, &ncon, iptr, jcn,
116 NULL, NULL, NULL,
117 k, NULL, NULL, options,
118 &edgecut, part);
119 # else
120 printf("** Error: METIS version >= 4, IDXTYPE WIDTH !=64, but MUMPS_METIS_KWAY_64 was called\n");
121 ierr=1;
122 # endif
123 #endif
124 return;
125 }
126 #endif
127