74#ifndef DOXYGEN_SHOULD_SKIP_THIS
75 typedef typename Adapter::scalar_t scalar_t;
76 typedef typename Adapter::gno_t
gno_t;
77 typedef typename Adapter::lno_t
lno_t;
78 typedef typename Adapter::node_t node_t;
79 typedef StridedData<lno_t, scalar_t> input_t;
90 const RCP<const Environment> &env,
91 const RCP<
const Comm<int> > &comm,
modelFlag_t &modelFlags);
100 return numGlobalIdentifiers_;
112 ArrayView<input_t> &wgts)
const
114 Ids = ArrayView<const gno_t>();
115 wgts = weights_.view(0, nUserWeights_);
118 Ids = ArrayView<const gno_t>(
119 reinterpret_cast<const gno_t*
>(gids_.getRawPtr()), n);
125 Kokkos::View<const gno_t *, typename node_t::device_type> &Ids,
126 Kokkos::View<scalar_t **, typename node_t::device_type> &wgts)
const {
128 adapter_->getIDsKokkosView(Ids);
129 adapter_->getWeightsKokkosView(wgts);
145 gno_t numGlobalIdentifiers_;
146 const RCP<const Environment> env_;
147 const RCP<const Comm<int> > comm_;
148 ArrayRCP<const gno_t> gids_;
149 const RCP<const Adapter> adapter_;
151 ArrayRCP<input_t> weights_;
157 const RCP<const Adapter> &ia,
158 const RCP<const Environment> &env,
159 const RCP<
const Comm<int> > &comm,
161 numGlobalIdentifiers_(), env_(env), comm_(comm),
162 gids_(), adapter_(ia), nUserWeights_(0), weights_()
165 size_t nLocalIds = ia->getLocalNumIDs();
166 gno_t lsum = nLocalIds;
167 reduceAll<int, gno_t>(*comm_, Teuchos::REDUCE_SUM, 1, &lsum,
168 &numGlobalIdentifiers_);
171 int tmp = ia->getNumWeightsPerID();
173 Teuchos::reduceAll<int, int>(*comm, Teuchos::REDUCE_MAX, 1,
174 &tmp, &nUserWeights_);
179 Array<const scalar_t *> wgts(nUserWeights_, (
const scalar_t *)NULL);
180 Array<int> wgtStrides(nUserWeights_, 0);
182 if (nUserWeights_ > 0){
183 input_t *w =
new input_t [nUserWeights_];
184 weights_ = arcp<input_t>(w, 0, nUserWeights_);
187 const gno_t *gids=NULL;
191 ia->getIDsView(gids);
192 for (
int idx=0; idx < nUserWeights_; idx++)
193 ia->getWeightsView(wgts[idx], wgtStrides[idx], idx);
198 gids_ = arcp(gids, 0, nLocalIds,
false);
200 if (nUserWeights_ > 0){
201 for (
int idx=0; idx < nUserWeights_; idx++){
202 ArrayRCP<const scalar_t> wgtArray(wgts[idx], 0,
203 nLocalIds*wgtStrides[idx],
false);
204 weights_[idx] = input_t(wgtArray, wgtStrides[idx]);
209 env_->memory(
"After construction of identifier model");