Octopus
metis_f.c
Go to the documentation of this file.
1/*
2 Copyright (C) 2013 M. Oliveira
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18
19*/
20
21#include <config.h>
22
23#include <stdlib.h>
24
25#if defined(HAVE_METIS)
26#include <metis.h>
27#endif
28#if defined(HAVE_PARMETIS)
29#include <mpi.h>
30#include <parmetis.h>
31#endif
32
33#ifdef HAVE_METIS
34
35#if defined(METIS_USE_DOUBLEPRECISION) || REALTYPEWIDTH == 64
36#error METIS must be compiled in single precision for Octopus.
37#endif
38
39void FC_FUNC_(oct_metis_setdefaultoptions,
40 OCT_METIS_SETDEFAULTOPTIONS)(idx_t *options) {
41 METIS_SetDefaultOptions(options);
42}
43
44int FC_FUNC_(oct_metis_partgraphrecursive, OCT_METIS_PARTGRAPHRECURSIVE)(
45 idx_t *nvtxs, idx_t *ncon, idx_t *xadj, idx_t *adjncy, idx_t *nparts,
46 real_t *tpwgts, real_t *ubvec, idx_t *options, idx_t *objval, idx_t *part) {
47
48 return METIS_PartGraphRecursive(nvtxs, ncon, xadj, adjncy, NULL, NULL, NULL,
49 nparts, tpwgts, ubvec, options, objval, part);
50}
51
52int FC_FUNC_(oct_metis_partgraphkway, OCT_METIS_PARTGRAPHKWAY)(
53 idx_t *nvtxs, idx_t *ncon, idx_t *xadj, idx_t *adjncy, idx_t *nparts,
54 real_t *tpwgts, real_t *ubvec, idx_t *options, idx_t *objval, idx_t *part) {
55
56 return METIS_PartGraphKway(nvtxs, ncon, xadj, adjncy, NULL, NULL, NULL,
57 nparts, tpwgts, ubvec, options, objval, part);
58}
59
60#endif
61
62#ifdef HAVE_PARMETIS
63
64void FC_FUNC_(oct_parmetis_v3_partkway,
65 OCT_PARMETIS_V3_PARTKWAY)(idx_t *vtxdist, idx_t *xadj, idx_t *adjncy,
66 idx_t *ncon, idx_t *nparts, real_t *tpwgts,
67 real_t *ubvec, idx_t *options,
68 idx_t *edgecut, idx_t *part,
69 MPI_Fint *fcomm) {
70 idx_t wgtflag = 0, numflag = 1;
71
72 MPI_Comm comm;
73
74 comm = MPI_Comm_f2c(*fcomm);
75
76 ParMETIS_V3_PartKway(vtxdist, xadj, adjncy, NULL, NULL, &wgtflag, &numflag,
77 ncon, nparts, tpwgts, ubvec, options, edgecut, part,
78 &comm);
79}
81#endif