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
63typedef UF_long SuiteSparse_long;
73#ifdef HAVE_ZOLTAN2_AMD
74template <
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));
94class 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));
112template <
typename Adapter>
117 const RCP<const typename Adapter::base_adapter_t> adapter;
118 const RCP<Teuchos::ParameterList> pl;
119 const RCP<const Teuchos::Comm<int> > comm;
120 RCP<const Environment> env;
126 const RCP<const typename Adapter::base_adapter_t> &adapter__,
127 const RCP<Teuchos::ParameterList> &pl__,
128 const RCP<
const Teuchos::Comm<int> > &comm__,
129 RCP<const Environment> &env__,
131 ) : adapter(adapter__), pl(pl__), comm(comm__), env(env__), graphFlags(graphFlags__)
136 throw std::logic_error(
"AlgAMD does not yet support global ordering.");
142#ifndef HAVE_ZOLTAN2_AMD
144 throw std::runtime_error(
145 "BUILD ERROR: AMD requested but not compiled into Zoltan2.\n"
146 "Please set CMake flag Zoltan2_ENABLE_AMD:BOOL=ON.");
148 typedef typename Adapter::gno_t
gno_t;
149 typedef typename Adapter::lno_t
lno_t;
150 typedef typename Adapter::offset_t offset_t;
151 typedef typename Adapter::scalar_t
scalar_t;
156 const size_t nVtx = model->getLocalNumVertices();
159 ArrayView<const gno_t> edgeIds;
160 ArrayView<const offset_t> offsets;
161 ArrayView<StridedData<lno_t, scalar_t> > wgts;
164 model->getEdgeList(edgeIds, offsets, wgts);
167 AMDTraits<SuiteSparse_long> AMDobj;
168 double Control[AMD_CONTROL];
169 double Info[AMD_INFO];
171 amd_defaults(Control);
172 amd_control(Control);
176 perm = (
lno_t *) (solution->getPermutationRCP().getRawPtr());
178 SuiteSparse_long *amd_offsets, *amd_edgeIds;
186 SuiteSparse_long amd_nVtx=0;
190 SuiteSparse_long *amd_perm =
new SuiteSparse_long[amd_nVtx];
192 lno_t result = AMDobj.order(amd_nVtx, amd_offsets,
193 amd_edgeIds, amd_perm, Control, Info);
195 if (result != AMD_OK && result != AMD_OK_BUT_JUMBLED)
201 for (
size_t i = 0; i < nVtx; i++)
209 solution->setHavePerm(
true);
Defines the GraphModel interface.
Defines the OrderingSolution class.
Traits class to handle conversions between gno_t/lno_t and TPL data types (e.g., ParMETIS's idx_t,...
int globalOrder(const RCP< GlobalOrderingSolution< typename Adapter::gno_t > > &)
Ordering method.
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__)
int localOrder(const RCP< LocalOrderingSolution< typename Adapter::lno_t > > &solution)
Ordering method.
Algorithm defines the base class for all algorithms.
Adapter::scalar_t scalar_t
GraphModel defines the interface required for graph models.
Created by mbenlioglu on Aug 31, 2020.
std::bitset< NUM_MODEL_FLAGS > modelFlag_t
static void DELETE_ARRAY(first_t **a)
static void ASSIGN_ARRAY(first_t **a, ArrayView< second_t > &b)
static void ASSIGN(first_t &a, second_t b)