14 #ifndef _ZOLTAN2_ALGAMD_HPP_
15 #define _ZOLTAN2_ALGAMD_HPP_
23 #ifdef HAVE_ZOLTAN2_AMD
25 #ifdef SUITESPARSE_MAIN_VERSION
26 #if SUITESPARSE_MAIN_VERSION < 4
27 typedef UF_long SuiteSparse_long;
37 #ifdef HAVE_ZOLTAN2_AMD
38 template <
typename Ordinal>
42 Ordinal order(Ordinal n,
const Ordinal *Ap,
const Ordinal *Ai,
43 Ordinal *perm,
double *control,
double *info);
50 int order(
int n,
const int *Ap,
const int *Ai,
int *perm,
51 double *control,
double *info)
53 return (amd_order(n, Ap, Ai, perm, control, info));
58 class AMDTraits<SuiteSparse_long>
61 long order(SuiteSparse_long n,
const SuiteSparse_long *Ap,
62 const SuiteSparse_long *Ai, SuiteSparse_long *perm,
63 double *control,
double *info)
65 return (amd_l_order(n, Ap, Ai, perm, control, info));
76 template <
typename Adapter>
81 const RCP<const typename Adapter::base_adapter_t> adapter;
82 const RCP<Teuchos::ParameterList> pl;
83 const RCP<const Teuchos::Comm<int> > comm;
84 RCP<const Environment> env;
90 const RCP<const typename Adapter::base_adapter_t> &adapter__,
91 const RCP<Teuchos::ParameterList> &pl__,
92 const RCP<
const Teuchos::Comm<int> > &comm__,
93 RCP<const Environment> &env__,
95 ) : adapter(adapter__), pl(pl__), comm(comm__), env(env__), graphFlags(graphFlags__)
100 throw std::logic_error(
"AlgAMD does not yet support global ordering.");
106 #ifndef HAVE_ZOLTAN2_AMD
108 throw std::runtime_error(
109 "BUILD ERROR: AMD requested but not compiled into Zoltan2.\n"
110 "Please set CMake flag Zoltan2_ENABLE_AMD:BOOL=ON.");
114 typedef typename Adapter::offset_t offset_t;
115 typedef typename Adapter::scalar_t
scalar_t;
120 const size_t nVtx = model->getLocalNumVertices();
123 ArrayView<const gno_t> edgeIds;
124 ArrayView<const offset_t> offsets;
125 ArrayView<StridedData<lno_t, scalar_t> > wgts;
128 model->getEdgeList(edgeIds, offsets, wgts);
131 AMDTraits<SuiteSparse_long> AMDobj;
132 double Control[AMD_CONTROL];
133 double Info[AMD_INFO];
135 amd_defaults(Control);
136 amd_control(Control);
140 perm = (lno_t *) (solution->getPermutationRCP().getRawPtr());
142 SuiteSparse_long *amd_offsets, *amd_edgeIds;
150 SuiteSparse_long amd_nVtx=0;
154 SuiteSparse_long *amd_perm =
new SuiteSparse_long[amd_nVtx];
156 lno_t result = AMDobj.order(amd_nVtx, amd_offsets,
157 amd_edgeIds, amd_perm, Control, Info);
159 if (result != AMD_OK && result != AMD_OK_BUT_JUMBLED)
165 for (
size_t i = 0; i < nVtx; i++)
173 solution->setHavePerm(
true);
AlgAMD(const RCP< const typename Adapter::base_adapter_t > &adapter__, const RCP< Teuchos::ParameterList > &pl__, const RCP< const Teuchos::Comm< int > > &comm__, RCP< const Environment > &env__, const modelFlag_t &graphFlags__)
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
map_t::global_ordinal_type gno_t
Defines the OrderingSolution class.
Adapter::scalar_t scalar_t
int localOrder(const RCP< LocalOrderingSolution< typename Adapter::lno_t > > &solution)
Ordering method.
Algorithm defines the base class for all algorithms.
map_t::local_ordinal_type lno_t
static void ASSIGN(first_t &a, second_t b)
Traits class to handle conversions between gno_t/lno_t and TPL data types (e.g., ParMETIS's idx_t...
GraphModel defines the interface required for graph models.
static void ASSIGN_ARRAY(first_t **a, ArrayView< second_t > &b)
Defines the GraphModel interface.
static void DELETE_ARRAY(first_t **a)
int globalOrder(const RCP< GlobalOrderingSolution< typename Adapter::gno_t > > &)
Ordering method.