50 #ifndef _ZOLTAN2_ALGAMD_HPP_
51 #define _ZOLTAN2_ALGAMD_HPP_
59 #ifdef HAVE_ZOLTAN2_AMD
61 #ifdef SUITESPARSE_MAIN_VERSION
62 #if SUITESPARSE_MAIN_VERSION < 4
63 typedef UF_long SuiteSparse_long;
73 #ifdef HAVE_ZOLTAN2_AMD
74 template <
typename Ordinal>
78 Ordinal order(Ordinal n,
const Ordinal *Ap,
const Ordinal *Ai,
79 Ordinal *perm,
double *control,
double *info);
86 int order(
int n,
const int *Ap,
const int *Ai,
int *perm,
87 double *control,
double *info)
89 return (amd_order(n, Ap, Ai, perm, control, info));
94 class AMDTraits<SuiteSparse_long>
97 long order(SuiteSparse_long n,
const SuiteSparse_long *Ap,
98 const SuiteSparse_long *Ai, SuiteSparse_long *perm,
99 double *control,
double *info)
101 return (amd_l_order(n, Ap, Ai, perm, control, info));
112 template <
typename Adapter>
117 const RCP<GraphModel<Adapter> > model;
118 const RCP<Teuchos::ParameterList> pl;
119 const RCP<const Teuchos::Comm<int> > comm;
125 const RCP<Teuchos::ParameterList> &pl__,
126 const RCP<
const Teuchos::Comm<int> > &comm__
127 ) : model(model__), pl(pl__), comm(comm__)
132 throw std::logic_error(
"AlgAMD does not yet support global ordering.");
138 #ifndef HAVE_ZOLTAN2_AMD
140 throw std::runtime_error(
141 "BUILD ERROR: AMD requested but not compiled into Zoltan2.\n"
142 "Please set CMake flag Zoltan2_ENABLE_AMD:BOOL=ON.");
144 typedef typename Adapter::gno_t
gno_t;
145 typedef typename Adapter::lno_t
lno_t;
146 typedef typename Adapter::offset_t offset_t;
147 typedef typename Adapter::scalar_t
scalar_t;
151 const size_t nVtx = model->getLocalNumVertices();
154 ArrayView<const gno_t> edgeIds;
155 ArrayView<const offset_t> offsets;
156 ArrayView<StridedData<lno_t, scalar_t> > wgts;
159 model->getEdgeList(edgeIds, offsets, wgts);
162 AMDTraits<SuiteSparse_long> AMDobj;
163 double Control[AMD_CONTROL];
164 double Info[AMD_INFO];
166 amd_defaults(Control);
167 amd_control(Control);
171 perm = (lno_t *) (solution->getPermutationRCP().getRawPtr());
173 SuiteSparse_long *amd_offsets, *amd_edgeIds;
181 SuiteSparse_long amd_nVtx=0;
185 SuiteSparse_long *amd_perm =
new SuiteSparse_long[amd_nVtx];
187 lno_t result = AMDobj.order(amd_nVtx, amd_offsets,
188 amd_edgeIds, amd_perm, Control, Info);
190 if (result != AMD_OK && result != AMD_OK_BUT_JUMBLED)
196 for (
size_t i = 0; i < nVtx; i++)
204 solution->setHavePerm(
true);
Defines the OrderingSolution class.
AlgAMD(const RCP< GraphModel< Adapter > > &model__, const RCP< Teuchos::ParameterList > &pl__, const RCP< const Teuchos::Comm< int > > &comm__)
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.
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.