90#ifndef DOXYGEN_SHOULD_SKIP_THIS
118 const scalar_t *entries,
int entryStride=1,
120 const scalar_t *wgts=NULL,
int wgtStride=1):
121 numIds_(numIds), idList_(ids),
122 numEntriesPerID_(1), entries_(),
123 numWeights_(usewgts==true), weights_()
125 std::vector<const scalar_t *> values;
126 std::vector<int> strides;
127 std::vector<const scalar_t *> weightValues;
128 std::vector<int> weightStrides;
130 values.push_back(entries);
131 strides.push_back(entryStride);
133 weightValues.push_back(wgts);
134 weightStrides.push_back(wgtStride);
137 createBasicVector(values, strides, weightValues, weightStrides);
166 std::vector<const scalar_t *> &entries, std::vector<int> &entryStride,
167 std::vector<const scalar_t *> &
weights, std::vector<int> &weightStrides):
168 numIds_(numIds), idList_(ids),
169 numEntriesPerID_(entries.size()), entries_(),
170 numWeights_(
weights.size()), weights_()
172 createBasicVector(entries, entryStride,
weights, weightStrides);
204 int xStride=1,
int yStride=1,
int zStride=1,
205 bool usewgts=
false,
const scalar_t *wgts=NULL,
207 numIds_(numIds), idList_(ids), numEntriesPerID_(0), entries_(),
208 numWeights_(usewgts==true), weights_()
210 std::vector<const scalar_t *> values, weightValues;
211 std::vector<int> strides, weightStrides;
215 strides.push_back(xStride);
219 strides.push_back(yStride);
223 strides.push_back(zStride);
229 weightValues.push_back(wgts);
230 weightStrides.push_back(wgtStride);
232 createBasicVector(values, strides, weightValues, weightStrides);
247 typename node_t::device_type> &ids)
const
249 ids = this->kokkos_ids_;
255 typename node_t::device_type> &wgt)
const
257 wgt = kokkos_weights_;
262 if (idx < 0 || idx >= numWeights_) {
263 std::ostringstream emsg;
264 emsg << __FILE__ <<
":" << __LINE__
265 <<
" Invalid vector index " << idx << std::endl;
266 throw std::runtime_error(emsg.str());
269 weights_[idx].getStridedList(length,
weights, stride);
280 if (idx < 0 || idx >= numEntriesPerID_) {
281 std::ostringstream emsg;
282 emsg << __FILE__ <<
":" << __LINE__
283 <<
" Invalid vector index " << idx << std::endl;
284 throw std::runtime_error(emsg.str());
287 entries_[idx].getStridedList(length, entries, stride);
292 Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
293 typename node_t::device_type> & entries)
const
295 entries = kokkos_entries_;
300 const gno_t *idList_;
302 int numEntriesPerID_;
303 ArrayRCP<StridedData<lno_t, scalar_t> > entries_ ;
305 Kokkos::View<gno_t *, typename node_t::device_type> kokkos_ids_;
308 Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
309 typename node_t::device_type> kokkos_entries_;
312 ArrayRCP<StridedData<lno_t, scalar_t> > weights_;
314 Kokkos::View<scalar_t**, typename node_t::device_type> kokkos_weights_;
316 void createBasicVector(
317 std::vector<const scalar_t *> &entries, std::vector<int> &entryStride,
318 std::vector<const scalar_t *> &
weights, std::vector<int> &weightStrides)
320 typedef StridedData<lno_t,scalar_t> input_t;
324 kokkos_ids_ = Kokkos::View<gno_t *, typename node_t::device_type>(
325 Kokkos::ViewAllocateWithoutInitializing(
"ids"), numIds_);
326 auto host_kokkos_ids_ = Kokkos::create_mirror_view(kokkos_ids_);
327 for(
int n = 0; n < numIds_; ++n) {
328 host_kokkos_ids_(n) = idList_[n];
330 Kokkos::deep_copy(kokkos_ids_, host_kokkos_ids_);
334 entries_ = arcp(
new input_t[numEntriesPerID_], 0, numEntriesPerID_,
true);
335 for (
int v=0; v < numEntriesPerID_; v++) {
336 if (entryStride.size()) stride = entryStride[v];
337 ArrayRCP<const scalar_t> eltV(entries[v], 0, stride*numIds_,
false);
338 entries_[v] = input_t(eltV, stride);
343 kokkos_entries_ = Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
344 typename node_t::device_type>(
345 Kokkos::ViewAllocateWithoutInitializing(
"entries"),
346 numIds_, numEntriesPerID_);
351 auto host_kokkos_entries =
352 Kokkos::create_mirror_view(this->kokkos_entries_);
354 for (
int idx=0; idx < numEntriesPerID_; idx++) {
355 entries_[idx].getStridedList(length, entriesPtr, stride);
356 size_t fill_index = 0;
357 for(
int n = 0; n < numIds_; ++n) {
358 host_kokkos_entries(fill_index++,idx) = entriesPtr[n*stride];
361 Kokkos::deep_copy(this->kokkos_entries_, host_kokkos_entries);
366 weights_ = arcp(
new input_t [numWeights_], 0, numWeights_,
true);
367 for (
int w=0; w < numWeights_; w++){
368 if (weightStrides.size()) stride = weightStrides[w];
369 ArrayRCP<const scalar_t> wgtV(
weights[w], 0, stride*numIds_,
false);
370 weights_[w] = input_t(wgtV, stride);
374 kokkos_weights_ = Kokkos::View<
scalar_t**,
375 typename node_t::device_type>(
376 Kokkos::ViewAllocateWithoutInitializing(
"kokkos weights"),
377 numIds_, numWeights_);
380 auto host_weight_temp_values =
381 Kokkos::create_mirror_view(this->kokkos_weights_);
382 for(
int idx = 0; idx < numWeights_; ++idx) {
385 weights_[idx].getStridedList(length, weightsPtr, stride);
386 size_t fill_index = 0;
387 for(
size_t n = 0; n < length; n += stride) {
388 host_weight_temp_values(fill_index++,idx) = weightsPtr[n];
391 Kokkos::deep_copy(this->kokkos_weights_, host_weight_temp_values);
BasicVectorAdapter(lno_t numIds, const gno_t *ids, std::vector< const scalar_t * > &entries, std::vector< int > &entryStride, std::vector< const scalar_t * > &weights, std::vector< int > &weightStrides)
Constructor for multivector (a set of vectors sharing the same global numbering and data distribution...
BasicVectorAdapter(lno_t numIds, const gno_t *ids, const scalar_t *x, const scalar_t *y, const scalar_t *z, int xStride=1, int yStride=1, int zStride=1, bool usewgts=false, const scalar_t *wgts=NULL, int wgtStride=1)
A simple constructor for coordinate-based problems with dimension 1, 2 or 3 and (optionally) one weig...