14 #ifndef _ZOLTAN2_ADAPTER_HPP_
15 #define _ZOLTAN2_ADAPTER_HPP_
17 #include "Kokkos_StaticCrsGraph.hpp"
18 #include <Kokkos_Core.hpp>
69 template <
typename User>
79 using host_t =
typename Kokkos::HostSpace::memory_space;
128 ids = kokkosIds.data();
140 const gno_t * ptr_ids;
144 auto host_ids = Kokkos::create_mirror_view(non_const_ids);
146 host_ids(i) = ptr_ids[i];
148 Kokkos::deep_copy(non_const_ids, host_ids);
182 Kokkos::View<scalar_t **, device_t> kokkos_wgts_2d;
184 Kokkos::View<scalar_t *, device_t> kokkos_wgts;
185 wgt = Kokkos::subview(kokkos_wgts_2d, Kokkos::ALL, idx).data();
200 wgt = Kokkos::View<scalar_t **, device_t>(
202 auto host_wgt = Kokkos::create_mirror_view(wgt);
208 for(
size_t n = 0; n < this->
getLocalNumIDs() * stride; n += stride) {
209 host_wgt(i++,j) = ptr_wgts[n];
212 Kokkos::deep_copy(wgt, host_wgt);
285 template <
typename Adapter>
299 const Teuchos::Comm<int> &comm)
const;
303 template <
typename User>
309 using host_t =
typename Kokkos::HostSpace::memory_space;
317 int coordDim)
const = 0;
329 template <
typename User>
332 template <
typename User,
typename UserCoord=User>
340 template <
typename User>
342 const char *fileprefix,
343 const Teuchos::Comm<int> &comm
346 int np = comm.getSize();
347 int me = comm.getRank();
349 size_t nLocalIDs = this->getLocalNumIDs();
356 std::string filenamestr = fileprefix;
357 filenamestr = filenamestr +
".graph";
358 const char *filename = filenamestr.c_str();
361 Teuchos::reduceAll(comm, Teuchos::REDUCE_SUM, 1, &nLocalIDs, &nGlobalIDs);
363 int nWgts = this->getNumWeightsPerID();
365 for (
int p = 0; p < np; p++) {
374 fp.open(filename, std::ios::out);
377 fp << nGlobalIDs <<
" " << 0 <<
" "
378 << (nWgts ?
"010" :
"000") <<
" "
379 << (nWgts > 1 ? std::to_string(nWgts) :
" ") << std::endl;
383 fp.open(filename, std::ios::app);
390 int *strides =
new int[nWgts];
391 for (
int n = 0; n < nWgts; n++)
392 getWeightsView(wgts[n], strides[n], n);
395 for (
size_t i = 0; i < nLocalIDs; i++) {
396 for (
int n = 0; n < nWgts; n++)
397 fp << wgts[n][i*strides[n]] <<
" ";
414 std::string filenamestr = fileprefix;
415 filenamestr = filenamestr +
".assign";
416 const char *filename = filenamestr.c_str();
418 for (
int p = 0; p < np; p++) {
427 fp.open(filename, std::ios::out);
431 fp.open(filename, std::ios::app);
435 this->getPartsView(parts);
437 for (
size_t i = 0; i < nLocalIDs; i++) {
438 fp << (parts != NULL ? parts[i] : me) <<
"\n";
Kokkos::View< const scalar_t *, device_t > ConstWeightsDeviceView1D
virtual int getNumWeightsPerID() const
Returns the number of weights per object. Number of weights per object should be zero or greater...
virtual VectorAdapter< UserCoord > * getCoordinateInput() const =0
virtual void getPartsDeviceView(Kokkos::View< part_t *, device_t > &inputPart) const
virtual void getIDsView(const gno_t *&ids) const
Provide a pointer to this process' identifiers.
typename InputTraits< UserCoord >::scalar_t scalar_t
typename Kokkos::HostSpace::memory_space host_t
Kokkos::View< scalar_t *, device_t > WeightsDeviceView1D
Kokkos::View< scalar_t **, Kokkos::LayoutLeft, device_t > CoordsDeviceView
virtual void getIDsDeviceView(ConstIdsDeviceView &deviceIds) const
Provide a Kokkos view (Device side) to this process' identifiers.
#define Z2_THROW_NOT_IMPLEMENTED
virtual void setCoordinateInput(VectorAdapter< UserCoord > *coordData)=0
typename node_t::device_type device_t
typename ScalarsDeviceView::HostMirror ScalarsHostView
Defines the PartitioningSolution class.
typename InputTraits< UserCoord >::part_t part_t
Kokkos::View< const gno_t *, device_t > ConstIdsDeviceView
typename ConstScalarsDeviceView::HostMirror ConstScalarsHostView
virtual void getWeightsDeviceView(WeightsDeviceView1D &deviceWgts, int idx=0) const
Provide a Kokkos view (Device side) of the weights.
virtual void getWeightsView(const scalar_t *&wgt, int &stride, int idx=0) const
Provide pointer to a weight array with stride.
virtual void getIDsKokkosView(ConstIdsDeviceView &ids) const
Provide a Kokkos view to this process' identifiers.
typename IdsDeviceView::HostMirror IdsHostView
typename WeightsDeviceView::HostMirror WeightsHostView
Kokkos::View< const scalar_t *, device_t > ConstScalarsDeviceView
typename InputTraits< UserCoord >::node_t node_t
typename CoordsDeviceView::HostMirror CoordsHostView
virtual void getWeightsKokkosView(Kokkos::View< scalar_t **, device_t > &wgt) const
Provide kokkos view of weights.
virtual ~BaseAdapterRoot()=default
A PartitioningSolution is a solution to a partitioning problem.
virtual void getPartsView(const part_t *&inputPart) const
Provide pointer to an array containing the input part assignment for each ID. The input part informat...
typename ConstOffsetsDeviceView::HostMirror ConstOffsetsHostView
typename InputTraits< UserCoord >::gno_t gno_t
typename ConstIdsDeviceView::HostMirror ConstIdsHostView
void generateWeightFileOnly(const char *fileprefix, const Teuchos::Comm< int > &comm) const
BaseAdapterType
An enum to identify general types of adapters.
identifier data, just a list of IDs
VectorAdapter defines the interface for vector input.
typename ConstWeightsDeviceView1D::HostMirror ConstWeightsHostView1D
BaseAdapter defines methods required by all Adapters.
Kokkos::View< gno_t *, device_t > IdsDeviceView
virtual void getPartsHostView(Kokkos::View< part_t *, host_t > &inputPart) const
Kokkos::View< offset_t *, device_t > OffsetsDeviceView
typename InputTraits< UserCoord >::offset_t offset_t
typename WeightsDeviceView1D::HostMirror WeightsHostView1D
virtual void getWeightsHostView(WeightsHostView &hostWgts) const
Provide a Kokkos view (Host side) of the weights.
void applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
Apply a PartitioningSolution to an input.
virtual size_t getLocalNumIDs() const =0
Returns the number of objects on this process.
typename ConstWeightsDeviceView::HostMirror ConstWeightsHostView
virtual void getCoordinatesHostView(CoordsHostView &) const
Gathering definitions used in software development.
virtual void getCoordinatesDeviceView(CoordsDeviceView &elements) const
Kokkos::View< const scalar_t **, device_t > ConstWeightsDeviceView
Kokkos::View< scalar_t **, device_t > WeightsDeviceView
typename OffsetsDeviceView::HostMirror OffsetsHostView
Kokkos::View< scalar_t *, device_t > ScalarsDeviceView
virtual void getCoordinatesKokkosView(CoordsDeviceView &elements) const =0
virtual void getWeightsHostView(WeightsHostView1D &hostWgts, int idx=0) const
Provide a Kokkos view (Host side) of the weights.
virtual void getWeightsDeviceView(WeightsDeviceView &deviceWgts) const
Provide a Kokkos view (Device side) of the weights.
Kokkos::View< const offset_t *, device_t > ConstOffsetsDeviceView
typename InputTraits< UserCoord >::lno_t lno_t
virtual void getCoordinatesView(const scalar_t *&coords, int &stride, int coordDim) const =0
virtual enum BaseAdapterType adapterType() const =0
Returns the type of adapter.
virtual void getIDsHostView(ConstIdsHostView &hostIds) const
Provide a Kokkos view (Host side) to this process' identifiers.